Merge branch 'feature-allRegions' into 'develop'

add multi-region handling for checkMesh etc,  centralized the region handling #2072

See merge request Development/openfoam!445
This commit is contained in:
Andrew Heather
2021-05-07 10:50:02 +00:00
31 changed files with 1467 additions and 1144 deletions

View File

@ -55,12 +55,8 @@ int main(int argc, char *argv[])
argList::noParallel(); argList::noParallel();
argList::noBanner(); argList::noBanner();
#include "addRegionOption.H" #include "addAllRegionOptions.H"
argList::addBoolOption
(
"allRegions",
"operate on all regions in regionProperties"
);
argList::addBoolOption argList::addBoolOption
( (
"verbose", "verbose",
@ -76,11 +72,11 @@ int main(int argc, char *argv[])
const auto decompFile = args.get<fileName>(1); const auto decompFile = args.get<fileName>(1);
const bool region = args.found("region"); const bool region = args.found("region");
const bool allRegions = args.found("allRegions");
const bool verbose = args.found("verbose"); const bool verbose = args.found("verbose");
// Set time from database // Set time from database
#include "createTime.H" #include "createTime.H"
// Allow override of time // Allow override of time
instantList times = timeSelector::selectIfPresent(runTime, args); instantList times = timeSelector::selectIfPresent(runTime, args);
@ -88,31 +84,18 @@ int main(int argc, char *argv[])
const fileName decompDictFile = const fileName decompDictFile =
args.getOrDefault<fileName>("decomposeParDict", ""); args.getOrDefault<fileName>("decomposeParDict", "");
wordList regionNames; // Get region names
wordList regionDirs; #include "getAllRegionOptions.H"
if (allRegions)
wordList regionDirs(regionNames);
if (regionDirs.size() == 1 && regionDirs[0] == polyMesh::defaultRegion)
{ {
Info<< "Decomposing all regions in regionProperties" << nl << endl; regionDirs[0].clear();
regionProperties rp(runTime);
forAllConstIters(rp, iter)
{
const wordList& regions = iter();
forAll(regions, i)
{
regionNames.appendUniq(regions[i]);
}
}
regionDirs = regionNames;
} }
else else
{ {
regionNames.resize(1, fvMesh::defaultRegion); Info<< "Decomposing regions: "
regionDirs.resize(1, word::null); << flatOutput(regionNames) << nl << endl;
if (args.readIfPresent("region", regionNames.first()))
{
regionDirs.first() = regionNames.first();
}
} }
labelList cellToProc; labelList cellToProc;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2017-2020 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -62,12 +62,9 @@ int main(int argc, char *argv[])
"file", "file",
"Use specified file for decomposePar dictionary" "Use specified file for decomposePar dictionary"
); );
#include "addRegionOption.H"
argList::addBoolOption #include "addAllRegionOptions.H"
(
"allRegions",
"Operate on all regions in regionProperties"
);
argList::addBoolOption argList::addBoolOption
( (
"verbose", "verbose",
@ -107,7 +104,6 @@ int main(int argc, char *argv[])
#include "setRootCase.H" #include "setRootCase.H"
const bool optRegion = args.found("region"); const bool optRegion = args.found("region");
const bool allRegions = args.found("allRegions");
const bool verbose = args.found("verbose"); const bool verbose = args.found("verbose");
const label numSubdomains = args.getOrDefault<label>("domains", 0); const label numSubdomains = args.getOrDefault<label>("domains", 0);
@ -122,27 +118,20 @@ int main(int argc, char *argv[])
const fileName decompDictFile = const fileName decompDictFile =
args.getOrDefault<fileName>("decomposeParDict", ""); args.getOrDefault<fileName>("decomposeParDict", "");
// Get all region names // Get region names
wordList regionNames; #include "getAllRegionOptions.H"
if (allRegions)
{ Info<< "Decomposing regions: "
regionNames = regionProperties(runTime).names(); << flatOutput(regionNames) << nl << endl;
Info<< "Decomposing all regions in regionProperties" << nl
<< " " << flatOutput(regionNames) << nl << endl;
}
else
{
regionNames.resize(1);
regionNames.first() =
args.getOrDefault<word>("region", fvMesh::defaultRegion);
}
forAll(regionNames, regioni) forAll(regionNames, regioni)
{ {
const word& regionName = regionNames[regioni]; const word& regionName = regionNames[regioni];
const word& regionDir = const word& regionDir =
(regionName == fvMesh::defaultRegion ? word::null : regionName); (
regionName == polyMesh::defaultRegion ? word::null : regionName
);
Info<< "\n\nDecomposing mesh " << regionName << nl << endl; Info<< "\n\nDecomposing mesh " << regionName << nl << endl;
Info<< "Create mesh..." << flush; Info<< "Create mesh..." << flush;

View File

@ -50,6 +50,9 @@ Usage
- \par -region \<name\> - \par -region \<name\>
Specify an alternative mesh region. Specify an alternative mesh region.
- \par -allRegions
Check all regions in regionProperties.
\param -writeSets \<surfaceFormat\> \n \param -writeSets \<surfaceFormat\> \n
Reconstruct all cellSets and faceSets geometry and write to postProcessing Reconstruct all cellSets and faceSets geometry and write to postProcessing
directory according to surfaceFormat (e.g. vtk or ensight). Additionally directory according to surfaceFormat (e.g. vtk or ensight). Additionally
@ -74,6 +77,8 @@ Usage
#include "vtkSetWriter.H" #include "vtkSetWriter.H"
#include "vtkSurfaceWriter.H" #include "vtkSurfaceWriter.H"
#include "IOdictionary.H" #include "IOdictionary.H"
#include "regionProperties.H"
#include "polyMeshTools.H"
#include "checkTools.H" #include "checkTools.H"
#include "checkTopology.H" #include "checkTopology.H"
@ -93,7 +98,8 @@ int main(int argc, char *argv[])
); );
timeSelector::addOptions(); timeSelector::addOptions();
#include "addRegionOption.H" #include "addAllRegionOptions.H"
argList::addBoolOption argList::addBoolOption
( (
"noTopology", "noTopology",
@ -139,8 +145,9 @@ int main(int argc, char *argv[])
#include "setRootCase.H" #include "setRootCase.H"
#include "createTime.H" #include "createTime.H"
#include "getAllRegionOptions.H"
instantList timeDirs = timeSelector::select0(runTime, args); instantList timeDirs = timeSelector::select0(runTime, args);
#include "createNamedMesh.H" #include "createNamedMeshes.H"
const bool noTopology = args.found("noTopology"); const bool noTopology = args.found("noTopology");
const bool allGeometry = args.found("allGeometry"); const bool allGeometry = args.found("allGeometry");
@ -230,24 +237,28 @@ int main(int argc, char *argv[])
} }
autoPtr<IOdictionary> qualDict; PtrList<IOdictionary> qualDict(meshes.size());
if (meshQuality) if (meshQuality)
{ {
qualDict.reset forAll(meshes, meshi)
{
qualDict.set
( (
meshi,
new IOdictionary new IOdictionary
( (
IOobject IOobject
( (
"meshQualityDict", "meshQualityDict",
mesh.time().system(), meshes[meshi].time().system(),
mesh, meshes[meshi],
IOobject::MUST_READ, IOobject::MUST_READ,
IOobject::NO_WRITE IOobject::NO_WRITE
) )
) )
); );
} }
}
autoPtr<surfaceWriter> surfWriter; autoPtr<surfaceWriter> surfWriter;
@ -263,7 +274,13 @@ int main(int argc, char *argv[])
{ {
runTime.setTime(timeDirs[timeI], timeI); runTime.setTime(timeDirs[timeI], timeI);
polyMesh::readUpdateState state = mesh.readUpdate(); // Get most changed of all meshes
polyMesh::readUpdateState state = polyMesh::UNCHANGED;
for (auto& mesh : meshes)
{
state = polyMeshTools::combine(state, mesh.readUpdate());
}
if if
( (
@ -274,6 +291,10 @@ int main(int argc, char *argv[])
{ {
Info<< "Time = " << runTime.timeName() << nl << endl; Info<< "Time = " << runTime.timeName() << nl << endl;
forAll(meshes, meshi)
{
const auto& mesh = meshes[meshi];
// Reconstruct globalMeshData // Reconstruct globalMeshData
mesh.globalData(); mesh.globalData();
@ -303,12 +324,14 @@ int main(int argc, char *argv[])
if (meshQuality) if (meshQuality)
{ {
nFailedChecks += checkMeshQuality(mesh, qualDict(), surfWriter); nFailedChecks +=
checkMeshQuality(mesh, qualDict[meshi], surfWriter);
} }
// Note: no reduction in nFailedChecks necessary since is // Note: no reduction in nFailedChecks necessary since is
// counter of checks, not counter of failed cells,faces etc. // counter of checks, not counter of failed cells,faces
// etc.
if (nFailedChecks == 0) if (nFailedChecks == 0)
{ {
@ -324,10 +347,15 @@ int main(int argc, char *argv[])
// Write selected fields // Write selected fields
Foam::writeFields(mesh, selectedFields, writeFaceFields); Foam::writeFields(mesh, selectedFields, writeFaceFields);
} }
}
else if (state == polyMesh::POINTS_MOVED) else if (state == polyMesh::POINTS_MOVED)
{ {
Info<< "Time = " << runTime.timeName() << nl << endl; Info<< "Time = " << runTime.timeName() << nl << endl;
forAll(meshes, meshi)
{
const auto& mesh = meshes[meshi];
label nFailedChecks = checkGeometry label nFailedChecks = checkGeometry
( (
mesh, mesh,
@ -338,7 +366,8 @@ int main(int argc, char *argv[])
if (meshQuality) if (meshQuality)
{ {
nFailedChecks += checkMeshQuality(mesh, qualDict(), surfWriter); nFailedChecks +=
checkMeshQuality(mesh, qualDict[meshi], surfWriter);
} }
@ -357,6 +386,7 @@ int main(int argc, char *argv[])
Foam::writeFields(mesh, selectedFields, writeFaceFields); Foam::writeFields(mesh, selectedFields, writeFaceFields);
} }
} }
}
Info<< "End\n" << endl; Info<< "End\n" << endl;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2015-2017 OpenFOAM Foundation Copyright (C) 2015-2017 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd. Copyright (C) 2015-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -50,10 +50,18 @@ License
void Foam::printMeshStats(const polyMesh& mesh, const bool allTopology) void Foam::printMeshStats(const polyMesh& mesh, const bool allTopology)
{ {
Info<< "Mesh stats" << nl if (mesh.name() == Foam::polyMesh::defaultRegion)
<< " points: " {
Info<< "Mesh stats" << nl;
}
else
{
Info<< "Mesh " << mesh.name() << " stats" << nl;
}
Info<< " points: "
<< returnReduce(mesh.points().size(), sumOp<label>()) << nl; << returnReduce(mesh.points().size(), sumOp<label>()) << nl;
// Count number of internal points (-1 if not sorted; 0 if no internal // Count number of internal points (-1 if not sorted; 0 if no internal
// points) // points)
const label minInt = returnReduce(mesh.nInternalPoints(), minOp<label>()); const label minInt = returnReduce(mesh.nInternalPoints(), minOp<label>());

View File

@ -57,6 +57,8 @@ Description
#include "pointSet.H" #include "pointSet.H"
#include "processorMeshes.H" #include "processorMeshes.H"
#include "hexRef8Data.H" #include "hexRef8Data.H"
#include "regionProperties.H"
#include "polyMeshTools.H"
#ifdef HAVE_ZOLTAN #ifdef HAVE_ZOLTAN
#include "zoltanRenumber.H" #include "zoltanRenumber.H"
@ -613,7 +615,7 @@ int main(int argc, char *argv[])
"Renumber mesh cells to reduce the bandwidth" "Renumber mesh cells to reduce the bandwidth"
); );
#include "addRegionOption.H" #include "addAllRegionOptions.H"
#include "addOverwriteOption.H" #include "addOverwriteOption.H"
#include "addTimeOptions.H" #include "addTimeOptions.H"
@ -629,7 +631,7 @@ int main(int argc, char *argv[])
#include "setRootCase.H" #include "setRootCase.H"
#include "createTime.H" #include "createTime.H"
#include "getAllRegionOptions.H"
// Force linker to include zoltan symbols. This section is only needed since // Force linker to include zoltan symbols. This section is only needed since
// Zoltan is a static library // Zoltan is a static library
@ -638,7 +640,6 @@ int main(int argc, char *argv[])
(void)zoltanRenumber::typeName; (void)zoltanRenumber::typeName;
#endif #endif
// Get times list // Get times list
instantList Times = runTime.times(); instantList Times = runTime.times();
@ -647,14 +648,20 @@ int main(int argc, char *argv[])
runTime.setTime(Times[startTime], startTime); runTime.setTime(Times[startTime], startTime);
#include "createNamedMesh.H" #include "createNamedMeshes.H"
const word oldInstance = mesh.pointsInstance();
const bool readDict = args.found("dict"); const bool readDict = args.found("dict");
const bool doFrontWidth = args.found("frontWidth"); const bool doFrontWidth = args.found("frontWidth");
const bool overwrite = args.found("overwrite"); const bool overwrite = args.found("overwrite");
for (fvMesh& mesh : meshes)
{
// Reset time in case of multiple meshes and not overwrite
runTime.setTime(Times[startTime], startTime);
const word oldInstance = mesh.pointsInstance();
label band; label band;
scalar profile; scalar profile;
scalar sumSqrIntersect; scalar sumSqrIntersect;
@ -680,7 +687,8 @@ int main(int argc, char *argv[])
)/mesh.globalData().nTotalCells() )/mesh.globalData().nTotalCells()
); );
Info<< "Mesh size: " << mesh.globalData().nTotalCells() << nl Info<< "Mesh " << mesh.name()
<< " size: " << mesh.globalData().nTotalCells() << nl
<< "Before renumbering :" << nl << "Before renumbering :" << nl
<< " band : " << band << nl << " band : " << band << nl
<< " profile : " << profile << nl; << " profile : " << profile << nl;
@ -729,7 +737,8 @@ int main(int argc, char *argv[])
{ {
Info<< "Ordering cells into regions of size " << blockSize Info<< "Ordering cells into regions of size " << blockSize
<< " (using decomposition);" << " (using decomposition);"
<< " ordering faces into region-internal and region-external." << " ordering faces into region-internal"
<< " and region-external."
<< nl << endl; << nl << endl;
if (blockSize < 0 || blockSize >= mesh.nCells()) if (blockSize < 0 || blockSize >= mesh.nCells())
@ -745,7 +754,8 @@ int main(int argc, char *argv[])
orderPoints = renumberDict.getOrDefault("orderPoints", false); orderPoints = renumberDict.getOrDefault("orderPoints", false);
if (orderPoints) if (orderPoints)
{ {
Info<< "Ordering points into internal and boundary points." << nl Info<< "Ordering points into internal and boundary points."
<< nl
<< endl; << endl;
} }
@ -763,7 +773,8 @@ int main(int argc, char *argv[])
renumberPtr.reset(new CuthillMcKeeRenumber(renumberDict)); renumberPtr.reset(new CuthillMcKeeRenumber(renumberDict));
} }
Info<< "Selecting renumberMethod " << renumberPtr().type() << nl << endl; Info<< "Selecting renumberMethod " << renumberPtr().type() << nl
<< endl;
@ -996,7 +1007,8 @@ int main(int argc, char *argv[])
if (reverseCellOrder[celli] != -1) if (reverseCellOrder[celli] != -1)
{ {
bndCells[nBndCells] = celli; bndCells[nBndCells] = celli;
bndCellMap[nBndCells++] = reverseCellOrder[celli]; bndCellMap[nBndCells++] =
reverseCellOrder[celli];
reverseCellOrder[celli] = -1; reverseCellOrder[celli] = -1;
} }
} }
@ -1018,7 +1030,8 @@ int main(int argc, char *argv[])
newReverseCellOrder[origCelli] = --sortedI; newReverseCellOrder[origCelli] = --sortedI;
} }
Info<< "Ordered all " << nBndCells << " cells with a coupled face" Info<< "Ordered all " << nBndCells
<< " cells with a coupled face"
<< " to the end of the cell list, starting at " << sortedI << " to the end of the cell list, starting at " << sortedI
<< endl; << endl;
@ -1139,7 +1152,8 @@ int main(int argc, char *argv[])
if (masterFacei == 0) if (masterFacei == 0)
{ {
FatalErrorInFunction FatalErrorInFunction
<< " masterFacei:" << masterFacei << exit(FatalError); << " masterFacei:" << masterFacei
<< exit(FatalError);
} }
} }
} }
@ -1254,8 +1268,8 @@ int main(int argc, char *argv[])
if (orderPoints) if (orderPoints)
{ {
// Force edge calculation (since only reason that points would need to // Force edge calculation (since only reason that points would
// be sorted) // need to be sorted)
(void)mesh.edges(); (void)mesh.edges();
label nTotPoints = returnReduce label nTotPoints = returnReduce
@ -1364,9 +1378,9 @@ int main(int argc, char *argv[])
identity(mesh.nCells()) identity(mesh.nCells())
)().write(); )().write();
Info<< nl << "Written current cellID and origCellID as volScalarField" Info<< nl
<< " for use in postprocessing." << "Written current cellID and origCellID as volScalarField"
<< nl << endl; << " for use in postprocessing." << nl << endl;
labelIOList labelIOList
( (
@ -1413,7 +1427,7 @@ int main(int argc, char *argv[])
map().pointMap() map().pointMap()
).write(); ).write();
} }
}
Info<< "End\n" << endl; Info<< "End\n" << endl;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -294,12 +294,9 @@ int main(int argc, char *argv[])
"file", "file",
"Use specified file for decomposePar dictionary" "Use specified file for decomposePar dictionary"
); );
#include "addRegionOption.H"
argList::addBoolOption #include "addAllRegionOptions.H"
(
"allRegions",
"Operate on all regions in regionProperties"
);
argList::addBoolOption argList::addBoolOption
( (
"dry-run", "dry-run",
@ -354,8 +351,6 @@ int main(int argc, char *argv[])
#include "setRootCase.H" #include "setRootCase.H"
const bool dryrun = args.found("dry-run"); const bool dryrun = args.found("dry-run");
const bool optRegion = args.found("region");
const bool allRegions = args.found("allRegions");
const bool writeCellDist = args.found("cellDist"); const bool writeCellDist = args.found("cellDist");
const bool verbose = args.found("verbose"); const bool verbose = args.found("verbose");
@ -391,27 +386,24 @@ int main(int argc, char *argv[])
decompDictFile = runTime.globalPath()/decompDictFile; decompDictFile = runTime.globalPath()/decompDictFile;
} }
// Get all region names // Get region names
wordList regionNames; #include "getAllRegionOptions.H"
if (allRegions)
{
regionNames = regionProperties(runTime).names();
Info<< "Decomposing all regions in regionProperties" << nl const bool optRegions =
<< " " << flatOutput(regionNames) << nl << endl; (regionNames.size() != 1 || regionNames[0] != polyMesh::defaultRegion);
}
else if (regionNames.size() == 1 && regionNames[0] != polyMesh::defaultRegion)
{ {
regionNames.resize(1); Info<< "Using region: " << regionNames[0] << nl << endl;
regionNames.first() =
args.getOrDefault<word>("region", fvMesh::defaultRegion);
} }
forAll(regionNames, regioni) forAll(regionNames, regioni)
{ {
const word& regionName = regionNames[regioni]; const word& regionName = regionNames[regioni];
const word& regionDir = const word& regionDir =
(regionName == fvMesh::defaultRegion ? word::null : regionName); (
regionName == polyMesh::defaultRegion ? word::null : regionName
);
if (dryrun) if (dryrun)
{ {
@ -436,7 +428,12 @@ int main(int argc, char *argv[])
continue; continue;
} }
Info<< "\n\nDecomposing mesh " << regionName << nl << endl; Info<< "\n\nDecomposing mesh";
if (!regionDir.empty())
{
Info<< ' ' << regionName;
}
Info<< nl << endl;
// Determine the existing processor count directly // Determine the existing processor count directly
label nProcs = fileHandler().nProcs(runTime.path(), regionDir); label nProcs = fileHandler().nProcs(runTime.path(), regionDir);
@ -495,7 +492,7 @@ int main(int argc, char *argv[])
Info<< "Using existing processor directories" << nl; Info<< "Using existing processor directories" << nl;
} }
if (allRegions || optRegion) if (optRegions)
{ {
procDirsProblem = false; procDirsProblem = false;
forceOverwrite = false; forceOverwrite = false;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2018 OpenCFD Ltd. Copyright (C) 2015-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -89,12 +89,9 @@ int main(int argc, char *argv[])
// Enable -withZero to prevent accidentally trashing the initial fields // Enable -withZero to prevent accidentally trashing the initial fields
timeSelector::addOptions(true, true); // constant(true), zero(true) timeSelector::addOptions(true, true); // constant(true), zero(true)
argList::noParallel(); argList::noParallel();
#include "addRegionOption.H"
argList::addBoolOption #include "addAllRegionOptions.H"
(
"allRegions",
"Operate on all regions in regionProperties"
);
argList::addOption argList::addOption
( (
"fields", "fields",
@ -171,30 +168,24 @@ int main(int argc, char *argv[])
} }
const bool newTimes = args.found("newTimes"); const bool newTimes = args.found("newTimes");
const bool allRegions = args.found("allRegions");
wordList regionNames; // Get region names
wordList regionDirs; #include "getAllRegionOptions.H"
if (allRegions)
wordList regionDirs(regionNames);
if (regionNames.size() == 1)
{ {
regionNames = regionProperties(runTime).names(); if (regionNames[0] == polyMesh::defaultRegion)
regionDirs = regionNames; {
regionDirs[0].clear();
Info<< "Reconstructing all regions in regionProperties" << nl
<< " " << flatOutput(regionNames) << nl << endl;
} }
else else
{ {
regionNames.resize(1, fvMesh::defaultRegion); Info<< "Using region: " << regionNames[0] << nl << endl;
regionDirs.resize(1, word::null);
if (args.readIfPresent("region", regionNames.first()))
{
regionDirs.first() = regionNames.first();
} }
} }
// Determine the processor count // Determine the processor count
label nProcs = fileHandler().nProcs(args.path(), regionDirs[0]); label nProcs = fileHandler().nProcs(args.path(), regionDirs[0]);

View File

@ -2263,12 +2263,9 @@ int main(int argc, char *argv[])
// enable -constant ... if someone really wants it // enable -constant ... if someone really wants it
// enable -zeroTime to prevent accidentally trashing the initial fields // enable -zeroTime to prevent accidentally trashing the initial fields
timeSelector::addOptions(true, true); timeSelector::addOptions(true, true);
#include "addRegionOption.H"
argList::addBoolOption #include "addAllRegionOptions.H"
(
"allRegions",
"operate on all regions in regionProperties"
);
#include "addOverwriteOption.H" #include "addOverwriteOption.H"
argList::addBoolOption("decompose", "Decompose case"); argList::addBoolOption("decompose", "Decompose case");
argList::addBoolOption("reconstruct", "Reconstruct case"); argList::addBoolOption("reconstruct", "Reconstruct case");
@ -2506,20 +2503,12 @@ int main(int argc, char *argv[])
const fileName decompDictFile = const fileName decompDictFile =
args.getOrDefault<fileName>("decomposeParDict", ""); args.getOrDefault<fileName>("decomposeParDict", "");
// Get all region names // Get region names
wordList regionNames; #include "getAllRegionOptions.H"
if (args.found("allRegions"))
{
regionNames = regionProperties(runTime).names();
Info<< "Decomposing all regions in regionProperties" << nl if (regionNames.size() == 1 && regionNames[0] != polyMesh::defaultRegion)
<< " " << flatOutput(regionNames) << nl << endl;
}
else
{ {
regionNames.resize(1); Info<< "Using region: " << regionNames[0] << nl << endl;
regionNames.first() =
args.getOrDefault<word>("region", fvMesh::defaultRegion);
} }
@ -2553,12 +2542,11 @@ int main(int argc, char *argv[])
forAll(regionNames, regioni) forAll(regionNames, regioni)
{ {
const word& regionName = regionNames[regioni]; const word& regionName = regionNames[regioni];
const fileName meshSubDir const word& regionDir =
( (
regionName == fvMesh::defaultRegion regionName == polyMesh::defaultRegion ? word::null : regionName
? fileName(polyMesh::meshSubDir)
: regionNames[regioni]/polyMesh::meshSubDir
); );
const fileName meshSubDir(regionDir/polyMesh::meshSubDir);
Info<< "\n\nReconstructing mesh " << regionName << nl << endl; Info<< "\n\nReconstructing mesh " << regionName << nl << endl;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018-2020 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -39,7 +39,7 @@ if (doLagrangian)
( (
readDir readDir
( (
runTime.timePath()/regionPrefix/cloud::prefix, runTime.timePath()/regionDir/cloud::prefix,
fileName::DIRECTORY fileName::DIRECTORY
) )
); );

View File

@ -7,7 +7,7 @@ HashTable<HashTable<word>> cloudFields;
if (timeDirs.size() && doLagrangian) if (timeDirs.size() && doLagrangian)
{ {
const fileName& baseDir = mesh.time().path(); const fileName& baseDir = mesh.time().path();
const fileName cloudPrefix(regionPrefix/cloud::prefix); const fileName cloudPrefix(regionDir/cloud::prefix);
Info<< "Searching for lagrangian ... " << flush; Info<< "Searching for lagrangian ... " << flush;

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -313,12 +313,10 @@ int main(int argc, char *argv[])
#include "createNamedMesh.H" #include "createNamedMesh.H"
fileName regionPrefix; // Mesh instance (region0 gets filtered out) const word& regionDir =
if (regionName != polyMesh::defaultRegion) (
{ regionName == polyMesh::defaultRegion ? word::null : regionName
regionPrefix = regionName; );
}
// //
// Configuration // Configuration

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018-2020 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -67,7 +67,7 @@ if (doFiniteArea)
pp, pp,
writeOpts, writeOpts,
( (
outputDir/regionPrefix/"finite-area" outputDir/regionDir/"finite-area"
/ "finiteArea" + timeDesc / "finiteArea" + timeDesc
), ),
Pstream::parRun() Pstream::parRun()

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -31,7 +31,7 @@ Description
if (doLagrangian) if (doLagrangian)
{ {
const fileName cloudPrefix = (regionPrefix/cloud::prefix); const fileName cloudPrefix = (regionDir/cloud::prefix);
wordList cloudNames = ListOps::create<word> wordList cloudNames = ListOps::create<word>
( (
@ -89,7 +89,7 @@ if (doLagrangian)
writeOpts, writeOpts,
// Output name for the cloud // Output name for the cloud
( (
outputDir/regionPrefix/cloud::prefix outputDir/regionDir/cloud::prefix
/ cloudName/cloudName + timeDesc / cloudName/cloudName + timeDesc
), ),
Pstream::parRun() Pstream::parRun()

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2019-2020 OpenCFD Ltd. Copyright (C) 2019-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -47,7 +47,7 @@ Description
fileName vtmOutputBase fileName vtmOutputBase
( (
outputDir/regionPrefix/vtkName + timeDesc outputDir/regionDir/vtkName + timeDesc
); );
// Naming // Naming

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -102,7 +102,7 @@ Description
meshProxy.mesh(), meshProxy.mesh(),
writeOpts, writeOpts,
( (
outputDir/regionPrefix outputDir/regionDir
/ "surface-fields"/"surfaceFields" + timeDesc / "surface-fields"/"surfaceFields" + timeDesc
), ),
Pstream::parRun() Pstream::parRun()
@ -205,7 +205,7 @@ Description
pp, pp,
writeOpts, writeOpts,
( (
outputDir/regionPrefix/fz.name() outputDir/regionDir/fz.name()
/ (meshProxy.useSubMesh() ? meshProxy.name() : fz.name()) / (meshProxy.useSubMesh() ? meshProxy.name() : fz.name())
+ timeDesc + timeDesc
), ),

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -39,7 +39,7 @@ if (faceSetName.size())
fileName outputName fileName outputName
( (
outputDir/regionPrefix/"face-set" outputDir/regionDir/"face-set"
/ set.name()/set.name() + timeDesc / set.name()/set.name() + timeDesc
); );
@ -67,7 +67,7 @@ if (pointSetName.size())
fileName outputName fileName outputName
( (
outputDir/regionPrefix/"point-set" outputDir/regionDir/"point-set"
/ set.name()/set.name() + timeDesc / set.name()/set.name() + timeDesc
); );

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018-2020 OpenCFD Ltd. Copyright (C) 2018-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -65,7 +65,7 @@ Description
fileName vtmOutputBase fileName vtmOutputBase
( (
outputDir/regionPrefix/vtkName + timeDesc outputDir/regionDir/vtkName + timeDesc
); );
// Combined internal + boundary in a vtm file // Combined internal + boundary in a vtm file
@ -148,7 +148,7 @@ Description
writeOpts.legacy() writeOpts.legacy()
? ?
( (
outputDir/regionPrefix/"boundary" outputDir/regionDir/"boundary"
/ (meshProxy.useSubMesh() ? meshProxy.name() : "boundary") / (meshProxy.useSubMesh() ? meshProxy.name() : "boundary")
+ timeDesc + timeDesc
) )
@ -203,7 +203,7 @@ Description
writeOpts.legacy() writeOpts.legacy()
? ?
( (
outputDir/regionPrefix/pp.name() outputDir/regionDir/pp.name()
/ (meshProxy.useSubMesh() ? meshProxy.name() : pp.name()) / (meshProxy.useSubMesh() ? meshProxy.name() : pp.name())
+ timeDesc + timeDesc
) )
@ -461,7 +461,7 @@ Description
series.write(seriesName); series.write(seriesName);
// Add to multi-region vtm // Add to multi-region vtm
vtmMultiRegion.add(regionName, regionPrefix, vtmWriter); vtmMultiRegion.add(regionName, regionDir, vtmWriter);
} }
if (vtmBoundaries.size()) if (vtmBoundaries.size())

View File

@ -0,0 +1,46 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
Additional mesh accounting (foamToVTK)
\*---------------------------------------------------------------------------*/
PtrList<fvMeshSubsetProxy> meshProxies(meshes.size());
PtrList<vtk::vtuCells> vtuMappings(meshes.size());
{
forAll(meshes, regioni)
{
// Mesh subsetting, or pass through
meshProxies.set
(
regioni,
new fvMeshSubsetProxy
(
meshes[regioni],
cellSubsetType,
cellSelectionName
)
);
// VTU sizing and decomposition information
vtuMappings.set
(
regioni,
new vtk::vtuCells(writeOpts, decomposePoly)
);
}
}
// ************************************************************************* //

View File

@ -1,58 +0,0 @@
PtrList<fvMesh> meshes(regionNames.size());
PtrList<fvMeshSubsetProxy> meshProxies(regionNames.size());
PtrList<vtk::vtuCells> vtuMappings(regionNames.size());
forAll(regionNames, regioni)
{
const word& regionName = regionNames[regioni];
Info<< "Create mesh";
if (regionName != fvMesh::defaultRegion)
{
Info<< ' ' << regionName;
}
Info<< " for time = " << runTime.timeName() << nl << endl;
meshes.set
(
regioni,
new fvMesh
(
IOobject
(
regionName,
runTime.timeName(),
runTime,
IOobject::MUST_READ
)
)
);
// Mesh subsetting, or pass through
meshProxies.set
(
regioni,
new fvMeshSubsetProxy
(
meshes[regioni],
cellSubsetType,
cellSelectionName
)
);
// VTU sizing and decomposition information
vtuMappings.set
(
regioni,
new vtk::vtuCells(writeOpts, decomposePoly)
);
}
Info<< "VTK mesh topology: "
<< timer.cpuTimeIncrement() << " s, "
<< mem.update().size() << " kB" << endl;
// ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2020 OpenCFD Ltd. Copyright (C) 2016-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -405,20 +405,7 @@ int main(int argc, char *argv[])
); );
argList::addOptionCompat("one-boundary", {"allPatches", 1806}); argList::addOptionCompat("one-boundary", {"allPatches", 1806});
#include "addRegionOption.H" #include "addAllRegionOptions.H"
argList::addOption
(
"regions",
"wordRes",
"Operate on selected regions from regionProperties.\n"
"Eg, '( gas \"solid.*\" )'"
);
argList::addBoolOption
(
"allRegions",
"Operate on all regions in regionProperties"
);
argList::addOption argList::addOption
( (
@ -473,7 +460,6 @@ int main(int argc, char *argv[])
const bool oneBoundary = args.found("one-boundary") && doBoundary; const bool oneBoundary = args.found("one-boundary") && doBoundary;
const bool nearCellValue = args.found("nearCellValue") && doBoundary; const bool nearCellValue = args.found("nearCellValue") && doBoundary;
const bool allRegions = args.found("allRegions");
const vtk::outputOptions writeOpts = getOutputOptions(args); const vtk::outputOptions writeOpts = getOutputOptions(args);
@ -563,80 +549,8 @@ int main(int argc, char *argv[])
// Information for file series // Information for file series
HashTable<vtk::seriesWriter, fileName> vtkSeries; HashTable<vtk::seriesWriter, fileName> vtkSeries;
wordList regionNames; // Handle -allRegions, -regions, -region
wordRes selectRegions; #include "getAllRegionOptions.H"
if (allRegions)
{
regionNames =
regionProperties(runTime, IOobject::READ_IF_PRESENT).names();
if (regionNames.empty())
{
Info<< "Warning: "
<< "No regionProperties - assuming default region"
<< nl << endl;
regionNames.resize(1);
regionNames.first() = fvMesh::defaultRegion;
}
else
{
Info<< "Using all regions in regionProperties" << nl
<< " "<< flatOutput(regionNames) << nl;
}
}
else if (args.readListIfPresent<wordRe>("regions", selectRegions))
{
if (selectRegions.empty())
{
regionNames.resize(1);
regionNames.first() = fvMesh::defaultRegion;
}
else if
(
selectRegions.size() == 1 && selectRegions.first().isLiteral()
)
{
// Identical to -region NAME
regionNames.resize(1);
regionNames.first() = selectRegions.first();
}
else
{
regionNames =
regionProperties(runTime, IOobject::READ_IF_PRESENT).names();
if (regionNames.empty())
{
Info<< "Warning: "
<< "No regionProperties - assuming default region"
<< nl << endl;
regionNames.resize(1);
regionNames.first() = fvMesh::defaultRegion;
}
else
{
inplaceSubsetStrings(selectRegions, regionNames);
if (regionNames.empty())
{
Info<< "No matching regions ... stopping" << nl << endl;
return 1;
}
Info<< "Using matching regions: "
<< flatOutput(regionNames) << nl;
}
}
}
else
{
regionNames.resize(1);
regionNames.first() =
args.getOrDefault<word>("region", fvMesh::defaultRegion);
}
// Names for sets and zones // Names for sets and zones
word cellSelectionName; word cellSelectionName;
@ -686,13 +600,7 @@ int main(int argc, char *argv[])
} }
} }
// ------------------------------------------------------------------------
cpuTime timer;
memInfo mem;
Info<< "Initial memory " << mem.update().size() << " kB" << endl;
#include "createMeshes.H"
// Directory management // Directory management
// Sub-directory for output // Sub-directory for output
@ -705,29 +613,39 @@ int main(int argc, char *argv[])
// Overwrite or create the VTK/regionName directories. // Overwrite or create the VTK/regionName directories.
// For the default region, this is simply "VTK/" // For the default region, this is simply "VTK/"
fileName regionDir;
for (const word& regionName : regionNames) for (const word& regionName : regionNames)
{ {
if (regionName != polyMesh::defaultRegion) const word& regionDir =
{ (
regionDir = outputDir / regionName; regionName == polyMesh::defaultRegion ? word::null : regionName
} );
else
{
regionDir = outputDir;
}
if (args.found("overwrite") && isDir(regionDir)) fileName regionalDir(outputDir/regionDir);
if (args.found("overwrite") && Foam::isDir(regionalDir))
{ {
Info<< "Removing old directory " Info<< "Removing old directory "
<< args.relativePath(regionDir) << args.relativePath(regionalDir)
<< nl << endl; << nl << endl;
rmDir(regionDir); Foam::rmDir(regionalDir);
} }
mkDir(regionDir); Foam::mkDir(regionalDir);
} }
} }
// ------------------------------------------------------------------------
cpuTime timer;
memInfo mem;
Info<< "Initial memory " << mem.update().size() << " kB" << endl;
#include "createNamedMeshes.H"
#include "createMeshAccounting.H"
Info<< "VTK mesh topology: "
<< timer.cpuTimeIncrement() << " s, "
<< mem.update().size() << " kB" << endl;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -749,11 +667,13 @@ int main(int argc, char *argv[])
forAll(regionNames, regioni) forAll(regionNames, regioni)
{ {
const word& regionName = regionNames[regioni]; const word& regionName = regionNames[regioni];
const word& regionDir =
fileName regionPrefix; (
if (regionName != polyMesh::defaultRegion) regionName == polyMesh::defaultRegion ? word::null : regionName
);
if (regionNames.size() > 1 || !regionDir.empty())
{ {
regionPrefix = regionName; Info<< "region = " << regionName << nl;
} }
auto& meshProxy = meshProxies[regioni]; auto& meshProxy = meshProxies[regioni];

View File

@ -0,0 +1,45 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
Add multi-region command-line options: -allRegions, -regions, -region
See Also
getAllRegionOptions.H
\*---------------------------------------------------------------------------*/
{
Foam::argList::addBoolOption
(
"allRegions",
"Use all regions in regionProperties"
);
Foam::argList::addOption
(
"regions",
"wordRes",
"Use specified mesh region. Eg, -regions gas\n"
"Or from regionProperties. Eg, -regions '(gas \"solid.*\")'"
);
Foam::argList::addOption
(
"region",
"name",
"Use specified mesh region. Eg, -region gas"
);
}
// ************************************************************************* //

View File

@ -1,5 +1,32 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
Description
Create a fvMesh (specified region or defaultRegion) with
additional handling of -dry-run and -dry-run-write options.
Required Variables
- args [argList]
- runTime [Time]
Provided Variables
- regionName [word]
- mesh [fvMesh]
- meshPtr [autoPtr<fvMesh>]
\*---------------------------------------------------------------------------*/
Foam::autoPtr<Foam::fvMesh> meshPtr(nullptr); Foam::autoPtr<Foam::fvMesh> meshPtr(nullptr);
Foam::word regionName = Foam::fvMesh::defaultRegion; Foam::word regionName(Foam::polyMesh::defaultRegion);
if (args.found("dry-run") || args.found("dry-run-write")) if (args.found("dry-run") || args.found("dry-run-write"))
{ {
@ -42,16 +69,13 @@ else
{ {
if (args.readIfPresent("region", regionName)) if (args.readIfPresent("region", regionName))
{ {
Foam::Info Foam::Info << "Create mesh " << regionName;
<< "Create mesh " << regionName << " for time = "
<< runTime.timeName() << Foam::nl << Foam::endl;
} }
else else
{ {
Foam::Info Foam::Info << "Create mesh";
<< "Create mesh for time = "
<< runTime.timeName() << Foam::nl << Foam::endl;
} }
Foam::Info << " for time = " << runTime.timeName() << Foam::nl;
meshPtr.reset meshPtr.reset
( (
@ -68,6 +92,11 @@ else
) )
); );
meshPtr().init(true); // initialise all (lower levels and current) meshPtr().init(true); // initialise all (lower levels and current)
Foam::Info << Foam::endl;
} }
Foam::fvMesh& mesh = meshPtr(); Foam::fvMesh& mesh = meshPtr();
// ************************************************************************* //

View File

@ -1,4 +1,29 @@
// Currently identical to createMesh.H /*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
Description
Create a fvMesh (defaultRegion)
Required Variables
- runTime [Time]
Provided Variables
- mesh [fvMesh]
Notes
Currently identical to non-dry-run version of createMesh.H
\*---------------------------------------------------------------------------*/
Foam::Info Foam::Info
<< "Create mesh, no clear-out for time = " << "Create mesh, no clear-out for time = "
@ -14,3 +39,6 @@ Foam::fvMesh mesh
Foam::IOobject::MUST_READ Foam::IOobject::MUST_READ
) )
); );
// ************************************************************************* //

View File

@ -1,17 +1,43 @@
Foam::word regionName = Foam::fvMesh::defaultRegion; /*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
Description
Create a fvMesh for a specified region, or the defaultRegion
Required Variables
- args [argList]
- runTime [Time]
Provided Variables
- regionName [word]
- mesh [fvMesh]
\*---------------------------------------------------------------------------*/
Foam::word regionName(Foam::polyMesh::defaultRegion);
{
if (args.readIfPresent("region", regionName)) if (args.readIfPresent("region", regionName))
{ {
Foam::Info Foam::Info << "Create mesh " << regionName;
<< "Create mesh " << regionName << " for time = "
<< runTime.timeName() << Foam::nl << Foam::endl;
} }
else else
{ {
Foam::Info Foam::Info << "Create mesh";
<< "Create mesh for time = "
<< runTime.timeName() << Foam::nl << Foam::endl;
} }
Foam::Info << " for time = " << runTime.timeName() << Foam::nl;
}
Foam::fvMesh mesh Foam::fvMesh mesh
( (
@ -24,4 +50,10 @@ Foam::fvMesh mesh
), ),
false false
); );
mesh.init(true); // initialise all (lower levels and current)
mesh.init(true); // Initialise all (lower levels and current)
Foam::Info << Foam::endl;
// ************************************************************************* //

View File

@ -0,0 +1,73 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
Create single or multiple regions based on the wordList 'regionNames'
Required Variables
- runTime [Time]
- regionNames [wordList]
Provided Variables
- meshes [PtrList<fvMesh>]
See Also
addAllRegionOptions.H
getAllRegionOptions.H
\*---------------------------------------------------------------------------*/
Foam::PtrList<Foam::fvMesh> meshes(regionNames.size());
{
forAll(regionNames, regioni)
{
const Foam::word& regionName = regionNames[regioni];
Foam::Info<< "Create mesh";
if
(
regionNames.size() > 1
|| regionName != Foam::polyMesh::defaultRegion
)
{
Foam::Info<< ' ' << regionName;
}
Foam::Info<< " for time = " << runTime.timeName() << Foam::nl;
meshes.set
(
regioni,
new Foam::fvMesh
(
Foam::IOobject
(
regionName,
runTime.timeName(),
runTime,
Foam::IOobject::MUST_READ
),
false // Do not initialise
)
);
}
for (auto& mesh : meshes)
{
mesh.init(true); // Initialise all (lower levels and current)
}
Foam::Info<< Foam::endl;
}
// ************************************************************************* //

View File

@ -1,17 +1,42 @@
Foam::word regionName = Foam::polyMesh::defaultRegion; /*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
Description
Create a polyMesh for a specified region, or the defaultRegion
Required Variables
- runTime [Time]
Provided Variables
- regionName [word]
- mesh [polyMesh]
\*---------------------------------------------------------------------------*/
Foam::word regionName(Foam::polyMesh::defaultRegion);
{
if (args.readIfPresent("region", regionName)) if (args.readIfPresent("region", regionName))
{ {
Foam::Info Foam::Info << "Create polyMesh " << regionName;
<< "Create polyMesh " << regionName << " for time = "
<< runTime.timeName() << Foam::nl << Foam::endl;
} }
else else
{ {
Foam::Info Foam::Info << "Create polyMesh";
<< "Create polyMesh for time = "
<< runTime.timeName() << Foam::nl << Foam::endl;
} }
Foam::Info << " for time = " << runTime.timeName() << Foam::nl;
}
Foam::polyMesh mesh Foam::polyMesh mesh
( (
@ -23,3 +48,7 @@ Foam::polyMesh mesh
Foam::IOobject::MUST_READ Foam::IOobject::MUST_READ
) )
); );
Foam::Info << Foam::endl;
// ************************************************************************* //

View File

@ -1,6 +1,30 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
Description
Create a polyMesh (defaultRegion only)
Required Variables
- runTime [Time]
Provided Variables
- mesh [polyMesh]
\*---------------------------------------------------------------------------*/
Foam::Info Foam::Info
<< "Create polyMesh for time = " << "Create polyMesh for time = "
<< runTime.timeName() << Foam::nl << Foam::endl; << runTime.timeName() << Foam::nl;
Foam::polyMesh mesh Foam::polyMesh mesh
( (
@ -12,3 +36,7 @@ Foam::polyMesh mesh
Foam::IOobject::MUST_READ Foam::IOobject::MUST_READ
) )
); );
Foam::Info << Foam::endl;
// ************************************************************************* //

View File

@ -0,0 +1,114 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / 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
Gets single or multiple region names based on command-line options:
(-allRegions | -regions | -regions)
Priority
1. -allRegions
2. -regions = specify multiple regions to select, or a single region
3. -region = specify a single region
Note
There is no semantical difference between "-regions name"
and "-region name"
Required Variables
- args [argList]
- runTime [Time]
Provides Variables
- regionNames [wordList]
See Also
addAllRegionOptions.H
\*---------------------------------------------------------------------------*/
wordList regionNames;
{
wordRes selectByName;
if (args.found("allRegions"))
{
regionNames =
regionProperties(runTime, IOobject::READ_IF_PRESENT).names();
if (regionNames.empty())
{
InfoErr
<< "Warning: No regionProperties, assume default region"
<< nl << endl;
}
else
{
Info<< "Using all regions: " << flatOutput(regionNames) << nl;
}
}
else if (args.readListIfPresent<wordRe>("regions", selectByName))
{
if
(
selectByName.size() == 1
&& selectByName.first().isLiteral()
)
{
// Identical to -region NAME
regionNames.resize(1);
regionNames.first() = selectByName.first();
}
else if (selectByName.size())
{
regionNames =
regionProperties(runTime, IOobject::READ_IF_PRESENT).names();
if (regionNames.empty())
{
Info<< "Warning: No regionProperties, assume default region"
<< nl << endl;
}
else
{
const labelList matching = selectByName.matching(regionNames);
if (matching.empty())
{
InfoErr
<< "No match in regions: "
<< flatOutput(regionNames) << nl
<< "... stopping" << nl << endl;
return 1;
}
regionNames = wordList(regionNames, matching);
Info<< "Using regions: " << flatOutput(regionNames) << nl;
}
}
}
else if (args.found("region"))
{
regionNames.resize(1);
regionNames.first() = args.get<word>("region");
}
// Fallback to defaultRegion
if (regionNames.empty())
{
regionNames.resize(1);
regionNames.first() = polyMesh::defaultRegion;
}
}
// ************************************************************************* //

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2016 OpenFOAM Foundation Copyright (C) 2012-2016 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -280,4 +281,35 @@ Foam::tmp<Foam::scalarField> Foam::polyMeshTools::volRatio
} }
Foam::polyMesh::readUpdateState Foam::polyMeshTools::combine
(
const polyMesh::readUpdateState& state0,
const polyMesh::readUpdateState& state1
)
{
if
(
(
state0 == polyMesh::UNCHANGED
&& state1 != polyMesh::UNCHANGED
)
|| (
state0 == polyMesh::POINTS_MOVED
&& (state1 != polyMesh::UNCHANGED && state1 != polyMesh::POINTS_MOVED)
)
|| (
state0 == polyMesh::TOPO_CHANGE
&& state1 == polyMesh::TOPO_PATCH_CHANGE
)
)
{
return state1;
}
else
{
return state0;
}
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -6,6 +6,7 @@
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2012-2013 OpenFOAM Foundation Copyright (C) 2012-2013 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -92,6 +93,13 @@ public:
const scalarField& vol const scalarField& vol
); );
//- Combine readUpdateState. topo change trumps geom-only
// change etc.
static polyMesh::readUpdateState combine
(
const polyMesh::readUpdateState& state0,
const polyMesh::readUpdateState& state1
);
}; };

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2017-2020 OpenCFD Ltd. Copyright (C) 2017-2021 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -280,11 +280,10 @@ bool Foam::functionObjects::vtkWrite::write()
label regioni = 0; label regioni = 0;
for (const word& regionName : meshes_.sortedToc()) for (const word& regionName : meshes_.sortedToc())
{ {
fileName regionPrefix; const word& regionDir =
if (regionName != polyMesh::defaultRegion) (
{ regionName == polyMesh::defaultRegion ? word::null : regionName
regionPrefix = regionName; );
}
auto& meshProxy = meshSubsets_[regioni]; auto& meshProxy = meshSubsets_[regioni];
auto& vtuMeshCells = vtuMappings_[regioni]; auto& vtuMeshCells = vtuMappings_[regioni];
@ -331,7 +330,7 @@ bool Foam::functionObjects::vtkWrite::write()
fileName vtmOutputBase fileName vtmOutputBase
( (
outputDir_/regionPrefix/vtkName + timeDesc outputDir_/regionDir/vtkName + timeDesc
); );
// Combined internal + boundary in a vtm file // Combined internal + boundary in a vtm file
@ -412,7 +411,7 @@ bool Foam::functionObjects::vtkWrite::write()
// Output name for one patch: "boundary" // Output name for one patch: "boundary"
( (
writeOpts_.legacy() writeOpts_.legacy()
? (outputDir_/regionPrefix/"boundary"/"boundary" + timeDesc) ? (outputDir_/regionDir/"boundary"/"boundary" + timeDesc)
: (vtmOutputBase / "boundary") : (vtmOutputBase / "boundary")
), ),
Pstream::parRun() Pstream::parRun()
@ -464,7 +463,7 @@ bool Foam::functionObjects::vtkWrite::write()
writeOpts_.legacy() writeOpts_.legacy()
? ?
( (
outputDir_/regionPrefix/pp.name() outputDir_/regionDir/pp.name()
/ (pp.name()) + timeDesc / (pp.name()) + timeDesc
) )
: (vtmOutputBase / "boundary" / pp.name()) : (vtmOutputBase / "boundary" / pp.name())
@ -704,7 +703,7 @@ bool Foam::functionObjects::vtkWrite::write()
series.write(seriesName); series.write(seriesName);
// Add to multi-region vtm // Add to multi-region vtm
vtmMultiRegion.add(regionName, regionPrefix, vtmWriter); vtmMultiRegion.add(regionName, regionDir, vtmWriter);
} }
if (vtmBoundaries.size()) if (vtmBoundaries.size())