linearSpatial.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-2015 OpenFOAM Foundation
9  Copyright (C) 2018 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 "linearSpatial.H"
31 #include "volumeType.H"
32 
33 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
34 
35 namespace Foam
36 {
37  defineTypeNameAndDebug(linearSpatial, 0);
38  addToRunTimeSelectionTable(cellSizeFunction, linearSpatial, dictionary);
39 }
40 
41 
42 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
43 
45 (
46  const dictionary& initialPointsDict,
47  const searchableSurface& surface,
48  const scalar& defaultCellSize,
49  const labelList regionIndices
50 )
51 :
52  cellSizeFunction
53  (
54  typeName,
55  initialPointsDict,
56  surface,
57  defaultCellSize,
58  regionIndices
59  ),
60  referencePoint_
61  (
62  coeffsDict().get<point>("referencePoint")
63  ),
64  referenceCellSize_
65  (
66  coeffsDict().get<scalar>("referenceCellSizeCoeff") * defaultCellSize
67  ),
68  direction_
69  (
70  coeffsDict().get<vector>("direction").normalise()
71  ),
72  cellSizeGradient_
73  (
74  coeffsDict().get<scalar>("cellSizeGradient")
75  )
76 {}
77 
78 
79 // * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * * //
80 
81 Foam::scalar Foam::linearSpatial::sizeFunction(const point& pt) const
82 {
83  return
84  referenceCellSize_
85  + ((pt - referencePoint_) & direction_)*cellSizeGradient_;
86 }
87 
88 
89 
90 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
91 
93 (
94  const pointIndexHit& hitPt,
95  const vector& n,
96  pointField& shapePts,
97  scalarField& shapeSizes
98 ) const
99 {
100  if (sideMode_ == rmBothsides)
101  {
102  }
103  else if (sideMode_ == smInside)
104  {
105  }
106  else if (sideMode_ == smOutside)
107  {
108  }
109 
110  return false;
111 }
112 
113 
115 (
116  const point& pt,
117  scalar& size
118 ) const
119 {
120  if (sideMode_ == rmBothsides)
121  {
122  size = sizeFunction(pt);
123 
124  return true;
125  }
126 
127  size = 0;
128 
129  List<pointIndexHit> hits;
130 
131  surface_.findNearest
132  (
133  pointField(1, pt),
134  scalarField(1, sqr(snapToSurfaceTol_)),
135  regionIndices_,
136  hits
137  );
138 
139  const pointIndexHit& hitInfo = hits[0];
140 
141  // If the nearest point is essentially on the surface, do not do a
142  // getVolumeType calculation, as it will be prone to error.
143  if (hitInfo.hit())
144  {
145  size = sizeFunction(pt);
146 
147  return true;
148  }
149 
150  pointField ptF(1, pt);
151  List<volumeType> vTL;
152 
153  surface_.getVolumeType(ptF, vTL);
154 
155  bool functionApplied = false;
156 
157  if
158  (
159  sideMode_ == smInside
160  && vTL[0] == volumeType::INSIDE
161  )
162  {
163  size = sizeFunction(pt);
164 
165  functionApplied = true;
166  }
167  else if
168  (
169  sideMode_ == smOutside
170  && vTL[0] == volumeType::OUTSIDE
171  )
172  {
173  size = sizeFunction(pt);
174 
175  functionApplied = true;
176  }
177 
178  return functionApplied;
179 }
180 
181 
182 // ************************************************************************* //
List< ReturnType > get(const UPtrList< T > &list, const AccessOp &aop)
List of values generated by applying the access operation to each list item.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
linearSpatial(const dictionary &initialPointsDict, const searchableSurface &surface, const scalar &defaultCellSize, const labelList regionIndices)
Construct from components.
PointIndexHit< point > pointIndexHit
A PointIndexHit with a 3D point.
Definition: pointIndexHit.H:58
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.
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:38
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
virtual bool sizeLocations(const pointIndexHit &hitPt, const vector &n, pointField &shapePts, scalarField &shapeSizes) const
Vector< scalar > vector
Definition: vector.H:57
A location inside the volume.
Definition: volumeType.H:65
A location outside the volume.
Definition: volumeType.H:66
const wordList surface
Standard surface field types (scalar, vector, tensor, etc)
defineTypeNameAndDebug(combustionModel, 0)
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
vector point
Point is a vector.
Definition: point.H:37
label n
List< label > labelList
A List of labels.
Definition: List.H:62
Namespace for OpenFOAM.