mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Finite area port, Hrvoje Jasak
- with sphereSurfactantFoam and sphereTransport test case
This commit is contained in:
committed by
Andrew Heather
parent
4c81ee202d
commit
0c64622341
@ -4,6 +4,8 @@ domainDecompositionMesh.C
|
||||
domainDecompositionDistribute.C
|
||||
dimFieldDecomposer.C
|
||||
pointFieldDecomposer.C
|
||||
faMeshDecomposition.C
|
||||
faFieldDecomposer.C
|
||||
lagrangianFieldDecomposer.C
|
||||
|
||||
EXE = $(FOAM_APPBIN)/decomposePar
|
||||
|
||||
@ -2,6 +2,7 @@ EXE_INC = \
|
||||
-I$(LIB_SRC)/parallel/decompose/decompose/lnInclude \
|
||||
-I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \
|
||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
||||
-I$(LIB_SRC)/finiteArea/lnInclude \
|
||||
-I$(LIB_SRC)/dynamicMesh/lnInclude \
|
||||
-I$(LIB_SRC)/lagrangian/basic/lnInclude \
|
||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||
@ -14,6 +15,7 @@ EXE_LIBS = \
|
||||
-ldecompositionMethods \
|
||||
-L$(FOAM_LIBBIN)/dummy \
|
||||
-lkahipDecomp -lmetisDecomp -lscotchDecomp \
|
||||
-lfiniteArea \
|
||||
-llagrangian \
|
||||
-ldynamicMesh \
|
||||
-lregionModels
|
||||
|
||||
@ -106,6 +106,11 @@ Usage
|
||||
#include "decompositionModel.H"
|
||||
#include "collatedFileOperation.H"
|
||||
|
||||
#include "faCFD.H"
|
||||
#include "emptyFaPatch.H"
|
||||
#include "faMeshDecomposition.H"
|
||||
#include "faFieldDecomposer.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
@ -1239,6 +1244,178 @@ int main(int argc, char *argv[])
|
||||
processorDbList.set(proci, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
// Finite area mesh and field decomposition
|
||||
|
||||
IOobject faMeshBoundaryIOobj
|
||||
(
|
||||
"faBoundary",
|
||||
mesh.time().findInstance
|
||||
(
|
||||
mesh.dbDir()/polyMesh::meshSubDir,
|
||||
"boundary"
|
||||
),
|
||||
faMesh::meshSubDir,
|
||||
mesh,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::NO_WRITE
|
||||
);
|
||||
|
||||
|
||||
if (faMeshBoundaryIOobj.typeHeaderOk<faBoundaryMesh>(true))
|
||||
{
|
||||
Info << "\nFinite area mesh decomposition" << endl;
|
||||
|
||||
faMeshDecomposition aMesh(mesh);
|
||||
|
||||
aMesh.decomposeMesh();
|
||||
|
||||
aMesh.writeDecomposition();
|
||||
|
||||
|
||||
// Construct the area fields
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
PtrList<areaScalarField> areaScalarFields;
|
||||
readFields(aMesh, objects, areaScalarFields);
|
||||
|
||||
PtrList<areaVectorField> areaVectorFields;
|
||||
readFields(aMesh, objects, areaVectorFields);
|
||||
|
||||
PtrList<areaSphericalTensorField> areaSphericalTensorFields;
|
||||
readFields(aMesh, objects, areaSphericalTensorFields);
|
||||
|
||||
PtrList<areaSymmTensorField> areaSymmTensorFields;
|
||||
readFields(aMesh, objects, areaSymmTensorFields);
|
||||
|
||||
PtrList<areaTensorField> areaTensorFields;
|
||||
readFields(aMesh, objects, areaTensorFields);
|
||||
|
||||
|
||||
// Construct the edge fields
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
PtrList<edgeScalarField> edgeScalarFields;
|
||||
readFields(aMesh, objects, edgeScalarFields);
|
||||
|
||||
Info << endl;
|
||||
|
||||
// Split the fields over processors
|
||||
for (label procI = 0; procI < mesh.nProcs(); procI++)
|
||||
{
|
||||
Info<< "Processor " << procI
|
||||
<< ": finite area field transfer" << endl;
|
||||
|
||||
// open the database
|
||||
Time processorDb
|
||||
(
|
||||
Time::controlDictName,
|
||||
args.rootPath(),
|
||||
args.caseName()/
|
||||
fileName(word("processor") + name(procI))
|
||||
);
|
||||
|
||||
processorDb.setTime(runTime);
|
||||
|
||||
// Read the mesh
|
||||
fvMesh procFvMesh
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
regionName,
|
||||
processorDb.timeName(),
|
||||
processorDb
|
||||
)
|
||||
);
|
||||
|
||||
faMesh procMesh(procFvMesh);
|
||||
|
||||
// // Does not work. HJ, 15/Aug/2017
|
||||
// const labelIOList& faceProcAddressing =
|
||||
// procAddressing
|
||||
// (
|
||||
// procMeshList,
|
||||
// procI,
|
||||
// "faceProcAddressing",
|
||||
// faceProcAddressingList
|
||||
// );
|
||||
|
||||
// const labelIOList& boundaryProcAddressing =
|
||||
// procAddressing
|
||||
// (
|
||||
// procMeshList,
|
||||
// procI,
|
||||
// "boundaryProcAddressing",
|
||||
// boundaryProcAddressingList
|
||||
// );
|
||||
|
||||
labelIOList faceProcAddressing
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"faceProcAddressing",
|
||||
"constant",
|
||||
procMesh.meshSubDir,
|
||||
procFvMesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
|
||||
labelIOList boundaryProcAddressing
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"boundaryProcAddressing",
|
||||
"constant",
|
||||
procMesh.meshSubDir,
|
||||
procFvMesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
|
||||
// FA fields
|
||||
if
|
||||
(
|
||||
areaScalarFields.size()
|
||||
|| areaVectorFields.size()
|
||||
|| areaSphericalTensorFields.size()
|
||||
|| areaSymmTensorFields.size()
|
||||
|| areaTensorFields.size()
|
||||
|| edgeScalarFields.size()
|
||||
)
|
||||
{
|
||||
labelIOList edgeProcAddressing
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
"edgeProcAddressing",
|
||||
"constant",
|
||||
procMesh.meshSubDir,
|
||||
procFvMesh,
|
||||
IOobject::MUST_READ,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
);
|
||||
|
||||
faFieldDecomposer fieldDecomposer
|
||||
(
|
||||
aMesh,
|
||||
procMesh,
|
||||
edgeProcAddressing,
|
||||
faceProcAddressing,
|
||||
boundaryProcAddressing
|
||||
);
|
||||
|
||||
fieldDecomposer.decomposeFields(areaScalarFields);
|
||||
fieldDecomposer.decomposeFields(areaVectorFields);
|
||||
fieldDecomposer.decomposeFields(areaSphericalTensorFields);
|
||||
fieldDecomposer.decomposeFields(areaSymmTensorFields);
|
||||
fieldDecomposer.decomposeFields(areaTensorFields);
|
||||
|
||||
fieldDecomposer.decomposeFields(edgeScalarFields);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,238 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd |
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2016-2017 Wikki Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "faFieldDecomposer.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
faFieldDecomposer::patchFieldDecomposer::patchFieldDecomposer
|
||||
(
|
||||
const label sizeBeforeMapping,
|
||||
const labelUList& addressingSlice,
|
||||
const label addressingOffset
|
||||
)
|
||||
:
|
||||
sizeBeforeMapping_(sizeBeforeMapping),
|
||||
directAddressing_(addressingSlice)
|
||||
{
|
||||
forAll (directAddressing_, i)
|
||||
{
|
||||
// Subtract one to align addressing.
|
||||
// directAddressing_[i] -= addressingOffset + 1;
|
||||
// ZT, 12/Nov/2010
|
||||
directAddressing_[i] -= addressingOffset;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
faFieldDecomposer::processorAreaPatchFieldDecomposer::
|
||||
processorAreaPatchFieldDecomposer
|
||||
(
|
||||
const faMesh& mesh,
|
||||
const labelUList& addressingSlice
|
||||
)
|
||||
:
|
||||
sizeBeforeMapping_(mesh.nFaces()),
|
||||
addressing_(addressingSlice.size()),
|
||||
weights_(addressingSlice.size())
|
||||
{
|
||||
const scalarField& weights = mesh.weights().internalField();
|
||||
const labelList& own = mesh.edgeOwner();
|
||||
const labelList& neighb = mesh.edgeNeighbour();
|
||||
|
||||
forAll (addressing_, i)
|
||||
{
|
||||
// Subtract one to align addressing.
|
||||
label ai = addressingSlice[i];
|
||||
// label ai = mag(addressingSlice[i]) - 1;
|
||||
|
||||
if (ai < neighb.size())
|
||||
{
|
||||
// This is a regular edge. it has been an internal edge
|
||||
// of the original mesh and now it has become a edge
|
||||
// on the parallel boundary
|
||||
addressing_[i].setSize(2);
|
||||
weights_[i].setSize(2);
|
||||
|
||||
addressing_[i][0] = own[ai];
|
||||
addressing_[i][1] = neighb[ai];
|
||||
|
||||
weights_[i][0] = weights[ai];
|
||||
weights_[i][1] = 1.0 - weights[ai];
|
||||
}
|
||||
else
|
||||
{
|
||||
// This is a edge that used to be on a cyclic boundary
|
||||
// but has now become a parallel patch edge. I cannot
|
||||
// do the interpolation properly (I would need to look
|
||||
// up the different (edge) list of data), so I will
|
||||
// just grab the value from the owner face
|
||||
//
|
||||
addressing_[i].setSize(1);
|
||||
weights_[i].setSize(1);
|
||||
|
||||
addressing_[i][0] = own[ai];
|
||||
|
||||
weights_[i][0] = 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
faFieldDecomposer::processorEdgePatchFieldDecomposer::
|
||||
processorEdgePatchFieldDecomposer
|
||||
(
|
||||
label sizeBeforeMapping,
|
||||
const labelUList& addressingSlice
|
||||
)
|
||||
:
|
||||
sizeBeforeMapping_(sizeBeforeMapping),
|
||||
addressing_(addressingSlice.size()),
|
||||
weights_(addressingSlice.size())
|
||||
{
|
||||
forAll (addressing_, i)
|
||||
{
|
||||
addressing_[i].setSize(1);
|
||||
weights_[i].setSize(1);
|
||||
|
||||
addressing_[i][0] = mag(addressingSlice[i]) - 1;
|
||||
weights_[i][0] = sign(addressingSlice[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
faFieldDecomposer::faFieldDecomposer
|
||||
(
|
||||
const faMesh& completeMesh,
|
||||
const faMesh& procMesh,
|
||||
const labelList& edgeAddressing,
|
||||
const labelList& faceAddressing,
|
||||
const labelList& boundaryAddressing
|
||||
)
|
||||
:
|
||||
completeMesh_(completeMesh),
|
||||
procMesh_(procMesh),
|
||||
edgeAddressing_(edgeAddressing),
|
||||
faceAddressing_(faceAddressing),
|
||||
boundaryAddressing_(boundaryAddressing),
|
||||
patchFieldDecomposerPtrs_
|
||||
(
|
||||
procMesh_.boundary().size(),
|
||||
static_cast<patchFieldDecomposer*>(NULL)
|
||||
),
|
||||
processorAreaPatchFieldDecomposerPtrs_
|
||||
(
|
||||
procMesh_.boundary().size(),
|
||||
static_cast<processorAreaPatchFieldDecomposer*>(NULL)
|
||||
),
|
||||
processorEdgePatchFieldDecomposerPtrs_
|
||||
(
|
||||
procMesh_.boundary().size(),
|
||||
static_cast<processorEdgePatchFieldDecomposer*>(NULL)
|
||||
)
|
||||
{
|
||||
forAll (boundaryAddressing_, patchi)
|
||||
{
|
||||
if (boundaryAddressing_[patchi] >= 0)
|
||||
{
|
||||
patchFieldDecomposerPtrs_[patchi] = new patchFieldDecomposer
|
||||
(
|
||||
completeMesh_.boundary()[boundaryAddressing_[patchi]].size(),
|
||||
procMesh_.boundary()[patchi].patchSlice(edgeAddressing_),
|
||||
// completeMesh_.boundaryMesh()
|
||||
completeMesh_.boundary()
|
||||
[
|
||||
boundaryAddressing_[patchi]
|
||||
].start()
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
processorAreaPatchFieldDecomposerPtrs_[patchi] =
|
||||
new processorAreaPatchFieldDecomposer
|
||||
(
|
||||
completeMesh_,
|
||||
procMesh_.boundary()[patchi].patchSlice(edgeAddressing_)
|
||||
);
|
||||
|
||||
processorEdgePatchFieldDecomposerPtrs_[patchi] =
|
||||
new processorEdgePatchFieldDecomposer
|
||||
(
|
||||
procMesh_.boundary()[patchi].size(),
|
||||
static_cast<const labelUList&>
|
||||
(
|
||||
procMesh_.boundary()[patchi].patchSlice
|
||||
(
|
||||
edgeAddressing_
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
faFieldDecomposer::~faFieldDecomposer()
|
||||
{
|
||||
forAll (patchFieldDecomposerPtrs_, patchi)
|
||||
{
|
||||
if (patchFieldDecomposerPtrs_[patchi])
|
||||
{
|
||||
delete patchFieldDecomposerPtrs_[patchi];
|
||||
}
|
||||
}
|
||||
|
||||
forAll (processorAreaPatchFieldDecomposerPtrs_, patchi)
|
||||
{
|
||||
if (processorAreaPatchFieldDecomposerPtrs_[patchi])
|
||||
{
|
||||
delete processorAreaPatchFieldDecomposerPtrs_[patchi];
|
||||
}
|
||||
}
|
||||
|
||||
forAll (processorEdgePatchFieldDecomposerPtrs_, patchi)
|
||||
{
|
||||
if (processorEdgePatchFieldDecomposerPtrs_[patchi])
|
||||
{
|
||||
delete processorEdgePatchFieldDecomposerPtrs_[patchi];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,319 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd |
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2016-2017 Wikki Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
faFieldDecomposer
|
||||
|
||||
Description
|
||||
Finite Area area and edge field decomposer.
|
||||
|
||||
Author
|
||||
Zeljko Tukovic, FSB Zagreb
|
||||
Hrvoje Jasak, Wikki Ltd.
|
||||
|
||||
SourceFiles
|
||||
faFieldDecomposer.C
|
||||
faFieldDecomposerDecomposeFields.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef faFieldDecomposer_H
|
||||
#define faFieldDecomposer_H
|
||||
|
||||
#include "faMesh.H"
|
||||
#include "faPatchFieldMapper.H"
|
||||
#include "edgeFields.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
class IOobjectList;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class faFieldDecomposer Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class faFieldDecomposer
|
||||
{
|
||||
public:
|
||||
|
||||
//- Patch field decomposer class
|
||||
class patchFieldDecomposer
|
||||
:
|
||||
public faPatchFieldMapper
|
||||
{
|
||||
// Private data
|
||||
|
||||
label sizeBeforeMapping_;
|
||||
labelList directAddressing_;
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct given addressing
|
||||
patchFieldDecomposer
|
||||
(
|
||||
const label sizeBeforeMapping,
|
||||
const labelUList& addressingSlice,
|
||||
const label addressingOffset
|
||||
);
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
label size() const
|
||||
{
|
||||
return directAddressing_.size();
|
||||
}
|
||||
|
||||
virtual label sizeBeforeMapping() const
|
||||
{
|
||||
return sizeBeforeMapping_;
|
||||
}
|
||||
|
||||
bool direct() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
virtual bool hasUnmapped() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const labelUList& directAddressing() const
|
||||
{
|
||||
return directAddressing_;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//- Processor patch field decomposer class
|
||||
class processorAreaPatchFieldDecomposer
|
||||
:
|
||||
public faPatchFieldMapper
|
||||
{
|
||||
// Private data
|
||||
|
||||
label sizeBeforeMapping_;
|
||||
labelListList addressing_;
|
||||
scalarListList weights_;
|
||||
|
||||
public:
|
||||
|
||||
//- Construct given addressing
|
||||
processorAreaPatchFieldDecomposer
|
||||
(
|
||||
const faMesh& mesh,
|
||||
const labelUList& addressingSlice
|
||||
);
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
label size() const
|
||||
{
|
||||
return addressing_.size();
|
||||
}
|
||||
|
||||
virtual label sizeBeforeMapping() const
|
||||
{
|
||||
return sizeBeforeMapping_;
|
||||
}
|
||||
|
||||
bool direct() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool hasUnmapped() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const labelListList& addressing() const
|
||||
{
|
||||
return addressing_;
|
||||
}
|
||||
|
||||
const scalarListList& weights() const
|
||||
{
|
||||
return weights_;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//- Processor patch field decomposer class
|
||||
class processorEdgePatchFieldDecomposer
|
||||
:
|
||||
public faPatchFieldMapper
|
||||
{
|
||||
label sizeBeforeMapping_;
|
||||
labelListList addressing_;
|
||||
scalarListList weights_;
|
||||
|
||||
public:
|
||||
|
||||
//- Construct given addressing
|
||||
processorEdgePatchFieldDecomposer
|
||||
(
|
||||
label sizeBeforeMapping,
|
||||
const labelUList& addressingSlice
|
||||
);
|
||||
|
||||
|
||||
// Member functions
|
||||
|
||||
label size() const
|
||||
{
|
||||
return addressing_.size();
|
||||
}
|
||||
|
||||
virtual label sizeBeforeMapping() const
|
||||
{
|
||||
return sizeBeforeMapping_;
|
||||
}
|
||||
|
||||
bool direct() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
virtual bool hasUnmapped() const
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const labelListList& addressing() const
|
||||
{
|
||||
return addressing_;
|
||||
}
|
||||
|
||||
const scalarListList& weights() const
|
||||
{
|
||||
return weights_;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
private:
|
||||
|
||||
// Private data
|
||||
|
||||
//- Reference to complete mesh
|
||||
const faMesh& completeMesh_;
|
||||
|
||||
//- Reference to processor mesh
|
||||
const faMesh& procMesh_;
|
||||
|
||||
//- Reference to edge addressing
|
||||
const labelList& edgeAddressing_;
|
||||
|
||||
//- Reference to face addressing
|
||||
const labelList& faceAddressing_;
|
||||
|
||||
//- Reference to boundary addressing
|
||||
const labelList& boundaryAddressing_;
|
||||
|
||||
//- List of patch field decomposers
|
||||
List<patchFieldDecomposer*> patchFieldDecomposerPtrs_;
|
||||
|
||||
List<processorAreaPatchFieldDecomposer*>
|
||||
processorAreaPatchFieldDecomposerPtrs_;
|
||||
|
||||
List<processorEdgePatchFieldDecomposer*>
|
||||
processorEdgePatchFieldDecomposerPtrs_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
//- Disallow default bitwise copy construct
|
||||
faFieldDecomposer(const faFieldDecomposer&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const faFieldDecomposer&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from components
|
||||
faFieldDecomposer
|
||||
(
|
||||
const faMesh& completeMesh,
|
||||
const faMesh& procMesh,
|
||||
const labelList& edgeAddressing,
|
||||
const labelList& faceAddressing,
|
||||
const labelList& boundaryAddressing
|
||||
);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
~faFieldDecomposer();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Decompose area field
|
||||
template<class Type>
|
||||
tmp<GeometricField<Type, faPatchField, areaMesh> >
|
||||
decomposeField
|
||||
(
|
||||
const GeometricField<Type, faPatchField, areaMesh>& field
|
||||
) const;
|
||||
|
||||
//- Decompose surface field
|
||||
template<class Type>
|
||||
tmp<GeometricField<Type, faePatchField, edgeMesh> >
|
||||
decomposeField
|
||||
(
|
||||
const GeometricField<Type, faePatchField, edgeMesh>& field
|
||||
) const;
|
||||
|
||||
template<class GeoField>
|
||||
void decomposeFields(const PtrList<GeoField>& fields) const;
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#ifdef NoRepository
|
||||
# include "faFieldDecomposerDecomposeFields.C"
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -0,0 +1,237 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd |
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2016-2017 Wikki Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "faFieldDecomposer.H"
|
||||
#include "processorFaPatchField.H"
|
||||
#include "processorFaePatchField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
tmp<GeometricField<Type, faPatchField, areaMesh> >
|
||||
faFieldDecomposer::decomposeField
|
||||
(
|
||||
const GeometricField<Type, faPatchField, areaMesh>& field
|
||||
) const
|
||||
{
|
||||
// Create and map the internal field values
|
||||
Field<Type> internalField(field.internalField(), faceAddressing_);
|
||||
|
||||
// Create and map the patch field values
|
||||
PtrList<faPatchField<Type> > patchFields(boundaryAddressing_.size());
|
||||
|
||||
forAll (boundaryAddressing_, patchi)
|
||||
{
|
||||
if (boundaryAddressing_[patchi] >= 0)
|
||||
{
|
||||
patchFields.set
|
||||
(
|
||||
patchi,
|
||||
faPatchField<Type>::New
|
||||
(
|
||||
field.boundaryField()[boundaryAddressing_[patchi]],
|
||||
procMesh_.boundary()[patchi],
|
||||
DimensionedField<Type, areaMesh>::null(),
|
||||
*patchFieldDecomposerPtrs_[patchi]
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
patchFields.set
|
||||
(
|
||||
patchi,
|
||||
new processorFaPatchField<Type>
|
||||
(
|
||||
procMesh_.boundary()[patchi],
|
||||
DimensionedField<Type, areaMesh>::null(),
|
||||
Field<Type>
|
||||
(
|
||||
field.internalField(),
|
||||
*processorAreaPatchFieldDecomposerPtrs_[patchi]
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Create the field for the processor
|
||||
return tmp<GeometricField<Type, faPatchField, areaMesh> >
|
||||
(
|
||||
new GeometricField<Type, faPatchField, areaMesh>
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
field.name(),
|
||||
procMesh_.time().timeName(),
|
||||
procMesh_(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
procMesh_,
|
||||
field.dimensions(),
|
||||
internalField,
|
||||
patchFields
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
tmp<GeometricField<Type, faePatchField, edgeMesh> >
|
||||
faFieldDecomposer::decomposeField
|
||||
(
|
||||
const GeometricField<Type, faePatchField, edgeMesh>& field
|
||||
) const
|
||||
{
|
||||
labelList mapAddr
|
||||
(
|
||||
labelList::subList
|
||||
(
|
||||
edgeAddressing_,
|
||||
procMesh_.nInternalEdges()
|
||||
)
|
||||
);
|
||||
forAll (mapAddr, i)
|
||||
{
|
||||
mapAddr[i] -= 1;
|
||||
}
|
||||
|
||||
// Create and map the internal field values
|
||||
Field<Type> internalField
|
||||
(
|
||||
field.internalField(),
|
||||
mapAddr
|
||||
);
|
||||
|
||||
// Problem with addressing when a processor patch picks up both internal
|
||||
// edges and edges from cyclic boundaries. This is a bit of a hack, but
|
||||
// I cannot find a better solution without making the internal storage
|
||||
// mechanism for edgeFields correspond to the one of edges in polyMesh
|
||||
// (i.e. using slices)
|
||||
Field<Type> allEdgeField(field.mesh().nEdges());
|
||||
|
||||
forAll (field.internalField(), i)
|
||||
{
|
||||
allEdgeField[i] = field.internalField()[i];
|
||||
}
|
||||
|
||||
forAll (field.boundaryField(), patchi)
|
||||
{
|
||||
const Field<Type> & p = field.boundaryField()[patchi];
|
||||
|
||||
const label patchStart = field.mesh().boundary()[patchi].start();
|
||||
|
||||
forAll (p, i)
|
||||
{
|
||||
allEdgeField[patchStart + i] = p[i];
|
||||
}
|
||||
}
|
||||
|
||||
// Create and map the patch field values
|
||||
PtrList<faePatchField<Type> > patchFields(boundaryAddressing_.size());
|
||||
|
||||
forAll (boundaryAddressing_, patchi)
|
||||
{
|
||||
if (boundaryAddressing_[patchi] >= 0)
|
||||
{
|
||||
patchFields.set
|
||||
(
|
||||
patchi,
|
||||
faePatchField<Type>::New
|
||||
(
|
||||
field.boundaryField()[boundaryAddressing_[patchi]],
|
||||
procMesh_.boundary()[patchi],
|
||||
DimensionedField<Type, edgeMesh>::null(),
|
||||
*patchFieldDecomposerPtrs_[patchi]
|
||||
)
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
patchFields.set
|
||||
(
|
||||
patchi,
|
||||
new processorFaePatchField<Type>
|
||||
(
|
||||
procMesh_.boundary()[patchi],
|
||||
DimensionedField<Type, edgeMesh>::null(),
|
||||
Field<Type>
|
||||
(
|
||||
allEdgeField,
|
||||
*processorEdgePatchFieldDecomposerPtrs_[patchi]
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Create the field for the processor
|
||||
return tmp<GeometricField<Type, faePatchField, edgeMesh> >
|
||||
(
|
||||
new GeometricField<Type, faePatchField, edgeMesh>
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
field.name(),
|
||||
procMesh_.time().timeName(),
|
||||
procMesh_(),
|
||||
IOobject::NO_READ,
|
||||
IOobject::NO_WRITE
|
||||
),
|
||||
procMesh_,
|
||||
field.dimensions(),
|
||||
internalField,
|
||||
patchFields
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
template<class GeoField>
|
||||
void faFieldDecomposer::decomposeFields
|
||||
(
|
||||
const PtrList<GeoField>& fields
|
||||
) const
|
||||
{
|
||||
forAll (fields, fieldI)
|
||||
{
|
||||
decomposeField(fields[fieldI])().write();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// ************************************************************************* //
|
||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,178 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd |
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2016-2017 Wikki Ltd
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
faMeshDecomposition
|
||||
|
||||
Description
|
||||
Automatic faMesh decomposition class
|
||||
|
||||
Author
|
||||
Zeljko Tukovic, FSB Zagreb
|
||||
Hrvoje Jasak, Wikki Ltd.
|
||||
|
||||
SourceFiles
|
||||
faMeshDecomposition.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef faMeshDecomposition_H
|
||||
#define faMeshDecomposition_H
|
||||
|
||||
#include "fvMesh.H"
|
||||
#include "faMesh.H"
|
||||
#include "labelList.H"
|
||||
#include "SLList.H"
|
||||
#include "PtrList.H"
|
||||
#include "point.H"
|
||||
|
||||
#ifndef namespaceFoam
|
||||
#define namespaceFoam
|
||||
using namespace Foam;
|
||||
#endif
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class faMeshDecomposition Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class faMeshDecomposition
|
||||
:
|
||||
public faMesh
|
||||
{
|
||||
// Private data
|
||||
|
||||
//- Mesh decomposition control dictionary
|
||||
IOdictionary decompositionDict_;
|
||||
|
||||
//- Number of processors in decomposition
|
||||
label nProcs_;
|
||||
|
||||
//- Is the decomposition data to be distributed for each processor
|
||||
bool distributed_;
|
||||
|
||||
//- Processor label for each cell
|
||||
labelList faceToProc_;
|
||||
|
||||
//- Face labels for each processor mesh
|
||||
labelListList procFaceLabels_;
|
||||
|
||||
//-
|
||||
List<Map<label> > procMeshEdgesMap_;
|
||||
|
||||
//- Number of internal edges for each processor mesh
|
||||
labelList procNInternalEdges_;
|
||||
|
||||
//- Edge labels for patches of processor meshes
|
||||
List<List<List<label> > > procPatchEdgeLabels_;
|
||||
|
||||
//- Labels of points for each processor
|
||||
labelListList procPatchPointAddressing_;
|
||||
|
||||
//- Labels of edges for each processor
|
||||
labelListList procPatchEdgeAddressing_;
|
||||
|
||||
//- Labels of edges for each processor
|
||||
labelListList procEdgeAddressing_;
|
||||
|
||||
//- Labels of faces for each processor
|
||||
labelListList procFaceAddressing_;
|
||||
|
||||
//- Original patch index for every processor patch
|
||||
labelListList procBoundaryAddressing_;
|
||||
|
||||
//- Sizes for processor mesh patches
|
||||
// Excludes inter-processor boundaries
|
||||
labelListList procPatchSize_;
|
||||
|
||||
//- Start indices for processor patches
|
||||
// Excludes inter-processor boundaries
|
||||
labelListList procPatchStartIndex_;
|
||||
|
||||
//- Neighbour processor ID for inter-processor boundaries
|
||||
labelListList procNeighbourProcessors_;
|
||||
|
||||
//- Sizes for inter-processor patches
|
||||
labelListList procProcessorPatchSize_;
|
||||
|
||||
//- Start indices for inter-processor patches
|
||||
labelListList procProcessorPatchStartIndex_;
|
||||
|
||||
//- List of globally shared point labels
|
||||
labelList globallySharedPoints_;
|
||||
|
||||
//- Are there cyclic-parallel faces
|
||||
bool cyclicParallel_;
|
||||
|
||||
|
||||
// Private Member Functions
|
||||
|
||||
void distributeFaces();
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from fvMesh
|
||||
faMeshDecomposition(const fvMesh& mesh);
|
||||
|
||||
|
||||
// Destructor
|
||||
|
||||
~faMeshDecomposition();
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Number of processor in decomposition
|
||||
label nProcs() const
|
||||
{
|
||||
return nProcs_;
|
||||
}
|
||||
|
||||
//- Is the decomposition data to be distributed for each processor
|
||||
bool distributed() const
|
||||
{
|
||||
return distributed_;
|
||||
}
|
||||
|
||||
//- Decompose mesh
|
||||
void decomposeMesh();
|
||||
|
||||
//- Write decomposition
|
||||
bool writeDecomposition();
|
||||
|
||||
//- Cell-processor decomposition labels
|
||||
const labelList& faceToProc() const
|
||||
{
|
||||
return faceToProc_;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
Reference in New Issue
Block a user