All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
linearSpatial.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 "linearSpatial.H"
28 #include "volumeType.H"
29 
30 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
31 
32 namespace Foam
33 {
34 
35 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
36 
37 defineTypeNameAndDebug(linearSpatial, 0);
38 addToRunTimeSelectionTable(cellSizeFunction, linearSpatial, dictionary);
39 
40 
41 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
42 
44 (
45  const dictionary& initialPointsDict,
46  const searchableSurface& surface,
47  const scalar& defaultCellSize,
48  const labelList regionIndices
49 )
50 :
51  cellSizeFunction
52  (
53  typeName,
54  initialPointsDict,
55  surface,
56  defaultCellSize,
57  regionIndices
58  ),
59  referencePoint_(coeffsDict().lookup("referencePoint")),
60  referenceCellSize_
61  (
62  coeffsDict().lookup<scalar>("referenceCellSizeCoeff")
63  *defaultCellSize
64  ),
65  direction_(coeffsDict().lookup("direction")),
66  cellSizeGradient_(coeffsDict().lookup<scalar>("cellSizeGradient"))
67 {
68  direction_ /= mag(direction_);
69 }
70 
71 
72 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
73 
74 scalar linearSpatial::sizeFunction(const point& pt) const
75 {
76  return
77  referenceCellSize_
78  + ((pt - referencePoint_) & direction_)*cellSizeGradient_;
79 }
80 
81 
82 
83 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
84 
86 (
87  const pointIndexHit& hitPt,
88  const vector& n,
89  pointField& shapePts,
90  scalarField& shapeSizes
91 ) const
92 {
93  if (sideMode_ == rmBothsides)
94  {
95  }
96  else if (sideMode_ == smInside)
97  {
98  }
99  else if (sideMode_ == smOutside)
100  {
101  }
102 
103  return false;
104 }
105 
106 
108 (
109  const point& pt,
110  scalar& size
111 ) const
112 {
113  if (sideMode_ == rmBothsides)
114  {
115  size = sizeFunction(pt);
116 
117  return true;
118  }
119 
120  size = 0;
121 
122  List<pointIndexHit> hits;
123 
125  (
126  pointField(1, pt),
129  hits
130  );
131 
132  const pointIndexHit& hitInfo = hits[0];
133 
134  // If the nearest point is essentially on the surface, do not do a
135  // getVolumeType calculation, as it will be prone to error.
136  if (hitInfo.hit())
137  {
138  size = sizeFunction(pt);
139 
140  return true;
141  }
142 
143  pointField ptF(1, pt);
144  List<volumeType> vTL;
145 
146  surface_.getVolumeType(ptF, vTL);
147 
148  bool functionApplied = false;
149 
150  if
151  (
153  && vTL[0] == volumeType::inside
154  )
155  {
156  size = sizeFunction(pt);
157 
158  functionApplied = true;
159  }
160  else if
161  (
163  && vTL[0] == volumeType::outside
164  )
165  {
166  size = sizeFunction(pt);
167 
168  functionApplied = true;
169  }
170 
171  return functionApplied;
172 
173 }
174 
175 
176 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
177 
178 } // End namespace Foam
179 
180 // ************************************************************************* //
dimensionedSymmTensor sqr(const dimensionedVector &dv)
linearSpatial(const dictionary &initialPointsDict, const searchableSurface &surface, const scalar &defaultCellSize, const labelList regionIndices)
Construct from components.
PointIndexHit< point > pointIndexHit
Definition: pointIndexHit.H:42
Vector< scalar > vector
A scalar version of the templated Vector.
Definition: vector.H:49
virtual bool cellSize(const point &pt, scalar &size) const
Modify scalar argument to the cell size specified by function.
Macros for easy insertion into run-time selection tables.
const labelList regionIndices_
Index of the region of the surface that this cell size function.
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:42
stressControl lookup("compactNormalStress") >> compactNormalStress
virtual void findNearest(const pointField &sample, const scalarField &nearestDistSqr, List< pointIndexHit > &) const =0
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
List< label > labelList
A List of labels.
Definition: labelList.H:56
virtual bool sizeLocations(const pointIndexHit &hitPt, const vector &n, pointField &shapePts, scalarField &shapeSizes) const
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
defineTypeNameAndDebug(combustionModel, 0)
vector point
Point is a vector.
Definition: point.H:41
virtual void getVolumeType(const pointField &, List< volumeType > &) const =0
Determine type (inside/outside) for point. unknown if.
static scalar snapToSurfaceTol_
Point closeness tolerance to a surface where the function "snaps" to.
dimensioned< scalar > mag(const dimensioned< Type > &)
const searchableSurface & surface_
Reference to the searchableSurface that cellSizeFunction.
sideMode sideMode_
Mode of size specification, i.e. inside, outside or bothSides.
Namespace for OpenFOAM.