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 {
58  calcSkewCorrectionVectors();
59 }
60 
61 
63 {}
64 
65 
66 void Foam::skewCorrectionVectors::calcSkewCorrectionVectors()
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 // ************************************************************************* //
virtual bool coupled() const
Return true if this patch field is coupled.
Mesh data needed to do the Finite Volume discretisation.
Definition: fvMesh.H:78
dimensioned< scalar > mag(const dimensioned< Type > &)
GeometricBoundaryField & boundaryField()
Return reference to GeometricBoundaryField.
const surfaceVectorField & Sf() const
Return cell face area vectors.
const fvPatch & patch() const
Return patch.
virtual tmp< vectorField > delta() const
Return cell-centre to face-centre vector.
Definition: fvPatch.C:142
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
void size(const label)
Override size to be inconsistent with allocated storage.
Definition: ListI.H:76
InternalField & internalField()
Return internal field.
const labelUList & owner() const
Internal face owner.
Definition: fvMesh.H:282
const surfaceScalarField & deltaCoeffs() const
Return reference to cell-centre difference coefficients.
Graphite solid properties.
Definition: C.H:57
virtual const labelUList & faceCells() const
Return faceCells.
Definition: fvPatch.C:93
messageStream Info
dynamicFvMesh & mesh
const surfaceVectorField & Cf() const
Return face centres as surfaceVectorField.
Namespace for OpenFOAM.
const double e
Elementary charge.
Definition: doubleFloat.H:78
Ostream & endl(Ostream &os)
Add newline and flush stream.
Definition: Ostream.H:251
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:91
const volVectorField & C() const
Return cell centres as volVectorField.
volScalarField & p
Definition: createFields.H:51
skewCorrectionVectors(const fvMesh &mesh)
dimensioned< Type > max(const dimensioned< Type > &, const dimensioned< Type > &)
#define forAll(list, i)
Definition: UList.H:421
Templated abstract base-class for optional mesh objects used to automate their allocation to the mesh...
Definition: MeshObject.H:81
Skew-correction vectors for the skewness-corrected interpolation scheme.
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
static const Vector zero
Definition: Vector.H:80
const dimensionSet dimless(0, 0, 0, 0, 0, 0, 0)
Definition: dimensionSets.H:47
A finiteVolume patch using a polyPatch and a fvBoundaryMesh.
Definition: fvPatch.H:61
const labelUList & neighbour() const
Internal face neighbour.
Definition: fvMesh.H:288
virtual ~skewCorrectionVectors()
Destructor.
An abstract base class with a fat-interface to all derived classes covering all possible ways in whic...
Definition: fvsPatchField.H:65
virtual bool movePoints()
Update the correction vectors when the mesh moves.
defineTypeNameAndDebug(combustionModel, 0)