mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -116,6 +116,22 @@ Foam::coordinateSystems::coordinateSystems(const IOobject& io)
|
||||
}
|
||||
|
||||
|
||||
Foam::coordinateSystems::coordinateSystems(const objectRegistry& obr)
|
||||
:
|
||||
coordinateSystems
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
typeName,
|
||||
obr.time().constant(),
|
||||
obr,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
)
|
||||
{}
|
||||
|
||||
|
||||
Foam::coordinateSystems::coordinateSystems
|
||||
(
|
||||
const IOobject& io,
|
||||
@ -162,20 +178,7 @@ const Foam::coordinateSystems& Foam::coordinateSystems::New
|
||||
}
|
||||
|
||||
// Read construct from registry
|
||||
return obr.store
|
||||
(
|
||||
new coordinateSystems
|
||||
(
|
||||
IOobject
|
||||
(
|
||||
typeName,
|
||||
obr.time().constant(),
|
||||
obr,
|
||||
IOobject::READ_IF_PRESENT,
|
||||
IOobject::NO_WRITE
|
||||
)
|
||||
)
|
||||
);
|
||||
return obr.store(new coordinateSystems(obr));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -107,6 +107,10 @@ public:
|
||||
//- Read construct from IOobject
|
||||
explicit coordinateSystems(const IOobject& io);
|
||||
|
||||
//- Read construct "coordinateSystems" from "constant"
|
||||
//- using given registry
|
||||
explicit coordinateSystems(const objectRegistry& obr);
|
||||
|
||||
//- Construct from IOobject and PtrList content
|
||||
coordinateSystems
|
||||
(
|
||||
|
||||
@ -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_
|
||||
(
|
||||
|
||||
@ -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
|
||||
(
|
||||
|
||||
@ -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 << " :"
|
||||
|
||||
@ -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
|
||||
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 coordinate system | 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
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: v2112 |
|
||||
| \\ / O peration | Version: v2206 |
|
||||
| \\ / A nd | Website: www.openfoam.com |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
@ -26,8 +26,9 @@ porosity1
|
||||
coordinateSystem
|
||||
{
|
||||
origin (0 0 0);
|
||||
e1 (0.70710678 0.70710678 0);
|
||||
e2 (0 0 1);
|
||||
rotation axisAngle;
|
||||
axis (0 0 1);
|
||||
angle 45;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -94,7 +94,7 @@ plane
|
||||
writeControl writeTime;
|
||||
|
||||
surfaceFormat vtk;
|
||||
fields ( cellZoneID );
|
||||
fields ( cellZoneID U );
|
||||
|
||||
surfaces
|
||||
{
|
||||
@ -105,6 +105,24 @@ plane
|
||||
normal (0 0 1);
|
||||
interpolate false;
|
||||
}
|
||||
|
||||
slices
|
||||
{
|
||||
type cuttingPlane;
|
||||
point (0 0 0);
|
||||
normal (1 0 0);
|
||||
offsets (0.02 0.04 0.06 0.08);
|
||||
|
||||
interpolate true;
|
||||
|
||||
transform
|
||||
{
|
||||
origin (0 0 0);
|
||||
rotation axisAngle;
|
||||
axis (0 0 1);
|
||||
angle 45;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: v2112 |
|
||||
| \\ / O peration | Version: v2206 |
|
||||
| \\ / A nd | Website: www.openfoam.com |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
@ -55,8 +55,7 @@ geometry
|
||||
transform
|
||||
{
|
||||
origin (2 2 0);
|
||||
e1 (1 0 0);
|
||||
e3 (0 0 1);
|
||||
rotation none;
|
||||
}
|
||||
}
|
||||
herring
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
/*--------------------------------*- C++ -*----------------------------------*\
|
||||
| ========= | |
|
||||
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
|
||||
| \\ / O peration | Version: v2112 |
|
||||
| \\ / O peration | Version: v2206 |
|
||||
| \\ / A nd | Website: www.openfoam.com |
|
||||
| \\/ M anipulation | |
|
||||
\*---------------------------------------------------------------------------*/
|
||||
@ -53,20 +53,10 @@ geometry
|
||||
surface box1;
|
||||
scale (1.0 1.0 2.1);
|
||||
|
||||
// Old syntax
|
||||
transform
|
||||
{
|
||||
coordinateSystem
|
||||
{
|
||||
type cartesian;
|
||||
origin (2 2 0);
|
||||
rotation
|
||||
{
|
||||
type axes;
|
||||
e1 (1 0 0);
|
||||
e3 (0 0 1);
|
||||
}
|
||||
}
|
||||
rotation none;
|
||||
}
|
||||
}
|
||||
herring
|
||||
@ -74,7 +64,6 @@ geometry
|
||||
surface box1;
|
||||
scale (1.0 1.0 2.1);
|
||||
|
||||
// Simplified syntax
|
||||
transform
|
||||
{
|
||||
origin (3.5 3 0);
|
||||
|
||||
Reference in New Issue
Block a user