From d5b37a2d37d1300bd16d688db1c73f69a183d23c Mon Sep 17 00:00:00 2001 From: Vuko Vukcevic Date: Fri, 7 Sep 2018 14:56:55 +0200 Subject: [PATCH 1/8] Bugfix: mesh flux using backward scheme with variable time step The coefficients in backwardDdtScheme::meshPhi did not correctly take into account the possibility of having variable time steps. Reported by Sopheak Seng, Bureau Veritas. --- .../backwardDdtScheme/backwardDdtScheme.C | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/finiteVolume/finiteVolume/ddtSchemes/backwardDdtScheme/backwardDdtScheme.C b/src/finiteVolume/finiteVolume/ddtSchemes/backwardDdtScheme/backwardDdtScheme.C index ec96b9249..a06892a42 100644 --- a/src/finiteVolume/finiteVolume/ddtSchemes/backwardDdtScheme/backwardDdtScheme.C +++ b/src/finiteVolume/finiteVolume/ddtSchemes/backwardDdtScheme/backwardDdtScheme.C @@ -801,16 +801,15 @@ tmp backwardDdtScheme::meshPhi const GeometricField& vf ) { - scalar deltaT = deltaT_(); - scalar deltaT0 = deltaT0_(vf); + const scalar deltaT = deltaT_(); + const scalar deltaT0 = deltaT0_(vf); - // Coefficient for t-3/2 (between times 0 and 00) - scalar coefft0_00 = deltaT/(deltaT + deltaT0); + // Bugfix: missing possibility of having the variable time step + // Reported by Sopheak Seng, Bureau Veritas, 6/Sep/2018. + const scalar coefft00 = deltaT*deltaT/(deltaT0*(deltaT + deltaT0)); + const scalar coefft = 1 + deltaT/(deltaT + deltaT0); - // Coefficient for t-1/2 (between times n and 0) - scalar coefftn_0 = 1 + coefft0_00; - - return coefftn_0*mesh().phi() - coefft0_00*mesh().phi().oldTime(); + return coefft*mesh().phi() - coefft00*mesh().phi().oldTime(); } From 8d356e74568d3ba1770405e2077638d9dd0c2556 Mon Sep 17 00:00:00 2001 From: Henrik Rusche Date: Tue, 3 Jul 2018 22:26:12 +0200 Subject: [PATCH 2/8] PLB with clouds --- .../finiteVolume/fvFieldDecomposer.C | 3 + .../finiteVolume/processorMeshesRebuild.C | 4 +- .../processorMeshesReconstructor.C | 35 ++-- .../topoChangerFvMeshLoadBalance.C | 76 +++++++- .../cfdTools/incompressible/CourantNo.H | 21 ++- src/foam/CMakeLists.txt | 1 + src/foam/Make/files | 1 + src/foam/fields/cloud/cloud.C | 27 +++ src/foam/fields/cloud/cloud.H | 17 +- .../fields/cloudDistribute/cloudDistribute.C | 77 ++++++++ .../fields/cloudDistribute/cloudDistribute.H | 98 +++++++++++ src/foam/meshes/polyMesh/polyMesh.C | 17 +- .../CloudDistributeTemplate.C | 107 +++++++++++ .../CloudDistributeTemplate.H | 114 ++++++++++++ .../basic/CloudTemplate/CloudTemplate.C | 166 ++++++++++++++++++ .../basic/CloudTemplate/CloudTemplate.H | 41 +++++ .../KinematicCloud/KinematicCloudTemplate.C | 22 +++ .../KinematicCloud/KinematicCloudTemplate.H | 9 + .../ConeInjection/ConeInjection.C | 11 +- .../ConeInjection/ConeInjection.H | 3 + .../InjectionModel/InjectionModel.C | 11 ++ .../InjectionModel/InjectionModel.H | 6 + 22 files changed, 843 insertions(+), 24 deletions(-) create mode 100644 src/foam/fields/cloudDistribute/cloudDistribute.C create mode 100644 src/foam/fields/cloudDistribute/cloudDistribute.H create mode 100644 src/lagrangian/basic/CloudDistributeTemplate/CloudDistributeTemplate.C create mode 100644 src/lagrangian/basic/CloudDistributeTemplate/CloudDistributeTemplate.H diff --git a/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/fvFieldDecomposer.C b/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/fvFieldDecomposer.C index 4b458c56f..bacec25b3 100644 --- a/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/fvFieldDecomposer.C +++ b/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/fvFieldDecomposer.C @@ -155,6 +155,9 @@ fvFieldDecomposer::fvFieldDecomposer static_cast(NULL) ) { + // HR 25.06.18: Weights may be required for some mappings and might hang in parallel. + completeMesh_.weights(); + forAll (boundaryAddressing_, patchi) { if (boundaryAddressing_[patchi] >= 0) diff --git a/src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume/processorMeshesRebuild.C b/src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume/processorMeshesRebuild.C index dec08f0db..fbe520e7b 100644 --- a/src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume/processorMeshesRebuild.C +++ b/src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume/processorMeshesRebuild.C @@ -1147,7 +1147,7 @@ Foam::processorMeshesReconstructor::reconstructMesh(const Time& db) != masterPpAddr[curMF[pointI]] ) { - WarningIn + FatalErrorIn ( "autoPtr " "processorMeshesReconstructor::" @@ -1213,7 +1213,7 @@ Foam::processorMeshesReconstructor::reconstructMesh(const Time& db) != ppAddr[curSpl[splI]] ) { - WarningIn + FatalErrorIn ( "autoPtr " "processorMeshesReconstructor::" diff --git a/src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume/processorMeshesReconstructor.C b/src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume/processorMeshesReconstructor.C index d13afe638..18ace98bb 100644 --- a/src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume/processorMeshesReconstructor.C +++ b/src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume/processorMeshesReconstructor.C @@ -115,21 +115,32 @@ Foam::processorMeshesReconstructor::readUpdate() { stat = procStat; } - else + else if (stat != procStat) { - if (stat != procStat) + if ( + ( + stat == polyMesh::TOPO_CHANGE + && procStat == polyMesh::TOPO_PATCH_CHANGE + ) + || ( + procStat == polyMesh::TOPO_CHANGE + && stat == polyMesh::TOPO_PATCH_CHANGE + ) + ) { - FatalErrorIn("processorMeshesReconstructor::readUpdate()") - << "Processor " << procI - << " has a different polyMesh at time " - << meshes_[procI].time().timeName() - << " compared to any previous processors." << nl - << "Please check time " - << meshes_[procI].time().timeName() - << " directories on all processors for consistent" - << " mesh files." - << exit(FatalError); + continue; } + + FatalErrorIn("processorMeshesReconstructor::readUpdate()") + << "Processor " << procI + << " has a different polyMesh at time " + << meshes_[procI].time().timeName() + << " compared to any previous processors." << nl + << "Please check time " + << meshes_[procI].time().timeName() + << " directories on all processors for consistent" + << " mesh files." + << exit(FatalError); } } } diff --git a/src/dynamicMesh/topoChangerFvMesh/topoChangerFvMesh/topoChangerFvMeshLoadBalance.C b/src/dynamicMesh/topoChangerFvMesh/topoChangerFvMesh/topoChangerFvMeshLoadBalance.C index 54b6c5417..032371914 100644 --- a/src/dynamicMesh/topoChangerFvMesh/topoChangerFvMesh/topoChangerFvMeshLoadBalance.C +++ b/src/dynamicMesh/topoChangerFvMesh/topoChangerFvMesh/topoChangerFvMeshLoadBalance.C @@ -30,6 +30,8 @@ License #include "fvFieldReconstructor.H" #include "passiveProcessorPolyPatch.H" #include "addToRunTimeSelectionTable.H" +#include "cloud.H" +#include "cloudDistribute.H" // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // @@ -87,7 +89,7 @@ bool Foam::topoChangerFvMesh::loadBalance(const dictionary& decompDict) // forAll(cellToProc, celli) // { - // cellDist[celli] = cellToProc[celli]; + // cellDist[celli] = cellToProc[celli]; // } // cellDist.write(); @@ -102,8 +104,29 @@ bool Foam::topoChangerFvMesh::loadBalance(const dictionary& decompDict) Pstream::gatherList(migratedCells); Pstream::scatterList(migratedCells); Info<< "Migrated cells per processor: " << migratedCells << endl; + // Reading through second index now tells how many cells will arrive // from which processor + forAll (migratedCells, i) + { + bool allZero = true; + forAll (migratedCells, j) + { + if (migratedCells[j][i] > 0) + { + allZero = false; + break; + } + } + + if (allZero) + { + FatalErrorIn("bool topoChangerFvMesh::loadBalance()") + << "Reconstructed mesh must have at least one cell " + "on each processor" + << abort(FatalError); + } + } // Find out which processor faces will become local internal faces // by comparing decomposition index from the other side @@ -135,6 +158,14 @@ bool Foam::topoChangerFvMesh::loadBalance(const dictionary& decompDict) HashTable surfaceVectorFields = thisDb().lookupClass(); + // Particles + HashTable clouds = thisDb().lookupClass(); + + forAllConstIter(HashTable, clouds, iter) + { + cloud& c = const_cast(*iter()); + } + //HJ, HERE: remove the fields that should not be load balanced // Prepare fields for reconstruction @@ -180,6 +211,26 @@ bool Foam::topoChangerFvMesh::loadBalance(const dictionary& decompDict) receivedSurfaceVectorFields[fieldI].setSize(Pstream::nProcs()); } + PtrList cloudDistributes(clouds.size()); + { + label cloudI = 0; + forAllConstIter(HashTable, clouds, iter) + { + cloud& c = const_cast(*iter()); + cloudDistributes.set + ( + cloudI++, + c.cloudDist + ( + meshDecomp.cellToProc(), + meshDecomp.procCellAddressing(), + meshDecomp.procFaceAddressing() + ) + ); + } + } + + for (label procI = 0; procI < meshDecomp.nProcs(); procI++) { // Check if there is a mesh to send @@ -225,6 +276,12 @@ bool Foam::topoChangerFvMesh::loadBalance(const dictionary& decompDict) sendFields(volVectorFields, fieldDecomposer, toProc); sendFields(surfaceScalarFields, fieldDecomposer, toProc); sendFields(surfaceVectorFields, fieldDecomposer, toProc); + + // Send clouds + forAll(cloudDistributes, cloudI) + { + cloudDistributes[cloudI].send(toProc, procI); + } } else { @@ -343,6 +400,11 @@ bool Foam::topoChangerFvMesh::loadBalance(const dictionary& decompDict) procMeshes[procI], fromProc ); + + forAll(cloudDistributes, cloudI) + { + cloudDistributes[cloudI].receive(fromProc, procI); + } } } } @@ -368,6 +430,8 @@ bool Foam::topoChangerFvMesh::loadBalance(const dictionary& decompDict) Pout<< "Reconstructed mesh stats: " << " nCells: " << reconMesh.nCells() + << " nFaces: " << reconMesh.nFaces() + << " nIntFaces: " << reconMesh.nInternalFaces() << " polyPatches: " << reconMesh.boundaryMesh().size() << " patches: " @@ -623,7 +687,6 @@ bool Foam::topoChangerFvMesh::loadBalance(const dictionary& decompDict) oldPatchNMeshPoints // oldPatchNMeshPoints ); - // Reset fvMesh and patches resetFvPrimitives ( @@ -681,6 +744,15 @@ bool Foam::topoChangerFvMesh::loadBalance(const dictionary& decompDict) meshMap ); + forAll(cloudDistributes, cloudI) + { + cloudDistributes[cloudI].rebuild + ( + meshRecon.cellProcAddressing(), + meshRecon.faceProcAddressing() + ); + } + // Debug checkMesh(true); diff --git a/src/finiteVolume/cfdTools/incompressible/CourantNo.H b/src/finiteVolume/cfdTools/incompressible/CourantNo.H index b04a6f527..b1e05b72a 100644 --- a/src/finiteVolume/cfdTools/incompressible/CourantNo.H +++ b/src/finiteVolume/cfdTools/incompressible/CourantNo.H @@ -33,7 +33,12 @@ scalar CoNum = 0.0; scalar meanCoNum = 0.0; scalar velMag = 0.0; -if (mesh.nInternalFaces()) +// HR 26.06.28: A parallel run has at least two cells and therefore at least +// one internal face in the global mesh. It may be a processor boundary, but +// this is captured by max(mag(phi)). +// Old formulation hangs on parallel cases where one partition is degenerated +// to a single cell. +if (mesh.nInternalFaces() || Pstream::parRun()) { surfaceScalarField magPhi = mag(phi); @@ -48,6 +53,20 @@ if (mesh.nInternalFaces()) velMag = max(magPhi/mesh.magSf()).value(); } +else +{ + // Single cell mesh: Co is still defined; use cell formulation + + const scalar deltaT = runTime.deltaT().value(); + + const scalar deltaX = Foam::cbrt(mesh.V()[0]); + + velMag = mag(U[0]); + + CoNum = velMag*deltaT/deltaX; + + meanCoNum = CoNum; +} Info<< "Courant Number mean: " << meanCoNum << " max: " << CoNum diff --git a/src/foam/CMakeLists.txt b/src/foam/CMakeLists.txt index e43423333..048a3dd1e 100644 --- a/src/foam/CMakeLists.txt +++ b/src/foam/CMakeLists.txt @@ -712,6 +712,7 @@ list(APPEND SOURCES ${meshTools}/mergePoints.C fields/UniformDimensionedFields/uniformDimensionedFields.C fields/cloud/cloud.C + fields/cloudDistribute/cloudDistribute.C ) set(Fields fields/Fields) diff --git a/src/foam/Make/files b/src/foam/Make/files index 2e7492146..afee07ad2 100644 --- a/src/foam/Make/files +++ b/src/foam/Make/files @@ -567,6 +567,7 @@ $(meshTools)/mergePoints.C fields/UniformDimensionedFields/uniformDimensionedFields.C fields/cloud/cloud.C +fields/cloudDistribute/cloudDistribute.C Fields = fields/Fields $(Fields)/labelField/labelField.C diff --git a/src/foam/fields/cloud/cloud.C b/src/foam/fields/cloud/cloud.C index 4d6339b72..4c7681f41 100644 --- a/src/foam/fields/cloud/cloud.C +++ b/src/foam/fields/cloud/cloud.C @@ -52,10 +52,37 @@ Foam::cloud::cloud(const objectRegistry& obr, const word& cloudName) {} +Foam::autoPtr Foam::cloud::cloudDist +( + const labelList& cellToProc, + const labelListList& procCellAddressing, + const labelListList& procFaceAddressing +) +{ + NotImplemented; + return autoPtr(NULL); +} + + // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // Foam::cloud::~cloud() {} +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +Foam::label Foam::cloud::size() const +{ + NotImplemented; + return 0; +} + + +void Foam::cloud::autoMap(const mapPolyMesh&) +{ + NotImplemented; +} + + // ************************************************************************* // diff --git a/src/foam/fields/cloud/cloud.H b/src/foam/fields/cloud/cloud.H index 71bea1561..613bed946 100644 --- a/src/foam/fields/cloud/cloud.H +++ b/src/foam/fields/cloud/cloud.H @@ -36,6 +36,7 @@ SourceFiles #define cloud_H #include "objectRegistry.H" +#include "cloudDistribute.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -44,6 +45,7 @@ namespace Foam // Forward declaration of classes class mapPolyMesh; +class polyMesh; /*---------------------------------------------------------------------------*\ Class cloud Declaration @@ -80,6 +82,13 @@ public: //- Construct for the given objectRegistry and named cloud instance cloud(const objectRegistry&, const word& cloudName = ""); + virtual autoPtr cloudDist + ( + const labelList& cellToProc, + const labelListList& procCellAddressing, + const labelListList& procFaceAddressing + ); + //- Destructor virtual ~cloud(); @@ -87,11 +96,17 @@ public: // Member Functions + // Access + + //- Return size of the cloud + virtual label size() const; + + // Edit //- Remap the cells of particles corresponding to the // mesh topology change - virtual void autoMap(const mapPolyMesh&) = 0; + virtual void autoMap(const mapPolyMesh&); }; diff --git a/src/foam/fields/cloudDistribute/cloudDistribute.C b/src/foam/fields/cloudDistribute/cloudDistribute.C new file mode 100644 index 000000000..36d9d9f8a --- /dev/null +++ b/src/foam/fields/cloudDistribute/cloudDistribute.C @@ -0,0 +1,77 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | Version: 4.1 + \\ / A nd | Web: http://www.foam-extend.org + \\/ M anipulation | For copyright notice see file Copyright +------------------------------------------------------------------------------- +License + This file is part of foam-extend. + + foam-extend 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. + + foam-extend 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 foam-extend. If not, see . + +Description + Lagrangian field decomposer. + +\*---------------------------------------------------------------------------*/ + +#include "cloudDistribute.H" + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +cloudDistribute::cloudDistribute() +{} + + +// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // + +cloudDistribute::~cloudDistribute() +{} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +void cloudDistribute::send(Ostream& toProc, const label procIndex) +{ + NotImplemented; +} + + +void cloudDistribute::receive(Istream& fromProc, const label procIndex) +{ + NotImplemented; +} + + +void cloudDistribute::rebuild +( + const PtrList& cellProcAddressing, + const PtrList& faceProcAddressing +) +{ + NotImplemented; +} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/foam/fields/cloudDistribute/cloudDistribute.H b/src/foam/fields/cloudDistribute/cloudDistribute.H new file mode 100644 index 000000000..f25f9d4c5 --- /dev/null +++ b/src/foam/fields/cloudDistribute/cloudDistribute.H @@ -0,0 +1,98 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | Version: 4.1 + \\ / A nd | Web: http://www.foam-extend.org + \\/ M anipulation | For copyright notice see file Copyright +------------------------------------------------------------------------------- +License + This file is part of foam-extend. + + foam-extend 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. + + foam-extend 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 foam-extend. If not, see . + +Class + Foam::cloudDistribute + +Description + Lagrangian field decomposer. + +SourceFiles + cloudDistribute.C + +\*---------------------------------------------------------------------------*/ + +#ifndef cloudDistribute_H +#define cloudDistribute_H + +#include "labelIOList.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class cloudDistribute Declaration +\*---------------------------------------------------------------------------*/ + +class cloudDistribute +{ + // Private Member Functions + + //- Disallow default bitwise copy construct + cloudDistribute(const cloudDistribute&); + + //- Disallow default bitwise assignment + void operator=(const cloudDistribute&); + + +public: + + // Constructors + + //- Null constructor + cloudDistribute(); + + + //- Destructor + virtual ~cloudDistribute(); + + + // Member Functions + + // Send particles + virtual void send(Ostream& toProc, const label procIndex); + + // Receive particles + virtual void receive(Istream& fromProc, const label procIndex); + + // Receive particles + virtual void rebuild + ( + const PtrList& cellProcAddressing, + const PtrList& faceProcAddressing + ); + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/foam/meshes/polyMesh/polyMesh.C b/src/foam/meshes/polyMesh/polyMesh.C index 6ef9def6d..9b4a7e8ad 100644 --- a/src/foam/meshes/polyMesh/polyMesh.C +++ b/src/foam/meshes/polyMesh/polyMesh.C @@ -739,15 +739,24 @@ void Foam::polyMesh::resetPrimitives // Faces will be reset in initMesh(), using size of owner list } + // HR 25.06.18: A mesh with a single cell has an empty neighbour list and + // we need to be able reset to such a mesh eg. during load balancing if (!own().empty()) { + // Mesh has at least one face in owner list. Reset both lists even if + // neighbours are empty (single cell mesh). owner_.transfer(own()); - } - - if (!nei().empty()) - { neighbour_.transfer(nei()); } + else + { + if (!nei().empty()) + { + // This mesh is invalid, but the operation was valid before. + // Therefore we do what was done before. + neighbour_.transfer(nei()); + } + } // Reset patch sizes and starts diff --git a/src/lagrangian/basic/CloudDistributeTemplate/CloudDistributeTemplate.C b/src/lagrangian/basic/CloudDistributeTemplate/CloudDistributeTemplate.C new file mode 100644 index 000000000..42d835c2f --- /dev/null +++ b/src/lagrangian/basic/CloudDistributeTemplate/CloudDistributeTemplate.C @@ -0,0 +1,107 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | Version: 4.1 + \\ / A nd | Web: http://www.foam-extend.org + \\/ M anipulation | For copyright notice see file Copyright +------------------------------------------------------------------------------- +License + This file is part of foam-extend. + + foam-extend 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. + + foam-extend 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 foam-extend. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "CloudDistributeTemplate.H" +#include "CloudTemplate.H" +#include "cloud.H" +#include "polyMesh.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::CloudDistribute::CloudDistribute +( + const labelList& cellToProc, + const labelListList& procCellAddressing, + const labelListList& procFaceAddressing, + cloud& cloud +) +: + cloudDistribute(), + cloud_(reinterpret_cast& >(cloud)), + transferList_(Pstream::nProcs()) +{ + cloud_.split + ( + cellToProc, + procCellAddressing, + procFaceAddressing, + transferList_ + ); +} + + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +void Foam::CloudDistribute::send +( + Ostream& toProc, + const label procIndex +) +{ + // Send transfer list prepared in constructor + toProc << transferList_[procIndex] << nl; + + // Clear the list for particles to be received + transferList_[procIndex].clear(); +} + + +template +void Foam::CloudDistribute::receive +( + Istream& fromProc, + const label procIndex +) +{ + // Receive particles and transfer into transfer list + IDLList newParticles + ( + fromProc, + typename ParticleType::iNew(cloud_) + ); + + transferList_[procIndex].DLListBase::transfer(newParticles); +} + + +template +void Foam::CloudDistribute::rebuild +( + const PtrList& cellProcAddressing, + const PtrList& faceProcAddressing +) +{ + cloud_.rebuild + ( + transferList_, + cellProcAddressing, + faceProcAddressing + ); +} + + +// ************************************************************************* // diff --git a/src/lagrangian/basic/CloudDistributeTemplate/CloudDistributeTemplate.H b/src/lagrangian/basic/CloudDistributeTemplate/CloudDistributeTemplate.H new file mode 100644 index 000000000..be366e58e --- /dev/null +++ b/src/lagrangian/basic/CloudDistributeTemplate/CloudDistributeTemplate.H @@ -0,0 +1,114 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | Version: 4.1 + \\ / A nd | Web: http://www.foam-extend.org + \\/ M anipulation | For copyright notice see file Copyright +------------------------------------------------------------------------------- +License + This file is part of foam-extend. + + foam-extend 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. + + foam-extend 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 foam-extend. If not, see . + +Class + Foam::Cloud + +Description + +SourceFiles + CloudDistributeTemplate.C + +\*---------------------------------------------------------------------------*/ + +#ifndef CloudDistributeTemplate_H +#define CloudDistributeTemplate_H + +#include "CloudTemplate.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// Forward declaration of functions +template +class Cloud; + +class polyMesh; +class cloud; + +/*---------------------------------------------------------------------------*\ + Class Cloud Declaration +\*---------------------------------------------------------------------------*/ + +template +class CloudDistribute +: + public cloudDistribute +{ + // Private data + + //- Reference to the cloud + Cloud& cloud_; + + //- Transfer buffer for ordering by procID (for sending) and receiving + List > transferList_; + +public: + + // Constructors + + //- Construct from components and fill the transfer list + CloudDistribute + ( + const labelList& cellToProc, + const labelListList& procCellAddressing, + const labelListList& procFaceAddressing, + cloud& cloud + ); + + + // Member Functions + + //- Send particles in the transfer list + void send(Ostream& toProc, const label procIndex); + + //- Receive particles into the transfer list + void receive(Istream& fromProc, const label procIndex); + + //- Rebuild the cloud by adding the particles in the transfer list + void rebuild + ( + const PtrList& cellProcAddressing, + const PtrList& faceProcAddressing + ); + +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "CloudDistributeTemplate.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/lagrangian/basic/CloudTemplate/CloudTemplate.C b/src/lagrangian/basic/CloudTemplate/CloudTemplate.C index 5873f8375..328ea496e 100644 --- a/src/lagrangian/basic/CloudTemplate/CloudTemplate.C +++ b/src/lagrangian/basic/CloudTemplate/CloudTemplate.C @@ -339,6 +339,172 @@ void Foam::Cloud::autoMap(const mapPolyMesh& mapper) } +template +void Foam::Cloud::split +( + const labelList& cellToProc, + const labelListList& procCellAddressing, + const labelListList& procFaceAddressing, + List >& procParticles +) +{ + // Create addressing old cell ID to new cell ID from procCellAddressing + labelList reverseCellMap(cellToProc.size()); + forAll(procCellAddressing, procI) + { + const labelList& procCell = procCellAddressing[procI]; + + forAll(procCell, cellI) + { + reverseCellMap[procCell[cellI]] = cellI; + } + } + + labelList reverseFaceMap(polyMesh_.nFaces()); + forAll(procFaceAddressing, procI) + { + const labelList& procFace = procFaceAddressing[procI]; + + forAll(procFace, faceI) + { + reverseFaceMap[mag(procFace[faceI])-1] = faceI; + } + } + + if (cloud::debug) + { + Pout << "printing cloud before splitting" << endl; + + forAllConstIter(typename Cloud, *this, pIter) + { + const ParticleType& p = pIter(); + + Pout << p.celli_ << " " + << p.facei_ << " " + << p.position() << " " + << p.inCell() << endl; + } + } + + // Loop over all particles + forAllIter(typename Cloud, *this, pIter) + { + ParticleType& p = pIter(); + + const label newProc = cellToProc[p.celli_]; + + // Map cellID and faceID of the particle to new mesh + p.celli_ = reverseCellMap[p.celli_]; + + if (p.facei_ >= 0) + { + // HR 29.06.17: face mapping not tested. Did not occur in test cases. + p.facei_ = reverseFaceMap[p.facei_]; + } + + if (newProc != Pstream::myProcNo()) + { + // Add for transfer to new processor and delete from local cloud + procParticles[newProc].append(this->remove(&p)); + } + } +} + + +template +void Foam::Cloud::rebuild +( + List >& receivedClouds, + const PtrList& cellProcAddressing, + const PtrList& faceProcAddressing +) +{ + { + const labelList& procCell = cellProcAddressing[Pstream::myProcNo()]; + const labelList& procFace = faceProcAddressing[Pstream::myProcNo()]; + + // Particles in local cloud. Map cellID and faceID in-place + forAllIter + ( + typename Cloud, + *this, + pIter + ) + { + ParticleType& p = pIter(); + + // Map cellID and faceID of the particle to new mesh + p.celli_ = procCell[p.celli_]; + + if (p.facei_ >= 0) + { + // HR 29.06.17: face mapping not tested. Did not occur in test cases. + p.facei_ = procFace[p.facei_]; + } + } + } + + forAll(cellProcAddressing, procI) + { + if (!cellProcAddressing.set(procI)) + { + continue; + } + + const labelList& procCell = cellProcAddressing[procI]; + const labelList& procFace = faceProcAddressing[procI]; + + IDLList& receivedCloud = receivedClouds[procI]; + + // Particles received from other processors. To be added to local cloud + forAllIter + ( + typename Cloud, + receivedCloud, + newpIter + ) + { + ParticleType& newp = newpIter(); + + // Map cellID and faceID of the particle to new mesh + newp.celli_ = procCell[newp.celli_]; + + if (newp.facei_ >= 0) + { + // HR 29.06.17: face mapping not tested. Did not occur in test cases. + newp.facei_ = procFace[newp.facei_]; + } + + // Add to cloud and remove from transfer list + this->addParticle(receivedCloud.remove(&newp)); + } + } + + + if (cloud::debug) + { + Pout << "printing cloud after rebuild" << endl; + + forAllIter + ( + typename Cloud, + *this, + pIter + ) + { + const ParticleType& p = pIter(); + + Pout << p.celli_ << " " + << p.facei_ << " " + << p.position() << " " + << p.inCell() << endl; + } + } + + this->updateMesh(); +} + + template void Foam::Cloud::writePositions() const { diff --git a/src/lagrangian/basic/CloudTemplate/CloudTemplate.H b/src/lagrangian/basic/CloudTemplate/CloudTemplate.H index c557265b4..e5716ed85 100644 --- a/src/lagrangian/basic/CloudTemplate/CloudTemplate.H +++ b/src/lagrangian/basic/CloudTemplate/CloudTemplate.H @@ -39,6 +39,7 @@ SourceFiles #include "IDLList.H" #include "IOField.H" #include "polyMesh.H" +#include "CloudDistributeTemplate.H" // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // @@ -150,6 +151,25 @@ public: const bool checkClass = true ); + autoPtr cloudDist + ( + const labelList& cellToProc, + const labelListList& procCellAddressing, + const labelListList& procFaceAddressing + ) + { + return autoPtr + ( + new CloudDistribute + ( + cellToProc, + procCellAddressing, + procFaceAddressing, + *this + ) + ); + } + // Member Functions @@ -245,10 +265,31 @@ public: template void move(TrackingData& td); + //- Update mesh + virtual void updateMesh() + {} + //- Remap the cells of particles corresponding to the // mesh topology change virtual void autoMap(const mapPolyMesh&); + //- Split cloud in load balancing + virtual void split + ( + const labelList& cellToProc, + const labelListList& procCellAddressing, + const labelListList& procFaceAddressing, + List >& procClouds + ); + + //- Rebuild cloud in load balancing + virtual void rebuild + ( + List >& receivedClouds, + const PtrList& cellProcAddressing, + const PtrList& faceProcAddressing + ); + // Read diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudTemplate.C b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudTemplate.C index a3aa6797d..306ac0dca 100644 --- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudTemplate.C +++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudTemplate.C @@ -266,6 +266,28 @@ void Foam::KinematicCloud::evolve() } +template +void Foam::KinematicCloud::updateMesh() +{ + UTrans_.setSize(this->pMesh().nCells()); + + injection().updateMesh(); +} + + +template +void Foam::KinematicCloud::autoMap(const mapPolyMesh& mapper) +{ + //typedef typename particle::TrackingData> tdType; + + //tdType td(*this); + + //Cloud::template autoMap(td, mapper); + + updateMesh(); +} + + template void Foam::KinematicCloud::info() const { diff --git a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudTemplate.H b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudTemplate.H index 4a40bdd61..0f4e3ce78 100644 --- a/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudTemplate.H +++ b/src/lagrangian/intermediate/clouds/Templates/KinematicCloud/KinematicCloudTemplate.H @@ -375,6 +375,15 @@ public: //- Evolve the spray (inject, inject) void evolve(); + + // Mapping + + //- Update mesh + virtual void updateMesh(); + + //- Remap the cells of particles corresponding to the + // mesh topology change with a default tracking data object + virtual void autoMap(const mapPolyMesh&); }; diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjection/ConeInjection.C b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjection/ConeInjection.C index 523e75665..3647d280a 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjection/ConeInjection.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjection/ConeInjection.C @@ -147,8 +147,7 @@ Foam::ConeInjection::ConeInjection // Set total volume to inject this->volumeTotal_ = volumeFlowRate_().integrate(0.0, duration_); - // Set/cache the injector cell - this->findCellAtPosition(injectorCell_, position_); + updateMesh(); } @@ -168,6 +167,14 @@ bool Foam::ConeInjection::active() const } +template +void Foam::ConeInjection::updateMesh() +{ + // Set/cache the injector cell + this->findCellAtPosition(injectorCell_, position_); +} + + template Foam::scalar Foam::ConeInjection::timeEnd() const { diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjection/ConeInjection.H b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjection/ConeInjection.H index 6f2cd9ea0..dc7e13019 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjection/ConeInjection.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/ConeInjection/ConeInjection.H @@ -152,6 +152,9 @@ public: //- Flag to indicate whether model activates injection model bool active() const; + //- Set injector locations when mesh is updated + virtual void updateMesh(); + //- Return the end-of-injection time scalar timeEnd() const; diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModel.C b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModel.C index 9aa65743f..aaf119dc5 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModel.C +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModel.C @@ -347,6 +347,12 @@ Foam::InjectionModel::~InjectionModel() // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // +template +void Foam::InjectionModel::updateMesh() +{ + // do nothing +} + template template void Foam::InjectionModel::inject(TrackData& td) @@ -360,6 +366,11 @@ void Foam::InjectionModel::inject(TrackData& td) const scalar carrierDt = owner_.db().time().deltaTValue(); const polyMesh& mesh = owner_.mesh(); + // BUGFIX HR 23.06.18: Force recalculation of global data because + // constrainToMeshCentre is inside of an if-statement + mesh.geometricD(); + mesh.bounds(); + // Prepare for next time step label parcelsAdded = 0; scalar massAdded = 0.0; diff --git a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModel.H b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModel.H index c00b3001a..2fcc59e72 100644 --- a/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModel.H +++ b/src/lagrangian/intermediate/submodels/Kinematic/InjectionModel/InjectionModel/InjectionModel.H @@ -260,6 +260,12 @@ public: virtual bool active() const = 0; + // Mapping + + //- Update mesh + virtual void updateMesh(); + + // Global information //- Return the start-of-injection time From 0d33286f17a342e2f92872e756c621152bff930e Mon Sep 17 00:00:00 2001 From: Henrik Rusche Date: Mon, 16 Jul 2018 12:11:02 +0200 Subject: [PATCH 3/8] BUGFIX: incremental switch merged incorrectly --- .../tractionBoundaryGradient.C | 28 +++++++++---------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/solidModels/constitutiveModel/tractionBoundaryGradient/tractionBoundaryGradient.C b/src/solidModels/constitutiveModel/tractionBoundaryGradient/tractionBoundaryGradient.C index b70845d04..01d483f65 100644 --- a/src/solidModels/constitutiveModel/tractionBoundaryGradient/tractionBoundaryGradient.C +++ b/src/solidModels/constitutiveModel/tractionBoundaryGradient/tractionBoundaryGradient.C @@ -551,23 +551,23 @@ Foam::tmp Foam::tractionBoundaryGradient::snGrad "((threeK*rho)*alpha)" ); - if (!incremental) - { - const fvPatchScalarField& DT = - patch.lookupPatchField("DT"); + if (incremental) + { + const fvPatchScalarField& DT = + patch.lookupPatchField("DT"); - gradient += n*threeKalpha*DT; - } - else - { - const fvPatchScalarField& T = - patch.lookupPatchField("T"); + gradient += n*threeKalpha*DT; + } + else + { + const fvPatchScalarField& T = + patch.lookupPatchField("T"); - const scalarField T0 = - thermo.T0()().boundaryField()[patch.index()]; + const scalarField T0 = + thermo.T0()().boundaryField()[patch.index()]; - gradient += n*threeKalpha*(T - T0); - } + gradient += n*threeKalpha*(T - T0); + } } // Higher order non-linear terms From f67382b044ff3f9be237c29dbcd6a7679b6453f1 Mon Sep 17 00:00:00 2001 From: Henrik Rusche Date: Fri, 20 Jul 2018 17:52:02 +0200 Subject: [PATCH 4/8] BACKPORT: MVC interpolation --- src/finiteVolume/CMakeLists.txt | 1 + src/finiteVolume/Make/files | 2 + .../interpolationPointMVC.C | 53 +++ .../interpolationPointMVC.H | 112 ++++++ .../interpolationPointMVCI.H | 53 +++ .../makeInterpolationPointMVC.C | 35 ++ .../interpolationPointMVC/pointMVCWeight.C | 324 ++++++++++++++++++ .../interpolationPointMVC/pointMVCWeight.H | 162 +++++++++ .../interpolationPointMVC/pointMVCWeightI.H | 48 +++ 9 files changed, 790 insertions(+) create mode 100644 src/finiteVolume/interpolation/interpolation/interpolationPointMVC/interpolationPointMVC.C create mode 100644 src/finiteVolume/interpolation/interpolation/interpolationPointMVC/interpolationPointMVC.H create mode 100644 src/finiteVolume/interpolation/interpolation/interpolationPointMVC/interpolationPointMVCI.H create mode 100644 src/finiteVolume/interpolation/interpolation/interpolationPointMVC/makeInterpolationPointMVC.C create mode 100644 src/finiteVolume/interpolation/interpolation/interpolationPointMVC/pointMVCWeight.C create mode 100644 src/finiteVolume/interpolation/interpolation/interpolationPointMVC/pointMVCWeight.H create mode 100644 src/finiteVolume/interpolation/interpolation/interpolationPointMVC/pointMVCWeightI.H diff --git a/src/finiteVolume/CMakeLists.txt b/src/finiteVolume/CMakeLists.txt index a85cd059e..ef40896bf 100644 --- a/src/finiteVolume/CMakeLists.txt +++ b/src/finiteVolume/CMakeLists.txt @@ -306,6 +306,7 @@ list(APPEND SOURCES ${interpolation}/interpolationCellPointFace/makeInterpolationCellPointFace.C ${interpolation}/interpolationCellPointWallModified/cellPointWeightWallModified/cellPointWeightWallModified.C ${interpolation}/interpolationCellPointWallModified/makeInterpolationCellPointWallModified.C + ${interpolation}/interpolationPointMVC/interpolationPointMVC.C ) set(volPointInterpolation interpolation/volPointInterpolation) diff --git a/src/finiteVolume/Make/files b/src/finiteVolume/Make/files index dbc7cacd5..efc3c98e7 100644 --- a/src/finiteVolume/Make/files +++ b/src/finiteVolume/Make/files @@ -238,6 +238,8 @@ $(interpolation)/interpolationCellPoint/makeInterpolationCellPoint.C $(interpolation)/interpolationCellPointFace/makeInterpolationCellPointFace.C $(interpolation)/interpolationCellPointWallModified/cellPointWeightWallModified/cellPointWeightWallModified.C $(interpolation)/interpolationCellPointWallModified/makeInterpolationCellPointWallModified.C +$(interpolation)/interpolationPointMVC/pointMVCWeight.C +$(interpolation)/interpolationPointMVC/makeInterpolationPointMVC.C volPointInterpolation = interpolation/volPointInterpolation $(volPointInterpolation)/pointPatchInterpolation/pointPatchInterpolation.C diff --git a/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/interpolationPointMVC.C b/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/interpolationPointMVC.C new file mode 100644 index 000000000..a4d318f7f --- /dev/null +++ b/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/interpolationPointMVC.C @@ -0,0 +1,53 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | Version: 4.1 + \\ / A nd | Web: http://www.foam-extend.org + \\/ M anipulation | For copyright notice see file Copyright +------------------------------------------------------------------------------- +License + This file is part of foam-extend. + + foam-extend 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. + + foam-extend 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 foam-extend. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "interpolationPointMVC.H" +#include "volPointInterpolation.H" + +// * * * * * * * * * * * * * * * * Constructor * * * * * * * * * * * * * * * // + +template +Foam::interpolationPointMVC::interpolationPointMVC +( + const GeometricField& psi +) +: + interpolation(psi), + psip_(volPointInterpolation::New(psi.mesh()).interpolate(psi)) +/* + psip_ + ( + volPointInterpolation::New(psi.mesh()).interpolate + ( + psi, + "volPointInterpolate(" + psi.name() + ')', + true // use cache + ) + ) +*/ +{} + + +// ************************************************************************* // diff --git a/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/interpolationPointMVC.H b/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/interpolationPointMVC.H new file mode 100644 index 000000000..bec28fdbf --- /dev/null +++ b/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/interpolationPointMVC.H @@ -0,0 +1,112 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | Version: 4.1 + \\ / A nd | Web: http://www.foam-extend.org + \\/ M anipulation | For copyright notice see file Copyright +------------------------------------------------------------------------------- +License + This file is part of foam-extend. + + foam-extend 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. + + foam-extend 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 foam-extend. If not, see . + +Class + Foam::interpolationPointMVC + +Description + Given cell centre values interpolates to vertices and uses these to + do a Mean Value Coordinates interpolation. + +\*---------------------------------------------------------------------------*/ + +#ifndef interpolationPointMVC_H +#define interpolationPointMVC_H + +#include "interpolation.H" +#include "pointMVCWeight.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class interpolationPointMVC Declaration +\*---------------------------------------------------------------------------*/ + +template +class interpolationPointMVC +: + public interpolation +{ +protected: + + // Protected data + + //- Interpolated volfield + const GeometricField psip_; + + +public: + + //- Runtime type information + TypeName("pointMVC"); + + + // Constructors + + //- Construct from components + interpolationPointMVC + ( + const GeometricField& psi + ); + + + // Member Functions + + //- Inherit interpolate from interpolation + using interpolation::interpolate; + + //- Interpolate field for the given cellPointWeight + inline Type interpolate(const pointMVCWeight& cpw) const; + + //- Interpolate field to the given point in the given cell + inline Type interpolate + ( + const vector& position, + const label celli, + const label facei = -1 + ) const; +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#include "interpolationPointMVCI.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository + #include "interpolationPointMVC.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/interpolationPointMVCI.H b/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/interpolationPointMVCI.H new file mode 100644 index 000000000..17d03a224 --- /dev/null +++ b/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/interpolationPointMVCI.H @@ -0,0 +1,53 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | Version: 4.1 + \\ / A nd | Web: http://www.foam-extend.org + \\/ M anipulation | For copyright notice see file Copyright +------------------------------------------------------------------------------- +License + This file is part of foam-extend. + + foam-extend 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. + + foam-extend 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 foam-extend. If not, see . + +\*---------------------------------------------------------------------------*/ + +// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // + +template +inline Type Foam::interpolationPointMVC::interpolate +( + const pointMVCWeight& cpw +) const +{ + return cpw.interpolate(psip_); +} + + +template +inline Type Foam::interpolationPointMVC::interpolate +( + const vector& position, + const label celli, + const label facei +) const +{ + return interpolate + ( + pointMVCWeight(this->pMesh_, position, celli, facei) + ); +} + + +// ************************************************************************* // diff --git a/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/makeInterpolationPointMVC.C b/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/makeInterpolationPointMVC.C new file mode 100644 index 000000000..582b575ad --- /dev/null +++ b/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/makeInterpolationPointMVC.C @@ -0,0 +1,35 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | Version: 4.1 + \\ / A nd | Web: http://www.foam-extend.org + \\/ M anipulation | For copyright notice see file Copyright +------------------------------------------------------------------------------- +License + This file is part of foam-extend. + + foam-extend 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. + + foam-extend 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 foam-extend. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "interpolationPointMVC.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + makeInterpolation(interpolationPointMVC); +} + +// ************************************************************************* // diff --git a/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/pointMVCWeight.C b/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/pointMVCWeight.C new file mode 100644 index 000000000..6a812aa34 --- /dev/null +++ b/src/finiteVolume/interpolation/interpolation/interpolationPointMVC/pointMVCWeight.C @@ -0,0 +1,324 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | Version: 4.1 + \\ / A nd | Web: http://www.foam-extend.org + \\/ M anipulation | For copyright notice see file Copyright +------------------------------------------------------------------------------- +License + This file is part of foam-extend. + + foam-extend 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. + + foam-extend 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 foam-extend. If not, see . + +\*---------------------------------------------------------------------------*/ + +#include "pointMVCWeight.H" +#include "polyMesh.H" + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +Foam::debug::debugSwitch +Foam::pointMVCWeight::debug +( + "pointMVCWeight", + 0 +); +Foam::scalar Foam::pointMVCWeight::tol(SMALL); + + +// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * // + +void Foam::pointMVCWeight::calcWeights +( + const Map