38 template<
class Int, Int Offset,
class Sequence>
41 template<
class Int, Int Offset, Int ... Is>
44 using type = std::integer_sequence<Int, Is + Offset ...>;
48 template<
class Int, Int Min, Int Max>
56 std::make_index_sequence<Max - Min>
61 template<
class Tuple,
class Int, Int ... Is>
65 const std::integer_sequence<Int, Is ...>&
68 return std::make_tuple(std::get<Is>(tuple) ...);
72 template<
class Op,
class Tuple,
class Int, Int ... Is>
76 const std::integer_sequence<Int, Is ...>&,
80 return std::make_tuple(op(std::get<Is>(tuple)) ...);
84 template<
class ... Types>
96 template<
class Op,
class ... Types>
97 auto tupleOp(
const std::tuple<Types ...>& tuple,
const Op& op)
103 std::make_index_sequence<
sizeof ... (Types)>(),
109 template<
class Op,
class Tuple,
class Int, Int ... Is>
113 const std::integer_sequence<Int, Is ...>&,
117 (void)std::initializer_list<nil>
119 op(std::get<Is>(tuple)),
125 template<
class Op,
class ... Types>
128 tupleInPlaceOp(tuple, std::make_index_sequence<
sizeof ... (Types)>(), op);
132 template<
class BinaryOp,
class Tuple,
class Int, Int ... Is>
137 const std::integer_sequence<Int, Is ...>&,
141 return std::make_tuple(bop(std::get<Is>(tupleA), std::get<Is>(tupleB)) ...);
145 template<
class BinaryOp,
class ... TypesA,
class ... TypesB>
148 const std::tuple<TypesA ...>& tupleA,
149 const std::tuple<TypesB ...>& tupleB,
157 std::make_index_sequence<
sizeof ... (TypesA)>(),
169 template<
template<
class>
class FaceValues,
class ... Types>
173 std::tuple<Foam::cutPoly::AreaIntegralType<Types> ...>
177 const FaceValues<point>& fPs,
179 const std::tuple<FaceValues<Types> ...>& fPsis,
180 const std::tuple<Types ...>& fPsiAvgs
184 auto fCutsAreaPsi = std::make_tuple(AreaIntegralType<Types>(
Zero) ...);
186 typename FaceValues<point>::const_iterator fPIter(fPs.begin());
187 auto fPsiIter =
tupleOp(fPsis, OpBegin());
189 for(; fPIter != fPs.end(); ++ fPIter)
191 const point p0 = *fPIter;
192 const point p1 = fPIter.next();
193 auto psi0 =
tupleOp(fPsiIter, OpDereference());
194 auto psi1 =
tupleOp(fPsiIter, OpNext());
196 const vector a = ((p1 - p0)^(fPAvg - p0))/2;
216 OpScaled<vector>(a/3)
225 Tuple2<vector, std::tuple<AreaIntegralType<Types> ...>>
233 template<
template<
class>
class FaceValues,
class ... Types>
237 const FaceValues<point>& fPs,
239 const std::tuple<FaceValues<Types> ...>& fPsis,
240 const std::tuple<Types ...>& fPsiAvgs
245 const vector& fArea = fSumPPsis.first();
246 const scalar fMagSqrArea =
magSqr(fArea);
249 Tuple2<
vector, std::tuple<Types ...>>
253 ?
tupleOp(fSumPPsis.second(), OpPreInner(fArea/fMagSqrArea))
259 template<
class ... Types>
263 std::tuple<Foam::cutPoly::AreaIntegralType<Types> ...>
269 const std::tuple<Types ...>& fPsis,
270 const List<labelPair>& fCuts,
272 const std::tuple<
const Field<Types>& ...>& pPsis,
274 const scalar isoAlpha,
280 if (fCuts.size() == 0)
282 if ((pAlphas[
f[0]] < isoAlpha) == below)
285 Tuple2<vector, std::tuple<AreaIntegralType<Types> ...>>
288 tupleOp(fPsis, OpScaled<vector>(fArea))
294 Tuple2<vector, std::tuple<AreaIntegralType<Types> ...>>
297 std::make_tuple(pTraits<AreaIntegralType<Types>>::zero ...)
305 FaceCutValues<vector>(
f, fCuts, ps, pAlphas, isoAlpha, below),
306 OpIndirectAverage(
f)(ps),
307 tupleOp(pPsis, OpFaceCutValues(
f, fCuts, pAlphas, isoAlpha, below)),
308 tupleOp(pPsis, OpIndirectAverage(
f))
313 template<
class ... Types>
318 const cellEdgeAddressing& cAddr,
320 const std::tuple<Types ...>& cPsiAvgs,
323 const std::tuple<
const Field<Types>& ...>& fPsis
327 std::tuple<Types ...> cVolumePsis(pTraits<Types>::zero ...);
331 const scalar pyrVolume =
332 (cAddr.cOwns()[cfi] ? +1 : -1)
333 *(fAreas[
c[cfi]] & (fCentres[
c[cfi]] - cPAvg))/3;
335 cVolume += pyrVolume;
345 OpScaled<scalar>(scalar(3)/scalar(4)*pyrVolume)
350 OpScaled<scalar>(scalar(1)/scalar(4)*pyrVolume)
358 return Tuple2<scalar, std::tuple<Types ...>>(cVolume, cVolumePsis);
362 template<
class ... Types>
367 const cellEdgeAddressing& cAddr,
368 const scalar cVolume,
369 const std::tuple<Types ...>& cPsis,
374 const std::tuple<
const Field<Types>& ...>& fPsis,
376 const std::tuple<
const Field<Types>& ...>& fCutPsis,
378 const std::tuple<
const Field<Types>& ...>& pPsis,
380 const scalar isoAlpha,
386 if (cCuts.size() == 0)
388 if ((pAlphas[fs[
c[0]][0]] < isoAlpha) == below)
391 Tuple2<scalar, std::tuple<Types ...>>
394 tupleOp(cPsis, OpScaled<scalar>(cVolume))
400 Tuple2<scalar, std::tuple<Types ...>>
403 std::make_tuple(pTraits<Types>::zero ...)
409 const point cPAvg = OpIndirectAverage(
c)(fCentres);
410 auto cPsiAvgs =
tupleOp(fPsis, OpIndirectAverage(
c));
432 scalar& cCutsVolume = result.first();
433 std::tuple<Types ...>& cCutsVolumePsis = result.second();
436 const cutPoly::CellCutValues<point> cCutPValues
446 const point cCutPAvg = OpIterableAverage()(cCutPValues);
461 auto cCutPsiAvgs =
tupleOp(cCutPsiValues, OpIterableAverage());
467 const auto cCutAreaPPsis =
472 std::tuple_cat(std::make_tuple(cCutPValues), cCutPsiValues),
473 std::tuple_cat(std::make_tuple(cCutPAvg), cCutPsiAvgs)
475 const vector& cCutArea = cCutAreaPPsis.first();
476 const vector& cCutCentre = std::get<0>(cCutAreaPPsis.second());
477 const auto cCutPsis =
tupleTail(cCutAreaPPsis.second());
496 const scalar pyrVolume =
497 (below ? +1 : -1)*(cCutArea & (cCutCentre - cPAvg))/3;
499 cCutsVolume += pyrVolume;
509 OpScaled<scalar>(scalar(3)/scalar(4)*pyrVolume)
514 OpScaled<scalar>(scalar(1)/scalar(4)*pyrVolume)
#define forAll(list, i)
Loop across all elements in list.
A 2-tuple for storing two objects of different types.
A zero-sized class without any storage. Used, for example, in HashSet.
volScalarField scalarField(fieldObject, mesh)
volVectorField vectorField(fieldObject, mesh)
const dimensionedScalar c
Speed of light in a vacuum.
Tuple2< vector, std::tuple< AreaIntegralType< Types > ... > > faceAreaIntegral(const FaceValues< point > &fPs, const point &fPAvg, const std::tuple< FaceValues< Types > ... > &fPsis, const std::tuple< Types ... > &fPsiAvgs)
Compute the face-area and face-area-integrals of the given properties.
Tuple2< vector, std::tuple< AreaIntegralType< Types > ... > > faceCutAreaIntegral(const face &f, const vector &fArea, const std::tuple< Types ... > &fPsis, const List< labelPair > &fCuts, const pointField &ps, const std::tuple< const Field< Types > &... > &pPsis, const scalarField &pAlphas, const scalar isoAlpha, const bool below)
Compute the face-cut-area and face-cut-area-integral of the given properties.
auto tupleOp(const std::tuple< Types ... > &tuple, const Op &op)
Tuple2< scalar, std::tuple< Types ... > > cellCutVolumeIntegral(const cell &c, const cellEdgeAddressing &cAddr, const scalar cVolume, const std::tuple< Types ... > &cPsis, const labelListList &cCuts, const faceUList &fs, const vectorField &fAreas, const pointField &fCentres, const std::tuple< const Field< Types > &... > &fPsis, const vectorField &fCutAreas, const std::tuple< const Field< Types > &... > &fCutPsis, const pointField &ps, const std::tuple< const Field< Types > &... > &pPsis, const scalarField &pAlphas, const scalar isoAlpha, const bool below)
Compute the cell-cut-volume and cell-cut-volume-integral.
Tuple2< scalar, std::tuple< Types ... > > cellVolumeIntegral(const cell &c, const cellEdgeAddressing &cAddr, const point &cPAvg, const std::tuple< Types ... > &cPsiAvgs, const vectorField &fAreas, const pointField &fCentres, const std::tuple< const Field< Types > &... > &fPsis)
Compute the cell-volume and cell-volume-integrals of the given properties.
Tuple2< vector, std::tuple< Types ... > > faceAreaAverage(const FaceValues< point > &fPs, const point &fPAvg, const std::tuple< FaceValues< Types > ... > &fPsis, const std::tuple< Types ... > &fPsiAvgs)
Compute the face-area and face-area-averages of the given properties.
auto tupleBinaryOp(const Tuple &tupleA, const Tuple &tupleB, const std::integer_sequence< Int, Is ... > &, const BinaryOp &bop)
void tupleInPlaceOp(Tuple &tuple, const std::integer_sequence< Int, Is ... > &, const Op &op)
auto tupleTail(const std::tuple< Types ... > &tuple)
void tupleInPlaceOp(std::tuple< Types ... > &tuple, const Op &op)
auto tupleBinaryOp(const std::tuple< TypesA ... > &tupleA, const std::tuple< TypesB ... > &tupleB, const BinaryOp &bop)
auto tupleSubset(const Tuple &tuple, const std::integer_sequence< Int, Is ... > &)
vectorField pointField
pointField is a vectorField.
vector point
Point is a vector.
Vector< scalar > vector
A scalar version of the templated Vector.
List< labelList > labelListList
A List of labelList.
void magSqr(LagrangianPatchField< scalar > &f, const LagrangianPatchField< Type > &f1)
fileType type(const fileName &, const bool checkVariants=true, const bool followLink=true)
Return the file type: directory or file.
std::integer_sequence< Int, Is+Offset ... > type
typename OffsetSequence< Int, Min, std::make_index_sequence< Max - Min > >::type type