cellSizeFunction.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) 2012-2017 OpenFOAM Foundation
9  Copyright (C) 2019-2021 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 \*---------------------------------------------------------------------------*/
28 
29 #include "cellSizeFunction.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36  defineTypeNameAndDebug(cellSizeFunction, 0);
37  defineRunTimeSelectionTable(cellSizeFunction, dictionary);
38 }
39 
41 
42 
43 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
44 
46 (
47  const word& type,
48  const dictionary& cellSizeFunctionDict,
49  const searchableSurface& surface,
50  const scalar& defaultCellSize,
51  const labelList regionIndices
52 )
53 :
54  dictionary(cellSizeFunctionDict),
55  surface_(surface),
56  surfaceCellSizeFunction_
57  (
58  surfaceCellSizeFunction::New
59  (
60  cellSizeFunctionDict,
61  surface,
62  defaultCellSize
63  )
64  ),
65  coeffsDict_(optionalSubDict(type + "Coeffs")),
66  defaultCellSize_(defaultCellSize),
67  regionIndices_(regionIndices),
68  sideMode_(),
69  priority_
70  (
71  cellSizeFunctionDict.get<label>("priority", keyType::REGEX_RECURSIVE)
72  )
73 {
74  const word mode =
75  cellSizeFunctionDict.get<word>("mode", keyType::REGEX_RECURSIVE);
76 
77  if (surface_.hasVolumeType())
78  {
79  if (mode == "inside")
80  {
81  sideMode_ = smInside;
82  }
83  else if (mode == "outside")
84  {
85  sideMode_ = smOutside;
86  }
87  else if (mode == "bothSides")
88  {
89  sideMode_ = rmBothsides;
90  }
91  else
92  {
94  << "Unknown mode, expected: inside, outside or bothSides" << nl
95  << exit(FatalError);
96  }
97  }
98  else
99  {
100  if (mode != "bothSides")
101  {
103  << "surface does not support volumeType, defaulting mode to "
104  << "bothSides."
105  << endl;
106  }
107 
108  sideMode_ = rmBothsides;
109  }
110 
111  if (debug)
112  {
113  Info<< nl
114  << "Cell size function for surface " << surface.name()
115  << ", " << mode
116  << ", priority = " << priority_
117  << ", regions = " << regionIndices_
118  << endl;
119  }
120 }
121 
122 
123 // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
124 
126 (
127  const dictionary& dict,
128  const searchableSurface& surface,
129  const scalar& defaultCellSize,
130  const labelList regionIndices
131 )
132 {
133  const word modelType(dict.get<word>("cellSizeFunction"));
134 
135  Info<< indent << "Selecting cellSizeFunction " << modelType << endl;
136 
137  auto* ctorPtr = dictionaryConstructorTable(modelType);
138 
139  if (!ctorPtr)
140  {
142  (
143  dict,
144  "cellSizeFunction",
145  modelType,
146  *dictionaryConstructorTablePtr_
147  ) << exit(FatalIOError);
148  }
149 
150  return autoPtr<cellSizeFunction>
151  (
152  ctorPtr
153  (
154  dict,
155  surface,
156  defaultCellSize,
157  regionIndices
158  )
159  );
160 }
161 
162 
163 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
164 
166 {}
167 
168 
169 // ************************************************************************* //
Foam::expressions::patchExpr::debug
int debug
Static debugging option.
Foam::labelList
List< label > labelList
A List of labels.
Definition: List.H:67
Foam::defineRunTimeSelectionTable
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
Foam::FatalIOError
IOerror FatalIOError
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::dictionary::get
T get(const word &keyword, enum keyType::option matchOpt=keyType::REGEX) const
Definition: dictionaryTemplates.C:107
Foam::mode
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
Definition: MSwindows.C:564
Foam::cellSizeFunction::cellSizeFunction
cellSizeFunction(const cellSizeFunction &)=delete
No copy construct.
cellSizeFunction.H
FatalIOErrorInLookup
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:478
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::cellSizeFunction::snapToSurfaceTol_
static scalar snapToSurfaceTol_
Point closeness tolerance to a surface where the function "snaps" to.
Definition: cellSizeFunction.H:81
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::FatalError
error FatalError
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam::cellSizeFunction::~cellSizeFunction
virtual ~cellSizeFunction()
Destructor.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::cellSizeFunction::New
static autoPtr< cellSizeFunction > New(const dictionary &cellSizeFunctionDict, const searchableSurface &surface, const scalar &defaultCellSize, const labelList regionIndices)
Return a reference to the selected cellSizeFunction.
Foam::indent
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:339
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::constant::electromagnetic::e
const dimensionedScalar e
Elementary charge.
Definition: createFields.H:11
Foam::roots::type
type
Types of root.
Definition: Roots.H:54
Foam::PtrListOps::get
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
WarningInFunction
#define WarningInFunction
Report a warning using Foam::Warning.
Definition: messageStream.H:328
Foam::keyType::REGEX_RECURSIVE
Definition: keyType.H:87