Commit c56d376b authored by Sergio Ferraris's avatar Sergio Ferraris
Browse files

ENH: Adding 'baseGroup' option to createBaffle.C to add a pair patches but in

different groups. This is used in 3D baffle where the generated patches are not
coupled.
     The tutorial circuitBoardCooling has been updated.
parent fbffbdb1
......@@ -619,19 +619,41 @@ int main(int argc, char *argv[])
const word masterName = groupName + "_master";
const word slaveName = groupName + "_slave";
dictionary patchDict = patchSource;
patchDict.set("nFaces", 0);
patchDict.set("startFace", 0);
patchDict.set("coupleGroup", groupName);
word groupNameMaster = groupName;
word groupNameSlave = groupName;
addPatch(mesh, masterName, groupName, patchDict);
addPatch(mesh, slaveName, groupName, patchDict);
dictionary patchDictMaster(patchSource);
patchDictMaster.set("nFaces", 0);
patchDictMaster.set("startFace", 0);
patchDictMaster.set("coupleGroup", groupName);
dictionary patchDictSlave(patchDictMaster);
// Note: This is added for the particular case where we want
// master and slave in different groupNames
// (ie 3D thermal baffles)
bool groupBase = false;
if (patchSource.found("groupBase"))
{
groupBase = readBool(patchSource.lookup("groupBase"));
if (groupBase)
{
groupNameMaster = groupName + "Group_master";
groupNameSlave = groupName + "Group_slave";
patchDictMaster.set("coupleGroup", groupNameMaster);
patchDictSlave.set("coupleGroup", groupNameSlave);
}
}
addPatch(mesh, masterName, groupNameMaster, patchDictMaster);
addPatch(mesh, slaveName, groupNameSlave, patchDictSlave);
}
}
}
// Make sure patches and zoneFaces are synchronised across couples
mesh.boundaryMesh().checkParallelSync(true);
mesh.faceZones().checkParallelSync(true);
......@@ -793,6 +815,12 @@ int main(int argc, char *argv[])
else
{
const dictionary& patchSource = dict.subDict("patchPairs");
bool groupBase = false;
if (patchSource.found("groupBase"))
{
groupBase = readBool(patchSource.lookup("groupBase"));
}
const word& groupName = selectors[selectorI].name();
if (patchSource.found("patchFields"))
......@@ -801,23 +829,51 @@ int main(int argc, char *argv[])
(
"patchFields"
);
// Add coupleGroup to all entries
forAllIter(dictionary, patchFieldsDict, iter)
if (!groupBase)
{
if (iter().isDict())
// Add coupleGroup to all entries
forAllIter(dictionary, patchFieldsDict, iter)
{
dictionary& dict = iter().dict();
dict.set("coupleGroup", groupName);
if (iter().isDict())
{
dictionary& dict = iter().dict();
dict.set("coupleGroup", groupName);
}
}
}
const labelList& patchIDs = pbm.groupPatchIDs()[groupName];
forAll(patchIDs, i)
const labelList& patchIDs =
pbm.groupPatchIDs()[groupName];
forAll(patchIDs, i)
{
fvMeshTools::setPatchFields
(
mesh,
patchIDs[i],
patchFieldsDict
);
}
}
else
{
const word masterPatchName(groupName + "_master");
const word slavePatchName(groupName + "_slave");
label patchIMaster = pbm.findPatchID(masterPatchName);
label patchISlave = pbm.findPatchID(slavePatchName);
fvMeshTools::setPatchFields
(
mesh,
patchIMaster,
patchFieldsDict
);
fvMeshTools::setPatchFields
(
mesh,
patchIDs[i],
patchISlave,
patchFieldsDict
);
}
......
......@@ -43,6 +43,39 @@ defineTypeNameAndDebug(extrudePatchMesh, 0);
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
extrudePatchMesh::extrudePatchMesh
(
const fvMesh& mesh,
const fvPatch& patch,
const dictionary& dict,
const word regionName,
const List<polyPatch*>& regionPatches
)
:
fvMesh
(
IOobject
(
regionName,
mesh.facesInstance(),
mesh,
IOobject::READ_IF_PRESENT,
IOobject::NO_WRITE,
true
),
xferCopy(pointField()),
xferCopy(faceList()),
xferCopy(labelList()),
xferCopy(labelList()),
false
),
extrudedPatch_(patch.patch()),
dict_(dict)
{
extrudeMesh(regionPatches);
}
extrudePatchMesh::extrudePatchMesh
(
const fvMesh& mesh,
......@@ -68,11 +101,59 @@ extrudePatchMesh::extrudePatchMesh
xferCopy(labelList()),
false
),
extrudedPatch_(patch.patch())
extrudedPatch_(patch.patch()),
dict_(dict)
{
List<polyPatch*> regionPatches(3);
List<word> patchNames(regionPatches.size());
List<word> patchTypes(regionPatches.size());
PtrList<dictionary> dicts(regionPatches.size());
forAll (dicts, patchI)
{
if (!dicts.set(patchI))
{
dicts.set(patchI, new dictionary());
}
}
dicts[bottomPatchID] = dict_.subDict("bottomCoeffs");
dicts[sidePatchID] = dict_.subDict("sideCoeffs");
dicts[topPatchID] = dict_.subDict("topCoeffs");
forAll (dicts, patchI)
{
dicts[patchI].lookup("name") >> patchNames[patchI];
dicts[patchI].lookup("type") >> patchTypes[patchI];
}
forAll (regionPatches, patchI)
{
dictionary& patchDict = dicts[patchI];
patchDict.set("nFaces", 0);
patchDict.set("startFace", 0);
regionPatches[patchI] = polyPatch::New
(
patchNames[patchI],
patchDict,
patchI,
mesh.boundaryMesh()
).ptr();
}
extrudeMesh(regionPatches);
}
void extrudePatchMesh::extrudeMesh(const List<polyPatch*>& regionPatches)
{
if (this->boundaryMesh().size() == 0)
{
bool columnCells = readBool(dict.lookup("columnCells"));
bool columnCells = readBool(dict_.lookup("columnCells"));
PackedBoolList nonManifoldEdge(extrudedPatch_.nEdges());
for (label edgeI = 0; edgeI < extrudedPatch_.nInternalEdges(); edgeI++)
......@@ -83,7 +164,7 @@ extrudePatchMesh::extrudePatchMesh
}
}
autoPtr<extrudeModel> model_(extrudeModel::New(dict));
autoPtr<extrudeModel> model_(extrudeModel::New(dict_));
faceList pointGlobalRegions;
faceList pointLocalRegions;
......@@ -180,7 +261,7 @@ extrudePatchMesh::extrudePatchMesh
pointLocalRegions,
localRegionPoints
);
/*
List<polyPatch*> regionPatches(3);
List<word> patchNames(regionPatches.size());
List<word> patchTypes(regionPatches.size());
......@@ -194,9 +275,9 @@ extrudePatchMesh::extrudePatchMesh
}
}
dicts[bottomPatchID] = dict.subDict("bottomCoeffs");
dicts[sidePatchID] = dict.subDict("sideCoeffs");
dicts[topPatchID] = dict.subDict("topCoeffs");
dicts[bottomPatchID] = dict_.subDict("bottomCoeffs");
dicts[sidePatchID] = dict_.subDict("sideCoeffs");
dicts[topPatchID] = dict_.subDict("topCoeffs");
forAll (dicts, patchI)
{
......@@ -219,7 +300,7 @@ extrudePatchMesh::extrudePatchMesh
).ptr();
}
*/
this->clearOut();
this->removeFvBoundary();
this->addFvPatches(regionPatches, true);
......
......@@ -105,6 +105,15 @@ private:
//- Const reference to the patch from which this mesh is extruded
const polyPatch& extrudedPatch_;
//- Model dictionary
dictionary dict_;
// Private member functions
//- Extrude mesh using polyPatches
void extrudeMesh(const List<polyPatch*>& regionPatches);
public:
......@@ -123,6 +132,17 @@ public:
const word
);
//- Construct from mesh, patch, dictionary and new mesh
// polyPatch information
extrudePatchMesh
(
const fvMesh&,
const fvPatch&,
const dictionary&,
const word,
const List<polyPatch*>& polyPatches
);
//- Destructor
virtual ~extrudePatchMesh();
......
......@@ -25,6 +25,9 @@ License
#include "thermalBaffleFvPatchScalarField.H"
#include "addToRunTimeSelectionTable.H"
#include "emptyPolyPatch.H"
#include "polyPatch.H"
#include "mappedWallPolyPatch.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
......@@ -114,17 +117,6 @@ thermalBaffleFvPatchScalarField
owner_ = true;
baffle_->rename(baffleName);
}
else if //Backwards compatibility (if region exists)
(
thisMesh.time().foundObject<fvMesh>(regionName)
&& baffle_.empty()
&& regionName != "none"
)
{
baffle_.reset(baffle::New(thisMesh, dict).ptr());
owner_ = true;
baffle_->rename(baffleName);
}
}
}
......@@ -168,19 +160,79 @@ void thermalBaffleFvPatchScalarField::rmap
void thermalBaffleFvPatchScalarField::createPatchMesh()
{
const fvMesh& defaultRegion =
db().time().lookupObject<fvMesh>(fvMesh::defaultRegion);
const fvMesh& thisMesh = patch().boundaryMesh().mesh();
word regionName = dict_.lookup("regionName");
List<polyPatch*> regionPatches(3);
List<word> patchNames(regionPatches.size());
List<word> patchTypes(regionPatches.size());
List<dictionary> dicts(regionPatches.size());
patchNames[bottomPatchID] = word("bottom");
patchNames[sidePatchID] = word("side");
patchNames[topPatchID] = word("top");
patchTypes[bottomPatchID] = mappedWallPolyPatch::typeName;
patchTypes[topPatchID] = mappedWallPolyPatch::typeName;
if (readBool(dict_.lookup("columnCells")))
{
patchTypes[sidePatchID] = emptyPolyPatch::typeName;
}
else
{
patchTypes[sidePatchID] = polyPatch::typeName;
}
const mappedPatchBase& mpp =
refCast<const mappedPatchBase>(patch().patch());
const word coupleGroup(mpp.coupleGroup());
wordList inGroups(1);
inGroups[0] = coupleGroup;
dicts[bottomPatchID].add("coupleGroup", coupleGroup);
dicts[bottomPatchID].add("inGroups", inGroups);
dicts[bottomPatchID].add("sampleMode", mpp.sampleModeNames_[mpp.mode()]);
const label sepPos = coupleGroup.find('_');
const word coupleGroupSlave = coupleGroup(0, sepPos) + "_slave";
inGroups[0] = coupleGroupSlave;
dicts[topPatchID].add("coupleGroup", coupleGroupSlave);
dicts[topPatchID].add("inGroups", inGroups);
dicts[topPatchID].add("sampleMode", mpp.sampleModeNames_[mpp.mode()]);
forAll (regionPatches, patchI)
{
dictionary& patchDict = dicts[patchI];
patchDict.set("nFaces", 0);
patchDict.set("startFace", 0);
regionPatches[patchI] = polyPatch::New
(
patchTypes[patchI],
patchNames[patchI],
dicts[patchI],
patchI,
thisMesh.boundaryMesh()
).ptr();
}
extrudeMeshPtr_.reset
(
new extrudePatchMesh
(
defaultRegion,
thisMesh,
patch(),
dict_,
regionName
regionName,
regionPatches
)
);
......
......@@ -182,6 +182,14 @@ class thermalBaffleFvPatchScalarField
{
// Private data
//- Enumeration of patch IDs
enum patchID
{
bottomPatchID,
topPatchID,
sidePatchID
};
//- Is the baffle owner
bool owner_;
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -47,7 +47,7 @@ turbulentTemperatureCoupledBaffleMixedFvPatchScalarField
:
mixedFvPatchScalarField(p, iF),
temperatureCoupledBase(patch(), "undefined", "undefined-K"),
neighbourFieldName_("undefined-neighbourFieldName")
TnbrName_("undefined-Tnbr")
{
this->refValue() = 0.0;
this->refGrad() = 0.0;
......@@ -66,7 +66,7 @@ turbulentTemperatureCoupledBaffleMixedFvPatchScalarField
:
mixedFvPatchScalarField(ptf, p, iF, mapper),
temperatureCoupledBase(patch(), ptf.KMethod(), ptf.kappaName()),
neighbourFieldName_(ptf.neighbourFieldName_)
TnbrName_(ptf.TnbrName_)
{}
......@@ -80,7 +80,7 @@ turbulentTemperatureCoupledBaffleMixedFvPatchScalarField
:
mixedFvPatchScalarField(p, iF),
temperatureCoupledBase(patch(), dict),
neighbourFieldName_(dict.lookup("neighbourFieldName"))
TnbrName_(dict.lookup("neighbourFieldName"))
{
if (!isA<mappedPatchBase>(this->patch().patch()))
{
......@@ -129,7 +129,7 @@ turbulentTemperatureCoupledBaffleMixedFvPatchScalarField
:
mixedFvPatchScalarField(wtcsf, iF),
temperatureCoupledBase(patch(), wtcsf.KMethod(), wtcsf.kappaName()),
neighbourFieldName_(wtcsf.neighbourFieldName_)
TnbrName_(wtcsf.TnbrName_)
{}
......@@ -169,7 +169,7 @@ void turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::updateCoeffs()
(
nbrPatch.lookupPatchField<volScalarField, scalar>
(
neighbourFieldName_
TnbrName_
)
);
......@@ -237,7 +237,7 @@ void turbulentTemperatureCoupledBaffleMixedFvPatchScalarField::write
) const
{
mixedFvPatchScalarField::write(os);
os.writeKeyword("neighbourFieldName")<< neighbourFieldName_
os.writeKeyword("TnbrName")<< TnbrName_
<< token::END_STATEMENT << nl;
temperatureCoupledBase::write(os);
}
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -89,7 +89,7 @@ class turbulentTemperatureCoupledBaffleMixedFvPatchScalarField
// Private data
//- Name of field on the neighbour region
const word neighbourFieldName_;
const word TnbrName_;
public:
......
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2012 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -84,9 +84,9 @@ turbulentTemperatureRadCoupledMixedFvPatchScalarField
:
mixedFvPatchScalarField(p, iF),
temperatureCoupledBase(patch(), dict),
TnbrName_(dict.lookup("Tnbr")),
QrNbrName_(dict.lookup("QrNbr")),
QrName_(dict.lookup("Qr"))
TnbrName_(dict.lookupOrDefault<word>("Tnbr", "T")),
QrNbrName_(dict.lookupOrDefault<word>("QrNbr", "none")),
QrName_(dict.lookupOrDefault<word>("Qr", "none"))
{
if (!isA<mappedPatchBase>(this->patch().patch()))
{
......
......@@ -24,11 +24,8 @@ boundaryField
bottom
{
type compressible::thermalBaffle;
Tnbr T;
kappa solidThermo;
kappaName none;
QrNbr none;
Qr none;
value uniform 300;
}
side
......@@ -38,11 +35,8 @@ boundaryField
top
{
type compressible::thermalBaffle;
Tnbr T;
kappa solidThermo;
kappaName none;
QrNbr none;
Qr none;
value uniform 300;
}
}
......
......@@ -9,15 +9,10 @@
T
{
type compressible::thermalBaffle;
Tnbr T;
kappa fluidThermo;
kappaName none;
QrNbr none;
Qr none;
value uniform 300;
// Thermo baffle model
//thermalBaffleModel thermalBaffle;
regionName ${baffleRegionName};
active yes;
......@@ -26,33 +21,6 @@ T
// New fvMesh (region) information
# include "extrudeModel"
// New mesh polyPatch information
bottomCoeffs
{
name "bottom";
type mappedWall;
sampleMode nearestPatchFace;
samplePatch ${masterPatchName};