ENH: add createNamedPolyMeshes.H file

This commit is contained in:
Mark Olesen
2022-02-28 14:15:39 +01:00
parent 02f57f8a36
commit cb10045094
4 changed files with 75 additions and 15 deletions

View File

@ -67,13 +67,10 @@ if (args.dryRun() || args.found("dry-run-write"))
} }
else else
{ {
Foam::Info << "Create mesh";
if (args.readIfPresent("region", regionName)) if (args.readIfPresent("region", regionName))
{ {
Foam::Info << "Create mesh " << regionName; Foam::Info << ' ' << regionName;
}
else
{
Foam::Info << "Create mesh";
} }
Foam::Info << " for time = " << runTime.timeName() << Foam::nl; Foam::Info << " for time = " << runTime.timeName() << Foam::nl;

View File

@ -27,13 +27,10 @@ Provided Variables
Foam::word regionName(Foam::polyMesh::defaultRegion); Foam::word regionName(Foam::polyMesh::defaultRegion);
{ {
Foam::Info << "Create mesh";
if (args.readIfPresent("region", regionName)) if (args.readIfPresent("region", regionName))
{ {
Foam::Info << "Create mesh " << regionName; Foam::Info << ' ' << regionName;
}
else
{
Foam::Info << "Create mesh";
} }
Foam::Info << " for time = " << runTime.timeName() << Foam::nl; Foam::Info << " for time = " << runTime.timeName() << Foam::nl;
} }

View File

@ -26,13 +26,10 @@ Provided Variables
Foam::word regionName(Foam::polyMesh::defaultRegion); Foam::word regionName(Foam::polyMesh::defaultRegion);
{ {
Foam::Info << "Create polyMesh";
if (args.readIfPresent("region", regionName)) if (args.readIfPresent("region", regionName))
{ {
Foam::Info << "Create polyMesh " << regionName; Foam::Info << ' ' << regionName;
}
else
{
Foam::Info << "Create polyMesh";
} }
Foam::Info << " for time = " << runTime.timeName() << Foam::nl; Foam::Info << " for time = " << runTime.timeName() << Foam::nl;
} }
@ -51,4 +48,5 @@ Foam::polyMesh mesh
Foam::Info << Foam::endl; Foam::Info << Foam::endl;
// ************************************************************************* // // ************************************************************************* //

View File

@ -0,0 +1,68 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
Description
Create single or multiple polyMesh regions based on the
wordList 'regionNames'
Required Variables
- runTime [Time]
- regionNames [wordList]
Provided Variables
- meshes [PtrList<polyMesh>]
See Also
addAllRegionOptions.H
getAllRegionOptions.H
\*---------------------------------------------------------------------------*/
Foam::PtrList<Foam::polyMesh> meshes(regionNames.size());
{
forAll(regionNames, regioni)
{
const Foam::word& regionName = regionNames[regioni];
Foam::Info<< "Create polyMesh";
if
(
regionNames.size() > 1
|| regionName != Foam::polyMesh::defaultRegion
)
{
Foam::Info<< ' ' << regionName;
}
Foam::Info<< " for time = " << runTime.timeName() << Foam::nl;
meshes.set
(
regioni,
new Foam::polyMesh
(
Foam::IOobject
(
regionName,
runTime.timeName(),
runTime,
Foam::IOobject::MUST_READ
)
)
);
}
Foam::Info<< Foam::endl;
}
// ************************************************************************* //