Loading...
Searching...
No Matches
lnGradScheme.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) 2016-2017 Wikki Ltd
9 Copyright (C) 2019-2021 OpenCFD Ltd.
10-------------------------------------------------------------------------------
11License
12 This file is part of OpenFOAM.
13
14 OpenFOAM is free software: you can redistribute it and/or modify it
15 under the terms of the GNU General Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22 for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26
27\*---------------------------------------------------------------------------*/
28
29#include "fa.H"
30#include "lnGradScheme.H"
31#include "areaFields.H"
32#include "edgeFields.H"
33
34// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
35
36namespace Foam
37{
38
39// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41namespace fa
42{
43
44// * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
45
46template<class Type>
48(
49 const faMesh& mesh,
50 Istream& schemeData
51)
52{
53 if (fa::debug)
54 {
56 << "constructing lnGradScheme<Type>"
57 << endl;
58 }
59
60 if (schemeData.eof())
61 {
62 FatalIOErrorInFunction(schemeData)
63 << "Grad scheme not specified" << nl << nl
64 << "Valid schemes are :" << endl
65 << MeshConstructorTablePtr_->sortedToc()
67 }
68
69 const word schemeName(schemeData);
70
71 auto* ctorPtr = MeshConstructorTable(schemeName);
72
73 if (!ctorPtr)
74 {
76 (
77 schemeData,
78 "grad",
79 schemeName,
80 *MeshConstructorTablePtr_
81 ) << exit(FatalIOError);
82 }
83
84 return ctorPtr(mesh, schemeData);
85}
86
87
88// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
89
90template<class Type>
92{}
93
94
95// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
96
97template<class Type>
100(
102 const tmp<edgeScalarField>& tdeltaCoeffs,
103 const word& lnGradName
104)
105{
106 const faMesh& mesh = vf.mesh();
107
108 // construct GeometricField<Type, faePatchField, edgeMesh>
110 (
112 (
114 (
115 lnGradName + "("+vf.name()+')',
116 vf.instance(),
117 vf.db(),
120 ),
121 mesh,
122 vf.dimensions()*tdeltaCoeffs().dimensions()
123 )
124 );
126
127 // set reference to difference factors array
128 const scalarField& deltaCoeffs = tdeltaCoeffs().internalField();
129
130 // owner/neighbour addressing
131 const labelUList& owner = mesh.owner();
132 const labelUList& neighbour = mesh.neighbour();
133
134 forAll(owner, faceI)
135 {
136 ssf[faceI] =
137 deltaCoeffs[faceI]*(vf[neighbour[faceI]] - vf[owner[faceI]]);
138 }
139
140 auto& ssfb = ssf.boundaryFieldRef();
141
142 forAll(vf.boundaryField(), patchI)
143 {
144 ssfb[patchI] = vf.boundaryField()[patchI].snGrad();
145 }
147 return tssf;
148}
149
150
151template<class Type>
154(
156) const
157{
159 lnGrad(vf, deltaCoeffs(vf));
160
161 if (corrected())
162 {
163 tsf.ref() += correction(vf);
164 }
166 return tsf;
167}
168
169
170template<class Type>
173(
175) const
176{
178 lnGrad(tvf());
179 tvf.clear();
180 return tinterpVf;
181}
182
183
184// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
185
186} // End namespace fa
187
188// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
189
190} // End namespace Foam
191
192// ************************************************************************* //
const Mesh & mesh() const noexcept
Return const reference to mesh.
const dimensionSet & dimensions() const noexcept
Return dimensions.
Generic GeometricField class.
Internal & ref(const bool updateAccessTime=true)
Same as internalFieldRef().
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
const Boundary & boundaryField() const noexcept
Return const-reference to the boundary field.
@ NO_READ
Nothing to be read.
@ NO_WRITE
Ignore writing from objectRegistry::writeObject().
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
bool eof() const noexcept
True if end of input seen.
Definition IOstream.H:289
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition Istream.H:60
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition faMesh.H:140
virtual ~lnGradScheme()
Destructor.
virtual bool corrected() const
Return true if this scheme uses an explicit correction.
static tmp< GeometricField< Type, faePatchField, edgeMesh > > lnGrad(const GeometricField< Type, faPatchField, areaMesh > &, const tmp< edgeScalarField > &, const word &snGradName="lnGrad")
Return the lnGrad of the given cell field.
const faMesh & mesh() const noexcept
Return mesh reference.
static tmp< lnGradScheme< Type > > New(const faMesh &mesh, Istream &schemeData)
Return new tmp interpolation scheme.
virtual tmp< edgeScalarField > deltaCoeffs(const GeometricField< Type, faPatchField, areaMesh > &) const =0
Return the interpolation weighting factors for the given field.
A class for managing temporary objects.
Definition tmp.H:75
T & ref() const
Return non-const reference to the contents of a non-null managed pointer.
Definition tmpI.H:235
A class for handling words, derived from Foam::string.
Definition word.H:66
dynamicFvMesh & mesh
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition error.H:637
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition error.H:629
#define InfoInFunction
Report an information message using Foam::Info.
Namespace for finite-area.
Definition limitHeight.C:30
Namespace for OpenFOAM.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition Ostream.H:519
IOerror FatalIOError
Error stream (stdout output on all processes), with additional 'FOAM FATAL IO ERROR' header text and ...
tmp< fvMatrix< Type > > correction(const fvMatrix< Type > &)
Return the correction form of the given matrix by subtracting the matrix multiplied by the current fi...
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition errorManip.H:125
UList< label > labelUList
A UList of labels.
Definition UList.H:75
constexpr char nl
The newline '\n' character (0x0a).
Definition Ostream.H:50
#define forAll(list, i)
Loop across all elements in list.
Definition stdFoam.H:299