ENH: parallel: added -decomposeParDict option to

- foamyHexMesh
- snappyHexMesh
- decomposePar
This commit is contained in:
mattijs
2015-11-24 17:35:18 +00:00
parent f0cf39e020
commit c020702403
22 changed files with 265 additions and 202 deletions

View File

@ -16,6 +16,7 @@ EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \ -I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \
-I$(LIB_SRC)/parallel/decompose/decompose/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude \ -I$(LIB_SRC)/edgeMesh/lnInclude \
-I$(LIB_SRC)/fileFormats/lnInclude \ -I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude \
@ -29,6 +30,7 @@ EXE_INC = \
LIB_LIBS = \ LIB_LIBS = \
${CGAL_LIBS} \ ${CGAL_LIBS} \
-lmeshTools \ -lmeshTools \
-ldecompose \
-ledgeMesh \ -ledgeMesh \
-lfileFormats \ -lfileFormats \
-ltriSurface \ -ltriSurface \

View File

@ -30,6 +30,7 @@ License
#include "Time.H" #include "Time.H"
#include "Random.H" #include "Random.H"
#include "pointConversion.H" #include "pointConversion.H"
#include "decompositionModel.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * // // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
@ -149,7 +150,8 @@ void Foam::backgroundMeshDecomposition::initialRefinement()
const conformationSurfaces& geometry = geometryToConformTo_; const conformationSurfaces& geometry = geometryToConformTo_;
decompositionMethod& decomposer = decomposerPtr_(); decompositionMethod& decomposer =
decompositionModel::New(mesh_).decomposer();
volScalarField::InternalField& icellWeights = cellWeights.internalField(); volScalarField::InternalField& icellWeights = cellWeights.internalField();
@ -782,7 +784,8 @@ Foam::backgroundMeshDecomposition::backgroundMeshDecomposition
const Time& runTime, const Time& runTime,
Random& rndGen, Random& rndGen,
const conformationSurfaces& geometryToConformTo, const conformationSurfaces& geometryToConformTo,
const dictionary& coeffsDict const dictionary& coeffsDict,
const fileName& decompDictFile
) )
: :
runTime_(runTime), runTime_(runTime),
@ -810,18 +813,6 @@ Foam::backgroundMeshDecomposition::backgroundMeshDecomposition
bFTreePtr_(), bFTreePtr_(),
allBackgroundMeshBounds_(Pstream::nProcs()), allBackgroundMeshBounds_(Pstream::nProcs()),
globalBackgroundBounds_(), globalBackgroundBounds_(),
decomposeDict_
(
IOobject
(
"decomposeParDict",
runTime_.system(),
runTime_,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
),
decomposerPtr_(decompositionMethod::New(decomposeDict_)),
mergeDist_(1e-6*mesh_.bounds().mag()), mergeDist_(1e-6*mesh_.bounds().mag()),
spanScale_(readScalar(coeffsDict.lookup("spanScale"))), spanScale_(readScalar(coeffsDict.lookup("spanScale"))),
minCellSizeLimit_ minCellSizeLimit_
@ -846,14 +837,17 @@ Foam::backgroundMeshDecomposition::backgroundMeshDecomposition
<< exit(FatalError); << exit(FatalError);
} }
if (!decomposerPtr_().parallelAware()) const decompositionMethod& decomposer =
decompositionModel::New(mesh_, decompDictFile).decomposer();
if (!decomposer.parallelAware())
{ {
FatalErrorIn FatalErrorIn
( (
"void Foam::backgroundMeshDecomposition::initialRefinement() const" "void Foam::backgroundMeshDecomposition::initialRefinement() const"
) )
<< "You have selected decomposition method " << "You have selected decomposition method "
<< decomposerPtr_().typeName << decomposer.typeName
<< " which is not parallel aware." << endl << " which is not parallel aware." << endl
<< exit(FatalError); << exit(FatalError);
} }
@ -1008,7 +1002,10 @@ Foam::backgroundMeshDecomposition::distribute
<< endl; << endl;
} }
labelList newDecomp = decomposerPtr_().decompose decompositionMethod& decomposer =
decompositionModel::New(mesh_).decomposer();
labelList newDecomp = decomposer.decompose
( (
mesh_, mesh_,
mesh_.cellCentres(), mesh_.cellCentres(),

View File

@ -127,13 +127,7 @@ class backgroundMeshDecomposition
// a point that is not found on any processor is in the domain at all // a point that is not found on any processor is in the domain at all
treeBoundBox globalBackgroundBounds_; treeBoundBox globalBackgroundBounds_;
//- Decomposition dictionary //- merge distance required by fvMeshDistribute
IOdictionary decomposeDict_;
//- Decomposition method
autoPtr<decompositionMethod> decomposerPtr_;
//- Merge distance required by fvMeshDistribute
scalar mergeDist_; scalar mergeDist_;
//- Scale of a cell span vs cell size used to decide to refine a cell //- Scale of a cell span vs cell size used to decide to refine a cell
@ -204,7 +198,8 @@ public:
const Time& runTime, const Time& runTime,
Random& rndGen, Random& rndGen,
const conformationSurfaces& geometryToConformTo, const conformationSurfaces& geometryToConformTo,
const dictionary& coeffsDict const dictionary& coeffsDict,
const fileName& decompDictFile = ""
); );
@ -324,8 +319,6 @@ public:
//- Return the point level of the underlying mesh //- Return the point level of the underlying mesh
inline const labelList& pointLevel() const; inline const labelList& pointLevel() const;
//- Return the current decomposition method
inline const decompositionMethod& decomposer() const;
}; };

View File

@ -57,11 +57,4 @@ const Foam::labelList& Foam::backgroundMeshDecomposition::pointLevel() const
} }
const Foam::decompositionMethod&
Foam::backgroundMeshDecomposition::decomposer() const
{
return decomposerPtr_();
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -392,61 +392,59 @@ Foam::cellShapeControlMesh::cellShapeControlMesh(const Time& runTime)
if (mesh.nPoints() == this->vertexCount()) if (mesh.nPoints() == this->vertexCount())
{ {
pointScalarField sizes IOobject io
( (
IOobject "sizes",
( runTime.timeName(),
"sizes", meshSubDir,
runTime.timeName(), runTime,
meshSubDir, IOobject::MUST_READ,
runTime, IOobject::NO_WRITE,
IOobject::READ_IF_PRESENT, false
IOobject::NO_WRITE,
false
),
pointMesh::New(mesh)
); );
triadIOField alignments if (io.headerOk())
(
IOobject
(
"alignments",
mesh.time().timeName(),
meshSubDir,
mesh.time(),
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE,
false
)
);
if
(
sizes.size() == this->vertexCount()
&& alignments.size() == this->vertexCount()
)
{ {
for pointScalarField sizes(io, pointMesh::New(mesh));
triadIOField alignments
( (
Finite_vertices_iterator vit = finite_vertices_begin(); IOobject
vit != finite_vertices_end(); (
++vit "alignments",
) mesh.time().timeName(),
meshSubDir,
mesh.time(),
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
if (alignments.size() == this->vertexCount())
{ {
vit->targetCellSize() = sizes[vit->index()]; for
vit->alignment() = alignments[vit->index()]; (
Finite_vertices_iterator vit = finite_vertices_begin();
vit != finite_vertices_end();
++vit
)
{
vit->targetCellSize() = sizes[vit->index()];
vit->alignment() = alignments[vit->index()];
}
}
else
{
FatalErrorIn
(
"Foam::cellShapeControlMesh::cellShapeControlMesh"
"(const Time&)"
) << "Cell alignments point field " << alignments.size()
<< " is not the same size as the number of vertices"
<< " in the mesh " << this->vertexCount()
<< abort(FatalError);
} }
}
else
{
FatalErrorIn
(
"Foam::cellShapeControlMesh::cellShapeControlMesh"
"(const Time&)"
) << "Cell size point field is not the same size as the "
<< "mesh."
<< abort(FatalError);
} }
} }
} }
@ -672,7 +670,7 @@ void Foam::cellShapeControlMesh::write() const
IOobject::AUTO_WRITE IOobject::AUTO_WRITE
), ),
pointMesh::New(mesh), pointMesh::New(mesh),
scalar(0) dimensionedScalar("zero", dimLength, scalar(0))
); );
triadIOField alignments triadIOField alignments

View File

@ -837,7 +837,8 @@ bool Foam::conformalVoronoiMesh::ownerAndNeighbour
Foam::conformalVoronoiMesh::conformalVoronoiMesh Foam::conformalVoronoiMesh::conformalVoronoiMesh
( (
const Time& runTime, const Time& runTime,
const dictionary& foamyHexMeshDict const dictionary& foamyHexMeshDict,
const fileName& decompDictFile
) )
: :
DistributedDelaunayMesh<Delaunay>(runTime), DistributedDelaunayMesh<Delaunay>(runTime),
@ -876,7 +877,8 @@ Foam::conformalVoronoiMesh::conformalVoronoiMesh
foamyHexMeshControls().foamyHexMeshDict().subDict foamyHexMeshControls().foamyHexMeshDict().subDict
( (
"backgroundMeshDecomposition" "backgroundMeshDecomposition"
) ),
decompDictFile
) )
: NULL : NULL
), ),

View File

@ -163,10 +163,8 @@ private:
//- Limiting bound box before infinity begins //- Limiting bound box before infinity begins
treeBoundBox limitBounds_; treeBoundBox limitBounds_;
//-
mutable pointPairs<Delaunay> ptPairs_; mutable pointPairs<Delaunay> ptPairs_;
//-
featurePointConformer ftPtConformer_; featurePointConformer ftPtConformer_;
//- Search tree for edge point locations //- Search tree for edge point locations
@ -546,7 +544,7 @@ private:
) const; ) const;
//- Check if a location is in the exclusion range of an existing feature //- Check if a location is in the exclusion range of an existing feature
//- Edge conformation location // edge conformation location
bool nearFeatureEdgeLocation bool nearFeatureEdgeLocation
( (
const pointIndexHit& pHit, const pointIndexHit& pHit,
@ -730,8 +728,7 @@ private:
label classifyBoundaryPoint(Cell_handle cit) const; label classifyBoundaryPoint(Cell_handle cit) const;
//- Index all of the the Delaunay cells and calculate their //- Index all of the the Delaunay cells and calculate their dual points
//- Dual points
void indexDualVertices void indexDualVertices
( (
pointField& pts, pointField& pts,
@ -874,7 +871,8 @@ public:
conformalVoronoiMesh conformalVoronoiMesh
( (
const Time& runTime, const Time& runTime,
const dictionary& foamyHexMeshDict const dictionary& foamyHexMeshDict,
const fileName& decompDictFile = ""
); );

View File

@ -1292,9 +1292,9 @@ void Foam::conformalVoronoiMesh::indexDualVertices
} }
} }
OBJstream snapping1("snapToSurface1.obj"); //OBJstream snapping1("snapToSurface1.obj");
OBJstream snapping2("snapToSurface2.obj"); //OBJstream snapping2("snapToSurface2.obj");
OFstream tetToSnapTo("tetsToSnapTo.obj"); //OFstream tetToSnapTo("tetsToSnapTo.obj");
for for
( (

View File

@ -88,15 +88,13 @@ class indexedCell
// Private data // Private data
//- The index for this Delaunay tetrahedral cell. Type information is //- The index for this Delaunay tetrahedral cell. Type information is
//- Also carried: // also carried:
// ctFar : the dual point of this cell does not form part of the // ctFar : the dual point of this cell does not form part of the
// internal or boundary of the dual mesh // internal or boundary of the dual mesh
// >=0 : the (local) index of an internal or boundary dual point, // >=0 : the (local) index of an internal or boundary dual point,
// not on a processor face // not on a processor face
// < 0 && > ctFar : the (global) index of a dual point on a processor // < 0 && > ctFar : the (global) index of a dual point on a processor
// face // face
Foam::label index_; Foam::label index_;
//- The number of times that this Delaunay cell has been limited //- The number of times that this Delaunay cell has been limited

View File

@ -30,7 +30,8 @@ EXE_LIBS = \
-lconformalVoronoiMesh \ -lconformalVoronoiMesh \
-lmeshTools \ -lmeshTools \
-ldecompositionMethods \ -ldecompositionMethods \
-L$(FOAM_LIBBIN)/dummy -lptscotchDecomp \ -ldecompose \
-L$(FOAM_LIBBIN)/dummy -lptscotchDecomp -lscotchDecomp \
-ledgeMesh \ -ledgeMesh \
-lfileFormats \ -lfileFormats \
-ltriSurface \ -ltriSurface \

View File

@ -62,6 +62,17 @@ int main(int argc, char *argv[])
const bool checkGeometry = args.optionFound("checkGeometry"); const bool checkGeometry = args.optionFound("checkGeometry");
const bool conformationOnly = args.optionFound("conformationOnly"); const bool conformationOnly = args.optionFound("conformationOnly");
// Allow override of decomposeParDict location
fileName decompDictFile;
if (args.optionReadIfPresent("decomposeParDict", decompDictFile))
{
if (isDir(decompDictFile))
{
decompDictFile = decompDictFile / "decomposeParDict";
}
}
IOdictionary foamyHexMeshDict IOdictionary foamyHexMeshDict
( (
IOobject IOobject
@ -114,7 +125,7 @@ int main(int argc, char *argv[])
Info<< "Create mesh for time = " << runTime.timeName() << nl << endl; Info<< "Create mesh for time = " << runTime.timeName() << nl << endl;
conformalVoronoiMesh mesh(runTime, foamyHexMeshDict); conformalVoronoiMesh mesh(runTime, foamyHexMeshDict, decompDictFile);
if (conformationOnly) if (conformationOnly)
@ -145,7 +156,7 @@ int main(int argc, char *argv[])
} }
Info<< nl << "End" << nl << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -271,11 +271,18 @@ motionControl
forceInitialPointInsertion on; forceInitialPointInsertion on;
priority 1; priority 1;
mode inside; mode inside;
// Cell size at surface
surfaceCellSizeFunction uniformValue; surfaceCellSizeFunction uniformValue;
uniformValueCoeffs uniformValueCoeffs
{ {
surfaceCellSizeCoeff 0.5; surfaceCellSizeCoeff 0.5;
} }
// Cell size inside domain by having a region of thickness
// surfaceOffsetaround the surface with the surface cell size
// (so constant) and then down to distanceCellSize over a distance
// of linearDistance.
cellSizeFunction surfaceOffsetLinearDistance; cellSizeFunction surfaceOffsetLinearDistance;
surfaceOffsetLinearDistanceCoeffs surfaceOffsetLinearDistanceCoeffs
{ {
@ -375,9 +382,17 @@ polyMeshFiltering
// Filter small and sliver faces // Filter small and sliver faces
filterFaces off; filterFaces off;
// Write the underlying Delaunay tet mesh at output time // Write the underlying Delaunay tet mesh (at output time)
writeTetDualMesh false; writeTetDualMesh false;
// Write the Delaunay tet mesh used for interpolating cell size and
// alignment (at output time)
writeCellShapeControlMesh true;
// Write the hex/split-hex mesh used for parallel load balancing
// (at output time)
writeBackgroundMeshDecomposition true;
// Upper limit on the size of faces to be filtered. // Upper limit on the size of faces to be filtered.
// fraction of the local target cell size // fraction of the local target cell size
filterSizeCoeff 0.2; filterSizeCoeff 0.2;

View File

@ -9,6 +9,7 @@ EXE_INC = \
${CGAL_INC} \ ${CGAL_INC} \
-I../conformalVoronoiMesh/lnInclude \ -I../conformalVoronoiMesh/lnInclude \
-I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \ -I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \
-I$(LIB_SRC)/parallel/decompose/decompose/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude \ -I$(LIB_SRC)/edgeMesh/lnInclude \
-I$(LIB_SRC)/mesh/autoMesh/lnInclude \ -I$(LIB_SRC)/mesh/autoMesh/lnInclude \
-I$(LIB_SRC)/triSurface/lnInclude \ -I$(LIB_SRC)/triSurface/lnInclude \
@ -26,6 +27,7 @@ EXE_LIBS = \
-lgmp \ -lgmp \
-lconformalVoronoiMesh \ -lconformalVoronoiMesh \
-ldecompositionMethods /* -L$(FOAM_LIBBIN)/dummy -lscotchDecomp */ \ -ldecompositionMethods /* -L$(FOAM_LIBBIN)/dummy -lscotchDecomp */ \
-ldecompose \
-ledgeMesh \ -ledgeMesh \
-ltriSurface \ -ltriSurface \
-lmeshTools \ -lmeshTools \

View File

@ -44,6 +44,7 @@ Description
#include "isoSurfaceCell.H" #include "isoSurfaceCell.H"
#include "vtkSurfaceWriter.H" #include "vtkSurfaceWriter.H"
#include "syncTools.H" #include "syncTools.H"
#include "decompositionModel.H"
using namespace Foam; using namespace Foam;
@ -467,7 +468,7 @@ int main(int argc, char *argv[])
// Determine the number of cells in each direction. // Determine the number of cells in each direction.
const vector span = bb.span(); const vector span = bb.span();
vector nScalarCells = span/cellShapeControls().defaultCellSize(); vector nScalarCells = span/cellShapeControls.defaultCellSize();
// Calculate initial cell size to be a little bit smaller than the // Calculate initial cell size to be a little bit smaller than the
// defaultCellSize to avoid initial refinement triggering. // defaultCellSize to avoid initial refinement triggering.
@ -521,28 +522,21 @@ int main(int argc, char *argv[])
Info<< "Loaded mesh:" << endl; Info<< "Loaded mesh:" << endl;
printMeshData(mesh); printMeshData(mesh);
// Allocate a decomposer // Allow override of decomposeParDict location
IOdictionary decompositionDict fileName decompDictFile;
( if (args.optionReadIfPresent("decomposeParDict", decompDictFile))
IOobject {
( if (isDir(decompDictFile))
"decomposeParDict", {
runTime.system(), decompDictFile = decompDictFile / "decomposeParDict";
mesh, }
IOobject::MUST_READ_IF_MODIFIED, }
IOobject::NO_WRITE
)
);
autoPtr<decompositionMethod> decomposer labelList decomp = decompositionModel::New
( (
decompositionMethod::New mesh,
( decompDictFile
decompositionDict ).decomposer().decompose(mesh, mesh.cellCentres());
)
);
labelList decomp = decomposer().decompose(mesh, mesh.cellCentres());
// Global matching tolerance // Global matching tolerance
const scalar tolDim = getMergeDistance const scalar tolDim = getMergeDistance
@ -574,18 +568,15 @@ int main(int argc, char *argv[])
Info<< "Refining backgroud mesh according to cell size specification" << nl Info<< "Refining backgroud mesh according to cell size specification" << nl
<< endl; << endl;
const dictionary& backgroundMeshDict =
foamyHexMeshDict.subDict("backgroundMeshDecomposition");
backgroundMeshDecomposition backgroundMesh backgroundMeshDecomposition backgroundMesh
( (
1.0, //spanScale,ratio of poly cell size v.s. hex cell size
0.0, //minCellSizeLimit
0, //minLevels
4, //volRes, check multiple points per cell
20.0, //maxCellWeightCoeff
runTime, runTime,
geometryToConformTo,
cellShapeControls(),
rndGen, rndGen,
foamyHexMeshDict geometryToConformTo,
backgroundMeshDict
); );
if (writeMesh) if (writeMesh)

View File

@ -221,7 +221,7 @@ int main(int argc, char *argv[])
Info<< "Finished extruding in = " Info<< "Finished extruding in = "
<< runTime.cpuTimeIncrement() << " s." << endl; << runTime.cpuTimeIncrement() << " s." << endl;
Info<< nl << "End\n" << endl; Info<< "\nEnd\n" << endl;
return 0; return 0;
} }

View File

@ -8,14 +8,18 @@ EXE_INC = \
-I$(LIB_SRC)/surfMesh/lnInclude \ -I$(LIB_SRC)/surfMesh/lnInclude \
-I$(LIB_SRC)/dynamicMesh/lnInclude \ -I$(LIB_SRC)/dynamicMesh/lnInclude \
-I$(LIB_SRC)/edgeMesh/lnInclude \ -I$(LIB_SRC)/edgeMesh/lnInclude \
-I$(LIB_SRC)/parallel/decompose/decompose/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude -I$(LIB_SRC)/finiteVolume/lnInclude
EXE_LIBS = \ EXE_LIBS = \
-lfiniteVolume \ -lfiniteVolume \
-ldecompositionMethods \ -ldecompositionMethods \
-L$(FOAM_LIBBIN)/dummy -lptscotchDecomp \ -L$(FOAM_LIBBIN)/dummy -lptscotchDecomp \
/* note: scotch < 6.0 does not like both scotch and ptscotch together */ \
-lscotchDecomp \
-lmeshTools \ -lmeshTools \
-lsurfMesh \ -lsurfMesh \
-lfileFormats \ -lfileFormats \
-ldynamicMesh \ -ldynamicMesh \
-ldecompose \
-lautoMesh -lautoMesh

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -57,6 +57,7 @@ Description
#include "MeshedSurface.H" #include "MeshedSurface.H"
#include "globalIndex.H" #include "globalIndex.H"
#include "IOmanip.H" #include "IOmanip.H"
#include "decompositionModel.H"
using namespace Foam; using namespace Foam;
@ -819,15 +820,28 @@ int main(int argc, char *argv[])
{ {
if (Pstream::parRun()) if (Pstream::parRun())
{ {
fileName decompDictFile;
if (args.optionReadIfPresent("decomposeParDict", decompDictFile))
{
if (isDir(decompDictFile))
{
decompDictFile = decompDictFile/"decomposeParDict";
}
}
decomposeDict = IOdictionary decomposeDict = IOdictionary
( (
IOobject decompositionModel::selectIO
( (
"decomposeParDict", IOobject
runTime.system(), (
mesh, "decomposeParDict",
IOobject::MUST_READ_IF_MODIFIED, runTime.system(),
IOobject::NO_WRITE mesh,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
),
decompDictFile
) )
); );
} }

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation | Copyright (C) 2015 OpenCFD Ltd. \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -143,7 +143,7 @@ int main(int argc, char *argv[])
); );
argList::noParallel(); argList::noParallel();
Foam::argList::addOption argList::addOption
( (
"decomposeParDict", "decomposeParDict",
"file", "file",

View File

@ -2,6 +2,8 @@ EXE_INC = \
-I$(LIB_SRC)/meshTools/lnInclude \ -I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/lagrangian/basic/lnInclude \ -I$(LIB_SRC)/lagrangian/basic/lnInclude \
-I$(LIB_SRC)/finiteVolume/lnInclude \ -I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/parallel/decompose/decompose/lnInclude \
-I$(LIB_SRC)/parallel/decompose/decompositionMethods/lnInclude \
-I$(LIB_SRC)/sampling/lnInclude -I$(LIB_SRC)/sampling/lnInclude
EXE_LIBS = \ EXE_LIBS = \
@ -9,4 +11,5 @@ EXE_LIBS = \
-lmeshTools \ -lmeshTools \
-llagrangian \ -llagrangian \
-lfiniteVolume \ -lfiniteVolume \
-ldecompose \
-lgenericPatchFields -lgenericPatchFields

View File

@ -36,9 +36,48 @@ Description
#include "meshToMesh0.H" #include "meshToMesh0.H"
#include "processorFvPatch.H" #include "processorFvPatch.H"
#include "MapMeshes.H" #include "MapMeshes.H"
#include "decompositionModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int readNumProcs
(
const argList& args,
const word& optionName,
const Time& runTime
)
{
fileName dictFile;
if (args.optionReadIfPresent(optionName, dictFile))
{
if (isDir(dictFile))
{
dictFile = dictFile/"decomposeParDict";
}
}
return readInt
(
IOdictionary
(
decompositionModel::selectIO
(
IOobject
(
"decomposeParDict",
runTime.system(),
runTime,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE,
false
),
dictFile
)
).lookup("numberOfSubdomains")
);
}
void mapConsistentMesh void mapConsistentMesh
( (
const fvMesh& meshSource, const fvMesh& meshSource,
@ -225,6 +264,19 @@ int main(int argc, char *argv[])
"subtract", "subtract",
"subtract mapped source from target" "subtract mapped source from target"
); );
argList::addOption
(
"sourceDecomposeParDict",
"file",
"read decomposePar dictionary from specified location"
);
argList::addOption
(
"targetDecomposeParDict",
"file",
"read decomposePar dictionary from specified location"
);
argList args(argc, argv); argList args(argc, argv);
@ -320,20 +372,13 @@ int main(int argc, char *argv[])
if (parallelSource && !parallelTarget) if (parallelSource && !parallelTarget)
{ {
IOdictionary decompositionDict int nProcs = readNumProcs
( (
IOobject args,
( "sourceDecomposeParDict",
"decomposeParDict", runTimeSource
runTimeSource.system(),
runTimeSource,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
); );
int nProcs(readInt(decompositionDict.lookup("numberOfSubdomains")));
Info<< "Create target mesh\n" << endl; Info<< "Create target mesh\n" << endl;
fvMesh meshTarget fvMesh meshTarget
@ -399,19 +444,13 @@ int main(int argc, char *argv[])
} }
else if (!parallelSource && parallelTarget) else if (!parallelSource && parallelTarget)
{ {
IOdictionary decompositionDict int nProcs = readNumProcs
( (
IOobject args,
( "targetDecomposeParDict",
"decomposeParDict", runTimeTarget
runTimeTarget.system(),
runTimeTarget,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
); );
int nProcs(readInt(decompositionDict.lookup("numberOfSubdomains")));
Info<< "Create source mesh\n" << endl; Info<< "Create source mesh\n" << endl;
@ -478,39 +517,17 @@ int main(int argc, char *argv[])
} }
else if (parallelSource && parallelTarget) else if (parallelSource && parallelTarget)
{ {
IOdictionary decompositionDictSource int nProcsSource = readNumProcs
( (
IOobject args,
( "sourceDecomposeParDict",
"decomposeParDict", runTimeSource
runTimeSource.system(),
runTimeSource,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
); );
int nProcsTarget = readNumProcs
int nProcsSource
( (
readInt(decompositionDictSource.lookup("numberOfSubdomains")) args,
); "targetDecomposeParDict",
runTimeTarget
IOdictionary decompositionDictTarget
(
IOobject
(
"decomposeParDict",
runTimeTarget.system(),
runTimeTarget,
IOobject::MUST_READ_IF_MODIFIED,
IOobject::NO_WRITE
)
);
int nProcsTarget
(
readInt(decompositionDictTarget.lookup("numberOfSubdomains"))
); );
List<boundBox> bbsTarget(nProcsTarget); List<boundBox> bbsTarget(nProcsTarget);

View File

@ -104,6 +104,8 @@ void MapLagrangianFields
Info<< " mapping lagrangian fieldField " << fieldName << endl; Info<< " mapping lagrangian fieldField " << fieldName << endl;
// Read field (does not need mesh) // Read field (does not need mesh)
// Note: some fieldFields are 0 size (e.g. collision records) if
// not used
IOField<Field<Type> > fieldSource(*fieldIter()); IOField<Field<Type> > fieldSource(*fieldIter());
// Map - use CompactIOField to automatically write in // Map - use CompactIOField to automatically write in
@ -120,12 +122,22 @@ void MapLagrangianFields
IOobject::NO_WRITE, IOobject::NO_WRITE,
false false
), ),
addParticles.size() min(fieldSource.size(), addParticles.size()) // handle 0 size
); );
forAll(addParticles, i) if (fieldSource.size())
{ {
fieldTarget[i] = fieldSource[addParticles[i]]; forAll(addParticles, i)
{
fieldTarget[i] = fieldSource[addParticles[i]];
}
}
else if (cloud::debug)
{
Pout<< "Not mapping " << fieldName << " since source size "
<< fieldSource.size() << " different to"
<< " cloud size " << addParticles.size()
<< endl;
} }
// Write field // Write field
@ -139,8 +151,9 @@ void MapLagrangianFields
forAllIter(IOobjectList, fieldFields, fieldIter) forAllIter(IOobjectList, fieldFields, fieldIter)
{ {
Info<< " mapping lagrangian fieldField " const word& fieldName = fieldIter()->name();
<< fieldIter()->name() << endl;
Info<< " mapping lagrangian fieldField " << fieldName << endl;
// Read field (does not need mesh) // Read field (does not need mesh)
CompactIOField<Field<Type>, Type> fieldSource(*fieldIter()); CompactIOField<Field<Type>, Type> fieldSource(*fieldIter());
@ -150,7 +163,7 @@ void MapLagrangianFields
( (
IOobject IOobject
( (
fieldIter()->name(), fieldName,
meshTarget.time().timeName(), meshTarget.time().timeName(),
cloud::prefix/cloudName, cloud::prefix/cloudName,
meshTarget, meshTarget,
@ -158,12 +171,22 @@ void MapLagrangianFields
IOobject::NO_WRITE, IOobject::NO_WRITE,
false false
), ),
addParticles.size() min(fieldSource.size(), addParticles.size()) // handle 0 size
); );
forAll(addParticles, i) if (fieldSource.size())
{ {
fieldTarget[i] = fieldSource[addParticles[i]]; forAll(addParticles, i)
{
fieldTarget[i] = fieldSource[addParticles[i]];
}
}
else if (cloud::debug)
{
Pout<< "Not mapping " << fieldName << " since source size "
<< fieldSource.size() << " different to"
<< " cloud size " << addParticles.size()
<< endl;
} }
// Write field // Write field

View File

@ -110,9 +110,10 @@ void mapLagrangian(const meshToMesh& interp)
cloud::prefix/cloudDirs[cloudI] cloud::prefix/cloudDirs[cloudI]
); );
IOobject* positionsPtr = objects.lookup(word("positions")); bool foundPositions =
returnReduce(objects.found("positions"), orOp<bool>());;
if (positionsPtr) if (foundPositions)
{ {
Info<< nl << " processing cloud " << cloudDirs[cloudI] << endl; Info<< nl << " processing cloud " << cloudDirs[cloudI] << endl;