1 /*---------------------------------------------------------------------------*\
3 \\ / F ield | foam-extend: Open Source CFD
4 \\ / O peration | Version: 3.2
5 \\ / A nd | Web: http://www.foam-extend.org
6 \\/ M anipulation | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
9 This file is part of foam-extend.
11 foam-extend 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 3 of the License, or (at your
14 option) any later version.
16 foam-extend is distributed in the hope that it will be useful, but
17 WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 General Public License for more details.
21 You should have received a copy of the GNU General Public License
22 along with foam-extend. If not, see <http://www.gnu.org/licenses/>.
25 Class of static functions to calculate explicit finite element derivatives.
27 \*---------------------------------------------------------------------------*/
30 #include "tetCellList.H"
31 #include "tetPointRef.H"
33 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
38 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
46 typename outerProduct<vector, Type>::type,
53 const GeometricField<Type, tetPolyPatchField, tetPointMesh>& psi
56 typedef typename outerProduct<vector, Type>::type GradType;
58 const tetPolyMesh& tetMesh = psi.mesh();
60 tmp<GeometricField<GradType, tetPolyPatchField, tetPointMesh> > tFemGrad
62 new GeometricField<GradType, tetPolyPatchField, tetPointMesh>
66 "grad("+psi.name()+')',
76 psi.dimensions()/dimLength,
77 pTraits<GradType>::zero
82 GeometricField<GradType, tetPolyPatchField, tetPointMesh>& femGrad =
85 pointField points = tetMesh.points();
86 cellShapeList tetCellShapes = tetMesh.tetCells();
88 scalarField weights (points.size(), 0.0);
90 forAll (tetCellShapes, tetI)
92 cellShape& curShape = tetCellShapes[tetI];
94 tetPointRef curTetrahedron
105 curTetrahedron.Sa()*psi.internalField()[curShape[0]]
106 + curTetrahedron.Sb()*psi.internalField()[curShape[1]]
107 + curTetrahedron.Sc()*psi.internalField()[curShape[2]]
108 + curTetrahedron.Sd()*psi.internalField()[curShape[3]]
109 )/curTetrahedron.mag();
111 forAll (curShape, pointI)
114 curTetrahedron.mag()/
117 points[curShape[pointI]]
118 - curShape.centre(points)
121 femGrad.internalField()[curShape[pointI]] += weight*tetGrad;
123 weights[curShape[pointI]] += weight;
127 femGrad.internalField() /= weights;
138 typename outerProduct<vector, Type>::type,
145 const GeometricField<Type, tetPolyPatchField, tetPointMesh>& psi
148 typedef typename outerProduct<vector, Type>::type GradType;
150 const tetPolyMesh& tetMesh = psi.mesh();
152 const polyMesh& mesh = tetMesh();
155 tmp<GeometricField<GradType, elementPatchField, elementMesh> > tElemGrad
157 new GeometricField<GradType, elementPatchField, elementMesh>
161 "grad("+psi.name()+')',
168 dimensioned<GradType>
171 psi.dimensions()/dimLength,
172 pTraits<GradType>::zero
177 GeometricField<GradType, elementPatchField, elementMesh>& elemGrad =
180 pointField points = tetMesh.points();
182 scalarField weights (tetMesh.nCells(), 0.0);
184 const vectorField& C = mesh.cellCentres();
187 for (label cellI = 0; cellI < tetMesh.nCells(); cellI++)
189 tetCellList tets = tetMesh.tets(cellI);
193 tetPointRef curTetrahedron = tets[tetI].tet(points);
195 cellShape curShape = tets[tetI].tetCellShape();
200 curTetrahedron.Sa()*psi.internalField()[curShape[0]]
201 + curTetrahedron.Sb()*psi.internalField()[curShape[1]]
202 + curTetrahedron.Sc()*psi.internalField()[curShape[2]]
203 + curTetrahedron.Sd()*psi.internalField()[curShape[3]]
204 )/curTetrahedron.mag();
206 scalar weight = mag(C[cellI] - curShape.centre(points));
208 elemGrad.internalField()[cellI] += weight*tetGrad;
209 weights[cellI] += weight;
213 elemGrad.internalField() /= weights;
221 tmp<GeometricField<Type, elementPatchField, elementMesh> > tetFec::ddt
223 const GeometricField<Type, elementPatchField, elementMesh>& ef
226 const polyMesh& mesh = ef.mesh()();
228 dimensionedScalar rDeltaT = 1.0/mesh.time().deltaT();
232 "ddt("+ef.name()+')',
233 mesh.time().timeName(),
239 return tmp<GeometricField<Type, elementPatchField, elementMesh> >
241 new GeometricField<Type, elementPatchField, elementMesh>
244 rDeltaT*(ef - ef.oldTime())
249 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
251 } // End namespace Foam
253 // ************************************************************************* //