Пример #1
0
void Domain1D::restore(const XML_Node& dom, doublereal* soln, int loglevel)
{
    vector_fp values;
    vector<XML_Node*> nodes;
    dom.getChildren("floatArray", nodes);
    for (size_t i = 0; i < nodes.size(); i++) {
        string title = nodes[i]->attrib("title");
        getFloatArray(*nodes[i], values, false);
        if (values.size() != nComponents()) {
            throw CanteraError("Domain1D::restore", "Got an array of length " +
                               int2str(values.size()) + " when one of length " +
                               int2str(nComponents()) + "was expected.");
        }
        if (title == "abstol_transient") {
            m_atol_ts = values;
        } else if (title == "reltol_transient") {
            m_rtol_ts = values;
        } else if (title == "abstol_steady") {
            m_atol_ss = values;
        } else if (title == "reltol_steady") {
            m_rtol_ss = values;
        } else {
            throw CanteraError("Domain1D::restore",
                               "Got an unexpected array, '" + title + "'");
        }
    }
}
Пример #2
0
void CollisionComponentManager::findCollisions(HitEventQueue& hitQueue) {
	compactArray();

	// TODO: Less brute-force approach.
	// TODO: Support shapes other than aligned boxes
	HitEvent hit;
	for(int ci0 = 0; ci0 < int(nComponents()); ++ci0) {
		CollisionComponent& c0 = _components[ci0];
		if(!c0.entity().isEnabledRec() || !c0.isEnabled()
		|| !c0.shape() || c0.shape()->type() != SHAPE_ALIGNED_BOX)
			continue;
		hit.entities[0] = c0.entity();

		for(int ci1 = ci0 + 1; ci1 < int(nComponents()); ++ci1) {
			CollisionComponent& c1 = _components[ci1];

			if(!c1.entity().isEnabledRec() || !c1.isEnabled()
			|| !c1.shape() || c1.shape()->type() != SHAPE_ALIGNED_BOX
			|| (c0.hitMask() & c1.hitMask())    == 0
			|| (c0.hitMask() & c1.ignoreMask()) != 0
			|| (c1.hitMask() & c0.ignoreMask()) != 0)
				continue;
			hit.entities[1] = c1.entity();

			hit.boxes[0] = c0.worldAlignedBox();
			hit.boxes[1] = c1.worldAlignedBox();

			if(!hit.boxes[0].intersection(hit.boxes[1]).isEmpty())
				hitQueue.push_back(hit);
		}
	}
}
Пример #3
0
XML_Node& Domain1D::save(XML_Node& o, const doublereal* const sol)
{
    XML_Node& d = o.addChild("domain");
    d.addAttribute("points", nPoints());
    d.addAttribute("components", nComponents());
    d.addAttribute("id", id());
    addFloatArray(d, "abstol_transient", nComponents(), &m_atol_ts[0]);
    addFloatArray(d, "reltol_transient", nComponents(), &m_rtol_ts[0]);
    addFloatArray(d, "abstol_steady", nComponents(), &m_atol_ss[0]);
    addFloatArray(d, "reltol_steady", nComponents(), &m_rtol_ss[0]);
    return d;
}
Пример #4
0
 void Inlet1D::
 save(XML_Node& o, doublereal* soln) {
     doublereal* s = soln + loc();
     XML_Node& inlt = o.addChild("domain");
     inlt.addAttribute("id",id());
     inlt.addAttribute("points",1);
     inlt.addAttribute("type","inlet");
     inlt.addAttribute("components",nComponents());
     for (int k = 0; k < nComponents(); k++) {
         ctml::addFloat(inlt, componentName(k), s[k], "", "",lowerBound(k), upperBound(k));
     }
 }
Пример #5
0
 void ReactingSurf1D::
 save(XML_Node& o, doublereal* soln) {
     doublereal* s = soln + loc();
     //XML_Node& inlt = o.addChild("inlet");
     XML_Node& inlt = o.addChild("domain");
     inlt.addAttribute("id",id());
     inlt.addAttribute("points",1);
     inlt.addAttribute("type","surface");
     inlt.addAttribute("components",nComponents());
     for (int k = 0; k < nComponents(); k++) {
         ctml::addFloat(inlt, componentName(k), s[k], "", "",0.0, 1.0);
     }
 }
Пример #6
0
 void OutletRes1D::
 save(XML_Node& o, doublereal* soln) {
     XML_Node& outlt = o.addChild("domain");
     outlt.addAttribute("id",id());
     outlt.addAttribute("points",1);
     outlt.addAttribute("type","outletres");
     outlt.addAttribute("components",nComponents());
 }
Пример #7
0
 void Symm1D::
 save(XML_Node& o, doublereal* soln) {
     XML_Node& symm = o.addChild("domain");
     symm.addAttribute("id",id());
     symm.addAttribute("points",1);
     symm.addAttribute("type","symmetry");
     symm.addAttribute("components",nComponents());
 }
Пример #8
0
size_t Domain1D::componentIndex(const std::string& name) const
{
    for (size_t n = 0; n < nComponents(); n++) {
        if (name == componentName(n)) {
            return n;
        }
    }
    throw CanteraError("Domain1D::componentIndex",
                       "no component named "+name);
}
XML_Node& Surf1D::save(XML_Node& o, const doublereal* const soln)
{
    const doublereal* s = soln + loc();
    XML_Node& inlt = Domain1D::save(o, soln);
    inlt.addAttribute("type","surface");
    for (size_t k = 0; k < nComponents(); k++) {
        addFloat(inlt, componentName(k), s[k]);
    }
    return inlt;
}
Пример #10
0
void Domain1D::restore(const XML_Node& dom, doublereal* soln, int loglevel)
{
    vector_fp values;
    vector<XML_Node*> nodes;
    dom.getChildren("floatArray", nodes);
    for (size_t i = 0; i < nodes.size(); i++) {
        string title = nodes[i]->attrib("title");
        getFloatArray(*nodes[i], values, false);
        if (values.size() != nComponents()) {
            if (loglevel > 0) {
                writelog("Warning: Domain1D::restore: Got an array of length " +
                         int2str(values.size()) + " when one of length " +
                         int2str(nComponents()) + " was expected. " +
                         "Tolerances for individual species may not be preserved.\n");
            }
            // The number of components will differ when restoring from a
            // mechanism with a different number of species. Assuming that
            // tolerances are the same for all species, we can just copy the
            // tolerance from the last species.
            if (!values.empty()) {
                values.resize(nComponents(), values[values.size()-1]);
            } else {
                // If the tolerance vector is empty, just leave the defaults
                // in place.
                continue;
            }
        }
        if (title == "abstol_transient") {
            m_atol_ts = values;
        } else if (title == "reltol_transient") {
            m_rtol_ts = values;
        } else if (title == "abstol_steady") {
            m_atol_ss = values;
        } else if (title == "reltol_steady") {
            m_rtol_ss = values;
        } else {
            throw CanteraError("Domain1D::restore",
                               "Got an unexpected array, '" + title + "'");
        }
    }
}
Пример #11
0
int main(int argc, char *argv[])
{
	Graph G;

	G = readGraph(stdin);
	if (G == NULL)
		printf("Invalid graph\n");
	else {
		printf("Graph:\n"); showGraph(G); printf("\n");
		printf("# connected components = %d\n", nComponents(G));
	}

	return 0;
}
XML_Node& Inlet1D::save(XML_Node& o, const doublereal* const soln)
{
    const doublereal* s = soln + loc();
    XML_Node& inlt = Domain1D::save(o, soln);
    inlt.addAttribute("type","inlet");
    for (size_t k = 0; k < nComponents(); k++) {
        addFloat(inlt, componentName(k), s[k]);
    }
    for (size_t k=0; k < m_nsp; k++) {
        addFloat(inlt, "massFraction", m_yin[k], "",
                       m_flow->phase().speciesName(k));
    }
    return inlt;
}
Пример #13
0
bool CollisionComponentManager::hitTest(std::deque<EntityRef>& hits, const Box2& box, unsigned hitMask) {
	bool found = false;
	for(int ci = 0; ci < int(nComponents()); ++ci) {
		CollisionComponent& c = _components[ci];
		if(!c.entity().isEnabledRec() || !c.isEnabled()
		|| !c.shape() || c.shape()->type() != SHAPE_ALIGNED_BOX
		|| (hitMask & c.hitMask())    == 0
		|| (hitMask & c.ignoreMask()) != 0)
			continue;

		Box2    cbox = c.worldAlignedBox();
		if(!cbox.intersection(box).isEmpty()) {
			hits.push_back(c.entity());
			found = true;
		}
	}
	return found;
}