diff --git a/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C b/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C index bc0e78a67f..cdbe770d1a 100644 --- a/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C +++ b/applications/utilities/mesh/manipulation/createBaffles/createBaffles.C @@ -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) + { + fvMeshTools::setPatchFields + ( + mesh, + patchIDs[i], + patchFieldsDict + ); } } - - const labelList& patchIDs = pbm.groupPatchIDs()[groupName]; - forAll(patchIDs, i) + else { + const word masterPatchName(groupName + "_master"); + const word slavePatchName(groupName + "_slave"); + + label patchIMaster = pbm.findPatchID(masterPatchName); + label patchISlave = pbm.findPatchID(slavePatchName); + fvMeshTools::setPatchFields ( mesh, - patchIDs[i], + patchIMaster, + patchFieldsDict + ); + + fvMeshTools::setPatchFields + ( + mesh, + patchISlave, patchFieldsDict ); } diff --git a/src/dynamicMesh/extrudePatchMesh/extrudePatchMesh.C b/src/dynamicMesh/extrudePatchMesh/extrudePatchMesh.C index 970e0dac47..ca87555627 100644 --- a/src/dynamicMesh/extrudePatchMesh/extrudePatchMesh.C +++ b/src/dynamicMesh/extrudePatchMesh/extrudePatchMesh.C @@ -43,6 +43,39 @@ defineTypeNameAndDebug(extrudePatchMesh, 0); // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // +extrudePatchMesh::extrudePatchMesh +( + const fvMesh& mesh, + const fvPatch& patch, + const dictionary& dict, + const word regionName, + const List& 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 regionPatches(3); + List patchNames(regionPatches.size()); + List patchTypes(regionPatches.size()); + PtrList 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& 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 model_(extrudeModel::New(dict)); + autoPtr model_(extrudeModel::New(dict_)); faceList pointGlobalRegions; faceList pointLocalRegions; @@ -180,7 +261,7 @@ extrudePatchMesh::extrudePatchMesh pointLocalRegions, localRegionPoints ); - +/* List regionPatches(3); List patchNames(regionPatches.size()); List 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); diff --git a/src/dynamicMesh/extrudePatchMesh/extrudePatchMesh.H b/src/dynamicMesh/extrudePatchMesh/extrudePatchMesh.H index 0ced75eec6..6fc480b1bd 100644 --- a/src/dynamicMesh/extrudePatchMesh/extrudePatchMesh.H +++ b/src/dynamicMesh/extrudePatchMesh/extrudePatchMesh.H @@ -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& 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& polyPatches + ); + //- Destructor virtual ~extrudePatchMesh(); diff --git a/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.C b/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.C index 027336f2e6..aa3195cc6c 100644 --- a/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.C +++ b/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.C @@ -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(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::defaultRegion); + + const fvMesh& thisMesh = patch().boundaryMesh().mesh(); word regionName = dict_.lookup("regionName"); + List regionPatches(3); + List patchNames(regionPatches.size()); + List patchTypes(regionPatches.size()); + List 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(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 ) ); diff --git a/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.H b/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.H index 543df2e39b..7516656350 100644 --- a/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.H +++ b/src/regionModels/thermalBaffleModels/derivedFvPatchFields/thermalBaffle/thermalBaffleFvPatchScalarField.H @@ -182,6 +182,14 @@ class thermalBaffleFvPatchScalarField { // Private data + //- Enumeration of patch IDs + enum patchID + { + bottomPatchID, + topPatchID, + sidePatchID + }; + //- Is the baffle owner bool owner_; diff --git a/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C b/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C index 862d4ee6be..bd27dc874d 100644 --- a/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C +++ b/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.C @@ -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(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 ( - 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); } diff --git a/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.H b/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.H index e9fc1f84ae..60e61d9d0f 100644 --- a/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.H +++ b/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/turbulentTemperatureCoupledBaffleMixed/turbulentTemperatureCoupledBaffleMixedFvPatchScalarField.H @@ -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: diff --git a/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C b/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C index 137db852d4..6d512d50bd 100644 --- a/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C +++ b/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/turbulentTemperatureRadCoupledMixed/turbulentTemperatureRadCoupledMixedFvPatchScalarField.C @@ -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("Tnbr", "T")), + QrNbrName_(dict.lookupOrDefault("QrNbr", "none")), + QrName_(dict.lookupOrDefault("Qr", "none")) { if (!isA(this->patch().patch())) { diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/0.org/baffle3DRegion/T b/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/0.org/baffle3DRegion/T index 2c6bde2e11..656062e8a9 100644 --- a/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/0.org/baffle3DRegion/T +++ b/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/0.org/baffle3DRegion/T @@ -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; } } diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/0.org/include/3DBaffle/3DTemperatureMasterBafflePatches b/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/0.org/include/3DBaffle/3DTemperatureMasterBafflePatches index 17ab57161f..a068b051ba 100644 --- a/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/0.org/include/3DBaffle/3DTemperatureMasterBafflePatches +++ b/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/0.org/include/3DBaffle/3DTemperatureMasterBafflePatches @@ -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}; - offsetMode uniform; - offset (0 0 0); - } - - topCoeffs - { - name "top"; - type mappedWall; - sampleMode nearestPatchFace; - samplePatch ${slavePatchName}; - offsetMode uniform; - offset (0 0 0); - } - - sideCoeffs - { - name "side"; - type patch; - } } // ************************************************************************* // diff --git a/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/system/createBafflesDict b/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/system/createBafflesDict index fe16ef97a2..2aed1e32a6 100644 --- a/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/system/createBafflesDict +++ b/tutorials/heatTransfer/buoyantSimpleFoam/circuitBoardCooling/system/createBafflesDict @@ -48,47 +48,16 @@ baffles surface triSurfaceMesh; name baffle3D.stl; - patches + patchPairs { - master + type mappedWall; + sampleMode nearestPatchFace; + //Group master and slave in different groups. (default off) + groupBase on; + patchFields { - //- Master side patch - name ${masterPatchName}; - - type mappedWall; - inGroups (baffleWallGroup); - - sampleMode nearestPatchFace; - sampleRegion ${baffleRegionName}; - samplePatch bottom; - offsetMode uniform; - offset (0 0 0); - - patchFields - { - #include "./0/include/wallBafflePatches" - #include "./0/include/3DBaffle/3DTemperatureMasterBafflePatches" - } - } - slave - { - //- Slave side patch - name ${slavePatchName}; - - type mappedWall; - inGroups (baffleWallGroup); - - sampleMode nearestPatchFace; - sampleRegion ${baffleRegionName}; - samplePatch top; - offsetMode uniform; - offset (0 0 0); - - patchFields - { - #include "./0/include/wallBafflePatches" - #include "./0/include/3DBaffle/3DTemperatureSlaveBafflePatches" - } + #include "./0/include/wallBafflePatches" + #include "./0/include/3DBaffle/3DTemperatureMasterBafflePatches" } } }