42 const DimensionedField<Type, volMesh>& positiveC,
43 const DimensionedField<Type, pointMesh>& positiveP,
44 const DimensionedField<Type, volMesh>& negativeC,
45 const DimensionedField<Type, pointMesh>& negativeP
48 tmp<DimensionedField<Type, volMesh>> tResult
50 new DimensionedField<Type, volMesh>
54 positiveC.name() +
":levelSetAverage",
55 mesh.time().timeName(),
59 dimensioned<Type>(positiveC.dimensions(),
Zero)
62 DimensionedField<Type, volMesh>& result = tResult.ref();
66 const List<tetIndices> cellTetIs =
67 polyMeshTetDecomposition::cellTetIndices(
mesh, cI);
72 forAll(cellTetIs, cellTetI)
74 const triFace triIs = cellTetIs[cellTetI].faceTriIs(
mesh);
76 const FixedList<point, 4>
79 mesh.cellCentres()[cI],
80 mesh.points()[triIs[0]],
81 mesh.points()[triIs[1]],
82 mesh.points()[triIs[2]]
84 const FixedList<scalar, 4>
92 const cut::volumeIntegrateOp<Type>
93 positive = FixedList<Type, 4>
100 const cut::volumeIntegrateOp<Type>
101 negative = FixedList<Type, 4>
109 v += cut::volumeOp()(tet);
111 r +=
tetCut(tet, level, positive, negative);
124 const fvPatch&
patch,
127 const Field<Type>& positiveF,
128 const Field<Type>& positiveP,
129 const Field<Type>& negativeF,
130 const Field<Type>& negativeP
135 tmp<Field<Type>> tResult(
new Field<Type>(
patch.size(),
Zero));
136 Field<Type>& result = tResult.ref();
140 const face&
f =
patch.patch().localFaces()[fI];
145 for (label edgei = 0; edgei <
f.nEdges(); ++edgei)
147 const edge
e =
f.edge(edgei);
149 const FixedList<point, 3>
152 patch.patch().faceCentres()[fI],
153 patch.patch().localPoints()[
e[0]],
154 patch.patch().localPoints()[
e[1]]
156 const FixedList<scalar, 3>
163 const cut::areaIntegrateOp<Type>
164 positive = FixedList<Type, 3>
170 const cut::areaIntegrateOp<Type>
171 negative = FixedList<Type, 3>
178 a += cut::areaOp()(tri);
180 r +=
triCut(tri, level, positive, negative);
183 result[fI] = a/
magSqr(a) & r;
cut::opAddResult< AboveOp, BelowOp >::type tetCut(const FixedList< point, 4 > &tet, const FixedList< scalar, 4 > &level, const AboveOp &aboveOp, const BelowOp &belowOp)
As triCut, but for a tetrahedron.
cut::opAddResult< AboveOp, BelowOp >::type triCut(const FixedList< point, 3 > &tri, const FixedList< scalar, 3 > &level, const AboveOp &aboveOp, const BelowOp &belowOp)
Cut a triangle along the zero plane defined by the given levels.
#define forAll(list, i)
Loop across all elements in list.
tmp< DimensionedField< Type, volMesh > > levelSetAverage(const fvMesh &mesh, const scalarField &levelC, const scalarField &levelP, const DimensionedField< Type, volMesh > &positiveC, const DimensionedField< Type, pointMesh > &positiveP, const DimensionedField< Type, volMesh > &negativeC, const DimensionedField< Type, pointMesh > &negativeP)
Calculate the average value of two fields, one on each side of a level set.
const dimensionedScalar e
Elementary charge.
Field< scalar > scalarField
Specialisation of Field<T> for scalar.
const std::string patch
OpenFOAM patch number as a std::string.
A class for managing temporary objects.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
static constexpr const zero Zero
Global zero (0)