Merge branch 'develop' into radiation

Conflicts:
	applications/utilities/preProcessing/viewFactorsGen/shootRays.H
	src/lagrangian/intermediate/submodels/addOns/radiation/absorptionEmission/cloudAbsorptionEmission/cloudAbsorptionEmission.C
	src/thermophysicalModels/radiation/derivedFvPatchFields/radiationCoupledBase/radiationCoupledBase.C
	src/thermophysicalModels/radiation/derivedFvPatchFields/radiationCoupledBase/radiationCoupledBase.H
	src/thermophysicalModels/radiation/radiationModels/fvDOM/fvDOM/fvDOM.C
	src/thermophysicalModels/radiation/radiationModels/fvDOM/radiativeIntensityRay/radiativeIntensityRay.C
	tutorials/mesh/parallel/filter/0.org/T
This commit is contained in:
mattijs
2015-12-11 09:50:43 +00:00
6811 changed files with 211130 additions and 50126 deletions

View File

@ -1,7 +1,10 @@
EXE_INC = \
-I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \
-I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/transportModels \
-I$(LIB_SRC)/transportModels/compressible/lnInclude \
-I$(LIB_SRC)/transportModels/incompressible/singlePhaseTransportModel \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
@ -9,7 +12,10 @@ EXE_INC = \
EXE_LIBS = \
-lturbulenceModels \
-lincompressibleTurbulenceModels \
-lcompressibleTurbulenceModels \
-lincompressibleTransportModels \
-lcompressibleTransportModels \
-lgenericPatchFields \
-lfiniteVolume \
-lmeshTools
-lmeshTools \
-lfvOptions

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -33,12 +33,18 @@ Description
the thickness coefficient supplied via the option -Cbl. If both options
are provided -ybl is used.
Compressible modes is automatically selected based on the existence of the
"thermophysicalProperties" dictionary required to construct the
thermodynamics package.
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "singlePhaseTransportModel.H"
#include "turbulentTransportModel.H"
#include "turbulentFluidThermoModel.H"
#include "wallDist.H"
#include "processorFvPatchField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -46,6 +52,266 @@ Description
static const scalar Cmu(0.09);
static const scalar kappa(0.41);
void correctProcessorPatches(volScalarField& vf)
{
if (!Pstream::parRun())
{
return;
}
// Not possible to use correctBoundaryConditions on fields as they may
// use local info as opposed to the constraint values employed here,
// but still need to update processor patches
volScalarField::GeometricBoundaryField& bf = vf.boundaryField();
forAll(bf, patchI)
{
if (isA<processorFvPatchField<scalar> >(bf[patchI]))
{
bf[patchI].initEvaluate();
}
}
forAll(bf, patchI)
{
if (isA<processorFvPatchField<scalar> >(bf[patchI]))
{
bf[patchI].evaluate();
}
}
}
template<class TurbulenceModel>
Foam::tmp<Foam::volScalarField> calcK
(
TurbulenceModel& turbulence,
const volScalarField& mask,
const volScalarField& nut,
const volScalarField& y,
const dimensionedScalar& ybl,
const scalar Cmu,
const scalar kappa
)
{
// Turbulence k
tmp<volScalarField> tk = turbulence->k();
volScalarField& k = tk();
scalar ck0 = pow025(Cmu)*kappa;
k = (1 - mask)*k + mask*sqr(nut/(ck0*min(y, ybl)));
// Do not correct BC
// - operation may use inconsistent fields wrt these local manipulations
// k.correctBoundaryConditions();
correctProcessorPatches(k);
Info<< "Writing k\n" << endl;
k.write();
return tk;
}
template<class TurbulenceModel>
Foam::tmp<Foam::volScalarField> calcEpsilon
(
TurbulenceModel& turbulence,
const volScalarField& mask,
const volScalarField& k,
const volScalarField& y,
const dimensionedScalar& ybl,
const scalar Cmu,
const scalar kappa
)
{
// Turbulence epsilon
tmp<volScalarField> tepsilon = turbulence->epsilon();
volScalarField& epsilon = tepsilon();
scalar ce0 = ::pow(Cmu, 0.75)/kappa;
epsilon = (1 - mask)*epsilon + mask*ce0*k*sqrt(k)/min(y, ybl);
epsilon.max(SMALL);
// Do not correct BC
// - operation may use inconsistent fields wrt these local manipulations
// epsilon.correctBoundaryConditions();
correctProcessorPatches(epsilon);
Info<< "Writing epsilon\n" << endl;
epsilon.write();
return tepsilon;
}
void calcOmega
(
const fvMesh& mesh,
const volScalarField& mask,
const volScalarField& k,
const volScalarField& epsilon
)
{
// Turbulence omega
IOobject omegaHeader
(
"omega",
mesh.time().timeName(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
);
if (omegaHeader.headerOk())
{
volScalarField omega(omegaHeader, mesh);
dimensionedScalar k0("SMALL", k.dimensions(), SMALL);
omega = (1 - mask)*omega + mask*epsilon/(Cmu*k + k0);
omega.max(SMALL);
// Do not correct BC
// - operation may use inconsistent fields wrt these local
// manipulations
// omega.correctBoundaryConditions();
correctProcessorPatches(omega);
Info<< "Writing omega\n" << endl;
omega.write();
}
}
void setField
(
const fvMesh& mesh,
const word& fieldName,
const volScalarField& value
)
{
IOobject fldHeader
(
fieldName,
mesh.time().timeName(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
);
if (fldHeader.headerOk())
{
volScalarField fld(fldHeader, mesh);
fld = value;
// Do not correct BC
// - operation may use inconsistent fields wrt these local
// manipulations
// fld.correctBoundaryConditions();
correctProcessorPatches(fld);
Info<< "Writing " << fieldName << nl << endl;
fld.write();
}
}
void calcCompressible
(
const fvMesh& mesh,
const volScalarField& mask,
const volVectorField& U,
const volScalarField& y,
const dimensionedScalar& ybl
)
{
const Time& runTime = mesh.time();
autoPtr<fluidThermo> pThermo(fluidThermo::New(mesh));
fluidThermo& thermo = pThermo();
volScalarField rho(thermo.rho());
// Update/re-write phi
#include "compressibleCreatePhi.H"
phi.write();
autoPtr<compressible::turbulenceModel> turbulence
(
compressible::turbulenceModel::New
(
rho,
U,
phi,
thermo
)
);
// Calculate nut - reference nut is calculated by the turbulence model
// on its construction
tmp<volScalarField> tnut = turbulence->nut();
volScalarField& nut = tnut();
volScalarField S(mag(dev(symm(fvc::grad(U)))));
nut = (1 - mask)*nut + mask*sqr(kappa*min(y, ybl))*::sqrt(2)*S;
// Do not correct BC - wall functions will 'undo' manipulation above
// by using nut from turbulence model
correctProcessorPatches(nut);
nut.write();
tmp<volScalarField> k =
calcK(turbulence, mask, nut, y, ybl, Cmu, kappa);
tmp<volScalarField> epsilon =
calcEpsilon(turbulence, mask, k, y, ybl, Cmu, kappa);
calcOmega(mesh, mask, k, epsilon);
setField(mesh, "nuTilda", nut);
}
void calcIncompressible
(
const fvMesh& mesh,
const volScalarField& mask,
const volVectorField& U,
const volScalarField& y,
const dimensionedScalar& ybl
)
{
const Time& runTime = mesh.time();
// Update/re-write phi
#include "createPhi.H"
phi.write();
singlePhaseTransportModel laminarTransport(U, phi);
autoPtr<incompressible::turbulenceModel> turbulence
(
incompressible::turbulenceModel::New(U, phi, laminarTransport)
);
tmp<volScalarField> tnut = turbulence->nut();
// Calculate nut - reference nut is calculated by the turbulence model
// on its construction
volScalarField& nut = tnut();
volScalarField S(mag(dev(symm(fvc::grad(U)))));
nut = (1 - mask)*nut + mask*sqr(kappa*min(y, ybl))*::sqrt(2)*S;
// Do not correct BC - wall functions will 'undo' manipulation above
// by using nut from turbulence model
correctProcessorPatches(nut);
nut.write();
tmp<volScalarField> k =
calcK(turbulence, mask, nut, y, ybl, Cmu, kappa);
tmp<volScalarField> epsilon =
calcEpsilon(turbulence, mask, k, y, ybl, Cmu, kappa);
calcOmega(mesh, mask, k, epsilon);
setField(mesh, "nuTilda", nut);
}
int main(int argc, char *argv[])
{
@ -55,6 +321,8 @@ int main(int argc, char *argv[])
"turbulence fields based on the 1/7th power-law."
);
#include "addRegionOption.H"
argList::addOption
(
"ybl",
@ -67,17 +335,12 @@ int main(int argc, char *argv[])
"scalar",
"boundary-layer thickness as Cbl * mean distance to wall"
);
argList::addBoolOption
(
"writenut",
"write nut field"
);
#include "setRootCase.H"
if (!args.optionFound("ybl") && !args.optionFound("Cbl"))
{
FatalErrorIn(args.executable())
FatalErrorInFunction
<< "Neither option 'ybl' or 'Cbl' have been provided to calculate "
<< "the boundary-layer thickness.\n"
<< "Please choose either 'ybl' OR 'Cbl'."
@ -85,7 +348,7 @@ int main(int argc, char *argv[])
}
else if (args.optionFound("ybl") && args.optionFound("Cbl"))
{
FatalErrorIn(args.executable())
FatalErrorInFunction
<< "Both 'ybl' and 'Cbl' have been provided to calculate "
<< "the boundary-layer thickness.\n"
<< "Please choose either 'ybl' OR 'Cbl'."
@ -93,7 +356,7 @@ int main(int argc, char *argv[])
}
#include "createTime.H"
#include "createMesh.H"
#include "createNamedMesh.H"
#include "createFields.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -117,113 +380,24 @@ int main(int argc, char *argv[])
Info<< "Writing U\n" << endl;
U.write();
// Update/re-write phi
#include "createPhi.H"
phi.write();
singlePhaseTransportModel laminarTransport(U, phi);
autoPtr<incompressible::turbulenceModel> turbulence
if
(
incompressible::turbulenceModel::New(U, phi, laminarTransport)
);
if (isA<incompressible::RASModel>(turbulence()))
IOobject
(
basicThermo::dictName,
runTime.constant(),
mesh
).headerOk()
)
{
// Calculate nut - reference nut is calculated by the turbulence model
// on its construction
tmp<volScalarField> tnut = turbulence->nut();
volScalarField& nut = tnut();
volScalarField S(mag(dev(symm(fvc::grad(U)))));
nut = (1 - mask)*nut + mask*sqr(kappa*min(y, ybl))*::sqrt(2)*S;
// do not correct BC - wall functions will 'undo' manipulation above
// by using nut from turbulence model
if (args.optionFound("writenut"))
{
Info<< "Writing nut" << endl;
nut.write();
}
//--- Read and modify turbulence fields
// Turbulence k
tmp<volScalarField> tk = turbulence->k();
volScalarField& k = tk();
scalar ck0 = pow025(Cmu)*kappa;
k = (1 - mask)*k + mask*sqr(nut/(ck0*min(y, ybl)));
// do not correct BC - operation may use inconsistent fields wrt these
// local manipulations
// k.correctBoundaryConditions();
Info<< "Writing k\n" << endl;
k.write();
// Turbulence epsilon
tmp<volScalarField> tepsilon = turbulence->epsilon();
volScalarField& epsilon = tepsilon();
scalar ce0 = ::pow(Cmu, 0.75)/kappa;
epsilon = (1 - mask)*epsilon + mask*ce0*k*sqrt(k)/min(y, ybl);
// do not correct BC - wall functions will use non-updated k from
// turbulence model
// epsilon.correctBoundaryConditions();
Info<< "Writing epsilon\n" << endl;
epsilon.write();
// Turbulence omega
IOobject omegaHeader
(
"omega",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
);
if (omegaHeader.headerOk())
{
volScalarField omega(omegaHeader, mesh);
dimensionedScalar k0("VSMALL", k.dimensions(), VSMALL);
omega = (1 - mask)*omega + mask*epsilon/(Cmu*k + k0);
// do not correct BC - wall functions will use non-updated k from
// turbulence model
// omega.correctBoundaryConditions();
Info<< "Writing omega\n" << endl;
omega.write();
}
// Turbulence nuTilda
IOobject nuTildaHeader
(
"nuTilda",
runTime.timeName(),
mesh,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
);
if (nuTildaHeader.headerOk())
{
volScalarField nuTilda(nuTildaHeader, mesh);
nuTilda = nut;
// do not correct BC
// nuTilda.correctBoundaryConditions();
Info<< "Writing nuTilda\n" << endl;
nuTilda.write();
}
calcCompressible(mesh, mask, U, y, ybl);
}
else
{
calcIncompressible(mesh, mask, U, y, ybl);
}
Info<< nl << "ExecutionTime = " << runTime.elapsedCpuTime() << " s"
<< " ClockTime = " << runTime.elapsedClockTime() << " s"

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2014 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -74,7 +74,7 @@ int main(int argc, char *argv[])
runTime.graphFormat()
);
Info<< "end" << endl;
Info<< "End" << nl << endl;
return 0;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -420,7 +420,7 @@ int main(int argc, char *argv[])
instantList times = timeSelector::selectIfPresent(runTime, args);
if (times.size() < 1)
{
FatalErrorIn(args.executable())
FatalErrorInFunction
<< "No times selected." << exit(FatalError);
}
runTime.setTime(times[0], 0);
@ -612,41 +612,51 @@ int main(int argc, char *argv[])
}
else
{
// Read dictionary. (disable class type checking so we can load
// field)
// Read dictionary
// Note: disable class type checking so we can load field
Info<< "Loading dictionary " << fieldName << endl;
const word oldTypeName = IOdictionary::typeName;
const_cast<word&>(IOdictionary::typeName) = word::null;
IOdictionary fieldDict
IOobject fieldHeader
(
IOobject
(
fieldName,
instance,
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE,
false
)
fieldName,
instance,
mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE,
false
);
const_cast<word&>(IOdictionary::typeName) = oldTypeName;
// Fake type back to what was in field
const_cast<word&>(fieldDict.type()) = fieldDict.headerClassName();
if (fieldHeader.headerOk())
{
IOdictionary fieldDict(fieldHeader);
Info<< "Loaded dictionary " << fieldName
<< " with entries " << fieldDict.toc() << endl;
const_cast<word&>(IOdictionary::typeName) = oldTypeName;
// Get the replacement dictionary for the field
const dictionary& replaceDict = fieldIter().dict();
Info<< "Merging entries from " << replaceDict.toc() << endl;
// Fake type back to what was in field
const_cast<word&>(fieldDict.type()) =
fieldDict.headerClassName();
// Merge the replacements in
merge(fieldDict, replaceDict, literalRE, patchGroups);
Info<< "Loaded dictionary " << fieldName
<< " with entries " << fieldDict.toc() << endl;
Info<< "Writing modified fieldDict " << fieldName << endl;
fieldDict.regIOobject::write();
// Get the replacement dictionary for the field
const dictionary& replaceDict = fieldIter().dict();
Info<< "Merging entries from " << replaceDict.toc() << endl;
// Merge the replacements in
merge(fieldDict, replaceDict, literalRE, patchGroups);
Info<< "Writing modified fieldDict " << fieldName << endl;
fieldDict.regIOobject::write();
}
else
{
WarningInFunction
<< "Requested field to change " << fieldName
<< " does not exist in " << fieldHeader.path() << endl;
}
}
}

View File

@ -2,7 +2,7 @@
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile

View File

@ -1,9 +1,8 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/postProcessing/functionObjects/jobControl/lnInclude
EXE_LIBS = \
-lturbulenceModels \
-lcompressibleTurbulenceModels \
-lfiniteVolume \
-lmeshTools
-ljobControl

View File

@ -0,0 +1,10 @@
//
// addRegionOption.H
// ~~~~~~~~~~~~~~~~~
Foam::argList::addOption
(
"regions",
"(name1 .. nameN)",
"specify alternative mesh regions"
);

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-2014 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2013-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -26,15 +26,24 @@ Application
Description
Application to generate the patch geometry (points and faces) for use
with the externalCoupled boundary condition.
with the externalCoupled functionObject.
Usage:
Usage
- createExternalCoupledPatchGeometry \<patchGroup\> [OPTION]
createExternalCoupledPatchGeometry \<fieldName\>
\param -commsDir \<commsDir\> \n
Specify an alternative communications directory (default is comms
in the case directory)
On execution, the field \<fieldName\> is read, and its boundary conditions
interrogated for the presence of an \c externalCoupled type. If found,
the patch geometry (points and faces) for the coupled patches are output
\param -region \<name\> \n
Specify an alternative mesh region.
\param -regions (\<name1\> \<name2\> .. \<namen\>) \n
Specify alternative mesh regions. The region names will be sorted
alphabetically and a single composite name will be created
\<nameX\>_\<nameY\>.._\<nameZ\>
On execution, the combined patch geometry (points and faces) are output
to the communications directory.
Note:
@ -42,12 +51,12 @@ Note:
used for face addressing starts at index 0.
SeeAlso
externalCoupledMixedFvPatchField
externalCoupledFunctionObject
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "createExternalCoupledPatchGeometryTemplates.H"
#include "externalCoupledFunctionObject.H"
#include "IOobjectList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -55,29 +64,63 @@ SeeAlso
int main(int argc, char *argv[])
{
#include "addRegionOption.H"
argList::validArgs.append("fieldName");
#include "addRegionsOption.H"
argList::validArgs.append("patchGroup");
argList::addOption
(
"commsDir",
"dir",
"specify alternate communications directory. default is 'comms'"
);
#include "setRootCase.H"
#include "createTime.H"
#include "createNamedMesh.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
const word fieldName = args[1];
IOobjectList objects(IOobjectList(mesh, mesh.time().timeName()));
label processed = -1;
processField<scalar>(mesh, objects, fieldName, processed);
processField<vector>(mesh, objects, fieldName, processed);
processField<sphericalTensor>(mesh, objects, fieldName, processed);
processField<symmTensor>(mesh, objects, fieldName, processed);
processField<tensor>(mesh, objects, fieldName, processed);
if (processed == -1)
wordList regionNames(1, fvMesh::defaultRegion);
if (!args.optionReadIfPresent("region", regionNames[0]))
{
Info<< "Field " << fieldName << " not found" << endl;
args.optionReadIfPresent("regions", regionNames);
}
const wordRe patchGroup(args.argRead<wordRe>(1));
fileName commsDir(runTime.path()/"comms");
args.optionReadIfPresent("commsDir", commsDir);
// Make sure region names are in canonical order
stableSort(regionNames);
PtrList<const fvMesh> meshes(regionNames.size());
forAll(regionNames, i)
{
Info<< "Create mesh " << regionNames[i] << " for time = "
<< runTime.timeName() << nl << endl;
meshes.set
(
i,
new fvMesh
(
Foam::IOobject
(
regionNames[i],
runTime.timeName(),
runTime,
Foam::IOobject::MUST_READ
)
)
);
}
externalCoupledFunctionObject::writeGeometry
(
UPtrList<const fvMesh>(meshes),
commsDir,
patchGroup
);
Info<< "\nEnd\n" << endl;
return 0;

View File

@ -1,90 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013 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 "createExternalCoupledPatchGeometryTemplates.H"
#include "externalCoupledMixedFvPatchField.H"
#include "IOobjectList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
template<class Type>
void processField
(
const fvMesh& mesh,
const IOobjectList& objects,
const word& fieldName,
label& processed
)
{
if (processed != -1)
{
return;
}
typedef GeometricField<Type, fvPatchField, volMesh> fieldType;
const word timeName(mesh.time().timeName());
IOobjectList fieldObjbjects(objects.lookupClass(fieldType::typeName));
if (fieldObjbjects.lookup(fieldName) != NULL)
{
fieldType vtf(*fieldObjbjects.lookup(fieldName), mesh);
const typename fieldType::GeometricBoundaryField& bf =
vtf.boundaryField();
forAll(bf, patchI)
{
if (isA<externalCoupledMixedFvPatchField<Type> >(bf[patchI]))
{
Info<< "Generating external coupled geometry for field "
<< fieldName << endl;
const externalCoupledMixedFvPatchField<Type>& pf =
refCast<const externalCoupledMixedFvPatchField<Type> >
(
bf[patchI]
);
pf.writeGeometry();
processed = 1;
break;
}
}
if (processed != 1)
{
processed = 0;
Info<< "Field " << fieldName << " found, but does not have any "
<< externalCoupledMixedFvPatchField<Type>::typeName
<< " boundary conditions" << endl;
}
}
}
// ************************************************************************* //

View File

@ -1,49 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2013-2015 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/>.
\*---------------------------------------------------------------------------*/
#ifndef createExternalCoupledPatchGeometryTemplates_H
#define createExternalCoupledPatchGeometryTemplates_H
#include "word.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
template<class Type>
void processField(bool& processed, const word& fieldName);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
#include "createExternalCoupledPatchGeometryTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,7 @@
boundaryInfo.C
boundaryTemplates.C
caseInfo.C
solverTemplate.C
createZeroDirectory.C
EXE = $(FOAM_APPBIN)/createZeroDirectory

View File

@ -0,0 +1,11 @@
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/regionModels/regionModel/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-ldynamicMesh \
-lmeshTools \
-lregionModels

View File

@ -0,0 +1,198 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 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 "boundaryInfo.H"
#include "Time.H"
#include "polyMesh.H"
#include "processorPolyPatch.H"
using namespace Foam;
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
namespace Foam
{
defineTemplateTypeNameAndDebug(IOPtrList<entry>, 0);
}
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::IOPtrList<Foam::entry> Foam::boundaryInfo::readBoundaryDict
(
const Time& runTime,
const word& regionName
) const
{
Info<< " Reading mesh boundaries" << endl;
const_cast<word&>(IOPtrList<entry>::typeName) = polyBoundaryMesh::typeName;
IOPtrList<entry> boundaryPatchList
(
IOobject
(
"boundary",
runTime.findInstance(regionName/polyMesh::meshSubDir, "boundary"),
regionName/polyMesh::meshSubDir,
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
// remove zero-sized patches
PtrList<entry> boundaryPatchListNew;
forAll(boundaryPatchList, patchI)
{
const dictionary& dict = boundaryPatchList[patchI].dict();
const word pType = dict.lookup("type");
bool procPatch = pType == processorPolyPatch::typeName;
bool addPatch = true;
if (!procPatch)
{
label nFaces = readLabel(dict.lookup("nFaces"));
reduce(nFaces, sumOp<label>());
if (nFaces == 0)
{
addPatch = false;
}
}
if (addPatch)
{
boundaryPatchListNew.append(boundaryPatchList[patchI].clone());
}
}
boundaryPatchList.transfer(boundaryPatchListNew);
return boundaryPatchList;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::boundaryInfo::boundaryInfo(const Time& runTime, const word& regionName)
:
boundaryDict_(readBoundaryDict(runTime, regionName)),
names_(),
types_(),
constraint_(),
groups_(),
allGroupNames_()
{
names_.setSize(boundaryDict_.size());
types_.setSize(boundaryDict_.size());
constraint_.setSize(boundaryDict_.size(), false);
groups_.setSize(boundaryDict_.size());
forAll(boundaryDict_, patchI)
{
const dictionary& dict = boundaryDict_[patchI].dict();
names_[patchI] = dict.dictName();
dict.lookup("type") >> types_[patchI];
if (polyPatch::constraintType(types_[patchI]))
{
constraint_[patchI] = true;
}
if (dict.found("inGroups"))
{
dict.lookup("inGroups") >> groups_[patchI];
allGroupNames_.insert(groups_[patchI]);
}
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::wordList& Foam::boundaryInfo::names() const
{
return names_;
}
const Foam::wordList& Foam::boundaryInfo::types() const
{
return types_;
}
const Foam::boolList& Foam::boundaryInfo::constraint() const
{
return constraint_;
}
const Foam::List<Foam::wordList>& Foam::boundaryInfo::groups() const
{
return groups_;
}
const Foam::wordHashSet& Foam::boundaryInfo::allGroupNames() const
{
return allGroupNames_;
}
void Foam::boundaryInfo::setType(const label patchI, const word& condition)
{
if (constraint_[patchI])
{
// not overriding constraint types
return;
}
if (wordRe(".*[mM]apped.*", wordRe::DETECT).match(types_[patchI]))
{
// ugly hack to avoid overriding mapped types
return;
}
if (condition == "wall")
{
types_[patchI] = condition;
}
else
{
types_[patchI] = "patch";
}
dictionary& patchDict = boundaryDict_[patchI].dict();
patchDict.add("type", types_[patchI], true);
}
void Foam::boundaryInfo::write() const
{
boundaryDict_.write();
}
// ************************************************************************* //

View File

@ -0,0 +1,124 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 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/>.
Class
Foam::boundaryInfo
Description
Class to interrogate the polyMesh/boundary file to provide mesh patching
information, without the need to read the mesh.
\*---------------------------------------------------------------------------*/
#ifndef boundaryInfo_H
#define boundaryInfo_H
#include "boolList.H"
#include "wordList.H"
#include "HashSet.H"
#include "IOPtrList.H"
#include "entry.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class Time;
/*---------------------------------------------------------------------------*\
Class boundaryInfo Declaration
\*---------------------------------------------------------------------------*/
class boundaryInfo
{
// Private data
//- Boundary dictionary
IOPtrList<entry> boundaryDict_;
//- Patch names
wordList names_;
//- Patch types
wordList types_;
//- Constraint flag
boolList constraint_;
//- Groups per patch
List<wordList> groups_;
//- Set of all group names
wordHashSet allGroupNames_;
// Private member functions
//- Read the boundary dict
IOPtrList<entry> readBoundaryDict
(
const Time& runTime,
const word& regionName
) const;
public:
//- Constructor
boundaryInfo(const Time& runTime, const word& regionName);
// Public member functions
//- Patch names
const wordList& names() const;
//- Patch types
const wordList& types() const;
//- Constraint flag
const boolList& constraint() const;
//- Groups
const List<wordList>& groups() const;
//- Set of all group names
const wordHashSet& allGroupNames() const;
//- Set the patch type based on the condition
void setType(const label patchI, const word& condition);
//- Write the boundary dictionary
void write() const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,381 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 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 "boundaryTemplates.H"
#include "Time.H"
#include "IFstream.H"
#include "OStringStream.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::boundaryTemplates::boundaryTemplates
(
const fileName& baseDir,
const Time& runTime,
const word& solverType
)
:
templates_(dictionary::null),
options_(dictionary::null)
{
Info<< " Reading boundary templates" << endl;
fileName BCDir(baseDir/"boundaryConditions");
IOdictionary regionBCs
(
IOobject
(
fileName(BCDir/"boundaries"),
runTime,
IOobject::MUST_READ
)
);
forAllConstIter(dictionary, regionBCs, iter)
{
const word& regionType = iter().keyword();
wordList patchTypes(regionBCs.lookup(regionType));
dictionary regionTemplate = dictionary::null;
dictionary regionOptions = dictionary::null;
// read general boundary types
forAll(patchTypes, i)
{
IOdictionary dict
(
IOobject
(
fileName(BCDir/regionType/patchTypes[i]),
runTime,
IOobject::MUST_READ
)
);
regionTemplate.add(patchTypes[i], dictionary(dict));
}
// add solver type boundary types
forAll(patchTypes, i)
{
IOobject io
(
fileName(BCDir/regionType/solverType/patchTypes[i]),
runTime,
IOobject::MUST_READ
);
if (io.headerOk())
{
IOdictionary dict(io);
regionTemplate.subDict(patchTypes[i]).merge(dict);
}
}
// read general boundary options
forAll(patchTypes, i)
{
fileName optFile(BCDir/regionType/patchTypes[i] + "Options");
IFstream is(optFile);
if (is.good())
{
IOdictionary dict
(
IOobject
(
optFile,
runTime,
IOobject::MUST_READ
)
);
regionOptions.add(patchTypes[i], dictionary(dict));
}
}
// add solver type boundary options
forAll(patchTypes, i)
{
// options are optional - however, if file exists, assume that it
// is to be read
fileName optFile
(
BCDir/regionType/solverType/patchTypes[i] + "Options"
);
IFstream is(optFile);
if (is.good())
{
IOdictionary dict
(
IOobject
(
optFile,
runTime,
IOobject::MUST_READ
)
);
regionOptions.subDict(patchTypes[i]).merge(dict);
}
}
templates_.add(regionType, regionTemplate);
options_.add(regionType, regionOptions);
}
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::dictionary& Foam::boundaryTemplates::templates() const
{
return templates_;
}
Foam::dictionary Foam::boundaryTemplates::generatePatchDict
(
const word& regionPrefix,
const word& fieldName,
const word& condition,
const word& category,
const word& patchType,
const dictionary& conditionOptions
) const
{
const dictionary& regionTemplates = templates_.subDict(regionPrefix);
// look for inlet, outlet, wall etc
if (regionTemplates.found(category))
{
const dictionary& categoryDict(regionTemplates.subDict(category));
// look for subSonic, slip etc
if (categoryDict.found(patchType))
{
dictionary patchDict = categoryDict.subDict(patchType);
// add any options
if (patchDict.found("OPTIONS"))
{
const dictionary& regionOptions =
options_.subDict(regionPrefix);
if (!regionOptions.found(category))
{
FatalErrorInFunction
<< "No options available for category "
<< category << exit(FatalError);
}
const dictionary& dict = regionOptions.subDict(category);
const wordList requiredOptions(patchDict.lookup("OPTIONS"));
forAll(requiredOptions, i)
{
const word& option = requiredOptions[i];
word selected;
if (!conditionOptions.readIfPresent(option, selected))
{
FatalErrorInFunction
<< "Condition " << condition << ": "
<< "No option '" << option
<< "' available for category '" << category
<< "' and patch type '" << patchType
<< "'. Valid options are: "
<< conditionOptions.toc()
<< exit(FatalError);
}
if (!dict.found(option))
{
FatalErrorInFunction
<< "Condition " << condition << ": "
<< "No option '" << option
<< "' available for category '" << category
<< "' and patch type '" << patchType
<< "'. Valid options are " << dict.toc()
<< exit(FatalError);
}
const dictionary& optionDict = dict.subDict(option);
if (!optionDict.found(selected))
{
FatalErrorInFunction
<< "Condition " << condition << ": "
<< "No option '" << selected
<< "' available for category '" << category
<< "' and patch type '" << patchType
<< "'. Valid options are " << optionDict.toc()
<< exit(FatalError);
}
const dictionary& dict = optionDict.subDict(selected);
patchDict.merge(dict);
}
}
// look for field name
if (patchDict.found(fieldName))
{
dictionary dict(dictionary::null);
const dictionary& fieldDict(patchDict.subDict(fieldName));
forAllConstIter(IDLList<entry>, fieldDict, iter)
{
OStringStream oss;
oss << iter();
string s(oss.str());
s.replace(iter().keyword(), "");
s.replace
(
"VALUE",
"boundaryConditions." + condition + ".values"
);
dict.add(iter().keyword(), s.c_str());
}
return dict;
}
else
{
FatalErrorInFunction
<< "Condition " << condition << ": "
<< "No '" << patchType
<< "' condition found for field '" << fieldName
<< "' in category type '" << category << "'"
<< exit(FatalError);
}
}
else
{
FatalErrorInFunction
<< "Condition " << condition << ": "
<< "No '" << patchType << "' boundary types defined in "
<< categoryDict.dictName() << " templates. "
<< "Available types are: " << categoryDict.toc()
<< exit(FatalError);
}
}
else
{
FatalErrorInFunction
<< "Condition " << condition << ": "
<< "Invalid boundary condition type '" << patchType
<< "'. Valid types are:" << regionTemplates.toc()
<< exit(FatalError);
}
return dictionary::null;
}
void Foam::boundaryTemplates::checkPatch
(
const word& regionPrefix,
const word& condition,
const word& category,
const word& patchType
) const
{
const dictionary& regionTemplates = templates_.subDict(regionPrefix);
if (!regionTemplates.found(category))
{
FatalErrorInFunction
<< "Condition " << condition << ": "
<< "Unknown category '" << category
<< "'. Valid categories are: " << regionTemplates.toc()
<< exit(FatalError);
}
const dictionary& categoryDict = regionTemplates.subDict(category);
if (!categoryDict.found(patchType))
{
FatalErrorInFunction
<< "Condition " << condition << ": "
<< "Unknown type '" << patchType << "' in category '"
<< category << "'. Valid types are: " << categoryDict.toc()
<< exit(FatalError);
}
}
bool Foam::boundaryTemplates::optionsRequired
(
const word& regionPrefix,
const word& category,
const word& patchType
) const
{
const dictionary& regionTemplates = templates_.subDict(regionPrefix);
if (regionTemplates.found(category))
{
const dictionary& categoryDict(regionTemplates.subDict(category));
if (categoryDict.found(patchType))
{
const dictionary& patchDict = categoryDict.subDict(patchType);
if (patchDict.found("OPTIONS"))
{
return true;
}
}
else
{
FatalErrorInFunction
<< "No type '" << patchType << "' found in category '"
<< category << "'. Valid types are "
<< categoryDict.toc()
<< exit(FatalError);
}
}
else
{
FatalErrorInFunction
<< "No category '" << category << "' found in templates. "
<< "Valid categories are " << templates_.toc()
<< exit(FatalError);
}
return false;
}
// ************************************************************************* //

View File

@ -0,0 +1,118 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 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/>.
Class
Foam::boundaryTemplates
Description
Class to store boundary template specifications
Templates are typically stored centrally, and constructed in a hierarchical
manner. The main use is to convert the (user) specified conditions into
a form which can be inserted into each field file as dictionary entries.
\*---------------------------------------------------------------------------*/
#ifndef boundaryTemplates_H
#define boundaryTemplates_H
#include "dictionary.H"
#include "wordList.H"
#include "wordReList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class Time;
/*---------------------------------------------------------------------------*\
Class boundaryTemplates Declaration
\*---------------------------------------------------------------------------*/
class boundaryTemplates
{
// Private data
//- Dictionary of boundary templates
dictionary templates_;
//- Dictionary of boundary template options
dictionary options_;
public:
//- Constructor
boundaryTemplates
(
const fileName& baseDir,
const Time& runTime,
const word& solverType
);
// Public member functions
//- Return the dictionary of boundary templates
const dictionary& templates() const;
//- Generate a dictionary representation of patch boundary condition
dictionary generatePatchDict
(
const word& regionPrefix,
const word& fieldName,
const word& condition,
const word& category,
const word& patchType,
const dictionary& conditionOptions
) const;
//- Check that user supplied patch info is valid
void checkPatch
(
const word& regionPrefix,
const word& condition,
const word& category,
const word& patchType
) const;
//- Return true if condition requires additional user options
bool optionsRequired
(
const word& regionPrefix,
const word& category,
const word& patchType
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,256 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 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 "caseInfo.H"
#include "Time.H"
#include "boundaryInfo.H"
#include "boundaryTemplates.H"
using namespace Foam;
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::label Foam::caseInfo::findPatchConditionID
(
const label patchI,
const word& patchName
) const
{
const wordList& patchGroups = boundaryInfo_.groups()[patchI];
// Assign condition according to last condition applied, wins
forAllReverse(conditionNames_, conditionI)
{
const wordReList& patchNames = patchNames_[conditionI];
forAll(patchNames, nameI)
{
if (patchNames[nameI] == patchName)
{
// Check for explicit match
return conditionI;
}
else if (patchNames[nameI].match(patchName))
{
// Check wildcards
return conditionI;
}
else
{
// Check for group match
forAll(patchGroups, groupI)
{
if (patchNames[nameI] == patchGroups[groupI])
{
return conditionI;
}
}
}
}
}
FatalErrorInFunction
<< "Boundary patch " << patchName << " not defined"
<< exit(FatalError);
return -1;
}
void Foam::caseInfo::updateGeometricBoundaryField()
{
forAll(boundaryInfo_.names(), i)
{
const word& patchName = boundaryInfo_.names()[i];
if (!boundaryInfo_.constraint()[i])
{
// Condition ID to apply to mesh boundary patch name
const label conditionI = findPatchConditionID(i, patchName);
const word& category = patchCategories_[conditionI];
boundaryInfo_.setType(i, category);
}
}
boundaryInfo_.write();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::caseInfo::caseInfo(const Time& runTime, const word& regionName)
:
properties_
(
IOobject
(
"caseProperties",
runTime.system(),
regionName,
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
),
boundaryInfo_(runTime, regionName),
bcDict_(properties_.subDict("boundaryConditions")),
conditionNames_(bcDict_.toc()),
patchNames_(conditionNames_.size()),
patchCategories_(conditionNames_.size()),
patchTypes_(conditionNames_.size())
{
// Read the (user-supplied) boundary condition information
Info<< " Reading case properties" << endl;
forAll(conditionNames_, i)
{
const dictionary& dict = bcDict_.subDict(conditionNames_[i]);
dict.lookup("category") >> patchCategories_[i];
dict.lookup("type") >> patchTypes_[i];
dict.lookup("patches") >> patchNames_[i];
}
updateGeometricBoundaryField();
}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
void Foam::caseInfo::checkPatches
(
const word& regionPrefix,
const boundaryTemplates& bcTemplates
) const
{
// Check that all conditions have been specified correctly wrt templates
forAll(conditionNames_, i)
{
bcTemplates.checkPatch
(
regionPrefix,
conditionNames_[i],
patchCategories_[i],
patchTypes_[i]
);
}
}
const Foam::List<Foam::wordReList>& Foam::caseInfo::patchNames() const
{
return patchNames_;
}
const Foam::word& Foam::caseInfo::conditionName(const label patchI) const
{
return conditionNames_[patchI];
}
const Foam::word& Foam::caseInfo::patchCategory(const label patchI) const
{
return patchCategories_[patchI];
}
const Foam::word& Foam::caseInfo::patchType(const label patchI) const
{
return patchTypes_[patchI];
}
Foam::dictionary Foam::caseInfo::generateBoundaryField
(
const word& regionPrefix,
const word& fieldName,
const boundaryTemplates& bcTemplates
) const
{
dictionary boundaryField = dictionary::null;
forAll(boundaryInfo_.names(), j)
{
const word& patchName = boundaryInfo_.names()[j];
if (boundaryInfo_.constraint()[j])
{
dictionary patchDict = dictionary::null;
patchDict.add("type", boundaryInfo_.types()[j]);
// Add value for processor patches
patchDict.add("value", "${:internalField}");
boundaryField.add(patchName.c_str(), patchDict);
}
else
{
// Condition ID to apply to mesh boundary patch name
const label conditionI = findPatchConditionID(j, patchName);
if (conditionI == -1)
{
FatalErrorInFunction
<< "Unable to find patch " << patchName
<< " in list of boundary conditions"
<< exit(FatalError);
}
const word& condition = conditionNames_[conditionI];
const word& category = patchCategories_[conditionI];
const word& patchType = patchTypes_[conditionI];
dictionary optionDict = dictionary::null;
if (bcTemplates.optionsRequired(regionPrefix, category, patchType))
{
optionDict = bcDict_.subDict(condition).subDict("options");
}
// Create the patch dictionary entry
dictionary patchDict
(
bcTemplates.generatePatchDict
(
regionPrefix,
fieldName,
condition,
category,
patchType,
optionDict
)
);
boundaryField.add(patchName.c_str(), patchDict);
}
}
return boundaryField;
}
// ************************************************************************* //

View File

@ -0,0 +1,141 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 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/>.
Class
Foam::caseInfo
Description
Class to hold information related to the simaulation case.
\*---------------------------------------------------------------------------*/
#ifndef caseInfo_H
#define caseInfo_H
#include "boolList.H"
#include "labelList.H"
#include "wordList.H"
#include "HashSet.H"
#include "wordReList.H"
#include "IOdictionary.H"
#include "boundaryInfo.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class Time;
class boundaryTemplates;
/*---------------------------------------------------------------------------*\
Class caseInfo Declaration
\*---------------------------------------------------------------------------*/
class caseInfo
{
// Private data
//- Properties dictionary
IOdictionary properties_;
//- Mesh boundary information (read from mesh boundary file)
boundaryInfo boundaryInfo_;
//- Boundary conditions dictionary
const dictionary& bcDict_;
//- List of condition names
wordList conditionNames_;
// Per-condition information
//- List of patch names
List<wordReList> patchNames_;
//- Patch category
wordList patchCategories_;
//- Patch type
wordList patchTypes_;
// Private member functions
//- Update the polyMesh boundary based on the patch categories
void updateGeometricBoundaryField();
public:
//- Constructor
caseInfo(const Time& runTime, const word& regionName);
// Public member functions
//- Check patches
void checkPatches
(
const word& regionPrefix,
const boundaryTemplates& bcTemplates
) const;
//- Return the list of patch names
const List<wordReList>& patchNames() const;
//- Return the condition name for patch with index patchI
const word& conditionName(const label patchI) const;
//- Return the category name for patch with index patchI
const word& patchCategory(const label patchI) const;
//- Return the type name for patch with index patchI
const word& patchType(const label patchI) const;
//- Return the condition ID for a boundary patch
label findPatchConditionID
(
const label patchI,
const word& patchName
) const;
//- Generate boundary field (dictionary)
dictionary generateBoundaryField
(
const word& regionPrefix,
const word& fieldName,
const boundaryTemplates& bcTemplates
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -0,0 +1,311 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 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/>.
Application
createZeroDirectory
Description
Creates a zero directory with fields appropriate for the chosen solver and
turbulence model. Operates on both single and multi-region cases.
Usage
The set-up is configured using a 'caseProperties' dictionary, located under
the $FOAM_CASE/system (or system/regionName if multi-region) directory.
This consists of a lists of initial and boundary conditions, e.g.
\verbatim
initialConditions
{
U uniform (0 0 0);
p uniform 0;
}
boundaryConditions
{
topWall
{
category wall;
patches (movingWall);
type noSlip;
options
{
wallFunction highReynolds;
motion moving;
};
values
{
U uniform (1 0 0);
}
}
walls
{
category wall;
patches (fixedWalls);
type noSlip;
options
{
wallFunction highReynolds;
motion stationary;
};
}
}
\endverbatim
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "volFields.H"
#include "IOdictionary.H"
#include "caseInfo.H"
#include "boundaryTemplates.H"
#include "solverTemplate.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
const word getClassType(const word& pType)
{
if (pType == pTraits<scalar>::typeName)
{
return GeometricField<scalar, fvPatchField, volMesh>::typeName;
}
else if (pType == pTraits<vector>::typeName)
{
return GeometricField<vector, fvPatchField, volMesh>::typeName;
}
else if (pType == pTraits<sphericalTensor>::typeName)
{
return GeometricField<sphericalTensor, fvPatchField, volMesh>::typeName;
}
else if (pType == pTraits<symmTensor>::typeName)
{
return GeometricField<symmTensor, fvPatchField, volMesh>::typeName;
}
else if (pType == pTraits<tensor>::typeName)
{
return GeometricField<tensor, fvPatchField, volMesh>::typeName;
}
else
{
// Error
return word::null;
}
}
void createFieldFiles
(
const Time& runTime,
const word& regionName,
const word& regionPrefix,
const wordList& fieldNames,
const wordList& fieldTypes,
const PtrList<dimensionSet>& fieldDimensions,
const caseInfo& cInfo,
const boundaryTemplates& bcTemplates
)
{
Info<< " Generating field files" << nl << endl;
// Create files
mkDir(runTime.path()/runTime.timeName()/regionName);
forAll(fieldNames, i)
{
const_cast<word&>(IOdictionary::typeName) =
getClassType(fieldTypes[i]);
dictionary field;
fileName regionPath = "/";
if (regionName != word::null)
{
regionPath += regionName + '/';
}
field.add
(
"#include",
"${FOAM_CASE}/system" + regionPath + "caseProperties"
);
field.add("dimensions", fieldDimensions[i]);
string iField("${:initialConditions." + fieldNames[i] + '}');
field.add("internalField", iField.c_str());
dictionary boundaryField =
cInfo.generateBoundaryField
(
regionPrefix,
fieldNames[i],
bcTemplates
);
field.add("boundaryField", boundaryField);
// Expand all of the dictionary redirections and remove unnecessary
// entries
OStringStream os;
os << field;
entry::disableFunctionEntries = 0;
dictionary field2(IStringStream(os.str())());
entry::disableFunctionEntries = 1;
field2.remove("#include");
field2.remove("initialConditions");
field2.remove("boundaryConditions");
// Construct and write field dictionary
IOdictionary fieldOut
(
IOobject
(
fieldNames[i],
"0",
regionName,
runTime,
IOobject::NO_READ
),
field2
);
fieldOut.regIOobject::writeObject
(
IOstream::ASCII,
IOstream::currentVersion,
IOstream::UNCOMPRESSED
);
}
}
// Main program:
int main(int argc, char *argv[])
{
Foam::argList::addOption
(
"templateDir",
"file",
"read case set-up templates from specified location"
);
#include "setRootCase.H"
#include "createTime.H"
Info<< "Reading controlDict" << nl << endl;
IOdictionary controlDict
(
IOobject
(
"controlDict",
runTime.system(),
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE
)
);
fileName baseDir
(
"${WM_PROJECT_DIR}/etc/caseDicts/createZeroDirectoryTemplates"
);
if (args.optionFound("templateDir"))
{
baseDir = args["templateDir"];
}
baseDir.expand();
baseDir.toAbsolute();
if (!isDir(baseDir))
{
FatalErrorInFunction
<< "templateDir " << baseDir
<< " should point to the folder containing the "
<< "case set-up templates" << exit(FatalError);
}
// Keep variable substitutions - delay until after creation of controlDict
// to allow #include files to be processed
entry::disableFunctionEntries = 1;
// Read the solver
const word& solverName = controlDict.lookup("application");
// Generate solver template
const solverTemplate solver(baseDir, runTime, solverName);
// Read the boundary condition templates
const boundaryTemplates bcTemplates
(
baseDir,
runTime,
solver.type()
);
Info<< endl;
const label nRegion = solver.nRegion();
for (label regionI = 0; regionI < nRegion; regionI++)
{
const word& regionName = solver.regionName(regionI);
if (regionName == word::null)
{
Info<< "Region: " << polyMesh::defaultRegion << " (default)"
<< endl;
}
else
{
Info<< "Region: " << regionName << endl;
}
// Read the case set-up info for the current region
const caseInfo cInfo(runTime, regionName);
cInfo.checkPatches(solver.regionType(regionI), bcTemplates);
createFieldFiles
(
runTime,
regionName,
solver.regionType(regionI),
solver.fieldNames(regionI),
solver.fieldTypes(regionI),
solver.fieldDimensions(regionI),
cInfo,
bcTemplates
);
}
Info<< "End\n" << endl;
return 0;
}
// ************************************************************************* //

View File

@ -0,0 +1,414 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 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.headerOk())
{
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];
}
// ************************************************************************* //

View File

@ -0,0 +1,187 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2015 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/>.
Class
Foam::solverTemplate
Description
Class to store solver template specifications
\*---------------------------------------------------------------------------*/
#ifndef solverTemplate_H
#define solverTemplate_H
#include "boolList.H"
#include "wordList.H"
#include "dimensionSet.H"
#include "IOobject.H"
#include "NamedEnum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
class Time;
/*---------------------------------------------------------------------------*\
Class solverTemplate Declaration
\*---------------------------------------------------------------------------*/
class solverTemplate
{
public:
// Public enumerations
//- Solver type
enum solverType
{
stCompressible,
stIncompressible,
stBuoyant,
stUnknown
};
//- Solver type names
static const NamedEnum<solverType, 4> solverTypeNames_;
private:
// Private data
//- Solver type
solverType solverType_;
//- Multi-region flag
bool multiRegion_;
// Per-region info
//- Region types
wordList regionTypes_;
//- Region names
wordList regionNames_;
//- Field names
List<wordList> fieldNames_;
//- Field types
List<wordList> fieldTypes_;
//- Field dimensions
List<PtrList<dimensionSet> > fieldDimensions_;
// Public member functions
//- Read a word from a dictionary (offers some protection...)
word readFromDict
(
IOobject& dictHeader,
const word& entryName
) const;
//- Read fluid region templates
dictionary readFluidFieldTemplates
(
const word& regionName,
const fileName& baseDir,
const dictionary& solverDict,
const Time& runTime
) const;
//- Read solid region templates
dictionary readSolidFieldTemplates
(
const word& regionName,
const dictionary& solverDict
) const;
//- Set the properties for region with index regionI
void setRegionProperties
(
const dictionary& dict,
const word& regionType,
const word& regionName,
const label regionI
);
public:
//- Constructor
solverTemplate
(
const fileName& baseDir,
const Time& runTime,
const word& regionName
);
// Public member functions
//- Solver type name
word type() const;
//- Return the multi-region flag
bool multiRegion() const;
//- Return the number of regions
label nRegion() const;
// Per-region info
//- Return the region type
const word& regionType(const label regionI) const;
//- Return the region name
const word& regionName(const label regionI) const;
//- Return the field names
const wordList& fieldNames(const label regionI) const;
//- Return the field types
const wordList& fieldTypes(const label regionI) const;
//- Return the field dimensions
const PtrList<dimensionSet>& fieldDimensions
(
const label regionI
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -73,7 +73,7 @@ int main(int argc, char *argv[])
if (!mesh.write())
{
FatalErrorIn(args.executable())
FatalErrorInFunction
<< "Failed writing dsmcCloud."
<< nl << exit(FatalError);
}

View File

@ -72,7 +72,7 @@ int main(int argc, char *argv[])
U.write();
Info<< "\n end\n";
Info<< nl << "End" << nl << endl;
return 0;
}

View File

@ -25,10 +25,13 @@ Application
faceAgglomerate
Description
Agglomerate boundary faces using the pairPatchAgglomeration algorithm.
It writes a map from the fine to coarse grid.
SeeAlso
pairPatchAgglomeration.H
\*---------------------------------------------------------------------------*/
#include "argList.H"

View File

@ -2,7 +2,7 @@
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile

View File

@ -2,6 +2,8 @@ EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/parallel/decompose/decompose/lnInclude \
-I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude
EXE_LIBS = \
@ -9,4 +11,5 @@ EXE_LIBS = \
-lmeshTools \
-llagrangian \
-lfiniteVolume \
-ldecompose \
-lgenericPatchFields

View File

@ -27,6 +27,7 @@ Application
Description
Maps volume fields from one mesh to another, reading and
interpolating all fields present in the time directory of both cases.
Parallel and non-parallel cases are handled without the need to reconstruct
them first.
@ -36,9 +37,48 @@ Description
#include "meshToMesh0.H"
#include "processorFvPatch.H"
#include "MapMeshes.H"
#include "decompositionModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int readNumProcs
(
const argList& args,
const word& optionName,
const Time& runTime
)
{
fileName dictFile;
if (args.optionReadIfPresent(optionName, dictFile))
{
if (isDir(dictFile))
{
dictFile = dictFile/"decomposeParDict";
}
}
return readInt
(
IOdictionary
(
decompositionModel::selectIO
(
IOobject
(
"decomposeParDict",
runTime.system(),
runTime,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE,
false
),
dictFile
)
).lookup("numberOfSubdomains")
);
}
void mapConsistentMesh
(
const fvMesh& meshSource,
@ -225,6 +265,19 @@ int main(int argc, char *argv[])
"subtract",
"subtract mapped source from target"
);
argList::addOption
(
"sourceDecomposeParDict",
"file",
"read decomposePar dictionary from specified location"
);
argList::addOption
(
"targetDecomposeParDict",
"file",
"read decomposePar dictionary from specified location"
);
argList args(argc, argv);
@ -278,7 +331,7 @@ int main(int argc, char *argv[])
}
else
{
FatalErrorIn(args.executable())
FatalErrorInFunction
<< "Unknown mapMethod " << mapMethod << ". Valid options are: "
<< "mapNearest, interpolate and cellPointInterpolate"
<< exit(FatalError);
@ -320,20 +373,13 @@ int main(int argc, char *argv[])
if (parallelSource && !parallelTarget)
{
IOdictionary decompositionDict
int nProcs = readNumProcs
(
IOobject
(
"decomposeParDict",
runTimeSource.system(),
runTimeSource,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
args,
"sourceDecomposeParDict",
runTimeSource
);
int nProcs(readInt(decompositionDict.lookup("numberOfSubdomains")));
Info<< "Create target mesh\n" << endl;
fvMesh meshTarget
@ -399,19 +445,13 @@ int main(int argc, char *argv[])
}
else if (!parallelSource && parallelTarget)
{
IOdictionary decompositionDict
int nProcs = readNumProcs
(
IOobject
(
"decomposeParDict",
runTimeTarget.system(),
runTimeTarget,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
args,
"targetDecomposeParDict",
runTimeTarget
);
int nProcs(readInt(decompositionDict.lookup("numberOfSubdomains")));
Info<< "Create source mesh\n" << endl;
@ -478,39 +518,17 @@ int main(int argc, char *argv[])
}
else if (parallelSource && parallelTarget)
{
IOdictionary decompositionDictSource
int nProcsSource = readNumProcs
(
IOobject
(
"decomposeParDict",
runTimeSource.system(),
runTimeSource,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
args,
"sourceDecomposeParDict",
runTimeSource
);
int nProcsSource
int nProcsTarget = readNumProcs
(
readInt(decompositionDictSource.lookup("numberOfSubdomains"))
);
IOdictionary decompositionDictTarget
(
IOobject
(
"decomposeParDict",
runTimeTarget.system(),
runTimeTarget,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
);
int nProcsTarget
(
readInt(decompositionDictTarget.lookup("numberOfSubdomains"))
args,
"targetDecomposeParDict",
runTimeTarget
);
List<boundBox> bbsTarget(nProcsTarget);

View File

@ -2,7 +2,7 @@
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: 2.2.2 |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile

View File

@ -104,6 +104,8 @@ void MapLagrangianFields
Info<< " mapping lagrangian fieldField " << fieldName << endl;
// Read field (does not need mesh)
// Note: some fieldFields are 0 size (e.g. collision records) if
// not used
IOField<Field<Type> > fieldSource(*fieldIter());
// Map - use CompactIOField to automatically write in
@ -120,12 +122,22 @@ void MapLagrangianFields
IOobject::NO_WRITE,
false
),
addParticles.size()
min(fieldSource.size(), addParticles.size()) // handle 0 size
);
forAll(addParticles, i)
if (fieldSource.size())
{
fieldTarget[i] = fieldSource[addParticles[i]];
forAll(addParticles, i)
{
fieldTarget[i] = fieldSource[addParticles[i]];
}
}
else if (cloud::debug)
{
Pout<< "Not mapping " << fieldName << " since source size "
<< fieldSource.size() << " different to"
<< " cloud size " << addParticles.size()
<< endl;
}
// Write field
@ -139,8 +151,9 @@ void MapLagrangianFields
forAllIter(IOobjectList, fieldFields, fieldIter)
{
Info<< " mapping lagrangian fieldField "
<< fieldIter()->name() << endl;
const word& fieldName = fieldIter()->name();
Info<< " mapping lagrangian fieldField " << fieldName << endl;
// Read field (does not need mesh)
CompactIOField<Field<Type>, Type> fieldSource(*fieldIter());
@ -150,7 +163,7 @@ void MapLagrangianFields
(
IOobject
(
fieldIter()->name(),
fieldName,
meshTarget.time().timeName(),
cloud::prefix/cloudName,
meshTarget,
@ -158,12 +171,22 @@ void MapLagrangianFields
IOobject::NO_WRITE,
false
),
addParticles.size()
min(fieldSource.size(), addParticles.size()) // handle 0 size
);
forAll(addParticles, i)
if (fieldSource.size())
{
fieldTarget[i] = fieldSource[addParticles[i]];
forAll(addParticles, i)
{
fieldTarget[i] = fieldSource[addParticles[i]];
}
}
else if (cloud::debug)
{
Pout<< "Not mapping " << fieldName << " since source size "
<< fieldSource.size() << " different to"
<< " cloud size " << addParticles.size()
<< endl;
}
// Write field

View File

@ -2,7 +2,7 @@
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -41,7 +41,8 @@ void mapConsistentMesh
(
const fvMesh& meshSource,
const fvMesh& meshTarget,
const meshToMesh::interpolationMethod& mapMethod,
const word& mapMethod,
const word& AMIMapMethod,
const bool subtract,
const HashSet<word>& selectedFields,
const bool noLagrangian
@ -50,7 +51,7 @@ void mapConsistentMesh
Info<< nl << "Consistently creating and mapping fields for time "
<< meshSource.time().timeName() << nl << endl;
meshToMesh interp(meshSource, meshTarget, mapMethod);
meshToMesh interp(meshSource, meshTarget, mapMethod, AMIMapMethod);
if (subtract)
{
@ -79,7 +80,8 @@ void mapSubMesh
const fvMesh& meshTarget,
const HashTable<word>& patchMap,
const wordList& cuttingPatches,
const meshToMesh::interpolationMethod& mapMethod,
const word& mapMethod,
const word& AMIMapMethod,
const bool subtract,
const HashSet<word>& selectedFields,
const bool noLagrangian
@ -93,6 +95,7 @@ void mapSubMesh
meshSource,
meshTarget,
mapMethod,
AMIMapMethod,
patchMap,
cuttingPatches
);
@ -184,7 +187,14 @@ int main(int argc, char *argv[])
(
"mapMethod",
"word",
"specify the mapping method"
"specify the mapping method "
"(direct|mapNearest|cellVolumeWeight|correctedCellVolumeWeight)"
);
argList::addOption
(
"patchMapMethod",
"word",
"specify the patch mapping method (direct|mapNearest|faceAreaWeight)"
);
argList::addBoolOption
(
@ -231,15 +241,46 @@ int main(int argc, char *argv[])
const bool consistent = args.optionFound("consistent");
meshToMesh::interpolationMethod mapMethod =
meshToMesh::imCellVolumeWeight;
if (args.optionFound("mapMethod"))
word mapMethod = meshToMesh::interpolationMethodNames_
[
meshToMesh::imCellVolumeWeight
];
if (args.optionReadIfPresent("mapMethod", mapMethod))
{
mapMethod = meshToMesh::interpolationMethodNames_[args["mapMethod"]];
Info<< "Mapping method: " << mapMethod << endl;
}
Info<< "Mapping method: "
<< meshToMesh::interpolationMethodNames_[mapMethod] << endl;
word patchMapMethod;
if (meshToMesh::interpolationMethodNames_.found(mapMethod))
{
// Lookup corresponding AMI method
meshToMesh::interpolationMethod method =
meshToMesh::interpolationMethodNames_[mapMethod];
patchMapMethod = AMIPatchToPatchInterpolation::interpolationMethodToWord
(
meshToMesh::interpolationMethodAMI(method)
);
}
// Optionally override
if (args.optionFound("patchMapMethod"))
{
patchMapMethod = args["patchMapMethod"];
Info<< "Patch mapping method: " << patchMapMethod << endl;
}
if (patchMapMethod.empty())
{
FatalErrorInFunction
<< "No valid patchMapMethod for method " << mapMethod
<< ". Please supply one through the 'patchMapMethod' option"
<< exit(FatalError);
}
const bool subtract = args.optionFound("subtract");
@ -304,8 +345,9 @@ int main(int argc, char *argv[])
)
);
Info<< "Source mesh size: " << meshSource.nCells() << tab
<< "Target mesh size: " << meshTarget.nCells() << nl << endl;
Info<< "Source mesh size: " << meshSource.globalData().nTotalCells() << tab
<< "Target mesh size: " << meshTarget.globalData().nTotalCells()
<< nl << endl;
if (consistent)
{
@ -314,6 +356,7 @@ int main(int argc, char *argv[])
meshSource,
meshTarget,
mapMethod,
patchMapMethod,
subtract,
selectedFields,
noLagrangian
@ -328,6 +371,7 @@ int main(int argc, char *argv[])
patchMap,
addProcessorPatches(meshTarget, cuttingPatches),
mapMethod,
patchMapMethod,
subtract,
selectedFields,
noLagrangian

View File

@ -110,9 +110,10 @@ void mapLagrangian(const meshToMesh& interp)
cloud::prefix/cloudDirs[cloudI]
);
IOobject* positionsPtr = objects.lookup(word("positions"));
bool foundPositions =
returnReduce(objects.found("positions"), orOp<bool>());;
if (positionsPtr)
if (foundPositions)
{
Info<< nl << " processing cloud " << cloudDirs[cloudI] << endl;

View File

@ -80,7 +80,7 @@ int main(int argc, char *argv[])
if (!mesh.write())
{
FatalErrorIn(args.executable())
FatalErrorInFunction
<< "Failed writing moleculeCloud."
<< nl << exit(FatalError);
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -106,22 +106,14 @@ bool setCellFieldType
if (!field.write())
{
FatalErrorIn
(
"void setCellFieldType"
"(const fvMesh& mesh, const labelList& selectedCells,"
"Istream& fieldValueStream)"
) << "Failed writing field " << fieldName << endl;
FatalErrorInFunction
<< "Failed writing field " << fieldName << endl;
}
}
else
{
WarningIn
(
"void setCellFieldType"
"(const fvMesh& mesh, const labelList& selectedCells,"
"Istream& fieldValueStream)"
) << "Field " << fieldName << " not found" << endl;
WarningInFunction
<< "Field " << fieldName << " not found" << endl;
// Consume value
(void)pTraits<Type>(fieldValueStream);
@ -177,7 +169,7 @@ public:
)
)
{
WarningIn("setCellField::iNew::operator()(Istream& is)")
WarningInFunction
<< "field type " << fieldType << " not currently supported"
<< endl;
}
@ -266,7 +258,7 @@ bool setFaceFieldType
if (!hasWarned)
{
hasWarned = true;
WarningIn("setFaceFieldType(..)")
WarningInFunction
<< "Ignoring internal face " << facei
<< ". Suppressing further warnings." << endl;
}
@ -302,22 +294,14 @@ bool setFaceFieldType
if (!field.write())
{
FatalErrorIn
(
"void setFaceFieldType"
"(const fvMesh& mesh, const labelList& selectedFaces,"
"Istream& fieldValueStream)"
) << "Failed writing field " << field.name() << exit(FatalError);
FatalErrorInFunction
<< "Failed writing field " << field.name() << exit(FatalError);
}
}
else
{
WarningIn
(
"void setFaceFieldType"
"(const fvMesh& mesh, const labelList& selectedFaces,"
"Istream& fieldValueStream)"
) << "Field " << fieldName << " not found" << endl;
WarningInFunction
<< "Field " << fieldName << " not found" << endl;
// Consume value
(void)pTraits<Type>(fieldValueStream);
@ -373,7 +357,7 @@ public:
)
)
{
WarningIn("setFaceField::iNew::operator()(Istream& is)")
WarningInFunction
<< "field type " << fieldType << " not currently supported"
<< endl;
}

View File

@ -2,7 +2,7 @@
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile

View File

@ -60,10 +60,8 @@ for (label procI = 0; procI < Pstream::nProcs(); procI++)
endAgg.append(globalNumbering.toGlobal(procI, remAgg));
if (startIndex.size() > maxDynListLength)
{
FatalErrorIn
(
"shootRays"
) << "Dynamic list need from capacity."
FatalErrorInFunction
<< "Dynamic list need from capacity."
<< "Actual size maxDynListLength : "
<< maxDynListLength
<< abort(FatalError);
@ -89,8 +87,8 @@ for (label procI = 0; procI < Pstream::nProcs(); procI++)
DynamicList<label> dRayIs;
// Collect the rays which has not obstacle in bettween in rayStartFace
// and rayEndFace. If the ray hit itself get stored in dRayIs
// Collect the rays which have no obstacle in between rayStartFace
// and rayEndFace. If the ray hit itself, it gets stored in dRayIs
forAll(hitInfo, rayI)
{
if (!hitInfo[rayI].hit())

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -104,7 +104,7 @@ void Foam::tabulatedWallFunctions::SpaldingsLaw::invertFunction()
if (iter == maxIters_)
{
WarningIn("SpaldingsLaw::invertFunction()")
WarningInFunction
<< "Newton iterations not converged:" << nl
<< " iters = " << iter << ", error = " << error << endl;
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -119,15 +119,8 @@ Foam::scalar Foam::tabulatedWallFunctions::general::interpolate
}
default:
{
FatalErrorIn
(
"tabulatedWallFunctions::general::interpolate"
"("
"const scalar, "
"const scalarList&, "
"const scalarList&"
")"
) << "Unknown interpolation method" << nl
FatalErrorInFunction
<< "Unknown interpolation method" << nl
<< abort(FatalError);
}
}
@ -154,14 +147,8 @@ Foam::tabulatedWallFunctions::general::general
List<Tuple2<scalar, scalar> > inputTable = coeffDict_.lookup("inputTable");
if (inputTable.size() < 2)
{
FatalErrorIn
(
"tabulatedWallFunctions::general::general"
"("
"const dictionary&, "
"const polyMesh&"
")"
) << "Input table must have at least 2 values" << nl
FatalErrorInFunction
<< "Input table must have at least 2 values" << nl
<< exit(FatalError);
}

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -49,10 +49,8 @@ autoPtr<tabulatedWallFunction> tabulatedWallFunction::New
if (cstrIter == dictionaryConstructorTablePtr_->end())
{
FatalErrorIn
(
"tabulatedWallFunction::New(const dictionary&, const polyMesh&)"
) << "Unknown tabulatedWallFunction type " << twfTypeName
FatalErrorInFunction
<< "Unknown tabulatedWallFunction type " << twfTypeName
<< nl << nl << "Valid tabulatedWallFunction types are:" << nl
<< dictionaryConstructorTablePtr_->toc()
<< exit(FatalError);

View File

@ -2,7 +2,7 @@
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: dev |
| \\ / A nd | Web: www.OpenFOAM.org |
| \\ / A nd | Web: www.OpenFOAM.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile