From 9553a60ab31e6b9c7df3c3ecc9bcb722d2615a5a Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 10 Jan 2013 09:15:08 +0000 Subject: [PATCH 01/42] ENH: Updated heat transfer coefficient calculation --- .../constantHeatTransfer/constantHeatTransfer.C | 2 +- .../tabulatedHeatTransfer/tabulatedHeatTransfer.C | 2 +- .../variableHeatTransfer/variableHeatTransfer.C | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fvOptions/sources/derived/interRegionHeatTransferModel/constantHeatTransfer/constantHeatTransfer.C b/src/fvOptions/sources/derived/interRegionHeatTransferModel/constantHeatTransfer/constantHeatTransfer.C index cc8879877c..1a02041238 100644 --- a/src/fvOptions/sources/derived/interRegionHeatTransferModel/constantHeatTransfer/constantHeatTransfer.C +++ b/src/fvOptions/sources/derived/interRegionHeatTransferModel/constantHeatTransfer/constantHeatTransfer.C @@ -97,7 +97,7 @@ Foam::fv::constantHeatTransfer::constantHeatTransfer AoV_().dimensionedInternalField(); dimensionedScalar interVol("V", dimVolume, meshInterp().V()); - htc_.dimensionedInternalField() = htcConsti*AoVi*interVol/mesh.V(); + htc_.dimensionedInternalField() = htcConsti*AoVi; htc_.correctBoundaryConditions(); } } diff --git a/src/fvOptions/sources/derived/interRegionHeatTransferModel/tabulatedHeatTransfer/tabulatedHeatTransfer.C b/src/fvOptions/sources/derived/interRegionHeatTransferModel/tabulatedHeatTransfer/tabulatedHeatTransfer.C index cf8ec5a67e..185926f907 100644 --- a/src/fvOptions/sources/derived/interRegionHeatTransferModel/tabulatedHeatTransfer/tabulatedHeatTransfer.C +++ b/src/fvOptions/sources/derived/interRegionHeatTransferModel/tabulatedHeatTransfer/tabulatedHeatTransfer.C @@ -130,7 +130,7 @@ Foam::fv::tabulatedHeatTransfer::calculateHtc() htcc[i] = hTable()(mag(U[i]), UMagNbrMapped[i]); } - htcc = htcc*AoV()*meshInterp().V()/mesh_.V(); + htcc = htcc*AoV(); return htc_; } diff --git a/src/fvOptions/sources/derived/interRegionHeatTransferModel/variableHeatTransfer/variableHeatTransfer.C b/src/fvOptions/sources/derived/interRegionHeatTransferModel/variableHeatTransfer/variableHeatTransfer.C index 4445306bdd..fc72cabe33 100644 --- a/src/fvOptions/sources/derived/interRegionHeatTransferModel/variableHeatTransfer/variableHeatTransfer.C +++ b/src/fvOptions/sources/derived/interRegionHeatTransferModel/variableHeatTransfer/variableHeatTransfer.C @@ -120,7 +120,7 @@ Foam::fv::variableHeatTransfer::calculateHtc() const scalarField htcNbrMapped(interpolate(htcNbr)); - htc_.internalField() = htcNbrMapped*AoV_*meshInterp().V()/mesh_.V(); + htc_.internalField() = htcNbrMapped*AoV_; return htc_; } From 83dae500ac374c2c83a4eb12827773ad8eee3cab Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 10 Jan 2013 09:42:46 +0000 Subject: [PATCH 02/42] ENH: Removed calculation order dependancy --- .../constantHeatTransfer.C | 14 ++------- .../constantHeatTransfer.H | 2 +- .../interRegionHeatTransferModel.C | 30 ++++++++++++++----- .../interRegionHeatTransferModel.H | 18 ++++++----- .../tabulatedHeatTransfer.C | 5 +--- .../tabulatedHeatTransfer.H | 2 +- .../variableHeatTransfer.C | 5 +--- .../variableHeatTransfer.H | 2 +- 8 files changed, 41 insertions(+), 37 deletions(-) diff --git a/src/fvOptions/sources/derived/interRegionHeatTransferModel/constantHeatTransfer/constantHeatTransfer.C b/src/fvOptions/sources/derived/interRegionHeatTransferModel/constantHeatTransfer/constantHeatTransfer.C index 1a02041238..1cafec08c4 100644 --- a/src/fvOptions/sources/derived/interRegionHeatTransferModel/constantHeatTransfer/constantHeatTransfer.C +++ b/src/fvOptions/sources/derived/interRegionHeatTransferModel/constantHeatTransfer/constantHeatTransfer.C @@ -91,14 +91,7 @@ Foam::fv::constantHeatTransfer::constantHeatTransfer ) ); - const DimensionedField& htcConsti = - htcConst_().dimensionedInternalField(); - const DimensionedField& AoVi = - AoV_().dimensionedInternalField(); - dimensionedScalar interVol("V", dimVolume, meshInterp().V()); - - htc_.dimensionedInternalField() = htcConsti*AoVi; - htc_.correctBoundaryConditions(); + htc_ = htcConst_()*AoV_(); } } @@ -111,10 +104,9 @@ Foam::fv::constantHeatTransfer::~constantHeatTransfer() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -const Foam::tmp -Foam::fv::constantHeatTransfer::calculateHtc() +void Foam::fv::constantHeatTransfer::calculateHtc() { - return htc_; + // do nothing } diff --git a/src/fvOptions/sources/derived/interRegionHeatTransferModel/constantHeatTransfer/constantHeatTransfer.H b/src/fvOptions/sources/derived/interRegionHeatTransferModel/constantHeatTransfer/constantHeatTransfer.H index 52facea986..ceb4aaf15a 100644 --- a/src/fvOptions/sources/derived/interRegionHeatTransferModel/constantHeatTransfer/constantHeatTransfer.H +++ b/src/fvOptions/sources/derived/interRegionHeatTransferModel/constantHeatTransfer/constantHeatTransfer.H @@ -87,7 +87,7 @@ public: // Public Functions //- Calculate the heat transfer coefficient - virtual const tmp calculateHtc(); + virtual void calculateHtc(); // I-O diff --git a/src/fvOptions/sources/derived/interRegionHeatTransferModel/interRegionHeatTransferModel/interRegionHeatTransferModel.C b/src/fvOptions/sources/derived/interRegionHeatTransferModel/interRegionHeatTransferModel/interRegionHeatTransferModel.C index 7cfde633e1..31a684afb9 100644 --- a/src/fvOptions/sources/derived/interRegionHeatTransferModel/interRegionHeatTransferModel/interRegionHeatTransferModel.C +++ b/src/fvOptions/sources/derived/interRegionHeatTransferModel/interRegionHeatTransferModel/interRegionHeatTransferModel.C @@ -41,7 +41,7 @@ namespace fv } -// * * * * * * * * * * * * Private member functions * * * * * * * * * * * // +// * * * * * * * * * * * * Protected member functions * * * * * * * * * * * // void Foam::fv::interRegionHeatTransferModel::setNbrModel() { @@ -71,7 +71,7 @@ void Foam::fv::interRegionHeatTransferModel::setNbrModel() if (!nbrModelFound) { - FatalErrorIn("interRegionHeatTransferModel::check()") + FatalErrorIn("interRegionHeatTransferModel::setNbrModel()") << "Neighbour model not found" << nbrModelName_ << " in region " << nbrMesh.name() << nl << exit(FatalError); @@ -81,6 +81,24 @@ void Foam::fv::interRegionHeatTransferModel::setNbrModel() } +void Foam::fv::interRegionHeatTransferModel::correct() +{ + if (master_) + { + if (mesh_.time().timeIndex() != timeIndex_) + { + calculateHtc(); + timeIndex_ = mesh_.time().timeIndex(); + } + } + else + { + nbrModel().correct(); + interpolate(nbrModel().htc(), htc_); + } +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::fv::interRegionHeatTransferModel::interRegionHeatTransferModel @@ -94,6 +112,7 @@ Foam::fv::interRegionHeatTransferModel::interRegionHeatTransferModel option(name, modelType, dict, mesh), nbrModel_(NULL), firstIter_(true), + timeIndex_(-1), htc_ ( IOobject @@ -143,6 +162,8 @@ void Foam::fv::interRegionHeatTransferModel::addSup { setNbrModel(); + correct(); + const volScalarField& h = eqn.psi(); const volScalarField& T = mesh_.lookupObject(TName_); @@ -172,11 +193,6 @@ void Foam::fv::interRegionHeatTransferModel::addSup interpolate(Tnbr, Tmapped.internalField()); - if (!master_) - { - interpolate(nbrModel().calculateHtc()(), htc_); - } - if (debug) { Info<< "Volumetric integral of htc: " diff --git a/src/fvOptions/sources/derived/interRegionHeatTransferModel/interRegionHeatTransferModel/interRegionHeatTransferModel.H b/src/fvOptions/sources/derived/interRegionHeatTransferModel/interRegionHeatTransferModel/interRegionHeatTransferModel.H index dd7104de13..736bd094fb 100644 --- a/src/fvOptions/sources/derived/interRegionHeatTransferModel/interRegionHeatTransferModel/interRegionHeatTransferModel.H +++ b/src/fvOptions/sources/derived/interRegionHeatTransferModel/interRegionHeatTransferModel/interRegionHeatTransferModel.H @@ -68,19 +68,15 @@ private: //- First iteration bool firstIter_; - - // Private members - - //- Set the neighbour interRegionHeatTransferModel - void setNbrModel(); + //- Time index - used for updating htc + label timeIndex_; protected: // Protected data - //- Heat transfer coefficient [W/m2/k] by area/volume [1/m] - // registered on the master mesh + //- Heat transfer coefficient [W/m2/k] times area/volume [1/m] volScalarField htc_; //- Flag to activate semi-implicit coupling @@ -95,6 +91,12 @@ protected: // Protected member functions + //- Set the neighbour interRegionHeatTransferModel + void setNbrModel(); + + //- Correct to calculate the inter-region heat transfer coefficient + void correct(); + //- Interpolate field with nbrModel specified template tmp > interpolate @@ -168,7 +170,7 @@ public: virtual void addSup(fvMatrix& eqn, const label fieldI); //- Calculate heat transfer coefficient - virtual const tmp calculateHtc() = 0; + virtual void calculateHtc() = 0; // I-O diff --git a/src/fvOptions/sources/derived/interRegionHeatTransferModel/tabulatedHeatTransfer/tabulatedHeatTransfer.C b/src/fvOptions/sources/derived/interRegionHeatTransferModel/tabulatedHeatTransfer/tabulatedHeatTransfer.C index 185926f907..fd49c31963 100644 --- a/src/fvOptions/sources/derived/interRegionHeatTransferModel/tabulatedHeatTransfer/tabulatedHeatTransfer.C +++ b/src/fvOptions/sources/derived/interRegionHeatTransferModel/tabulatedHeatTransfer/tabulatedHeatTransfer.C @@ -109,8 +109,7 @@ Foam::fv::tabulatedHeatTransfer::~tabulatedHeatTransfer() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -const Foam::tmp -Foam::fv::tabulatedHeatTransfer::calculateHtc() +void Foam::fv::tabulatedHeatTransfer::calculateHtc() { const fvMesh& nbrMesh = mesh_.time().lookupObject(nbrRegionName()); @@ -131,8 +130,6 @@ Foam::fv::tabulatedHeatTransfer::calculateHtc() } htcc = htcc*AoV(); - - return htc_; } diff --git a/src/fvOptions/sources/derived/interRegionHeatTransferModel/tabulatedHeatTransfer/tabulatedHeatTransfer.H b/src/fvOptions/sources/derived/interRegionHeatTransferModel/tabulatedHeatTransfer/tabulatedHeatTransfer.H index 4656560eac..8feb9d68df 100644 --- a/src/fvOptions/sources/derived/interRegionHeatTransferModel/tabulatedHeatTransfer/tabulatedHeatTransfer.H +++ b/src/fvOptions/sources/derived/interRegionHeatTransferModel/tabulatedHeatTransfer/tabulatedHeatTransfer.H @@ -104,7 +104,7 @@ public: // Public Functions //- Calculate the heat transfer coefficient - virtual const tmp calculateHtc(); + virtual void calculateHtc(); // I-O diff --git a/src/fvOptions/sources/derived/interRegionHeatTransferModel/variableHeatTransfer/variableHeatTransfer.C b/src/fvOptions/sources/derived/interRegionHeatTransferModel/variableHeatTransfer/variableHeatTransfer.C index fc72cabe33..cf96fa0433 100644 --- a/src/fvOptions/sources/derived/interRegionHeatTransferModel/variableHeatTransfer/variableHeatTransfer.C +++ b/src/fvOptions/sources/derived/interRegionHeatTransferModel/variableHeatTransfer/variableHeatTransfer.C @@ -97,8 +97,7 @@ Foam::fv::variableHeatTransfer::~variableHeatTransfer() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -const Foam::tmp -Foam::fv::variableHeatTransfer::calculateHtc() +void Foam::fv::variableHeatTransfer::calculateHtc() { const fvMesh& nbrMesh = mesh_.time().lookupObject(nbrRegionName()); @@ -121,8 +120,6 @@ Foam::fv::variableHeatTransfer::calculateHtc() const scalarField htcNbrMapped(interpolate(htcNbr)); htc_.internalField() = htcNbrMapped*AoV_; - - return htc_; } diff --git a/src/fvOptions/sources/derived/interRegionHeatTransferModel/variableHeatTransfer/variableHeatTransfer.H b/src/fvOptions/sources/derived/interRegionHeatTransferModel/variableHeatTransfer/variableHeatTransfer.H index 8180f63a34..57e42be811 100644 --- a/src/fvOptions/sources/derived/interRegionHeatTransferModel/variableHeatTransfer/variableHeatTransfer.H +++ b/src/fvOptions/sources/derived/interRegionHeatTransferModel/variableHeatTransfer/variableHeatTransfer.H @@ -108,7 +108,7 @@ public: // Public Functions //- Calculate the heat transfer coefficient - virtual const tmp calculateHtc(); + virtual void calculateHtc(); // I-O From 6fa5295b4bf97fa45b4b2fcb3dc58c17008fcfd0 Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 10 Jan 2013 10:00:31 +0000 Subject: [PATCH 03/42] ENH: Tutorial update --- .../heatExchanger/0.org/porous/U | 4 ++-- .../constant/air/polyMesh/blockMeshDict | 18 +++++++++--------- .../constant/porous/polyMesh/blockMeshDict | 2 +- .../heatExchanger/system/air/fvSolution | 10 +++++----- .../heatExchanger/system/porous/fvSolution | 10 +++++----- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/0.org/porous/U b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/0.org/porous/U index 7d6875ae04..23454ad6de 100644 --- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/0.org/porous/U +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/0.org/porous/U @@ -17,14 +17,14 @@ FoamFile dimensions [0 1 -1 0 0 0 0]; -internalField uniform (0.1 0 0); +internalField uniform (0.01 0 0); boundaryField { inlet { type fixedValue; - value uniform (0.1 0 0); + value uniform (0.01 0 0); } outlet { diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/constant/air/polyMesh/blockMeshDict b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/constant/air/polyMesh/blockMeshDict index 49c36ebacf..d0439108c7 100644 --- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/constant/air/polyMesh/blockMeshDict +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/constant/air/polyMesh/blockMeshDict @@ -52,15 +52,15 @@ vertices blocks ( - hex (0 1 5 4 12 13 17 16) (20 20 20) simpleGrading (1 1 1) - hex (1 2 6 5 13 14 18 17) (20 20 20) simpleGrading (1 1 1) - hex (2 3 7 6 14 15 19 18) (20 20 20) simpleGrading (1 1 1) - hex (3 0 4 7 15 12 16 19) (20 20 20) simpleGrading (1 1 1) - hex (4 5 9 8 16 17 21 20) cylinder (20 20 20) simpleGrading (1 1 1) - hex (5 6 10 9 17 18 22 21) cylinder (20 20 20) simpleGrading (1 1 1) - hex (6 7 11 10 18 19 23 22) cylinder (20 20 20) simpleGrading (1 1 1) - hex (7 4 8 11 19 16 20 23) cylinder (20 20 20) simpleGrading (1 1 1) - hex (8 9 10 11 20 21 22 23) innerCylinder (20 20 20) simpleGrading (1 1 1) + hex (0 1 5 4 12 13 17 16) (30 30 30) simpleGrading (1 1 1) + hex (1 2 6 5 13 14 18 17) (30 30 30) simpleGrading (1 1 1) + hex (2 3 7 6 14 15 19 18) (30 30 30) simpleGrading (1 1 1) + hex (3 0 4 7 15 12 16 19) (30 30 30) simpleGrading (1 1 1) + hex (4 5 9 8 16 17 21 20) cylinder (30 30 30) simpleGrading (1 1 1) + hex (5 6 10 9 17 18 22 21) cylinder (30 30 30) simpleGrading (1 1 1) + hex (6 7 11 10 18 19 23 22) cylinder (30 30 30) simpleGrading (1 1 1) + hex (7 4 8 11 19 16 20 23) cylinder (30 30 30) simpleGrading (1 1 1) + hex (8 9 10 11 20 21 22 23) innerCylinder (30 30 30) simpleGrading (1 1 1) ); edges diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/constant/porous/polyMesh/blockMeshDict b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/constant/porous/polyMesh/blockMeshDict index 86e616bd27..eae25e8926 100644 --- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/constant/porous/polyMesh/blockMeshDict +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/constant/porous/polyMesh/blockMeshDict @@ -31,7 +31,7 @@ vertices blocks ( - hex (0 1 2 3 4 5 6 7) (20 4 4) simpleGrading (1 1 1) + hex (0 1 2 3 4 5 6 7) (40 15 15) simpleGrading (1 1 1) ); edges diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/system/air/fvSolution b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/system/air/fvSolution index 4f83fc7823..36d404271f 100644 --- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/system/air/fvSolution +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/system/air/fvSolution @@ -55,14 +55,14 @@ relaxationFactors fields { rho 1; - p_rgh 0.5; + p_rgh 0.7; } equations { - U 0.2; - "(h|e)" 0.2; - k 0.2; - epsilon 0.2; + U 0.3; + "(h|e)" 0.3; + k 0.3; + epsilon 0.3; } } diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/system/porous/fvSolution b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/system/porous/fvSolution index 1b3b041a2a..fd6da4016c 100644 --- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/system/porous/fvSolution +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/system/porous/fvSolution @@ -53,14 +53,14 @@ relaxationFactors fields { rho 1; - p_rgh 0.5; + p_rgh 0.7; } equations { - U 0.2; - "(h|e)" 0.2; - k 0.2; - epsilon 0.2; + U 0.3; + "(h|e)" 0.3; + k 0.3; + epsilon 0.3; } } From 147e2794f91dd0dab6095355efea6d816b4d2323 Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 10 Jan 2013 10:27:17 +0000 Subject: [PATCH 04/42] ENH: Updated mesh-to-mesh interpolation --- src/fvOptions/fvOptions/fvOption.C | 5 +- .../meshToMesh/meshToMesh.H | 3 + .../meshToMeshNew/meshToMeshNew.C | 68 ++++++++++++++----- .../meshToMeshNew/meshToMeshNew.H | 25 +++++-- .../meshToMeshNew/meshToMeshNewTemplates.C | 37 +++++----- 5 files changed, 99 insertions(+), 39 deletions(-) diff --git a/src/fvOptions/fvOptions/fvOption.C b/src/fvOptions/fvOptions/fvOption.C index 4a66ded16e..6cd5c770f4 100644 --- a/src/fvOptions/fvOptions/fvOption.C +++ b/src/fvOptions/fvOptions/fvOption.C @@ -191,7 +191,10 @@ void Foam::fv::option::setCellSet() ( mesh_, nbrMesh, - readBool(dict_.lookup("consistentMeshes")) + meshToMeshNew::interpolationMethodNames_.read + ( + dict_.lookup("interpolationMethod") + ) ) ); } diff --git a/src/sampling/meshToMeshInterpolation/meshToMesh/meshToMesh.H b/src/sampling/meshToMeshInterpolation/meshToMesh/meshToMesh.H index 9344f75ba0..b99c0629cc 100644 --- a/src/sampling/meshToMeshInterpolation/meshToMesh/meshToMesh.H +++ b/src/sampling/meshToMeshInterpolation/meshToMesh/meshToMesh.H @@ -27,6 +27,9 @@ Class Description mesh to mesh interpolation class. +Note + This class is due to be deprecated in favour of meshToMeshNew + SourceFiles meshToMesh.C calculateMeshToMeshAddressing.C diff --git a/src/sampling/meshToMeshInterpolation/meshToMeshNew/meshToMeshNew.C b/src/sampling/meshToMeshInterpolation/meshToMeshNew/meshToMeshNew.C index b71e768f42..9ecda6cb4f 100644 --- a/src/sampling/meshToMeshInterpolation/meshToMeshNew/meshToMeshNew.C +++ b/src/sampling/meshToMeshInterpolation/meshToMeshNew/meshToMeshNew.C @@ -39,6 +39,20 @@ License namespace Foam { defineTypeNameAndDebug(meshToMeshNew, 0); + + template<> + const char* Foam::NamedEnum + < + Foam::meshToMeshNew::interpolationMethod, + 2 + >::names[] = + { + "map", + "cellVolumeWeight" + }; + + const NamedEnum + meshToMeshNew::interpolationMethodNames_; } Foam::scalar Foam::meshToMeshNew::tolerance_ = 1e-6; @@ -707,22 +721,40 @@ void Foam::meshToMeshNew::calcAddressing } - if (directMapping_) + switch (method_) { - calcDirect(src, tgt, srcSeedI, tgtSeedI); - } - else - { - calcIndirect - ( - src, - tgt, - srcSeedI, - tgtSeedI, - srcCellIDs, - mapFlag, - startSeedI - ); + case imMap: + { + calcDirect(src, tgt, srcSeedI, tgtSeedI); + break; + } + case imCellVolumeWeight: + { + calcIndirect + ( + src, + tgt, + srcSeedI, + tgtSeedI, + srcCellIDs, + mapFlag, + startSeedI + ); + break; + } + default: + { + FatalErrorIn + ( + "void Foam::meshToMeshNew::calcAddressing" + "(" + "const polyMesh&, " + "const polyMesh&" + ")" + ) + << "Unknown interpolation method" + << abort(FatalError); + } } @@ -739,7 +771,7 @@ Foam::meshToMeshNew::meshToMeshNew ( const polyMesh& src, const polyMesh& tgt, - const bool directMapping + const interpolationMethod& method ) : srcRegionName_(src.name()), @@ -748,11 +780,11 @@ Foam::meshToMeshNew::meshToMeshNew tgtToSrcCellAddr_(), srcToTgtCellWght_(), tgtToSrcCellWght_(), + method_(method), V_(0.0), singleMeshProc_(-1), srcMapPtr_(NULL), - tgtMapPtr_(NULL), - directMapping_(directMapping) + tgtMapPtr_(NULL) { Info<< "Creating mesh-to-mesh addressing for " << src.name() << " and " << tgt.name() << " regions" << endl; diff --git a/src/sampling/meshToMeshInterpolation/meshToMeshNew/meshToMeshNew.H b/src/sampling/meshToMeshInterpolation/meshToMeshNew/meshToMeshNew.H index 6b5211ef43..85f0c1332e 100644 --- a/src/sampling/meshToMeshInterpolation/meshToMeshNew/meshToMeshNew.H +++ b/src/sampling/meshToMeshInterpolation/meshToMeshNew/meshToMeshNew.H @@ -40,6 +40,7 @@ SourceFiles #include "boundBox.H" #include "mapDistribute.H" #include "volFieldsFwd.H" +#include "NamedEnum.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -52,6 +53,22 @@ namespace Foam class meshToMeshNew { +public: + + // Public data types + + //- Enumeration specifying required accuracy + enum interpolationMethod + { + imMap, + imCellVolumeWeight + }; + + static const NamedEnum + interpolationMethodNames_; + +private: + // Private data //- Name of source mesh region @@ -72,6 +89,9 @@ class meshToMeshNew //- Target to source cell interpolation weights scalarListList tgtToSrcCellWght_; + //- Interpolation method + interpolationMethod method_; + //- Cell total volume in overlap region [m3] scalar V_; @@ -85,9 +105,6 @@ class meshToMeshNew //- Target map pointer - parallel running only autoPtr tgtMapPtr_; - //- Flag to indicate that direct (one-to-one) mapping should be applied - bool directMapping_; - //- Tolerance used in volume overlap calculations static scalar tolerance_; @@ -289,7 +306,7 @@ public: ( const polyMesh& src, const polyMesh& tgt, - const bool directMapping + const interpolationMethod& method ); diff --git a/src/sampling/meshToMeshInterpolation/meshToMeshNew/meshToMeshNewTemplates.C b/src/sampling/meshToMeshInterpolation/meshToMeshNew/meshToMeshNewTemplates.C index 4587b8ea60..69bbc69667 100644 --- a/src/sampling/meshToMeshInterpolation/meshToMeshNew/meshToMeshNewTemplates.C +++ b/src/sampling/meshToMeshInterpolation/meshToMeshNew/meshToMeshNewTemplates.C @@ -395,28 +395,33 @@ void Foam::meshToMeshNew::interpolate if (interpPatches) { - if (directMapping_) + switch (method_) { - result.boundaryField() == field.boundaryField(); - } - else - { - notImplemented - ( - "void Foam::meshToMeshNew::interpolate" - "(" - "const GeometricField&, " - "const CombineOp&, " - "GeometricField&, " - "const bool" - ") const - non-conformal patches" - ) + case imMap: + { + result.boundaryField() == field.boundaryField(); + break; + } + default: + { + notImplemented + ( + "void Foam::meshToMeshNew::interpolate" + "(" + "const GeometricField&, " + "const CombineOp&, " + "GeometricField&, " + "const bool" + ") const - non-conformal patches" + ) - // do something... + // do something... + } } } } + template Foam::tmp > Foam::meshToMeshNew::interpolate From 94704b466e2b65a9562d6694807d5efaf1c7908c Mon Sep 17 00:00:00 2001 From: andy Date: Thu, 10 Jan 2013 10:27:47 +0000 Subject: [PATCH 05/42] ENH: Tutorial update --- .../chtMultiRegionSimpleFoam/heatExchanger/system/air/fvOptions | 2 +- .../heatExchanger/system/porous/fvOptions | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/system/air/fvOptions b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/system/air/fvOptions index 8f81bdae42..44aba3100f 100644 --- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/system/air/fvOptions +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/system/air/fvOptions @@ -20,7 +20,7 @@ airToporous type constantHeatTransfer; active on; selectionMode mapRegion; - consistentMeshes no; + interpolationMethod cellVolumeWeight; nbrModelName porousToair; nbrRegionName porous; master false; diff --git a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/system/porous/fvOptions b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/system/porous/fvOptions index 3c5bd05176..64561c37f6 100644 --- a/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/system/porous/fvOptions +++ b/tutorials/heatTransfer/chtMultiRegionSimpleFoam/heatExchanger/system/porous/fvOptions @@ -20,7 +20,7 @@ porousToair type constantHeatTransfer; active on; selectionMode mapRegion; - consistentMeshes no; + interpolationMethod cellVolumeWeight; nbrModelName airToporous; nbrRegionName air; master true; From 51db019bee41f7dfbf312b015a60c0f7e1331d9c Mon Sep 17 00:00:00 2001 From: laurence Date: Thu, 10 Jan 2013 10:47:47 +0000 Subject: [PATCH 06/42] BUG: face: Early exit test on circulate removed. Does not work for faces of size 1 that match --- .../test/Circulator/Test-Circulator.C | 104 ++---------------- src/OpenFOAM/meshes/meshShapes/face/face.C | 10 +- 2 files changed, 13 insertions(+), 101 deletions(-) diff --git a/applications/test/Circulator/Test-Circulator.C b/applications/test/Circulator/Test-Circulator.C index 19a21f6b79..1369ef6e59 100644 --- a/applications/test/Circulator/Test-Circulator.C +++ b/applications/test/Circulator/Test-Circulator.C @@ -38,94 +38,6 @@ Description using namespace Foam; -// return -// 0: no match -// +1: identical -// -1: same face, but different orientation -label compare(const face& a, const face& b) -{ - // Basic rule: we assume that the sequence of labels in each list - // will be circular in the same order (but not necessarily in the - // same direction or from the same starting point). - - // Trivial reject: faces are different size - label sizeA = a.size(); - label sizeB = b.size(); - - if (sizeA != sizeB || sizeA == 0) - { - return 0; - } - - const_circulator aCirc(a); - const_circulator bCirc(b); - - // Rotate face b until its element matches the starting element of face a. - do - { - if (aCirc() == bCirc()) - { - // Set bCirc fulcrum to its iterator and increment the iterators - bCirc.setFulcrumToIterator(); - ++aCirc; - ++bCirc; - - break; - } - } while (bCirc.circulate(CirculatorBase::CLOCKWISE)); - - // Look forwards around the faces for a match - do - { - if (aCirc() != bCirc()) - { - break; - } - } - while - ( - aCirc.circulate(CirculatorBase::CLOCKWISE), - bCirc.circulate(CirculatorBase::CLOCKWISE) - ); - - // If the circulator has stopped then faces a and b matched. - if (!aCirc.circulate()) - { - return 1; - } - else - { - // Reset the circulators back to their fulcrum - aCirc.setIteratorToFulcrum(); - bCirc.setIteratorToFulcrum(); - ++aCirc; - --bCirc; - } - - // Look backwards around the faces for a match - do - { - if (aCirc() != bCirc()) - { - break; - } - } - while - ( - aCirc.circulate(CirculatorBase::CLOCKWISE), - bCirc.circulate(CirculatorBase::ANTICLOCKWISE) - ); - - // If the circulator has stopped then faces a and b matched. - if (!aCirc.circulate()) - { - return -1; - } - - return 0; -} - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // Main program: @@ -184,40 +96,40 @@ int main(int argc, char *argv[]) Info<< nl << nl << "Compare two faces: " << endl; face a(identity(5)); - Info<< "Compare " << a << " and " << a << " Match = " << compare(a, a) + Info<< "Compare " << a << " and " << a << " Match = " << face::compare(a, a) << endl; face b(reverseList(a)); - Info<< "Compare " << a << " and " << b << " Match = " << compare(a, b) + Info<< "Compare " << a << " and " << b << " Match = " << face::compare(a, b) << endl; face c(a); c[4] = 3; - Info<< "Compare " << a << " and " << c << " Match = " << compare(a, c) + Info<< "Compare " << a << " and " << c << " Match = " << face::compare(a, c) << endl; face d(rotateList(a, 2)); - Info<< "Compare " << a << " and " << d << " Match = " << compare(a, d) + Info<< "Compare " << a << " and " << d << " Match = " << face::compare(a, d) << endl; face g(labelList(5, 1)); face h(g); - Info<< "Compare " << g << " and " << h << " Match = " << compare(g, h) + Info<< "Compare " << g << " and " << h << " Match = " << face::compare(g, h) << endl; g[0] = 2; h[3] = 2; - Info<< "Compare " << g << " and " << h << " Match = " << compare(g, h) + Info<< "Compare " << g << " and " << h << " Match = " << face::compare(g, h) << endl; g[4] = 3; h[4] = 3; - Info<< "Compare " << g << " and " << h << " Match = " << compare(g, h) + Info<< "Compare " << g << " and " << h << " Match = " << face::compare(g, h) << endl; face face1(identity(1)); Info<< "Compare " << face1 << " and " << face1 - << " Match = " << compare(face1, face1) << endl; + << " Match = " << face::compare(face1, face1) << endl; Info<< nl << nl << "Zero face" << nl << endl; diff --git a/src/OpenFOAM/meshes/meshShapes/face/face.C b/src/OpenFOAM/meshes/meshShapes/face/face.C index 1d7ee06c2e..fcf273cc35 100644 --- a/src/OpenFOAM/meshes/meshShapes/face/face.C +++ b/src/OpenFOAM/meshes/meshShapes/face/face.C @@ -337,11 +337,11 @@ int Foam::face::compare(const face& a, const face& b) } while (bCirc.circulate(CirculatorBase::CLOCKWISE)); // If the circulator has stopped then faces a and b do not share a matching - // point - if (!bCirc.circulate()) - { - return 0; - } + // point. Doesn't work on matching, single element face. + //if (!bCirc.circulate()) + //{ + // return 0; + //} // Look forwards around the faces for a match do From ff3654956af385a74a8f075701ffa1dc75e16184 Mon Sep 17 00:00:00 2001 From: laurence Date: Thu, 10 Jan 2013 10:50:05 +0000 Subject: [PATCH 07/42] STYLE: Code cleanup and add some comments --- .../mesh/advanced/collapseEdges/collapseDict | 13 ++-- .../extrude2DMesh/extrude2DMesh/Make/options | 1 - .../patchToPoly2DMesh/patchToPoly2DMesh.C | 17 ----- .../patchToPoly2DMesh/patchToPoly2DMesh.H | 75 ++++++++++--------- .../extrude2DMesh/extrude2DMeshApp.C | 4 +- .../CGALPolyhedron/CGALPolyhedronRings.H | 46 ++++++------ .../dynamicIndexedOctree.H | 6 +- .../polyMeshFilter/polyMeshFilter.H | 9 ++- .../polyTopoChange/edgeCollapser.H | 17 +++-- 9 files changed, 96 insertions(+), 92 deletions(-) diff --git a/applications/utilities/mesh/advanced/collapseEdges/collapseDict b/applications/utilities/mesh/advanced/collapseEdges/collapseDict index 60f4cb2f43..340c33049f 100644 --- a/applications/utilities/mesh/advanced/collapseEdges/collapseDict +++ b/applications/utilities/mesh/advanced/collapseEdges/collapseDict @@ -17,7 +17,7 @@ FoamFile collapseEdgesCoeffs { // Edges shorter than this absolute value will be merged - minimumEdgeLength 1e-8; + minimumEdgeLength 1e-6; // The maximum angle between two edges that share a point attached to // no other edges @@ -25,7 +25,7 @@ collapseEdgesCoeffs // The amount that minimumEdgeLength will be reduced by for each // edge if that edge's collapse generates a poor quality face - reductionFactor 0.5; + reductionFactor 0.5; } @@ -67,14 +67,17 @@ meshQualityCoeffs { // Name of the dictionary that has the mesh quality coefficients used // by motionSmoother::checkMesh - meshQualityCoeffDict meshQualityDict; + #include "meshQualityDict"; + + // Maximum number of smoothing iterations for the reductionFactors + maximumSmoothingIterations 2; // Maximum number of outer iterations is mesh quality checking is enabled - maximumIterations 10; + maximumIterations 10; // Maximum number of iterations deletion of a point can cause a bad face // to be constructed before it is forced to not be deleted - maxPointErrorCount 5; + maxPointErrorCount 5; } diff --git a/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMesh/Make/options b/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMesh/Make/options index f1db60d53f..fe1283a73a 100644 --- a/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMesh/Make/options +++ b/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMesh/Make/options @@ -1,5 +1,4 @@ EXE_INC = \ - /* -DFULLDEBUG -g -O0 */ \ -I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \ diff --git a/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMesh/patchToPoly2DMesh/patchToPoly2DMesh.C b/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMesh/patchToPoly2DMesh/patchToPoly2DMesh.C index 7979fa966a..1b83599b31 100644 --- a/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMesh/patchToPoly2DMesh/patchToPoly2DMesh.C +++ b/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMesh/patchToPoly2DMesh/patchToPoly2DMesh.C @@ -26,12 +26,6 @@ License #include "patchToPoly2DMesh.H" #include "PatchTools.H" -// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // - - // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // void Foam::patchToPoly2DMesh::flipFaceOrder() @@ -275,12 +269,9 @@ void Foam::patchToPoly2DMesh::createPolyMeshComponents() addPatchFacesToOwner(); } -// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // - // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -//- Construct from a primitivePatch Foam::patchToPoly2DMesh::patchToPoly2DMesh ( const MeshedSurface& patch, @@ -321,13 +312,5 @@ void Foam::patchToPoly2DMesh::createMesh() } } -// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * Friend Functions * * * * * * * * * * * * * * // - - -// * * * * * * * * * * * * * * Friend Operators * * * * * * * * * * * * * * // - // ************************************************************************* // diff --git a/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMesh/patchToPoly2DMesh/patchToPoly2DMesh.H b/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMesh/patchToPoly2DMesh/patchToPoly2DMesh.H index ea27dc6f53..b7c81e68a2 100644 --- a/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMesh/patchToPoly2DMesh/patchToPoly2DMesh.H +++ b/applications/utilities/mesh/generation/extrude2DMesh/extrude2DMesh/patchToPoly2DMesh/patchToPoly2DMesh.H @@ -51,6 +51,7 @@ class patchToPoly2DMesh { // Private data + // Reference to the meshed surface const MeshedSurface& patch_; const wordList& patchNames_; @@ -62,11 +63,16 @@ class patchToPoly2DMesh const EdgeMap