Loading...
Searching...
No Matches
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-------------------------------------------------------------------------------
11License
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
34namespace Foam
35{
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// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
if(patchID !=-1)
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition autoPtr.H:65
Abstract base class for specifying target cell sizes.
static scalar snapToSurfaceTol_
Point closeness tolerance to a surface where the function "snaps" to.
static autoPtr< cellSizeFunction > New(const dictionary &cellSizeFunctionDict, const searchableSurface &surface, const scalar &defaultCellSize, const labelList regionIndices)
Return a reference to the selected cellSizeFunction.
virtual ~cellSizeFunction()
Destructor.
cellSizeFunction(const cellSizeFunction &)=delete
No copy construct.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition error.H:637
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition error.H:600
#define WarningInFunction
Report a warning using Foam::Warning.
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
const wordList surface
Standard surface field types (scalar, vector, tensor, etc).
type
Types of root.
Definition Roots.H:53
Namespace for OpenFOAM.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
messageStream Info
Information stream (stdout output on master, null elsewhere).
mode_t mode(const fileName &name, const bool followLink=true)
Return the file mode, normally following symbolic links.
Definition POSIX.C:775
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
Ostream & indent(Ostream &os)
Indent stream.
Definition Ostream.H:481
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
#define defineRunTimeSelectionTable(baseType, argNames)
Define run-time selection table.
dictionary dict
volScalarField & e