Merge branch 'master' into dsmc

This commit is contained in:
graham
2009-09-24 09:55:56 +01:00
208 changed files with 74989 additions and 914 deletions

View File

@ -68,10 +68,10 @@ int main(int argc, char *argv[])
#include "chemistry.H"
#include "rhoEqn.H"
#include "UEqn.H"
for (label ocorr=1; ocorr <= nOuterCorr; ocorr++)
{
#include "UEqn.H"
#include "YEqn.H"
#define Db turbulence->alphaEff()

View File

@ -1,5 +1,6 @@
EXE_INC = \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/thermalPorousZone/lnInclude \
-I$(LIB_SRC)/turbulenceModels \
-I$(LIB_SRC)/turbulenceModels/compressible/RAS/RASModel \
-I$(LIB_SRC)/finiteVolume/cfdTools \
@ -8,6 +9,7 @@ EXE_INC = \
EXE_LIBS = \
-lbasicThermophysicalModels \
-lthermalPorousZone \
-lspecie \
-lcompressibleRASModels \
-lfiniteVolume \

View File

@ -64,7 +64,7 @@
dimensionedScalar initialMass = fvc::domainIntegrate(rho);
porousZones pZones(mesh);
thermalPorousZones pZones(mesh);
Switch pressureImplicitPorosity(false);
int nUCorr = 0;
@ -84,4 +84,3 @@
pressureImplicitPorosity = true;
}
}

View File

@ -9,6 +9,8 @@
- p*fvc::div(phi/fvc::interpolate(rho))
);
pZones.addEnthalpySource(thermo, rho, hEqn);
hEqn.relax();
eqnResidual = hEqn.solve().initialResidual();

View File

@ -34,7 +34,7 @@ Description
#include "fvCFD.H"
#include "basicPsiThermo.H"
#include "RASModel.H"
#include "porousZones.H"
#include "thermalPorousZones.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -1,7 +1,4 @@
regionProperties/regionProperties.C
derivedFvPatchFields/solidWallHeatFluxTemperature/solidWallHeatFluxTemperatureFvPatchScalarField.C
derivedFvPatchFields/solidWallMixedTemperatureCoupled/solidWallMixedTemperatureCoupledFvPatchScalarField.C
fluid/compressibleCourantNo.C

View File

@ -5,7 +5,8 @@ EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/thermophysicalModels/basic/lnInclude \
-I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel
-I$(LIB_SRC)/turbulenceModels/compressible/turbulenceModel \
-I$(LIB_SRC)/turbulenceModels/compressible/RAS/lnInclude
EXE_LIBS = \
-lbasicThermophysicalModels \

View File

@ -1,380 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\*---------------------------------------------------------------------------*/
#include "solidWallMixedTemperatureCoupledFvPatchScalarField.H"
#include "addToRunTimeSelectionTable.H"
#include "fvPatchFieldMapper.H"
#include "volFields.H"
#include "directMappedPatchBase.H"
#include "regionProperties.H"
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
bool Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::interfaceOwner
(
const polyMesh& nbrRegion
) const
{
const fvMesh& myRegion = patch().boundaryMesh().mesh();
const regionProperties& props =
myRegion.objectRegistry::parent().lookupObject<regionProperties>
(
"regionProperties"
);
label myIndex = findIndex(props.fluidRegionNames(), myRegion.name());
if (myIndex == -1)
{
label i = findIndex(props.solidRegionNames(), myRegion.name());
if (i == -1)
{
FatalErrorIn
(
"solidWallMixedTemperatureCoupledFvPatchScalarField"
"::interfaceOwner(const polyMesh&) const"
) << "Cannot find region " << myRegion.name()
<< " neither in fluids " << props.fluidRegionNames()
<< " nor in solids " << props.solidRegionNames()
<< exit(FatalError);
}
myIndex = props.fluidRegionNames().size() + i;
}
label nbrIndex = findIndex(props.fluidRegionNames(), nbrRegion.name());
if (nbrIndex == -1)
{
label i = findIndex(props.solidRegionNames(), nbrRegion.name());
if (i == -1)
{
FatalErrorIn("coupleManager::interfaceOwner(const polyMesh&) const")
<< "Cannot find region " << nbrRegion.name()
<< " neither in fluids " << props.fluidRegionNames()
<< " nor in solids " << props.solidRegionNames()
<< exit(FatalError);
}
nbrIndex = props.fluidRegionNames().size() + i;
}
return myIndex < nbrIndex;
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::
solidWallMixedTemperatureCoupledFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF
)
:
mixedFvPatchScalarField(p, iF),
neighbourFieldName_("undefined-neighbourFieldName"),
KName_("undefined-K")
{
this->refValue() = 0.0;
this->refGrad() = 0.0;
this->valueFraction() = 1.0;
this->fixesValue_ = true;
}
Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::
solidWallMixedTemperatureCoupledFvPatchScalarField
(
const solidWallMixedTemperatureCoupledFvPatchScalarField& ptf,
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const fvPatchFieldMapper& mapper
)
:
mixedFvPatchScalarField(ptf, p, iF, mapper),
neighbourFieldName_(ptf.neighbourFieldName_),
KName_(ptf.KName_),
fixesValue_(ptf.fixesValue_)
{}
Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::
solidWallMixedTemperatureCoupledFvPatchScalarField
(
const fvPatch& p,
const DimensionedField<scalar, volMesh>& iF,
const dictionary& dict
)
:
mixedFvPatchScalarField(p, iF),
neighbourFieldName_(dict.lookup("neighbourFieldName")),
KName_(dict.lookup("K"))
{
if (!isA<directMappedPatchBase>(this->patch().patch()))
{
FatalErrorIn
(
"solidWallMixedTemperatureCoupledFvPatchScalarField::"
"solidWallMixedTemperatureCoupledFvPatchScalarField\n"
"(\n"
" const fvPatch& p,\n"
" const DimensionedField<scalar, volMesh>& iF,\n"
" const dictionary& dict\n"
")\n"
) << "\n patch type '" << p.type()
<< "' not type '" << directMappedPatchBase::typeName << "'"
<< "\n for patch " << p.name()
<< " of field " << dimensionedInternalField().name()
<< " in file " << dimensionedInternalField().objectPath()
<< exit(FatalError);
}
fvPatchScalarField::operator=(scalarField("value", dict, p.size()));
if (dict.found("refValue"))
{
// Full restart
refValue() = scalarField("refValue", dict, p.size());
refGrad() = scalarField("refGradient", dict, p.size());
valueFraction() = scalarField("valueFraction", dict, p.size());
fixesValue_ = readBool(dict.lookup("fixesValue"));
}
else
{
// Start from user entered data. Assume fixedValue.
refValue() = *this;
refGrad() = 0.0;
valueFraction() = 1.0;
fixesValue_ = true;
}
}
Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::
solidWallMixedTemperatureCoupledFvPatchScalarField
(
const solidWallMixedTemperatureCoupledFvPatchScalarField& wtcsf,
const DimensionedField<scalar, volMesh>& iF
)
:
mixedFvPatchScalarField(wtcsf, iF),
neighbourFieldName_(wtcsf.neighbourFieldName_),
KName_(wtcsf.KName_),
fixesValue_(wtcsf.fixesValue_)
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
const Foam::fvPatchScalarField&
Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::K() const
{
return this->patch().lookupPatchField<volScalarField, scalar>(KName_);
}
void Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::updateCoeffs()
{
if (updated())
{
return;
}
// Get the coupling information from the directMappedPatchBase
const directMappedPatchBase& mpp = refCast<const directMappedPatchBase>
(
patch().patch()
);
const polyMesh& nbrMesh = mpp.sampleMesh();
// Force recalculation of mapping and schedule
const mapDistribute& distMap = mpp.map();
(void)distMap.schedule();
tmp<scalarField> intFld = patchInternalField();
if (interfaceOwner(nbrMesh))
{
// Note: other side information could be cached - it only needs
// to be updated the first time round the iteration (i.e. when
// switching regions) but unfortunately we don't have this information.
const fvPatch& nbrPatch = refCast<const fvMesh>
(
nbrMesh
).boundary()[mpp.samplePolyPatch().index()];
// Calculate the temperature by harmonic averaging
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const solidWallMixedTemperatureCoupledFvPatchScalarField& nbrField =
refCast<const solidWallMixedTemperatureCoupledFvPatchScalarField>
(
nbrPatch.lookupPatchField<volScalarField, scalar>
(
neighbourFieldName_
)
);
// Swap to obtain full local values of neighbour internal field
scalarField nbrIntFld = nbrField.patchInternalField();
mapDistribute::distribute
(
Pstream::defaultCommsType,
distMap.schedule(),
distMap.constructSize(),
distMap.subMap(), // what to send
distMap.constructMap(), // what to receive
nbrIntFld
);
// Swap to obtain full local values of neighbour K*delta
scalarField nbrKDelta = nbrField.K()*nbrPatch.deltaCoeffs();
mapDistribute::distribute
(
Pstream::defaultCommsType,
distMap.schedule(),
distMap.constructSize(),
distMap.subMap(), // what to send
distMap.constructMap(), // what to receive
nbrKDelta
);
tmp<scalarField> myKDelta = K()*patch().deltaCoeffs();
// Calculate common wall temperature. Reuse *this to store common value.
scalarField Twall
(
(myKDelta()*intFld() + nbrKDelta*nbrIntFld)
/ (myKDelta() + nbrKDelta)
);
// Assign to me
fvPatchScalarField::operator=(Twall);
// Distribute back and assign to neighbour
mapDistribute::distribute
(
Pstream::defaultCommsType,
distMap.schedule(),
nbrField.size(),
distMap.constructMap(), // reverse : what to send
distMap.subMap(),
Twall
);
const_cast<solidWallMixedTemperatureCoupledFvPatchScalarField&>
(
nbrField
).fvPatchScalarField::operator=(Twall);
}
// Switch between fixed value (of harmonic avg) or gradient
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
label nFixed = 0;
// Like snGrad but bypass switching on refValue/refGrad.
tmp<scalarField> normalGradient = (*this-intFld())*patch().deltaCoeffs();
if (debug)
{
scalar Q = gSum(K()*patch().magSf()*normalGradient());
Info<< "solidWallMixedTemperatureCoupledFvPatchScalarField::"
<< "updateCoeffs() :"
<< " patch:" << patch().name()
<< " heatFlux:" << Q
<< " walltemperature "
<< " min:" << gMin(*this)
<< " max:" << gMax(*this)
<< " avg:" << gAverage(*this)
<< endl;
}
forAll(*this, i)
{
// if outgoing flux use fixed value.
if (normalGradient()[i] < 0.0)
{
this->refValue()[i] = operator[](i);
this->refGrad()[i] = 0.0; // not used
this->valueFraction()[i] = 1.0;
nFixed++;
}
else
{
this->refValue()[i] = 0.0; // not used
this->refGrad()[i] = normalGradient()[i];
this->valueFraction()[i] = 0.0;
}
}
reduce(nFixed, sumOp<label>());
fixesValue_ = (nFixed > 0);
if (debug)
{
label nTotSize = returnReduce(this->size(), sumOp<label>());
Info<< "solidWallMixedTemperatureCoupledFvPatchScalarField::"
<< "updateCoeffs() :"
<< " patch:" << patch().name()
<< " out of:" << nTotSize
<< " fixedBC:" << nFixed
<< " gradient:" << nTotSize-nFixed << endl;
}
mixedFvPatchScalarField::updateCoeffs();
}
void Foam::solidWallMixedTemperatureCoupledFvPatchScalarField::write
(
Ostream& os
) const
{
mixedFvPatchScalarField::write(os);
os.writeKeyword("neighbourFieldName")<< neighbourFieldName_
<< token::END_STATEMENT << nl;
os.writeKeyword("K") << KName_ << token::END_STATEMENT << nl;
os.writeKeyword("fixesValue") << fixesValue_ << token::END_STATEMENT << nl;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
makePatchTypeField
(
fvPatchScalarField,
solidWallMixedTemperatureCoupledFvPatchScalarField
);
} // End namespace Foam
// ************************************************************************* //

View File

@ -1,193 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 1991-2009 OpenCFD Ltd.
\\/ 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 2 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, write to the Free Software Foundation,
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
solidWallMixedTemperatureCoupledFvPatchScalarField
Description
Mixed boundary condition for temperature, to be used by the
conjugate heat transfer solver.
If my temperature is T1, neighbour is T2:
T1 > T2: my side becomes fixedValue T2 bc, other side becomes fixedGradient.
Example usage:
myInterfacePatchName
{
type solidWallMixedTemperatureCoupled;
neighbourFieldName T;
K K;
value uniform 300;
}
Needs to be on underlying directMapped(Wall)FvPatch.
Note: runs in parallel with arbitrary decomposition. Uses directMapped
functionality to calculate exchange.
Note: lags interface data so both sides use same data.
- problem: schedule to calculate average would interfere
with standard processor swaps.
- so: updateCoeffs sets both to same Twall. Only need to do
this for last outer iteration but don't have access to this.
SourceFiles
solidWallMixedTemperatureCoupledFvPatchScalarField.C
\*---------------------------------------------------------------------------*/
#ifndef solidWallMixedTemperatureCoupledFvPatchScalarField_H
#define solidWallMixedTemperatureCoupledFvPatchScalarField_H
#include "fvPatchFields.H"
#include "mixedFvPatchFields.H"
#include "fvPatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
/*---------------------------------------------------------------------------*\
Class solidWallMixedTemperatureCoupledFvPatchScalarField Declaration
\*---------------------------------------------------------------------------*/
class solidWallMixedTemperatureCoupledFvPatchScalarField
:
public mixedFvPatchScalarField
{
// Private data
//- Name of field on the neighbour region
const word neighbourFieldName_;
//- Name of thermal conductivity field
const word KName_;
bool fixesValue_;
// Private Member Functions
//- Am I or neighbour owner of interface
bool interfaceOwner(const polyMesh& nbrRegion) const;
public:
//- Runtime type information
TypeName("solidWallMixedTemperatureCoupled");
// Constructors
//- Construct from patch and internal field
solidWallMixedTemperatureCoupledFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&
);
//- Construct from patch, internal field and dictionary
solidWallMixedTemperatureCoupledFvPatchScalarField
(
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const dictionary&
);
//- Construct by mapping given
// solidWallMixedTemperatureCoupledFvPatchScalarField onto a new patch
solidWallMixedTemperatureCoupledFvPatchScalarField
(
const solidWallMixedTemperatureCoupledFvPatchScalarField&,
const fvPatch&,
const DimensionedField<scalar, volMesh>&,
const fvPatchFieldMapper&
);
//- Construct and return a clone
virtual tmp<fvPatchScalarField> clone() const
{
return tmp<fvPatchScalarField>
(
new solidWallMixedTemperatureCoupledFvPatchScalarField(*this)
);
}
//- Construct as copy setting internal field reference
solidWallMixedTemperatureCoupledFvPatchScalarField
(
const solidWallMixedTemperatureCoupledFvPatchScalarField&,
const DimensionedField<scalar, volMesh>&
);
//- Construct and return a clone setting internal field reference
virtual tmp<fvPatchScalarField> clone
(
const DimensionedField<scalar, volMesh>& iF
) const
{
return tmp<fvPatchScalarField>
(
new solidWallMixedTemperatureCoupledFvPatchScalarField
(
*this,
iF
)
);
}
// Member functions
//- Get corresponding K field
const fvPatchScalarField& K() const;
//- Return true if this patch field fixes a value.
// Needed to check if a level has to be specified while solving
// Poissons equations.
virtual bool fixesValue() const
{
return fixesValue_;
}
//- Update the coefficients associated with the patch field
virtual void updateCoeffs();
//- Write
virtual void write(Ostream&) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -38,7 +38,7 @@
for (label i=0; i<Ua.boundaryField().size(); i++)
{
if (isType<fixedValueFvPatchVectorField>(Ua.boundaryField()[i]))
if (isA<fixedValueFvPatchVectorField>(Ua.boundaryField()[i]))
{
phiTypes[i] = fixedValueFvPatchScalarField::typeName;
}

View File

@ -38,7 +38,7 @@
for (label i=0; i<Ub.boundaryField().size(); i++)
{
if (isType<fixedValueFvPatchVectorField>(Ub.boundaryField()[i]))
if (isA<fixedValueFvPatchVectorField>(Ub.boundaryField()[i]))
{
phiTypes[i] = fixedValueFvPatchScalarField::typeName;
}

View File

@ -37,7 +37,7 @@ Description
{
const fvPatch& p = patches[patchi];
if (isType<wallFvPatch>(p))
if (isA<wallFvPatch>(p))
{
epsEqn.setValues
(

View File

@ -12,7 +12,7 @@
{
const fvPatch& currPatch = patches[patchi];
if (isType<wallFvPatch>(currPatch))
if (isA<wallFvPatch>(currPatch))
{
forAll(currPatch, facei)
{
@ -30,7 +30,7 @@
{
const fvPatch& currPatch = patches[patchi];
if (isType<wallFvPatch>(currPatch))
if (isA<wallFvPatch>(currPatch))
{
const scalarField& nuw = nutb.boundaryField()[patchi];
@ -74,7 +74,7 @@
{
const fvPatch& curPatch = patches[patchi];
if (isType<wallFvPatch>(curPatch))
if (isA<wallFvPatch>(curPatch))
{
forAll(curPatch, facei)
{

View File

@ -10,7 +10,7 @@
{
const fvPatch& currPatch = patches[patchi];
if (isType<wallFvPatch>(currPatch))
if (isA<wallFvPatch>(currPatch))
{
scalarField& nutw = nutb.boundaryField()[patchi];

View File

@ -352,7 +352,7 @@ void Foam::multiphaseMixture::correctContactAngle
forAll(boundary, patchi)
{
if (typeid(gbf[patchi]) == typeid(alphaContactAngleFvPatchScalarField))
if (isA<alphaContactAngleFvPatchScalarField>(gbf[patchi]))
{
const alphaContactAngleFvPatchScalarField& acap =
refCast<const alphaContactAngleFvPatchScalarField>(gbf[patchi]);

View File

@ -37,7 +37,7 @@ Description
{
const fvPatch& p = patches[patchi];
if (isType<wallFvPatch>(p))
if (isA<wallFvPatch>(p))
{
epsEqn.setValues
(

View File

@ -12,7 +12,7 @@
{
const fvPatch& curPatch = patches[patchi];
if (isType<wallFvPatch>(curPatch))
if (isA<wallFvPatch>(curPatch))
{
forAll(curPatch, facei)
{
@ -30,7 +30,7 @@
{
const fvPatch& curPatch = patches[patchi];
if (isType<wallFvPatch>(curPatch))
if (isA<wallFvPatch>(curPatch))
{
const scalarField& rhow = rho.boundaryField()[patchi];
@ -76,7 +76,7 @@
{
const fvPatch& curPatch = patches[patchi];
if (isType<wallFvPatch>(curPatch))
if (isA<wallFvPatch>(curPatch))
{
forAll(curPatch, facei)
{

View File

@ -9,7 +9,7 @@
{
const fvPatch& curPatch = patches[patchi];
if (isType<wallFvPatch>(curPatch))
if (isA<wallFvPatch>(curPatch))
{
const scalarField& rhow = rho.boundaryField()[patchi];

View File

@ -109,7 +109,7 @@ Foam::phaseModel::phaseModel
for (label i=0; i<U_.boundaryField().size(); i++)
{
if (isType<fixedValueFvPatchVectorField>(U_.boundaryField()[i]))
if (isA<fixedValueFvPatchVectorField>(U_.boundaryField()[i]))
{
phiTypes[i] = fixedValueFvPatchScalarField::typeName;
}

View File

@ -77,7 +77,7 @@ int main(int argc, char *argv[])
{
const fvPatch& patch = mesh.boundary()[patchI];
if (typeid(patch) == typeid(wallFvPatch))
if (isA<wallFvPatch>(patch))
{
nWalls += patch.size();
}
@ -91,7 +91,7 @@ int main(int argc, char *argv[])
{
const fvPatch& patch = mesh.boundary()[patchI];
if (typeid(patch) == typeid(wallFvPatch))
if (isA<wallFvPatch>(patch))
{
forAll (patch.Cf(), patchFaceI)
{

View File

@ -66,7 +66,7 @@ int main(int argc, char *argv[])
{
const fvPatch& patch = mesh.boundary()[patchI];
if (typeid(patch) == typeid(wallFvPatch))
if (isA<wallFvPatch>(patch))
{
fvPatchVectorField& wallData = n.boundaryField()[patchI];

View File

@ -66,7 +66,7 @@ int main(int argc, char *argv[])
{
const fvPatch& patch = mesh.boundary()[patchI];
if (typeid(patch) == typeid(wallFvPatch))
if (isA<wallFvPatch>(patch))
{
fvPatchScalarField& wallData = yStar.boundaryField()[patchI];

View File

@ -55,7 +55,7 @@ labelList procNeighbours(const polyMesh& mesh)
forAll (mesh.boundaryMesh(), patchI)
{
if (typeid(mesh.boundaryMesh()[patchI]) == typeid(processorPolyPatch))
if (isA<processorPolyPatch>(mesh.boundaryMesh()[patchI]))
{
nNeighbours++;
}
@ -67,7 +67,7 @@ labelList procNeighbours(const polyMesh& mesh)
forAll (mesh.boundaryMesh(), patchI)
{
if (typeid(mesh.boundaryMesh()[patchI]) == typeid(processorPolyPatch))
if (isA<processorPolyPatch>(mesh.boundaryMesh()[patchI]))
{
const polyPatch& patch = mesh.boundaryMesh()[patchI];

View File

@ -174,17 +174,11 @@ void Foam::fluentFvMesh::writeFluentMesh() const
nWrittenFaces += patchFaces.size();
// Write patch type
if
(
typeid(boundary()[patchI]) == typeid(wallFvPatch)
)
if (isA<wallFvPatch>(boundary()[patchI]))
{
fluentMeshFile << 3;
}
else if
(
typeid(boundary()[patchI]) == typeid(symmetryFvPatch)
)
else if (isA<symmetryFvPatch>(boundary()[patchI]))
{
fluentMeshFile << 7;
}
@ -282,17 +276,11 @@ void Foam::fluentFvMesh::writeFluentMesh() const
<< "(39 (" << patchI + 10 << " ";
// Write patch type
if
(
typeid(boundary()[patchI]) == typeid(wallFvPatch)
)
if (isA<wallFvPatch>(boundary()[patchI]))
{
fluentMeshFile << "wall ";
}
else if
(
typeid(boundary()[patchI]) == typeid(symmetryFvPatch)
)
else if (isA<symmetryFvPatch>(boundary()[patchI]))
{
fluentMeshFile << "symmetry ";
}

View File

@ -0,0 +1,79 @@
// Parametres geometriques
r1 = 200*Cos(Pi/4)/1000;
r2 = 200*Cos(Pi/4)/1000;
h1 = 250/1000;
h2 = 360/1000;
h3 = 900/1000;
h4 = 1900/1000;
// Parametres de maillage
// selon le rayon
rCells = 10/2; rRatio = 0.85;
// selon S1
S1Cells = 30/2; S1ratio = 1;
// selon S2
S2Cells = 35/2; S2ratio = 0.95;
// selon S3
S3Cells = 20/2; S3ratio = 1;
Point(1) = {r1, r1, h4};
Point(2) = {r1, r1, h3};
Point(3) = {r2, r2, h2};
Point(4) = {r2, r2, h1};
Point(5) = {0, 0, h1};
Point(6) = {0, 0, h2};
Point(7) = {0, 0, h3};
Point(8) = {0, 0, h4};
Line(1) = {8, 1};
Line(2) = {1, 2};
Line(3) = {7, 2};
Line(4) = {8, 7};
Line(5) = {2, 3};
Line(6) = {6, 3};
Line(7) = {7, 6};
Line(8) = {3, 4};
Line(9) = {5, 4};
Line(10) = {6, 5};
Line Loop(11) = {1, 2, -3, -4};
Ruled Surface(12) = {11};
Line Loop(13) = {5, -6, -7, 3};
Ruled Surface(14) = {13};
Line Loop(15) = {8, -9, -10, 6};
Ruled Surface(16) = {15};
Transfinite Line {1, 3, 6, 9} = rCells Using Progression rRatio;
Transfinite Line {4, 2} = S1Cells Using Progression S1ratio;
Transfinite Line {7, 5} = S2Cells Using Progression S2ratio;
Transfinite Line {10, 8} = S3Cells Using Progression S3ratio;
Transfinite Surface {12} = {8, 1, 2, 7};
Transfinite Surface {14} = {7, 2, 3, 6};
Transfinite Surface {16} = {6, 3, 4, 5};
Recombine Surface {12, 14, 16};
Extrude {{0, 0, 1}, {0, 0, 0}, Pi/2} {
Surface{12, 14, 16};
Layers{25};
Recombine;
}
Extrude {{0, 0, 1}, {0, 0, 0}, Pi/2} {
Surface{33, 50, 67};
Layers{25};
Recombine;
}
Extrude {{0, 0, 1}, {0, 0, 0}, Pi/2} {
Surface{84, 101, 118};
Layers{25};
Recombine;
}
Extrude {{0, 0, 1}, {0, 0, 0}, Pi/2} {
Surface{135, 152, 169};
Layers{25};
Recombine;
}
Physical Surface("entree") = {126, 75, 24, 177};
Physical Surface("S1") = {28, 181, 130, 79};
Physical Surface("S2") = {93, 42, 193, 144};
Physical Surface("S3") = {110, 59, 205, 161};
Physical Surface("fond") = {113, 62, 208, 164};
Physical Volume("fluide") = {4, 7, 10, 1, 5, 8, 11, 2, 9, 12, 3, 6};

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -312,11 +312,36 @@ void readPhysNames(IFstream& inFile, Map<word>& physicalNames)
string line;
inFile.getLine(line);
IStringStream lineStr(line);
label nSpaces = lineStr.str().count(' ');
lineStr >> regionI >> regionName;
if(nSpaces == 1)
{
lineStr >> regionI >> regionName;
Info<< " " << regionI << '\t' << string::validate<word>(regionName)
<< endl;
Info<< " " << regionI << '\t'
<< string::validate<word>(regionName) << endl;
}
else if(nSpaces == 2)
{
// >= Gmsh2.4 physical types has tag in front.
label physType;
lineStr >> physType >> regionI >> regionName;
if (physType == 1)
{
Info<< " " << "Line " << regionI << '\t'
<< string::validate<word>(regionName) << endl;
}
else if (physType == 2)
{
Info<< " " << "Surface " << regionI << '\t'
<< string::validate<word>(regionName) << endl;
}
else if (physType == 3)
{
Info<< " " << "Volume " << regionI << '\t'
<< string::validate<word>(regionName) << endl;
}
}
physicalNames.insert(regionI, string::validate<word>(regionName));
}

View File

@ -138,12 +138,29 @@ label findPatchID(const polyBoundaryMesh& patches, const word& name)
}
labelList patchFaces(const polyBoundaryMesh& patches, const word& name)
labelList patchFaces(const polyBoundaryMesh& patches, const wordList& names)
{
label patchID = findPatchID(patches, name);
const polyPatch& pp = patches[patchID];
label n = 0;
return identity(pp.size()) + pp.start();
forAll(names, i)
{
const polyPatch& pp = patches[findPatchID(patches, names[i])];
n += pp.size();
}
labelList faceLabels(n);
n = 0;
forAll(names, i)
{
const polyPatch& pp = patches[findPatchID(patches, names[i])];
forAll(pp, j)
{
faceLabels[n++] = pp.start()+j;
}
}
return faceLabels;
}
@ -231,13 +248,26 @@ int main(int argc, char *argv[])
if (mode == PATCH || mode == MESH)
{
if (flipNormals)
{
FatalErrorIn(args.executable())
<< "Flipping normals not supported for extrusions from patch."
<< exit(FatalError);
}
fileName sourceCasePath(dict.lookup("sourceCase"));
sourceCasePath.expand();
fileName sourceRootDir = sourceCasePath.path();
fileName sourceCaseDir = sourceCasePath.name();
dict.lookup("sourcePatch") >> frontPatchName;
wordList sourcePatches;
dict.lookup("sourcePatches") >> sourcePatches;
Info<< "Extruding patch " << frontPatchName
if (sourcePatches.size() == 1)
{
frontPatchName = sourcePatches[0];
}
Info<< "Extruding patches " << sourcePatches
<< " on mesh " << sourceCasePath << nl
<< endl;
@ -272,7 +302,7 @@ int main(int argc, char *argv[])
IndirectList<face>
(
mesh.faces(),
patchFaces(patches, frontPatchName)
patchFaces(patches, sourcePatches)
),
mesh.points()
);
@ -471,13 +501,13 @@ int main(int argc, char *argv[])
frontPatchFaces = patchFaces
(
meshFromSurface().boundaryMesh(),
frontPatchName
wordList(1, frontPatchName)
);
backPatchName = "otherSide";
backPatchFaces = patchFaces
(
meshFromSurface().boundaryMesh(),
backPatchName
wordList(1, backPatchName)
);
}

View File

@ -1,6 +1,7 @@
extrudeModel/extrudeModel.C
extrudeModel/newExtrudeModel.C
linearNormal/linearNormal.C
linearDirection/linearDirection.C
linearRadial/linearRadial.C
sigmaRadial/sigmaRadial.C
wedge/wedge.C

View File

@ -24,46 +24,67 @@ License
\*---------------------------------------------------------------------------*/
#include "regionProperties.H"
#include "linearDirection.H"
#include "addToRunTimeSelectionTable.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace extrudeModels
{
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
defineTypeNameAndDebug(linearDirection, 0);
addToRunTimeSelectionTable(extrudeModel, linearDirection, dictionary);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::regionProperties::regionProperties(const Time& runTime)
linearDirection::linearDirection(const dictionary& dict)
:
IOdictionary
(
IOobject
(
"regionProperties",
runTime.time().constant(),
runTime.db(),
IOobject::MUST_READ,
IOobject::NO_WRITE
)
),
fluidRegionNames_(lookup("fluidRegionNames")),
solidRegionNames_(lookup("solidRegionNames"))
{}
extrudeModel(typeName, dict),
direction_(coeffDict_.lookup("direction")),
thickness_(readScalar(coeffDict_.lookup("thickness")))
{
direction_ /= mag(direction_);
if (thickness_ <= 0)
{
FatalErrorIn("linearDirection(const dictionary&)")
<< "thickness should be positive : " << thickness_
<< exit(FatalError);
}
}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::regionProperties::~regionProperties()
linearDirection::~linearDirection()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Operators * * * * * * * * * * * * * * * * //
const Foam::List<Foam::word>& Foam::regionProperties::fluidRegionNames() const
point linearDirection::operator()
(
const point& surfacePoint,
const vector& surfaceNormal,
const label layer
) const
{
return fluidRegionNames_;
//scalar d = thickness_*layer/nLayers_;
scalar d = thickness_*sumThickness(layer);
return surfacePoint + d*direction_;
}
const Foam::List<Foam::word>& Foam::regionProperties::solidRegionNames() const
{
return solidRegionNames_;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace extrudeModels
} // End namespace Foam
// ************************************************************************* //

View File

@ -23,80 +23,72 @@ License
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Class
regionProperties
Foam::extrudeModels::linearDirection
Description
Simple class to hold region information for coupled region simulations
SourceFiles
regionProperties.C
Extrudes by transforming points in a specified direction by a given distance
\*---------------------------------------------------------------------------*/
#ifndef regionProperties_H
#define regionProperties_H
#ifndef linearDirection_H
#define linearDirection_H
#include "IOdictionary.H"
#include "Time.H"
#include "point.H"
#include "extrudeModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
namespace extrudeModels
{
/*---------------------------------------------------------------------------*\
Class regionProperties Declaration
Class linearDirection Declaration
\*---------------------------------------------------------------------------*/
class regionProperties
class linearDirection
:
public IOdictionary
public extrudeModel
{
// Private data
//- List of the fluid region names
List<word> fluidRegionNames_;
//- Extrude direction
vector direction_;
//- List of the solid region names
List<word> solidRegionNames_;
// Private Member Functions
//- Disallow default bitwise copy construct
regionProperties(const regionProperties&);
//- Disallow default bitwise assignment
void operator=(const regionProperties&);
//- layer thickness
scalar thickness_;
public:
//- Runtime type information
TypeName("linearDirection");
// Constructors
//- Construct from components
regionProperties(const Time& runTime);
//- Construct from dictionary
linearDirection(const dictionary& dict);
// Destructor
~regionProperties();
//- Destructor
~linearDirection();
// Member Functions
// Member Operators
// Access
//- Return const reference to the list of fluid region names
const List<word>& fluidRegionNames() const;
//- Return const reference to the list of solid region names
const List<word>& solidRegionNames() const;
point operator()
(
const point& surfacePoint,
const vector& surfaceNormal,
const label layer
) const;
};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace extrudeModels
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -104,3 +96,4 @@ public:
#endif
// ************************************************************************* //

View File

@ -25,7 +25,7 @@ constructFrom patch;
// If construct from patch/mesh:
sourceCase "../cavity";
sourcePatch movingWall;
sourcePatches (movingWall);
// If construct from patch: patch to use for back (can be same as sourcePatch)
exposedPatchName movingWall;
// If construct from surface:
@ -41,6 +41,9 @@ flipNormals false;
//- Linear extrusion in point-normal direction
//extrudeModel linearNormal;
//- Linear extrusion in specified direction
//extrudeModel linearDirection;
//- Wedge extrusion. If nLayers is 1 assumes symmetry around plane.
extrudeModel wedge;
@ -66,6 +69,11 @@ linearNormalCoeffs
thickness 0.05;
}
linearDirectionCoeffs
{
direction (0 0 1);
}
linearRadialCoeffs
{
R 0.1;

View File

@ -363,6 +363,8 @@ int main(int argc, char *argv[])
if (wantRefine)
{
cpuTime timer;
autoRefineDriver refineDriver
(
meshRefiner,
@ -387,10 +389,15 @@ int main(int argc, char *argv[])
meshRefiner,
debug
);
Info<< "Mesh refined in = "
<< timer.cpuTimeIncrement() << " s." << endl;
}
if (wantSnap)
{
cpuTime timer;
autoSnapDriver snapDriver
(
meshRefiner,
@ -413,10 +420,15 @@ int main(int argc, char *argv[])
meshRefiner,
debug
);
Info<< "Mesh snapped in = "
<< timer.cpuTimeIncrement() << " s." << endl;
}
if (wantLayers)
{
cpuTime timer;
autoLayerDriver layerDriver(meshRefiner);
// Layer addition parameters
@ -442,6 +454,9 @@ int main(int argc, char *argv[])
meshRefiner,
debug
);
Info<< "Layers added in = "
<< timer.cpuTimeIncrement() << " s." << endl;
}

View File

@ -222,13 +222,14 @@ labelList findBaffles(const polyMesh& mesh, const labelList& boundaryFaces)
int main(int argc, char *argv[])
{
# include "addRegionOption.H"
argList::validOptions.insert("split", "");
argList::validOptions.insert("overwrite", "");
argList::validOptions.insert("detectOnly", "");
# include "setRootCase.H"
# include "createTime.H"
runTime.functionObjects().off();
# include "createMesh.H"
# include "createNamedMesh.H"
const word oldInstance = mesh.pointsInstance();
bool split = args.optionFound("split");

View File

@ -167,6 +167,16 @@ Foam::mirrorFvMesh::mirrorFvMesh(const IOobject& io)
forAll (oldPatches, patchI)
{
const polyPatch& curPatch = oldPatches[patchI];
if (curPatch.coupled())
{
WarningIn("mirrorFvMesh::mirrorFvMesh(const IOobject&)")
<< "Found coupled patch " << curPatch.name() << endl
<< " Mirroring faces on coupled patches destroys"
<< " the ordering. This might be fixed by running a dummy"
<< " createPatch afterwards." << endl;
}
boolList& curInsBouFace = insertedBouFace[patchI];
curInsBouFace.setSize(curPatch.size());

View File

@ -268,10 +268,7 @@ label twoDNess(const polyMesh& mesh)
{
const polyPatch& patch = patches[patchI];
if
(
typeid(patch) != typeid(wedgePolyPatch)
)
if (!isA<wedgePolyPatch>(patch))
{
const vectorField& n = patch.faceAreas();

View File

@ -121,7 +121,7 @@ void writeVTK
const fileName& vtkName
)
{
if (typeid(currentSet) == typeid(faceSet))
if (isA<faceSet>(currentSet))
{
// Faces of set with OpenFOAM faceID as value
@ -148,7 +148,7 @@ void writeVTK
mesh.time().path()/vtkName
);
}
else if (typeid(currentSet) == typeid(cellSet))
else if (isA<cellSet>(currentSet))
{
// External faces of cellset with OpenFOAM cellID as value
@ -208,7 +208,7 @@ void writeVTK
mesh.time().path()/vtkName
);
}
else if (typeid(currentSet) == typeid(pointSet))
else if (isA<pointSet>(currentSet))
{
writePointSet
(

View File

@ -160,12 +160,8 @@ void reorderPatchFields(fvMesh& mesh, const labelList& oldToNew)
// Adds patch if not yet there. Returns patchID.
label addPatch
(
fvMesh& mesh,
const word& patchName,
const word& patchType
)
template<class PatchType>
label addPatch(fvMesh& mesh, const word& patchName)
{
polyBoundaryMesh& polyPatches =
const_cast<polyBoundaryMesh&>(mesh.boundaryMesh());
@ -173,11 +169,18 @@ label addPatch
label patchI = polyPatches.findPatchID(patchName);
if (patchI != -1)
{
if (polyPatches[patchI].type() == patchType)
if (isA<PatchType>(polyPatches[patchI]))
{
// Already there
return patchI;
}
else
{
FatalErrorIn("addPatch<PatchType>(fvMesh&, const word&)")
<< "Already have patch " << patchName
<< " but of type " << PatchType::typeName
<< exit(FatalError);
}
}
@ -214,7 +217,7 @@ label addPatch
sz,
polyPatch::New
(
patchType,
PatchType::typeName,
patchName,
0, // size
startFaceI,
@ -583,12 +586,12 @@ void getInterfaceSizes
{
// Send to master
{
OPstream toMaster(Pstream::blocking, Pstream::master());
OPstream toMaster(Pstream::blocking, Pstream::masterNo());
toMaster << interfaceSizes;
}
// Receive from master
{
IPstream fromMaster(Pstream::blocking, Pstream::master());
IPstream fromMaster(Pstream::blocking, Pstream::masterNo());
fromMaster >> interfaceSizes;
}
}
@ -1021,17 +1024,15 @@ EdgeMap<label> addRegionPatches
if (interfaceSizes[e] > 0)
{
label patchI = addPatch
label patchI = addPatch<directMappedWallPolyPatch>
(
mesh,
regionNames[e[0]] + "_to_" + regionNames[e[1]],
directMappedWallPolyPatch::typeName
regionNames[e[0]] + "_to_" + regionNames[e[1]]
);
addPatch
addPatch<directMappedWallPolyPatch>
(
mesh,
regionNames[e[1]] + "_to_" + regionNames[e[0]],
directMappedWallPolyPatch::typeName
regionNames[e[1]] + "_to_" + regionNames[e[0]]
);
Info<< "For interface between region " << e[0]
@ -1405,7 +1406,7 @@ int main(int argc, char *argv[])
IOobject
(
"cellToRegion",
mesh.facesInstance(),
runTime.timeName(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,

View File

@ -243,7 +243,7 @@ void domainDecomposition::decomposeMesh(const bool filterEmptyPatches)
const label patchStart = patches[patchi].start();
if (typeid(patches[patchi]) != typeid(cyclicPolyPatch))
if (!isA<cyclicPolyPatch>(patches[patchi]))
{
// Normal patch. Add faces to processor where the cell
// next to the face lives

View File

@ -237,23 +237,28 @@ int main(int argc, char *argv[])
if (writeCellDist)
{
const labelList& procIds = mesh.cellToProc();
// Write the decomposition as labelList for use with 'manual'
// decomposition method.
// FIXME: may attempt to write to a non-existent "region0/"
OFstream os
labelIOList cellDecomposition
(
runTime.path()
/ mesh.facesInstance()
/ regionName
/ "cellDecomposition"
IOobject
(
"cellDecomposition",
mesh.facesInstance(),
mesh,
IOobject::NO_READ,
IOobject::NO_WRITE,
false
),
procIds
);
os << mesh.cellToProc();
cellDecomposition.write();
Info<< nl << "Wrote decomposition to "
<< os.name() << " for use in manual decomposition."
<< endl;
<< cellDecomposition.objectPath()
<< " for use in manual decomposition." << endl;
// Write as volScalarField for postprocessing.
volScalarField cellDist
@ -271,7 +276,6 @@ int main(int argc, char *argv[])
zeroGradientFvPatchScalarField::typeName
);
const labelList& procIds = mesh.cellToProc();
forAll(procIds, celli)
{
cellDist[celli] = procIds[celli];

View File

@ -22,6 +22,12 @@ numberOfSubdomains 4;
//- Keep owner and neighbour on same processor for faces in zones:
// preserveFaceZones (heater solid1 solid3);
//- Keep owner and neighbour on same processor for faces in patches:
// (makes sense only for cyclic patches)
//preservePatches (cyclic_left_right);
method scotch;
// method hierarchical;
// method simple;

View File

@ -45,6 +45,35 @@ void domainDecomposition::distributeCells()
labelHashSet sameProcFaces;
if (decompositionDict_.found("preservePatches"))
{
wordList pNames(decompositionDict_.lookup("preservePatches"));
Info<< "Keeping owner of faces in patches " << pNames
<< " on same processor. This only makes sense for cyclics." << endl;
const polyBoundaryMesh& patches = boundaryMesh();
forAll(pNames, i)
{
label patchI = patches.findPatchID(pNames[i]);
if (patchI == -1)
{
FatalErrorIn("domainDecomposition::distributeCells()")
<< "Unknown preservePatch " << pNames[i]
<< endl << "Valid patches are " << patches.names()
<< exit(FatalError);
}
const polyPatch& pp = patches[patchI];
forAll(pp, i)
{
sameProcFaces.insert(pp.start() + i);
}
}
}
if (decompositionDict_.found("preserveFaceZones"))
{
wordList zNames(decompositionDict_.lookup("preserveFaceZones"));

View File

@ -191,7 +191,7 @@ Foam::fvFieldReconstructor::reconstructFvVolumeField
// add empty patches
if
(
typeid(mesh_.boundary()[patchI]) == typeid(emptyFvPatch)
isType<emptyFvPatch>(mesh_.boundary()[patchI])
&& !patchFields(patchI)
)
{
@ -411,7 +411,7 @@ Foam::fvFieldReconstructor::reconstructFvSurfaceField
// add empty patches
if
(
typeid(mesh_.boundary()[patchI]) == typeid(emptyFvPatch)
isType<emptyFvPatch>(mesh_.boundary()[patchI])
&& !patchFields(patchI)
)
{

View File

@ -127,8 +127,8 @@ Foam::fieldviewTopology::fieldviewTopology
const polyPatch& currPatch = mesh.boundaryMesh()[patchI];
if
(
isType<wallPolyPatch>(currPatch)
|| isType<symmetryPolyPatch>(currPatch)
isA<wallPolyPatch>(currPatch)
|| isA<symmetryPolyPatch>(currPatch)
)
{
forAll(currPatch, patchFaceI)

View File

@ -205,8 +205,8 @@ labelList getSelectedPatches
if
(
isType<emptyPolyPatch>(pp)
|| (Pstream::parRun() && isType<processorPolyPatch>(pp))
isA<emptyPolyPatch>(pp)
|| (Pstream::parRun() && isA<processorPolyPatch>(pp))
)
{
Info<< " discarding empty/processor patch " << patchI
@ -805,7 +805,7 @@ int main(int argc, char *argv[])
labelList(1, patchI)
);
if (!isType<emptyPolyPatch>(pp))
if (!isA<emptyPolyPatch>(pp))
{
// VolFields + patchID
writeFuns::writeCellDataHeader

View File

@ -152,7 +152,7 @@ void Foam::patchWriter::writePatchIDs()
const polyPatch& pp = mesh.boundaryMesh()[patchI];
if (!isType<emptyPolyPatch>(pp))
if (!isA<emptyPolyPatch>(pp))
{
writeFuns::insert(scalarField(pp.size(), patchI), fField);
}

View File

@ -191,7 +191,7 @@ void Foam::vtkPV3Foam::convertPointField
pointData->SetNumberOfTuples(nPoints + addPointCellLabels.size());
pointData->SetNumberOfComponents(nComp);
pointData->Allocate(nComp*(nPoints + addPointCellLabels.size()));
pointData->SetName(tf.name().c_str());
pointData->SetName(ptf.name().c_str());
if (debug)
{

View File

@ -609,7 +609,7 @@ void user_query_file_function
strcpy(face_type_names[patchI], patch.name().c_str());
if (isType<wallPolyPatch>(patch))
if (isA<wallPolyPatch>(patch))
{
wall_flags[patchI] = 1;
}

View File

@ -76,7 +76,7 @@ int main(int argc, char *argv[])
}
// Give patch area
if (isType<cyclicPolyPatch>(mesh.boundaryMesh()[patchi]))
if (isA<cyclicPolyPatch>(mesh.boundaryMesh()[patchi]))
{
Info<< " Cyclic patch vector area: " << nl;
label nFaces = mesh.boundaryMesh()[patchi].size();

View File

@ -64,7 +64,7 @@ int main(int argc, char *argv[])
Info<< "\nWall heat fluxes [W]" << endl;
forAll(patchHeatFlux, patchi)
{
if (typeid(mesh.boundary()[patchi]) == typeid(wallFvPatch))
if (isA<wallFvPatch>(mesh.boundary()[patchi]))
{
Info<< mesh.boundary()[patchi].name()
<< " "

View File

@ -109,7 +109,7 @@ int main(int argc, char *argv[])
{
const fvPatch& currPatch = patches[patchi];
if (typeid(currPatch) == typeid(wallFvPatch))
if (isA<wallFvPatch>(currPatch))
{
yPlus.boundaryField()[patchi] =
d[patchi]

View File

@ -202,7 +202,7 @@ void replaceBoundaryType
dictionary& boundaryDict = dict.subDict("boundaryField");
forAll(bMesh, patchI)
{
if (isType<wallPolyPatch>(bMesh[patchI]))
if (isA<wallPolyPatch>(bMesh[patchI]))
{
word patchName = bMesh[patchI].name();
dictionary& oldPatch = boundaryDict.subDict(patchName);

View File

@ -30,7 +30,8 @@ Description
type in the field and polyMesh/boundary files.
Reads dictionaries (fields) and entries to change from a dictionary.
E.g. to make the @em movingWall a @em fixedValue for @em p, the
E.g. to make the @em movingWall a @em fixedValue for @em p but all other
@em Walls a zeroGradient boundary condition, the
@c system/changeDictionaryDict would contain the following:
@verbatim
dictionaryReplacement
@ -39,6 +40,10 @@ Description
{
boundaryField
{
".*Wall" // entry to change
{
type zeroGradient;
}
movingWall // entry to change
{
type fixedValue;
@ -49,6 +54,13 @@ Description
}
@endverbatim
Usage
- changeDictionary [OPTION]
@param -literalRE \n
Do not interpret regular expressions; treat them as any other keyword.
\*---------------------------------------------------------------------------*/
@ -56,6 +68,7 @@ Description
#include "IOobjectList.H"
#include "IOPtrList.H"
#include "volFields.H"
#include "stringListOps.H"
using namespace Foam;
@ -68,17 +81,189 @@ namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
bool merge(dictionary&, const dictionary&, const bool);
// Add thisEntry to dictionary thisDict.
bool addEntry
(
dictionary& thisDict,
entry& thisEntry,
const entry& mergeEntry,
const bool literalRE
)
{
bool changed = false;
// Recursively merge sub-dictionaries
// TODO: merge without copying
if (thisEntry.isDict() && mergeEntry.isDict())
{
if
(
merge
(
const_cast<dictionary&>(thisEntry.dict()),
mergeEntry.dict(),
literalRE
)
)
{
changed = true;
}
}
else
{
// Should use in-place modification instead of adding
thisDict.add(mergeEntry.clone(thisDict).ptr(), true);
changed = true;
}
return changed;
}
// Dictionary merging/editing.
// literalRE:
// - true: behave like dictionary::merge, i.e. add regexps just like
// any other key.
// - false : interpret wildcard as a rule for items to be matched.
bool merge
(
dictionary& thisDict,
const dictionary& mergeDict,
const bool literalRE
)
{
bool changed = false;
// Save current (non-wildcard) keys before adding items.
HashSet<word> thisKeysSet;
{
List<keyType> keys = thisDict.keys(false);
forAll(keys, i)
{
thisKeysSet.insert(keys[i]);
}
}
// Pass 1. All literal matches
forAllConstIter(IDLList<entry>, mergeDict, mergeIter)
{
const keyType& key = mergeIter().keyword();
if (literalRE || !key.isPattern())
{
entry* entryPtr = thisDict.lookupEntryPtr
(
key,
false, // recursive
false // patternMatch
);
if (entryPtr)
{
// Mark thisDict entry as having been match for wildcard
// handling later on.
thisKeysSet.erase(entryPtr->keyword());
if
(
addEntry
(
thisDict,
*entryPtr,
mergeIter(),
literalRE
)
)
{
changed = true;
}
}
else
{
// not found - just add
thisDict.add(mergeIter().clone(thisDict).ptr());
changed = true;
}
}
}
// Pass 2. Wildcard matches (if any) on any non-match keys.
if (!literalRE && thisKeysSet.size() > 0)
{
wordList thisKeys(thisKeysSet.toc());
forAllConstIter(IDLList<entry>, mergeDict, mergeIter)
{
const keyType& key = mergeIter().keyword();
if (key.isPattern())
{
// Find all matching entries in the original thisDict
labelList matches = findStrings(key, thisKeys);
forAll(matches, i)
{
label matchI = matches[i];
entry& thisEntry = const_cast<entry&>
(
thisDict.lookupEntry(thisKeys[matchI], false, false)
);
if
(
addEntry
(
thisDict,
thisEntry,
mergeIter(),
literalRE
)
)
{
changed = true;
}
}
}
}
}
return changed;
}
// Main program:
int main(int argc, char *argv[])
{
argList::validOptions.insert("instance", "instance");
argList::validOptions.insert("literalRE", "");
#include "addRegionOption.H"
#include "setRootCase.H"
#include "createTime.H"
#include "createNamedMesh.H"
bool literalRE = args.optionFound("literalRE");
if (literalRE)
{
Info<< "Not interpreting any regular expressions (RE)"
<< " in the changeDictionaryDict." << endl
<< "Instead they are handled as any other entry, i.e. added if"
<< " not present." << endl;
}
fileName regionPrefix = "";
if (regionName != fvMesh::defaultRegion)
{
@ -163,7 +348,7 @@ int main(int argc, char *argv[])
Info<< "Merging entries from " << replaceDict.toc() << endl;
// Merge the replacements in
fieldDict.merge(replaceDict);
merge(fieldDict, replaceDict, literalRE);
Info<< "fieldDict:" << fieldDict << endl;
@ -229,7 +414,7 @@ int main(int argc, char *argv[])
Info<< "Merging entries from " << replaceDict.toc() << endl;
// Merge the replacements in
fieldDict.merge(replaceDict);
merge(fieldDict, replaceDict, literalRE);
Info<< "Writing modified fieldDict " << fieldName << endl;
fieldDict.regIOobject::write();

View File

@ -16,26 +16,30 @@ FoamFile
dictionaryReplacement
{
boundary
{
".*"
{
type directMappedPatch;
}
}
T
{
internalField uniform 300;
boundaryField
{
".*"
{
type zeroGradient;
}
minY
{
type fixedValue;
value uniform 500;
}
minZ
{
type zeroGradient;
}
maxZ
{
type zeroGradient;
}
}
}
@ -45,18 +49,11 @@ dictionaryReplacement
boundaryField
{
minY
{
type zeroGradient;
}
minZ
{
type zeroGradient;
}
maxZ
".*"
{
type zeroGradient;
}
}
}
@ -66,18 +63,11 @@ dictionaryReplacement
boundaryField
{
minY
{
type zeroGradient;
}
minZ
{
type zeroGradient;
}
maxZ
".*"
{
type zeroGradient;
}
}
}
@ -87,18 +77,11 @@ dictionaryReplacement
boundaryField
{
minY
{
type zeroGradient;
}
minZ
{
type zeroGradient;
}
maxZ
".*"
{
type zeroGradient;
}
}
}
}

View File

@ -164,7 +164,7 @@ void mapConsistentSubMesh
forAll(meshTarget.boundary(), patchi)
{
if (typeid(meshTarget.boundary()[patchi]) != typeid(processorFvPatch))
if (!isA<processorFvPatch>(meshTarget.boundary()[patchi]))
{
patchMap.insert
(
@ -201,7 +201,7 @@ wordList addProcessorPatches
forAll (meshTarget.boundary(), patchi)
{
if (typeid(meshTarget.boundary()[patchi]) == typeid(processorFvPatch))
if (isA<processorFvPatch>(meshTarget.boundary()[patchi]))
{
if
(

View File

@ -108,11 +108,7 @@ int main(int argc, char *argv[])
{
const polyPatch& patch = bMesh[patchI];
if
(
includeProcPatches
|| (patch.type() != processorPolyPatch::typeName)
)
if (includeProcPatches || !isA<processorPolyPatch>(patch))
{
includePatches.insert(patchI);
}