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-------------------------------------------------------------------------------
10License
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
36namespace 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_,
87 false
88 )
89{
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
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// ************************************************************************* //
Y[inertIndex] max(0.0)
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
const triSurfaceMesh & surfaceTriMesh_
triSurfacePointScalarField pointCellSize_
constant condensation/saturation model.
bool interpolate() const noexcept
Same as isPointData()
virtual tmp< pointField > points() const
Get the points that define the surface.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
tmp< GeometricField< Type, faPatchField, areaMesh > > average(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Area-weighted average a edgeField creating a areaField.
Definition: facAverage.C:47
const wordList surface
Standard surface field types (scalar, vector, tensor, etc)
Namespace for OpenFOAM.
To & refCast(From &r)
Reference type cast template function.
Definition: typeInfo.H:131
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:52
messageStream Info
Information stream (stdout output on master, null elsewhere)
vectorField pointField
pointField is a vectorField.
Definition: pointFieldFwd.H:44
Barycentric2D< scalar > barycentric2D
A scalar version of the templated Barycentric2D.
Definition: barycentric2D.H:52
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition: Ostream.H:349
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
Ostream & indent(Ostream &os)
Indent stream.
Definition: Ostream.H:342
triangle< point, const point & > triPointRef
A triangle using referred points.
Definition: triangle.H:71
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:33
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tdf1, const word &name, const dimensionSet &dimensions)
Global function forwards to reuseTmpDimensionedField::New.
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition: Ostream.H:356
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53