View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0003700 | OpenFOAM | Feature | public | 2021-07-28 12:57 | 2021-07-28 19:16 |
Reporter | mboesi | Assigned To | henry | ||
Priority | normal | Severity | tweak | Reproducibility | N/A |
Status | closed | Resolution | suspended | ||
Platform | all | OS | all | OS Version | all |
Product Version | dev | ||||
Summary | 0003700: A small modification of the look-up for the chemistry method could enable a smooth integration of custom developed models. | ||||
Description | The current selection of the chemistry method limits the available options to "standard" or "TDAC". The look-up procedure is rather complicated by checking if the method is "TDAC" and passing a word based on the boolean value. const word methodName ( chemistryTypeDict.lookupOrDefault<word> ( "method", chemistryTypeDict.lookupOrDefault<bool>("TDAC", false) ? "TDAC" : "standard" ) ); This look-up prevents any alternative chemistry methods (e.g. load balancing, etc.) from being used within the OF framework. Using alternative chemistry methods requires either modifications to the "basicChemistryModelNew.C" or lots of code duplication as a work around. Simplifying the look-up of the "method" to: const word methodName ( chemistryTypeDict.lookupOrDefault<word>("method", "standard") ); could solve this issue, while sill ensuring proper error handling if a non-existen chemistry model is chosen (a modified version of the basicChemistryModelNew.C is attached). To allow more flexibility to the developments also the chemistry reduction and tabulation could be templated to enable them for custom chemistry models - I have not done this so far, but could provide the files if requested. | ||||
Steps To Reproduce | N/A | ||||
Tags | No tags attached. | ||||
|
basicChemistryModelNew.C (6,818 bytes)
/*---------------------------------------------------------------------------*\ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | Website: https://openfoam.org \\ / A nd | Copyright (C) 2012-2021 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License This file is part of OpenFOAM. OpenFOAM is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. OpenFOAM is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>. \*---------------------------------------------------------------------------*/ #include "basicChemistryModel.H" #include "basicThermo.H" #include "compileTemplate.H" // * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * // Foam::autoPtr<Foam::basicChemistryModel> Foam::basicChemistryModel::New ( const fluidReactionThermo& thermo ) { IOdictionary chemistryDict ( IOobject ( thermo.phasePropertyName("chemistryProperties"), thermo.T().mesh().time().constant(), thermo.T().mesh(), IOobject::MUST_READ, IOobject::NO_WRITE, false ) ); if (!chemistryDict.isDict("chemistryType")) { FatalErrorInFunction << "Template parameter based chemistry solver selection is no " << "longer supported. Please create a chemistryType dictionary" << "instead." << endl << endl << "For example, the entry:" << endl << " chemistrySolver ode<standardChemistryModel<" << "rhoChemistryModel,sutherland<specie<janaf<perfectGas>," << "sensibleInternalEnergy>>>>" << endl << endl << "becomes:" << endl << " chemistryType" << endl << " {" << endl << " solver ode;" << endl << " method standard;" << endl << " }" << exit(FatalError); } const dictionary& chemistryTypeDict = chemistryDict.subDict("chemistryType"); const word solverName = chemistryTypeDict.lookupBackwardsCompatible<word> ( {"solver", "chemistrySolver"} ); const word methodName ( chemistryTypeDict.lookupOrDefault<word>("method", "standard") ); dictionary chemistryTypeDictNew; chemistryTypeDictNew.add("solver", solverName); chemistryTypeDictNew.add("method", methodName); Info<< "Selecting chemistry solver " << chemistryTypeDictNew << endl; const word chemSolverNameName = solverName + '<' + methodName + '<' + thermo.thermoName() + ">>"; typename thermoConstructorTable::iterator cstrIter = thermoConstructorTablePtr_->find(chemSolverNameName); if (cstrIter == thermoConstructorTablePtr_->end()) { if ( dynamicCode::allowSystemOperations && !dynamicCode::resolveTemplate(basicChemistryModel::typeName).empty() ) { List<Pair<word>> substitutions ( basicThermo::thermoNameComponents(thermo.thermoName()) ); substitutions.append({"solver", solverName}); substitutions.append({"method", methodName}); compileTemplate chemistryModel ( basicChemistryModel::typeName, chemSolverNameName, substitutions ); cstrIter = thermoConstructorTablePtr_->find(chemSolverNameName); if (cstrIter == thermoConstructorTablePtr_->end()) { FatalErrorInFunction << "Compilation and linkage of " << basicChemistryModel::typeName << " type " << nl << "chemistryType" << chemistryTypeDict << nl << nl << "failed." << exit(FatalError); } } else { FatalErrorInFunction << "Unknown " << typeName_() << " type " << chemistryTypeDictNew << endl; const wordList names(thermoConstructorTablePtr_->sortedToc()); wordList thisCmpts; thisCmpts.append(word::null); thisCmpts.append(word::null); thisCmpts.append ( basicThermo::splitThermoName(thermo.thermoName(), 5) ); List<wordList> validNames; validNames.append(wordList(2, word::null)); validNames[0][0] = "solver"; validNames[0][1] = "method"; forAll(names, i) { const wordList cmpts(basicThermo::splitThermoName(names[i], 7)); if ( SubList<word>(cmpts, 5, 2) == SubList<word>(thisCmpts, 5, 2) ) { validNames.append(SubList<word>(cmpts, 2)); } } FatalErrorInFunction << "Valid " << validNames[0][0] << '/' << validNames[0][1] << " combinations for this thermodynamic model are:" << endl << endl; printTable(validNames, FatalErrorInFunction); FatalErrorInFunction << endl; List<wordList> validCmpts; validCmpts.append(wordList(7, word::null)); validCmpts[0][0] = "solver"; validCmpts[0][1] = "method"; validCmpts[0][2] = "transport"; validCmpts[0][3] = "thermo"; validCmpts[0][4] = "equationOfState"; validCmpts[0][5] = "specie"; validCmpts[0][6] = "energy"; forAll(names, i) { validCmpts.append(basicThermo::splitThermoName(names[i], 7)); } FatalErrorInFunction << "All " << validCmpts[0][0] << '/' << validCmpts[0][1] << "/thermodynamics combinations are:" << endl << endl; printTable(validCmpts, FatalErrorInFunction); FatalErrorInFunction << exit(FatalError); } } return autoPtr<basicChemistryModel>(cstrIter()(thermo)); } // ************************************************************************* // |
|
The change you propose is not compatible with the generalisation of the chemistry implementation we are currently working on. If you would like to get involved in OpenFOAM core development and maintenance see https://openfoam.org/dev/how-to-contribute/ https://openfoam.org/maintenance/ Creating a specialised load-balancing implementation just for chemistry is not appropriate for OpenFOAM given the number of different parts of the code which would benefit from load-balancing and the limited maintenance funding we receive; we need a single general implementation to avoid unnecessary maintenance overhead. If you would like to get involved in a general load-balancing implementation please contact us directly. |
Date Modified | Username | Field | Change |
---|---|---|---|
2021-07-28 12:57 | mboesi | New Issue | |
2021-07-28 12:57 | mboesi | File Added: basicChemistryModelNew.C | |
2021-07-28 19:16 | henry | Assigned To | => henry |
2021-07-28 19:16 | henry | Status | new => closed |
2021-07-28 19:16 | henry | Resolution | open => suspended |
2021-07-28 19:16 | henry | Note Added: 0012116 |