mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: parallel makeFaMesh with addressing and field decomposition (#2084)
This commit is contained in:
@ -1,12 +1,13 @@
|
|||||||
EXE_INC = \
|
EXE_INC = \
|
||||||
-I$(LIB_SRC)/finiteArea/lnInclude \
|
-I$(LIB_SRC)/finiteArea/lnInclude \
|
||||||
-I$(LIB_SRC)/finiteVolume/lnInclude \
|
|
||||||
-I$(LIB_SRC)/fileFormats/lnInclude \
|
-I$(LIB_SRC)/fileFormats/lnInclude \
|
||||||
-I$(LIB_SRC)/meshTools/lnInclude \
|
-I$(LIB_SRC)/meshTools/lnInclude \
|
||||||
-I$(LIB_SRC)/cfdTools/general/lnInclude
|
-I$(LIB_SRC)/parallel/decompose/faDecompose/lnInclude \
|
||||||
|
-I$(LIB_SRC)/parallel/reconstruct/faReconstruct/lnInclude
|
||||||
|
|
||||||
EXE_LIBS = \
|
EXE_LIBS = \
|
||||||
-lfiniteArea \
|
-lfiniteArea \
|
||||||
-lfiniteVolume \
|
|
||||||
-lfileFormats \
|
-lfileFormats \
|
||||||
-lmeshTools
|
-lmeshTools \
|
||||||
|
-lfaDecompose \
|
||||||
|
-lfaReconstruct
|
||||||
|
|||||||
@ -11,13 +11,84 @@ License
|
|||||||
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||||
|
|
||||||
Description
|
Description
|
||||||
placeholder for decomposing fields
|
Decompose area fields, when mesh was generated in parallel
|
||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
if (Pstream::parRun())
|
if (Pstream::parRun())
|
||||||
{
|
{
|
||||||
|
faMeshReconstructor reconstructor(areaMesh);
|
||||||
|
reconstructor.writeAddressing();
|
||||||
|
|
||||||
|
// Handle area fields
|
||||||
|
// ------------------
|
||||||
|
|
||||||
|
PtrList<areaScalarField> areaScalarFields;
|
||||||
|
PtrList<areaVectorField> areaVectorFields;
|
||||||
|
PtrList<areaSphericalTensorField> areaSphTensorFields;
|
||||||
|
PtrList<areaSymmTensorField> areaSymmTensorFields;
|
||||||
|
PtrList<areaTensorField> areaTensorFields;
|
||||||
|
|
||||||
|
const faMesh& fullMesh = reconstructor.mesh();
|
||||||
|
|
||||||
|
{
|
||||||
|
// Use uncollated (or master uncollated) file handler here.
|
||||||
|
// - each processor is reading in the identical serial fields.
|
||||||
|
// - nothing should be parallel-coordinated.
|
||||||
|
|
||||||
|
// Similarly, if we write the serial finite-area mesh, this is only
|
||||||
|
// done from one processor!
|
||||||
|
|
||||||
|
reconstructor.writeMesh();
|
||||||
|
|
||||||
|
const bool oldDistributed = fileHandler().distributed();
|
||||||
|
auto oldHandler = fileHandler(fileOperation::NewUncollated());
|
||||||
|
fileHandler().distributed(true);
|
||||||
|
|
||||||
|
IOobjectList objects(fullMesh.time(), runTime.timeName());
|
||||||
|
|
||||||
|
faFieldDecomposer::readFields(fullMesh, objects, areaScalarFields);
|
||||||
|
faFieldDecomposer::readFields(fullMesh, objects, areaVectorFields);
|
||||||
|
faFieldDecomposer::readFields(fullMesh, objects, areaSphTensorFields);
|
||||||
|
faFieldDecomposer::readFields(fullMesh, objects, areaSymmTensorFields);
|
||||||
|
faFieldDecomposer::readFields(fullMesh, objects, areaTensorFields);
|
||||||
|
|
||||||
|
// Restore old settings
|
||||||
|
if (oldHandler)
|
||||||
|
{
|
||||||
|
fileHandler(std::move(oldHandler));
|
||||||
|
}
|
||||||
|
fileHandler().distributed(oldDistributed);
|
||||||
|
}
|
||||||
|
|
||||||
|
const label nAreaFields =
|
||||||
|
(
|
||||||
|
areaScalarFields.size()
|
||||||
|
+ areaVectorFields.size()
|
||||||
|
+ areaSphTensorFields.size()
|
||||||
|
+ areaSymmTensorFields.size()
|
||||||
|
+ areaTensorFields.size()
|
||||||
|
);
|
||||||
|
|
||||||
|
if (nAreaFields)
|
||||||
|
{
|
||||||
|
Info<< "Decomposing " << nAreaFields << " area fields" << nl << endl;
|
||||||
|
|
||||||
|
faFieldDecomposer fieldDecomposer
|
||||||
|
(
|
||||||
|
fullMesh,
|
||||||
|
areaMesh,
|
||||||
|
reconstructor.edgeProcAddressing(),
|
||||||
|
reconstructor.faceProcAddressing(),
|
||||||
|
reconstructor.boundaryProcAddressing()
|
||||||
|
);
|
||||||
|
|
||||||
|
fieldDecomposer.decomposeFields(areaScalarFields);
|
||||||
|
fieldDecomposer.decomposeFields(areaVectorFields);
|
||||||
|
fieldDecomposer.decomposeFields(areaSphTensorFields);
|
||||||
|
fieldDecomposer.decomposeFields(areaSymmTensorFields);
|
||||||
|
fieldDecomposer.decomposeFields(areaTensorFields);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// ************************************************************************* //
|
// ************************************************************************* //
|
||||||
|
|||||||
@ -0,0 +1,43 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||||
|
\\ / O peration |
|
||||||
|
\\ / A nd | www.openfoam.com
|
||||||
|
\\/ M anipulation |
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Copyright (C) 2021 OpenCFD Ltd.
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
License
|
||||||
|
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
|
||||||
|
|
||||||
|
Description
|
||||||
|
OBJ output of faMesh edges
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
{
|
||||||
|
Info<< "Writing edges in obj format" << endl;
|
||||||
|
|
||||||
|
word outputName("faMesh-edges.obj");
|
||||||
|
|
||||||
|
if (Pstream::parRun())
|
||||||
|
{
|
||||||
|
outputName = word
|
||||||
|
(
|
||||||
|
"faMesh-edges-" + Foam::name(Pstream::myProcNo()) + ".obj"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
OBJstream os(runTime.globalPath()/outputName);
|
||||||
|
|
||||||
|
os.writeQuoted
|
||||||
|
(
|
||||||
|
("# " + outputName + "\n"),
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
|
os.write(areaMesh.patch().edges(), areaMesh.patch().localPoints());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -29,6 +29,8 @@ Application
|
|||||||
|
|
||||||
Description
|
Description
|
||||||
A mesh generator for finiteArea mesh.
|
A mesh generator for finiteArea mesh.
|
||||||
|
When called in parallel, it will also try to act like decomposePar,
|
||||||
|
create procAddressing and decompose serial finite-area fields.
|
||||||
|
|
||||||
Author
|
Author
|
||||||
Zeljko Tukovic, FAMENA
|
Zeljko Tukovic, FAMENA
|
||||||
@ -36,15 +38,17 @@ Author
|
|||||||
|
|
||||||
\*---------------------------------------------------------------------------*/
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
#include "objectRegistry.H"
|
|
||||||
#include "Time.H"
|
#include "Time.H"
|
||||||
#include "argList.H"
|
#include "argList.H"
|
||||||
#include "OSspecific.H"
|
#include "OSspecific.H"
|
||||||
#include "faMesh.H"
|
#include "faMesh.H"
|
||||||
#include "fvMesh.H"
|
|
||||||
#include "IOdictionary.H"
|
#include "IOdictionary.H"
|
||||||
#include "globalIndex.H"
|
#include "IOobjectList.H"
|
||||||
#include "globalMeshData.H"
|
|
||||||
|
#include "areaFields.H"
|
||||||
|
#include "faFieldDecomposer.H"
|
||||||
|
#include "faMeshReconstructor.H"
|
||||||
|
#include "OBJstream.H"
|
||||||
|
|
||||||
using namespace Foam;
|
using namespace Foam;
|
||||||
|
|
||||||
@ -65,10 +69,17 @@ int main(int argc, char *argv[])
|
|||||||
);
|
);
|
||||||
argList::addOption("dict", "file", "Alternative faMeshDefinition");
|
argList::addOption("dict", "file", "Alternative faMeshDefinition");
|
||||||
|
|
||||||
|
argList::addBoolOption
|
||||||
|
(
|
||||||
|
"write-edges-obj",
|
||||||
|
"Write mesh edges as obj files and exit",
|
||||||
|
false // could make an advanced option
|
||||||
|
);
|
||||||
|
|
||||||
#include "addRegionOption.H"
|
#include "addRegionOption.H"
|
||||||
#include "setRootCase.H"
|
#include "setRootCase.H"
|
||||||
#include "createTime.H"
|
#include "createTime.H"
|
||||||
#include "createNamedMesh.H"
|
#include "createNamedPolyMesh.H"
|
||||||
|
|
||||||
// Reading faMeshDefinition dictionary
|
// Reading faMeshDefinition dictionary
|
||||||
#include "findMeshDefinitionDict.H"
|
#include "findMeshDefinitionDict.H"
|
||||||
@ -80,12 +91,29 @@ int main(int argc, char *argv[])
|
|||||||
meshDefDict.add("emptyPatch", patchName, true);
|
meshDefDict.add("emptyPatch", patchName, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Creation
|
// Create
|
||||||
faMesh areaMesh(mesh, meshDefDict);
|
faMesh areaMesh(mesh, meshDefDict);
|
||||||
|
|
||||||
// Writing faMesh
|
bool quickExit = false;
|
||||||
Info << "Write finite area mesh ... ";
|
|
||||||
|
if (args.found("write-edges-obj"))
|
||||||
|
{
|
||||||
|
quickExit = true;
|
||||||
|
#include "faMeshWriteEdgesOBJ.H"
|
||||||
|
}
|
||||||
|
|
||||||
|
if (quickExit)
|
||||||
|
{
|
||||||
|
Info<< "\nEnd\n" << endl;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the precision of the points data to 10
|
||||||
|
IOstream::defaultPrecision(10);
|
||||||
|
|
||||||
|
Info<< nl << "Write finite area mesh." << nl;
|
||||||
areaMesh.write();
|
areaMesh.write();
|
||||||
|
Info<< endl;
|
||||||
|
|
||||||
#include "decomposeFaFields.H"
|
#include "decomposeFaFields.H"
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user