From 7dd14d82e0b67c64b620e17d56dc180cca723dd0 Mon Sep 17 00:00:00 2001 From: Sergio Ferraris Date: Wed, 8 May 2013 09:27:48 +0100 Subject: [PATCH 1/2] BUG: Completing autoMap and rMap fucntions for private scalarFields. Correcting write function for solidThermo Ptr --- .../thermalBaffle1DFvPatchScalarField.C | 35 ++++++++++++++++--- .../thermalBaffle1DFvPatchScalarField.H | 16 +++++++-- 2 files changed, 45 insertions(+), 6 deletions(-) diff --git a/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C b/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C index 05370cbc44..e39162f585 100644 --- a/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C +++ b/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.C @@ -51,6 +51,7 @@ thermalBaffle1DFvPatchScalarField baffleActivated_(true), thickness_(p.size()), Qs_(p.size()), + solidDict_(), solidPtr_(NULL) {} @@ -70,6 +71,7 @@ thermalBaffle1DFvPatchScalarField baffleActivated_(ptf.baffleActivated_), thickness_(ptf.thickness_), Qs_(ptf.Qs_), + solidDict_(ptf.solidDict_), solidPtr_(ptf.solidPtr_) {} @@ -88,6 +90,7 @@ thermalBaffle1DFvPatchScalarField baffleActivated_(readBool(dict.lookup("baffleActivated"))), thickness_(scalarField("thickness", dict, p.size())), Qs_(scalarField("Qs", dict, p.size())), + solidDict_(dict), solidPtr_(new solidType(dict)) { if (!isA(this->patch().patch())) @@ -141,6 +144,7 @@ thermalBaffle1DFvPatchScalarField baffleActivated_(ptf.baffleActivated_), thickness_(ptf.thickness_), Qs_(ptf.Qs_), + solidDict_(ptf.solidDict_), solidPtr_(ptf.solidPtr_) {} @@ -158,12 +162,28 @@ thermalBaffle1DFvPatchScalarField baffleActivated_(ptf.baffleActivated_), thickness_(ptf.thickness_), Qs_(ptf.Qs_), + solidDict_(ptf.solidDict_), solidPtr_(ptf.solidPtr_) {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +template +const solidType& thermalBaffle1DFvPatchScalarField::solidPtr() const +{ + if (!solidPtr_.empty()) + { + return solidPtr_(); + } + else + { + solidPtr_.reset(new solidType(solidDict_)); + return solidPtr_(); + } +} + + template void thermalBaffle1DFvPatchScalarField::autoMap ( @@ -171,6 +191,8 @@ void thermalBaffle1DFvPatchScalarField::autoMap ) { mixedFvPatchScalarField::autoMap(m); + thickness_.autoMap(m); + Qs_.autoMap(m); } template @@ -181,6 +203,12 @@ void thermalBaffle1DFvPatchScalarField::rmap ) { mixedFvPatchScalarField::rmap(ptf, addr); + + const thermalBaffle1DFvPatchScalarField& tiptf = + refCast(ptf); + + thickness_.rmap(tiptf.thickness_, addr); + Qs_.rmap(tiptf.Qs_, addr); } @@ -264,7 +292,7 @@ void thermalBaffle1DFvPatchScalarField::updateCoeffs() forAll(KDeltaw, i) { KDeltaw[i] = - solidPtr_().kappa(0.0, (Tp[i] + nbrTw[i])/2.0)/thickness_[i]; + solidPtr().kappa(0.0, (Tp[i] + nbrTw[i])/2.0)/thickness_[i]; } const scalarField q @@ -338,8 +366,7 @@ void thermalBaffle1DFvPatchScalarField::updateCoeffs() } template -void thermalBaffle1DFvPatchScalarField:: -write(Ostream& os) const +void thermalBaffle1DFvPatchScalarField:: write(Ostream& os) const { mixedFvPatchScalarField::write(os); os.writeKeyword("TName") @@ -348,7 +375,7 @@ write(Ostream& os) const os.writeKeyword("baffleActivated") << baffleActivated_ << token::END_STATEMENT << nl; Qs_.writeEntry("Qs", os); - solidPtr_->write(os); + solidPtr().write(os); } diff --git a/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.H b/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.H index c2b209cb16..399e80062a 100644 --- a/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.H +++ b/src/turbulenceModels/compressible/turbulenceModel/derivedFvPatchFields/thermalBaffle1D/thermalBaffle1DFvPatchScalarField.H @@ -70,8 +70,17 @@ class thermalBaffle1DFvPatchScalarField //- Superficial heat source [W/m2] scalarField Qs_; - // Solid thermo - autoPtr solidPtr_; + //- Solid dictionary + dictionary solidDict_; + + //- Solid thermo + mutable autoPtr solidPtr_; + + + // Private members + + //- Return non const solid thermo autoMap + const solidType& solidPtr() const; public: @@ -144,6 +153,7 @@ public: // Member functions + // Mapping functions //- Map (and resize as needed) from self given a mapping object @@ -160,6 +170,8 @@ public: ); + + //- Update the coefficients associated with the patch field virtual void updateCoeffs(); From aea1fbff8b8599866902129f4f00b61b90e3464a Mon Sep 17 00:00:00 2001 From: mattijs Date: Wed, 8 May 2013 09:47:00 +0100 Subject: [PATCH 2/2] ENH: mergeMeshes: preserve additional patch data --- .../manipulation/mergeMeshes/mergePolyMesh.C | 32 ++++++++++++------- .../manipulation/mergeMeshes/mergePolyMesh.H | 8 ++--- 2 files changed, 24 insertions(+), 16 deletions(-) diff --git a/applications/utilities/mesh/manipulation/mergeMeshes/mergePolyMesh.C b/applications/utilities/mesh/manipulation/mergeMeshes/mergePolyMesh.C index 26d472c44d..afe8c1ce63 100644 --- a/applications/utilities/mesh/manipulation/mergeMeshes/mergePolyMesh.C +++ b/applications/utilities/mesh/manipulation/mergeMeshes/mergePolyMesh.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 @@ -54,7 +54,7 @@ Foam::label Foam::mergePolyMesh::patchIndex(const polyPatch& p) { if (patchNames_[patchI] == pName) { - if (patchTypes_[patchI] == pType) + if (word(patchDicts_[patchI]["type"]) == pType) { // Found name and types match return patchI; @@ -68,7 +68,11 @@ Foam::label Foam::mergePolyMesh::patchIndex(const polyPatch& p) } // Patch not found. Append to the list - patchTypes_.append(pType); + { + OStringStream os; + p.write(os); + patchDicts_.append(dictionary(IStringStream(os.str())())); + } if (nameFound) { @@ -121,20 +125,22 @@ Foam::mergePolyMesh::mergePolyMesh(const IOobject& io) : polyMesh(io), meshMod_(*this), - patchTypes_(2*boundaryMesh().size()), patchNames_(2*boundaryMesh().size()), + patchDicts_(2*boundaryMesh().size()), pointZoneNames_(), faceZoneNames_(), cellZoneNames_() { // Insert the original patches into the list - wordList curPatchTypes = boundaryMesh().types(); wordList curPatchNames = boundaryMesh().names(); - forAll(curPatchTypes, patchI) + forAll(boundaryMesh(), patchI) { - patchTypes_.append(curPatchTypes[patchI]); - patchNames_.append(curPatchNames[patchI]); + patchNames_.append(boundaryMesh()[patchI].name()); + + OStringStream os; + boundaryMesh()[patchI].write(os); + patchDicts_.append(dictionary(IStringStream(os.str())())); } // Insert point, face and cell zones into the list @@ -379,7 +385,7 @@ void Foam::mergePolyMesh::addMesh(const polyMesh& m) void Foam::mergePolyMesh::merge() { Info<< "patch names: " << patchNames_ << nl - << "patch types: " << patchTypes_ << nl + << "patch dicts: " << patchDicts_ << nl << "point zone names: " << pointZoneNames_ << nl << "face zone names: " << faceZoneNames_ << nl << "cell zone names: " << cellZoneNames_ << endl; @@ -409,14 +415,16 @@ void Foam::mergePolyMesh::merge() for (; patchI < patchNames_.size(); patchI++) { // Add a patch + dictionary dict(patchDicts_[patchI]); + dict.set("nFaces", 0); + dict.set("startFace", endOfLastPatch); + newPatches[patchI] = ( polyPatch::New ( - patchTypes_[patchI], patchNames_[patchI], - 0, - endOfLastPatch, + dict, patchI, oldPatches ).ptr() diff --git a/applications/utilities/mesh/manipulation/mergeMeshes/mergePolyMesh.H b/applications/utilities/mesh/manipulation/mergeMeshes/mergePolyMesh.H index ef6c2f0ee4..a9db4fb32e 100644 --- a/applications/utilities/mesh/manipulation/mergeMeshes/mergePolyMesh.H +++ b/applications/utilities/mesh/manipulation/mergeMeshes/mergePolyMesh.H @@ -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-2013 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -58,12 +58,12 @@ class mergePolyMesh //- Topological change to accumulated all mesh changes polyTopoChange meshMod_; - //- Patch types - DynamicList patchTypes_; - //- Patch names DynamicList patchNames_; + //- Patch dictionaries + DynamicList patchDicts_; + //- Point zone names DynamicList pointZoneNames_;