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 | Copyright (C) 2011-2013 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 \*---------------------------------------------------------------------------*/
25 
26 #include "skewCorrectionVectors.H"
27 #include "volFields.H"
28 
29 // * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
30 
31 namespace Foam
32 {
33  defineTypeNameAndDebug(skewCorrectionVectors, 0);
34 }
35 
36 
37 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
38 
40 :
42  skew_(false),
43  skewCorrectionVectors_
44  (
45  IOobject
46  (
47  "skewCorrectionVectors",
48  mesh_.pointsInstance(),
49  mesh_,
50  IOobject::NO_READ,
51  IOobject::NO_WRITE,
52  false
53  ),
54  mesh_,
55  dimless
56  )
57 {
59 }
60 
61 
63 {}
64 
65 
67 {
68  if (debug)
69  {
70  Info<< "surfaceInterpolation::calcSkewCorrectionVectors() : "
71  << "Calculating skew correction vectors"
72  << endl;
73  }
74 
75  // Set local references to mesh data
76  const volVectorField& C = mesh_.C();
77  const surfaceVectorField& Cf = mesh_.Cf();
78  const surfaceVectorField& Sf = mesh_.Sf();
79 
80  const labelUList& owner = mesh_.owner();
81  const labelUList& neighbour = mesh_.neighbour();
82 
83  forAll(owner, facei)
84  {
85  label own = owner[facei];
86  label nei = neighbour[facei];
87 
88  vector d = C[nei] - C[own];
89  vector Cpf = Cf[facei] - C[own];
90 
91  skewCorrectionVectors_[facei] =
92  Cpf - ((Sf[facei] & Cpf)/(Sf[facei] & d))*d;
93  }
94 
95 
96  forAll(skewCorrectionVectors_.boundaryField(), patchI)
97  {
98  fvsPatchVectorField& patchSkewCorrVecs =
99  skewCorrectionVectors_.boundaryField()[patchI];
100 
101  if (!patchSkewCorrVecs.coupled())
102  {
103  patchSkewCorrVecs = vector::zero;
104  }
105  else
106  {
107  const fvPatch& p = patchSkewCorrVecs.patch();
108  const labelUList& faceCells = p.faceCells();
109  const vectorField& patchFaceCentres = Cf.boundaryField()[patchI];
110  const vectorField& patchSf = Sf.boundaryField()[patchI];
111  const vectorField patchD(p.delta());
112 
113  forAll(p, patchFaceI)
114  {
115  vector Cpf =
116  patchFaceCentres[patchFaceI] - C[faceCells[patchFaceI]];
117 
118  patchSkewCorrVecs[patchFaceI] =
119  Cpf
120  - (
121  (patchSf[patchFaceI] & Cpf)/
122  (patchSf[patchFaceI] & patchD[patchFaceI])
123  )*patchD[patchFaceI];
124  }
125  }
126  }
127 
128  scalar skewCoeff = 0.0;
129 
130  if (Sf.internalField().size())
131  {
132  skewCoeff =
133  max(mag(skewCorrectionVectors_)*mesh_.deltaCoeffs()).value();
134  }
135 
136  if (debug)
137  {
138  Info<< "surfaceInterpolation::calcSkewCorrectionVectors() : "
139  << "skew coefficient = " << skewCoeff << endl;
140  }
141 
142  if (skewCoeff < 1e-5)
143  {
144  skew_ = false;
145  }
146  else
147  {
148  skew_ = true;
149  }
150 
151  if (debug)
152  {
153  Info<< "surfaceInterpolation::calcSkewCorrectionVectors() : "
154  << "Finished constructing skew correction vectors"
155  << endl;
156  }
157 }
158 
159 
161 {
162  calcSkewCorrectionVectors();
163  return true;
164 }
165 
166 
167 // ************************************************************************* //
skewCorrectionVectors.H
volFields.H
Foam::IOobject
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
Foam::dimless
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:47
Foam::Vector< scalar >::zero
static const Vector zero
Definition: Vector.H:80
p
p
Definition: pEqn.H:62
Foam::skewCorrectionVectors::~skewCorrectionVectors
virtual ~skewCorrectionVectors()
Destructor.
Definition: skewCorrectionVectors.C:62
forAll
#define forAll(list, i)
Loop across all elements in list.
Definition: UList.H:406
Foam::skewCorrectionVectors::calcSkewCorrectionVectors
void calcSkewCorrectionVectors()
Calculate skewness correction vectors.
Definition: skewCorrectionVectors.C:66
Foam::fvsPatchField
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:65
Foam::GeometricField::boundaryField
GeometricBoundaryField & boundaryField()
Return reference to GeometricBoundaryField.
Definition: GeometricField.C:735
Foam::MoveableMeshObject
Definition: MeshObject.H:238
Foam::endl
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
Foam::dimensioned::value
const Type & value() const
Return const reference to value.
Definition: dimensionedType.C:261
Foam::mag
dimensioned< scalar > mag(const dimensioned< Type > &)
Foam::skewCorrectionVectors::skewCorrectionVectors
skewCorrectionVectors(const fvMesh &mesh)
Definition: skewCorrectionVectors.C:39
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:59
Foam::Field
Pre-declare SubField and related Field type.
Definition: Field.H:57
Foam::Info
messageStream Info
Foam::fvPatch
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
Foam::GeometricField::internalField
InternalField & internalField()
Return internal field.
Definition: GeometricField.C:724
mesh
dynamicFvMesh & mesh
Definition: createDynamicFvMesh.H:18
Foam::C::C
C()
Construct null.
Definition: C.C:41
Foam::fvMesh
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
Foam
Namespace for OpenFOAM.
Definition: combustionModel.C:30
Foam::skewCorrectionVectors
Skew-correction vectors for the skewness-corrected interpolation scheme.
Definition: skewCorrectionVectors.H:52
Foam::e
const double e
Elementary charge.
Definition: doubleFloat.H:94
Foam::max
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
Foam::skewCorrectionVectors::movePoints
virtual bool movePoints()
Update the correction vectors when the mesh moves.
Definition: skewCorrectionVectors.C:160
Foam::fvsPatchField::patch
const fvPatch & patch() const
Return patch.
Definition: fvsPatchField.H:278
Foam::Vector< scalar >
Foam::UList
A 1D vector of objects of type <T>, where the size of the vector is known and can be used for subscri...
Definition: HashTable.H:60
Foam::MeshObject
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
Definition: MeshObject.H:81
Foam::C
Graphite solid properties.
Definition: C.H:57
Foam::GeometricField
Generic GeometricField class.
Definition: surfaceFieldsFwd.H:52
Foam::fvsPatchField::coupled
virtual bool coupled() const
Return true if this patch field is coupled.
Definition: fvsPatchField.H:308
Foam::defineTypeNameAndDebug
defineTypeNameAndDebug(combustionModel, 0)