1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
5 \\ / A nd | Copyright held by original author
7 -------------------------------------------------------------------------------
9 This file is part of OpenFOAM.
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 the
13 Free Software Foundation; either version 2 of the License, or (at your
14 option) any later version.
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
21 You should have received a copy of the GNU General Public License
22 along with OpenFOAM; if not, write to the Free Software Foundation,
23 Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26 Class of static functions to calculate explicit finite element derivatives.
28 \*---------------------------------------------------------------------------*/
31 #include "tetCellList.H"
32 #include "tetPointRef.H"
34 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
39 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
47 typename outerProduct<vector, Type>::type,
54 const GeometricField<Type, tetPolyPatchField, tetPointMesh>& psi
57 typedef typename outerProduct<vector, Type>::type GradType;
59 const tetPolyMesh& tetMesh = psi.mesh();
61 tmp<GeometricField<GradType, tetPolyPatchField, tetPointMesh> > tFemGrad
63 new GeometricField<GradType, tetPolyPatchField, tetPointMesh>
67 "grad("+psi.name()+')',
77 psi.dimensions()/dimLength,
78 pTraits<GradType>::zero
83 GeometricField<GradType, tetPolyPatchField, tetPointMesh>& femGrad =
86 pointField points = tetMesh.points();
87 cellShapeList tetCellShapes = tetMesh.tetCells();
89 scalarField weights (points.size(), 0.0);
91 forAll (tetCellShapes, tetI)
93 cellShape& curShape = tetCellShapes[tetI];
95 tetPointRef curTetrahedron
106 curTetrahedron.Sa()*psi.internalField()[curShape[0]]
107 + curTetrahedron.Sb()*psi.internalField()[curShape[1]]
108 + curTetrahedron.Sc()*psi.internalField()[curShape[2]]
109 + curTetrahedron.Sd()*psi.internalField()[curShape[3]]
110 )/curTetrahedron.mag();
112 forAll (curShape, pointI)
115 curTetrahedron.mag()/
118 points[curShape[pointI]]
119 - curShape.centre(points)
122 femGrad.internalField()[curShape[pointI]] += weight*tetGrad;
124 weights[curShape[pointI]] += weight;
128 femGrad.internalField() /= weights;
139 typename outerProduct<vector, Type>::type,
146 const GeometricField<Type, tetPolyPatchField, tetPointMesh>& psi
149 typedef typename outerProduct<vector, Type>::type GradType;
151 const tetPolyMesh& tetMesh = psi.mesh();
153 const polyMesh& mesh = tetMesh();
156 tmp<GeometricField<GradType, elementPatchField, elementMesh> > tElemGrad
158 new GeometricField<GradType, elementPatchField, elementMesh>
162 "grad("+psi.name()+')',
169 dimensioned<GradType>
172 psi.dimensions()/dimLength,
173 pTraits<GradType>::zero
178 GeometricField<GradType, elementPatchField, elementMesh>& elemGrad =
181 pointField points = tetMesh.points();
183 scalarField weights (tetMesh.nCells(), 0.0);
185 const vectorField& C = mesh.cellCentres();
188 for (label cellI = 0; cellI < tetMesh.nCells(); cellI++)
190 tetCellList tets = tetMesh.tets(cellI);
194 tetPointRef curTetrahedron = tets[tetI].tet(points);
196 cellShape curShape = tets[tetI].tetCellShape();
201 curTetrahedron.Sa()*psi.internalField()[curShape[0]]
202 + curTetrahedron.Sb()*psi.internalField()[curShape[1]]
203 + curTetrahedron.Sc()*psi.internalField()[curShape[2]]
204 + curTetrahedron.Sd()*psi.internalField()[curShape[3]]
205 )/curTetrahedron.mag();
207 scalar weight = mag(C[cellI] - curShape.centre(points));
209 elemGrad.internalField()[cellI] += weight*tetGrad;
210 weights[cellI] += weight;
214 elemGrad.internalField() /= weights;
222 tmp<GeometricField<Type, elementPatchField, elementMesh> > tetFec::ddt
224 const GeometricField<Type, elementPatchField, elementMesh>& ef
227 const polyMesh& mesh = ef.mesh()();
229 dimensionedScalar rDeltaT = 1.0/mesh.time().deltaT();
233 "ddt("+ef.name()+')',
234 mesh.time().timeName(),
240 return tmp<GeometricField<Type, elementPatchField, elementMesh> >
242 new GeometricField<Type, elementPatchField, elementMesh>
245 rDeltaT*(ef - ef.oldTime())
250 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
252 } // End namespace Foam
254 // ************************************************************************* //