skewCorrectionVectors.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) 2011-2016 OpenFOAM Foundation
9 Copyright (C) 2020 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
30#include "volFields.H"
31
32// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
33
34namespace Foam
35{
37}
38
39
40// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
41
43:
45 skew_(false),
46 skewCorrectionVectors_
47 (
49 (
50 "skewCorrectionVectors",
51 mesh_.pointsInstance(),
52 mesh_,
53 IOobject::NO_READ,
54 IOobject::NO_WRITE,
55 false
56 ),
57 mesh_,
59 )
60{
61 calcSkewCorrectionVectors();
62}
63
64
66{}
67
68
69void Foam::skewCorrectionVectors::calcSkewCorrectionVectors()
70{
71 DebugInFunction << "Calculating skew correction vectors" << nl;
72
73 // Set local references to mesh data
74 const volVectorField& C = mesh_.C();
75 const surfaceVectorField& Cf = mesh_.Cf();
76 const surfaceVectorField& Sf = mesh_.Sf();
77
78 const labelUList& owner = mesh_.owner();
79 const labelUList& neighbour = mesh_.neighbour();
80
81 forAll(owner, facei)
82 {
83 label own = owner[facei];
84 label nei = neighbour[facei];
85
86 vector d = C[nei] - C[own];
87 vector Cpf = Cf[facei] - C[own];
88
89 skewCorrectionVectors_[facei] =
90 Cpf - ((Sf[facei] & Cpf)/(Sf[facei] & d))*d;
91 }
92
93 surfaceVectorField::Boundary& skewCorrVecsBf =
94 skewCorrectionVectors_.boundaryFieldRef();
95
96 forAll(skewCorrVecsBf, patchi)
97 {
98 fvsPatchVectorField& patchSkewCorrVecs = skewCorrVecsBf[patchi];
99
100 if (!patchSkewCorrVecs.coupled())
101 {
102 patchSkewCorrVecs = Zero;
103 }
104 else
105 {
106 const fvPatch& p = patchSkewCorrVecs.patch();
107 const labelUList& faceCells = p.faceCells();
108 const vectorField& patchFaceCentres = Cf.boundaryField()[patchi];
109 const vectorField& patchSf = Sf.boundaryField()[patchi];
110 const vectorField patchD(p.delta());
111
112 forAll(p, patchFacei)
113 {
114 vector Cpf =
115 patchFaceCentres[patchFacei] - C[faceCells[patchFacei]];
116
117 patchSkewCorrVecs[patchFacei] =
118 Cpf
119 - (
120 (patchSf[patchFacei] & Cpf)/
121 (patchSf[patchFacei] & patchD[patchFacei])
122 )*patchD[patchFacei];
123 }
124 }
125 }
126
127 scalar skewCoeff = 0.0;
128
129 if (Sf.primitiveField().size())
130 {
131 skewCoeff =
132 max(mag(skewCorrectionVectors_)*mesh_.deltaCoeffs()).value();
133 }
134
135 DebugInFunction << "skew coefficient = " << skewCoeff << nl;
136
137 if (skewCoeff < 1e-5)
138 {
139 skew_ = false;
140 }
141 else
142 {
143 skew_ = true;
144 }
145
146 if (debug)
147 {
148 Info<< " Finished constructing skew correction vectors" << endl;
149 }
150}
151
152
154{
155 calcSkewCorrectionVectors();
156 return true;
157}
158
159
160// ************************************************************************* //
Graphite solid properties.
Definition: C.H:53
C()
Construct null.
Definition: C.C:43
const Internal::FieldType & primitiveField() const
Return a const-reference to the internal field.
GeometricBoundaryField< vector, fvsPatchField, surfaceMesh > Boundary
Type of boundary fields.
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
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
Definition: MeshObject.H:91
void size(const label n)
Older name for setAddressableSize.
Definition: UList.H:114
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:91
Skew-correction vectors for the skewness-corrected interpolation scheme.
virtual bool movePoints()
Update the correction vectors when the mesh moves.
virtual ~skewCorrectionVectors()
Destructor.
A Vector of values with scalar precision, where scalar is float/double depending on the compilation f...
#define defineTypeNameAndDebug(Type, DebugSwitch)
Define the typeName and debug information.
Definition: className.H:121
volScalarField & p
dynamicFvMesh & mesh
#define DebugInFunction
Report an information message using Foam::Info.
Namespace for OpenFOAM.
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
Definition: hashSets.C:47
const dimensionSet dimless
Dimensionless.
messageStream Info
Information stream (stdout output on master, null elsewhere)
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:372
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
Field< vector > vectorField
Specialisation of Field<T> for vector.
static constexpr const zero Zero
Global zero (0)
Definition: zero.H:131
UList< label > labelUList
A UList of labels.
Definition: UList.H:85
fvsPatchField< vector > fvsPatchVectorField
constexpr char nl
The newline '\n' character (0x0a)
Definition: Ostream.H:53
volScalarField & C
volScalarField & e
Definition: createFields.H:11
#define forAll(list, i)
Loop across all elements in list.
Definition: stdFoam.H:333