isoSurfaceBase.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2019 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "isoSurfaceBase.H"
29 
30 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
31 
32 const Foam::Enum
33 <
35 >
37 ({
38  { algorithmType::ALGO_CELL, "cell" },
39  { algorithmType::ALGO_TOPO, "topo" },
40  { algorithmType::ALGO_POINT, "point" },
41 });
42 
43 
44 const Foam::Enum
45 <
47 >
49 ({
50  { filterType::NONE, "none" },
51  { filterType::CELL, "cell" },
52  { filterType::DIAGCELL, "diagcell" },
53  { filterType::PARTIAL, "partial" },
54  { filterType::FULL, "full" },
55 });
56 
57 
58 // * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
59 
62 (
63  const dictionary& dict,
64  const isoSurfaceBase::filterType deflt
65 )
66 {
67  word filterName;
68 
69  if (!dict.readIfPresent("regularise", filterName, keyType::LITERAL))
70  {
71  return deflt;
72  }
73 
74  // Try as bool
75  Switch sw(filterName, true);
76 
77  if (sw.valid())
78  {
79  return
80  (
81  sw
82  ? deflt
83  : isoSurfaceBase::filterType::NONE
84  );
85  }
86 
87  // As enum
88  if (!isoSurfaceBase::filterNames.found(filterName))
89  {
91  << filterName << " is not in enumeration: "
92  << isoSurfaceBase::filterNames << nl
93  << exit(FatalIOError);
94  }
95 
96  return isoSurfaceBase::filterNames[filterName];
97 }
98 
99 
100 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
101 
103 (
104  const scalar iso,
105  const boundBox& bounds
106 )
107 :
108  meshedSurface(),
109  iso_(iso),
110  bounds_(bounds)
111 {}
112 
113 
114 // ************************************************************************* //
Foam::Switch
A simple wrapper around bool so that it can be read as a word: true/false, on/off,...
Definition: Switch.H:70
Foam::Enum
Enum is a wrapper around a list of names/values that represent particular enumeration (or int) values...
Definition: IOstreamOption.H:51
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:62
Foam::Switch::valid
bool valid() const noexcept
True if the Switch represents a valid enumeration.
Definition: Switch.C:203
Foam::isoSurfaceBase::algorithmNames
static const Enum< algorithmType > algorithmNames
Names for the iso-surface algorithms.
Definition: isoSurfaceBase.H:100
Foam::FatalIOError
IOerror FatalIOError
Foam::isoSurfaceBase::filterNames
static const Enum< filterType > filterNames
Names for the filtering types.
Definition: isoSurfaceBase.H:103
isoSurfaceBase.H
Foam::isoSurfaceBase::algorithmType
algorithmType
The algorithm types.
Definition: isoSurfaceBase.H:78
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::isoSurfaceBase::isoSurfaceBase
isoSurfaceBase(const scalar iso, const boundBox &bounds=boundBox::invertedBox)
Construct with iso value.
Definition: isoSurfaceBase.C:103
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:121
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
found
bool found
Definition: TABSMDCalcMethod2.H:32
Foam::nl
constexpr char nl
Definition: Ostream.H:372
Foam::meshedSurface
MeshedSurface< face > meshedSurface
Definition: MeshedSurfacesFwd.H:41
Foam::isoSurfaceBase::getFilterType
static filterType getFilterType(const dictionary &dict, const isoSurfaceBase::filterType deflt)
Get 'regularise' as bool or enumeration.
Definition: isoSurfaceBase.C:62
Foam::boundBox
A bounding box defined in terms of min/max extrema points.
Definition: boundBox.H:63
FatalIOErrorInFunction
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:375
Foam::isoSurfaceBase::filterType
filterType
The filtering (regularization) to apply.
Definition: isoSurfaceBase.H:87