All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
nonUniformField.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-2018 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 "nonUniformField.H"
27 #include "triSurfaceMesh.H"
28 #include "searchableSurface.H"
30 #include "Time.H"
31 
32 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33 
34 namespace Foam
35 {
36  defineTypeNameAndDebug(nonUniformField, 0);
38  (
39  surfaceCellSizeFunction,
40  nonUniformField,
41  dictionary
42  );
43 }
44 
45 
46 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
47 
49 (
50  const dictionary& cellSizeFunctionDict,
51  const searchableSurface& surface,
52  const scalar& defaultCellSize
53 )
54 :
55  surfaceCellSizeFunction
56  (
57  typeName,
58  cellSizeFunctionDict,
59  surface,
60  defaultCellSize
61  ),
62  surfaceTriMesh_(refCast<const triSurfaceMesh>(surface)),
63  cellSizeCalculationType_
64  (
65  cellSizeCalculationType::New
66  (
67  coeffsDict(),
68  surfaceTriMesh_,
69  defaultCellSize
70  )
71  ),
72  pointCellSize_
73  (
74  IOobject
75  (
76  "pointCellSize.cellSize",
77  surfaceTriMesh_.searchableSurface::time().constant(),
78  "triSurface",
79  surfaceTriMesh_.searchableSurface::time(),
80  IOobject::NO_READ,
81  IOobject::NO_WRITE
82  ),
83  surfaceTriMesh_,
84  dimLength,
85  false
86  )
87 {
88  Info<< incrIndent;
89 
90  pointCellSize_ = cellSizeCalculationType_().load();
91 
92  Info<< indent << "Cell size field statistics:" << nl
93  << indent << " Minimum: " << min(pointCellSize_).value() << nl
94  << indent << " Average: " << average(pointCellSize_).value() << nl
95  << indent << " Maximum: " << max(pointCellSize_).value() << endl;
96 
97  Info<< decrIndent;
98 }
99 
100 
101 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
102 
104 (
105  const point& pt,
106  const label index
107 ) const
108 {
109  const face& faceHitByPt = surfaceTriMesh_.triSurface::operator[](index);
110 
111  const pointField& pts = surfaceTriMesh_.points();
112 // const Map<label>& pMap = surfaceTriMesh_.meshPointMap();
113 
114  triPointRef tri
115  (
116  pts[faceHitByPt[0]],
117  pts[faceHitByPt[1]],
118  pts[faceHitByPt[2]]
119  );
120 
121  const barycentric2D bary = tri.pointToBarycentric(pt);
122 
123 // return pointCellSize_[pMap[faceHitByPt[0]]]*bary[0]
124 // + pointCellSize_[pMap[faceHitByPt[1]]]*bary[1]
125 // + pointCellSize_[pMap[faceHitByPt[2]]]*bary[2];
126  return pointCellSize_[faceHitByPt[0]]*bary[0]
127  + pointCellSize_[faceHitByPt[1]]*bary[1]
128  + pointCellSize_[faceHitByPt[2]]*bary[2];
129 }
130 
131 
132 // ************************************************************************* //
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:221
Barycentric2D< scalar > barycentric2D
A scalar version of the templated Barycentric2D.
Definition: barycentric2D.H:45
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
To & refCast(From &r)
Reference type cast template function.
Definition: typeInfo.H:106
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Macros for easy insertion into run-time selection tables.
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:42
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &df)
addToRunTimeSelectionTable(ensightPart, ensightPartCells, istream)
static const char nl
Definition: Ostream.H:260
defineTypeNameAndDebug(combustionModel, 0)
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:235
dimensioned< Type > min(const dimensioned< Type > &, const dimensioned< Type > &)
vector point
Point is a vector.
Definition: point.H:41
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:50
triangle< point, const point & > triPointRef
Definition: triPointRef.H:44
messageStream Info
virtual scalar interpolate(const point &pt, const label index) const
Return the interpolated cell size for a point in the given.
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:228
Namespace for OpenFOAM.
nonUniformField(const dictionary &cellSizeFunctionDict, const searchableSurface &surface, const scalar &defaultCellSize)
Construct from components.