cellSizeFunction.C
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2012-2019 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "cellSizeFunction.H"
28 
29 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33  defineTypeNameAndDebug(cellSizeFunction, 0);
34  defineRunTimeSelectionTable(cellSizeFunction, dictionary);
35 
37 }
38 
39 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
40 
42 (
43  const word& type,
44  const dictionary& cellSizeFunctionDict,
45  const searchableSurface& surface,
46  const scalar& defaultCellSize,
47  const labelList regionIndices
48 )
49 :
50  dictionary(cellSizeFunctionDict),
51  surface_(surface),
52  surfaceCellSizeFunction_
53  (
54  surfaceCellSizeFunction::New
55  (
56  cellSizeFunctionDict,
57  surface,
58  defaultCellSize
59  )
60  ),
61  coeffsDict_(optionalSubDict(type + "Coeffs")),
62  defaultCellSize_(defaultCellSize),
63  regionIndices_(regionIndices),
64  sideMode_(),
65  priority_(cellSizeFunctionDict.lookup<label>("priority", true))
66 {
67  word mode = cellSizeFunctionDict.lookup("mode", true);
68 
69  if (surface_.hasVolumeType())
70  {
71  if (mode == "inside")
72  {
73  sideMode_ = smInside;
74  }
75  else if (mode == "outside")
76  {
77  sideMode_ = smOutside;
78  }
79  else if (mode == "bothSides")
80  {
81  sideMode_ = rmBothsides;
82  }
83  else
84  {
86  << "Unknown mode, expected: inside, outside or bothSides" << nl
87  << exit(FatalError);
88  }
89  }
90  else
91  {
92  if (mode != "bothSides")
93  {
95  << "surface does not support volumeType, defaulting mode to "
96  << "bothSides."
97  << endl;
98  }
99 
100  sideMode_ = rmBothsides;
101  }
102 
103  if (debug)
104  {
105  Info<< nl
106  << "Cell size function for surface " << surface.name()
107  << ", " << mode
108  << ", priority = " << priority_
109  << ", regions = " << regionIndices_
110  << endl;
111  }
112 }
113 
114 
115 // * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
116 
118 (
119  const dictionary& cellSizeFunctionDict,
120  const searchableSurface& surface,
121  const scalar& defaultCellSize,
122  const labelList regionIndices
123 )
124 {
125  word cellSizeFunctionTypeName
126  (
127  cellSizeFunctionDict.lookup("cellSizeFunction")
128  );
129 
130  Info<< indent << "Selecting cellSizeFunction " << cellSizeFunctionTypeName
131  << endl;
132 
133  dictionaryConstructorTable::iterator cstrIter =
134  dictionaryConstructorTablePtr_->find(cellSizeFunctionTypeName);
135 
136  if (cstrIter == dictionaryConstructorTablePtr_->end())
137  {
139  << "Unknown cellSizeFunction type "
140  << cellSizeFunctionTypeName
141  << endl << endl
142  << "Valid cellSizeFunction types are :" << endl
143  << dictionaryConstructorTablePtr_->toc()
144  << exit(FatalError);
145  }
146 
147  return autoPtr<cellSizeFunction>
148  (
149  cstrIter()
150  (
151  cellSizeFunctionDict,
152  surface,
153  defaultCellSize,
154  regionIndices
155  )
156  );
157 }
158 
159 
160 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
161 
163 {}
164 
165 
166 // ************************************************************************* //
FvWallInfoData< WallInfo, label > label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:221
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
error FatalError
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:306
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Macros for easy insertion into run-time selection tables.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
stressControl lookup("compactNormalStress") >> compactNormalStress
cellSizeFunction(const word &type, const dictionary &cellSizeFunctionDict, const searchableSurface &surface, const scalar &defaultCellSize, const labelList regionIndices)
Construct from components.
List< label > labelList
A List of labels.
Definition: labelList.H:56
static const char nl
Definition: Ostream.H:260
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
defineTypeNameAndDebug(combustionModel, 0)
virtual ~cellSizeFunction()
Destructor.
#define WarningInFunction
Report a warning using Foam::Warning.
messageStream Info
static scalar snapToSurfaceTol_
Point closeness tolerance to a surface where the function "snaps" to.
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:52
const doubleScalar e
Elementary charge.
Definition: doubleScalar.H:105
static autoPtr< cellSizeFunction > New(const dictionary &cellSizeFunctionDict, const searchableSurface &surface, const scalar &defaultCellSize, const labelList regionIndices)
Return a reference to the selected cellSizeFunction.
Namespace for OpenFOAM.