From 6daff22a52bbdfe13a6ed9641e9470666ad349a2 Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 12 Sep 2013 10:18:06 +0100 Subject: [PATCH 01/12] ENH: writeRegisteredObject: changed default to false --- .../functionObjects/IO/controlDict | 26 ++++++++++--------- .../writeRegisteredObject.C | 2 +- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/postProcessing/functionObjects/IO/controlDict b/src/postProcessing/functionObjects/IO/controlDict index aed0d13d01..df7960250a 100644 --- a/src/postProcessing/functionObjects/IO/controlDict +++ b/src/postProcessing/functionObjects/IO/controlDict @@ -86,34 +86,36 @@ functions dumpObjects { - // Forcibly write registered objects. E.g. fields that have been - // created with NO_WRITE. + // Forcibly write registered objects type writeRegisteredObject; // Where to load it from functionObjectLibs ("libIOFunctionObjects.so"); - // Execute upon outputTime: - // timeStep - // outputTime + // When to write: + // timeStep (with optional outputInterval) + // outputTime (with optional outputInterval) // adjustableTime // runTime // clockTime // cpuTime outputControl outputTime; - // Is the object written by this function Object alone - exclusiveWriting true; + // Write every writeInterval (only valid for timeStemp, outputTime) + outputInterval 1; - // Interval of time (sec) to write down( - writeInterval 10.5 //(adjustableTime, runTime, clockTime, cpuTime) - - // Write as normal every writeInterval'th outputTime. - outputInterval 1; // (timeStep, outputTime) + // Interval of time (valid for adjustableTime, runTime, clockTime, + // cpuTime) + writeInterval 10.5; // Objects to write objectNames (); + + + // Is the object written by this function Object alone + // (default is false) + //exclusiveWriting true; } } diff --git a/src/postProcessing/functionObjects/IO/writeRegisteredObject/writeRegisteredObject.C b/src/postProcessing/functionObjects/IO/writeRegisteredObject/writeRegisteredObject.C index c05abb5b2f..efffb9e2f9 100644 --- a/src/postProcessing/functionObjects/IO/writeRegisteredObject/writeRegisteredObject.C +++ b/src/postProcessing/functionObjects/IO/writeRegisteredObject/writeRegisteredObject.C @@ -46,7 +46,7 @@ Foam::writeRegisteredObject::writeRegisteredObject ) : name_(name), - exclusiveWriting_(true), + exclusiveWriting_(false), obr_(obr), objectNames_() { From d2cefa9b26307314955df11706459e5e9aab96f0 Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 12 Sep 2013 11:36:07 +0100 Subject: [PATCH 02/12] fixedFluxPressureFvPatchScalarField: evaluate the value field after mapping --- .../fixedFluxPressureFvPatchScalarField.C | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C index 3894a5c3e4..ccdfaa8e8e 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C @@ -53,12 +53,15 @@ Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField fixedGradientFvPatchScalarField(p, iF), curTimeIndex_(-1) { - // Map value. Set unmapped values and overwrite with mapped ptf - fvPatchField::operator=(patchInternalField()); - map(ptf, mapper); // Map gradient. Set unmapped values and overwrite with mapped ptf gradient() = 0.0; gradient().map(ptf.gradient(), mapper); + + // Evaluate the value field from the gradient if the internal field is valid + if (&iF && iF.size()) + { + evaluate(); + } } From 0417e181e946d7cd2e688e472a64ab7e0342fc60 Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 12 Sep 2013 14:58:27 +0100 Subject: [PATCH 03/12] rhoPimpleDyMFoam: Updated to use Uf rather than phiAbs for ddtCorr --- .../rhoPimpleFoam/rhoPimpleDyMFoam/pEqn.H | 4 ++-- .../rhoPimpleDyMFoam/rhoPimpleDyMFoam.C | 22 +++++++------------ .../finiteVolume/fvc/fvcMeshPhi.C | 2 +- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleDyMFoam/pEqn.H b/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleDyMFoam/pEqn.H index 1d70a0f354..40cf109457 100644 --- a/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleDyMFoam/pEqn.H +++ b/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleDyMFoam/pEqn.H @@ -22,7 +22,7 @@ if (pimple.transonic()) fvc::interpolate(psi) *( (fvc::interpolate(rho*HbyA) & mesh.Sf()) - + rhorAUf*fvc::ddtCorr(rho, U, phiAbs) + + rhorAUf*fvc::ddtCorr(rho, U, rhoUf) )/fvc::interpolate(rho) ); @@ -55,7 +55,7 @@ else ( "phiHbyA", (fvc::interpolate(rho*HbyA) & mesh.Sf()) - + rhorAUf*fvc::ddtCorr(rho, U, phiAbs) + + rhorAUf*fvc::ddtCorr(rho, U, rhoUf) ); fvOptions.makeRelative(fvc::interpolate(rho), phiHbyA); diff --git a/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleDyMFoam/rhoPimpleDyMFoam.C b/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleDyMFoam/rhoPimpleDyMFoam.C index dac6980917..aae3285186 100644 --- a/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleDyMFoam/rhoPimpleDyMFoam.C +++ b/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleDyMFoam/rhoPimpleDyMFoam.C @@ -56,13 +56,10 @@ int main(int argc, char *argv[]) #include "createFields.H" #include "createFvOptions.H" #include "createPcorrTypes.H" + #include "createRhoUf.H" #include "CourantNo.H" #include "setInitialDeltaT.H" - // Create old-time absolute flux for ddtCorr - surfaceScalarField phiAbs("phiAbs", phi); - - // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // Info<< "\nStarting time loop\n" << endl; @@ -72,12 +69,6 @@ int main(int argc, char *argv[]) #include "readControls.H" #include "compressibleCourantNo.H" - // Make the fluxes absolute before mesh-motion - fvc::makeAbsolute(phi, rho, U); - - // Update absolute flux for ddtCorr - phiAbs = phi; - #include "setDeltaT.H" runTime++; @@ -86,20 +77,23 @@ int main(int argc, char *argv[]) { // Store divrhoU from the previous time-step/mesh for the correctPhi - volScalarField divrhoU(fvc::div(phi)); + volScalarField divrhoU(fvc::div(fvc::absolute(phi, rho, U))); // Do any mesh changes mesh.update(); if (mesh.changing() && correctPhi) { + // Calculate absolute flux from the mapped surface velocity + phi = mesh.Sf() & rhoUf; + #include "correctPhi.H" + + // Make the fluxes relative to the mesh-motion + fvc::makeRelative(phi, rho, U); } } - // Make the fluxes relative to the mesh-motion - fvc::makeRelative(phi, rho, U); - if (mesh.changing() && checkMeshCourantNo) { #include "meshCourantNo.H" diff --git a/src/finiteVolume/finiteVolume/fvc/fvcMeshPhi.C b/src/finiteVolume/finiteVolume/fvc/fvcMeshPhi.C index f3bf760877..4d578cc59d 100644 --- a/src/finiteVolume/finiteVolume/fvc/fvcMeshPhi.C +++ b/src/finiteVolume/finiteVolume/fvc/fvcMeshPhi.C @@ -174,7 +174,7 @@ Foam::tmp Foam::fvc::absolute { if (tphi().mesh().moving()) { - return tphi + fvc::meshPhi(rho, U); + return tphi + fvc::interpolate(rho)*fvc::meshPhi(rho, U); } else { From e678146fbfa10086ed79f3f2dc658fb703fb304b Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 12 Sep 2013 14:58:43 +0100 Subject: [PATCH 04/12] Updated header --- src/finiteVolume/finiteVolume/fvc/fvcMeshPhi.C | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/finiteVolume/finiteVolume/fvc/fvcMeshPhi.C b/src/finiteVolume/finiteVolume/fvc/fvcMeshPhi.C index 4d578cc59d..5c53f64fdd 100644 --- a/src/finiteVolume/finiteVolume/fvc/fvcMeshPhi.C +++ b/src/finiteVolume/finiteVolume/fvc/fvcMeshPhi.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 From 0cb4e1ecd8bf075cc610a93b933e4ed31cecc5df Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 12 Sep 2013 15:24:12 +0100 Subject: [PATCH 05/12] ENH: indexedOctree: print memory size --- src/OpenFOAM/algorithms/indexedOctree/indexedOctree.C | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.C b/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.C index b83b7ba1a1..38ccae1243 100644 --- a/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.C +++ b/src/OpenFOAM/algorithms/indexedOctree/indexedOctree.C @@ -27,6 +27,7 @@ License #include "linePointRef.H" #include "OFstream.H" #include "ListOps.H" +#include "memInfo.H" // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // @@ -2383,12 +2384,14 @@ Foam::indexedOctree::indexedOctree contents_(0), nodeTypes_(0) { + int oldMemSize = 0; if (debug) { Pout<< "indexedOctree::indexedOctree:" << nl << " shapes:" << shapes.size() << nl << " bb:" << bb << nl << endl; + oldMemSize = memInfo().size(); } if (shapes.size() == 0) @@ -2503,6 +2506,9 @@ Foam::indexedOctree::indexedOctree nEntries += contents_[i].size(); } + label memSize = memInfo().size(); + + Pout<< "indexedOctree::indexedOctree" << " : finished construction of tree of:" << shapes.typeName << nl @@ -2515,6 +2521,7 @@ Foam::indexedOctree::indexedOctree << scalar(nEntries)/contents.size() << nl << " per shape (duplicity):" << scalar(nEntries)/shapes.size() << nl + << " total memory:" << memSize-oldMemSize << endl; } } From e89fa0665e5ddf58ae21266086532cc2d62be90a Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 12 Sep 2013 15:24:53 +0100 Subject: [PATCH 06/12] ENH:Field: added default values to mapping constructor --- src/OpenFOAM/fields/Fields/Field/Field.C | 56 ++++++++++++++++++++++++ src/OpenFOAM/fields/Fields/Field/Field.H | 36 ++++++++++++++- 2 files changed, 91 insertions(+), 1 deletion(-) diff --git a/src/OpenFOAM/fields/Fields/Field/Field.C b/src/OpenFOAM/fields/Fields/Field/Field.C index 334eba8e41..118de048b3 100644 --- a/src/OpenFOAM/fields/Fields/Field/Field.C +++ b/src/OpenFOAM/fields/Fields/Field/Field.C @@ -124,6 +124,34 @@ Foam::Field::Field } +template +Foam::Field::Field +( + const UList& mapF, + const FieldMapper& mapper, + const Type& defaultValue +) +: + List(mapper.size(), defaultValue) +{ + map(mapF, mapper); +} + + +template +Foam::Field::Field +( + const UList& mapF, + const FieldMapper& mapper, + const UList& defaultValues +) +: + List(defaultValues) +{ + map(mapF, mapper); +} + + template Foam::Field::Field ( @@ -137,6 +165,34 @@ Foam::Field::Field } +template +Foam::Field::Field +( + const tmp >& tmapF, + const FieldMapper& mapper, + const Type& defaultValue +) +: + List(mapper.size(), defaultValue) +{ + map(tmapF, mapper); +} + + +template +Foam::Field::Field +( + const tmp >& tmapF, + const FieldMapper& mapper, + const UList& defaultValues +) +: + List(defaultValues) +{ + map(tmapF, mapper); +} + + template Foam::Field::Field(const Field& f) : diff --git a/src/OpenFOAM/fields/Fields/Field/Field.H b/src/OpenFOAM/fields/Fields/Field/Field.H index 9b4088a4eb..dd3dbabeae 100644 --- a/src/OpenFOAM/fields/Fields/Field/Field.H +++ b/src/OpenFOAM/fields/Fields/Field/Field.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 @@ -160,6 +160,22 @@ public: const FieldMapper& map ); + //- Construct by mapping from the given field + Field + ( + const UList& mapF, + const FieldMapper& map, + const Type& defaultValue + ); + + //- Construct by mapping from the given field + Field + ( + const UList& mapF, + const FieldMapper& map, + const UList& defaultValues + ); + //- Construct by mapping from the given tmp field Field ( @@ -167,6 +183,24 @@ public: const FieldMapper& map ); + //- Construct by mapping from the given tmp field. Supplied uniform + // value for unmapped items + Field + ( + const tmp >& tmapF, + const FieldMapper& map, + const Type& defaultValue + ); + + //- Construct by mapping from the given tmp field. Supplied values + // for unmapped items + Field + ( + const tmp >& tmapF, + const FieldMapper& map, + const UList& defaultValues + ); + //- Construct as copy Field(const Field&); From f35433bdeac4bb6d252cc0527a7253a28d26f992 Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 12 Sep 2013 15:25:53 +0100 Subject: [PATCH 07/12] ENH: fvPatchField: move mapping logic into Field --- .../fvPatchFields/fvPatchField/fvPatchField.C | 58 +++++++------------ .../fvPatchFields/fvPatchField/fvPatchField.H | 8 +++ 2 files changed, 28 insertions(+), 38 deletions(-) diff --git a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C index 3059eb5eea..23d3ef9c2b 100644 --- a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C @@ -47,6 +47,23 @@ Foam::fvPatchField::fvPatchField {} +template +Foam::fvPatchField::fvPatchField +( + const fvPatch& p, + const DimensionedField& iF, + const word& patchType +) +: + Field(p.size()), + patch_(p), + internalField_(iF), + updated_(false), + manipulatedMatrix_(false), + patchType_(patchType) +{} + + template Foam::fvPatchField::fvPatchField ( @@ -73,7 +90,7 @@ Foam::fvPatchField::fvPatchField const fvPatchFieldMapper& mapper ) : - Field(ptf, mapper), + Field(p.size()), patch_(p), internalField_(iF), updated_(false), @@ -83,44 +100,9 @@ Foam::fvPatchField::fvPatchField // For unmapped faces set to internal field value (zero-gradient) if (&iF && iF.size()) { - Field& f = *this; - - if - ( - mapper.direct() - && &mapper.directAddressing() - && mapper.directAddressing().size() - ) - { - Field pif(this->patchInternalField()); - - const labelList& mapAddressing = mapper.directAddressing(); - - forAll(mapAddressing, i) - { - if (mapAddressing[i] < 0) - { - f[i] = pif[i]; - } - } - } - else if (!mapper.direct() && mapper.addressing().size()) - { - Field pif(this->patchInternalField()); - - const labelListList& mapAddressing = mapper.addressing(); - - forAll(mapAddressing, i) - { - const labelList& localAddrs = mapAddressing[i]; - - if (!localAddrs.size()) - { - f[i] = pif[i]; - } - } - } + fvPatchField::operator=(this->patchInternalField()); } + this->map(ptf, mapper); } diff --git a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H index 3b9d54a2d3..5e9682634f 100644 --- a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H @@ -166,6 +166,14 @@ public: const DimensionedField& ); + //- Construct from patch and internal field and patch type + fvPatchField + ( + const fvPatch&, + const DimensionedField&, + const word& patchType + ); + //- Construct from patch and internal field and patch field fvPatchField ( From 5ac31aabc8bddb8dacc01a4d85db65aa62a2bdbd Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 12 Sep 2013 15:37:53 +0100 Subject: [PATCH 08/12] ENH: FieldMapper: extend with unmapped checking flag --- .../decomposePar/dimFieldDecomposer.H | 3 +- .../decomposePar/pointFieldDecomposer.C | 7 +- .../decomposePar/pointFieldDecomposer.H | 10 +- .../fields/Fields/Field/FieldMapper.H | 6 +- .../fields/Fields/Field/directFieldMapper.H | 104 ++++++++ .../directPointPatchFieldMapper.H | 111 ++++++++ .../pointMesh/pointMeshMapper/pointMapper.H | 9 +- .../pointMeshMapper/pointPatchMapper.C | 16 +- .../pointMeshMapper/pointPatchMapper.H | 9 +- .../mapPolyMesh/cellMapper/cellMapper.H | 11 +- .../mapPolyMesh/faceMapper/faceMapper.H | 7 +- src/dynamicMesh/fvMeshAdder/fvMeshAdder.H | 49 +--- .../fvMeshAdder/fvMeshAdderTemplates.C | 4 +- .../fixedFluxPressureFvPatchScalarField.C | 7 +- .../fvPatchField/directFvPatchFieldMapper.H | 111 ++++++++ .../fvMesh/fvMeshMapper/fvPatchMapper.C | 9 + .../fvMesh/fvMeshMapper/fvPatchMapper.H | 9 +- .../fvMesh/fvMeshMapper/fvSurfaceMapper.H | 8 +- .../fvMesh/fvMeshSubset/fvMeshSubset.H | 86 ------- .../fvMeshSubset/fvMeshSubsetInterpolate.C | 91 ++++--- .../singleCellFvMesh/singleCellFvMesh.H | 55 ++-- .../singleCellFvMeshInterpolate.C | 81 +++--- .../decompose/decompose/fvFieldDecomposer.H | 20 +- .../fvFieldDecomposerDecomposeFields.C | 239 +++++++++++------- .../reconstruct/fvFieldReconstructor.H | 7 +- .../reconstruct/pointFieldReconstructor.H | 7 +- .../meshToMesh/meshToMesh.H | 42 --- .../meshToMesh/meshToMeshInterpolate.C | 38 ++- 28 files changed, 754 insertions(+), 402 deletions(-) create mode 100644 src/OpenFOAM/fields/Fields/Field/directFieldMapper.H create mode 100644 src/OpenFOAM/fields/pointPatchFields/pointPatchField/directPointPatchFieldMapper.H create mode 100644 src/finiteVolume/fields/fvPatchFields/fvPatchField/directFvPatchFieldMapper.H diff --git a/applications/utilities/parallelProcessing/decomposePar/dimFieldDecomposer.H b/applications/utilities/parallelProcessing/decomposePar/dimFieldDecomposer.H index ac3700d8cd..5de5733013 100644 --- a/applications/utilities/parallelProcessing/decomposePar/dimFieldDecomposer.H +++ b/applications/utilities/parallelProcessing/decomposePar/dimFieldDecomposer.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 @@ -37,7 +37,6 @@ SourceFiles #define dimFieldDecomposer_H #include "fvMesh.H" -#include "fvPatchFieldMapper.H" #include "surfaceFields.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/applications/utilities/parallelProcessing/decomposePar/pointFieldDecomposer.C b/applications/utilities/parallelProcessing/decomposePar/pointFieldDecomposer.C index c978cd4f0a..3934fdc021 100644 --- a/applications/utilities/parallelProcessing/decomposePar/pointFieldDecomposer.C +++ b/applications/utilities/parallelProcessing/decomposePar/pointFieldDecomposer.C @@ -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 @@ -39,7 +39,8 @@ Foam::pointFieldDecomposer::patchFieldDecomposer::patchFieldDecomposer completeMeshPatch, procMeshPatch ), - directAddressing_(procMeshPatch.size(), -1) + directAddressing_(procMeshPatch.size(), -1), + hasUnmapped_(false) { // Create the inverse-addressing of the patch point labels. labelList pointMap(completeMeshPatch.boundaryMesh().mesh().size(), -1); @@ -64,6 +65,8 @@ Foam::pointFieldDecomposer::patchFieldDecomposer::patchFieldDecomposer // Check that all the patch point addresses are set if (directAddressing_.size() && min(directAddressing_) < 0) { + hasUnmapped_ = true; + FatalErrorIn ( "pointFieldDecomposer::patchFieldDecomposer()" diff --git a/applications/utilities/parallelProcessing/decomposePar/pointFieldDecomposer.H b/applications/utilities/parallelProcessing/decomposePar/pointFieldDecomposer.H index efe328833b..7214b9419a 100644 --- a/applications/utilities/parallelProcessing/decomposePar/pointFieldDecomposer.H +++ b/applications/utilities/parallelProcessing/decomposePar/pointFieldDecomposer.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 @@ -63,6 +63,9 @@ public: labelList directAddressing_; + //- Does map contain any unmapped values + bool hasUnmapped_; + public: // Constructors @@ -88,6 +91,11 @@ public: return true; } + bool hasUnmapped() const + { + return hasUnmapped_; + } + const labelUList& directAddressing() const { return directAddressing_; diff --git a/src/OpenFOAM/fields/Fields/Field/FieldMapper.H b/src/OpenFOAM/fields/Fields/Field/FieldMapper.H index 319c8f0575..f463f97c57 100644 --- a/src/OpenFOAM/fields/Fields/Field/FieldMapper.H +++ b/src/OpenFOAM/fields/Fields/Field/FieldMapper.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 @@ -64,6 +64,10 @@ public: virtual bool direct() const = 0; + //- Are there unmapped values? I.e. do all size() elements get + // get value + virtual bool hasUnmapped() const = 0; + virtual const labelUList& directAddressing() const { FatalErrorIn("FieldMapper::directAddressing() const") diff --git a/src/OpenFOAM/fields/Fields/Field/directFieldMapper.H b/src/OpenFOAM/fields/Fields/Field/directFieldMapper.H new file mode 100644 index 0000000000..34c8935c44 --- /dev/null +++ b/src/OpenFOAM/fields/Fields/Field/directFieldMapper.H @@ -0,0 +1,104 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ 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 3 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, see . + +Class + Foam::directFieldMapper + +Description + FieldMapper with direct mapping. + +\*---------------------------------------------------------------------------*/ + +#ifndef directFieldMapper_H +#define directFieldMapper_H + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class directFieldMapper Declaration +\*---------------------------------------------------------------------------*/ + +class directFieldMapper +: + public FieldMapper +{ + const labelUList& directAddressing_; + + bool hasUnmapped_; + +public: + + // Constructors + + //- Construct given addressing + patchFieldSubset(const labelUList& directAddressing) + : + directAddressing_(directAddressing), + hasUnmapped_(false) + { + if (directAddressing_.size() && min(directAddressing_) < 0) + { + hasUnmapped_ = true; + } + } + + //- Destructor + virtual ~directFieldMapper() + {} + + + // Member Functions + + label size() const + { + return directAddressing_.size(); + } + + bool direct() const + { + return true; + } + + bool hasUnmapped() const + { + return hasUnmapped_; + } + + const labelUList& directAddressing() const + { + return directAddressing_; + } +}; + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/fields/pointPatchFields/pointPatchField/directPointPatchFieldMapper.H b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/directPointPatchFieldMapper.H new file mode 100644 index 0000000000..4990061219 --- /dev/null +++ b/src/OpenFOAM/fields/pointPatchFields/pointPatchField/directPointPatchFieldMapper.H @@ -0,0 +1,111 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ 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 3 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, see . + +Class + Foam::directPointPatchFieldMapper + +Description + direct pointPatchFieldMapper + +\*---------------------------------------------------------------------------*/ + +#ifndef directPointPatchFieldMapper_H +#define directPointPatchFieldMapper_H + +#include "pointPatchFieldMapper.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class directPointPatchFieldMapper Declaration +\*---------------------------------------------------------------------------*/ + +class directPointPatchFieldMapper +: + public pointPatchFieldMapper +{ + + //- Addressing from new back to old + const labelUList& directAddressing_; + + //- Does map contain any unmapped values + bool hasUnmapped_; + + +public: + + // Constructors + + //- Construct given addressing + directPointPatchFieldMapper(const labelUList& directAddressing) + : + directAddressing_(directAddressing), + hasUnmapped_(false) + { + if (directAddressing_.size() && min(directAddressing_) < 0) + { + hasUnmapped_ = true; + } + } + + //- Destructor + virtual ~directPointPatchFieldMapper() + {} + + + // Member Functions + + label size() const + { + return directAddressing_.size(); + } + + bool direct() const + { + return true; + } + + bool hasUnmapped() const + { + return hasUnmapped_; + } + + const labelUList& directAddressing() const + { + return directAddressing_; + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/OpenFOAM/meshes/pointMesh/pointMeshMapper/pointMapper.H b/src/OpenFOAM/meshes/pointMesh/pointMeshMapper/pointMapper.H index 4900c7e074..4435edf3d7 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointMeshMapper/pointMapper.H +++ b/src/OpenFOAM/meshes/pointMesh/pointMeshMapper/pointMapper.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 @@ -129,6 +129,13 @@ public: return direct_; } + //- Are there unmapped values? I.e. do all size() elements get + // get value + virtual bool hasUnmapped() const + { + return insertedObjects(); + } + //- Return direct addressing virtual const labelUList& directAddressing() const; diff --git a/src/OpenFOAM/meshes/pointMesh/pointMeshMapper/pointPatchMapper.C b/src/OpenFOAM/meshes/pointMesh/pointMeshMapper/pointPatchMapper.C index 542455775f..624897bc09 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointMeshMapper/pointPatchMapper.C +++ b/src/OpenFOAM/meshes/pointMesh/pointMeshMapper/pointPatchMapper.C @@ -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 @@ -47,6 +47,8 @@ void Foam::pointPatchMapper::calcAddressing() const << abort(FatalError); } + hasUnmapped_ = false; + if (direct()) { // Direct mapping. @@ -57,7 +59,7 @@ void Foam::pointPatchMapper::calcAddressing() const { if (addr[i] < 0) { - addr[i] = 0; + hasUnmapped_ = true; } } } @@ -87,9 +89,11 @@ void Foam::pointPatchMapper::calcAddressing() const } else { - // Inserted point. Map from point0 (arbitrary choice) - addr[i] = labelList(1, label(0)); - w[i] = scalarList(1, 1.0); + // Inserted point. + ///// Map from point0 (arbitrary choice) + //addr[i] = labelList(1, label(0)); + //w[i] = scalarList(1, 1.0); + hasUnmapped_ = true; } } } @@ -101,6 +105,7 @@ void Foam::pointPatchMapper::clearOut() deleteDemandDrivenData(directAddrPtr_); deleteDemandDrivenData(interpolationAddrPtr_); deleteDemandDrivenData(weightsPtr_); + hasUnmapped_ = false; } @@ -124,6 +129,7 @@ Foam::pointPatchMapper::pointPatchMapper ? mpm_.oldPatchNMeshPoints()[patch_.index()] : 0 ), + hasUnmapped_(false), directAddrPtr_(NULL), interpolationAddrPtr_(NULL), weightsPtr_(NULL) diff --git a/src/OpenFOAM/meshes/pointMesh/pointMeshMapper/pointPatchMapper.H b/src/OpenFOAM/meshes/pointMesh/pointMeshMapper/pointPatchMapper.H index 575d6f6bc9..54d89cbdef 100644 --- a/src/OpenFOAM/meshes/pointMesh/pointMeshMapper/pointPatchMapper.H +++ b/src/OpenFOAM/meshes/pointMesh/pointMeshMapper/pointPatchMapper.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 @@ -74,6 +74,8 @@ class pointPatchMapper // Demand-driven private data + mutable bool hasUnmapped_; + //- Direct addressing (only one for of addressing is used) mutable labelList* directAddrPtr_; @@ -130,6 +132,11 @@ public: return patch_.size(); } + virtual bool hasUnmapped() const + { + return hasUnmapped_; + } + //- Return size of field before mapping virtual label sizeBeforeMapping() const { diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/cellMapper/cellMapper.H b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/cellMapper/cellMapper.H index 67c82e4353..03da8e0821 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/cellMapper/cellMapper.H +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/cellMapper/cellMapper.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 @@ -130,6 +130,11 @@ public: return direct_; } + virtual bool hasUnmapped() const + { + return insertedObjects(); + } + //- Return direct addressing virtual const labelUList& directAddressing() const; @@ -140,13 +145,13 @@ public: virtual const scalarListList& weights() const; //- Are there any inserted cells - bool insertedObjects() const + virtual bool insertedObjects() const { return insertedCells_; } //- Return list of inserted cells - const labelList& insertedObjectLabels() const; + const virtual labelList& insertedObjectLabels() const; }; diff --git a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/faceMapper/faceMapper.H b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/faceMapper/faceMapper.H index ad48462250..199481ea71 100644 --- a/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/faceMapper/faceMapper.H +++ b/src/OpenFOAM/meshes/polyMesh/mapPolyMesh/faceMapper/faceMapper.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 @@ -134,6 +134,11 @@ public: return direct_; } + virtual bool hasUnmapped() const + { + return insertedObjects(); + } + //- Return direct addressing virtual const labelUList& directAddressing() const; diff --git a/src/dynamicMesh/fvMeshAdder/fvMeshAdder.H b/src/dynamicMesh/fvMeshAdder/fvMeshAdder.H index f246a1887f..1247e68623 100644 --- a/src/dynamicMesh/fvMeshAdder/fvMeshAdder.H +++ b/src/dynamicMesh/fvMeshAdder/fvMeshAdder.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 @@ -67,53 +67,6 @@ class fvMeshAdder private: - - // Private class - - class directFvPatchFieldMapper - : - public fvPatchFieldMapper - { - // Private data - - const labelList& directAddressing_; - - public: - - // Constructors - - //- Construct from components - directFvPatchFieldMapper(const labelList& directAddressing) - : - fvPatchFieldMapper(), - directAddressing_(directAddressing) - {} - - - //- Destructor - virtual ~directFvPatchFieldMapper() - {} - - - // Member Functions - - label size() const - { - return directAddressing_.size(); - } - - bool direct() const - { - return true; - } - - const labelUList& directAddressing() const - { - return directAddressing_; - } - }; - - // Private Member Functions //- Calculate map from new patch faces to old patch faces. -1 where diff --git a/src/dynamicMesh/fvMeshAdder/fvMeshAdderTemplates.C b/src/dynamicMesh/fvMeshAdder/fvMeshAdderTemplates.C index bb01e2fa83..d5afadb9b3 100644 --- a/src/dynamicMesh/fvMeshAdder/fvMeshAdderTemplates.C +++ b/src/dynamicMesh/fvMeshAdder/fvMeshAdderTemplates.C @@ -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 @@ -23,10 +23,10 @@ License \*---------------------------------------------------------------------------*/ - #include "volFields.H" #include "surfaceFields.H" #include "emptyFvPatchField.H" +#include "directFvPatchFieldMapper.H" // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // diff --git a/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C b/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C index 3894a5c3e4..7120a09919 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/fixedFluxPressure/fixedFluxPressureFvPatchScalarField.C @@ -53,8 +53,13 @@ Foam::fixedFluxPressureFvPatchScalarField::fixedFluxPressureFvPatchScalarField fixedGradientFvPatchScalarField(p, iF), curTimeIndex_(-1) { + patchType() = ptf.patchType(); + // Map value. Set unmapped values and overwrite with mapped ptf - fvPatchField::operator=(patchInternalField()); + if (&iF && iF.size()) + { + fvPatchField::operator=(patchInternalField()); + } map(ptf, mapper); // Map gradient. Set unmapped values and overwrite with mapped ptf gradient() = 0.0; diff --git a/src/finiteVolume/fields/fvPatchFields/fvPatchField/directFvPatchFieldMapper.H b/src/finiteVolume/fields/fvPatchFields/fvPatchField/directFvPatchFieldMapper.H new file mode 100644 index 0000000000..7a87d1ad53 --- /dev/null +++ b/src/finiteVolume/fields/fvPatchFields/fvPatchField/directFvPatchFieldMapper.H @@ -0,0 +1,111 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | + \\ / A nd | Copyright (C) 2013 OpenFOAM Foundation + \\/ 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 3 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, see . + +Class + Foam::directFvPatchFieldMapper + +Description + direct fvPatchFieldMapper + +\*---------------------------------------------------------------------------*/ + +#ifndef directFvPatchFieldMapper_H +#define directFvPatchFieldMapper_H + +#include "fvPatchFieldMapper.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class directFvPatchFieldMapper Declaration +\*---------------------------------------------------------------------------*/ + +class directFvPatchFieldMapper +: + public fvPatchFieldMapper +{ + + //- Addressing from new back to old + const labelUList& directAddressing_; + + //- Does map contain any unmapped values + bool hasUnmapped_; + + +public: + + // Constructors + + //- Construct given addressing + directFvPatchFieldMapper(const labelUList& directAddressing) + : + directAddressing_(directAddressing), + hasUnmapped_(false) + { + if (directAddressing_.size() && min(directAddressing_) < 0) + { + hasUnmapped_ = true; + } + } + + //- Destructor + virtual ~directFvPatchFieldMapper() + {} + + + // Member Functions + + label size() const + { + return directAddressing_.size(); + } + + bool direct() const + { + return true; + } + + bool hasUnmapped() const + { + return hasUnmapped_; + } + + const labelUList& directAddressing() const + { + return directAddressing_; + } +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/fvMesh/fvMeshMapper/fvPatchMapper.C b/src/finiteVolume/fvMesh/fvMeshMapper/fvPatchMapper.C index 6a3e337357..ada0749df3 100644 --- a/src/finiteVolume/fvMesh/fvMeshMapper/fvPatchMapper.C +++ b/src/finiteVolume/fvMesh/fvMeshMapper/fvPatchMapper.C @@ -55,6 +55,8 @@ void Foam::fvPatchMapper::calcAddressing() const const label oldPatchEnd = oldPatchStart + faceMap_.oldPatchSizes()[patch_.index()]; + hasUnmapped_ = false; + // Assemble the maps: slice to patch if (direct()) { @@ -84,6 +86,7 @@ void Foam::fvPatchMapper::calcAddressing() const { //addr[faceI] = 0; addr[faceI] = -1; + hasUnmapped_ = true; } } @@ -175,6 +178,10 @@ void Foam::fvPatchMapper::calcAddressing() const { newWeights /= sum(newWeights); } + else + { + hasUnmapped_ = true; + } // Reset addressing and weights curAddr = newAddr; @@ -206,6 +213,7 @@ void Foam::fvPatchMapper::clearOut() deleteDemandDrivenData(directAddrPtr_); deleteDemandDrivenData(interpolationAddrPtr_); deleteDemandDrivenData(weightsPtr_); + hasUnmapped_ = false; } @@ -221,6 +229,7 @@ Foam::fvPatchMapper::fvPatchMapper patch_(patch), faceMap_(faceMap), sizeBeforeMapping_(faceMap.oldPatchSizes()[patch_.index()]), + hasUnmapped_(false), directAddrPtr_(NULL), interpolationAddrPtr_(NULL), weightsPtr_(NULL) diff --git a/src/finiteVolume/fvMesh/fvMeshMapper/fvPatchMapper.H b/src/finiteVolume/fvMesh/fvMeshMapper/fvPatchMapper.H index aa169fa082..bcfd49566b 100644 --- a/src/finiteVolume/fvMesh/fvMeshMapper/fvPatchMapper.H +++ b/src/finiteVolume/fvMesh/fvMeshMapper/fvPatchMapper.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 @@ -71,6 +71,8 @@ class fvPatchMapper // Demand-driven private data + mutable bool hasUnmapped_; + //- Direct addressing (only one for of addressing is used) mutable labelList* directAddrPtr_; @@ -138,6 +140,11 @@ public: return faceMap_.direct(); } + virtual bool hasUnmapped() const + { + return hasUnmapped_; + } + //- Return direct addressing virtual const labelUList& directAddressing() const; diff --git a/src/finiteVolume/fvMesh/fvMeshMapper/fvSurfaceMapper.H b/src/finiteVolume/fvMesh/fvMeshMapper/fvSurfaceMapper.H index c144bb9960..bf47b1f55c 100644 --- a/src/finiteVolume/fvMesh/fvMeshMapper/fvSurfaceMapper.H +++ b/src/finiteVolume/fvMesh/fvMeshMapper/fvSurfaceMapper.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 @@ -133,6 +133,12 @@ public: return faceMap_.direct(); } + //- Has unmapped elements + virtual bool hasUnmapped() const + { + return insertedObjects(); + } + //- Return direct addressing virtual const labelUList& directAddressing() const; diff --git a/src/finiteVolume/fvMesh/fvMeshSubset/fvMeshSubset.H b/src/finiteVolume/fvMesh/fvMeshSubset/fvMeshSubset.H index 2406da5db5..5f2a281d06 100644 --- a/src/finiteVolume/fvMesh/fvMeshSubset/fvMeshSubset.H +++ b/src/finiteVolume/fvMesh/fvMeshSubset/fvMeshSubset.H @@ -56,8 +56,6 @@ SourceFiles #include "fvMesh.H" #include "pointMesh.H" -#include "fvPatchFieldMapper.H" -#include "pointPatchFieldMapper.H" #include "GeometricField.H" #include "HashSet.H" #include "surfaceMesh.H" @@ -74,90 +72,6 @@ namespace Foam class fvMeshSubset { -public: - - //- Patch-field subset interpolation class - class patchFieldSubset - : - public fvPatchFieldMapper - { - const labelList& directAddressing_; - - public: - - // Constructors - - //- Construct given addressing - patchFieldSubset(const labelList& directAddressing) - : - directAddressing_(directAddressing) - {} - - //- Destructor - virtual ~patchFieldSubset() - {} - - - // Member Functions - - label size() const - { - return directAddressing_.size(); - } - - bool direct() const - { - return true; - } - - const labelUList& directAddressing() const - { - return directAddressing_; - } - }; - - - //- Patch-field subset interpolation class - class pointPatchFieldSubset - : - public pointPatchFieldMapper - { - const labelList& directAddressing_; - - public: - - // Constructors - - //- Construct given addressing - pointPatchFieldSubset(const labelList& directAddressing) - : - directAddressing_(directAddressing) - {} - - //- Destructor - virtual ~pointPatchFieldSubset() - {} - - - // Member Functions - - label size() const - { - return directAddressing_.size(); - } - - bool direct() const - { - return true; - } - - const labelUList& directAddressing() const - { - return directAddressing_; - } - }; - - private: // Private data diff --git a/src/finiteVolume/fvMesh/fvMeshSubset/fvMeshSubsetInterpolate.C b/src/finiteVolume/fvMesh/fvMeshSubset/fvMeshSubsetInterpolate.C index 130b08072a..7881194818 100644 --- a/src/finiteVolume/fvMesh/fvMeshSubset/fvMeshSubsetInterpolate.C +++ b/src/finiteVolume/fvMesh/fvMeshSubset/fvMeshSubsetInterpolate.C @@ -27,6 +27,8 @@ License #include "emptyFvsPatchField.H" #include "emptyPointPatchField.H" #include "emptyFvPatchFields.H" +#include "directFvPatchFieldMapper.H" +#include "directPointPatchFieldMapper.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -70,8 +72,9 @@ tmp > fvMeshSubset::interpolate patchFields.set ( patchI, - new calculatedFvPatchField + fvPatchField::New ( + calculatedFvPatchField::typeName, sMesh.boundary()[patchI], DimensionedField::null() ) @@ -142,7 +145,7 @@ tmp > fvMeshSubset::interpolate vf.boundaryField()[patchMap[patchI]], subPatch, resF.dimensionedInternalField(), - patchFieldSubset(directAddressing) + directFvPatchFieldMapper(directAddressing) ) ); } @@ -203,8 +206,9 @@ tmp > fvMeshSubset::interpolate patchFields.set ( patchI, - new calculatedFvsPatchField + fvsPatchField::New ( + calculatedFvsPatchField::typeName, sMesh.boundary()[patchI], DimensionedField::null() ) @@ -285,7 +289,7 @@ tmp > fvMeshSubset::interpolate vf.boundaryField()[patchMap[patchI]], subPatch, resF.dimensionedInternalField(), - patchFieldSubset(directAddressing) + directFvPatchFieldMapper(directAddressing) ) ); @@ -348,10 +352,7 @@ fvMeshSubset::interpolate const labelList& pointMap ) { - // Create and map the internal-field values - Field internalField(vf.internalField(), pointMap); - - // Create and map the patch field values + // 1. Create the complete field with dummy patch fields PtrList > patchFields(patchMap.size()); forAll(patchFields, patchI) @@ -372,6 +373,54 @@ fvMeshSubset::interpolate ); } else + { + patchFields.set + ( + patchI, + pointPatchField::New + ( + calculatedPointPatchField::typeName, + sMesh.boundary()[patchI], + DimensionedField::null() + ) + ); + } + } + + // Create the complete field from the pieces + tmp > tresF + ( + new GeometricField + ( + IOobject + ( + "subset"+vf.name(), + sMesh.time().timeName(), + sMesh.thisDb(), + IOobject::NO_READ, + IOobject::NO_WRITE + ), + sMesh, + vf.dimensions(), + Field(vf.internalField(), pointMap), + patchFields + ) + ); + GeometricField& resF = tresF(); + + + // 2. Change the pointPatchFields to the correct type using a mapper + // constructor (with reference to the now correct internal field) + + typename GeometricField:: + GeometricBoundaryField& bf = resF.boundaryField(); + + forAll(bf, patchI) + { + // Set the first one by hand as it corresponds to the + // exposed internal faces. Additional interpolation can be put here + // as necessary. + if (patchMap[patchI] != -1) { // Construct addressing const pointPatch& basePatch = @@ -406,40 +455,20 @@ fvMeshSubset::interpolate } } - patchFields.set + bf.set ( patchI, pointPatchField::New ( vf.boundaryField()[patchMap[patchI]], subPatch, - DimensionedField::null(), - pointPatchFieldSubset(directAddressing) + resF.dimensionedInternalField(), + directPointPatchFieldMapper(directAddressing) ) ); } } - // Create the complete field from the pieces - tmp > tresF - ( - new GeometricField - ( - IOobject - ( - "subset"+vf.name(), - vf.time().timeName(), - sMesh.thisDb(), - IOobject::NO_READ, - IOobject::NO_WRITE - ), - sMesh, - vf.dimensions(), - internalField, - patchFields - ) - ); - return tresF; } diff --git a/src/finiteVolume/fvMesh/singleCellFvMesh/singleCellFvMesh.H b/src/finiteVolume/fvMesh/singleCellFvMesh/singleCellFvMesh.H index 7ee6c37b68..036e4f24c9 100644 --- a/src/finiteVolume/fvMesh/singleCellFvMesh/singleCellFvMesh.H +++ b/src/finiteVolume/fvMesh/singleCellFvMesh/singleCellFvMesh.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 @@ -87,39 +87,6 @@ class singleCellFvMesh public: - //- Patch field mapper class for non-agglomerated meshes - class directPatchFieldMapper - : - public fvPatchFieldMapper - { - // Private data - - const labelUList& directAddressing_; - - public: - - //- Construct given addressing - directPatchFieldMapper(const labelUList& directAddressing) - : - directAddressing_(directAddressing) - {} - - virtual label size() const - { - return directAddressing_.size(); - } - - virtual bool direct() const - { - return true; - } - - virtual const labelUList& directAddressing() const - { - return directAddressing_; - } - }; - //- Patch field mapper class for agglomerated meshes class agglomPatchFieldMapper : @@ -129,6 +96,7 @@ public: const labelListList& addressing_; const scalarListList& weights_; + bool hasUnmapped_; public: @@ -140,8 +108,18 @@ public: ) : addressing_(addressing), - weights_(weights) - {} + weights_(weights), + hasUnmapped_(false) + { + forAll(addressing_, i) + { + if (addressing_[i].empty()) + { + hasUnmapped_ = true; + break; + } + } + } virtual label size() const { @@ -153,6 +131,11 @@ public: return false; } + bool hasUnmapped() const + { + return hasUnmapped_; + } + virtual const labelListList& addressing() const { return addressing_; diff --git a/src/finiteVolume/fvMesh/singleCellFvMesh/singleCellFvMeshInterpolate.C b/src/finiteVolume/fvMesh/singleCellFvMesh/singleCellFvMeshInterpolate.C index 33e8316ac7..93ef66101f 100644 --- a/src/finiteVolume/fvMesh/singleCellFvMesh/singleCellFvMeshInterpolate.C +++ b/src/finiteVolume/fvMesh/singleCellFvMesh/singleCellFvMeshInterpolate.C @@ -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 @@ -24,6 +24,8 @@ License \*---------------------------------------------------------------------------*/ #include "singleCellFvMesh.H" +#include "calculatedFvPatchFields.H" +#include "directFvPatchFieldMapper.H" #include "Time.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -39,12 +41,51 @@ tmp > singleCellFvMesh::interpolate const GeometricField& vf ) const { - // Create internal-field values - Field internalField(1, gAverage(vf)); - - // Create and map the patch field values + // 1. Create the complete field with dummy patch fields PtrList > patchFields(vf.boundaryField().size()); + forAll(patchFields, patchI) + { + patchFields.set + ( + patchI, + fvPatchField::New + ( + calculatedFvPatchField::typeName, + boundary()[patchI], + DimensionedField::null() + ) + ); + } + + // Create the complete field from the pieces + tmp > tresF + ( + new GeometricField + ( + IOobject + ( + vf.name(), + time().timeName(), + *this, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + *this, + vf.dimensions(), + Field(1, gAverage(vf)), + patchFields + ) + ); + GeometricField& resF = tresF(); + + + // 2. Change the fvPatchFields to the correct type using a mapper + // constructor (with reference to the now correct internal field) + + typename GeometricField:: + GeometricBoundaryField& bf = resF.boundaryField(); + if (agglomerate()) { forAll(vf.boundaryField(), patchI) @@ -67,14 +108,14 @@ tmp > singleCellFvMesh::interpolate ); } - patchFields.set + bf.set ( patchI, fvPatchField::New ( vf.boundaryField()[patchI], boundary()[patchI], - DimensionedField::null(), + resF.dimensionedInternalField(), agglomPatchFieldMapper(coarseToFine, coarseWeights) ) ); @@ -86,40 +127,20 @@ tmp > singleCellFvMesh::interpolate { labelList map(identity(vf.boundaryField()[patchI].size())); - patchFields.set + bf.set ( patchI, fvPatchField::New ( vf.boundaryField()[patchI], boundary()[patchI], - DimensionedField::null(), - directPatchFieldMapper(map) + resF.dimensionedInternalField(), + directFvPatchFieldMapper(map) ) ); } } - // Create the complete field from the pieces - tmp > tresF - ( - new GeometricField - ( - IOobject - ( - vf.name(), - time().timeName(), - *this, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - *this, - vf.dimensions(), - internalField, - patchFields - ) - ); - return tresF; } diff --git a/src/parallel/decompose/decompose/fvFieldDecomposer.H b/src/parallel/decompose/decompose/fvFieldDecomposer.H index 899b45b4b7..0bf83369e6 100644 --- a/src/parallel/decompose/decompose/fvFieldDecomposer.H +++ b/src/parallel/decompose/decompose/fvFieldDecomposer.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 @@ -88,6 +88,12 @@ public: return true; } + //- Are there unmapped values + bool hasUnmapped() const + { + return false; + } + const labelUList& directAddressing() const { return directAddressing_; @@ -128,6 +134,12 @@ public: return true; } + //- Are there unmapped values + bool hasUnmapped() const + { + return false; + } + const labelUList& directAddressing() const { return directAddressing_; @@ -165,6 +177,12 @@ public: return false; } + //- Are there unmapped values + bool hasUnmapped() const + { + return false; + } + const labelListList& addressing() const { return addressing_; diff --git a/src/parallel/decompose/decompose/fvFieldDecomposerDecomposeFields.C b/src/parallel/decompose/decompose/fvFieldDecomposerDecomposeFields.C index ca9d0e31b5..c72ceedfb8 100644 --- a/src/parallel/decompose/decompose/fvFieldDecomposerDecomposeFields.C +++ b/src/parallel/decompose/decompose/fvFieldDecomposerDecomposeFields.C @@ -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 @@ -40,83 +40,25 @@ Foam::fvFieldDecomposer::decomposeField const bool allowUnknownPatchFields ) const { - // Create and map the internal field values - Field internalField(field.internalField(), cellAddressing_); - - // Create and map the patch field values + // 1. Create the complete field with dummy patch fields PtrList > patchFields(boundaryAddressing_.size()); forAll(boundaryAddressing_, patchi) { - if (patchFieldDecomposerPtrs_[patchi]) - { - patchFields.set + patchFields.set + ( + patchi, + fvPatchField::New ( - patchi, - fvPatchField::New - ( - field.boundaryField()[boundaryAddressing_[patchi]], - procMesh_.boundary()[patchi], - DimensionedField::null(), - *patchFieldDecomposerPtrs_[patchi] - ) - ); - } - else if (isA(procMesh_.boundary()[patchi])) - { - patchFields.set - ( - patchi, - new processorCyclicFvPatchField - ( - procMesh_.boundary()[patchi], - DimensionedField::null(), - Field - ( - field.internalField(), - *processorVolPatchFieldDecomposerPtrs_[patchi] - ) - ) - ); - } - else if (isA(procMesh_.boundary()[patchi])) - { - patchFields.set - ( - patchi, - new processorFvPatchField - ( - procMesh_.boundary()[patchi], - DimensionedField::null(), - Field - ( - field.internalField(), - *processorVolPatchFieldDecomposerPtrs_[patchi] - ) - ) - ); - } - else if (allowUnknownPatchFields) - { - patchFields.set - ( - patchi, - new emptyFvPatchField - ( - procMesh_.boundary()[patchi], - DimensionedField::null() - ) - ); - } - else - { - FatalErrorIn("fvFieldDecomposer::decomposeField()") - << "Unknown type." << abort(FatalError); - } + calculatedFvPatchField::typeName, + procMesh_.boundary()[patchi], + DimensionedField::null() + ) + ); } // Create the field for the processor - return tmp > + tmp > tresF ( new GeometricField ( @@ -130,10 +72,90 @@ Foam::fvFieldDecomposer::decomposeField ), procMesh_, field.dimensions(), - internalField, + Field(field.internalField(), cellAddressing_), patchFields ) ); + GeometricField& resF = tresF(); + + + // 2. Change the fvPatchFields to the correct type using a mapper + // constructor (with reference to the now correct internal field) + + typename GeometricField:: + GeometricBoundaryField& bf = resF.boundaryField(); + + forAll(bf, patchi) + { + if (patchFieldDecomposerPtrs_[patchi]) + { + bf.set + ( + patchi, + fvPatchField::New + ( + field.boundaryField()[boundaryAddressing_[patchi]], + procMesh_.boundary()[patchi], + resF.dimensionedInternalField(), + *patchFieldDecomposerPtrs_[patchi] + ) + ); + } + else if (isA(procMesh_.boundary()[patchi])) + { + bf.set + ( + patchi, + new processorCyclicFvPatchField + ( + procMesh_.boundary()[patchi], + resF.dimensionedInternalField(), + Field + ( + field.internalField(), + *processorVolPatchFieldDecomposerPtrs_[patchi] + ) + ) + ); + } + else if (isA(procMesh_.boundary()[patchi])) + { + bf.set + ( + patchi, + new processorFvPatchField + ( + procMesh_.boundary()[patchi], + resF.dimensionedInternalField(), + Field + ( + field.internalField(), + *processorVolPatchFieldDecomposerPtrs_[patchi] + ) + ) + ); + } + else if (allowUnknownPatchFields) + { + bf.set + ( + patchi, + new emptyFvPatchField + ( + procMesh_.boundary()[patchi], + resF.dimensionedInternalField() + ) + ); + } + else + { + FatalErrorIn("fvFieldDecomposer::decomposeField()") + << "Unknown type." << abort(FatalError); + } + } + + // Create the field for the processor + return tresF; } @@ -188,34 +210,76 @@ Foam::fvFieldDecomposer::decomposeField } } - // Create and map the patch field values + + // 1. Create the complete field with dummy patch fields PtrList > patchFields(boundaryAddressing_.size()); + forAll(boundaryAddressing_, patchi) + { + patchFields.set + ( + patchi, + fvsPatchField::New + ( + calculatedFvsPatchField::typeName, + procMesh_.boundary()[patchi], + DimensionedField::null() + ) + ); + } + + tmp > tresF + ( + new GeometricField + ( + IOobject + ( + field.name(), + procMesh_.time().timeName(), + procMesh_, + IOobject::NO_READ, + IOobject::NO_WRITE + ), + procMesh_, + field.dimensions(), + Field(field.internalField(), mapAddr), + patchFields + ) + ); + GeometricField& resF = tresF(); + + + // 2. Change the fvsPatchFields to the correct type using a mapper + // constructor (with reference to the now correct internal field) + + typename GeometricField:: + GeometricBoundaryField& bf = resF.boundaryField(); + forAll(boundaryAddressing_, patchi) { if (patchFieldDecomposerPtrs_[patchi]) { - patchFields.set + bf.set ( patchi, fvsPatchField::New ( field.boundaryField()[boundaryAddressing_[patchi]], procMesh_.boundary()[patchi], - DimensionedField::null(), + resF.dimensionedInternalField(), *patchFieldDecomposerPtrs_[patchi] ) ); } else if (isA(procMesh_.boundary()[patchi])) { - patchFields.set + bf.set ( patchi, new processorCyclicFvsPatchField ( procMesh_.boundary()[patchi], - DimensionedField::null(), + resF.dimensionedInternalField(), Field ( allFaceField, @@ -226,13 +290,13 @@ Foam::fvFieldDecomposer::decomposeField } else if (isA(procMesh_.boundary()[patchi])) { - patchFields.set + bf.set ( patchi, new processorFvsPatchField ( procMesh_.boundary()[patchi], - DimensionedField::null(), + resF.dimensionedInternalField(), Field ( allFaceField, @@ -249,24 +313,7 @@ Foam::fvFieldDecomposer::decomposeField } // Create the field for the processor - return tmp > - ( - new GeometricField - ( - IOobject - ( - field.name(), - procMesh_.time().timeName(), - procMesh_, - IOobject::NO_READ, - IOobject::NO_WRITE - ), - procMesh_, - field.dimensions(), - internalField, - patchFields - ) - ); + return tresF; } diff --git a/src/parallel/reconstruct/reconstruct/fvFieldReconstructor.H b/src/parallel/reconstruct/reconstruct/fvFieldReconstructor.H index 43469d24b4..0ee1decbb4 100644 --- a/src/parallel/reconstruct/reconstruct/fvFieldReconstructor.H +++ b/src/parallel/reconstruct/reconstruct/fvFieldReconstructor.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 @@ -116,6 +116,11 @@ public: return true; } + bool hasUnmapped() const + { + return false; + } + const labelUList& directAddressing() const { return labelUList::null(); diff --git a/src/parallel/reconstruct/reconstruct/pointFieldReconstructor.H b/src/parallel/reconstruct/reconstruct/pointFieldReconstructor.H index 47ad5b23c2..c15b7111da 100644 --- a/src/parallel/reconstruct/reconstruct/pointFieldReconstructor.H +++ b/src/parallel/reconstruct/reconstruct/pointFieldReconstructor.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 @@ -112,6 +112,11 @@ public: return true; } + bool hasUnmapped() const + { + return false; + } + const labelUList& directAddressing() const { return labelUList::null(); diff --git a/src/sampling/meshToMeshInterpolation/meshToMesh/meshToMesh.H b/src/sampling/meshToMeshInterpolation/meshToMesh/meshToMesh.H index b99c0629cc..bfedab7433 100644 --- a/src/sampling/meshToMeshInterpolation/meshToMesh/meshToMesh.H +++ b/src/sampling/meshToMeshInterpolation/meshToMesh/meshToMesh.H @@ -175,48 +175,6 @@ public: ~meshToMesh(); - //- Patch-field interpolation class - class patchFieldInterpolator - : - public fvPatchFieldMapper - { - const labelList& directAddressing_; - - public: - - // Constructors - - //- Construct given addressing - patchFieldInterpolator(const labelList& addr) - : - directAddressing_(addr) - {} - - - //- Destructor - virtual ~patchFieldInterpolator() - {} - - - // Member Functions - - label size() const - { - return directAddressing_.size(); - } - - bool direct() const - { - return true; - } - - const labelList& directAddressing() const - { - return directAddressing_; - } - }; - - // Member Functions // Access diff --git a/src/sampling/meshToMeshInterpolation/meshToMesh/meshToMeshInterpolate.C b/src/sampling/meshToMeshInterpolation/meshToMesh/meshToMeshInterpolate.C index 372194e322..42a5269cd2 100644 --- a/src/sampling/meshToMeshInterpolation/meshToMesh/meshToMeshInterpolate.C +++ b/src/sampling/meshToMeshInterpolation/meshToMesh/meshToMeshInterpolate.C @@ -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 @@ -28,6 +28,7 @@ License #include "interpolationCellPoint.H" #include "SubField.H" #include "mixedFvPatchField.H" +#include "directFvPatchFieldMapper.H" // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // @@ -408,7 +409,7 @@ Foam::meshToMesh::interpolate << exit(FatalError); } - // Create and map the patch field values + // 1. Create the complete field with dummy patch fields PtrList > patchFields ( boundaryAddressing_.size() @@ -421,13 +422,9 @@ Foam::meshToMesh::interpolate patchI, fvPatchField::New ( - fromVf.boundaryField()[patchI], + calculatedFvPatchField::typeName, toMesh_.boundary()[patchI], - DimensionedField::null(), - patchFieldInterpolator - ( - boundaryAddressing_[patchI] - ) + DimensionedField::null() ) ); } @@ -452,6 +449,31 @@ Foam::meshToMesh::interpolate patchFields ) ); + GeometricField& toF = ttoF(); + + // 2. Change the fvPatchFields to the correct type using a mapper + // constructor (with reference to the now correct internal field) + + typename GeometricField:: + GeometricBoundaryField& bf = toF.boundaryField(); + + forAll(boundaryAddressing_, patchI) + { + bf.set + ( + patchI, + fvPatchField::New + ( + fromVf.boundaryField()[patchI], + toMesh_.boundary()[patchI], + toF.dimensionedInternalField(), + directFvPatchFieldMapper + ( + boundaryAddressing_[patchI] + ) + ) + ); + } return ttoF; } From a3b52a5f748a4fb6954a84c54bb0c46278137cad Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 12 Sep 2013 16:02:02 +0100 Subject: [PATCH 09/12] ENH: basic fvPatchFields: added mapping warning --- .../directionMixedFvPatchField.C | 22 +++++++++++++++++-- .../fixedGradient/fixedGradientFvPatchField.C | 22 +++++++++++++++++-- .../basic/fixedValue/fixedValueFvPatchField.C | 22 +++++++++++++++++-- .../basic/mixed/mixedFvPatchField.C | 22 +++++++++++++++++-- 4 files changed, 80 insertions(+), 8 deletions(-) diff --git a/src/finiteVolume/fields/fvPatchFields/basic/directionMixed/directionMixedFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/basic/directionMixed/directionMixedFvPatchField.C index 1a185a514f..ec66616b44 100644 --- a/src/finiteVolume/fields/fvPatchFields/basic/directionMixed/directionMixedFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/basic/directionMixed/directionMixedFvPatchField.C @@ -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 @@ -55,7 +55,25 @@ Foam::directionMixedFvPatchField::directionMixedFvPatchField refValue_(ptf.refValue_, mapper), refGrad_(ptf.refGrad_, mapper), valueFraction_(ptf.valueFraction_, mapper) -{} +{ + if (mapper.hasUnmapped()) + { + WarningIn + ( + "directionMixedFvPatchField::directionMixedFvPatchField\n" + "(\n" + " const directionMixedFvPatchField&,\n" + " const fvPatch&,\n" + " const DimensionedField&,\n" + " const fvPatchFieldMapper&\n" + ")\n" + ) << "On field " << iF.name() << " patch " << p.name() + << " patchField " << this->type() + << " : mapper does not map all values." << nl + << " To avoid this warning fully specify the mapping in derived" + << " patch fields." << endl; + } +} template diff --git a/src/finiteVolume/fields/fvPatchFields/basic/fixedGradient/fixedGradientFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/basic/fixedGradient/fixedGradientFvPatchField.C index dd10411a4f..9c46ecb089 100644 --- a/src/finiteVolume/fields/fvPatchFields/basic/fixedGradient/fixedGradientFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/basic/fixedGradient/fixedGradientFvPatchField.C @@ -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 @@ -56,7 +56,25 @@ fixedGradientFvPatchField::fixedGradientFvPatchField : fvPatchField(ptf, p, iF, mapper), gradient_(ptf.gradient_, mapper) -{} +{ + if (mapper.hasUnmapped()) + { + WarningIn + ( + "fixedGradientFvPatchField::fixedGradientFvPatchField\n" + "(\n" + " const fixedGradientFvPatchField&,\n" + " const fvPatch&,\n" + " const DimensionedField&,\n" + " const fvPatchFieldMapper&\n" + ")\n" + ) << "On field " << iF.name() << " patch " << p.name() + << " patchField " << this->type() + << " : mapper does not map all values." << nl + << " To avoid this warning fully specify the mapping in derived" + << " patch fields." << endl; + } +} template diff --git a/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.C index a401ede3ef..4fcf0863aa 100644 --- a/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/basic/fixedValue/fixedValueFvPatchField.C @@ -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 @@ -65,7 +65,25 @@ fixedValueFvPatchField::fixedValueFvPatchField ) : fvPatchField(ptf, p, iF, mapper) -{} +{ + if (mapper.hasUnmapped()) + { + WarningIn + ( + "fixedValueFvPatchField::fixedValueFvPatchField\n" + "(\n" + " const fixedGradientFvPatchField&,\n" + " const fvPatch&,\n" + " const DimensionedField&,\n" + " const fvPatchFieldMapper&\n" + ")\n" + ) << "On field " << iF.name() << " patch " << p.name() + << " patchField " << this->type() + << " : mapper does not map all values." << nl + << " To avoid this warning fully specify the mapping in derived" + << " patch fields." << endl; + } +} template diff --git a/src/finiteVolume/fields/fvPatchFields/basic/mixed/mixedFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/basic/mixed/mixedFvPatchField.C index b716d48686..378b5bbcf7 100644 --- a/src/finiteVolume/fields/fvPatchFields/basic/mixed/mixedFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/basic/mixed/mixedFvPatchField.C @@ -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 @@ -59,7 +59,25 @@ mixedFvPatchField::mixedFvPatchField refValue_(ptf.refValue_, mapper), refGrad_(ptf.refGrad_, mapper), valueFraction_(ptf.valueFraction_, mapper) -{} +{ + if (mapper.hasUnmapped()) + { + WarningIn + ( + "mixedFvPatchField::mixedFvPatchField\n" + "(\n" + " const mixedFvPatchField&,\n" + " const fvPatch&,\n" + " const DimensionedField&,\n" + " const fvPatchFieldMapper&\n" + ")\n" + ) << "On field " << iF.name() << " patch " << p.name() + << " patchField " << this->type() + << " : mapper does not map all values." << nl + << " To avoid this warning fully specify the mapping in derived" + << " patch fields." << endl; + } +} template From 759ecfce8fc18ee53a5ac8a10b266bb8a2e1a7cf Mon Sep 17 00:00:00 2001 From: mattijs Date: Thu, 12 Sep 2013 16:18:11 +0100 Subject: [PATCH 10/12] COMP: thermmoSingleLayer: missing include --- .../surfaceFilmModels/thermoSingleLayer/thermoSingleLayerI.H | 1 + 1 file changed, 1 insertion(+) diff --git a/src/regionModels/surfaceFilmModels/thermoSingleLayer/thermoSingleLayerI.H b/src/regionModels/surfaceFilmModels/thermoSingleLayer/thermoSingleLayerI.H index 0905176adf..5382fecb37 100644 --- a/src/regionModels/surfaceFilmModels/thermoSingleLayer/thermoSingleLayerI.H +++ b/src/regionModels/surfaceFilmModels/thermoSingleLayer/thermoSingleLayerI.H @@ -26,6 +26,7 @@ License #include "thermoSingleLayer.H" #include "heatTransferModel.H" #include "filmRadiationModel.H" +#include "phaseChangeModel.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // From 17f2d5f189b2562ec2acbcb90c91d14b296a3251 Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 12 Sep 2013 16:58:39 +0100 Subject: [PATCH 11/12] Completed update of ddtCorr to use Uf for DyM solvers --- .../combustion/coldEngineFoam/coldEngineFoam.C | 1 + .../solvers/combustion/engineFoam/engineFoam.C | 1 + .../solvers/combustion/engineFoam/pEqn.H | 17 +++++++++++++---- .../rhoPimpleFoam/rhoPimpleDyMFoam/pEqn.H | 11 +++++++++++ .../rhoPimpleDyMFoam/rhoPimpleDyMFoam.C | 3 +++ .../compressible/sonicFoam/sonicDyMFoam/pEqn.H | 14 ++++++++++++-- .../sonicFoam/sonicDyMFoam/sonicDyMFoam.C | 6 ------ .../lagrangian/sprayFoam/sprayEngineFoam/pEqn.H | 17 +++++++++++++---- .../sprayFoam/sprayEngineFoam/sprayEngineFoam.C | 1 + 9 files changed, 55 insertions(+), 16 deletions(-) diff --git a/applications/solvers/combustion/coldEngineFoam/coldEngineFoam.C b/applications/solvers/combustion/coldEngineFoam/coldEngineFoam.C index bd5e2c3b99..43eb616e17 100644 --- a/applications/solvers/combustion/coldEngineFoam/coldEngineFoam.C +++ b/applications/solvers/combustion/coldEngineFoam/coldEngineFoam.C @@ -48,6 +48,7 @@ int main(int argc, char *argv[]) #include "createEngineMesh.H" #include "createFields.H" #include "createFvOptions.H" + #include "createRhoUf.H" #include "initContinuityErrs.H" #include "readEngineTimeControls.H" #include "compressibleCourantNo.H" diff --git a/applications/solvers/combustion/engineFoam/engineFoam.C b/applications/solvers/combustion/engineFoam/engineFoam.C index 592abbd3e6..a35e22dc58 100644 --- a/applications/solvers/combustion/engineFoam/engineFoam.C +++ b/applications/solvers/combustion/engineFoam/engineFoam.C @@ -72,6 +72,7 @@ int main(int argc, char *argv[]) #include "readCombustionProperties.H" #include "createFields.H" #include "createFvOptions.H" + #include "createRhoUf.H" #include "initContinuityErrs.H" #include "readEngineTimeControls.H" #include "compressibleCourantNo.H" diff --git a/applications/solvers/combustion/engineFoam/pEqn.H b/applications/solvers/combustion/engineFoam/pEqn.H index 384ecbee59..2f6333cc97 100644 --- a/applications/solvers/combustion/engineFoam/pEqn.H +++ b/applications/solvers/combustion/engineFoam/pEqn.H @@ -15,12 +15,12 @@ if (pimple.transonic()) *( ( (fvc::interpolate(rho*HbyA) & mesh.Sf()) - //***HGW + rhorAUf*fvc::ddtCorr(rho, U, phi) + + rhorAUf*fvc::ddtCorr(rho, U, rhoUf) )/fvc::interpolate(rho) - - fvc::meshPhi(rho, U) ) ); + fvc::makeRelative(phid, psi, U); fvOptions.makeRelative(fvc::interpolate(psi), phid); while (pimple.correctNonOrthogonal()) @@ -51,11 +51,11 @@ else "phiHbyA", ( (fvc::interpolate(rho*HbyA) & mesh.Sf()) - //***HGW + rhorAUf*fvc::ddtCorr(rho, U, phi) + + rhorAUf*fvc::ddtCorr(rho, U, rhoUf) ) - - fvc::interpolate(rho)*fvc::meshPhi(rho, U) ); + fvc::makeRelative(phiHbyA, rho, U); fvOptions.makeRelative(fvc::interpolate(rho), phiHbyA); while (pimple.correctNonOrthogonal()) @@ -88,6 +88,15 @@ U.correctBoundaryConditions(); fvOptions.correct(U); K = 0.5*magSqr(U); +{ + rhoUf = fvc::interpolate(rho*U); + surfaceVectorField n(mesh.Sf()/mesh.magSf()); + rhoUf += + mesh.Sf() + *(fvc::absolute(phi, rho, U) - (mesh.Sf() & rhoUf)) + /sqr(mesh.magSf()); +} + if (thermo.dpdt()) { dpdt = fvc::ddt(p) - fvc::div(fvc::meshPhi(rho, U), p); diff --git a/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleDyMFoam/pEqn.H b/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleDyMFoam/pEqn.H index 40cf109457..14ba97d1c2 100644 --- a/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleDyMFoam/pEqn.H +++ b/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleDyMFoam/pEqn.H @@ -26,6 +26,7 @@ if (pimple.transonic()) )/fvc::interpolate(rho) ); + fvc::makeRelative(phid, psi, U); fvOptions.makeRelative(fvc::interpolate(psi), phid); while (pimple.correctNonOrthogonal()) @@ -58,6 +59,7 @@ else + rhorAUf*fvc::ddtCorr(rho, U, rhoUf) ); + fvc::makeRelative(phiHbyA, rho, U); fvOptions.makeRelative(fvc::interpolate(rho), phiHbyA); while (pimple.correctNonOrthogonal()) @@ -102,6 +104,15 @@ U.correctBoundaryConditions(); fvOptions.correct(U); K = 0.5*magSqr(U); +{ + rhoUf = fvc::interpolate(rho*U); + surfaceVectorField n(mesh.Sf()/mesh.magSf()); + rhoUf += + mesh.Sf() + *(fvc::absolute(phi, rho, U) - (mesh.Sf() & rhoUf)) + /sqr(mesh.magSf()); +} + if (thermo.dpdt()) { dpdt = fvc::ddt(p); diff --git a/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleDyMFoam/rhoPimpleDyMFoam.C b/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleDyMFoam/rhoPimpleDyMFoam.C index aae3285186..e633ebee60 100644 --- a/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleDyMFoam/rhoPimpleDyMFoam.C +++ b/applications/solvers/compressible/rhoPimpleFoam/rhoPimpleDyMFoam/rhoPimpleDyMFoam.C @@ -76,6 +76,9 @@ int main(int argc, char *argv[]) Info<< "Time = " << runTime.timeName() << nl << endl; { + // Store momentum to set rhoUf for introduced faces. + volVectorField rhoU("rhoU", rho*U); + // Store divrhoU from the previous time-step/mesh for the correctPhi volScalarField divrhoU(fvc::div(fvc::absolute(phi, rho, U))); diff --git a/applications/solvers/compressible/sonicFoam/sonicDyMFoam/pEqn.H b/applications/solvers/compressible/sonicFoam/sonicDyMFoam/pEqn.H index f8f99dafa5..65afd1aeb8 100644 --- a/applications/solvers/compressible/sonicFoam/sonicDyMFoam/pEqn.H +++ b/applications/solvers/compressible/sonicFoam/sonicDyMFoam/pEqn.H @@ -13,12 +13,13 @@ surfaceScalarField phid *( ( (fvc::interpolate(rho*HbyA) & mesh.Sf()) - //***HGW + rhorAUf*fvc::ddtCorr(rho, U, phi) + + rhorAUf*fvc::ddtCorr(rho, U, rhoUf) )/fvc::interpolate(rho) - - fvc::meshPhi(rho, U) ) ); +fvc::makeRelative(phid, psi, U); + for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) { fvScalarMatrix pEqn @@ -37,3 +38,12 @@ for (int nonOrth=0; nonOrth<=nNonOrthCorr; nonOrth++) U = HbyA - rAU*fvc::grad(p); U.correctBoundaryConditions(); + +{ + rhoUf = fvc::interpolate(rho*U); + surfaceVectorField n(mesh.Sf()/mesh.magSf()); + rhoUf += + mesh.Sf() + *(fvc::absolute(phi, rho, U) - (mesh.Sf() & rhoUf)) + /sqr(mesh.magSf()); +} diff --git a/applications/solvers/compressible/sonicFoam/sonicDyMFoam/sonicDyMFoam.C b/applications/solvers/compressible/sonicFoam/sonicDyMFoam/sonicDyMFoam.C index 11ec1de915..62d4716fb5 100644 --- a/applications/solvers/compressible/sonicFoam/sonicDyMFoam/sonicDyMFoam.C +++ b/applications/solvers/compressible/sonicFoam/sonicDyMFoam/sonicDyMFoam.C @@ -64,12 +64,6 @@ int main(int argc, char *argv[]) mesh.movePoints(motionPtr->newPoints()); - // Calculate absolute flux from the mapped surface velocity - phi = mesh.Sf() & rhoUf; - - // Make the flux relative to the mesh motion - fvc::makeRelative(phi, rho, U); - #include "rhoEqn.H" // --- Pressure-velocity PIMPLE corrector loop diff --git a/applications/solvers/lagrangian/sprayFoam/sprayEngineFoam/pEqn.H b/applications/solvers/lagrangian/sprayFoam/sprayEngineFoam/pEqn.H index 62c3e0376e..b10c24aa0b 100644 --- a/applications/solvers/lagrangian/sprayFoam/sprayEngineFoam/pEqn.H +++ b/applications/solvers/lagrangian/sprayFoam/sprayEngineFoam/pEqn.H @@ -15,12 +15,12 @@ if (pimple.transonic()) *( ( (fvc::interpolate(rho*HbyA) & mesh.Sf()) - //***HGW + rhorAUf*fvc::ddtCorr(rho, U, phi) + + rhorAUf*fvc::ddtCorr(rho, U, rhoUf) )/fvc::interpolate(rho) - - fvc::meshPhi(rho, U) ) ); + fvc::makeRelative(phid, psi, U); fvOptions.makeRelative(fvc::interpolate(psi), phid); while (pimple.correctNonOrthogonal()) @@ -52,11 +52,11 @@ else "phiHbyA", ( (fvc::interpolate(HbyA) & mesh.Sf()) - //***HGW + rhorAUf*fvc::ddtCorr(rho, U, phi) + + rhorAUf*fvc::ddtCorr(rho, U, rhoUf) ) - - fvc::interpolate(rho)*fvc::meshPhi(rho, U) ); + fvc::makeRelative(phiHbyA, rho, U); fvOptions.makeRelative(fvc::interpolate(rho), phiHbyA); while (pimple.correctNonOrthogonal()) @@ -90,6 +90,15 @@ U.correctBoundaryConditions(); fvOptions.correct(U); K = 0.5*magSqr(U); +{ + rhoUf = fvc::interpolate(rho*U); + surfaceVectorField n(mesh.Sf()/mesh.magSf()); + rhoUf += + mesh.Sf() + *(fvc::absolute(phi, rho, U) - (mesh.Sf() & rhoUf)) + /sqr(mesh.magSf()); +} + if (thermo.dpdt()) { dpdt = fvc::ddt(p) - fvc::div(fvc::meshPhi(rho, U), p); diff --git a/applications/solvers/lagrangian/sprayFoam/sprayEngineFoam/sprayEngineFoam.C b/applications/solvers/lagrangian/sprayFoam/sprayEngineFoam/sprayEngineFoam.C index baafc8d5e3..b91a3ad79d 100644 --- a/applications/solvers/lagrangian/sprayFoam/sprayEngineFoam/sprayEngineFoam.C +++ b/applications/solvers/lagrangian/sprayFoam/sprayEngineFoam/sprayEngineFoam.C @@ -52,6 +52,7 @@ int main(int argc, char *argv[]) #include "readGravitationalAcceleration.H" #include "createFields.H" #include "createFvOptions.H" + #include "createRhoUf.H" #include "createClouds.H" #include "createRadiationModel.H" #include "initContinuityErrs.H" From 40db2359b1dc843040442b9f16cd10ab33672ffe Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 12 Sep 2013 17:02:02 +0100 Subject: [PATCH 12/12] interDyMFoam: Update surface fields following mesh change --- .../solvers/multiphase/interFoam/alphaEqnSubCycle.H | 12 +++++++++++- .../multiphase/interFoam/interDyMFoam/interDyMFoam.C | 2 ++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/applications/solvers/multiphase/interFoam/alphaEqnSubCycle.H b/applications/solvers/multiphase/interFoam/alphaEqnSubCycle.H index 428876fd22..ac40a9bc9e 100644 --- a/applications/solvers/multiphase/interFoam/alphaEqnSubCycle.H +++ b/applications/solvers/multiphase/interFoam/alphaEqnSubCycle.H @@ -3,7 +3,17 @@ if (nAlphaSubCycles > 1) { dimensionedScalar totalDeltaT = runTime.deltaT(); - surfaceScalarField rhoPhiSum(0.0*rhoPhi); + surfaceScalarField rhoPhiSum + ( + IOobject + ( + "rhoPhiSum", + runTime.timeName(), + mesh + ), + mesh, + dimensionedScalar("0", dimDensity, 0) + ); for ( diff --git a/applications/solvers/multiphase/interFoam/interDyMFoam/interDyMFoam.C b/applications/solvers/multiphase/interFoam/interDyMFoam/interDyMFoam.C index 4c986ef2d8..032f2db730 100644 --- a/applications/solvers/multiphase/interFoam/interDyMFoam/interDyMFoam.C +++ b/applications/solvers/multiphase/interFoam/interDyMFoam/interDyMFoam.C @@ -100,6 +100,8 @@ int main(int argc, char *argv[]) // Make the flux relative to the mesh motion fvc::makeRelative(phi, U); + + interface.correct(); } if (mesh.changing() && checkMeshCourantNo)