openfoam/applications/utilities/preProcessing/createZeroDirectory/solverTemplate.C
mattijs 9e3ce4ec7f Merge branch 'master' of develop.openfoam.com:Development/OpenFOAM-plus into feature-shared-file
Conflicts:
	applications/utilities/mesh/advanced/refinementLevel/refinementLevel.C
	applications/utilities/mesh/generation/foamyMesh/conformalVoronoiMesh/initialPointsMethod/pointFile/pointFile.C
	applications/utilities/miscellaneous/foamHelp/helpTypes/helpBoundary/helpBoundary.C
	applications/utilities/postProcessing/graphics/PV3Readers/PV3FoamReader/vtkPV3Foam/vtkPV3FoamUpdateInfo.C
	applications/utilities/postProcessing/graphics/PV4Readers/PV4FoamReader/vtkPV4Foam/vtkPV4FoamUpdateInfo.C
	applications/utilities/postProcessing/turbulence/createTurbulenceFields/createTurbulenceFields.C
	applications/utilities/postProcessing/velocityField/Co/Co.C
	applications/utilities/postProcessing/velocityField/Pe/Pe.C
	applications/utilities/preProcessing/applyBoundaryLayer/applyBoundaryLayer.C
	applications/utilities/preProcessing/changeDictionary/changeDictionary.C
	applications/utilities/preProcessing/setFields/setFields.C
	applications/utilities/surface/surfaceMeshConvert/surfaceMeshConvert.C
	applications/utilities/surface/surfaceMeshExport/surfaceMeshExport.C
	applications/utilities/surface/surfaceMeshImport/surfaceMeshImport.C
	applications/utilities/surface/surfaceRedistributePar/surfaceRedistributePar.C
	src/OpenFOAM/db/IOobject/IOobject.C
	src/OpenFOAM/db/IOobjects/CompactIOList/CompactIOList.C
	src/OpenFOAM/db/IOobjects/IOField/IOField.C
	src/OpenFOAM/db/IOobjects/IOList/IOList.C
	src/OpenFOAM/db/IOobjects/IOPtrList/IOPtrList.C
	src/OpenFOAM/db/IOobjects/IOdictionary/IOdictionary.C
	src/OpenFOAM/db/Time/findInstance.C
	src/OpenFOAM/db/regIOobject/regIOobject.C
	src/OpenFOAM/db/regIOobject/regIOobjectI.H
	src/OpenFOAM/db/regIOobject/regIOobjectRead.C
	src/OpenFOAM/db/regIOobject/regIOobjectWrite.C
	src/OpenFOAM/meshes/polyMesh/mapPolyMesh/mapDistribute/IOmapDistribute.C
	src/OpenFOAM/meshes/polyMesh/polyBoundaryMesh/polyBoundaryMesh.C
	src/OpenFOAM/meshes/polyMesh/zones/ZoneMesh/ZoneMesh.C
	src/dynamicMesh/fvMeshDistribute/IOmapDistributePolyMesh.C
	src/dynamicMesh/motionSolver/componentDisplacement/componentDisplacementMotionSolver.C
	src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/hexRef8Data.C
	src/dynamicMesh/polyTopoChange/polyTopoChange/hexRef8/refinementHistory.C
	src/dynamicMesh/polyTopoChange/polyTopoChanger/polyTopoChanger.C
	src/edgeMesh/edgeMeshFormats/edgeMesh/edgeMeshFormat.C
	src/edgeMesh/extendedEdgeMesh/extendedEdgeMeshFormats/extendedEdgeMeshFormat/extendedEdgeMeshFormat.C
	src/edgeMesh/extendedEdgeMesh/extendedFeatureEdgeMesh/extendedFeatureEdgeMesh.C
	src/fvMotionSolver/fvMotionSolvers/displacement/interpolation/displacementInterpolationMotionSolver.C
	src/fvMotionSolver/pointPatchFields/derived/uniformInterpolatedDisplacement/uniformInterpolatedDisplacementPointPatchVectorField.C
	src/lagrangian/basic/Cloud/CloudIO.C
	src/meshTools/sets/cellSources/fieldToCell/fieldToCell.C
	src/postProcessing/foamCalcFunctions/basic/addSubtract/addSubtract.C
	src/postProcessing/functionObjects/field/fieldCoordinateSystemTransform/fieldCoordinateSystemTransformTemplates.C
	src/postProcessing/functionObjects/field/readFields/readFieldsTemplates.C
	src/thermophysicalModels/radiation/radiationModels/fvDOM/radiativeIntensityRay/radiativeIntensityRay.C
	src/triSurface/triSurface/surfacePatch/surfacePatchIOList.C
2016-01-25 16:29:04 +00:00

415 lines
10 KiB
C

/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015-2016 OpenCFD Ltd.
-------------------------------------------------------------------------------
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 "solverTemplate.H"
#include "Time.H"
#include "IOPtrList.H"
#include "polyMesh.H"
#include "regionProperties.H"
using namespace Foam;
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
template<>
const char* Foam::NamedEnum<Foam::solverTemplate::solverType, 4>::names[] =
{
"compressible",
"incompressible",
"buoyant",
"unknown"
};
}
const Foam::NamedEnum<Foam::solverTemplate::solverType, 4>
Foam::solverTemplate::solverTypeNames_;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::word Foam::solverTemplate::readFromDict
(
IOobject& dictHeader,
const word& entryName
) const
{
if (!dictHeader.typeHeaderOk<IOdictionary>(true))
{
FatalErrorInFunction
<< "Unable to open file "
<< dictHeader.objectPath()
<< exit(FatalError);
}
IOdictionary dict(dictHeader);
return dict.lookup(entryName);
}
Foam::dictionary Foam::solverTemplate::readFluidFieldTemplates
(
const word& regionName,
const fileName& baseDir,
const dictionary& solverDict,
const Time& runTime
) const
{
Info<< " Reading fluid field templates";
if (regionName == word::null)
{
Info<< endl;
}
else
{
Info<< " for region " << regionName << endl;
}
dictionary fieldTemplates = solverDict.subDict("fluidFields");
const fileName turbModelDir(baseDir/"models"/"turbulence");
word turbulenceModel("laminar"); // default to laminar
const dictionary fieldModels(solverDict.subDict("fluidModels"));
word turbulenceType = "none";
if (fieldModels.readIfPresent("turbulenceModel", turbulenceType))
{
word simulationType(word::null);
if (turbulenceType == "turbulenceModel")
{
IOdictionary turbulenceProperties
(
IOobject
(
"turbulenceProperties",
runTime.constant(),
regionName,
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
turbulenceProperties.lookup("simulationType") >> simulationType;
if (simulationType == "laminar")
{
// Leave turbulenceModel as laminar
}
else if (simulationType == "RAS")
{
turbulenceProperties.subDict(simulationType).lookup("RASModel")
>> turbulenceModel;
}
else if (simulationType == "LES")
{
turbulenceProperties.subDict(simulationType).lookup("LESModel")
>> turbulenceModel;
}
else
{
FatalErrorInFunction
<< "Unhandled turbulence model option " << simulationType
<< ". Valid options are laminar, RAS, LES"
<< exit(FatalError);
}
}
else
{
FatalErrorInFunction
<< "Unhandled turbulence model option " << simulationType
<< ". Valid options are turbulenceModel"
<< exit(FatalError);
}
}
Info<< " Selecting " << turbulenceType << ": " << turbulenceModel
<< endl;
IOdictionary turbModelDict
(
IOobject
(
fileName(turbModelDir/turbulenceModel),
runTime,
IOobject::MUST_READ
)
);
// Merge common fluid fields
fieldTemplates.merge(turbModelDict.subDict("fluidFields"));
// Merge specific compressible or incompressible fluid fields
switch (solverType_)
{
case stIncompressible:
{
fieldTemplates.merge(turbModelDict.subDict("incompressibleFields"));
break;
}
case stCompressible:
case stBuoyant:
{
fieldTemplates.merge(turbModelDict.subDict("compressibleFields"));
break;
}
default:
{
// do nothing
}
}
return fieldTemplates;
}
Foam::dictionary Foam::solverTemplate::readSolidFieldTemplates
(
const word& regionName,
const dictionary& solverDict
) const
{
Info<< " Reading solid field templates for region " << regionName
<< endl;
// nothing more to do for solids
return solverDict.subDict("solidFields");
}
void Foam::solverTemplate::setRegionProperties
(
const dictionary& fieldDict,
const word& regionType,
const word& regionName,
const label regionI
)
{
regionTypes_[regionI] = regionType,
regionNames_[regionI] = regionName,
fieldNames_[regionI] = fieldDict.toc();
fieldTypes_[regionI].setSize(fieldNames_[regionI].size());
fieldDimensions_[regionI].setSize(fieldNames_[regionI].size());
forAll(fieldNames_[regionI], i)
{
const word& fieldName = fieldNames_[regionI][i];
const dictionary& dict = fieldDict.subDict(fieldName);
dict.lookup("type") >> fieldTypes_[regionI][i];
fieldDimensions_[regionI].set
(
i,
new dimensionSet(dict.lookup("dimensions"))
);
}
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::solverTemplate::solverTemplate
(
const fileName& baseDir,
const Time& runTime,
const word& solverName
)
:
solverType_(stUnknown),
multiRegion_(false),
regionTypes_(),
fieldNames_(),
fieldTypes_(),
fieldDimensions_()
{
IOdictionary solverDict
(
IOobject
(
fileName(baseDir/"solvers"/solverName),
runTime,
IOobject::MUST_READ
)
);
Info<< "Selecting " << solverName << ": ";
solverType_ = solverTypeNames_.read(solverDict.lookup("solverType"));
Info<< solverTypeNames_[solverType_];
multiRegion_ = readBool(solverDict.lookup("multiRegion"));
if (multiRegion_)
{
Info<< ", multi-region";
}
else
{
Info<< ", single-region";
}
Info<< " case" << endl;
if (multiRegion_)
{
// read regionProperties
regionProperties rp(runTime);
const wordList fluidNames(rp["fluid"]);
const wordList solidNames(rp["solid"]);
const label nRegion = fluidNames.size() + solidNames.size();
regionTypes_.setSize(nRegion);
regionNames_.setSize(nRegion);
fieldNames_.setSize(nRegion);
fieldTypes_.setSize(nRegion);
fieldDimensions_.setSize(nRegion);
// read templates for solver lists of avaliable
// - fields and dimensions required for the solver
// - models
label regionI = 0;
forAll(fluidNames, i)
{
const dictionary fieldDict
(
readFluidFieldTemplates
(
fluidNames[i],
baseDir,
solverDict,
runTime
)
);
setRegionProperties(fieldDict, "fluid", fluidNames[i], regionI++);
}
forAll(solidNames, i)
{
const dictionary fieldDict
(
readSolidFieldTemplates
(
solidNames[i],
solverDict
)
);
setRegionProperties(fieldDict, "solid", solidNames[i], regionI++);
}
}
else
{
regionTypes_.setSize(1);
regionNames_.setSize(1);
fieldNames_.setSize(1);
fieldTypes_.setSize(1);
fieldDimensions_.setSize(1);
// read templates for solver lists of avaliable
// - fields and dimensions required for the solver
// - models
const dictionary fieldDict
(
readFluidFieldTemplates
(
word::null, // use region = null for single-region cases
baseDir,
solverDict,
runTime
)
);
setRegionProperties(fieldDict, "fluid", word::null, 0);
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
Foam::word Foam::solverTemplate::type() const
{
return solverTypeNames_[solverType_];
}
bool Foam::solverTemplate::multiRegion() const
{
return multiRegion_;
}
label Foam::solverTemplate::nRegion() const
{
return regionTypes_.size();
}
const Foam::word& Foam::solverTemplate::regionType(const label regionI) const
{
return regionTypes_[regionI];
}
const Foam::word& Foam::solverTemplate::regionName(const label regionI) const
{
return regionNames_[regionI];
}
const Foam::wordList& Foam::solverTemplate::fieldNames
(
const label regionI
) const
{
return fieldNames_[regionI];
}
const Foam::wordList& Foam::solverTemplate::fieldTypes
(
const label regionI
) const
{
return fieldTypes_[regionI];
}
const Foam::PtrList<Foam::dimensionSet>& Foam::solverTemplate::fieldDimensions
(
const label regionI
) const
{
return fieldDimensions_[regionI];
}
// ************************************************************************* //