Loading...
Searching...
No Matches
leastSquaresEdgeInterpolation.H
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) 2022 OpenCFD Ltd.
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
26Class
27 Foam::leastSquaresEdgeInterpolation
28
29Description
30 Least-squares edge interpolation scheme class, from
31 face centers to points then from points to edges.
32
33 References:
34 \verbatim
35 Governing equations (tag:P):
36 Pesci, C. (2019).
37 Computational analysis of fluid interfaces
38 influenced by soluble surfactant.
39 Darmstadt, Technische Universität. PhD thesis.
40 URI:https://tuprints.ulb.tu-darmstadt.de/id/eprint/9303
41 \endverbatim
42
43SourceFiles
44 leastSquaresEdgeInterpolationMake.C
45
46\*---------------------------------------------------------------------------*/
47
48#ifndef Foam_leastSquaresEdgeInterpolation_H
49#define Foam_leastSquaresEdgeInterpolation_H
50
52#include "areaFields.H"
53#include "edgeFields.H"
54#include "leastSquaresFaGrad.H"
55
56// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
57
58namespace Foam
59{
60
61/*---------------------------------------------------------------------------*\
62 Class leastSquaresEdgeInterpolation Declaration
63\*---------------------------------------------------------------------------*/
64
65template<class Type>
67:
68 virtual public edgeInterpolationScheme<Type>
69{
70public:
71
72 //- Runtime type information
73 TypeName("leastSquares");
74
75
76 // Generated Methods
77
78 //- No copy construct
80 = delete;
81
82 //- No copy assignment
83 void operator=(const leastSquaresEdgeInterpolation&) = delete;
85
86 // Constructors
87
88 //- Construct from mesh
90 :
92 {}
93
94 //- Construct from Istream
96 :
98 {}
99
100 //- Construct from faceFlux and Istream
102 (
103 const faMesh& mesh,
104 const edgeScalarField&,
105 Istream&
106 )
107 :
109 {}
110
111
112 // Member Functions
113
114 //- Return the edge-interpolate of the given face field
117 (
119 ) const;
120
121 //- Return the interpolation weighting factors
123 (
125 ) const
126 {
127 return this->mesh().edgeInterpolation::weights();
128 }
129};
130
131
132template<class Type>
142 typedef Field<Type> FieldType;
143
144 const faMesh& mesh = af.mesh();
146 const labelList& meshPts = mesh.patch().meshPoints();
147 const labelListList& pointFaceAddr = mesh.patch().pointFaces();
148 const areaVectorField& C = mesh.areaCentres();
149
151 const GradFieldType& gradAf = tgradAf.cref();
152
153 // Field at surface points, Pi (P:p. 29-30)
154 auto tPi = tmp<FieldType>::New(meshPts.size(), Zero);
155 FieldType& Pi = tPi.ref();
156
157 forAll(meshPts, i)
158 {
159 const label nFaces = pointFaceAddr[i].size();
160
161 FieldType Pij(nFaces);
162 vectorField dPC(nFaces);
163
164 for (label facei = 0; facei < nFaces; ++facei)
165 {
166 const label j = pointFaceAddr[i][facei];
167
168 // Euclidean distance between a point and face centres (P:Fig. 3.3)
169 dPC[facei] = mesh.points()[i] - C[j];
170
171 // (P:Eq. 3.14)
172 Pij[facei] = af[j] + (dPC[facei] & gradAf[j]);
173 }
174
175 const scalarField magdPC(max(mag(dPC), SMALL));
176
177 // (P:Eq. 3.15)
178 Pi[i] = sum(Pij/magdPC)/sum(scalar(1)/magdPC);
179 }
180
181 tgradAf.clear();
182
183
184 auto tinterp = tmp<EdgeFieldType>::New
185 (
186 IOobject
187 (
188 "interpolate(" + af.name() + ')',
189 af.instance(),
190 af.db()
191 ),
192 af.mesh(),
193 af.dimensions()
194 );
195 EdgeFieldType& interp = tinterp.ref();
196 FieldType& interpEdges = interp.primitiveFieldRef();
197
198
199 const edgeList& faEdges = mesh.edges();
200 const label nInternalEdges = mesh.nInternalEdges();
201
202 // Internal field
203 for (label edgei = 0; edgei < nInternalEdges; ++edgei)
204 {
205 // (P:Eq. 3.16)
206 interpEdges[edgei] =
207 0.5*
208 (
209 Pi[faEdges[edgei].start()]
210 + Pi[faEdges[edgei].end()]
211 );
212 }
213
214 // Boundary field from boundary condition [fixedValue]
215 // Coupled boundary fields are not handled
216 forAll(interp.boundaryField(), patchi)
217 {
218 interp.boundaryFieldRef()[patchi] = af.boundaryField()[patchi];
219 }
220
221 return tinterp;
222}
223
224
225// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
226
227} // End namespace Foam
228
229// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
230
231#endif
232
233// ************************************************************************* //
Graphite solid properties.
Definition C.H:49
const Mesh & mesh() const noexcept
Return const reference to mesh.
const dimensionSet & dimensions() const noexcept
Return dimensions.
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Definition Field.H:172
Generic GeometricField class.
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition IOobject.H:191
const word & name() const noexcept
Return the object name.
Definition IOobjectI.H:205
const objectRegistry & db() const noexcept
Return the local objectRegistry.
Definition IOobject.C:450
const fileName & instance() const noexcept
Read access to instance path component.
Definition IOobjectI.H:289
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
void size(const label n)
Older name for setAddressableSize.
Definition UList.H:118
Abstract base class for edge interpolation schemes.
edgeInterpolationScheme(const edgeInterpolationScheme &)=delete
No copy construct.
const faMesh & mesh() const
Return mesh reference.
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition faMesh.H:140
tmp< GeometricField< typename outerProduct< vector, Type >::type, faPatchField, areaMesh > > grad(const GeometricField< Type, faPatchField, areaMesh > &, const word &name) const
Calculate and return the grad of the given field which may have been cached.
Second-order gradient scheme using least-squares.
TypeName("leastSquares")
Runtime type information.
leastSquaresEdgeInterpolation(const faMesh &mesh)
Construct from mesh.
tmp< edgeScalarField > weights(const GeometricField< Type, faPatchField, areaMesh > &) const
Return the interpolation weighting factors.
leastSquaresEdgeInterpolation(const leastSquaresEdgeInterpolation &)=delete
No copy construct.
tmp< GeometricField< Type, faePatchField, edgeMesh > > interpolate(const GeometricField< Type, faPatchField, areaMesh > &) const
Return the edge-interpolate of the given face field.
void operator=(const leastSquaresEdgeInterpolation &)=delete
No copy assignment.
leastSquaresEdgeInterpolation(const faMesh &mesh, const edgeScalarField &, Istream &)
Construct from faceFlux and Istream.
leastSquaresEdgeInterpolation(const faMesh &mesh, Istream &)
Construct from Istream.
typeOfRank< typenamepTraits< arg1 >::cmptType, direction(pTraits< arg1 >::rank)+direction(pTraits< arg2 >::rank)>::type type
Definition products.H:118
A class for managing temporary objects.
Definition tmp.H:75
const T & cref() const
Return const reference to the object or to the contents of a (non-null) managed pointer.
Definition tmpI.H:221
void clear() const noexcept
If object pointer points to valid object: delete object and set pointer to nullptr.
Definition tmpI.H:289
static tmp< T > New(Args &&... args)
Construct tmp with forwarding arguments.
Definition tmp.H:215
dynamicFvMesh & mesh
Namespace for OpenFOAM.
List< edge > edgeList
List of edge.
Definition edgeList.H:32
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition hashSets.C:40
List< labelList > labelListList
List of labelList.
Definition labelList.H:38
List< label > labelList
A List of labels.
Definition List.H:62
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
GeometricField< vector, faPatchField, areaMesh > areaVectorField
GeometricField< scalar, faePatchField, edgeMesh > edgeScalarField
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Field< vector > vectorField
Specialisation of Field<T> for vector.
dimensioned< Type > sum(const DimensionedField< Type, GeoMesh > &f1, const label comm)
static constexpr const zero Zero
Global zero (0).
Definition zero.H:127
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299
#define TypeName(TypeNameString)
Declare a ClassName() with extra virtual type info.
Definition typeInfo.H:68