mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: multi-region support for transformPoints (#2080)
This commit is contained in:
@ -0,0 +1,49 @@
|
|||||||
|
/*---------------------------------------------------------------------------*\
|
||||||
|
========= |
|
||||||
|
\\ / 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 a fvMesh for a specified named region
|
||||||
|
|
||||||
|
Required Variables
|
||||||
|
- regionName [word]
|
||||||
|
- runTime [Time]
|
||||||
|
|
||||||
|
Provided Variables
|
||||||
|
- mesh [fvMesh]
|
||||||
|
|
||||||
|
\*---------------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
Foam::Info << "Create mesh";
|
||||||
|
if (regionName != Foam::polyMesh::defaultRegion)
|
||||||
|
{
|
||||||
|
Foam::Info << ' ' << regionName;
|
||||||
|
}
|
||||||
|
Foam::Info << " for time = " << runTime.timeName() << Foam::nl;
|
||||||
|
|
||||||
|
Foam::fvMesh mesh
|
||||||
|
(
|
||||||
|
Foam::IOobject
|
||||||
|
(
|
||||||
|
regionName,
|
||||||
|
runTime.timeName(),
|
||||||
|
runTime,
|
||||||
|
Foam::IOobject::MUST_READ
|
||||||
|
),
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
|
mesh.init(true); // Initialise all (lower levels and current)
|
||||||
|
|
||||||
|
Foam::Info << Foam::endl;
|
||||||
|
|
||||||
|
|
||||||
|
// ************************************************************************* //
|
||||||
@ -6,7 +6,7 @@
|
|||||||
\\/ M anipulation |
|
\\/ M anipulation |
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
Copyright (C) 2011-2016 OpenFOAM Foundation
|
Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||||
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.
|
||||||
@ -79,6 +79,7 @@ Note
|
|||||||
#include "surfaceFields.H"
|
#include "surfaceFields.H"
|
||||||
#include "ReadFields.H"
|
#include "ReadFields.H"
|
||||||
#include "pointFields.H"
|
#include "pointFields.H"
|
||||||
|
#include "regionProperties.H"
|
||||||
#include "transformField.H"
|
#include "transformField.H"
|
||||||
#include "transformGeometricField.H"
|
#include "transformGeometricField.H"
|
||||||
#include "axisAngleRotation.H"
|
#include "axisAngleRotation.H"
|
||||||
@ -99,18 +100,18 @@ void readAndRotateFields
|
|||||||
)
|
)
|
||||||
{
|
{
|
||||||
ReadFields(mesh, objects, flds);
|
ReadFields(mesh, objects, flds);
|
||||||
forAll(flds, i)
|
for (GeoField& fld : flds)
|
||||||
{
|
{
|
||||||
Info<< "Transforming " << flds[i].name() << endl;
|
Info<< "Transforming " << fld.name() << endl;
|
||||||
const dimensionedTensor dimT("t", flds[i].dimensions(), rotT);
|
const dimensionedTensor dimT("t", fld.dimensions(), rotT);
|
||||||
transform(flds[i], dimT, flds[i]);
|
transform(fld, dimT, fld);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void rotateFields(const argList& args, const Time& runTime, const tensor& T)
|
void rotateFields(const word& regionName, const Time& runTime, const tensor& T)
|
||||||
{
|
{
|
||||||
#include "createNamedMesh.H"
|
#include "createRegionMesh.H"
|
||||||
|
|
||||||
// Read objects in time directory
|
// Read objects in time directory
|
||||||
IOobjectList objects(mesh, runTime.timeName());
|
IOobjectList objects(mesh, runTime.timeName());
|
||||||
@ -300,7 +301,7 @@ int main(int argc, char *argv[])
|
|||||||
// Compatibility with surfaceTransformPoints
|
// Compatibility with surfaceTransformPoints
|
||||||
argList::addOptionCompat("scale", {"write-scale", 0});
|
argList::addOptionCompat("scale", {"write-scale", 0});
|
||||||
|
|
||||||
#include "addRegionOption.H"
|
#include "addAllRegionOptions.H"
|
||||||
#include "setRootCase.H"
|
#include "setRootCase.H"
|
||||||
|
|
||||||
const bool doRotateFields = args.found("rotateFields");
|
const bool doRotateFields = args.found("rotateFields");
|
||||||
@ -336,16 +337,10 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
#include "createTime.H"
|
#include "createTime.H"
|
||||||
|
|
||||||
word regionName = polyMesh::defaultRegion;
|
|
||||||
fileName meshDir = polyMesh::meshSubDir;
|
|
||||||
|
|
||||||
if (args.readIfPresent("region", regionName))
|
|
||||||
{
|
|
||||||
meshDir = regionName/polyMesh::meshSubDir;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (args.found("time"))
|
if (args.found("time"))
|
||||||
{
|
{
|
||||||
if (args["time"] == "constant")
|
if (args["time"] == "constant")
|
||||||
@ -359,6 +354,25 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handle -allRegions, -regions, -region
|
||||||
|
#include "getAllRegionOptions.H"
|
||||||
|
|
||||||
|
// ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
forAll(regionNames, regioni)
|
||||||
|
{
|
||||||
|
const word& regionName = regionNames[regioni];
|
||||||
|
const word& regionDir =
|
||||||
|
(
|
||||||
|
regionName == polyMesh::defaultRegion ? word::null : regionName
|
||||||
|
);
|
||||||
|
const fileName meshDir = regionDir/polyMesh::meshSubDir;
|
||||||
|
|
||||||
|
if (regionNames.size() > 1)
|
||||||
|
{
|
||||||
|
Info<< "region=" << regionName << nl;
|
||||||
|
}
|
||||||
|
|
||||||
pointIOField points
|
pointIOField points
|
||||||
(
|
(
|
||||||
IOobject
|
IOobject
|
||||||
@ -420,7 +434,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (doRotateFields)
|
if (doRotateFields)
|
||||||
{
|
{
|
||||||
rotateFields(args, runTime, rot);
|
rotateFields(regionName, runTime, rot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (args.found("rotate-angle"))
|
else if (args.found("rotate-angle"))
|
||||||
@ -444,7 +458,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (doRotateFields)
|
if (doRotateFields)
|
||||||
{
|
{
|
||||||
rotateFields(args, runTime, rot);
|
rotateFields(regionName, runTime, rot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (args.readIfPresent("rollPitchYaw", v))
|
else if (args.readIfPresent("rollPitchYaw", v))
|
||||||
@ -461,7 +475,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (doRotateFields)
|
if (doRotateFields)
|
||||||
{
|
{
|
||||||
rotateFields(args, runTime, rot);
|
rotateFields(regionName, runTime, rot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (args.readIfPresent("yawPitchRoll", v))
|
else if (args.readIfPresent("yawPitchRoll", v))
|
||||||
@ -478,7 +492,7 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (doRotateFields)
|
if (doRotateFields)
|
||||||
{
|
{
|
||||||
rotateFields(args, runTime, rot);
|
rotateFields(regionName, runTime, rot);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -495,8 +509,11 @@ int main(int argc, char *argv[])
|
|||||||
// Set the precision of the points data to 10
|
// Set the precision of the points data to 10
|
||||||
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision()));
|
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision()));
|
||||||
|
|
||||||
Info<< "Writing points into directory " << points.path() << nl << endl;
|
Info<< "Writing points into directory "
|
||||||
|
<< runTime.relativePath(points.path()) << nl
|
||||||
|
<< endl;
|
||||||
points.write();
|
points.write();
|
||||||
|
}
|
||||||
|
|
||||||
Info<< nl << "End" << nl << endl;
|
Info<< nl << "End" << nl << endl;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user