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 | Copyright (C) 2012-2015 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 
41 Foam::cellSizeFunction::cellSizeFunction
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_(subDict(type + "Coeffs")),
62  defaultCellSize_(defaultCellSize),
63  regionIndices_(regionIndices),
64  sideMode_(),
65  priority_(readLabel(cellSizeFunctionDict.lookup("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  {
85  FatalErrorIn("searchableSurfaceControl::searchableSurfaceControl")
86  << "Unknown mode, expected: inside, outside or bothSides" << nl
87  << exit(FatalError);
88  }
89  }
90  else
91  {
92  if (mode != "bothSides")
93  {
94  WarningIn("searchableSurfaceControl::searchableSurfaceControl")
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  (
140  "cellSizeFunction::New(dictionary&, "
141  "const conformalVoronoiMesh&, const searchableSurface&)"
142  ) << "Unknown cellSizeFunction type "
143  << cellSizeFunctionTypeName
144  << endl << endl
145  << "Valid cellSizeFunction types are :" << endl
146  << dictionaryConstructorTablePtr_->toc()
147  << exit(FatalError);
148  }
149 
150  return autoPtr<cellSizeFunction>
151  (
152  cstrIter()
153  (
154  cellSizeFunctionDict,
155  surface,
156  defaultCellSize,
157  regionIndices
158  )
159  );
160 }
161 
162 
163 // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
164 
166 {}
167 
168 
169 // ************************************************************************* //
virtual ~cellSizeFunction()
Destructor.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
label readLabel(Istream &is)
Definition: label.H:64
static const char nl
Definition: Ostream.H:260
#define FatalErrorIn(fn)
Definition: error.H:317
An auto-pointer similar to the STL auto_ptr but with automatic casting to a reference to the type and...
Definition: PtrList.H:117
#define WarningIn(fn)
messageStream Info
static scalar snapToSurfaceTol_
Point closeness tolerance to a surface where the function "snaps" to.
List< label > labelList
A List of labels.
Definition: labelList.H:56
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:221
error FatalError
defineRunTimeSelectionTable(reactionRateFlameArea, dictionary)
const double e
Elementary charge.
Definition: doubleFloat.H:78
Macros for easy insertion into run-time selection tables.
defineTypeNameAndDebug(combustionModel, 0)
static autoPtr< cellSizeFunction > New(const dictionary &cellSizeFunctionDict, const searchableSurface &surface, const scalar &defaultCellSize, const labelList regionIndices)
Return a reference to the selected cellSizeFunction.
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:124
stressControl lookup("compactNormalStress") >> compactNormalStress