ENH: general boundBox/treeBoundBox improvements

- null() static method
  * as const reference to the invertedBox with the appropriate casting.

- boundBox inflate(random)
  * refactored from treeBoundBox::extend, but allows in-place modification

- boundBox::hexFaces() instead of boundBox::faces
  * rarely used, but avoids confusion with treeBoundBox::faces
    and reuses hexCell face definitions without code duplication

- boundBox::hexCorners() for corner points corresponding to a hexCell.
  Can also be accessed from a treeBoundBox without ambiguity with
  points(), which could be hex corners (boundBox) or octant corners
  (treeBoundBox)

- boundBox::add with pairs of points
  * convenient (for example) when adding edges or a 'box' that has
    been extracted from a primitive mesh shape.

- declare boundBox nPoints(), nFaces(), nEdges() as per hexCell

ENH: return invertedBox instead of FatalError for empty trees

- similar to #2612

ENH: cellShape(HEX, ...) + boundBox hexCorners for block meshes

STYLE: cellModel::ref(...) instead of de-reference cellModel::ptr(...)
This commit is contained in:
Mark Olesen
2022-11-01 12:15:08 +01:00
committed by Andrew Heather
parent 0ba458fdbc
commit 1339c3357b
26 changed files with 373 additions and 219 deletions

View File

@ -452,8 +452,7 @@ public:
{
if (nodes_.empty())
{
FatalErrorInFunction
<< "Tree is empty" << abort(FatalError);
return treeBoundBox::null();
}
return nodes_[0].bb_;
}

View File

@ -465,8 +465,7 @@ public:
{
if (nodes_.empty())
{
FatalErrorInFunction
<< "Tree is empty" << abort(FatalError);
return treeBoundBox::null();
}
return nodes_[0].bb_;
}

View File

@ -1,89 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2013 OpenFOAM Foundation
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
\*---------------------------------------------------------------------------*/
#include "volumeType.H"
#include "dictionary.H"
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
const Foam::Enum
<
Foam::volumeType::type
>
Foam::volumeType::names
({
{ volumeType::type::UNKNOWN, "unknown" },
{ volumeType::type::INSIDE, "inside" },
{ volumeType::type::OUTSIDE, "outside" },
{ volumeType::type::MIXED, "mixed" },
});
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::volumeType::volumeType
(
const word& key,
const dictionary& dict,
const type deflt
)
:
t_(names.getOrDefault(key, dict, deflt))
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * //
const Foam::word& Foam::volumeType::str() const
{
return names[t_];
}
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
Foam::Istream& Foam::operator>>(Istream& is, volumeType& vt)
{
int val;
is >> val;
vt.t_ = static_cast<volumeType::type>(val);
return is;
}
Foam::Ostream& Foam::operator<<(Ostream& os, const volumeType& vt)
{
os << static_cast<int>(vt.t_);
return os;
}
// ************************************************************************* //

View File

@ -1,147 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2014 OpenFOAM Foundation
Copyright (C) 2015-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
OpenFOAM is free software: you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
for more details.
You should have received a copy of the GNU General Public License
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
Class
Foam::volumeType
Description
An enumeration wrapper for classification of a location as being
inside/outside of a volume.
SourceFiles
volumeType.C
\*---------------------------------------------------------------------------*/
#ifndef Foam_volumeType_H
#define Foam_volumeType_H
#include "contiguous.H"
#include "Enum.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// Forward Declarations
class dictionary;
class volumeType;
Istream& operator>>(Istream& is, volumeType& vt);
Ostream& operator<<(Ostream& os, const volumeType& vt);
/*---------------------------------------------------------------------------*\
Class volumeType Declaration
\*---------------------------------------------------------------------------*/
class volumeType
{
public:
//- Volume classification types
enum type : char
{
UNKNOWN = 0, //!< Unknown state
INSIDE = 0x1, //!< A location inside the volume
OUTSIDE = 0x2, //!< A location outside the volume
MIXED = 0x3 //!< A location that is partly inside and outside
};
// Static data
//- Names for the classification enumeration
static const Enum<volumeType::type> names;
private:
// Private data
//- Volume type
type t_;
public:
// Constructors
//- Default construct as \c UNKNOWN state
constexpr volumeType() noexcept
:
t_(UNKNOWN)
{}
//- Implicit construct from enumeration
volumeType(type t) noexcept
:
t_(t)
{}
//- Construct as getOrDefault by name from dictionary
volumeType(const word& key, const dictionary& dict, const type deflt);
//- Construct from integer
explicit volumeType(const int t)
:
t_(static_cast<volumeType::type>(t & 0x3))
{}
// Member Functions
//- Return the enumeration
operator type() const
{
return t_;
}
//- The string representation of the volume type enumeration
const word& str() const;
// IOstream Operators
friend Istream& operator>>(Istream& is, volumeType& vt);
friend Ostream& operator<<(Ostream& os, const volumeType& vt);
};
// * * * * * * * * * * * * * * * * * Traits * * * * * * * * * * * * * * * * //
//- Contiguous data for volumeType
template<> struct is_contiguous<volumeType> : std::true_type {};
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //