ENH: make 'planeType' optional for dictionary construct of a plane

- simpler to write for sampled cutting planes etc.
  For example,

      slice
      {
          type        cuttingPlane;
          point       (0 0 0);
          normal      (0 0 1);
          interpolate true;
      }

  instead of

      slice
      {
          type        cuttingPlane;
          planeType   pointAndNormal;
          pointAndNormalDict
          {
              point   (0 0 0);
              normal  (0 0 1);
          }
          interpolate true;
      }

STYLE: add noexcept to some plane methods
This commit is contained in:
Mark Olesen 2022-06-08 11:19:08 +02:00
parent da157dca47
commit fbaadf3a94
26 changed files with 166 additions and 271 deletions

View File

@ -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 | |
\*---------------------------------------------------------------------------*/
@ -190,16 +190,10 @@ surfaces
cutting
{
type plane;
planeType pointAndNormal;
pointAndNormalDict
{
point (100 100 50);
normal (1 0 0);
}
offsets (0 100 200);
type plane;
point (100 100 50);
normal (1 0 0);
offsets (0 100 200);
smooth true;
colourMap coolToWarm;

View File

@ -151,12 +151,8 @@ sets
// Surface sampling definition
//
// 1] patches are not triangulated by default
// 2] planes are always triangulated
// 3] iso-surfaces are always triangulated
surfaces
(
{
constantPlane
{
type plane; // always triangulated
@ -262,15 +258,11 @@ surfaces
triangleCut
{
// Cutingplane using iso surface
type cuttingPlane;
planeType pointAndNormal;
pointAndNormalDict
{
basePoint (0.4 0 0.4);
normalVector (1 0.2 0.2);
}
interpolate true;
// Cutting plane : using iso surface
type cuttingPlane;
point (0.4 0 0.4);
normal (1 0.2 0.2);
interpolate true;
//zone ABC; // Optional: zone only
//exposedPatchName fixedWalls; // Optional: zone only
@ -310,7 +302,7 @@ surfaces
// boundaryFaces (nearest boundary face)
interpolate true;
}
);
}
// *********************************************************************** //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016-2018 OpenCFD Ltd.
Copyright (C) 2016-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -26,6 +26,7 @@ License
\*---------------------------------------------------------------------------*/
#include "dictionary.H"
#include "plane.H"
#include "tensor.H"
@ -141,7 +142,7 @@ Foam::plane::plane
}
Foam::plane::plane(const scalarList& coeffs)
Foam::plane::plane(const UList<scalar>& coeffs)
{
calcFromCoeffs
(
@ -178,9 +179,28 @@ Foam::plane::plane(const dictionary& dict)
normal_(Zero),
origin_(Zero)
{
const word planeType(dict.get<word>("planeType"));
word planeType;
dict.readIfPresent("planeType", planeType);
if (planeType == "planeEquation")
if (planeType.empty())
{
const dictionary& coeffs = dict.optionalSubDict("pointAndNormalDict");
origin_ = coeffs.get<point>("point");
normal_ = coeffs.get<point>("normal");
makeUnitNormal("point/normal");
}
else if (planeType == "pointAndNormal")
{
const dictionary& coeffs = dict.subDict("pointAndNormalDict");
origin_ = coeffs.getCompat<point>("point", {{"basePoint", 1612}});
normal_ = coeffs.getCompat<point>("normal", {{"normalVector", 1612}});
makeUnitNormal("point/normal");
}
else if (planeType == "planeEquation")
{
const dictionary& subDict = dict.subDict("planeEquationDict");
@ -190,7 +210,7 @@ Foam::plane::plane(const dictionary& dict)
subDict.get<scalar>("b"),
subDict.get<scalar>("c"),
subDict.get<scalar>("d"),
"planeEquationDict" // caller name for makeUnitNormal
"planeEquation" // caller name for makeUnitNormal
);
}
else if (planeType == "embeddedPoints")
@ -202,18 +222,8 @@ Foam::plane::plane(const dictionary& dict)
subDict.get<point>("point1"),
subDict.get<point>("point2"),
subDict.get<point>("point3"),
"embeddedPointsDict" // caller name for makeUnitNormal
"embeddedPoints" // caller name for makeUnitNormal
);
}
else if (planeType == "pointAndNormal")
{
const dictionary& subDict = dict.subDict("pointAndNormalDict");
origin_ = subDict.getCompat<point>("point", {{"basePoint", 1612}});
normal_ = subDict.getCompat<point>("normal", {{"normalVector", 1612}});
makeUnitNormal("pointAndNormalDict");
}
else
{
@ -238,7 +248,7 @@ Foam::plane::plane(Istream& is)
Foam::FixedList<Foam::scalar, 4> Foam::plane::planeCoeffs() const
{
FixedList<scalar, 4> coeffs(4);
FixedList<scalar, 4> coeffs;
const scalar magX = mag(normal_.x());
const scalar magY = mag(normal_.y());

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2017-2019 OpenCFD Ltd.
Copyright (C) 2017-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -31,14 +31,16 @@ Description
Geometric class that creates a 3D plane and can return the intersection
point between a line and the plane.
Construction from a dictionary is driven by the \c planeType
Construction from a dictionary is driven by the \c planeType.
If \c planeType is missing, \c pointAndNormal is used and the
\c pointAndNormalDict becomes optional.
For \c planeType as \c pointAndNormal :
\verbatim
pointAndNormalDict
{
point <point>; // or basePoint
normal <vector>; // or normalVector
point <point>; // basePoint (1612 and earlier)
normal <vector>; // normalVector (1612 and earlier)
}
\endverbatim
@ -66,16 +68,16 @@ Description
\endverbatim
SourceFiles
planeI.H
plane.C
\*---------------------------------------------------------------------------*/
#ifndef plane_H
#define plane_H
#ifndef Foam_plane_H
#define Foam_plane_H
#include "point.H"
#include "scalarList.H"
#include "dictionary.H"
#include "line.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -83,6 +85,9 @@ SourceFiles
namespace Foam
{
// Forward Declarations
class dictionary;
/*---------------------------------------------------------------------------*\
Class plane Declaration
\*---------------------------------------------------------------------------*/
@ -115,12 +120,12 @@ public:
dir_(dir)
{}
const point& refPoint() const
const point& refPoint() const noexcept
{
return pt_;
}
const vector& dir() const
const vector& dir() const noexcept
{
return dir_;
}
@ -199,7 +204,7 @@ public:
//- Construct from coefficients for the plane equation:
//- ax + by + cz + d = 0
explicit plane(const scalarList& coeffs);
explicit plane(const UList<scalar>& coeffs);
//- Construct from coefficients for the plane equation:
//- ax + by + cz + d = 0
@ -215,16 +220,13 @@ public:
// Member Functions
//- The plane unit normal
inline const vector& normal() const;
inline const vector& normal() const noexcept;
//- The plane base point
inline const point& origin() const;
inline const point& origin() const noexcept;
//- The plane base point, for modification
inline point& origin();
//- The plane base point (same as origin)
inline const point& refPoint() const;
inline point& origin() noexcept;
//- Flip the plane by reversing the normal
inline void flip();
@ -292,16 +294,22 @@ public:
//- Write to dictionary
void writeDict(Ostream& os) const;
// Housekeeping
//- The plane base point (same as origin)
const point& refPoint() const noexcept { return origin_; }
};
// IOstream Operators
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
//- Write plane normal, origin
Ostream& operator<<(Ostream& os, const plane& pln);
// Global Operators
// * * * * * * * * * * * * * * * Global Operators * * * * * * * * * * * * * //
//- Test for equality of origin and normal
inline bool operator==(const plane& a, const plane& b);

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2019 OpenCFD Ltd.
Copyright (C) 2018-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -36,25 +36,19 @@ inline Foam::plane::plane()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline const Foam::vector& Foam::plane::normal() const
inline const Foam::vector& Foam::plane::normal() const noexcept
{
return normal_;
}
inline const Foam::point& Foam::plane::origin() const
inline const Foam::point& Foam::plane::origin() const noexcept
{
return origin_;
}
inline Foam::point& Foam::plane::origin()
{
return origin_;
}
inline const Foam::point& Foam::plane::refPoint() const
inline Foam::point& Foam::plane::origin() noexcept
{
return origin_;
}

View File

@ -40,12 +40,9 @@ Usage
{
surface1
{
type cuttingPlane;
planeType pointAndNormal;
pointAndNormalDict
{
...
}
type cuttingPlane;
point ...;
normal ...;
}
}
\endverbatim
@ -54,7 +51,7 @@ Usage
\table
Property | Description | Required | Default
type | cuttingPlane | yes |
planeType | plane description (pointAndNormal etc) | yes |
planeType | Plane description (pointAndNormal etc) | no |
offsets | Offsets of the origin in the normal direction | no | (0)
isoMethod | Iso-algorithm (cell/topo/point) | no | topo
bounds | limit with bounding box | no |

View File

@ -41,11 +41,8 @@ Usage
surface1
{
type plane;
planeType pointAndNormal;
pointAndNormalDict
{
...
}
point ...;
normal ...;
}
}
\endverbatim
@ -54,7 +51,7 @@ Usage
\table
Property | Description | Required | Default
type | plane | yes |
planeType | plane description (pointAndNormal etc) | 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 |

View File

@ -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 | |
\*---------------------------------------------------------------------------*/
@ -22,14 +22,10 @@ cuttingPlane
{
zNormal
{
type cuttingPlane;
planeType pointAndNormal;
pointAndNormalDict
{
point (0 0 0);
normal (0 0 1);
}
interpolate true;
type cuttingPlane;
point (0 0 0);
normal (0 0 1);
interpolate true;
}
}
}

View File

@ -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 | |
\*---------------------------------------------------------------------------*/
@ -100,14 +100,10 @@ plane
{
zNormal
{
type cuttingPlane;
planeType pointAndNormal;
pointAndNormalDict
{
point (0 0 0);
normal (0 0 1);
}
interpolate false;
type cuttingPlane;
point (0 0 0);
normal (0 0 1);
interpolate false;
}
}
}

View File

@ -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 | |
\*---------------------------------------------------------------------------*/
@ -80,13 +80,8 @@ sampled
source cells;
store true;
planeType pointAndNormal;
pointAndNormalDict
{
normal (-1 0 0);
point (-0.04 0 0);
}
point (-0.04 0 0);
normal (-1 0 0);
}
surfaces

View File

@ -43,14 +43,9 @@ debug
source cells;
triangulate false;
planeType pointAndNormal;
pointAndNormalDict
{
normal (-1 0 0);
point (-0.042 0 0);
// point (-0.0425 0 0); // between faces
}
normal (-1 0 0);
point (-0.042 0 0);
///point (-0.0425 0 0); // between faces
}
_disk1

View File

@ -16,14 +16,10 @@ cuttingPlane
{
zNormal
{
type cuttingPlane;
planeType pointAndNormal;
pointAndNormalDict
{
point (0 0 0);
normal (0 0 1);
}
interpolate true;
type cuttingPlane;
point (0 0 0);
normal (0 0 1);
interpolate true;
}
}
}

View File

@ -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 | |
\*---------------------------------------------------------------------------*/
@ -31,14 +31,10 @@ functions
{
yNormal
{
type cuttingPlane;
planeType pointAndNormal;
pointAndNormalDict
{
point (0 0 0.063);
normal (0 0 1);
}
interpolate true;
type cuttingPlane;
point (0 0 0.063);
normal (0 0 1);
interpolate true;
}
}
}

View File

@ -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 | |
\*---------------------------------------------------------------------------*/
@ -136,14 +136,9 @@ functions
{
zNormal
{
type cuttingPlane;
planeType pointAndNormal;
pointAndNormalDict
{
point (0 0 -0.01);
normal (0 0 1);
}
interpolate false;
type cuttingPlane;
point (0 0 -0.01);
normal (0 0 1);
}
}
}

View File

@ -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 | |
\*---------------------------------------------------------------------------*/
@ -132,16 +132,10 @@ postPro1
// Same colours and scaling as surface
${_surface};
type plane;
planeType pointAndNormal;
pointAndNormalDict
{
point (0 0 0);
normal (1 0 0);
}
offsets (0.1 0.2 0.3 0.4 0.5);
type plane;
point (0 0 0);
normal (1 0 0);
offsets (0.1 0.2 0.3 0.4 0.5);
colourMap coolToWarm;
}

View File

@ -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 | |
\*---------------------------------------------------------------------------*/
@ -25,15 +25,9 @@ planes
_plane
{
type plane; //cuttingPlane;
planeType pointAndNormal;
interpolate false;
pointAndNormalDict
{
point (0 0 0);
normal (1 0 0);
}
type plane; //cuttingPlane;
point (0 0 0);
normal (1 0 0);
}
surfaces
@ -41,19 +35,13 @@ planes
plane0
{
${_plane}
pointAndNormalDict
{
point (0 0 0);
}
point (0 0 0);
}
plane1
{
${_plane}
pointAndNormalDict
{
point (-0.1 0 0);
}
point (-0.1 0 0);
}
}

View File

@ -21,14 +21,10 @@ surfaces
{
zNormal
{
type cuttingPlane;
planeType pointAndNormal;
pointAndNormalDict
{
point (0 0 0);
normal (0 0 1);
}
interpolate true;
type cuttingPlane;
point (0 0 0);
normal (0 0 1);
interpolate true;
}
isoQ

View File

@ -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 | |
\*---------------------------------------------------------------------------*/
@ -22,14 +22,10 @@ cuttingPlane
{
zNormal
{
type cuttingPlane;
planeType pointAndNormal;
pointAndNormalDict
{
point (0 0 0);
normal (0 0 1);
}
interpolate true;
type cuttingPlane;
point (0 0 0);
normal (0 0 1);
interpolate true;
}
}
}

View File

@ -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 | |
\*---------------------------------------------------------------------------*/
@ -27,15 +27,11 @@ samples
{
yNormal
{
type cuttingPlane;
planeType pointAndNormal;
interpolate true;
store true;
pointAndNormalDict
{
point (0 0 0);
normal (0 1 0);
}
type cuttingPlane;
point (0 0 0);
normal (0 1 0);
interpolate true;
store true;
}
}
}

View File

@ -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 | |
\*---------------------------------------------------------------------------*/
@ -21,14 +21,10 @@ cuttingPlane
{
yNormal
{
type cuttingPlane;
planeType pointAndNormal;
pointAndNormalDict
{
point (0 0 0);
normal (0 1 0);
}
interpolate true;
type cuttingPlane;
point (0 0 0);
normal (0 1 0);
interpolate true;
}
}
}

View File

@ -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 | |
\*---------------------------------------------------------------------------*/
@ -80,13 +80,8 @@ sampled
source cells;
store true;
planeType pointAndNormal;
pointAndNormalDict
{
normal (-1 0 0);
point (-0.04 0 0);
}
point (-0.04 0 0);
normal (-1 0 0);
}
surfaces

View File

@ -202,14 +202,9 @@ postPro1
cutting
{
type plane;
planeType pointAndNormal;
pointAndNormalDict
{
point (100 100 50);
normal (1 0 0);
}
point (100 100 50);
normal (1 0 0);
offsets (0 200);
smooth true;

View File

@ -20,7 +20,6 @@ planes
_plane
{
type cuttingPlane;
planeType pointAndNormal;
interpolate false;
}
@ -29,32 +28,23 @@ planes
plane0
{
${_plane}
pointAndNormalDict
{
point (100 100 50);
normal (1 -1 0);
}
point (100 100 50);
normal (1 -1 0);
enabled false;
}
plane1
{
${_plane}
pointAndNormalDict
{
point (100 100 50);
normal (1 1 0);
}
point (100 100 50);
normal (1 1 0);
}
plane2
{
${_plane}
pointAndNormalDict
{
point (200 100 50);
normal (1 0 0);
}
point (200 100 50);
normal (1 0 0);
}
};

View File

@ -12,14 +12,10 @@ samplePlanes
{
planes
{
type cuttingPlane;
planeType pointAndNormal;
pointAndNormalDict
{
point (1e-8 0 0); // slightly inside the domain
normal (1 0 0);
}
type cuttingPlane;
point (1e-8 0 0); // slightly inside the domain
normal (1 0 0);
offsets ( 500 1000 1500 2000 2500 3000 3500 4000 4500 );
}
}

View File

@ -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 | |
\*---------------------------------------------------------------------------*/
@ -61,12 +61,14 @@ functions
writeControl writeTime;
writeInterval 1;
surfaceFormat raw;
fields
(
alpha.water
);
surfaces
(
{
freeSurface
{
type isoSurfaceCell;
@ -93,7 +95,7 @@ functions
interpolate false;
regularise false;
}
);
}
}
}

View File

@ -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 | |
\*---------------------------------------------------------------------------*/
@ -15,19 +15,14 @@ cuttingPlaneError
interpolationScheme cell;
surfaces
(
{
zNormal
{
type cuttingPlane;
planeType pointAndNormal;
pointAndNormalDict
{
point (0 0.05 -0.05);
normal (0 0 1);
}
interpolate no;
type cuttingPlane;
point (0 0.05 -0.05);
normal (0 0 1);
}
);
}
}
@ -40,19 +35,14 @@ cuttingPlaneMagError
interpolationScheme cell;
surfaces
(
{
zNormal
{
type cuttingPlane;
planeType pointAndNormal;
pointAndNormalDict
{
point (0 0.05 -0.05);
normal (0 0 1);
}
interpolate no;
type cuttingPlane;
point (0 0.05 -0.05);
normal (0 0 1);
}
);
}
}