diff --git a/src/OpenFOAM/primitives/Vector2D/Vector2D.H b/src/OpenFOAM/primitives/Vector2D/Vector2D.H index 9b67b6187c372da948280af0d211bb784e3b4689..23664464d3ace407d868ea7fb81d90ce7b5d620e 100644 --- a/src/OpenFOAM/primitives/Vector2D/Vector2D.H +++ b/src/OpenFOAM/primitives/Vector2D/Vector2D.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2018-2020 OpenCFD Ltd. + Copyright (C) 2018-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -116,13 +116,18 @@ public: //- Access to the vector y component inline Cmpt& y(); - //- Normalise the vector by its magnitude inline Vector2D& normalise(); - //- Perp dot product (dot product with perpendicular vector) inline scalar perp(const Vector2D& b) const; + + //- Return true if vector is within tol + inline bool isClose + ( + const Vector2D& b, + const scalar tol = 1e-10 + ) const; }; diff --git a/src/OpenFOAM/primitives/Vector2D/Vector2DI.H b/src/OpenFOAM/primitives/Vector2D/Vector2DI.H index b7387191cec2c29c3f57696d76535a2708bfbaab..46599dfc4875678a651476c550bc796fb48e20a4 100644 --- a/src/OpenFOAM/primitives/Vector2D/Vector2DI.H +++ b/src/OpenFOAM/primitives/Vector2D/Vector2DI.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2018-2020 OpenCFD Ltd. + Copyright (C) 2018-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -126,7 +126,18 @@ operator&(const Vector2D& v1, const Vector2D& v2) template inline scalar Vector2D::perp(const Vector2D& b) const { - return x()*b.y()-y()*b.x(); + return x()*b.y() - y()*b.x(); +} + + +template +inline bool Vector2D::isClose +( + const Vector2D& b, + const scalar tol +) const +{ + return (mag(x() - b.x()) < tol && mag(y() - b.y()) < tol); } diff --git a/src/functionObjects/field/mapFields/mapFields.H b/src/functionObjects/field/mapFields/mapFields.H index a699b313929deb1b952209faa67d6b963ea7d471..873ab0899b15ec9d595f495fadd0d50e0b9e77fa 100644 --- a/src/functionObjects/field/mapFields/mapFields.H +++ b/src/functionObjects/field/mapFields/mapFields.H @@ -98,7 +98,6 @@ Usage \verbatim nearestFaceAMI faceAreaWeightAMI - partialFaceAreaWeightAMI \endverbatim The inherited entries are elaborated in: diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C index 96ba959fa05c99d168da3d855d66c24e2865c0b8..7f6d4ea5406d924cfad6fa1397a10d1fe24a6ea7 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C @@ -1246,7 +1246,7 @@ void Foam::AMIInterpolation::write(Ostream& os) const if (reverseTarget_) { - os.writeEntry("flipNormals", reverseTarget_); + os.writeEntry("reverseTarget", reverseTarget_); } if (lowWeightCorrection_ > 0) diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H index 7a2259066e8c4d71fecf43dd240c3bdf7999fe65..f691d6ace3c9bb430352ee0ac0f5237702a36e96 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2017 OpenFOAM Foundation - Copyright (C) 2016-2020 OpenCFD Ltd. + Copyright (C) 2016-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -364,6 +364,9 @@ public: //- Access to the requireMatch flag inline bool setRequireMatch(const bool flag); + //- Return true if requireMatch and lowWeightCorrectionin active + inline bool mustMatchFaces() const; + //- Access to the reverseTarget flag inline bool reverseTarget() const; diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationI.H b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationI.H index 22823a23ec6d8d57f334b1731d8dba53d92506f9..1effda038534ba3eda4b9915dfbfcea305874db6 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationI.H +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationI.H @@ -6,7 +6,7 @@ \\/ M anipulation | ------------------------------------------------------------------------------- Copyright (C) 2011-2016 OpenFOAM Foundation - Copyright (C) 2016-2020 OpenCFD Ltd. + Copyright (C) 2016-2021 OpenCFD Ltd. ------------------------------------------------------------------------------- License This file is part of OpenFOAM. @@ -73,7 +73,7 @@ inline bool Foam::AMIInterpolation::distributed() const inline bool Foam::AMIInterpolation::requireMatch() const { - return requireMatch_ && lowWeightCorrection_ < 0; + return requireMatch_; } @@ -84,6 +84,12 @@ inline bool Foam::AMIInterpolation::setRequireMatch(const bool flag) } +inline bool Foam::AMIInterpolation::mustMatchFaces() const +{ + return requireMatch_ && !applyLowWeightCorrection(); +} + + inline bool Foam::AMIInterpolation::reverseTarget() const { return reverseTarget_; diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/advancingFrontAMI/advancingFrontAMI.C b/src/meshTools/AMIInterpolation/AMIInterpolation/advancingFrontAMI/advancingFrontAMI.C index dc41c132ea60a990f89c16e796022146944c596d..7c03cbed1cf488a860169f1ee7166837c548cf08 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/advancingFrontAMI/advancingFrontAMI.C +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/advancingFrontAMI/advancingFrontAMI.C @@ -55,7 +55,7 @@ void Foam::advancingFrontAMI::checkPatches() const } - if (conformal()) + if (requireMatch_) { const scalar maxBoundsError = 0.05; @@ -345,6 +345,27 @@ void Foam::advancingFrontAMI::triangulatePatch } +void Foam::advancingFrontAMI::nonConformalCorrection() +{ + if (!requireMatch_ && distributed()) + { + scalarList newTgtMagSf(std::move(tgtMagSf_)); + + // Assign default sizes. Override selected values with calculated + // values. This is to support ACMI where some of the target faces + // are never used (so never get sent over and hence never assigned + // to) + tgtMagSf_ = tgtPatch0().magFaceAreas(); + + for (const labelList& smap : this->extendedTgtMapPtr_->subMap()) + { + UIndirectList(tgtMagSf_, smap) = + UIndirectList(newTgtMagSf, smap); + } + } +} + + // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // Foam::advancingFrontAMI::advancingFrontAMI @@ -421,7 +442,8 @@ bool Foam::advancingFrontAMI::calculate { if (AMIInterpolation::calculate(srcPatch, tgtPatch, surfPtr)) { - // Create a representation of the target patch that covers the source patch + // Create a representation of the target patch that covers the source + // patch if (distributed()) { createExtendedTgtPatch(); @@ -454,10 +476,4 @@ bool Foam::advancingFrontAMI::calculate } -bool Foam::advancingFrontAMI::conformal() const -{ - return true; -} - - // ************************************************************************* // diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/advancingFrontAMI/advancingFrontAMI.H b/src/meshTools/AMIInterpolation/AMIInterpolation/advancingFrontAMI/advancingFrontAMI.H index 84031daa733f3e53df6d86d6bdaca30a458ee3db..07e08b68d8c683397c4d8712bf5a2ab2b7be0f43 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/advancingFrontAMI/advancingFrontAMI.H +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/advancingFrontAMI/advancingFrontAMI.H @@ -199,6 +199,9 @@ protected: List& magSf ) const; + //- Correction for non-conformal interpolations, e.g. for ACMI + virtual void nonConformalCorrection(); + public: @@ -249,10 +252,6 @@ public: //- Labels of faces that are not overlapped by any target faces // Note: this should be empty for correct functioning inline const labelList& srcNonOverlap() const; - - //- Flag to indicate that interpolation patches are conformal, i.e. - //- should fully cover each other - virtual bool conformal() const; }; diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/faceAreaWeightAMI/faceAreaWeightAMI.C b/src/meshTools/AMIInterpolation/AMIInterpolation/faceAreaWeightAMI/faceAreaWeightAMI.C index e6fbbb1816a1a9c7e970bafa02589d0082d0e4bf..395b1830f49d26b5268b3573950ff3b23c2d78b0 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/faceAreaWeightAMI/faceAreaWeightAMI.C +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/faceAreaWeightAMI/faceAreaWeightAMI.C @@ -115,6 +115,9 @@ void Foam::faceAreaWeightAMI::calcAddressing // Reset starting seed label startSeedi = 0; + // Should all faces be matched? + const bool mustMatch = mustMatchFaces(); + bool continueWalk = true; DynamicList