diff --git a/src/dynamicMesh/fvMeshAdder/fvMeshAdder.C b/src/dynamicMesh/fvMeshAdder/fvMeshAdder.C index b3aa15ff3f..f24dc996bf 100644 --- a/src/dynamicMesh/fvMeshAdder/fvMeshAdder.C +++ b/src/dynamicMesh/fvMeshAdder/fvMeshAdder.C @@ -71,7 +71,8 @@ Foam::autoPtr Foam::fvMeshAdder::add fvMesh& mesh0, const fvMesh& mesh1, const faceCoupleInfo& coupleInfo, - const bool validBoundary + const bool validBoundary, + const bool fullyMapped ) { mesh0.clearOut(); @@ -101,17 +102,20 @@ Foam::autoPtr Foam::fvMeshAdder::add // Do the mapping of the stored fields // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - fvMeshAdder::MapVolFields(map, mesh0, mesh1); - fvMeshAdder::MapVolFields(map, mesh0, mesh1); - fvMeshAdder::MapVolFields(map, mesh0, mesh1); - fvMeshAdder::MapVolFields(map, mesh0, mesh1); - fvMeshAdder::MapVolFields(map, mesh0, mesh1); + fvMeshAdder::MapVolFields(map, mesh0, mesh1, fullyMapped); + fvMeshAdder::MapVolFields(map, mesh0, mesh1, fullyMapped); + fvMeshAdder::MapVolFields(map, mesh0, mesh1, fullyMapped); + fvMeshAdder::MapVolFields(map, mesh0, mesh1, fullyMapped); + fvMeshAdder::MapVolFields(map, mesh0, mesh1, fullyMapped); - fvMeshAdder::MapSurfaceFields(map, mesh0, mesh1); - fvMeshAdder::MapSurfaceFields(map, mesh0, mesh1); - fvMeshAdder::MapSurfaceFields(map, mesh0, mesh1); - fvMeshAdder::MapSurfaceFields(map, mesh0, mesh1); - fvMeshAdder::MapSurfaceFields(map, mesh0, mesh1); + fvMeshAdder::MapSurfaceFields(map, mesh0, mesh1, fullyMapped); + fvMeshAdder::MapSurfaceFields(map, mesh0, mesh1, fullyMapped); + fvMeshAdder::MapSurfaceFields + ( + map, mesh0, mesh1, fullyMapped + ); + fvMeshAdder::MapSurfaceFields(map, mesh0, mesh1, fullyMapped); + fvMeshAdder::MapSurfaceFields(map, mesh0, mesh1, fullyMapped); fvMeshAdder::MapDimFields(map, mesh0, mesh1); fvMeshAdder::MapDimFields(map, mesh0, mesh1); diff --git a/src/dynamicMesh/fvMeshAdder/fvMeshAdder.H b/src/dynamicMesh/fvMeshAdder/fvMeshAdder.H index e86792c396..413dc0a48d 100644 --- a/src/dynamicMesh/fvMeshAdder/fvMeshAdder.H +++ b/src/dynamicMesh/fvMeshAdder/fvMeshAdder.H @@ -89,7 +89,8 @@ private: const mapAddedPolyMesh& meshMap, GeometricField& fld, - const GeometricField& fldToAdd + const GeometricField& fldToAdd, + const bool fullyMapped ); //- Update single surfaceField. @@ -99,7 +100,8 @@ private: const mapAddedPolyMesh& meshMap, GeometricField& fld, - const GeometricField& fldToAdd + const GeometricField& fldToAdd, + const bool fullyMapped ); //- Update single dimensionedField. @@ -126,16 +128,21 @@ public: fvMesh& mesh0, const fvMesh& mesh1, const faceCoupleInfo& coupleInfo, - const bool validBoundary = true + const bool validBoundary = true, + const bool fullyMapped = false ); - //- Map all volFields of Type + //- Map all volFields of Type. + // Optionally override mapping detection + // of unmapped values (e.g. used in fvMeshDistribute since it fixes + // up mapping itself) template static void MapVolFields ( const mapAddedPolyMesh&, const fvMesh& mesh, - const fvMesh& meshToAdd + const fvMesh& meshToAdd, + const bool fullyMapped = false ); //- Map all surfaceFields of Type @@ -144,7 +151,8 @@ public: ( const mapAddedPolyMesh&, const fvMesh& mesh, - const fvMesh& meshToAdd + const fvMesh& meshToAdd, + const bool fullyMapped = false ); //- Map all DimensionedFields of Type diff --git a/src/dynamicMesh/fvMeshAdder/fvMeshAdderTemplates.C b/src/dynamicMesh/fvMeshAdder/fvMeshAdderTemplates.C index b6640a354e..48a0456597 100644 --- a/src/dynamicMesh/fvMeshAdder/fvMeshAdderTemplates.C +++ b/src/dynamicMesh/fvMeshAdder/fvMeshAdderTemplates.C @@ -36,7 +36,8 @@ void Foam::fvMeshAdder::MapVolField const mapAddedPolyMesh& meshMap, GeometricField& fld, - const GeometricField& fldToAdd + const GeometricField& fldToAdd, + const bool fullyMapped ) { const fvMesh& mesh = fld.mesh(); @@ -142,6 +143,12 @@ void Foam::fvMeshAdder::MapVolField directFvPatchFieldMapper patchMapper(newToOld); + // Override mapping (for use in e.g. fvMeshDistribute where + // it sorts mapping out itself) + if (fullyMapped) + { + patchMapper.hasUnmapped() = false; + } // Create new patchField with same type as existing one. // Note: @@ -204,6 +211,13 @@ void Foam::fvMeshAdder::MapVolField directFvPatchFieldMapper patchMapper(newToAdded); + // Override mapping (for use in e.g. fvMeshDistribute where + // it sorts mapping out itself) + if (fullyMapped) + { + patchMapper.hasUnmapped() = false; + } + bfld.set ( newPatchi, @@ -250,7 +264,8 @@ void Foam::fvMeshAdder::MapVolFields ( const mapAddedPolyMesh& meshMap, const fvMesh& mesh, - const fvMesh& meshToAdd + const fvMesh& meshToAdd, + const bool fullyMapped ) { HashTable*> fields @@ -312,7 +327,7 @@ void Foam::fvMeshAdder::MapVolFields << "MapVolFields : mapping " << fld.name() << " and " << fldToAdd.name() << endl; - MapVolField(meshMap, fld, fldToAdd); + MapVolField(meshMap, fld, fldToAdd, fullyMapped); } else { @@ -331,7 +346,8 @@ void Foam::fvMeshAdder::MapSurfaceField const mapAddedPolyMesh& meshMap, GeometricField& fld, - const GeometricField& fldToAdd + const GeometricField& fldToAdd, + const bool fullyMapped ) { const fvMesh& mesh = fld.mesh(); @@ -458,6 +474,13 @@ void Foam::fvMeshAdder::MapSurfaceField directFvPatchFieldMapper patchMapper(newToOld); + // Override mapping (for use in e.g. fvMeshDistribute where + // it sorts mapping out itself) + if (fullyMapped) + { + patchMapper.hasUnmapped() = false; + } + // Create new patchField with same type as existing one. // Note: // - boundaryField already in new order so access with newPatchi @@ -519,6 +542,13 @@ void Foam::fvMeshAdder::MapSurfaceField directFvPatchFieldMapper patchMapper(newToAdded); + // Override mapping (for use in e.g. fvMeshDistribute where + // it sorts mapping out itself) + if (fullyMapped) + { + patchMapper.hasUnmapped() = false; + } + bfld.set ( newPatchi, @@ -565,7 +595,8 @@ void Foam::fvMeshAdder::MapSurfaceFields ( const mapAddedPolyMesh& meshMap, const fvMesh& mesh, - const fvMesh& meshToAdd + const fvMesh& meshToAdd, + const bool fullyMapped ) { typedef GeometricField fldType; @@ -619,7 +650,7 @@ void Foam::fvMeshAdder::MapSurfaceFields << "MapSurfaceFields : mapping " << fld.name() << " and " << fldToAdd.name() << endl; - MapSurfaceField(meshMap, fld, fldToAdd); + MapSurfaceField(meshMap, fld, fldToAdd, fullyMapped); } else { diff --git a/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C b/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C index 02ef7638ea..b7180c770d 100644 --- a/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C +++ b/src/dynamicMesh/fvMeshDistribute/fvMeshDistribute.C @@ -2606,7 +2606,8 @@ Foam::autoPtr Foam::fvMeshDistribute::distribute mesh_, domainMesh, couples, - false // no parallel comms + false, // no parallel comms + true // fake complete mapping ); // Update mesh data: sourceFace,sourceProc for added diff --git a/src/finiteVolume/fields/fvPatchFields/derived/mappedField/Sampled/Sampled.H b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/Sampled/Sampled.H index 9175b6df54..cc1c3f8c3a 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/mappedField/Sampled/Sampled.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/mappedField/Sampled/Sampled.H @@ -185,7 +185,19 @@ public: // Evaluation //- Return sampled value - virtual tmp> value(const scalar) const; + virtual tmp> value(const scalar x) const; + + //- Is value constant (i.e. independent of x) + virtual inline bool constant() const + { + return false; + } + + //- Is value uniform (i.e. independent of coordinate) + virtual inline bool uniform() const + { + return false; + } //- Integrate between two values virtual tmp> integrate diff --git a/src/finiteVolume/fields/fvPatchFields/derived/uniformFixedValue/uniformFixedValueFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/uniformFixedValue/uniformFixedValueFvPatchField.C index 012740f257..2211651b48 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/uniformFixedValue/uniformFixedValueFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/uniformFixedValue/uniformFixedValueFvPatchField.C @@ -63,7 +63,17 @@ Foam::uniformFixedValueFvPatchField::uniformFixedValueFvPatchField fixedValueFvPatchField(p, iF, dict, false), uniformValue_(PatchFunction1::New(p.patch(), "uniformValue", dict)) { - this->evaluate(); + if (dict.found("value")) + { + fvPatchField::operator= + ( + Field("value", dict, p.size()) + ); + } + else + { + this->evaluate(); + } } @@ -79,8 +89,16 @@ Foam::uniformFixedValueFvPatchField::uniformFixedValueFvPatchField fixedValueFvPatchField(p, iF), // Don't map uniformValue_(ptf.uniformValue_.clone(p.patch())) { - // Evaluate since value not mapped - this->evaluate(); + if (mapper.direct() && !mapper.hasUnmapped()) + { + // Use mapping instead of re-evaluation + this->map(ptf, mapper); + } + else + { + // Evaluate since value not mapped + this->evaluate(); + } } @@ -104,13 +122,7 @@ Foam::uniformFixedValueFvPatchField::uniformFixedValueFvPatchField : fixedValueFvPatchField(ptf, iF), uniformValue_(ptf.uniformValue_.clone(this->patch().patch())) -{ - // Evaluate the profile if defined - if (uniformValue_.valid()) - { - this->evaluate(); - } -} +{} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // @@ -123,6 +135,12 @@ void Foam::uniformFixedValueFvPatchField::autoMap { fixedValueFvPatchField::autoMap(mapper); uniformValue_().autoMap(mapper); + + if (uniformValue_().constant()) + { + // If mapper is not dependent on time we're ok to evaluate + this->evaluate(); + } } diff --git a/src/finiteVolume/fields/fvPatchFields/fvPatchField/directFvPatchFieldMapper.H b/src/finiteVolume/fields/fvPatchFields/fvPatchField/directFvPatchFieldMapper.H index 7a87d1ad53..8aa3163ef2 100644 --- a/src/finiteVolume/fields/fvPatchFields/fvPatchField/directFvPatchFieldMapper.H +++ b/src/finiteVolume/fields/fvPatchFields/fvPatchField/directFvPatchFieldMapper.H @@ -93,6 +93,11 @@ public: return hasUnmapped_; } + bool& hasUnmapped() + { + return hasUnmapped_; + } + const labelUList& directAddressing() const { return directAddressing_; diff --git a/src/meshTools/PatchFunction1/ConstantField/ConstantField.C b/src/meshTools/PatchFunction1/ConstantField/ConstantField.C index 1b9378ccc4..6815159711 100644 --- a/src/meshTools/PatchFunction1/ConstantField/ConstantField.C +++ b/src/meshTools/PatchFunction1/ConstantField/ConstantField.C @@ -32,13 +32,17 @@ Foam::PatchFunction1Types::ConstantField::ConstantField ( const polyPatch& pp, const word& entryName, - const Field& value, + const bool isUniform, + const Type& uniformValue, + const Field& nonUniformValue, const dictionary& dict, const bool faceValues ) : PatchFunction1(pp, entryName, dict, faceValues), - value_(value) + isUniform_(isUniform), + uniformValue_(uniformValue), + value_(nonUniformValue) {} @@ -47,9 +51,14 @@ Foam::Field Foam::PatchFunction1Types::ConstantField::getValue ( const word& keyword, const dictionary& dict, - const label len + const label len, + bool& isUniform, + Type& uniformValue ) { + isUniform = true; + uniformValue = Zero; + Field fld; if (len) @@ -67,13 +76,16 @@ Foam::Field Foam::PatchFunction1Types::ConstantField::getValue || firstToken.wordToken() == "constant" ) { + is >> uniformValue; fld.setSize(len); - fld = pTraits(is); + fld = uniformValue; } else if (firstToken.wordToken() == "nonuniform") { List& list = fld; is >> list; + isUniform = false; + label currentSize = fld.size(); if (currentSize != len) { @@ -105,6 +117,7 @@ Foam::Field Foam::PatchFunction1Types::ConstantField::getValue } else { + isUniform = false; FatalIOErrorInFunction(dict) << "Expected keyword 'uniform', 'nonuniform' or 'constant'" << ", found " << firstToken.wordToken() @@ -113,10 +126,10 @@ Foam::Field Foam::PatchFunction1Types::ConstantField::getValue } else { - fld.setSize(len); - is.putBack(firstToken); - fld = pTraits(is); + is >> uniformValue; + fld.setSize(len); + fld = uniformValue; } } return fld; @@ -134,7 +147,7 @@ Foam::PatchFunction1Types::ConstantField::ConstantField ) : PatchFunction1(pp, entryName, dict, faceValues), - value_(getValue(entryName, dict, pp.size())) + value_(getValue(entryName, dict, pp.size(), isUniform_, uniformValue_)) {} @@ -145,6 +158,8 @@ Foam::PatchFunction1Types::ConstantField::ConstantField ) : PatchFunction1(cnst), + isUniform_(cnst.isUniform_), + uniformValue_(cnst.uniformValue_), value_(cnst.value_) {} @@ -157,8 +172,17 @@ Foam::PatchFunction1Types::ConstantField::ConstantField ) : PatchFunction1(cnst, pp), + isUniform_(cnst.isUniform_), + uniformValue_(cnst.uniformValue_), value_(cnst.value_) -{} +{ + // If different sizes do what? + value_.setSize(this->patch_.size()); + if (isUniform_) + { + value_ = uniformValue_; + } +} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // @@ -170,6 +194,12 @@ void Foam::PatchFunction1Types::ConstantField::autoMap ) { value_.autoMap(mapper); + + // If originating from single value override just to make sure + if (isUniform_) + { + value_ = uniformValue_; + } } diff --git a/src/meshTools/PatchFunction1/ConstantField/ConstantField.H b/src/meshTools/PatchFunction1/ConstantField/ConstantField.H index 307a49c4ac..ccb56246c6 100644 --- a/src/meshTools/PatchFunction1/ConstantField/ConstantField.H +++ b/src/meshTools/PatchFunction1/ConstantField/ConstantField.H @@ -60,6 +60,12 @@ class ConstantField { // Private data + //- Is uniform? + bool isUniform_; + + //- If uniform the uniformValue + Type uniformValue_; + //- ConstantField value Field value_; @@ -71,7 +77,9 @@ class ConstantField ( const word& keyword, const dictionary& dict, - const label len + const label len, + bool& isUniform, + Type& uniformValue ); //- No copy assignment @@ -91,7 +99,9 @@ public: ( const polyPatch& pp, const word& entryName, - const Field& value, + const bool isUniform, + const Type& uniformValue, + const Field& nonUniformValue, const dictionary& dict = dictionary::null, const bool faceValues = true ); @@ -141,7 +151,19 @@ public: // Evaluation //- Return constant value - virtual inline tmp> value(const scalar) const; + virtual inline tmp> value(const scalar x) const; + + //- Is value constant (i.e. independent of x) + virtual inline bool constant() const + { + return true; + } + + //- Is value uniform (i.e. independent of coordinate) + virtual inline bool uniform() const + { + return isUniform_ && PatchFunction1::uniform(); + } //- Integrate between two values virtual inline tmp> integrate diff --git a/src/meshTools/PatchFunction1/MappedFile/MappedFile.H b/src/meshTools/PatchFunction1/MappedFile/MappedFile.H index 60bdb325b5..06db2eeae6 100644 --- a/src/meshTools/PatchFunction1/MappedFile/MappedFile.H +++ b/src/meshTools/PatchFunction1/MappedFile/MappedFile.H @@ -178,6 +178,18 @@ public: //- Return MappedFile value virtual tmp> value(const scalar) const; + //- Is value constant (i.e. independent of x) + virtual bool constant() const + { + return sampleTimes_.size() == 1; + } + + //- Is value uniform (i.e. independent of coordinate) + virtual bool uniform() const + { + return PatchFunction1::uniform(); + } + //- Integrate between two values virtual tmp> integrate ( diff --git a/src/meshTools/PatchFunction1/PatchFunction1.C b/src/meshTools/PatchFunction1/PatchFunction1.C index 94bbdf3f70..8b1fa65c0c 100644 --- a/src/meshTools/PatchFunction1/PatchFunction1.C +++ b/src/meshTools/PatchFunction1/PatchFunction1.C @@ -113,6 +113,12 @@ Foam::tmp> Foam::PatchFunction1::value return Field(); } +template +bool Foam::PatchFunction1::uniform() const +{ + return !coordSys_.active(); +} + template Foam::tmp> Foam::PatchFunction1::integrate diff --git a/src/meshTools/PatchFunction1/PatchFunction1.H b/src/meshTools/PatchFunction1/PatchFunction1.H index e6713a3023..9352d5591c 100644 --- a/src/meshTools/PatchFunction1/PatchFunction1.H +++ b/src/meshTools/PatchFunction1/PatchFunction1.H @@ -193,6 +193,12 @@ public: //- Return value as a function of (scalar) independent variable virtual tmp> value(const scalar x) const; + //- Is value constant (i.e. independent of x) + virtual bool constant() const = 0; + + //- Is value uniform (i.e. independent of coordinate) + virtual bool uniform() const = 0; + //- Integrate between two (scalar) values virtual tmp> integrate ( diff --git a/src/meshTools/PatchFunction1/PatchFunction1New.C b/src/meshTools/PatchFunction1/PatchFunction1New.C index ce379527eb..4b10bd59ca 100644 --- a/src/meshTools/PatchFunction1/PatchFunction1New.C +++ b/src/meshTools/PatchFunction1/PatchFunction1New.C @@ -67,7 +67,9 @@ Foam::autoPtr> Foam::PatchFunction1::New { // Backwards-compatibility for reading straight fields is.putBack(firstToken); - const Field value(pp.size(), pTraits(is)); + + const Type uniformValue = pTraits(is); + const Field value(pp.size(), uniformValue); return autoPtr> ( @@ -75,6 +77,8 @@ Foam::autoPtr> Foam::PatchFunction1::New ( pp, entryName, + true, // uniform + uniformValue, // uniform value value, // Supply value dict, faceValues diff --git a/src/meshTools/PatchFunction1/UniformValueField/UniformValueField.H b/src/meshTools/PatchFunction1/UniformValueField/UniformValueField.H index 683ff0c560..c3c94f5e86 100644 --- a/src/meshTools/PatchFunction1/UniformValueField/UniformValueField.H +++ b/src/meshTools/PatchFunction1/UniformValueField/UniformValueField.H @@ -128,7 +128,16 @@ public: // Evaluation //- Return UniformValueField value - virtual inline tmp> value(const scalar) const; + virtual inline tmp> value(const scalar x) const; + + //- Is value constant (i.e. independent of x) + virtual inline bool constant() const; + + //- Is value uniform (i.e. independent of coordinate) + virtual inline bool uniform() const + { + return PatchFunction1::uniform(); + } //- Integrate between two values virtual inline tmp> integrate diff --git a/src/meshTools/PatchFunction1/UniformValueField/UniformValueFieldI.H b/src/meshTools/PatchFunction1/UniformValueField/UniformValueFieldI.H index 480ea6d889..f4341ca844 100644 --- a/src/meshTools/PatchFunction1/UniformValueField/UniformValueFieldI.H +++ b/src/meshTools/PatchFunction1/UniformValueField/UniformValueFieldI.H @@ -25,9 +25,18 @@ License #include "UniformValueField.H" #include "SubField.H" +#include "Constant.H" // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +template +inline bool +Foam::PatchFunction1Types::UniformValueField::constant() const +{ + return uniformValuePtr_->type() == Function1Types::Constant::typeName; +} + + template inline Foam::tmp> Foam::PatchFunction1Types::UniformValueField::value diff --git a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/0.orig/cabin/omega b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/0.orig/cabin/omega index 989d77cf04..1442320b1c 100644 --- a/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/0.orig/cabin/omega +++ b/tutorials/heatTransfer/chtMultiRegionFoam/windshieldCondensation/0.orig/cabin/omega @@ -21,7 +21,6 @@ internalField uniform 0.2; boundaryField { - inlet { type uniformFixedValue; diff --git a/tutorials/multiphase/interPhaseChangeDyMFoam/propeller/0.orig/U b/tutorials/multiphase/interPhaseChangeDyMFoam/propeller/0.orig/U index aff8dd1982..7f90ff6f84 100644 --- a/tutorials/multiphase/interPhaseChangeDyMFoam/propeller/0.orig/U +++ b/tutorials/multiphase/interPhaseChangeDyMFoam/propeller/0.orig/U @@ -32,7 +32,6 @@ boundaryField (0.01 (0 -15 0)) (100 (0 -15 0)) ); - value $internalField; } outlet