nonUniformField.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-2017 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 #include "nonUniformField.H"
29 #include "triSurfaceMesh.H"
30 #include "searchableSurface.H"
32 #include "Time.H"
33 
34 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
35 
36 namespace Foam
37 {
38  defineTypeNameAndDebug(nonUniformField, 0);
40  (
41  surfaceCellSizeFunction,
42  nonUniformField,
43  dictionary
44  );
45 }
46 
47 
48 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
49 
51 (
52  const dictionary& cellSizeFunctionDict,
53  const searchableSurface& surface,
54  const scalar& defaultCellSize
55 )
56 :
57  surfaceCellSizeFunction
58  (
59  typeName,
60  cellSizeFunctionDict,
61  surface,
62  defaultCellSize
63  ),
64  surfaceTriMesh_(refCast<const triSurfaceMesh>(surface)),
65  cellSizeCalculationType_
66  (
67  cellSizeCalculationType::New
68  (
69  coeffsDict(),
70  surfaceTriMesh_,
71  defaultCellSize
72  )
73  ),
74  pointCellSize_
75  (
76  IOobject
77  (
78  "pointCellSize.cellSize",
79  surfaceTriMesh_.searchableSurface::time().constant(),
80  "triSurface",
81  surfaceTriMesh_.searchableSurface::time(),
82  IOobject::NO_READ,
83  IOobject::NO_WRITE
84  ),
85  surfaceTriMesh_,
86  dimLength,
87  false
88  )
89 {
90  Info<< incrIndent;
91 
92  pointCellSize_ = cellSizeCalculationType_().load();
93 
94  Info<< indent << "Cell size field statistics:" << nl
95  << indent << " Minimum: " << min(pointCellSize_).value() << nl
96  << indent << " Average: " << average(pointCellSize_).value() << nl
97  << indent << " Maximum: " << max(pointCellSize_).value() << endl;
98 
99  Info<< decrIndent;
100 }
101 
102 
103 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
104 
106 (
107  const point& pt,
108  const label index
109 ) const
110 {
111  const face& faceHitByPt = surfaceTriMesh_.triSurface::operator[](index);
112 
113  const pointField& pts = surfaceTriMesh_.points();
114 // const Map<label>& pMap = surfaceTriMesh_.meshPointMap();
115 
116  triPointRef tri
117  (
118  pts[faceHitByPt[0]],
119  pts[faceHitByPt[1]],
120  pts[faceHitByPt[2]]
121  );
122 
123  const barycentric2D bary = tri.pointToBarycentric(pt);
124 
125 // return pointCellSize_[pMap[faceHitByPt[0]]]*bary[0]
126 // + pointCellSize_[pMap[faceHitByPt[1]]]*bary[1]
127 // + pointCellSize_[pMap[faceHitByPt[2]]]*bary[2];
128  return pointCellSize_[faceHitByPt[0]]*bary[0]
129  + pointCellSize_[faceHitByPt[1]]*bary[1]
130  + pointCellSize_[faceHitByPt[2]]*bary[2];
131 }
132 
133 
134 // ************************************************************************* //
Foam::addToRunTimeSelectionTable
addToRunTimeSelectionTable(decompositionMethod, kahipDecomp, dictionary)
Foam::pointField
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:44
searchableSurface.H
Foam::dimLength
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:52
Foam::barycentric2D
Barycentric2D< scalar > barycentric2D
A scalar version of the templated Barycentric2D.
Definition: barycentric2D.H:47
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:369
Foam::incrIndent
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:346
nonUniformField.H
Foam::min
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
Foam::nonUniformField::nonUniformField
nonUniformField(const dictionary &cellSizeFunctionDict, const searchableSurface &surface, const scalar &defaultCellSize)
Construct from components.
Foam::Info
messageStream Info
Information stream (stdout output on master, null elsewhere)
Foam::max
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
addToRunTimeSelectionTable.H
Macros for easy insertion into run-time selection tables.
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::decrIndent
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:353
Foam::indent
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:339
Foam::refCast
To & refCast(From &r)
Reference type cast template function.
Definition: typeInfo.H:131
Foam::New
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh >> &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Definition: DimensionedFieldReuseFunctions.H:105
Time.H
Foam::nl
constexpr char nl
Definition: Ostream.H:404
Foam::point
vector point
Point is a vector.
Definition: point.H:43
Foam::nonUniformField::interpolate
virtual scalar interpolate(const point &pt, const label index) const
Return the interpolated cell size for a point in the given.
constant
constant condensation/saturation model.
triSurfaceMesh.H
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)
Foam::average
dimensioned< Type > average(const DimensionedField< Type, GeoMesh > &df)
Definition: DimensionedFieldFunctions.C:328
Foam::triPointRef
triangle< point, const point & > triPointRef
A triangle using referred points.
Definition: triangle.H:71