From 1e8847d71e1d40a006c7cf45119e6073c5ee88a7 Mon Sep 17 00:00:00 2001 From: Hrvoje Jasak Date: Tue, 1 May 2018 15:57:12 +0100 Subject: [PATCH] Refactor decompose/reconstruct tools for load balancing --- .../decomposeReconstruct/Make/files | 3 + .../finiteVolume/domainDecomposition.C | 8 - .../finiteVolume/fvFieldDecomposer.H | 5 +- .../fvFieldDecomposerDecomposeFields.C | 84 +++--- .../passiveProcessorFvPatchField.C | 112 ++++++++ .../passiveProcessorFvPatchField.H | 151 +++++++++++ .../passiveProcessorFvPatchFields.C | 43 ++++ .../passiveProcessorFvPatchFields.H | 49 ++++ .../passiveProcessorFvPatchFieldsFwd.H | 51 ++++ .../passiveProcessorFvsPatchField.C | 116 +++++++++ .../passiveProcessorFvsPatchField.H | 151 +++++++++++ .../passiveProcessorFvsPatchFields.C | 44 ++++ .../passiveProcessorFvsPatchFields.H | 49 ++++ .../passiveProcessorFvsPatchFieldsFwd.H | 51 ++++ .../finiteVolume/fvFieldReconstructor.H | 100 ++++---- .../fvFieldReconstructorReconstructFields.C | 242 +++++++++--------- 16 files changed, 1047 insertions(+), 212 deletions(-) create mode 100644 src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvPatchFields/passiveProcessor/passiveProcessorFvPatchField.C create mode 100644 src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvPatchFields/passiveProcessor/passiveProcessorFvPatchField.H create mode 100644 src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvPatchFields/passiveProcessor/passiveProcessorFvPatchFields.C create mode 100644 src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvPatchFields/passiveProcessor/passiveProcessorFvPatchFields.H create mode 100644 src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvPatchFields/passiveProcessor/passiveProcessorFvPatchFieldsFwd.H create mode 100644 src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvsPatchFields/passiveProcessor/passiveProcessorFvsPatchField.C create mode 100644 src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvsPatchFields/passiveProcessor/passiveProcessorFvsPatchField.H create mode 100644 src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvsPatchFields/passiveProcessor/passiveProcessorFvsPatchFields.C create mode 100644 src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvsPatchFields/passiveProcessor/passiveProcessorFvsPatchFields.H create mode 100644 src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvsPatchFields/passiveProcessor/passiveProcessorFvsPatchFieldsFwd.H diff --git a/src/decompositionMethods/decomposeReconstruct/Make/files b/src/decompositionMethods/decomposeReconstruct/Make/files index 0d3f4f821..ee9bfc9f7 100644 --- a/src/decompositionMethods/decomposeReconstruct/Make/files +++ b/src/decompositionMethods/decomposeReconstruct/Make/files @@ -1,6 +1,9 @@ passivePatches/passiveProcessorPolyPatch/passiveProcessorPolyPatch.C passivePatches/passiveProcessorFvPatch/passiveProcessorFvPatch.C +passivePatchFields/passiveFvPatchFields/passiveProcessor/passiveProcessorFvPatchFields.C +passivePatchFields/passiveFvsPatchFields/passiveProcessor/passiveProcessorFvsPatchFields.C + decomposeTools/finiteVolume/domainDecomposition.C decomposeTools/finiteVolume/distributeCells.C decomposeTools/finiteVolume/decomposeMesh.C diff --git a/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/domainDecomposition.C b/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/domainDecomposition.C index 67b12dd0f..a873dceb2 100644 --- a/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/domainDecomposition.C +++ b/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/domainDecomposition.C @@ -207,14 +207,6 @@ Foam::autoPtr Foam::domainDecomposition::processorMesh } // Create processor mesh without a boundary - Pout<< "RAW MESH: points: " << procPoints.size() - << " faces: " << procFaces.size() - << " owner: " << procOwner.size() - << " procNeighbour: " << procNeighbour.size() << nl - << "curPatchSizes: " << procPatchSize_[procI] << nl - << " curPatchStarts: " << procPatchStartIndex_[procI] << nl - << endl; - // Create the mesh autoPtr procMeshPtr ( new fvMesh diff --git a/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/fvFieldDecomposer.H b/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/fvFieldDecomposer.H index cbf16bbb2..b0323607e 100644 --- a/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/fvFieldDecomposer.H +++ b/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/fvFieldDecomposer.H @@ -253,9 +253,8 @@ public: ); - // Destructor - - ~fvFieldDecomposer(); + //- Destructor + ~fvFieldDecomposer(); // Member Functions diff --git a/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/fvFieldDecomposerDecomposeFields.C b/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/fvFieldDecomposerDecomposeFields.C index e32d72ab4..89950e2f0 100644 --- a/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/fvFieldDecomposerDecomposeFields.C +++ b/src/decompositionMethods/decomposeReconstruct/decomposeTools/finiteVolume/fvFieldDecomposerDecomposeFields.C @@ -47,38 +47,45 @@ fvFieldDecomposer::decomposeField // Create and map the patch field values PtrList > patchFields(boundaryAddressing_.size()); - forAll (boundaryAddressing_, patchi) + forAll (boundaryAddressing_, patchI) { - if (boundaryAddressing_[patchi] >= 0) + if (boundaryAddressing_[patchI] >= 0) { patchFields.set ( - patchi, + patchI, fvPatchField::New ( - field.boundaryField()[boundaryAddressing_[patchi]], - procMesh_.boundary()[patchi], + field.boundaryField()[boundaryAddressing_[patchI]], + procMesh_.boundary()[patchI], DimensionedField::null(), - *patchFieldDecomposerPtrs_[patchi] + *patchFieldDecomposerPtrs_[patchI] ) ); } else { + // This will be a processor or passiveProcessor field, + // depending on the patch type. Construct it first and set the + // data by hand patchFields.set ( - patchi, - new processorFvPatchField + patchI, + fvPatchField::New + // new processorFvPatchField ( - procMesh_.boundary()[patchi], - DimensionedField::null(), - Field - ( - field.internalField(), - *processorVolPatchFieldDecomposerPtrs_[patchi] - ) + procMesh_.boundary()[patchI].type(), + procMesh_.boundary()[patchI], + DimensionedField::null() ) ); + + patchFields[patchI] == + Field + ( + field.internalField(), + *processorVolPatchFieldDecomposerPtrs_[patchI] + ); } } @@ -135,7 +142,9 @@ fvFieldDecomposer::decomposeField // faces and faces from cyclic boundaries. This is a bit of a hack, but // I cannot find a better solution without making the internal storage // mechanism for surfaceFields correspond to the one of faces in polyMesh - // (i.e. using slices) + // (i.e. using slices). HJ, date unknown, before 2004 + + // Copy all face data into a single array across all patches Field allFaceField(field.mesh().nFaces()); forAll (field.internalField(), i) @@ -143,11 +152,11 @@ fvFieldDecomposer::decomposeField allFaceField[i] = field.internalField()[i]; } - forAll (field.boundaryField(), patchi) + forAll (field.boundaryField(), patchI) { - const Field & p = field.boundaryField()[patchi]; + const Field & p = field.boundaryField()[patchI]; - const label patchStart = field.mesh().boundaryMesh()[patchi].start(); + const label patchStart = field.mesh().boundaryMesh()[patchI].start(); forAll (p, i) { @@ -158,38 +167,45 @@ fvFieldDecomposer::decomposeField // Create and map the patch field values PtrList > patchFields(boundaryAddressing_.size()); - forAll (boundaryAddressing_, patchi) + forAll (boundaryAddressing_, patchI) { - if (boundaryAddressing_[patchi] >= 0) + if (boundaryAddressing_[patchI] >= 0) { patchFields.set ( - patchi, + patchI, fvsPatchField::New ( - field.boundaryField()[boundaryAddressing_[patchi]], - procMesh_.boundary()[patchi], + field.boundaryField()[boundaryAddressing_[patchI]], + procMesh_.boundary()[patchI], DimensionedField::null(), - *patchFieldDecomposerPtrs_[patchi] + *patchFieldDecomposerPtrs_[patchI] ) ); } else { + // This will be a processor or passiveProcessor field, + // depending on the patch type. Construct it first and set the + // data by hand patchFields.set ( - patchi, - new processorFvsPatchField + patchI, + fvsPatchField::New + // new processorFvsPatchField ( - procMesh_.boundary()[patchi], - DimensionedField::null(), - Field - ( - allFaceField, - *processorSurfacePatchFieldDecomposerPtrs_[patchi] - ) + procMesh_.boundary()[patchI].type(), + procMesh_.boundary()[patchI], + DimensionedField::null() ) ); + + patchFields[patchI] == + Field + ( + allFaceField, + *processorSurfacePatchFieldDecomposerPtrs_[patchI] + ); } } diff --git a/src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvPatchFields/passiveProcessor/passiveProcessorFvPatchField.C b/src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvPatchFields/passiveProcessor/passiveProcessorFvPatchField.C new file mode 100644 index 000000000..496ac394c --- /dev/null +++ b/src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvPatchFields/passiveProcessor/passiveProcessorFvPatchField.C @@ -0,0 +1,112 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | Version: 4.0 + \\ / 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 "passiveProcessorFvPatchField.H" +#include "passiveProcessorFvPatch.H" +#include "IPstream.H" +#include "OPstream.H" +#include "transformField.H" +#include "coeffFields.H" +#include "demandDrivenData.H" + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +Foam::passiveProcessorFvPatchField::passiveProcessorFvPatchField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fvPatchField(p, iF) +{} + + +template +Foam::passiveProcessorFvPatchField::passiveProcessorFvPatchField +( + const fvPatch& p, + const DimensionedField& iF, + const Field& f +) +: + fvPatchField(p, iF, f) +{} + + +template +Foam::passiveProcessorFvPatchField::passiveProcessorFvPatchField +( + const passiveProcessorFvPatchField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fvPatchField(ptf, p, iF, mapper) +{} + + +template +Foam::passiveProcessorFvPatchField::passiveProcessorFvPatchField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fvPatchField(p, iF, dict) +{} + + +template +Foam::passiveProcessorFvPatchField::passiveProcessorFvPatchField +( + const passiveProcessorFvPatchField& ptf +) +: + fvPatchField(ptf) +{} + + +template +Foam::passiveProcessorFvPatchField::passiveProcessorFvPatchField +( + const passiveProcessorFvPatchField& ptf, + const DimensionedField& iF +) +: + fvPatchField(ptf, iF) +{} + + +// * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * // + +template +Foam::passiveProcessorFvPatchField::~passiveProcessorFvPatchField() +{} + + +// ************************************************************************* // diff --git a/src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvPatchFields/passiveProcessor/passiveProcessorFvPatchField.H b/src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvPatchFields/passiveProcessor/passiveProcessorFvPatchField.H new file mode 100644 index 000000000..c37471378 --- /dev/null +++ b/src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvPatchFields/passiveProcessor/passiveProcessorFvPatchField.H @@ -0,0 +1,151 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | Version: 4.0 + \\ / 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::passiveProcessorFvPatchField + +Description + This patch field is used in parallel load balancing to communicate + future passiveProcessor data in parallel decomposition + +SourceFiles + passiveProcessorFvPatchField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef passiveProcessorFvPatchField_H +#define passiveProcessorFvPatchField_H + +#include "fvPatchField.H" +#include "passiveProcessorFvPatch.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class passiveProcessorFvPatchField Declaration +\*---------------------------------------------------------------------------*/ + +template +class passiveProcessorFvPatchField +: + public fvPatchField +{ +public: + + //- Runtime type information + TypeName(passiveProcessorFvPatch::typeName_()); + + + // Constructors + + //- Construct from patch and internal field + passiveProcessorFvPatchField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch and internal field and patch field + passiveProcessorFvPatchField + ( + const fvPatch&, + const DimensionedField&, + const Field& + ); + + //- Construct from patch, internal field and dictionary + passiveProcessorFvPatchField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given passiveProcessorFvPatchField + // onto a new patch + passiveProcessorFvPatchField + ( + const passiveProcessorFvPatchField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + passiveProcessorFvPatchField + ( + const passiveProcessorFvPatchField& + ); + + //- Construct and return a clone + virtual tmp > clone() const + { + return tmp > + ( + new passiveProcessorFvPatchField(*this) + ); + } + + //- Construct as copy setting internal field reference + passiveProcessorFvPatchField + ( + const passiveProcessorFvPatchField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp > clone + ( + const DimensionedField& iF + ) const + { + return tmp > + ( + new passiveProcessorFvPatchField(*this, iF) + ); + } + + + //- Destructor + virtual ~passiveProcessorFvPatchField(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "passiveProcessorFvPatchField.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvPatchFields/passiveProcessor/passiveProcessorFvPatchFields.C b/src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvPatchFields/passiveProcessor/passiveProcessorFvPatchFields.C new file mode 100644 index 000000000..263d356e1 --- /dev/null +++ b/src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvPatchFields/passiveProcessor/passiveProcessorFvPatchFields.C @@ -0,0 +1,43 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | Version: 4.0 + \\ / 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 "passiveProcessorFvPatchFields.H" +#include "addToRunTimeSelectionTable.H" +#include "volFields.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +makePatchFields(passiveProcessor); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvPatchFields/passiveProcessor/passiveProcessorFvPatchFields.H b/src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvPatchFields/passiveProcessor/passiveProcessorFvPatchFields.H new file mode 100644 index 000000000..cb576005e --- /dev/null +++ b/src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvPatchFields/passiveProcessor/passiveProcessorFvPatchFields.H @@ -0,0 +1,49 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | Version: 4.0 + \\ / 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 . + +\*---------------------------------------------------------------------------*/ + +#ifndef passiveProcessorFvPatchFields_H +#define passiveProcessorFvPatchFields_H + +#include "passiveProcessorFvPatchField.H" +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makePatchTypeFieldTypedefs(passiveProcessor) + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvPatchFields/passiveProcessor/passiveProcessorFvPatchFieldsFwd.H b/src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvPatchFields/passiveProcessor/passiveProcessorFvPatchFieldsFwd.H new file mode 100644 index 000000000..c21e87d14 --- /dev/null +++ b/src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvPatchFields/passiveProcessor/passiveProcessorFvPatchFieldsFwd.H @@ -0,0 +1,51 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | Version: 4.0 + \\ / 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 . + +\*---------------------------------------------------------------------------*/ + +#ifndef passiveProcessorFvPatchFieldsFwd_H +#define passiveProcessorFvPatchFieldsFwd_H + +#include "fvPatchField.H" +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template class passiveProcessorFvPatchField; + +makePatchTypeFieldTypedefs(passiveProcessor) + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvsPatchFields/passiveProcessor/passiveProcessorFvsPatchField.C b/src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvsPatchFields/passiveProcessor/passiveProcessorFvsPatchField.C new file mode 100644 index 000000000..cf25e6215 --- /dev/null +++ b/src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvsPatchFields/passiveProcessor/passiveProcessorFvsPatchField.C @@ -0,0 +1,116 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | Version: 4.0 + \\ / 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 "passiveProcessorFvsPatchField.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // + +template +passiveProcessorFvsPatchField::passiveProcessorFvsPatchField +( + const fvPatch& p, + const DimensionedField& iF +) +: + fvsPatchField(p, iF) +{} + + +template +passiveProcessorFvsPatchField::passiveProcessorFvsPatchField +( + const fvPatch& p, + const DimensionedField& iF, + const Field& f +) +: + fvsPatchField(p, iF, f) +{} + + +// Construct by mapping given passiveProcessorFvsPatchField +template +passiveProcessorFvsPatchField::passiveProcessorFvsPatchField +( + const passiveProcessorFvsPatchField& ptf, + const fvPatch& p, + const DimensionedField& iF, + const fvPatchFieldMapper& mapper +) +: + fvsPatchField(ptf, p, iF, mapper) +{} + + +template +passiveProcessorFvsPatchField::passiveProcessorFvsPatchField +( + const fvPatch& p, + const DimensionedField& iF, + const dictionary& dict +) +: + fvsPatchField(p, iF, dict) +{} + + +template +passiveProcessorFvsPatchField::passiveProcessorFvsPatchField +( + const passiveProcessorFvsPatchField& ptf +) +: + fvsPatchField(ptf) +{} + + +template +passiveProcessorFvsPatchField::passiveProcessorFvsPatchField +( + const passiveProcessorFvsPatchField& ptf, + const DimensionedField& iF +) +: + fvsPatchField(ptf, iF) +{} + + +// * * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * // + +template +passiveProcessorFvsPatchField::~passiveProcessorFvsPatchField() +{} + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvsPatchFields/passiveProcessor/passiveProcessorFvsPatchField.H b/src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvsPatchFields/passiveProcessor/passiveProcessorFvsPatchField.H new file mode 100644 index 000000000..45a310a30 --- /dev/null +++ b/src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvsPatchFields/passiveProcessor/passiveProcessorFvsPatchField.H @@ -0,0 +1,151 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | Version: 4.0 + \\ / 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::passiveProcessorFvsPatchField + +Description + This patch field is used in parallel load balancing to communicate + future processor data in parallel decomposition + +SourceFiles + passiveProcessorFvsPatchField.C + +\*---------------------------------------------------------------------------*/ + +#ifndef passiveProcessorFvsPatchField_H +#define passiveProcessorFvsPatchField_H + +#include "fvsPatchField.H" +#include "passiveProcessorFvPatch.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +/*---------------------------------------------------------------------------*\ + Class passiveProcessorFvsPatch Declaration +\*---------------------------------------------------------------------------*/ + +template +class passiveProcessorFvsPatchField +: + public fvsPatchField +{ +public: + + //- Runtime type information + TypeName(passiveProcessorFvPatch::typeName_()); + + + // Constructors + + //- Construct from patch and internal field + passiveProcessorFvsPatchField + ( + const fvPatch&, + const DimensionedField& + ); + + //- Construct from patch and internal field and patch field + passiveProcessorFvsPatchField + ( + const fvPatch&, + const DimensionedField&, + const Field& + ); + + //- Construct from patch, internal field and dictionary + passiveProcessorFvsPatchField + ( + const fvPatch&, + const DimensionedField&, + const dictionary& + ); + + //- Construct by mapping given passiveProcessorFvsPatchField + // onto a new patch + passiveProcessorFvsPatchField + ( + const passiveProcessorFvsPatchField&, + const fvPatch&, + const DimensionedField&, + const fvPatchFieldMapper& + ); + + //- Construct as copy + passiveProcessorFvsPatchField + ( + const passiveProcessorFvsPatchField& + ); + + //- Construct and return a clone + virtual tmp > clone() const + { + return tmp > + ( + new passiveProcessorFvsPatchField(*this) + ); + } + + //- Construct as copy setting internal field reference + passiveProcessorFvsPatchField + ( + const passiveProcessorFvsPatchField&, + const DimensionedField& + ); + + //- Construct and return a clone setting internal field reference + virtual tmp > clone + ( + const DimensionedField& iF + ) const + { + return tmp > + ( + new passiveProcessorFvsPatchField(*this, iF) + ); + } + + + //- Destructor + virtual ~passiveProcessorFvsPatchField(); +}; + + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#ifdef NoRepository +# include "passiveProcessorFvsPatchField.C" +#endif + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvsPatchFields/passiveProcessor/passiveProcessorFvsPatchFields.C b/src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvsPatchFields/passiveProcessor/passiveProcessorFvsPatchFields.C new file mode 100644 index 000000000..47c1216c9 --- /dev/null +++ b/src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvsPatchFields/passiveProcessor/passiveProcessorFvsPatchFields.C @@ -0,0 +1,44 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | Version: 4.0 + \\ / 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 "passiveProcessorFvsPatchFields.H" +#include "fvPatchFields.H" +#include "fvsPatchFields.H" +#include "addToRunTimeSelectionTable.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // + +makeFvsPatchFields(passiveProcessor); + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// ************************************************************************* // diff --git a/src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvsPatchFields/passiveProcessor/passiveProcessorFvsPatchFields.H b/src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvsPatchFields/passiveProcessor/passiveProcessorFvsPatchFields.H new file mode 100644 index 000000000..5d34c1a87 --- /dev/null +++ b/src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvsPatchFields/passiveProcessor/passiveProcessorFvsPatchFields.H @@ -0,0 +1,49 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | Version: 4.0 + \\ / 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 . + +\*---------------------------------------------------------------------------*/ + +#ifndef passiveProcessorFvsPatchFields_H +#define passiveProcessorFvsPatchFields_H + +#include "passiveProcessorFvsPatchField.H" +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +makeFvsPatchTypeFieldTypedefs(passiveProcessor) + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvsPatchFields/passiveProcessor/passiveProcessorFvsPatchFieldsFwd.H b/src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvsPatchFields/passiveProcessor/passiveProcessorFvsPatchFieldsFwd.H new file mode 100644 index 000000000..b1ceffbba --- /dev/null +++ b/src/decompositionMethods/decomposeReconstruct/passivePatchFields/passiveFvsPatchFields/passiveProcessor/passiveProcessorFvsPatchFieldsFwd.H @@ -0,0 +1,51 @@ +/*---------------------------------------------------------------------------*\ + ========= | + \\ / F ield | foam-extend: Open Source CFD + \\ / O peration | Version: 4.0 + \\ / 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 . + +\*---------------------------------------------------------------------------*/ + +#ifndef passiveProcessorFvsPatchFieldsFwd_H +#define passiveProcessorFvsPatchFieldsFwd_H + +#include "fvsPatchField.H" +#include "fieldTypes.H" + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +namespace Foam +{ + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +template class passiveProcessorFvsPatchField; + +makeFvsPatchTypeFieldTypedefs(passiveProcessor) + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +} // End namespace Foam + +// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // + +#endif + +// ************************************************************************* // diff --git a/src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume/fvFieldReconstructor.H b/src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume/fvFieldReconstructor.H index a1482069c..92d97a10f 100644 --- a/src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume/fvFieldReconstructor.H +++ b/src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume/fvFieldReconstructor.H @@ -153,57 +153,65 @@ public: // Member Functions - //- Reconstruct volume field data into a given field - // If a PtrList slot is empty, it is skipped - template - void reconstructFvVolumeField - ( - GeometricField& reconField, - const PtrList >& - procFields - ) const; + // Single field reconstruction + + //- Reconstruct volume field data into a given field + // If a PtrList slot is empty, it is skipped + template + void reconstructField + ( + GeometricField& reconField, + const PtrList >& + procFields + ) const; - //- Reconstruct volume field - template - tmp > - reconstructFvVolumeField - ( - const IOobject& fieldIoObject - ) const; + //- Reconstruct volume field data into a given field + // If a PtrList slot is empty, it is skipped + template + void reconstructField + ( + GeometricField& reconField, + const PtrList >& + procFields + ) const; - //- Reconstruct volume field data into a given field - // If a PtrList slot is empty, it is skipped - template - void reconstructFvSurfaceField - ( - GeometricField& reconField, - const PtrList >& - procFields - ) const; - //- Reconstruct surface field - template - tmp > - reconstructFvSurfaceField - ( - const IOobject& fieldIoObject - ) const; + // Reconstruct and return a single field + + //- Reconstruct volume field + template + tmp > + reconstructFvVolumeField + ( + const IOobject& fieldIoObject + ) const; - //- Reconstruct and write all/selected volume fields - template - void reconstructFvVolumeFields - ( - const IOobjectList& objects, - const HashSet& selectedFields - ) const; + //- Reconstruct surface field + template + tmp > + reconstructFvSurfaceField + ( + const IOobject& fieldIoObject + ) const; - //- Reconstruct and write all/selected volume fields - template - void reconstructFvSurfaceFields - ( - const IOobjectList& objects, - const HashSet& selectedFields - ) const; + + // Reconstruct and write all/selected fields + + //- Reconstruct and write all/selected volume fields + template + void reconstructFvVolumeFields + ( + const IOobjectList& objects, + const HashSet& selectedFields + ) const; + + //- Reconstruct and write all/selected volume fields + template + void reconstructFvSurfaceFields + ( + const IOobjectList& objects, + const HashSet& selectedFields + ) const; }; diff --git a/src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume/fvFieldReconstructorReconstructFields.C b/src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume/fvFieldReconstructorReconstructFields.C index 5d52249f1..77b2b9a9e 100644 --- a/src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume/fvFieldReconstructorReconstructFields.C +++ b/src/decompositionMethods/decomposeReconstruct/reconstructTools/finiteVolume/fvFieldReconstructorReconstructFields.C @@ -37,7 +37,7 @@ License // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * // template -void Foam::fvFieldReconstructor::reconstructFvVolumeField +void Foam::fvFieldReconstructor::reconstructField ( GeometricField& reconField, const PtrList >& procFields @@ -135,6 +135,124 @@ void Foam::fvFieldReconstructor::reconstructFvVolumeField } +template +void Foam::fvFieldReconstructor::reconstructField +( + GeometricField& reconField, + const PtrList >& procFields +) const +{ + // Create the internalField + Field& iField = reconField.internalField(); + + typename GeometricField:: + GeometricBoundaryField& bouField = reconField.boundaryField(); + + forAll (procFields, procI) + { + if (procFields.set(procI)) + { + const GeometricField& procField = + procFields[procI]; + + // Set the face values in the reconstructed field + + // It is necessary to create a copy of the addressing array to + // take care of the face direction offset trick. + // + { + labelList curAddr(faceProcAddressing_[procI]); + + forAll (curAddr, addrI) + { + curAddr[addrI] -= 1; + } + + iField.rmap + ( + procField.internalField(), + curAddr + ); + } + + // Set the boundary patch values in the reconstructed field + forAll (boundaryProcAddressing_[procI], patchI) + { + // Get patch index of the original patch + const label curBPatch = boundaryProcAddressing_[procI][patchI]; + + // Get addressing slice for this patch + const labelList::subList cp = + procMeshes_[procI].boundary()[patchI].patchSlice + ( + faceProcAddressing_[procI] + ); + + // Check if the boundary patch is not a processor patch + if (curBPatch >= 0) + { + // Regular patch. Fast looping + const label curPatchStart = + mesh_.boundaryMesh()[curBPatch].start(); + + labelList reverseAddressing(cp.size()); + + forAll (cp, faceI) + { + // Subtract one to take into account offsets for + // face direction. + reverseAddressing[faceI] = + cp[faceI] - 1 - curPatchStart; + } + + bouField[curBPatch].rmap + ( + procField.boundaryField()[patchI], + reverseAddressing + ); + } + else + { + const Field& curProcPatch = + procField.boundaryField()[patchI]; + + // In processor patches, there's a mix of internal faces + // (some of them turned) and possible cyclics. Slow loop + forAll (cp, faceI) + { + label curF = cp[faceI] - 1; + + // Is the face turned the right side round + if (curF >= 0) + { + // Is the face on the boundary? + if (curF >= mesh_.nInternalFaces()) + { + label curBPatch = + mesh_.boundaryMesh().whichPatch(curF); + + // Add the face + label curPatchFace = + mesh_.boundaryMesh() + [curBPatch].whichFace(curF); + + bouField[curBPatch][curPatchFace] = + curProcPatch[faceI]; + } + else + { + // Internal face + iField[curF] = curProcPatch[faceI]; + } + } + } + } + } + } + } +} + + template Foam::tmp > Foam::fvFieldReconstructor::reconstructFvVolumeField @@ -262,7 +380,7 @@ Foam::fvFieldReconstructor::reconstructFvVolumeField ); // Reconstruct field - reconstructFvVolumeField + this->reconstructField ( treconField(), procFields @@ -272,124 +390,6 @@ Foam::fvFieldReconstructor::reconstructFvVolumeField } -template -void Foam::fvFieldReconstructor::reconstructFvSurfaceField -( - GeometricField& reconField, - const PtrList >& procFields -) const -{ - // Create the internalField - Field& iField = reconField.internalField(); - - typename GeometricField:: - GeometricBoundaryField& bouField = reconField.boundaryField(); - - forAll (procFields, procI) - { - if (procFields.set(procI)) - { - const GeometricField& procField = - procFields[procI]; - - // Set the face values in the reconstructed field - - // It is necessary to create a copy of the addressing array to - // take care of the face direction offset trick. - // - { - labelList curAddr(faceProcAddressing_[procI]); - - forAll (curAddr, addrI) - { - curAddr[addrI] -= 1; - } - - iField.rmap - ( - procField.internalField(), - curAddr - ); - } - - // Set the boundary patch values in the reconstructed field - forAll (boundaryProcAddressing_[procI], patchI) - { - // Get patch index of the original patch - const label curBPatch = boundaryProcAddressing_[procI][patchI]; - - // Get addressing slice for this patch - const labelList::subList cp = - procMeshes_[procI].boundary()[patchI].patchSlice - ( - faceProcAddressing_[procI] - ); - - // Check if the boundary patch is not a processor patch - if (curBPatch >= 0) - { - // Regular patch. Fast looping - const label curPatchStart = - mesh_.boundaryMesh()[curBPatch].start(); - - labelList reverseAddressing(cp.size()); - - forAll (cp, faceI) - { - // Subtract one to take into account offsets for - // face direction. - reverseAddressing[faceI] = - cp[faceI] - 1 - curPatchStart; - } - - bouField[curBPatch].rmap - ( - procField.boundaryField()[patchI], - reverseAddressing - ); - } - else - { - const Field& curProcPatch = - procField.boundaryField()[patchI]; - - // In processor patches, there's a mix of internal faces - // (some of them turned) and possible cyclics. Slow loop - forAll (cp, faceI) - { - label curF = cp[faceI] - 1; - - // Is the face turned the right side round - if (curF >= 0) - { - // Is the face on the boundary? - if (curF >= mesh_.nInternalFaces()) - { - label curBPatch = - mesh_.boundaryMesh().whichPatch(curF); - - // Add the face - label curPatchFace = - mesh_.boundaryMesh() - [curBPatch].whichFace(curF); - - bouField[curBPatch][curPatchFace] = - curProcPatch[faceI]; - } - else - { - // Internal face - iField[curF] = curProcPatch[faceI]; - } - } - } - } - } - } - } -} - - template Foam::tmp > Foam::fvFieldReconstructor::reconstructFvSurfaceField @@ -517,7 +517,7 @@ Foam::fvFieldReconstructor::reconstructFvSurfaceField ); // Reconstruct field - reconstructFvSurfaceField + reconstructField ( treconField(), procFields