Kinetics* KineticsFactory::newKinetics(XML_Node& phaseData, vector<ThermoPhase*> th) { // Look for a child of the XML element phase called "kinetics". It has an // attribute name "model". Store the value of that attribute in the variable // kintype string kintype = phaseData.child("kinetics")["model"]; // Create a kinetics object of the desired type Kinetics* k = newKinetics(kintype); // Now that we have the kinetics manager, we can import the reaction // mechanism into it. importKinetics(phaseData, th, k); // Return the pointer to the kinetics manager return k; }
bool buildSolutionFromXML(XML_Node& root, const std::string& id, const std::string& nm, ThermoPhase* th, Kinetics* kin) { XML_Node* x = get_XML_NameID(nm, string("#")+id, &root); if (!x) { return false; } // Fill in the ThermoPhase object by querying the const XML_Node tree // located at x. importPhase(*x, th); // Create a vector of ThermoPhase pointers of length 1 having the current th // ThermoPhase as the entry. std::vector<ThermoPhase*> phases{th}; // Fill in the kinetics object k, by querying the const XML_Node tree // located by x. The source terms and eventually the source term vector will // be constructed from the list of ThermoPhases in the vector, phases. importKinetics(*x, phases, kin); return true; }
Kinetics* KineticsFactory:: newKinetics(XML_Node& phaseData, vector<ThermoPhase*> th) { /* * Look for a child of the xml element phase called * "kinetics". It has an attribute name "model". * Store the value of that attribute in the variable kintype */ string kintype = phaseData.child("kinetics")["model"]; /* * look up the string kintype in the list of known * kinetics managers (list is kept at the top of this file). * Translate it to an integer value, ikin. */ int ikin=-1; int n; for (n = 0; n < ntypes; n++) { if (kintype == _types[n]) { ikin = _itypes[n]; } } /* * Assign the kinetics manager based on the value of ikin. * Kinetics managers are classes derived from the base * Kinetics class. Unknown kinetics managers will throw a * CanteraError here. */ Kinetics* k=0; switch (ikin) { case 0: k = new Kinetics; break; case cGasKinetics: k = new GasKinetics; break; case cGRI30: k = new GRI_30_Kinetics; break; case cInterfaceKinetics: k = new InterfaceKinetics; break; case cEdgeKinetics: k = new EdgeKinetics; break; case cAqueousKinetics: k = new AqueousKinetics; break; default: throw UnknownKineticsModel("KineticsFactory::newKinetics", kintype); } // Now that we have the kinetics manager, we can // import the reaction mechanism into it. importKinetics(phaseData, th, k); // Return the pointer to the kinetics manager return k; }