ENH: support coordinateSystem/transform for sampled planes

- previously only defined for cell-cutting version, now for
  iso-surface version too

TUT: remove old transform/coordinateSystem syntax
This commit is contained in:
Mark Olesen
2022-06-08 12:28:02 +02:00
parent fbaadf3a94
commit 9a75ce8434
10 changed files with 197 additions and 79 deletions

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2021 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -31,6 +31,7 @@ License
#include "fvMesh.H"
#include "volFields.H"
#include "volPointInterpolation.H"
#include "cartesianCS.H"
#include "addToRunTimeSelectionTable.H"
#include "PtrList.H"
@ -51,6 +52,64 @@ namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::plane Foam::sampledCuttingPlane::definePlane
(
const polyMesh& mesh,
const dictionary& dict
)
{
plane pln(dict);
bool adjust = false;
const dictionary* dictptr = nullptr;
coordSystem::cartesian cs;
if (dict.found(coordinateSystem::typeName_(), keyType::LITERAL))
{
// Create with registry to allow lookup from globally defined
// coordinate systems?
auto csPtr =
coordinateSystem::New(mesh, dict, coordinateSystem::typeName_());
if (csPtr)
{
adjust = true;
cs = csPtr();
}
}
else if
(
(dictptr = dict.findDict("transform", keyType::LITERAL)) != nullptr
)
{
adjust = true;
cs = coordSystem::cartesian(*dictptr);
}
// Make plane relative to the Cartesian coordinate system
if (adjust)
{
const point orig = cs.globalPosition(pln.origin());
const vector norm = cs.globalVector(pln.normal());
DebugInfo
<< "plane "
<< " origin:" << pln.origin()
<< " normal:" << pln.normal()
<< " =>"
<< " origin:" << orig << " normal:" << norm
<< endl;
// Reassign the plane
pln = plane(orig, norm);
}
return pln;
}
void Foam::sampledCuttingPlane::checkBoundsIntersection
(
const plane& pln,
@ -512,7 +571,7 @@ Foam::sampledCuttingPlane::sampledCuttingPlane
)
:
sampledSurface(name, mesh, dict),
plane_(dict),
plane_(definePlane(mesh, dict)),
offsets_(),
isoParams_
(

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2021 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -60,6 +60,8 @@ Usage
exposedPatchName | name for zone subset | optional |
regularise | Face simplification (enum or bool) | no | true
mergeTol | tolerance for merging points | no | 1e-6
coordinateSystem | define plane within given cartesian system | no |
transform | define plane within given cartesian system | no |
\endtable
Note
@ -73,8 +75,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef sampledCuttingPlane_H
#define sampledCuttingPlane_H
#ifndef Foam_sampledCuttingPlane_H
#define Foam_sampledCuttingPlane_H
#include "sampledSurface.H"
#include "plane.H"
@ -153,6 +155,10 @@ class sampledCuttingPlane
// Private Member Functions
//- Define plane from dictionary entry and apply any coordinate
//- transformations
static plane definePlane(const polyMesh& mesh, const dictionary& dict);
//- Check and warn if bounding box does not intersect mesh or plane
void checkBoundsIntersection
(

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2021 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -50,6 +50,65 @@ namespace Foam
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
Foam::plane Foam::sampledPlane::definePlane
(
const polyMesh& mesh,
const dictionary& dict
)
{
plane pln(dict);
bool adjust = false;
const dictionary* dictptr = nullptr;
coordSystem::cartesian cs;
if (dict.found(coordinateSystem::typeName_(), keyType::LITERAL))
{
// Create with registry to allow lookup from globally defined
// coordinate systems?
auto csPtr =
coordinateSystem::New(mesh, dict, coordinateSystem::typeName_());
if (csPtr)
{
adjust = true;
cs = csPtr();
}
}
else if
(
(dictptr = dict.findDict("transform", keyType::LITERAL)) != nullptr
)
{
adjust = true;
cs = coordSystem::cartesian(*dictptr);
}
// Make plane relative to the Cartesian coordinate system
if (adjust)
{
const point orig = cs.globalPosition(pln.origin());
const vector norm = cs.globalVector(pln.normal());
DebugInfo
<< "plane "
<< " origin:" << pln.origin()
<< " normal:" << pln.normal()
<< " =>"
<< " origin:" << orig
<< " normal:" << norm
<< endl;
// Reassign the plane
pln = plane(orig, norm);
}
return pln;
}
Foam::bitSet Foam::sampledPlane::cellSelection(const bool warn) const
{
return cuttingPlane::cellSelection
@ -105,7 +164,7 @@ Foam::sampledPlane::sampledPlane
)
:
sampledSurface(name, mesh, dict),
cuttingPlane(plane(dict)),
cuttingPlane(definePlane(mesh, dict)),
zoneNames_(),
bounds_(dict.getOrDefault("bounds", boundBox::invertedBox)),
triangulate_(dict.getOrDefault("triangulate", true)),
@ -117,31 +176,6 @@ Foam::sampledPlane::sampledPlane
dict.readEntry("zone", zoneNames_.first());
}
// Make plane relative to the coordinateSystem (Cartesian)
// allow lookup from global coordinate systems
if (dict.found(coordinateSystem::typeName_()))
{
coordSystem::cartesian cs
(
coordinateSystem::New(mesh, dict, coordinateSystem::typeName_())
);
plane& pln = planeDesc();
const point orig = cs.globalPosition(pln.origin());
const vector norm = cs.globalVector(pln.normal());
DebugInfo
<< "plane " << name << " :"
<< " origin:" << origin()
<< " normal:" << normal()
<< " defined within a local coordinateSystem" << endl;
// Reassign the plane
pln = plane(orig, norm);
}
if (debug)
{
Info<< "plane " << name << " :"

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2021 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -49,14 +49,15 @@ Usage
Where the sub-entries comprise:
\table
Property | Description | Required | Default
type | plane | yes |
planeType | Plane description (pointAndNormal etc) | no |
triangulate | triangulate faces | no | true
bounds | limit with bounding box | no |
zone | limit to cell zone (name or regex) | no |
zones | limit to cell zones (names, regexs) | no |
coordinateSystem | define plane within given coordinate system | no |
Property | Description | Reqd | Default
type | plane | yes |
planeType | Plane description (pointAndNormal etc) | no |
triangulate | triangulate faces | no | true
bounds | limit with bounding box | no |
zone | limit to cell zone (name or regex) | no |
zones | limit to cell zones (names, regexs) | no |
coordinateSystem | define plane within given cartesian system | no |
transform | define plane within given cartesian system | no |
\endtable
SeeAlso
@ -73,8 +74,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef sampledPlane_H
#define sampledPlane_H
#ifndef Foam_sampledPlane_H
#define Foam_sampledPlane_H
#include "sampledSurface.H"
#include "cuttingPlane.H"
@ -110,6 +111,10 @@ class sampledPlane
// Private Member Functions
//- Define plane from dictionary entry and apply any coordinate
//- transformations
static plane definePlane(const polyMesh& mesh, const dictionary& dict);
//- Define cell selection from zones and bounding box.
// Optionally check and warn if the plane does not intersect
// with the bounds of the mesh (or submesh) or if the bounding box