mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
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:
@ -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());
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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_;
|
||||
}
|
||||
|
||||
@ -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 |
|
||||
|
||||
@ -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 |
|
||||
|
||||
Reference in New Issue
Block a user