diff --git a/src/meshTools/PatchFunction1/MappedFile/MappedFile.C b/src/meshTools/PatchFunction1/MappedFile/MappedFile.C index 3a1b28f19e910e0598f87448278fd03364d835e5..787cde62b5eb0533f09136ae5a96fc1bcd8204f2 100644 --- a/src/meshTools/PatchFunction1/MappedFile/MappedFile.C +++ b/src/meshTools/PatchFunction1/MappedFile/MappedFile.C @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2020 OpenCFD Ltd. + Copyright (C) 2018-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -175,8 +175,13 @@ void Foam::PatchFunction1Types::MappedFile<Type>::autoMap if (startSampledValues_.size()) { startSampledValues_.autoMap(mapper); + } + + if (endSampledValues_.size()) + { endSampledValues_.autoMap(mapper); } + // Clear interpolator mapperPtr_.clear(); startSampleTime_ = -1; @@ -196,8 +201,17 @@ void Foam::PatchFunction1Types::MappedFile<Type>::rmap const PatchFunction1Types::MappedFile<Type>& tiptf = refCast<const PatchFunction1Types::MappedFile<Type>>(pf1); - startSampledValues_.rmap(tiptf.startSampledValues_, addr); - endSampledValues_.rmap(tiptf.endSampledValues_, addr); + if (tiptf.startSampledValues_.size()) + { + startSampledValues_.setSize(this->size()); + startSampledValues_.rmap(tiptf.startSampledValues_, addr); + } + + if (tiptf.endSampledValues_.size()) + { + endSampledValues_.setSize(this->size()); + endSampledValues_.rmap(tiptf.endSampledValues_, addr); + } // Clear interpolator mapperPtr_.clear(); @@ -584,27 +598,11 @@ Foam::PatchFunction1Types::MappedFile<Type>::integrate template<class Type> -void Foam::PatchFunction1Types::MappedFile<Type>::writeData +void Foam::PatchFunction1Types::MappedFile<Type>::writeEntries ( Ostream& os ) const { - PatchFunction1<Type>::writeData(os); - - // Check if field name explicitly provided - // (e.g. through timeVaryingMapped bc) - if (dictConstructed_) - { - os.writeEntry(this->name(), type()); - - os.writeEntryIfDifferent - ( - "fieldTable", - this->name(), - fieldTableName_ - ); - } - if (setAverage_) { os.writeEntry("setAverage", setAverage_); @@ -628,4 +626,36 @@ void Foam::PatchFunction1Types::MappedFile<Type>::writeData } +template<class Type> +void Foam::PatchFunction1Types::MappedFile<Type>::writeData +( + Ostream& os +) const +{ + PatchFunction1<Type>::writeData(os); + + // Check if field name explicitly provided + // (e.g. through timeVaryingMapped bc) + if (dictConstructed_) + { + os.writeEntry(this->name(), type()); + + os.writeEntryIfDifferent + ( + "fieldTable", + this->name(), + fieldTableName_ + ); + + os.beginBlock(word(this->name() + "Coeffs")); + writeEntries(os); + os.endBlock(); + } + else + { + writeEntries(os); + } +} + + // ************************************************************************* // diff --git a/src/meshTools/PatchFunction1/MappedFile/MappedFile.H b/src/meshTools/PatchFunction1/MappedFile/MappedFile.H index 79adeb448ec775ac84130068b289aec928d255f1..4ac1fc917f8d88b3bcf8284c546802db3909b31a 100644 --- a/src/meshTools/PatchFunction1/MappedFile/MappedFile.H +++ b/src/meshTools/PatchFunction1/MappedFile/MappedFile.H @@ -5,7 +5,7 @@ \\ / A nd | www.openfoam.com \\/ M anipulation | ------------------------------------------------------------------------------- - Copyright (C) 2018-2020 OpenCFD Ltd. + Copyright (C) 2018-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -27,19 +27,34 @@ Class Foam::PatchFunction1Types::MappedFile Description - Patch value mapping from file + Patch value mapping from a set of values stored in a file and + a set of unstructured points using the following directory structure: + + \verbatim + constant/boundaryData/\<patchName\>/points + constant/boundaryData/\<patchName\>/\<time\>/\<field\> + \endverbatim Options: \table - Property | Description | Required | Default - mapMethod | (nearest/planarInterpolation) | no | planarInterpolation - offset | Time-varying offset values to interpolated data | no | - fieldTable | Name of field data table | no | field-name - points | The name of the points file | no | points - perturb | Perturbation fraction of bounding box | no | 1e-5 - setAverage | adjust mapped field to maintain average value | no | false + Property | Description | Type | Reqd | Deflt + mapMethod | Mapping method | word | no <!-- + --> | planarInterpolation + offset | Time-varying offset values to interpolated data <!-- + --> | Function1\<Type\> | no | - + fieldTable | Name of field data table | word | no | field-name + points | Name of the points file | word | no | points + perturb | Perturbation fraction of bounding box | scalar | no | 1e-5 + setAverage | Adjust mapped field to maintain average value <!-- + --> | scalar | no | false \endtable + Options for the \c mapMethod entry: + \verbatim + nearest | Use nearest points only (avoids triangulation) + planarInterpolation | Interpolation using 2D Delaunay triangulation + \endverbatim + SourceFiles MappedFile.C @@ -229,6 +244,9 @@ public: // I-O + //- Write coefficient entries in dictionary format + void writeEntries(Ostream& os) const; + //- Write in dictionary format virtual void writeData(Ostream& os) const; };