From 5e8593c1716490a4e74fe8136c248257123aa255 Mon Sep 17 00:00:00 2001 From: Henry Weller Date: Tue, 17 Jul 2018 23:06:45 +0100 Subject: [PATCH 1/2] wmake/rules/linux.*Gcc: added -fuse-ld=bfd to avoid problems on systems which use the gold linker by default. Resolves request https://bugs.openfoam.org/view.php?id=3006 --- wmake/rules/linux64Gcc/c | 4 ++-- wmake/rules/linux64Gcc/c++ | 4 ++-- wmake/rules/linux64GccKNL/c | 4 ++-- wmake/rules/linux64GccKNL/c++ | 4 ++-- wmake/rules/linuxARM7Gcc/c | 4 ++-- wmake/rules/linuxARM7Gcc/c++ | 4 ++-- wmake/rules/linuxGcc/c | 4 ++-- wmake/rules/linuxGcc/c++ | 4 ++-- wmake/rules/linuxIA64Gcc/c | 4 ++-- wmake/rules/linuxIA64Gcc/c++ | 4 ++-- wmake/rules/linuxPPC64Gcc/c | 4 ++-- wmake/rules/linuxPPC64Gcc/c++ | 4 ++-- wmake/rules/linuxPPC64leGcc/c | 4 ++-- wmake/rules/linuxPPC64leGcc/c++ | 4 ++-- 14 files changed, 28 insertions(+), 28 deletions(-) diff --git a/wmake/rules/linux64Gcc/c b/wmake/rules/linux64Gcc/c index 1097b3a594..5ebc53574d 100644 --- a/wmake/rules/linux64Gcc/c +++ b/wmake/rules/linux64Gcc/c @@ -12,5 +12,5 @@ ctoo = $(WM_SCHEDULER) $(cc) $(cFLAGS) -c $< -o $@ LINK_LIBS = $(cDBUG) -LINKLIBSO = $(cc) -shared -LINKEXE = $(cc) -Xlinker --add-needed -Xlinker -z -Xlinker nodefs +LINKLIBSO = $(cc) -fuse-ld=bfd -shared +LINKEXE = $(cc) -fuse-ld=bfd -Xlinker --add-needed -Xlinker -z -Xlinker nodefs diff --git a/wmake/rules/linux64Gcc/c++ b/wmake/rules/linux64Gcc/c++ index 48bd03b3b9..ca33d452d2 100644 --- a/wmake/rules/linux64Gcc/c++ +++ b/wmake/rules/linux64Gcc/c++ @@ -21,5 +21,5 @@ cpptoo = $(Ctoo) LINK_LIBS = $(c++DBUG) -LINKLIBSO = $(CC) $(c++FLAGS) -shared -Xlinker --add-needed -Xlinker --no-as-needed -LINKEXE = $(CC) $(c++FLAGS) -Xlinker --add-needed -Xlinker --no-as-needed +LINKLIBSO = $(CC) $(c++FLAGS) -fuse-ld=bfd -shared -Xlinker --add-needed -Xlinker --no-as-needed +LINKEXE = $(CC) $(c++FLAGS) -fuse-ld=bfd -Xlinker --add-needed -Xlinker --no-as-needed diff --git a/wmake/rules/linux64GccKNL/c b/wmake/rules/linux64GccKNL/c index a1cd9d6613..8a3dcd9580 100644 --- a/wmake/rules/linux64GccKNL/c +++ b/wmake/rules/linux64GccKNL/c @@ -12,5 +12,5 @@ ctoo = $(WM_SCHEDULER) $(cc) $(cFLAGS) -c $< -o $@ LINK_LIBS = $(cDBUG) -LINKLIBSO = $(cc) -shared -LINKEXE = $(cc) -Xlinker --add-needed -Xlinker -z -Xlinker nodefs +LINKLIBSO = $(cc) -fuse-ld=bfd -shared +LINKEXE = $(cc) -fuse-ld=bfd -Xlinker --add-needed -Xlinker -z -Xlinker nodefs diff --git a/wmake/rules/linux64GccKNL/c++ b/wmake/rules/linux64GccKNL/c++ index caeee4f5cc..cb308e8107 100644 --- a/wmake/rules/linux64GccKNL/c++ +++ b/wmake/rules/linux64GccKNL/c++ @@ -21,5 +21,5 @@ cpptoo = $(Ctoo) LINK_LIBS = $(c++DBUG) -LINKLIBSO = $(CC) $(c++FLAGS) -shared -Xlinker --add-needed -Xlinker --no-as-needed -LINKEXE = $(CC) $(c++FLAGS) -Xlinker --add-needed -Xlinker --no-as-needed +LINKLIBSO = $(CC) $(c++FLAGS) -fuse-ld=bfd -shared -Xlinker --add-needed -Xlinker --no-as-needed +LINKEXE = $(CC) $(c++FLAGS) -fuse-ld=bfd -Xlinker --add-needed -Xlinker --no-as-needed diff --git a/wmake/rules/linuxARM7Gcc/c b/wmake/rules/linuxARM7Gcc/c index dfae4adda0..91d6fda4de 100644 --- a/wmake/rules/linuxARM7Gcc/c +++ b/wmake/rules/linuxARM7Gcc/c @@ -12,5 +12,5 @@ ctoo = $(WM_SCHEDULER) $(cc) $(cFLAGS) -c $< -o $@ LINK_LIBS = $(cDBUG) -LINKLIBSO = $(cc) -shared -LINKEXE = $(cc) -Xlinker --add-needed -Xlinker -z -Xlinker nodefs +LINKLIBSO = $(cc) -fuse-ld=bfd -shared +LINKEXE = $(cc) -fuse-ld=bfd -Xlinker --add-needed -Xlinker -z -Xlinker nodefs diff --git a/wmake/rules/linuxARM7Gcc/c++ b/wmake/rules/linuxARM7Gcc/c++ index bc5ccb42bf..d9554221c5 100644 --- a/wmake/rules/linuxARM7Gcc/c++ +++ b/wmake/rules/linuxARM7Gcc/c++ @@ -21,5 +21,5 @@ cpptoo = $(Ctoo) LINK_LIBS = $(c++DBUG) -LINKLIBSO = $(CC) $(c++FLAGS) -shared -Xlinker --add-needed -Xlinker --no-as-needed -LINKEXE = $(CC) $(c++FLAGS) -Xlinker --add-needed -Xlinker --no-as-needed +LINKLIBSO = $(CC) $(c++FLAGS) -fuse-ld=bfd -shared -Xlinker --add-needed -Xlinker --no-as-needed +LINKEXE = $(CC) $(c++FLAGS) -fuse-ld=bfd -Xlinker --add-needed -Xlinker --no-as-needed diff --git a/wmake/rules/linuxGcc/c b/wmake/rules/linuxGcc/c index 8eddde0490..64cc4bf9d3 100644 --- a/wmake/rules/linuxGcc/c +++ b/wmake/rules/linuxGcc/c @@ -12,5 +12,5 @@ ctoo = $(WM_SCHEDULER) $(cc) $(cFLAGS) -c $< -o $@ LINK_LIBS = $(cDBUG) -LINKLIBSO = $(cc) -shared -LINKEXE = $(cc) -Xlinker --add-needed -Xlinker -z -Xlinker nodefs +LINKLIBSO = $(cc) -fuse-ld=bfd -shared +LINKEXE = $(cc) -fuse-ld=bfd -Xlinker --add-needed -Xlinker -z -Xlinker nodefs diff --git a/wmake/rules/linuxGcc/c++ b/wmake/rules/linuxGcc/c++ index 94bf753197..90950e7a01 100644 --- a/wmake/rules/linuxGcc/c++ +++ b/wmake/rules/linuxGcc/c++ @@ -21,5 +21,5 @@ cpptoo = $(Ctoo) LINK_LIBS = $(c++DBUG) -LINKLIBSO = $(CC) $(c++FLAGS) -shared -Xlinker --add-needed -Xlinker --no-as-needed -LINKEXE = $(CC) $(c++FLAGS) -Xlinker --add-needed -Xlinker --no-as-needed +LINKLIBSO = $(CC) $(c++FLAGS) -fuse-ld=bfd -shared -Xlinker --add-needed -Xlinker --no-as-needed +LINKEXE = $(CC) $(c++FLAGS) -fuse-ld=bfd -Xlinker --add-needed -Xlinker --no-as-needed diff --git a/wmake/rules/linuxIA64Gcc/c b/wmake/rules/linuxIA64Gcc/c index dfae4adda0..91d6fda4de 100644 --- a/wmake/rules/linuxIA64Gcc/c +++ b/wmake/rules/linuxIA64Gcc/c @@ -12,5 +12,5 @@ ctoo = $(WM_SCHEDULER) $(cc) $(cFLAGS) -c $< -o $@ LINK_LIBS = $(cDBUG) -LINKLIBSO = $(cc) -shared -LINKEXE = $(cc) -Xlinker --add-needed -Xlinker -z -Xlinker nodefs +LINKLIBSO = $(cc) -fuse-ld=bfd -shared +LINKEXE = $(cc) -fuse-ld=bfd -Xlinker --add-needed -Xlinker -z -Xlinker nodefs diff --git a/wmake/rules/linuxIA64Gcc/c++ b/wmake/rules/linuxIA64Gcc/c++ index f91f1d8270..13e8a72328 100644 --- a/wmake/rules/linuxIA64Gcc/c++ +++ b/wmake/rules/linuxIA64Gcc/c++ @@ -21,5 +21,5 @@ cpptoo = $(Ctoo) LINK_LIBS = $(c++DBUG) -LINKLIBSO = $(CC) $(c++FLAGS) -shared -LINKEXE = $(CC) $(c++FLAGS) -Xlinker --add-needed +LINKLIBSO = $(CC) $(c++FLAGS) -fuse-ld=bfd -shared +LINKEXE = $(CC) $(c++FLAGS) -fuse-ld=bfd -Xlinker --add-needed diff --git a/wmake/rules/linuxPPC64Gcc/c b/wmake/rules/linuxPPC64Gcc/c index f973417062..aa30565fb2 100644 --- a/wmake/rules/linuxPPC64Gcc/c +++ b/wmake/rules/linuxPPC64Gcc/c @@ -12,5 +12,5 @@ ctoo = $(WM_SCHEDULER) $(cc) $(cFLAGS) -c $< -o $@ LINK_LIBS = $(cDBUG) -LINKLIBSO = $(cc) -shared -LINKEXE = $(cc) -Xlinker --add-needed -Xlinker -z -Xlinker nodefs +LINKLIBSO = $(cc) -fuse-ld=bfd -shared +LINKEXE = $(cc) -fuse-ld=bfd -Xlinker --add-needed -Xlinker -z -Xlinker nodefs diff --git a/wmake/rules/linuxPPC64Gcc/c++ b/wmake/rules/linuxPPC64Gcc/c++ index 35d902a04c..ba8150a8a2 100644 --- a/wmake/rules/linuxPPC64Gcc/c++ +++ b/wmake/rules/linuxPPC64Gcc/c++ @@ -21,5 +21,5 @@ cpptoo = $(Ctoo) LINK_LIBS = $(c++DBUG) -LINKLIBSO = $(CC) $(c++FLAGS) -shared -LINKEXE = $(CC) $(c++FLAGS) -Xlinker --add-needed +LINKLIBSO = $(CC) $(c++FLAGS) -fuse-ld=bfd -shared +LINKEXE = $(CC) $(c++FLAGS) -fuse-ld=bfd -Xlinker --add-needed diff --git a/wmake/rules/linuxPPC64leGcc/c b/wmake/rules/linuxPPC64leGcc/c index c5e3c73eba..3d33163e0c 100644 --- a/wmake/rules/linuxPPC64leGcc/c +++ b/wmake/rules/linuxPPC64leGcc/c @@ -12,5 +12,5 @@ ctoo = $(WM_SCHEDULER) $(cc) $(cFLAGS) -c $< -o $@ LINK_LIBS = $(cDBUG) -LINKLIBSO = $(cc) -shared -LINKEXE = $(cc) -Xlinker --add-needed -Xlinker -z -Xlinker nodefs +LINKLIBSO = $(cc) -fuse-ld=bfd -shared +LINKEXE = $(cc) -fuse-ld=bfd -Xlinker --add-needed -Xlinker -z -Xlinker nodefs diff --git a/wmake/rules/linuxPPC64leGcc/c++ b/wmake/rules/linuxPPC64leGcc/c++ index 69b4f5f981..9611ea2e74 100644 --- a/wmake/rules/linuxPPC64leGcc/c++ +++ b/wmake/rules/linuxPPC64leGcc/c++ @@ -21,5 +21,5 @@ cpptoo = $(Ctoo) LINK_LIBS = $(c++DBUG) -LINKLIBSO = $(CC) $(c++FLAGS) -shared -Xlinker --add-needed -Xlinker --no-as-needed -LINKEXE = $(CC) $(c++FLAGS) -Xlinker --add-needed -Xlinker --no-as-needed +LINKLIBSO = $(CC) $(c++FLAGS) -fuse-ld=bfd -shared -Xlinker --add-needed -Xlinker --no-as-needed +LINKEXE = $(CC) $(c++FLAGS) -fuse-ld=bfd -Xlinker --add-needed -Xlinker --no-as-needed From aea61ccdbf9f8c74186c9817604844bccddce9c1 Mon Sep 17 00:00:00 2001 From: Will Bainbridge Date: Wed, 18 Jul 2018 14:49:11 +0100 Subject: [PATCH 2/2] AMI: Un-templated the interpolation and method classes AMI interpolation is only ever constructed between sets of primitive patches, so templating on the patch type is unnecessary. Templating in this instance is undesirable; it makes type type/debug/selection system more complex and increases the number and compilation times of files which need recompiling when code is modified. --- .../constraint/cyclicACMI/cyclicACMIFvPatch.H | 4 +- .../constraint/cyclicAMI/cyclicAMIFvPatch.H | 2 +- .../regionCoupled/regionCoupledBaseFvPatch.H | 2 +- .../AMIInterpolation/AMIInterpolation.C | 478 +++--------------- .../AMIInterpolation/AMIInterpolation.H | 115 ++--- .../AMIInterpolation/AMIInterpolationI.H | 69 +-- .../AMIInterpolation/AMIInterpolationName.C | 36 -- .../AMIInterpolationParallelOps.C | 29 +- .../AMIInterpolationTemplates.C | 336 ++++++++++++ .../AMIMethod/AMIMethod/AMIMethod.C | 45 +- .../AMIMethod/AMIMethod/AMIMethod.H | 76 +-- .../AMIMethod/AMIMethod/AMIMethodI.H | 4 +- .../AMIMethod/AMIMethod/AMIMethodNew.C | 12 +- .../AMIMethod/directAMI/directAMI.C | 31 +- .../AMIMethod/directAMI/directAMI.H | 13 +- .../faceAreaWeightAMI/faceAreaWeightAMI.C | 44 +- .../faceAreaWeightAMI/faceAreaWeightAMI.H | 13 +- .../AMIMethod/mapNearestAMI/mapNearestAMI.C | 38 +- .../AMIMethod/mapNearestAMI/mapNearestAMI.H | 17 +- .../partialFaceAreaWeightAMI.C | 37 +- .../partialFaceAreaWeightAMI.H | 13 +- .../sweptFaceAreaWeightAMI.C | 51 +- .../sweptFaceAreaWeightAMI.H | 11 +- .../AMIPatchToPatchInterpolation.C | 49 -- .../AMIPatchToPatchInterpolation.H | 50 -- .../cyclicAMIGAMGInterface.C | 2 +- .../cyclicAMIGAMGInterface.H | 4 +- .../cyclicACMIPolyPatch/cyclicACMIPolyPatch.C | 6 +- .../cyclicACMIPolyPatch/cyclicACMIPolyPatch.H | 2 +- .../cyclicAMILduInterface.H | 5 +- .../cyclicAMIPolyPatch/cyclicAMIPolyPatch.C | 13 +- .../cyclicAMIPolyPatch/cyclicAMIPolyPatch.H | 16 +- .../cyclicRepeatAMIPolyPatch.C | 28 +- .../cyclicRepeatAMIPolyPatch.H | 2 +- src/meshTools/Make/files | 27 +- .../mappedPolyPatch/mappedPatchBase.C | 4 +- .../mappedPolyPatch/mappedPatchBase.H | 6 +- .../mappedPolyPatch/mappedPatchBaseI.H | 2 +- .../regionCoupledBaseGAMGInterface.C | 2 +- .../regionCoupledBaseGAMGInterface.H | 4 +- .../regionCoupledLduInterface.H | 4 +- .../regionCoupledBase.C | 6 +- .../regionCoupledBase.H | 6 +- .../regionModel/regionModel/regionModel.C | 12 +- .../regionModel/regionModel/regionModel.H | 5 +- .../regionModel/regionModelTemplates.C | 6 +- src/sampling/meshToMesh/meshToMesh.C | 36 +- src/sampling/meshToMesh/meshToMesh.H | 37 +- src/sampling/meshToMesh/meshToMeshI.H | 2 +- src/sampling/meshToMesh/meshToMeshTemplates.C | 8 +- 50 files changed, 772 insertions(+), 1048 deletions(-) delete mode 100644 src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationName.C create mode 100644 src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationTemplates.C delete mode 100644 src/meshTools/AMIInterpolation/AMIInterpolation/AMIPatchToPatchInterpolation.C delete mode 100644 src/meshTools/AMIInterpolation/AMIInterpolation/AMIPatchToPatchInterpolation.H diff --git a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicACMI/cyclicACMIFvPatch.H b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicACMI/cyclicACMIFvPatch.H index 7546ed6a21..e78095f1b5 100644 --- a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicACMI/cyclicACMIFvPatch.H +++ b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicACMI/cyclicACMIFvPatch.H @@ -87,9 +87,9 @@ public: // Access //- Return a reference to the AMI interpolators - virtual const PtrList& AMIs() const + virtual const PtrList& AMIs() const { - const PtrList& AMIs = + const PtrList& AMIs = cyclicAMIFvPatch::AMIs(); updateAreas(); diff --git a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.H b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.H index 6869ebf7b1..26b23f65bc 100644 --- a/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.H +++ b/src/finiteVolume/fvMesh/fvPatches/constraint/cyclicAMI/cyclicAMIFvPatch.H @@ -122,7 +122,7 @@ public: } //- Return a reference to the AMI interpolators - virtual const PtrList& AMIs() const + virtual const PtrList& AMIs() const { return cyclicAMIPolyPatch_.AMIs(); } diff --git a/src/finiteVolume/fvMesh/fvPatches/derived/regionCoupled/regionCoupledBaseFvPatch.H b/src/finiteVolume/fvMesh/fvPatches/derived/regionCoupled/regionCoupledBaseFvPatch.H index 89409db1ba..7f466a413c 100644 --- a/src/finiteVolume/fvMesh/fvPatches/derived/regionCoupled/regionCoupledBaseFvPatch.H +++ b/src/finiteVolume/fvMesh/fvPatches/derived/regionCoupled/regionCoupledBaseFvPatch.H @@ -139,7 +139,7 @@ public: } //- Return a reference to the AMI interpolator - virtual const AMIPatchToPatchInterpolation& AMI() const + virtual const AMIInterpolation& AMI() const { return regionCoupledBase_.AMI(); } diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C index ba6fc6e3f0..bbdfb1088c 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.C @@ -31,9 +31,15 @@ License // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // -template -Foam::word -Foam::AMIInterpolation::interpolationMethodToWord +namespace Foam +{ + defineTypeNameAndDebug(AMIInterpolation, 0); +} + + +// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * // + +Foam::word Foam::AMIInterpolation::interpolationMethodToWord ( const interpolationMethod& im ) @@ -79,12 +85,8 @@ Foam::AMIInterpolation::interpolationMethodToWord } -template -typename Foam::AMIInterpolation::interpolationMethod -Foam::AMIInterpolation::wordTointerpolationMethod -( - const word& im -) +typename Foam::AMIInterpolation::interpolationMethod +Foam::AMIInterpolation::wordTointerpolationMethod(const word& im) { interpolationMethod method = imDirect; @@ -134,12 +136,9 @@ Foam::AMIInterpolation::wordTointerpolationMethod } -template -template -Foam::tmp -Foam::AMIInterpolation::patchMagSf +Foam::tmp Foam::AMIInterpolation::patchMagSf ( - const Patch& patch, + const primitivePatch& patch, const faceAreaIntersect::triangulationMode triMode ) { @@ -178,8 +177,7 @@ Foam::AMIInterpolation::patchMagSf // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -template -void Foam::AMIInterpolation::projectPointsToSurface +void Foam::AMIInterpolation::projectPointsToSurface ( const searchableSurface& surf, pointField& pts @@ -220,8 +218,7 @@ void Foam::AMIInterpolation::projectPointsToSurface } -template -void Foam::AMIInterpolation::sumWeights +void Foam::AMIInterpolation::sumWeights ( const scalarListList& wght, scalarField& wghtSum @@ -237,8 +234,7 @@ void Foam::AMIInterpolation::sumWeights } -template -void Foam::AMIInterpolation::sumWeights +void Foam::AMIInterpolation::sumWeights ( const UPtrList& wghts, scalarField& wghtSum @@ -260,8 +256,7 @@ void Foam::AMIInterpolation::sumWeights } -template -void Foam::AMIInterpolation::reportSumWeights +void Foam::AMIInterpolation::reportSumWeights ( const scalarField& patchAreas, const word& patchName, @@ -298,8 +293,7 @@ void Foam::AMIInterpolation::reportSumWeights } -template -void Foam::AMIInterpolation::normaliseWeights +void Foam::AMIInterpolation::normaliseWeights ( scalarListList& wght, const scalarField& wghtSum @@ -317,8 +311,7 @@ void Foam::AMIInterpolation::normaliseWeights } -template -void Foam::AMIInterpolation::normaliseWeights +void Foam::AMIInterpolation::normaliseWeights ( UPtrList& wghts, const scalarField& wghtSum @@ -339,8 +332,7 @@ void Foam::AMIInterpolation::normaliseWeights } -template -void Foam::AMIInterpolation::agglomerate +void Foam::AMIInterpolation::agglomerate ( const autoPtr& targetMapPtr, const scalarField& fineSrcMagSf, @@ -594,11 +586,10 @@ void Foam::AMIInterpolation::agglomerate } -template -void Foam::AMIInterpolation::constructFromSurface +void Foam::AMIInterpolation::constructFromSurface ( - const SourcePatch& srcPatch, - const TargetPatch& tgtPatch, + const primitivePatch& srcPatch, + const primitivePatch& tgtPatch, const autoPtr& surfPtr, const bool report ) @@ -607,7 +598,7 @@ void Foam::AMIInterpolation::constructFromSurface { // Create new patches for source and target pointField srcPoints = srcPatch.points(); - SourcePatch srcPatch0 + primitivePatch srcPatch0 ( SubList ( @@ -628,7 +619,7 @@ void Foam::AMIInterpolation::constructFromSurface } pointField tgtPoints = tgtPatch.points(); - TargetPatch tgtPatch0 + primitivePatch tgtPatch0 ( SubList ( @@ -666,11 +657,10 @@ void Foam::AMIInterpolation::constructFromSurface // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // -template -Foam::AMIInterpolation::AMIInterpolation +Foam::AMIInterpolation::AMIInterpolation ( - const SourcePatch& srcPatch, - const TargetPatch& tgtPatch, + const primitivePatch& srcPatch, + const primitivePatch& tgtPatch, const faceAreaIntersect::triangulationMode& triMode, const bool requireMatch, const interpolationMethod& method, @@ -698,11 +688,10 @@ Foam::AMIInterpolation::AMIInterpolation } -template -Foam::AMIInterpolation::AMIInterpolation +Foam::AMIInterpolation::AMIInterpolation ( - const SourcePatch& srcPatch, - const TargetPatch& tgtPatch, + const primitivePatch& srcPatch, + const primitivePatch& tgtPatch, const faceAreaIntersect::triangulationMode& triMode, const bool requireMatch, const word& methodName, @@ -730,11 +719,10 @@ Foam::AMIInterpolation::AMIInterpolation } -template -Foam::AMIInterpolation::AMIInterpolation +Foam::AMIInterpolation::AMIInterpolation ( - const SourcePatch& srcPatch, - const TargetPatch& tgtPatch, + const primitivePatch& srcPatch, + const primitivePatch& tgtPatch, const autoPtr& surfPtr, const faceAreaIntersect::triangulationMode& triMode, const bool requireMatch, @@ -763,11 +751,10 @@ Foam::AMIInterpolation::AMIInterpolation } -template -Foam::AMIInterpolation::AMIInterpolation +Foam::AMIInterpolation::AMIInterpolation ( - const SourcePatch& srcPatch, - const TargetPatch& tgtPatch, + const primitivePatch& srcPatch, + const primitivePatch& tgtPatch, const autoPtr& surfPtr, const faceAreaIntersect::triangulationMode& triMode, const bool requireMatch, @@ -796,10 +783,9 @@ Foam::AMIInterpolation::AMIInterpolation } -template -Foam::AMIInterpolation::AMIInterpolation +Foam::AMIInterpolation::AMIInterpolation ( - const AMIInterpolation& fineAMI, + const AMIInterpolation& fineAMI, const labelList& sourceRestrictAddressing, const labelList& targetRestrictAddressing, const bool report @@ -911,18 +897,16 @@ Foam::AMIInterpolation::AMIInterpolation // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // -template -Foam::AMIInterpolation::~AMIInterpolation() +Foam::AMIInterpolation::~AMIInterpolation() {} // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // -template -void Foam::AMIInterpolation::update +void Foam::AMIInterpolation::update ( - const SourcePatch& srcPatch, - const TargetPatch& tgtPatch, + const primitivePatch& srcPatch, + const primitivePatch& tgtPatch, const bool report ) { @@ -987,7 +971,7 @@ void Foam::AMIInterpolation::update tgtFaceIDs ); - TargetPatch + primitivePatch newTgtPatch ( SubList @@ -1000,9 +984,9 @@ void Foam::AMIInterpolation::update scalarField newTgtMagSf(patchMagSf(newTgtPatch, triMode_)); // Calculate AMI interpolation - autoPtr> AMIPtr + autoPtr AMIPtr ( - AMIMethod::New + AMIMethod::New ( methodName_, srcPatch, @@ -1099,9 +1083,9 @@ void Foam::AMIInterpolation::update else { // Calculate AMI interpolation - autoPtr> AMIPtr + autoPtr AMIPtr ( - AMIMethod::New + AMIMethod::New ( methodName_, srcPatch, @@ -1136,7 +1120,8 @@ void Foam::AMIInterpolation::update if (debug) { - Info<< "AMIInterpolation : Constructed addressing and weights" << nl + Info<< "AMIIPatchToPatchnterpolation :" + << "Constructed addressing and weights" << nl << " triMode :" << faceAreaIntersect::triangulationModeNames_[triMode_] << nl << " singlePatchProc:" << singlePatchProc_ << nl @@ -1147,22 +1132,14 @@ void Foam::AMIInterpolation::update } -template -void Foam::AMIInterpolation::sumWeights -( - AMIInterpolation& AMI -) +void Foam::AMIInterpolation::sumWeights(AMIInterpolation& AMI) { sumWeights(AMI.srcWeights_, AMI.srcWeightsSum_); sumWeights(AMI.tgtWeights_, AMI.tgtWeightsSum_); } -template -void Foam::AMIInterpolation::sumWeights -( - PtrList>& AMIs -) +void Foam::AMIInterpolation::sumWeights(PtrList& AMIs) { UPtrList srcWeights(AMIs.size()); forAll(AMIs, i) @@ -1192,11 +1169,7 @@ void Foam::AMIInterpolation::sumWeights } -template -void Foam::AMIInterpolation::reportSumWeights -( - AMIInterpolation& AMI -) +void Foam::AMIInterpolation::reportSumWeights(AMIInterpolation& AMI) { reportSumWeights ( @@ -1216,22 +1189,14 @@ void Foam::AMIInterpolation::reportSumWeights } -template -void Foam::AMIInterpolation::normaliseWeights -( - AMIInterpolation& AMI -) +void Foam::AMIInterpolation::normaliseWeights(AMIInterpolation& AMI) { normaliseWeights(AMI.srcWeights_, AMI.srcWeightsSum_); normaliseWeights(AMI.tgtWeights_, AMI.tgtWeightsSum_); } -template -void Foam::AMIInterpolation::normaliseWeights -( - UPtrList>& AMIs -) +void Foam::AMIInterpolation::normaliseWeights(UPtrList& AMIs) { UPtrList srcWeights(AMIs.size()); forAll(AMIs, i) @@ -1251,323 +1216,10 @@ void Foam::AMIInterpolation::normaliseWeights } -template -template -void Foam::AMIInterpolation::interpolateToTarget +Foam::label Foam::AMIInterpolation::srcPointFace ( - const UList& fld, - const CombineOp& cop, - List& result, - const UList& defaultValues -) const -{ - if (fld.size() != srcAddress_.size()) - { - FatalErrorInFunction - << "Supplied field size is not equal to source patch size" << nl - << " source patch = " << srcAddress_.size() << nl - << " target patch = " << tgtAddress_.size() << nl - << " supplied field = " << fld.size() - << abort(FatalError); - } - - if (lowWeightCorrection_ > 0) - { - if (defaultValues.size() != tgtAddress_.size()) - { - FatalErrorInFunction - << "Employing default values when sum of weights falls below " - << lowWeightCorrection_ - << " but supplied default field size is not equal to target " - << "patch size" << nl - << " default values = " << defaultValues.size() << nl - << " target patch = " << tgtAddress_.size() << nl - << abort(FatalError); - } - } - - result.setSize(tgtAddress_.size()); - - if (singlePatchProc_ == -1) - { - const mapDistribute& map = srcMapPtr_(); - - List work(fld); - map.distribute(work); - - forAll(result, facei) - { - if (tgtWeightsSum_[facei] < lowWeightCorrection_) - { - result[facei] = defaultValues[facei]; - } - else - { - const labelList& faces = tgtAddress_[facei]; - const scalarList& weights = tgtWeights_[facei]; - - forAll(faces, i) - { - cop(result[facei], facei, work[faces[i]], weights[i]); - } - } - } - } - else - { - forAll(result, facei) - { - if (tgtWeightsSum_[facei] < lowWeightCorrection_) - { - result[facei] = defaultValues[facei]; - } - else - { - const labelList& faces = tgtAddress_[facei]; - const scalarList& weights = tgtWeights_[facei]; - - forAll(faces, i) - { - cop(result[facei], facei, fld[faces[i]], weights[i]); - } - } - } - } -} - - -template -template -void Foam::AMIInterpolation::interpolateToSource -( - const UList& fld, - const CombineOp& cop, - List& result, - const UList& defaultValues -) const -{ - if (fld.size() != tgtAddress_.size()) - { - FatalErrorInFunction - << "Supplied field size is not equal to target patch size" << nl - << " source patch = " << srcAddress_.size() << nl - << " target patch = " << tgtAddress_.size() << nl - << " supplied field = " << fld.size() - << abort(FatalError); - } - - if (lowWeightCorrection_ > 0) - { - if (defaultValues.size() != srcAddress_.size()) - { - FatalErrorInFunction - << "Employing default values when sum of weights falls below " - << lowWeightCorrection_ - << " but supplied default field size is not equal to target " - << "patch size" << nl - << " default values = " << defaultValues.size() << nl - << " source patch = " << srcAddress_.size() << nl - << abort(FatalError); - } - } - - result.setSize(srcAddress_.size()); - - if (singlePatchProc_ == -1) - { - const mapDistribute& map = tgtMapPtr_(); - - List work(fld); - map.distribute(work); - - forAll(result, facei) - { - if (srcWeightsSum_[facei] < lowWeightCorrection_) - { - result[facei] = defaultValues[facei]; - } - else - { - const labelList& faces = srcAddress_[facei]; - const scalarList& weights = srcWeights_[facei]; - - forAll(faces, i) - { - cop(result[facei], facei, work[faces[i]], weights[i]); - } - } - } - } - else - { - forAll(result, facei) - { - if (srcWeightsSum_[facei] < lowWeightCorrection_) - { - result[facei] = defaultValues[facei]; - } - else - { - const labelList& faces = srcAddress_[facei]; - const scalarList& weights = srcWeights_[facei]; - - forAll(faces, i) - { - cop(result[facei], facei, fld[faces[i]], weights[i]); - } - } - } - } -} - - -template -template -Foam::tmp> -Foam::AMIInterpolation::interpolateToSource -( - const Field& fld, - const CombineOp& cop, - const UList& defaultValues -) const -{ - tmp> tresult - ( - new Field - ( - srcAddress_.size(), - Zero - ) - ); - - interpolateToSource - ( - fld, - multiplyWeightedOp(cop), - tresult.ref(), - defaultValues - ); - - return tresult; -} - - -template -template -Foam::tmp> -Foam::AMIInterpolation::interpolateToSource -( - const tmp>& tFld, - const CombineOp& cop, - const UList& defaultValues -) const -{ - return interpolateToSource(tFld(), cop, defaultValues); -} - - -template -template -Foam::tmp> -Foam::AMIInterpolation::interpolateToTarget -( - const Field& fld, - const CombineOp& cop, - const UList& defaultValues -) const -{ - tmp> tresult - ( - new Field - ( - tgtAddress_.size(), - Zero - ) - ); - - interpolateToTarget - ( - fld, - multiplyWeightedOp(cop), - tresult.ref(), - defaultValues - ); - - return tresult; -} - - -template -template -Foam::tmp> -Foam::AMIInterpolation::interpolateToTarget -( - const tmp>& tFld, - const CombineOp& cop, - const UList& defaultValues -) const -{ - return interpolateToTarget(tFld(), cop, defaultValues); -} - - -template -template -Foam::tmp> -Foam::AMIInterpolation::interpolateToSource -( - const Field& fld, - const UList& defaultValues -) const -{ - return interpolateToSource(fld, plusEqOp(), defaultValues); -} - - -template -template -Foam::tmp> -Foam::AMIInterpolation::interpolateToSource -( - const tmp>& tFld, - const UList& defaultValues -) const -{ - return interpolateToSource(tFld(), plusEqOp(), defaultValues); -} - - -template -template -Foam::tmp> -Foam::AMIInterpolation::interpolateToTarget -( - const Field& fld, - const UList& defaultValues -) const -{ - return interpolateToTarget(fld, plusEqOp(), defaultValues); -} - - -template -template -Foam::tmp> -Foam::AMIInterpolation::interpolateToTarget -( - const tmp>& tFld, - const UList& defaultValues -) const -{ - return interpolateToTarget(tFld(), plusEqOp(), defaultValues); -} - - -template -Foam::label Foam::AMIInterpolation::srcPointFace -( - const SourcePatch& srcPatch, - const TargetPatch& tgtPatch, + const primitivePatch& srcPatch, + const primitivePatch& tgtPatch, const vector& n, const label tgtFacei, point& tgtPoint @@ -1612,11 +1264,10 @@ const } -template -Foam::label Foam::AMIInterpolation::tgtPointFace +Foam::label Foam::AMIInterpolation::tgtPointFace ( - const SourcePatch& srcPatch, - const TargetPatch& tgtPatch, + const primitivePatch& srcPatch, + const primitivePatch& tgtPatch, const vector& n, const label srcFacei, point& srcPoint @@ -1661,11 +1312,10 @@ const } -template -void Foam::AMIInterpolation::writeFaceConnectivity +void Foam::AMIInterpolation::writeFaceConnectivity ( - const SourcePatch& srcPatch, - const TargetPatch& tgtPatch, + const primitivePatch& srcPatch, + const primitivePatch& tgtPatch, const labelListList& srcAddress ) const diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H index f99f6d57f1..36c5ee4a3b 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolation.H @@ -41,8 +41,8 @@ Description SourceFiles AMIInterpolation.C - AMIInterpolationName.C AMIInterpolationParallelOps.C + AMIInterpolationTemplates.C \*---------------------------------------------------------------------------*/ @@ -64,32 +64,13 @@ namespace Foam { /*---------------------------------------------------------------------------*\ - Class AMIInterpolationName Declaration + Class AMIInterpolation Declaration \*---------------------------------------------------------------------------*/ -TemplateName(AMIInterpolation); - - -/*---------------------------------------------------------------------------*\ - Class AMIInterpolation Declaration -\*---------------------------------------------------------------------------*/ - -template class AMIInterpolation -: - public AMIInterpolationName { public: - // Public typedefs - - // Typedef to SourcePatch type this AMIInterplation is instantiated on - typedef SourcePatch sourcePatchType; - - // Typedef to TargetPatch type this AMIInterplation is instantiated on - typedef TargetPatch targetPatchType; - - // Public data types //- Enumeration specifying interpolation method @@ -115,10 +96,9 @@ public: ); //- Calculate the patch face magnitudes for the given tri-mode - template static tmp patchMagSf ( - const Patch& patch, + const primitivePatch& patch, const faceAreaIntersect::triangulationMode triMode ); @@ -200,8 +180,8 @@ private: //- Calculate if patches are on multiple processors label calcDistribution ( - const SourcePatch& srcPatch, - const TargetPatch& tgtPatch + const primitivePatch& srcPatch, + const primitivePatch& tgtPatch ) const; label calcOverlappingProcs @@ -214,7 +194,7 @@ private: void distributePatches ( const mapDistribute& map, - const TargetPatch& pp, + const primitivePatch& pp, const globalIndex& gi, List& faces, List& points, @@ -224,7 +204,7 @@ private: void distributeAndMergePatches ( const mapDistribute& map, - const TargetPatch& tgtPatch, + const primitivePatch& tgtPatch, const globalIndex& gi, faceList& tgtFaces, pointField& tgtPoints, @@ -233,8 +213,8 @@ private: autoPtr calcProcMap ( - const SourcePatch& srcPatch, - const TargetPatch& tgtPatch + const primitivePatch& srcPatch, + const primitivePatch& tgtPatch ) const; @@ -312,21 +292,25 @@ private: void constructFromSurface ( - const SourcePatch& srcPatch, - const TargetPatch& tgtPatch, + const primitivePatch& srcPatch, + const primitivePatch& tgtPatch, const autoPtr& surfPtr, const bool report ); public: + //- Runtime type information + TypeName("cyclicAMI"); + + // Constructors //- Construct from components AMIInterpolation ( - const SourcePatch& srcPatch, - const TargetPatch& tgtPatch, + const primitivePatch& srcPatch, + const primitivePatch& tgtPatch, const faceAreaIntersect::triangulationMode& triMode, const bool requireMatch = true, const interpolationMethod& method = imFaceAreaWeight, @@ -338,8 +322,8 @@ public: //- Construct from components AMIInterpolation ( - const SourcePatch& srcPatch, - const TargetPatch& tgtPatch, + const primitivePatch& srcPatch, + const primitivePatch& tgtPatch, const faceAreaIntersect::triangulationMode& triMode, const bool requireMatch = true, const word& methodName = @@ -352,8 +336,8 @@ public: //- Construct from components, with projection surface AMIInterpolation ( - const SourcePatch& srcPatch, - const TargetPatch& tgtPatch, + const primitivePatch& srcPatch, + const primitivePatch& tgtPatch, const autoPtr& surf, const faceAreaIntersect::triangulationMode& triMode, const bool requireMatch = true, @@ -366,8 +350,8 @@ public: //- Construct from components, with projection surface AMIInterpolation ( - const SourcePatch& srcPatch, - const TargetPatch& tgtPatch, + const primitivePatch& srcPatch, + const primitivePatch& tgtPatch, const autoPtr& surf, const faceAreaIntersect::triangulationMode& triMode, const bool requireMatch = true, @@ -378,11 +362,12 @@ public: const bool report = true ); - //- Construct from agglomeration of AMIInterpolation. Agglomeration - // passed in as new coarse size and addressing from fine from coarse + //- Construct from agglomeration of AMIInterpolation. + // Agglomeration passed in as new coarse size and addressing from fine + // from coarse AMIInterpolation ( - const AMIInterpolation& fineAMI, + const AMIInterpolation& fineAMI, const labelList& sourceRestrictAddressing, const labelList& neighbourRestrictAddressing, const bool report = false @@ -390,7 +375,7 @@ public: //- Destructor - ~AMIInterpolation(); + virtual ~AMIInterpolation(); // Member Functions @@ -469,42 +454,27 @@ public: //- Update addressing and weights void update ( - const SourcePatch& srcPatch, - const TargetPatch& tgtPatch, + const primitivePatch& srcPatch, + const primitivePatch& tgtPatch, const bool report ); //- Sum the weights on both sides of an AMI - static void sumWeights - ( - AMIInterpolation& AMI - ); + static void sumWeights(AMIInterpolation& AMI); //- As above, but for multiple AMI-s - static void sumWeights - ( - PtrList>& AMIs - ); + static void sumWeights(PtrList& AMIs); //- Print out information relating to the weights sum. Values close // to one are ideal. This information acts as a measure of the // quality of the AMI. - static void reportSumWeights - ( - AMIInterpolation& AMI - ); + static void reportSumWeights(AMIInterpolation& AMI); //- Normalise the weights on both sides of an AMI - static void normaliseWeights - ( - AMIInterpolation& AMI - ); + static void normaliseWeights(AMIInterpolation& AMI); //- As above, but for multiple AMI-s - static void normaliseWeights - ( - UPtrList>& AMIs - ); + static void normaliseWeights(UPtrList& AMIs); // Evaluation @@ -608,8 +578,8 @@ public: //- Return source patch face index of point on target patch face label srcPointFace ( - const SourcePatch& srcPatch, - const TargetPatch& tgtPatch, + const primitivePatch& srcPatch, + const primitivePatch& tgtPatch, const vector& n, const label tgtFacei, point& tgtPoint @@ -619,8 +589,8 @@ public: //- Return target patch face index of point on source patch face label tgtPointFace ( - const SourcePatch& srcPatch, - const TargetPatch& tgtPatch, + const primitivePatch& srcPatch, + const primitivePatch& tgtPatch, const vector& n, const label srcFacei, point& srcPoint @@ -633,8 +603,8 @@ public: //- Write face connectivity as OBJ file void writeFaceConnectivity ( - const SourcePatch& srcPatch, - const TargetPatch& tgtPatch, + const primitivePatch& srcPatch, + const primitivePatch& tgtPatch, const labelListList& srcAddress ) const; }; @@ -651,8 +621,7 @@ public: // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // #ifdef NoRepository - #include "AMIInterpolation.C" - #include "AMIInterpolationParallelOps.C" + #include "AMIInterpolationTemplates.C" #endif // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationI.H b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationI.H index 0022819f8c..10fa684300 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationI.H +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationI.H @@ -23,138 +23,103 @@ License \*---------------------------------------------------------------------------*/ -template -inline Foam::label -Foam::AMIInterpolation::singlePatchProc() const +inline Foam::label Foam::AMIInterpolation::singlePatchProc() const { return singlePatchProc_; } -template -inline Foam::scalar -Foam::AMIInterpolation::lowWeightCorrection() const +inline Foam::scalar Foam::AMIInterpolation::lowWeightCorrection() const { return lowWeightCorrection_; } -template -inline bool -Foam::AMIInterpolation:: -applyLowWeightCorrection() const +inline bool Foam::AMIInterpolation::applyLowWeightCorrection() const { return lowWeightCorrection_ > 0; } -template -inline const Foam::scalarField& -Foam::AMIInterpolation::srcMagSf() const +inline const Foam::scalarField& Foam::AMIInterpolation::srcMagSf() const { return srcMagSf_; } -template -inline const Foam::labelListList& -Foam::AMIInterpolation::srcAddress() const +inline const Foam::labelListList& Foam::AMIInterpolation::srcAddress() const { return srcAddress_; } -template -inline const Foam::scalarListList& -Foam::AMIInterpolation::srcWeights() const +inline const Foam::scalarListList& Foam::AMIInterpolation::srcWeights() const { return srcWeights_; } -template -inline Foam::scalarListList& -Foam::AMIInterpolation::srcWeights() +inline Foam::scalarListList& Foam::AMIInterpolation::srcWeights() { return srcWeights_; } -template -inline const Foam::scalarField& -Foam::AMIInterpolation::srcWeightsSum() const +inline const Foam::scalarField& Foam::AMIInterpolation::srcWeightsSum() const { return srcWeightsSum_; } -template -inline Foam::scalarField& -Foam::AMIInterpolation::srcWeightsSum() +inline Foam::scalarField& Foam::AMIInterpolation::srcWeightsSum() { return srcWeightsSum_; } -template -inline const Foam::mapDistribute& -Foam::AMIInterpolation::srcMap() const +inline const Foam::mapDistribute& Foam::AMIInterpolation::srcMap() const { return srcMapPtr_(); } -template -inline const Foam::scalarField& -Foam::AMIInterpolation::tgtMagSf() const +inline const Foam::scalarField& Foam::AMIInterpolation::tgtMagSf() const { return tgtMagSf_; } -template -inline const Foam::labelListList& -Foam::AMIInterpolation::tgtAddress() const +inline const Foam::labelListList& Foam::AMIInterpolation::tgtAddress() const { return tgtAddress_; } -template -inline const Foam::scalarListList& -Foam::AMIInterpolation::tgtWeights() const +inline const Foam::scalarListList& Foam::AMIInterpolation::tgtWeights() const { return tgtWeights_; } -template -inline Foam::scalarListList& -Foam::AMIInterpolation::tgtWeights() +inline Foam::scalarListList& Foam::AMIInterpolation::tgtWeights() { return tgtWeights_; } -template -inline const Foam::scalarField& -Foam::AMIInterpolation::tgtWeightsSum() const +inline const Foam::scalarField& Foam::AMIInterpolation::tgtWeightsSum() const { return tgtWeightsSum_; } -template -inline Foam::scalarField& -Foam::AMIInterpolation::tgtWeightsSum() +inline Foam::scalarField& Foam::AMIInterpolation::tgtWeightsSum() { return tgtWeightsSum_; } -template -inline const Foam::mapDistribute& -Foam::AMIInterpolation::tgtMap() const +inline const Foam::mapDistribute& Foam::AMIInterpolation::tgtMap() const { return tgtMapPtr_(); } diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationName.C b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationName.C deleted file mode 100644 index 1024abb762..0000000000 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationName.C +++ /dev/null @@ -1,36 +0,0 @@ -/*---------------------------------------------------------------------------*\ - ========= | - \\ / F ield | OpenFOAM: The Open Source CFD Toolbox - \\ / O peration | Website: https://openfoam.org - \\ / A nd | Copyright (C) 2011-2018 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 . - -\*---------------------------------------------------------------------------*/ - -#include "AMIInterpolation.H" - -// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // - -namespace Foam -{ -defineTypeNameAndDebug(AMIInterpolationName, 0); -} - - -// ************************************************************************* // diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationParallelOps.C b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationParallelOps.C index 53db1497c6..76ec36b8f4 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationParallelOps.C +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationParallelOps.C @@ -29,11 +29,10 @@ License // * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * // -template -Foam::label Foam::AMIInterpolation::calcDistribution +Foam::label Foam::AMIInterpolation::calcDistribution ( - const SourcePatch& srcPatch, - const TargetPatch& tgtPatch + const primitivePatch& srcPatch, + const primitivePatch& tgtPatch ) const { label proci = 0; @@ -81,9 +80,7 @@ Foam::label Foam::AMIInterpolation::calcDistribution } -template -Foam::label -Foam::AMIInterpolation::calcOverlappingProcs +Foam::label Foam::AMIInterpolation::calcOverlappingProcs ( const List& procBb, const treeBoundBox& bb, @@ -113,11 +110,10 @@ Foam::AMIInterpolation::calcOverlappingProcs } -template -void Foam::AMIInterpolation::distributePatches +void Foam::AMIInterpolation::distributePatches ( const mapDistribute& map, - const TargetPatch& pp, + const primitivePatch& pp, const globalIndex& gi, List& faces, List& points, @@ -209,12 +205,10 @@ void Foam::AMIInterpolation::distributePatches } -template -void Foam::AMIInterpolation:: -distributeAndMergePatches +void Foam::AMIInterpolation::distributeAndMergePatches ( const mapDistribute& map, - const TargetPatch& tgtPatch, + const primitivePatch& tgtPatch, const globalIndex& gi, faceList& tgtFaces, pointField& tgtPoints, @@ -325,12 +319,11 @@ distributeAndMergePatches } -template Foam::autoPtr -Foam::AMIInterpolation::calcProcMap +Foam::AMIInterpolation::calcProcMap ( - const SourcePatch& srcPatch, - const TargetPatch& tgtPatch + const primitivePatch& srcPatch, + const primitivePatch& tgtPatch ) const { // Get decomposition of patch diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationTemplates.C b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationTemplates.C new file mode 100644 index 0000000000..c677977dd7 --- /dev/null +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIInterpolationTemplates.C @@ -0,0 +1,336 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | OpenFOAM: The Open Source CFD Toolbox + \\ / O peration | Website: https://openfoam.org + \\ / A nd | Copyright (C) 2011-2018 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 . + +\*---------------------------------------------------------------------------*/ + +#include "AMIInterpolation.H" +#include "AMIMethod.H" +#include "meshTools.H" +#include "mapDistribute.H" +#include "flipOp.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template +void Foam::AMIInterpolation::interpolateToTarget +( + const UList& fld, + const CombineOp& cop, + List& result, + const UList& defaultValues +) const +{ + if (fld.size() != srcAddress_.size()) + { + FatalErrorInFunction + << "Supplied field size is not equal to source patch size" << nl + << " source patch = " << srcAddress_.size() << nl + << " target patch = " << tgtAddress_.size() << nl + << " supplied field = " << fld.size() + << abort(FatalError); + } + + if (lowWeightCorrection_ > 0) + { + if (defaultValues.size() != tgtAddress_.size()) + { + FatalErrorInFunction + << "Employing default values when sum of weights falls below " + << lowWeightCorrection_ + << " but supplied default field size is not equal to target " + << "patch size" << nl + << " default values = " << defaultValues.size() << nl + << " target patch = " << tgtAddress_.size() << nl + << abort(FatalError); + } + } + + result.setSize(tgtAddress_.size()); + + if (singlePatchProc_ == -1) + { + const mapDistribute& map = srcMapPtr_(); + + List work(fld); + map.distribute(work); + + forAll(result, facei) + { + if (tgtWeightsSum_[facei] < lowWeightCorrection_) + { + result[facei] = defaultValues[facei]; + } + else + { + const labelList& faces = tgtAddress_[facei]; + const scalarList& weights = tgtWeights_[facei]; + + forAll(faces, i) + { + cop(result[facei], facei, work[faces[i]], weights[i]); + } + } + } + } + else + { + forAll(result, facei) + { + if (tgtWeightsSum_[facei] < lowWeightCorrection_) + { + result[facei] = defaultValues[facei]; + } + else + { + const labelList& faces = tgtAddress_[facei]; + const scalarList& weights = tgtWeights_[facei]; + + forAll(faces, i) + { + cop(result[facei], facei, fld[faces[i]], weights[i]); + } + } + } + } +} + + +template +void Foam::AMIInterpolation::interpolateToSource +( + const UList& fld, + const CombineOp& cop, + List& result, + const UList& defaultValues +) const +{ + if (fld.size() != tgtAddress_.size()) + { + FatalErrorInFunction + << "Supplied field size is not equal to target patch size" << nl + << " source patch = " << srcAddress_.size() << nl + << " target patch = " << tgtAddress_.size() << nl + << " supplied field = " << fld.size() + << abort(FatalError); + } + + if (lowWeightCorrection_ > 0) + { + if (defaultValues.size() != srcAddress_.size()) + { + FatalErrorInFunction + << "Employing default values when sum of weights falls below " + << lowWeightCorrection_ + << " but supplied default field size is not equal to target " + << "patch size" << nl + << " default values = " << defaultValues.size() << nl + << " source patch = " << srcAddress_.size() << nl + << abort(FatalError); + } + } + + result.setSize(srcAddress_.size()); + + if (singlePatchProc_ == -1) + { + const mapDistribute& map = tgtMapPtr_(); + + List work(fld); + map.distribute(work); + + forAll(result, facei) + { + if (srcWeightsSum_[facei] < lowWeightCorrection_) + { + result[facei] = defaultValues[facei]; + } + else + { + const labelList& faces = srcAddress_[facei]; + const scalarList& weights = srcWeights_[facei]; + + forAll(faces, i) + { + cop(result[facei], facei, work[faces[i]], weights[i]); + } + } + } + } + else + { + forAll(result, facei) + { + if (srcWeightsSum_[facei] < lowWeightCorrection_) + { + result[facei] = defaultValues[facei]; + } + else + { + const labelList& faces = srcAddress_[facei]; + const scalarList& weights = srcWeights_[facei]; + + forAll(faces, i) + { + cop(result[facei], facei, fld[faces[i]], weights[i]); + } + } + } + } +} + + +template +Foam::tmp> +Foam::AMIInterpolation::interpolateToSource +( + const Field& fld, + const CombineOp& cop, + const UList& defaultValues +) const +{ + tmp> tresult + ( + new Field + ( + srcAddress_.size(), + Zero + ) + ); + + interpolateToSource + ( + fld, + multiplyWeightedOp(cop), + tresult.ref(), + defaultValues + ); + + return tresult; +} + + +template +Foam::tmp> +Foam::AMIInterpolation::interpolateToSource +( + const tmp>& tFld, + const CombineOp& cop, + const UList& defaultValues +) const +{ + return interpolateToSource(tFld(), cop, defaultValues); +} + + +template +Foam::tmp> +Foam::AMIInterpolation::interpolateToTarget +( + const Field& fld, + const CombineOp& cop, + const UList& defaultValues +) const +{ + tmp> tresult + ( + new Field + ( + tgtAddress_.size(), + Zero + ) + ); + + interpolateToTarget + ( + fld, + multiplyWeightedOp(cop), + tresult.ref(), + defaultValues + ); + + return tresult; +} + + +template +Foam::tmp> +Foam::AMIInterpolation::interpolateToTarget +( + const tmp>& tFld, + const CombineOp& cop, + const UList& defaultValues +) const +{ + return interpolateToTarget(tFld(), cop, defaultValues); +} + + +template +Foam::tmp> +Foam::AMIInterpolation::interpolateToSource +( + const Field& fld, + const UList& defaultValues +) const +{ + return interpolateToSource(fld, plusEqOp(), defaultValues); +} + + +template +Foam::tmp> +Foam::AMIInterpolation::interpolateToSource +( + const tmp>& tFld, + const UList& defaultValues +) const +{ + return interpolateToSource(tFld(), plusEqOp(), defaultValues); +} + + +template +Foam::tmp> +Foam::AMIInterpolation::interpolateToTarget +( + const Field& fld, + const UList& defaultValues +) const +{ + return interpolateToTarget(fld, plusEqOp(), defaultValues); +} + + +template +Foam::tmp> +Foam::AMIInterpolation::interpolateToTarget +( + const tmp>& tFld, + const UList& defaultValues +) const +{ + return interpolateToTarget(tFld(), plusEqOp(), defaultValues); +} + + +// ************************************************************************* // diff --git a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/AMIMethod/AMIMethod.C b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/AMIMethod/AMIMethod.C index bf5bfb7d0b..bba3dbc570 100644 --- a/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/AMIMethod/AMIMethod.C +++ b/src/meshTools/AMIInterpolation/AMIInterpolation/AMIMethod/AMIMethod/AMIMethod.C @@ -28,10 +28,18 @@ License #include "mapDistribute.H" #include "unitConversion.H" +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +namespace Foam +{ + defineTypeNameAndDebug(AMIMethod, 0); + defineRunTimeSelectionTable(AMIMethod, components); +} + + // * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // -template -void Foam::AMIMethod::checkPatches() const +void Foam::AMIMethod::checkPatches() const { if (debug && (!srcPatch_.size() || !tgtPatch_.size())) { @@ -67,8 +75,7 @@ void Foam::AMIMethod::checkPatches() const } -template -bool Foam::AMIMethod::initialise +bool Foam::AMIMethod::initialise ( labelListList& srcAddress, scalarListList& srcWeights, @@ -142,8 +149,7 @@ bool Foam::AMIMethod::initialise } -template -void Foam::AMIMethod::writeIntersectionOBJ +void Foam::AMIMethod::writeIntersectionOBJ ( const scalar area, const face& f1, @@ -194,8 +200,7 @@ void Foam::AMIMethod::writeIntersectionOBJ } -template -void Foam::AMIMethod::resetTree() +void Foam::AMIMethod::resetTree() { // Clear the old octree treePtr_.clear(); @@ -225,8 +230,7 @@ void Foam::AMIMethod::resetTree() } -template -Foam::label Foam::AMIMethod::findTargetFace +Foam::label Foam::AMIMethod::findTargetFace ( const label srcFacei ) const @@ -256,11 +260,10 @@ Foam::label Foam::AMIMethod::findTargetFace } -template -void Foam::AMIMethod::appendNbrFaces +void Foam::AMIMethod::appendNbrFaces ( const label facei, - const TargetPatch& patch, + const primitivePatch& patch, const DynamicList