Loading...
Searching...
No Matches
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{
40 (
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 tmp<pointField> tpoints(surfaceTriMesh_.points());
114 const pointField& pts = tpoints();
115// const Map<label>& pMap = surfaceTriMesh_.meshPointMap();
116
117 triPointRef tri
118 (
119 pts[faceHitByPt[0]],
120 pts[faceHitByPt[1]],
121 pts[faceHitByPt[2]]
122 );
123
124 const barycentric2D bary = tri.pointToBarycentric(pt);
125
126// return pointCellSize_[pMap[faceHitByPt[0]]]*bary[0]
127// + pointCellSize_[pMap[faceHitByPt[1]]]*bary[1]
128// + pointCellSize_[pMap[faceHitByPt[2]]]*bary[2];
129 return pointCellSize_[faceHitByPt[0]]*bary[0]
130 + pointCellSize_[faceHitByPt[1]]*bary[1]
131 + pointCellSize_[faceHitByPt[2]]*bary[2];
132}
133
134
135// ************************************************************************* //
Macros for easy insertion into run-time selection tables.
#define addToRunTimeSelectionTable(baseType, thisType, argNames)
Add to construction table with typeName as the key.
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition dictionary.H:133
const triSurfaceMesh & surfaceTriMesh_
virtual scalar interpolate(const point &pt, const label index) const
Return the interpolated cell size for a point in the given.
nonUniformField(const dictionary &cellSizeFunctionDict, const searchableSurface &surface, const scalar &defaultCellSize)
Construct from components.
triSurfacePointScalarField pointCellSize_
constant condensation/saturation model.
Abstract base class for specifying target cell sizes.
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition className.H:142
tmp< GeometricField< Type, faPatchField, areaMesh > > average(const GeometricField< Type, faePatchField, edgeMesh > &ssf)
Area-weighted average a edgeField creating a areaField.
Definition facAverage.C:40
const wordList surface
Standard surface field types (scalar, vector, tensor, etc).
Namespace for OpenFOAM.
Type & refCast(U &obj)
A dynamic_cast (for references) to Type reference.
Definition typeInfo.H:172
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition hashSets.C:40
tmp< DimensionedField< TypeR, GeoMesh > > New(const tmp< DimensionedField< TypeR, GeoMesh > > &tf1, const word &name, const dimensionSet &dimensions, const bool initCopy=false)
Global function forwards to reuseTmpDimensionedField::New.
const dimensionSet dimLength(0, 1, 0, 0, 0, 0, 0)
Barycentric2D< scalar > barycentric2D
A scalar version of the templated Barycentric2D.
messageStream Info
Information stream (stdout output on master, null elsewhere).
Ostream & incrIndent(Ostream &os)
Increment the indent level.
Definition Ostream.H:490
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
Ostream & indent(Ostream &os)
Indent stream.
Definition Ostream.H:481
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
Definition hashSets.C:26
triangle< point, const point & > triPointRef
A triangle using referred points.
Definition triangleFwd.H:46
vectorField pointField
pointField is a vectorField.
Ostream & decrIndent(Ostream &os)
Decrement the indent level.
Definition Ostream.H:499
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
const pointField & pts