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 -------------------------------------------------------------------------------
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 "linearNormal.H"
31 
32 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36 namespace extrudeModels
37 {
38 
39 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
40 
41 defineTypeNameAndDebug(linearNormal, 0);
42 
43 addToRunTimeSelectionTable(extrudeModel, linearNormal, dictionary);
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 
95 point linearNormal::operator()
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 // ************************************************************************* //
Foam::extrudeModel::sumThickness
scalar sumThickness(const label layer) const
Helper: calculate cumulative relative thickness for layer.
Definition: extrudeModel.C:71
Foam::extrudeModels::defineTypeNameAndDebug
defineTypeNameAndDebug(cyclicSector, 0)
Foam::extrudeModel
Top level extrusion model class.
Definition: extrudeModel.H:76
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::extrudeModel::nLayers_
label nLayers_
Definition: extrudeModel.H:82
Foam::FatalError
error FatalError
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam::extrudeModels::addToRunTimeSelectionTable
addToRunTimeSelectionTable(extrudeModel, cyclicSector, dictionary)
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
linearNormal.H
Foam::exit
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:453
Foam::Vector< scalar >
Foam::PtrListOps::get
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
Foam::extrudeModels::linearNormal::linearNormal
linearNormal(const dictionary &dict)
Construct from dictionary.
Definition: linearNormal.C:48