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#include "HashTable.H"
34
35// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
36
37namespace Foam
38{
39
40// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41
42namespace fa
43{
44
45// * * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * //
46
47template<class Type>
49(
50 const faMesh& mesh,
51 Istream& schemeData
52)
53{
54 if (fa::debug)
55 {
57 << "constructing lnGradScheme<Type>"
58 << endl;
59 }
60
61 if (schemeData.eof())
62 {
63 FatalIOErrorInFunction(schemeData)
64 << "Grad scheme not specified" << nl << nl
65 << "Valid schemes are :" << endl
66 << MeshConstructorTablePtr_->sortedToc()
68 }
69
70 const word schemeName(schemeData);
71
72 auto* ctorPtr = MeshConstructorTable(schemeName);
73
74 if (!ctorPtr)
75 {
77 (
78 schemeData,
79 "grad",
80 schemeName,
81 *MeshConstructorTablePtr_
82 ) << exit(FatalIOError);
83 }
84
85 return ctorPtr(mesh, schemeData);
86}
87
88
89// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
90
91template<class Type>
93{}
94
95
96// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
97
98template<class Type>
101(
103 const tmp<edgeScalarField>& tdeltaCoeffs,
104 const word& lnGradName
105)
106{
107 const faMesh& mesh = vf.mesh();
108
109 // construct GeometricField<Type, faePatchField, edgeMesh>
111 (
113 (
115 (
116 lnGradName + "("+vf.name()+')',
117 vf.instance(),
118 vf.db(),
121 ),
122 mesh,
123 vf.dimensions()*tdeltaCoeffs().dimensions()
124 )
125 );
127
128 // set reference to difference factors array
129 const scalarField& deltaCoeffs = tdeltaCoeffs().internalField();
130
131 // owner/neighbour addressing
132 const labelUList& owner = mesh.owner();
133 const labelUList& neighbour = mesh.neighbour();
134
135 forAll(owner, faceI)
136 {
137 ssf[faceI] =
138 deltaCoeffs[faceI]*(vf[neighbour[faceI]] - vf[owner[faceI]]);
139 }
140
141 auto& ssfb = ssf.boundaryFieldRef();
142
143 forAll(vf.boundaryField(), patchI)
144 {
145 ssfb[patchI] = vf.boundaryField()[patchI].snGrad();
146 }
147
148 return tssf;
149}
150
151
152template<class Type>
155(
157) const
158{
160 lnGrad(vf, deltaCoeffs(vf));
161
162 if (corrected())
163 {
164 tsf.ref() += correction(vf);
165 }
166
167 return tsf;
168}
169
170
171template<class Type>
174(
176) const
177{
179 lnGrad(tvf());
180 tvf.clear();
181 return tinterpVf;
182}
183
184
185// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
186
187} // End namespace fa
188
189// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
190
191} // End namespace Foam
192
193// ************************************************************************* //
const dimensionSet & dimensions() const
Return dimensions.
const Mesh & mesh() const
Return mesh.
Generic GeometricField class.
Boundary & boundaryFieldRef(const bool updateAccessTime=true)
Return a reference to the boundary field.
const Boundary & boundaryField() const
Return const-reference to the boundary field.
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:170
const word & name() const noexcept
Return the object name.
Definition: IOobjectI.H:65
const objectRegistry & db() const noexcept
Return the local objectRegistry.
Definition: IOobject.C:500
const fileName & instance() const noexcept
Read access to instance path component.
Definition: IOobjectI.H:196
bool eof() const noexcept
True if end of input seen.
Definition: IOstream.H:239
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:64
static autoPtr< Time > New()
Construct (dummy) Time - no functionObjects or libraries.
Definition: Time.C:717
Finite area mesh (used for 2-D non-Euclidian finite area method) defined using a patch of faces on a ...
Definition: faMesh.H:100
virtual ~lnGradScheme()
Destructor.
Definition: lnGradScheme.C:92
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.
Definition: lnGradScheme.C:101
A class for managing temporary objects.
Definition: tmp.H:65
T & ref() const
Definition: tmpI.H:227
A class for handling words, derived from Foam::string.
Definition: word.H:68
dynamicFvMesh & mesh
#define FatalIOErrorInLookup(ios, lookupTag, lookupName, lookupTable)
Report an error message using Foam::FatalIOError.
Definition: error.H:478
#define FatalIOErrorInFunction(ios)
Report an error message using Foam::FatalIOError.
Definition: error.H:473
#define InfoInFunction
Report an information message using Foam::Info.
Namespace for OpenFOAM.
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
IOerror FatalIOError
tmp< fvMatrix< Type > > correction(const fvMatrix< Type > &)
errorManipArg< error, int > exit(error &err, const int errNo=1)
Definition: errorManip.H:130
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333