38#ifndef Foam_GeometricFieldExpression_H
39#define Foam_GeometricFieldExpression_H
68 typename UncoupledPatchExpr,
69 typename CoupledPatchExpr,
108 return static_cast<E const&
>(*this)[i];
110 auto size() const
noexcept {
return static_cast<const E&
>(*this).size(); }
124 return static_cast<const E&
>(*this).internalField();
129 return static_cast<E&
>(*this).internalField();
134 return static_cast<E&
>(*this).patchField(i);
137 UncoupledPatchExpr
patchField(
const label i)
const
139 return static_cast<const E&
>(*this).patchField(i);
144 return static_cast<E&
>(*this).coupledPatchField(i);
149 return static_cast<const E&
>(*this).coupledPatchField(i);
153 auto access(
const Op& cop,
const label i)
const
155 return static_cast<const E&
>(*this).access(cop, i);
159 template<
class GeoField>
165 assert(
fld.size() == this->size());
166 using ActualType =
typename IntExpr::value_type;
171 auto& bfld =
fld.boundaryFieldRef();
172 const label
n = bfld.size();
174 constexpr bool foam_offload =
true;
176 constexpr bool foam_offload =
false;
178 if constexpr (foam_offload)
183 constexpr bool is_pointField =
184 std::is_same_v<pointMesh, typename GeoField::Mesh>;
186 auto do_something = [](
auto& data, label& i,
auto& pfld)
188 if constexpr (is_pointField)
192 data[i++] =
const_cast<FieldType*
>(vp);
197 data[i++] = &
static_cast<FieldType&
>(pfld);
204 fld.boundaryFieldRef(),
208 std::vector<UncoupledPatchExpr> unc_patchExpr;
209 std::vector<CoupledPatchExpr> cou_patchExpr;
210 std::vector<int> coupledID;
211 std::vector<int> uncoupledID;
214 unc_patchExpr.reserve(
n);
215 uncoupledID.reserve(
n);
217 for (label i = 0; i <
n; ++i)
219 auto& pfld = bfld[i];
220 if (force || pfld.assignable())
226 cou_patchExpr.emplace_back(patchExpr);
227 coupledID.emplace_back(i);
232 unc_patchExpr.emplace_back(patchExpr);
233 uncoupledID.emplace_back(i);
255 for (label i = 0; i <
n; ++i)
257 auto& pfld = bfld[i];
258 if (force || pfld.assignable())
267 std::is_same_v<pointMesh, typename GeoField::Mesh>
273 patchExpr.evaluate(
const_cast<FieldType&
>(*vp));
278 patchExpr.evaluate(pfld);
287 std::is_same_v<pointMesh, typename GeoField::Mesh>
293 patchExpr.evaluate(
const_cast<FieldType&
>(*vp));
298 patchExpr.evaluate(pfld);
304 fld.correctLocalBoundaryConditions();
315template<
class GeoField>
316class GeometricFieldRefWrap
320 GeometricFieldRefWrap<GeoField>,
321 ListRefWrap<typename GeoField::value_type>,
322 ListRefWrap<typename GeoField::value_type>,
323 ListTmpWrap<Field<typename GeoField::value_type>>,
324 typename GeoField::value_type
329 static constexpr bool is_leaf =
false;
335 typedef typename GeoField::value_type
value_type;
395 typename E::UncoupledPatchExpr,
396 typename E::CoupledPatchExpr,
397 typename E::value_type
415 expr.evaluate(elems_);
426 typename E::UncoupledPatchExpr,
427 typename E::CoupledPatchExpr,
428 typename E::value_type
432 expr.evaluate(elems_);
444 typename E::UncoupledPatchExpr,
445 typename E::CoupledPatchExpr,
446 typename E::value_type
450 return expr.evaluate(elems_);
465 return elems_.size();
470 auto&
fld = elems_.internalFieldRef();
476 auto&
fld = elems_.internalField();
482 auto&
fld = elems_.boundaryFieldRef()[i];
485 std::is_same_v<pointMesh, typename GeoField::Mesh>
511 const auto&
fld = elems_.boundaryField()[i];
514 std::is_same_v<pointMesh, typename GeoField::Mesh>
535 auto&
fld = elems_.boundaryFieldRef()[i];
538 std::is_same_v<pointMesh, typename GeoField::Mesh>
548 const_cast<Field<value_type>&
>(v)
564 const auto&
fld = elems_.boundaryField()[i];
567 std::is_same_v<pointMesh, typename GeoField::Mesh>
589 template<
class AccessOp>
590 auto access(
const AccessOp& cop,
const label i)
const
592 return cop(elems_, i);
602template<
class GeoField>
607 GeometricFieldConstRefWrap<GeoField>,
608 ListConstRefWrap<typename GeoField::value_type>,
609 ListConstRefWrap<typename GeoField::value_type>,
610 ListConstTmpWrap<Field<typename GeoField::value_type>>,
611 typename GeoField::value_type
616 static constexpr bool is_leaf =
false;
622 typedef typename GeoField::value_type
value_type;
656 const auto&
data()
const
668 return elems_.size();
673 return elems_.internalField();
679 const auto&
fld = elems_.boundaryField()[i];
682 std::is_same_v<pointMesh, typename GeoField::Mesh>
703 const auto&
fld = elems_.boundaryField()[i];
706 std::is_same_v<pointMesh, typename GeoField::Mesh>
725 template<
class AccessOp>
726 auto access(
const AccessOp& cop,
const label i)
const
728 return cop(elems_, i);
738template<
class GeoField>
739class GeometricFieldConstTmpWrap
741 public GeometricFieldExpression
743 GeometricFieldConstTmpWrap<GeoField>,
744 ListConstRefWrap<typename GeoField::value_type>,
745 ListConstRefWrap<typename GeoField::value_type>,
746 ListConstTmpWrap<Field<typename GeoField::value_type>>,
747 typename GeoField::value_type
753 static constexpr bool is_leaf =
false;
759 typedef typename GeoField::value_type
value_type;
838 const auto&
data()
const
851 return elems_().size();
856 return elems_().internalField();
861 const auto&
fld = elems_().boundaryField()[i];
864 std::is_same_v<pointMesh, typename GeoField::Mesh>
886 const auto&
fld = elems_().boundaryField()[i];
889 std::is_same_v<pointMesh, typename GeoField::Mesh>
908 template<
class AccessOp>
909 auto access(
const AccessOp& cop,
const label i)
const
911 return cop(elems_(), i);
922template<
typename E1,
typename E2>
930 typename E1::IntExpr,
935 typename E1::UncoupledPatchExpr,
936 typename E2::UncoupledPatchExpr
940 typename E1::CoupledPatchExpr,
941 typename E2::CoupledPatchExpr
943 typename E1::value_type
947 typename std::conditional<E1::is_leaf, const E1&, const E1>::type u_;
948 typename std::conditional<E2::is_leaf, const E2&, const E2>::type v_;
951 static constexpr bool is_leaf =
false;
959 typename E1::IntExpr,
964 typename E1::UncoupledPatchExpr,
965 typename E2::UncoupledPatchExpr
969 typename E1::CoupledPatchExpr,
970 typename E2::CoupledPatchExpr
973 GF_add(
const E1& u,
const E2& v)
990 assert(u.size() == -1 || v.size() == -1 || u.size() == v.size());
995 typename E1::value_type,
996 typename E2::value_type
1002 return u_[i] + v_[i];
1008 return IntExpr(u_.internalField(), v_.internalField());
1020 u_.coupledPatchField(i),
1021 v_.coupledPatchField(i)
1025 template<
class AccessOp>
1026 auto access(
const AccessOp& cop,
const label i)
const
1031template<
typename E1,
typename E2>
1037 typename E1::IntExpr,
1038 typename E1::UncoupledPatchExpr,
1039 typename E1::CoupledPatchExpr,
1040 typename E1::value_type
1045 typename E2::IntExpr,
1046 typename E2::UncoupledPatchExpr,
1047 typename E2::CoupledPatchExpr,
1048 typename E2::value_type
1054 static_cast<const E1&
>(u),
1055 static_cast<const E2&
>(v)
1058template<
typename E1,
class Type,
template<
class>
class PatchField,
class GeoMesh>
1064 typename E1::IntExpr,
1065 typename E1::UncoupledPatchExpr,
1066 typename E1::CoupledPatchExpr,
1067 typename E1::value_type
1077 return GF_add(
static_cast<const E1&
>(u), E2(v));
1079template<
typename E1,
class Type,
template<
class>
class PatchField,
class GeoMesh>
1083 GeometricFieldExpression
1086 typename E1::IntExpr,
1087 typename E1::UncoupledPatchExpr,
1088 typename E1::CoupledPatchExpr,
1089 typename E1::value_type
1097 return GF_add(E2(u),
static_cast<const E1&
>(v));
1100<
class Type1,
class Type2,
template<
class>
class PatchField,
class GeoMesh>
1115 return GF_add(E1(u), E2(v));
1117template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1127 return GF_add(E1(u), E2(u, v));
1129template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1143#undef EXPRESSION_GF_FUNCTION1_DIMLESS
1144#define EXPRESSION_GF_FUNCTION1_DIMLESS(Func, BaseFunc, WrapType, OpFunc) \
1145template<typename E1> \
1148 public GeometricFieldExpression \
1151 WrapType<typename E1::IntExpr>, \
1152 WrapType<typename E1::UncoupledPatchExpr>, \
1153 WrapType<typename E1::CoupledPatchExpr>, \
1154 typename E1::value_type \
1158 typename std::conditional<E1::is_leaf, const E1&, const E1>::type u_; \
1161 static constexpr bool is_leaf = false; \
1164 typedef typename E1::value_type value_type; \
1167 typedef WrapType<typename E1::IntExpr> IntExpr; \
1168 typedef WrapType<typename E1::UncoupledPatchExpr> UncoupledPatchExpr; \
1169 typedef WrapType<typename E1::CoupledPatchExpr> CoupledPatchExpr; \
1171 OpFunc(const E1& u) \
1173 GeometricFieldExpression \
1177 UncoupledPatchExpr, \
1187 auto operator[](const label i) const \
1189 return BaseFunc(u_[i]); \
1191 auto size() const noexcept { return u_.size(); } \
1193 IntExpr internalField() const \
1195 return IntExpr(u_.internalField()); \
1198 UncoupledPatchExpr patchField(const label i) const \
1200 return UncoupledPatchExpr(u_.patchField(i)); \
1203 CoupledPatchExpr coupledPatchField(const label i) const \
1205 return CoupledPatchExpr(u_.coupledPatchField(i)); \
1208 template<class AccessOpOp> \
1209 auto access(const AccessOpOp& cop, const label i) const \
1211 return UncoupledPatchExpr(u_.access(cop, i)); \
1214template<typename E1> \
1217 GeometricFieldExpression \
1220 typename E1::IntExpr, \
1221 typename E1::UncoupledPatchExpr, \
1222 typename E1::CoupledPatchExpr, \
1223 typename E1::value_type \
1227 return OpFunc<E1>(static_cast<const E1&>(u)); \
1229template<class Type, template<class> class PatchField, class GeoMesh> \
1230auto Func(GeometricField<Type, PatchField, GeoMesh> const& fld) \
1232 typedef typename Expression::GeometricFieldConstRefWrap \
1233 <GeometricField<Type, PatchField, GeoMesh>> E1; \
1234 return Func(E1(fld)); \
1237#undef EXPRESSION_GF_FUNCTION1
1238#define EXPRESSION_GF_FUNCTION1(Func, BaseFunc, WrapType, OpFunc) \
1239template<typename E1> \
1242 public GeometricFieldExpression \
1245 WrapType<typename E1::IntExpr>, \
1246 WrapType<typename E1::UncoupledPatchExpr>, \
1247 WrapType<typename E1::CoupledPatchExpr>, \
1248 typename E1::value_type \
1252 typename std::conditional<E1::is_leaf, const E1&, const E1>::type u_; \
1255 static constexpr bool is_leaf = false; \
1258 typedef typename E1::value_type value_type; \
1261 typedef WrapType<typename E1::IntExpr> IntExpr; \
1262 typedef WrapType<typename E1::UncoupledPatchExpr> UncoupledPatchExpr; \
1263 typedef WrapType<typename E1::CoupledPatchExpr> CoupledPatchExpr; \
1265 OpFunc(const E1& u) \
1267 GeometricFieldExpression \
1271 UncoupledPatchExpr, \
1276 BaseFunc(u.dimensions()), \
1277 BaseFunc(u.oriented()) \
1281 auto operator[](const label i) const \
1283 return BaseFunc(u_[i]); \
1285 auto size() const noexcept { return u_.size(); } \
1287 IntExpr internalField() const \
1289 return IntExpr(u_.internalField()); \
1292 UncoupledPatchExpr patchField(const label i) const \
1294 return UncoupledPatchExpr(u_.patchField(i)); \
1297 CoupledPatchExpr coupledPatchField(const label i) const \
1299 return CoupledPatchExpr(u_.coupledPatchField(i)); \
1302 template<class AccessOpOp> \
1303 auto access(const AccessOpOp& cop, const label i) const \
1305 return UncoupledPatchExpr(u_.access(cop, i)); \
1308template<typename E1> \
1311 GeometricFieldExpression \
1314 typename E1::IntExpr, \
1315 typename E1::UncoupledPatchExpr, \
1316 typename E1::CoupledPatchExpr, \
1317 typename E1::value_type \
1321 return OpFunc<E1>(static_cast<const E1&>(u)); \
1323template<class Type, template<class> class PatchField, class GeoMesh> \
1324auto Func(GeometricField<Type, PatchField, GeoMesh> const& fld) \
1326 typedef typename Expression::GeometricFieldConstRefWrap \
1327 <GeometricField<Type, PatchField, GeoMesh>> E1; \
1328 return Func(E1(fld)); \
1407#undef EXPRESSION_GF_OPERATOR
1408#define EXPRESSION_GF_OPERATOR(Op, WrapType, OpFunc) \
1409template<typename E1, typename E2> \
1412 public GeometricFieldExpression \
1417 typename E1::IntExpr, \
1418 typename E2::IntExpr \
1422 typename E1::UncoupledPatchExpr, \
1423 typename E2::UncoupledPatchExpr \
1427 typename E1::CoupledPatchExpr, \
1428 typename E2::CoupledPatchExpr \
1430 typename E1::value_type \
1434 typename std::conditional<E1::is_leaf, const E1&, const E1>::type u_; \
1435 typename std::conditional<E2::is_leaf, const E2&, const E2>::type v_; \
1438 static constexpr bool is_leaf = false; \
1441 typedef typename E1::value_type value_type; \
1446 typename E1::IntExpr, \
1447 typename E2::IntExpr \
1451 typename E1::UncoupledPatchExpr, \
1452 typename E2::UncoupledPatchExpr \
1453 > UncoupledPatchExpr; \
1456 typename E1::CoupledPatchExpr, \
1457 typename E2::CoupledPatchExpr \
1458 > CoupledPatchExpr; \
1460 OpFunc(const E1& u, const E2& v) \
1462 GeometricFieldExpression \
1466 UncoupledPatchExpr, \
1468 typename E1::value_type \
1471 u.dimensions() Op v.dimensions(), \
1472 u.oriented() Op v.oriented() \
1485 assert(u.size() == -1 || v.size() == -1 || u.size() == v.size()); \
1487 auto operator[](const label i) const \
1489 return u_[i] Op v_[i]; \
1491 auto size() const noexcept { return Foam::max(u_.size(), v_.size()); } \
1493 IntExpr internalField() const \
1495 return IntExpr(u_.internalField(), v_.internalField()); \
1498 UncoupledPatchExpr patchField(const label i) const \
1500 return UncoupledPatchExpr(u_.patchField(i), v_.patchField(i)); \
1503 CoupledPatchExpr coupledPatchField(const label i) const \
1505 return CoupledPatchExpr \
1507 u_.coupledPatchField(i), \
1508 v_.coupledPatchField(i) \
1512 template<class AccessOp> \
1513 auto access(const AccessOp& cop, const label i) const \
1515 return UncoupledPatchExpr \
1517 u_.access(cop, i), \
1522template<typename E1, typename E2> \
1525 GeometricFieldExpression \
1528 typename E1::IntExpr, \
1529 typename E1::UncoupledPatchExpr, \
1530 typename E1::CoupledPatchExpr, \
1531 typename E1::value_type \
1533 GeometricFieldExpression \
1536 typename E2::IntExpr, \
1537 typename E2::UncoupledPatchExpr, \
1538 typename E2::CoupledPatchExpr, \
1539 typename E2::value_type \
1543 return OpFunc<E1, E2> \
1545 static_cast<const E1&>(u), \
1546 static_cast<const E2&>(v) \
1552 class Type, template<class> class PatchField, class GeoMesh \
1556 GeometricFieldExpression \
1559 typename E1::IntExpr, \
1560 typename E1::UncoupledPatchExpr, \
1561 typename E1::CoupledPatchExpr, \
1562 typename E1::value_type \
1564 GeometricField<Type, PatchField, GeoMesh> const& fld \
1567 typedef typename Expression::GeometricFieldConstRefWrap \
1568 <GeometricField<Type, PatchField, GeoMesh>> E2; \
1569 return operator Op(u, E2(fld)); \
1573 class Type, template<class> class PatchField, class GeoMesh, \
1578 GeometricField<Type, PatchField, GeoMesh> const& fld, \
1579 GeometricFieldExpression \
1582 typename E1::IntExpr, \
1583 typename E1::UncoupledPatchExpr, \
1584 typename E1::CoupledPatchExpr, \
1585 typename E1::value_type \
1589 typedef typename Expression::GeometricFieldConstRefWrap \
1590 <GeometricField<Type, PatchField, GeoMesh>> E2; \
1591 return operator Op(E2(fld), u); \
1594<class Type1, class Type2, template<class> class PatchField, class GeoMesh> \
1597 GeometricField<Type1, PatchField, GeoMesh> const& u, \
1598 GeometricField<Type2, PatchField, GeoMesh> const& v \
1601 typedef typename Expression::GeometricFieldConstRefWrap \
1602 <GeometricField<Type1, PatchField, GeoMesh>> E1; \
1603 typedef typename Expression::GeometricFieldConstRefWrap \
1604 <GeometricField<Type2, PatchField, GeoMesh>> E2; \
1605 return operator Op(E1(u), E2(v)); \
1608template<typename E1, class Type> \
1611 GeometricFieldExpression \
1614 typename E1::IntExpr, \
1615 typename E1::UncoupledPatchExpr, \
1616 typename E1::CoupledPatchExpr, \
1617 typename E1::value_type \
1619 dimensioned<Type> const& v \
1622 typedef typename Foam::Expression::UniformGeometricFieldWrap2<Type> E2; \
1623 return operator Op(u, E2(v)); \
1625template<typename E1, class Type> \
1628 dimensioned<Type> const& u, \
1629 GeometricFieldExpression \
1632 typename E1::IntExpr, \
1633 typename E1::UncoupledPatchExpr, \
1634 typename E1::CoupledPatchExpr, \
1635 typename E1::value_type \
1639 typedef typename Foam::Expression::UniformGeometricFieldWrap2<Type> E2; \
1640 return operator Op(E2(u), v); \
1645 class Type1, class Type2, template<class> class PatchField, class GeoMesh, \
1646 class = std::enable_if_t \
1648 (std::is_arithmetic_v<Type2> || Foam::is_vectorspace_v<Type2>) \
1653 GeometricField<Type1, PatchField, GeoMesh> const& u, \
1657 typedef typename Foam::GeometricField<Type1, PatchField, GeoMesh> GeoField;\
1658 typedef typename Expression::UniformGeometricFieldWrap<GeoField, Type2> E2;\
1659 return operator Op(u, E2(u, v)); \
1663 class Type1, class Type2, template<class> class PatchField, class GeoMesh, \
1664 class = std::enable_if_t \
1666 (std::is_arithmetic_v<Type2> || Foam::is_vectorspace_v<Type2>) \
1672 GeometricField<Type1, PatchField, GeoMesh> const& v \
1675 typedef typename Foam::GeometricField<Type1, PatchField, GeoMesh> GeoField;\
1676 typedef typename Expression::UniformGeometricFieldWrap<GeoField, Type2> E2;\
1677 return operator Op(E2(v, u), v); \
1682 class Type1, class Type2, template<class> class PatchField, class GeoMesh \
1686 GeometricField<Type1, PatchField, GeoMesh> const& u, \
1687 dimensioned<Type2> const& v \
1690 typedef typename Foam::Expression::UniformGeometricFieldWrap \
1691 <GeometricField<Type1, PatchField, GeoMesh>, Type2> E2; \
1692 return operator Op(u, E2(u, v)); \
1696 class Type1, class Type2, template<class> class PatchField, class GeoMesh \
1700 dimensioned<Type2> const& u, \
1701 GeometricField<Type1, PatchField, GeoMesh> const& v \
1704 typedef typename Foam::Expression::UniformGeometricFieldWrap \
1705 <GeometricField<Type1, PatchField, GeoMesh>, Type2> E2; \
1706 return operator Op(E2(v, u), v); \
1711 class E1, class Type2, \
1712 class = std::enable_if_t \
1714 (std::is_arithmetic_v<Type2> || Foam::is_vectorspace_v<Type2>) \
1719 GeometricFieldExpression \
1722 typename E1::IntExpr, \
1723 typename E1::UncoupledPatchExpr, \
1724 typename E1::CoupledPatchExpr, \
1725 typename E1::value_type \
1730 typedef typename Foam::Expression::UniformGeometricFieldWrap2<Type2> E2; \
1731 return operator Op(u, E2(v)); \
1735 class E1, class Type2, \
1736 class = std::enable_if_t \
1738 (std::is_arithmetic_v<Type2> || Foam::is_vectorspace_v<Type2>) \
1744 GeometricFieldExpression \
1747 typename E1::IntExpr, \
1748 typename E1::UncoupledPatchExpr, \
1749 typename E1::CoupledPatchExpr, \
1750 typename E1::value_type \
1754 typedef typename Foam::Expression::UniformGeometricFieldWrap2<Type2> E2; \
1755 return operator Op(E2(u), v); \
1759#undef EXPRESSION_GF_FUNCTION2
1760#define EXPRESSION_GF_FUNCTION2(Func, BaseFunc, WrapType, OpFunc) \
1761template<typename E1, typename E2> \
1764 public GeometricFieldExpression \
1769 typename E1::IntExpr, \
1770 typename E2::IntExpr \
1774 typename E1::UncoupledPatchExpr, \
1775 typename E2::UncoupledPatchExpr \
1779 typename E1::CoupledPatchExpr, \
1780 typename E2::CoupledPatchExpr \
1782 typename E1::value_type \
1786 typename std::conditional<E1::is_leaf, const E1&, const E1>::type u_; \
1787 typename std::conditional<E2::is_leaf, const E2&, const E2>::type v_; \
1790 static constexpr bool is_leaf = false; \
1793 typedef typename E1::value_type value_type; \
1798 typename E1::IntExpr, \
1799 typename E2::IntExpr \
1803 typename E1::UncoupledPatchExpr, \
1804 typename E2::UncoupledPatchExpr \
1805 > UncoupledPatchExpr; \
1808 typename E1::CoupledPatchExpr, \
1809 typename E2::CoupledPatchExpr \
1810 > CoupledPatchExpr; \
1812 OpFunc(const E1& u, const E2& v) \
1814 GeometricFieldExpression \
1818 UncoupledPatchExpr, \
1823 BaseFunc(u.dimensions(), v.dimensions()), \
1824 BaseFunc(u.oriented(), v.oriented()) \
1838 auto operator[](const label i) const \
1840 return BaseFunc(u_[i], v_[i]); \
1842 auto size() const noexcept {return Foam::max(u_.size(), v_.size()); } \
1844 IntExpr internalField() const \
1846 return IntExpr(u_.internalField(), v_.internalField()); \
1849 UncoupledPatchExpr patchField(const label i) const \
1851 return UncoupledPatchExpr(u_.patchField(i), v_.patchField(i)); \
1854 CoupledPatchExpr coupledPatchField(const label i) const \
1856 return CoupledPatchExpr \
1858 u_.coupledPatchField(i), \
1859 v_.coupledPatchField(i) \
1863 template<class AccessOp> \
1864 auto access(const AccessOp& cop, const label i) const \
1866 return UncoupledPatchExpr \
1868 u_.access(cop, i), \
1873template<typename E1, typename E2> \
1876 GeometricFieldExpression \
1879 typename E1::IntExpr, \
1880 typename E1::UncoupledPatchExpr, \
1881 typename E1::CoupledPatchExpr, \
1882 typename E1::value_type \
1884 GeometricFieldExpression \
1887 typename E2::IntExpr, \
1888 typename E2::UncoupledPatchExpr, \
1889 typename E2::CoupledPatchExpr, \
1890 typename E2::value_type \
1894 return OpFunc<E1, E2> \
1896 static_cast<const E1&>(u), \
1897 static_cast<const E2&>(v) \
1903 class Type, template<class> class PatchField, class GeoMesh \
1907 GeometricFieldExpression \
1910 typename E1::IntExpr, \
1911 typename E1::UncoupledPatchExpr, \
1912 typename E1::CoupledPatchExpr, \
1913 typename E1::value_type \
1915 GeometricField<Type, PatchField, GeoMesh> const& fld \
1918 typedef typename Expression::GeometricFieldConstRefWrap \
1919 <GeometricField<Type, PatchField, GeoMesh>> E2; \
1920 return Func(u, E2(fld)); \
1924 class Type, template<class> class PatchField, class GeoMesh, \
1929 GeometricField<Type, PatchField, GeoMesh> const& fld, \
1930 GeometricFieldExpression \
1933 typename E1::IntExpr, \
1934 typename E1::UncoupledPatchExpr, \
1935 typename E1::CoupledPatchExpr, \
1936 typename E1::value_type \
1940 typedef typename Expression::GeometricFieldConstRefWrap \
1941 <GeometricField<Type, PatchField, GeoMesh>> E2; \
1942 return Func(E2(fld), u); \
1946 class Type, template<class> class PatchField, class GeoMesh \
1950 GeometricField<Type, PatchField, GeoMesh> const& u, \
1951 GeometricField<Type, PatchField, GeoMesh> const& v \
1954 typedef typename Expression::GeometricFieldConstRefWrap \
1955 <GeometricField<Type, PatchField, GeoMesh>> E2; \
1956 return Func(E2(u), E2(v)); \
1961 class Type1, class Type2, template<class> class PatchField, class GeoMesh \
1965 GeometricField<Type1, PatchField, GeoMesh> const& u, \
1966 dimensioned<Type2> const& v \
1969 typedef typename Foam::Expression::UniformGeometricFieldWrap \
1970 <GeometricField<Type1, PatchField, GeoMesh>, Type2> E2; \
1971 return Func(u, E2(u,v)); \
1975 class Type1, class Type2, template<class> class PatchField, class GeoMesh \
1979 dimensioned<Type2> const& u, \
1980 GeometricField<Type1, PatchField, GeoMesh> const& v \
1983 typedef typename Foam::Expression::UniformGeometricFieldWrap \
1984 <GeometricField<Type1, PatchField, GeoMesh>, Type2> E2; \
1985 return Func(E2(v, u), v); \
1987template<typename E1, class Type> \
1990 GeometricFieldExpression \
1993 typename E1::IntExpr, \
1994 typename E1::UncoupledPatchExpr, \
1995 typename E1::CoupledPatchExpr, \
1996 typename E1::value_type \
1998 dimensioned<Type> const& v \
2001 typedef typename Foam::Expression::UniformGeometricFieldWrap2<Type> E2; \
2002 return Func(u, E2(v)); \
2004template<typename E1, class Type> \
2007 dimensioned<Type> const& u, \
2008 GeometricFieldExpression \
2011 typename E1::IntExpr, \
2012 typename E1::UncoupledPatchExpr, \
2013 typename E1::CoupledPatchExpr, \
2014 typename E1::value_type \
2018 typedef typename Foam::Expression::UniformGeometricFieldWrap2<Type> E2; \
2019 return Func(E2(u), v); \
2037#undef EXPRESSION_GF_FUNCTION1_DIMLESS
2049#undef EXPRESSION_GF_FUNCTION1
2054#undef EXPRESSION_GF_FUNCTION2
2061#undef EXPRESSION_GF_OPERATOR
2068template<
class GeoField,
class Type =
typename GeoField::value_type>
2073 UniformGeometricFieldWrap<GeoField, Type>,
2074 UniformListWrap<Type>,
2075 UniformListWrap<Type>,
2076 UniformListWrap<Type>,
2095 const GeoField& elems_;
2123 const GeoField& elems,
2150 return elems_.size();
2155 return IntExpr(elems_.internalField().size(), val_);
2168 template<
class AccessOp>
2169 auto access(
const AccessOp& cop,
const label i)
const
2182 UniformGeometricFieldWrap2<T>,
2191 static constexpr bool is_leaf =
false;
2275 template<
class AccessOp>
2276 auto access(
const AccessOp& cop,
const label i)
const
#define EXPRESSION_GF_OPERATOR(Op, WrapType, OpFunc)
#define EXPRESSION_GF_FUNCTION2(Func, BaseFunc, WrapType, OpFunc)
#define EXPRESSION_GF_FUNCTION1(Func, BaseFunc, WrapType, OpFunc)
#define EXPRESSION_GF_FUNCTION1_DIMLESS(Func, BaseFunc, WrapType, OpFunc)
Expression templates for List.
Info<< nl;Info<< "Write faMesh in vtk format:"<< nl;{ vtk::uindirectPatchWriter writer(aMesh.patch(), fileName(aMesh.time().globalPath()/vtkBaseFileName));writer.writeGeometry();globalIndex procAddr(aMesh.nFaces());labelList cellIDs;if(UPstream::master()) { cellIDs.resize(procAddr.totalSize());for(const labelRange &range :procAddr.ranges()) { auto slice=cellIDs.slice(range);slice=identity(range);} } writer.beginCellData(4);writer.writeProcIDs();writer.write("cellID", cellIDs);writer.write("area", aMesh.S().field());writer.write("normal", aMesh.faceAreaNormals());writer.beginPointData(1);writer.write("normal", aMesh.pointAreaNormals());Info<< " "<< writer.output().name()<< nl;}{ vtk::lineWriter writer(aMesh.points(), aMesh.edges(), fileName(aMesh.time().globalPath()/(vtkBaseFileName+"-edges")));writer.writeGeometry();writer.beginCellData(4);writer.writeProcIDs();{ Field< scalar > fld(faMeshTools::flattenEdgeField(aMesh.magLe(), true))
auto operator[](const label i) const
List_add< typename E1::UncoupledPatchExpr, typename E2::UncoupledPatchExpr > UncoupledPatchExpr
auto access(const AccessOp &cop, const label i) const
List_add< typename E1::CoupledPatchExpr, typename E2::CoupledPatchExpr > CoupledPatchExpr
static constexpr bool is_leaf
auto size() const noexcept
IntExpr internalField() const
E1::value_type value_type
UncoupledPatchExpr patchField(const label i) const
GF_add(const E1 &u, const E2 &v)
CoupledPatchExpr coupledPatchField(const label i) const
List_add< typename E1::IntExpr, typename E2::IntExpr > IntExpr
List_dot< typename E1::CoupledPatchExpr, typename E2::CoupledPatchExpr > CoupledPatchExpr
List_dot< typename E1::IntExpr, typename E2::IntExpr > IntExpr
E1::value_type value_type
List_dot< typename E1::UncoupledPatchExpr, typename E2::UncoupledPatchExpr > UncoupledPatchExpr
GeometricField expressions.
static constexpr bool is_leaf
Expression wrap of const reference to GeometricField.
const auto & data() const
auto access(const AccessOp &cop, const label i) const
GeometricFieldConstRefWrap(const this_type &elems)
static constexpr bool is_leaf
auto size() const noexcept
IntExpr internalField() const
ListConstRefWrap< value_type > UncoupledPatchExpr
ListConstRefWrap< value_type > IntExpr
UncoupledPatchExpr patchField(const label i) const
ListConstTmpWrap< Field< value_type > > CoupledPatchExpr
value_type operator[](const label i) const
typename Matrix::faceFluxFieldType this_type
CoupledPatchExpr coupledPatchField(const label i) const
typename Matrix::faceFluxFieldType::value_type value_type
Expression wrap of const tmp to GeometricField.
GeometricFieldConstTmpWrap(const GeometricFieldConstTmpWrap< GeoField > &w)
const auto & data() const
auto access(const AccessOp &cop, const label i) const
static constexpr bool is_leaf
Have expressions use copy to maintain tmp refCount.
auto size() const noexcept
IntExpr internalField() const
ListConstRefWrap< value_type > UncoupledPatchExpr
ListConstRefWrap< value_type > IntExpr
Type to return for patchField.
UncoupledPatchExpr patchField(const label i) const
ListConstTmpWrap< Field< value_type > > CoupledPatchExpr
~GeometricFieldConstTmpWrap()
value_type operator[](const label i) const
GeoField this_type
The GeometricField type.
CoupledPatchExpr coupledPatchField(const label i) const
GeometricFieldConstTmpWrap(const tmp< this_type > &elems)
GeoField::value_type value_type
Type to return for internal field.
Expression of GeometricField.
const orientedType oriented_
auto access(const Op &cop, const label i) const
Type operator[](const label i) const
const dimensionSet dimensions_
static constexpr bool is_leaf
auto size() const noexcept
IntExpr internalField() const
GeometricFieldExpression(const dimensionSet &dimensions, const orientedType oriented)
GeoField & evaluate(GeoField &fld, const bool force=false) const
Helper to evaluate a GeometricField.
const dimensionSet & dimensions() const noexcept
UncoupledPatchExpr patchField(const label i) const
CoupledPatchExpr coupledPatchField(const label i)
const orientedType & oriented() const noexcept
CoupledPatchExpr coupledPatchField(const label i) const
UncoupledPatchExpr patchField(const label i)
Expression wrap of non-const reference to GeometricField.
ListRefWrap< value_type > IntExpr
ListTmpWrap< Field< value_type > > CoupledPatchExpr
auto access(const AccessOp &cop, const label i) const
GeometricFieldRefWrap(this_type &elems)
Copy construct.
static constexpr bool is_leaf
this_type & evaluate(const GeometricFieldExpression< E, typename E::IntExpr, typename E::UncoupledPatchExpr, typename E::CoupledPatchExpr, typename E::value_type > &expr)
Evaluate and return as GeoField. Rename to evaluate to make it clear it takes time?...
auto size() const noexcept
IntExpr internalField() const
UncoupledPatchExpr patchField(const label i) const
value_type & operator[](const label i)
value_type operator[](const label i) const
CoupledPatchExpr coupledPatchField(const label i)
typename Matrix::faceFluxFieldType this_type
CoupledPatchExpr coupledPatchField(const label i) const
typename Matrix::faceFluxFieldType::value_type value_type
GeometricFieldRefWrap(this_type &elems, const GeometricFieldExpression< E, typename E::IntExpr, typename E::UncoupledPatchExpr, typename E::CoupledPatchExpr, typename E::value_type > &expr)
GeometricFieldRefWrap(this_type &&elems)
Move construct.
UncoupledPatchExpr patchField(const label i)
ListRefWrap< value_type > UncoupledPatchExpr
Expression wrap of const reference to UList.
Expression wrap of const tmp to List.
Expression wrap of non-const reference to List.
Expression wrap of tmp to List.
Expression wrapping function for unary cos function.
Expression wrapping function for unary cosh function.
Expression wrapping function for unary magSqr function.
Expression wrapping function for unary mag function.
Expression wrapping function for binary max function.
Expression wrapping function for binary min function.
Expression wrapping function for unary pow2 function.
Expression wrapping function for unary pow3 function.
Expression wrapping function for unary pow4 function.
Expression wrapping function for unary sin function.
Expression wrapping function for unary sinh function.
Expression wrapping function for unary sqr function.
Expression wrapping function for unary sqrt function.
Expression wrapping function for unary symm function.
Expression wrapping function for unary tan function.
Expression wrapping function for unary tanh function.
Expression wrap of multiple lists.
void evaluate(ListsRefWrap< E > &exprWarp, const Container &ds)
Assignment.
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
Generic GeometricField class.
static const List< T > & null() noexcept
Return a null List (reference to a nullObject). Behaves like an empty List.
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
Generic dimensioned Type class.
A special matrix type and solver, designed for finite volume solutions of scalar equations....
Class to determine the 'oriented' status of surface fields.
constant condensation/saturation model.
A class for managing temporary objects.
gmvFile<< "tracers "<< particles.size()<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().x()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().y()<< " ";}gmvFile<< nl;for(const passiveParticle &p :particles){ gmvFile<< p.position().z()<< " ";}gmvFile<< nl;forAll(lagrangianScalarNames, i){ word name=lagrangianScalarNames[i];IOField< scalar > s(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
A namespace for expression templates.
auto tanh(GeometricFieldExpression< E1, typename E1::IntExpr, typename E1::UncoupledPatchExpr, typename E1::CoupledPatchExpr, typename E1::value_type > const &u)
auto cos(GeometricFieldExpression< E1, typename E1::IntExpr, typename E1::UncoupledPatchExpr, typename E1::CoupledPatchExpr, typename E1::value_type > const &u)
ListRefWrap< typename Expr::value_type > evaluator
Evaluator of an expression.
auto sin(GeometricFieldExpression< E1, typename E1::IntExpr, typename E1::UncoupledPatchExpr, typename E1::CoupledPatchExpr, typename E1::value_type > const &u)
g_pow2< E1 > pow2(const GenericExpression< E1 > &u)
auto cosh(GeometricFieldExpression< E1, typename E1::IntExpr, typename E1::UncoupledPatchExpr, typename E1::CoupledPatchExpr, typename E1::value_type > const &u)
g_sqrt< E1 > sqrt(const GenericExpression< E1 > &u)
g_sqr< E1 > sqr(const GenericExpression< E1 > &u)
g_pow4< E1 > pow4(const GenericExpression< E1 > &u)
ListConstRefWrap< typename Expr::value_type > expr
Fully self-contained constant field wrapper. Not needed?
auto max(GeometricFieldExpression< E1, typename E1::IntExpr, typename E1::UncoupledPatchExpr, typename E1::CoupledPatchExpr, typename E1::value_type > const &u, GeometricFieldExpression< E2, typename E2::IntExpr, typename E2::UncoupledPatchExpr, typename E2::CoupledPatchExpr, typename E2::value_type > const &v)
g_symm< E1 > symm(const GenericExpression< E1 > &u)
auto sinh(GeometricFieldExpression< E1, typename E1::IntExpr, typename E1::UncoupledPatchExpr, typename E1::CoupledPatchExpr, typename E1::value_type > const &u)
auto tan(GeometricFieldExpression< E1, typename E1::IntExpr, typename E1::UncoupledPatchExpr, typename E1::CoupledPatchExpr, typename E1::value_type > const &u)
const expr V(m.psi().mesh().V())
g_pow3< E1 > pow3(const GenericExpression< E1 > &u)
auto min(GeometricFieldExpression< E1, typename E1::IntExpr, typename E1::UncoupledPatchExpr, typename E1::CoupledPatchExpr, typename E1::value_type > const &u, GeometricFieldExpression< E2, typename E2::IntExpr, typename E2::UncoupledPatchExpr, typename E2::CoupledPatchExpr, typename E2::value_type > const &v)
auto mag(GeometricFieldExpression< E1, typename E1::IntExpr, typename E1::UncoupledPatchExpr, typename E1::CoupledPatchExpr, typename E1::value_type > const &u)
g_magSqr< E1 > magSqr(const GenericExpression< E1 > &u)
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
dimensionedSymmTensor symm(const dimensionedSymmTensor &dt)
const dimensionSet dimless
Dimensionless.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
dimensionedScalar pow3(const dimensionedScalar &ds)
dimensionedScalar sqrt(const dimensionedScalar &ds)
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
dimensionedScalar pow4(const dimensionedScalar &ds)
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
void diag(pointPatchField< vector > &, const pointPatchField< tensor > &)
dimensionSet pow2(const dimensionSet &ds)
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
void SuSp(fvMatrix< typename Expr::value_type > &m, const Expr2 &mult, const Expr &expression)