linearNormal.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) 2011-2015 OpenFOAM Foundation
9 Copyright (C) 2019-2020 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 "linearNormal.H"
31
32// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33
34namespace Foam
35{
36namespace extrudeModels
37{
38
39// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
40
42
44
45
46// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
47
49:
50 extrudeModel(typeName, dict),
51 thickness_(coeffDict_.get<scalar>("thickness")),
52 firstCellThickness_
53 (
54 coeffDict_.getOrDefault<scalar>("firstCellThickness", 0)
55 ),
56 layerPoints_(nLayers_)
57{
58 if (thickness_ <= 0)
59 {
61 << "thickness should be positive : " << thickness_
62 << exit(FatalError);
63 }
64
65 if (nLayers_ > 1 && firstCellThickness_ > 0)
66 {
67 if (thickness_ <= firstCellThickness_)
68 {
70 << "firstCellThickness leave no room for further layers"
71 << exit(FatalError);
72 }
73
74 layerPoints_[0] = firstCellThickness_;
75
76 for (label layer = 1; layer < nLayers_; ++layer)
77 {
78 layerPoints_[layer] =
79 (thickness_ - layerPoints_[0])
80 *sumThickness(layer) + layerPoints_[0];
81 }
82 }
83 else
84 {
85 for (label layer = 0; layer < nLayers_; ++layer)
86 {
87 layerPoints_[layer] = thickness_*sumThickness(layer + 1);
88 }
89 }
90}
91
92
93// * * * * * * * * * * * * * * * * Operators * * * * * * * * * * * * * * * * //
94
96(
97 const point& surfacePoint,
98 const vector& surfaceNormal,
99 const label layer
100) const
101{
102 if (layer <= 0)
103 {
104 return surfacePoint;
105 }
106
107 return surfacePoint + layerPoints_[layer - 1]*surfaceNormal;
108}
109
110
111// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
112
113} // End namespace extrudeModels
114} // End namespace Foam
115
116// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:126
Top level extrusion model class.
Definition: extrudeModel.H:77
scalar sumThickness(const label layer) const
Helper: calculate cumulative relative thickness for layer.
Definition: extrudeModel.C:71
Extrudes by transforming points normal to the surface by a given distance.
Definition: linearNormal.H:77
friend Ostream & operator(Ostream &, const faMatrix< Type > &)
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Namespace for OpenFOAM.
error FatalError
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
dictionary dict