39 #ifndef Foam_GeometricFieldExpression_H 40 #define Foam_GeometricFieldExpression_H 77 static constexpr
bool is_leaf =
false;
102 return static_cast<E const&
>(*this)[i];
131 UncoupledPatchExpr
patchField(
const label i)
const 133 return static_cast<const E&
>(*this).
patchField(i);
147 auto access(
const Op& cop,
const label i)
const 149 return static_cast<const E&
>(*this).
access(cop, i);
153 template<
class GeoField>
156 constexpr
bool is_pointField =
157 std::is_same_v<pointMesh, typename GeoField::Mesh>;
162 assert(
fld.size() == this->
size());
163 typedef typename GeoField::value_type ActualType;
168 auto& bfld =
fld.boundaryFieldRef();
169 const label
n = bfld.size();
170 #if defined(__STDPAR__) 171 constexpr
bool foam_offload =
true;
173 constexpr
bool foam_offload =
false;
175 if constexpr (foam_offload)
180 auto do_something = [](
auto& data, label& i,
auto& pfld)
182 if constexpr (is_pointField)
184 if (
auto* vp = isA_constCast<FieldType>(pfld))
191 data[i++] = &
static_cast<FieldType&
>(pfld);
198 fld.boundaryFieldRef(),
202 std::vector<UncoupledPatchExpr> unc_patchExpr;
203 std::vector<CoupledPatchExpr> cou_patchExpr;
204 std::vector<int> coupledID;
205 std::vector<int> uncoupledID;
208 unc_patchExpr.reserve(
n);
209 uncoupledID.reserve(
n);
211 for (label i = 0; i <
n; ++i)
213 auto& pfld = bfld[i];
214 if (force || pfld.assignable())
220 cou_patchExpr.emplace_back(patchExpr);
221 coupledID.emplace_back(i);
226 unc_patchExpr.emplace_back(patchExpr);
227 uncoupledID.emplace_back(i);
249 for (label i = 0; i <
n; ++i)
251 auto& pfld = bfld[i];
252 if (force || pfld.assignable())
259 if constexpr (is_pointField)
261 if (
auto* vp = isA_constCast<FieldType>(pfld))
263 patchExpr.evaluate(*vp);
268 patchExpr.evaluate(pfld);
276 if constexpr (is_pointField)
278 if (
auto* vp = isA_constCast<FieldType>(pfld))
280 patchExpr.evaluate(*vp);
285 patchExpr.evaluate(pfld);
291 fld.correctLocalBoundaryConditions();
302 template<
class GeoField>
303 class GeometricFieldRefWrap
307 GeometricFieldRefWrap<GeoField>,
308 ListRefWrap<typename GeoField::value_type>,
309 ListRefWrap<typename GeoField::value_type>,
310 ListTmpWrap<Field<typename GeoField::value_type>>,
311 typename GeoField::value_type
316 static constexpr
bool is_leaf =
false;
320 std::is_same_v<pointMesh, typename GeoField::Mesh>;
326 typedef typename GeoField::value_type
value_type;
386 typename E::UncoupledPatchExpr,
387 typename E::CoupledPatchExpr,
388 typename E::value_type
417 typename E::UncoupledPatchExpr,
418 typename E::CoupledPatchExpr,
419 typename E::value_type
435 typename E::UncoupledPatchExpr,
436 typename E::CoupledPatchExpr,
437 typename E::value_type
456 return elems_.size();
461 auto&
fld = elems_.internalFieldRef();
467 auto&
fld = elems_.internalField();
473 auto&
fld = elems_.boundaryFieldRef()[i];
494 const auto&
fld = elems_.boundaryField()[i];
515 auto&
fld = elems_.boundaryFieldRef()[i];
536 const auto&
fld = elems_.boundaryField()[i];
558 template<
class AccessOp>
559 auto access(
const AccessOp& cop,
const label i)
const 561 return cop(elems_, i);
571 template<
class GeoField>
572 class GeometricFieldConstRefWrap
574 public GeometricFieldExpression
576 GeometricFieldConstRefWrap<GeoField>,
577 ListConstRefWrap<typename GeoField::value_type>,
578 ListConstRefWrap<typename GeoField::value_type>,
579 ListConstTmpWrap<Field<typename GeoField::value_type>>,
580 typename GeoField::value_type
585 static constexpr
bool is_leaf =
false;
589 std::is_same_v<pointMesh, typename GeoField::Mesh>;
595 typedef typename GeoField::value_type
value_type;
629 const auto&
data()
const 641 return elems_.size();
646 return elems_.internalField();
652 const auto&
fld = elems_.boundaryField()[i];
673 const auto&
fld = elems_.boundaryField()[i];
692 template<
class AccessOp>
693 auto access(
const AccessOp& cop,
const label i)
const 695 return cop(elems_, i);
705 template<
class GeoField>
710 GeometricFieldConstTmpWrap<GeoField>,
711 ListConstRefWrap<typename GeoField::value_type>,
712 ListConstRefWrap<typename GeoField::value_type>,
713 ListConstTmpWrap<Field<typename GeoField::value_type>>,
714 typename GeoField::value_type
720 static constexpr
bool is_leaf =
false;
724 std::is_same_v<pointMesh, typename GeoField::Mesh>;
730 typedef typename GeoField::value_type
value_type;
801 const auto&
data()
const 814 return elems_().size();
819 return elems_().internalField();
824 const auto&
fld = elems_().boundaryField()[i];
828 if (
const auto* vp =
isA<Field<value_type>>(
fld))
845 const auto&
fld = elems_().boundaryField()[i];
864 template<
class AccessOp>
865 auto access(
const AccessOp& cop,
const label i)
const 867 return cop(elems_(), i);
878 template<
typename E1,
typename E2>
881 public GeometricFieldExpression
886 typename E1::IntExpr,
891 typename E1::UncoupledPatchExpr,
892 typename E2::UncoupledPatchExpr
896 typename E1::CoupledPatchExpr,
897 typename E2::CoupledPatchExpr
899 typename E1::value_type
907 static constexpr
bool is_leaf =
false;
915 typename E1::IntExpr,
920 typename E1::UncoupledPatchExpr,
921 typename E2::UncoupledPatchExpr
925 typename E1::CoupledPatchExpr,
926 typename E2::CoupledPatchExpr
929 GF_add(
const E1& u,
const E2& v)
946 assert(u.size() == -1 || v.size() == -1 || u.size() == v.size());
951 typename E1::value_type,
952 typename E2::value_type
958 return u_[i] + v_[i];
964 return IntExpr(u_.internalField(), v_.internalField());
976 u_.coupledPatchField(i),
977 v_.coupledPatchField(i)
981 template<
class AccessOp>
982 auto access(
const AccessOp& cop,
const label i)
const 987 template<
typename E1,
typename E2>
990 GeometricFieldExpression
993 typename E1::IntExpr,
994 typename E1::UncoupledPatchExpr,
995 typename E1::CoupledPatchExpr,
996 typename E1::value_type
998 GeometricFieldExpression
1001 typename E2::IntExpr,
1002 typename E2::UncoupledPatchExpr,
1003 typename E2::CoupledPatchExpr,
1004 typename E2::value_type
1010 static_cast<const E1&
>(u),
1011 static_cast<const E2&>(v)
1014 template<
typename E1,
class Type,
template<
class>
class PatchField,
class GeoMesh>
1020 typename E1::IntExpr,
1021 typename E1::UncoupledPatchExpr,
1022 typename E1::CoupledPatchExpr,
1023 typename E1::value_type
1033 return GF_add(static_cast<const E1&>(u), E2(v));
1035 template<
typename E1,
class Type,
template<
class>
class PatchField,
class GeoMesh>
1039 GeometricFieldExpression
1042 typename E1::IntExpr,
1043 typename E1::UncoupledPatchExpr,
1044 typename E1::CoupledPatchExpr,
1045 typename E1::value_type
1053 return GF_add(E2(u), static_cast<const E1&>(v));
1056 <
class Type1,
class Type2,
template<
class>
class PatchField,
class GeoMesh>
1059 GeometricField<Type1, PatchField, GeoMesh>
const& u,
1071 return GF_add(E1(u), E2(v));
1073 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1083 return GF_add(E1(u), E2(u, v));
1085 template<
class Type,
template<
class>
class PatchField,
class GeoMesh>
1095 return GF_add(E2(v, u), E1(v));
1099 template<
typename E1>
1107 typename E1::IntExpr
1111 typename E1::UncoupledPatchExpr
1115 typename E1::CoupledPatchExpr
1117 typename E1::value_type
1124 static constexpr
bool is_leaf =
false;
1158 return u_.internalField();
1163 return u_.patchField(i);
1168 return u_.coupledPatchField(i);
1171 template<
class AccessOp>
1172 auto access(
const AccessOp& cop,
const label i)
const 1174 return -u_.access(cop, i);
1177 template<
typename E1>
1183 typename E1::IntExpr,
1184 typename E1::UncoupledPatchExpr,
1185 typename E1::CoupledPatchExpr,
1186 typename E1::value_type
1194 #undef EXPRESSION_GF_FUNCTION1_DIMLESS 1195 #define EXPRESSION_GF_FUNCTION1_DIMLESS(Func, BaseFunc, WrapType, OpFunc) \ 1196 template<typename E1> \ 1199 public GeometricFieldExpression \ 1202 WrapType<typename E1::IntExpr>, \ 1203 WrapType<typename E1::UncoupledPatchExpr>, \ 1204 WrapType<typename E1::CoupledPatchExpr>, \ 1205 typename E1::value_type \ 1209 typename std::conditional<E1::is_leaf, const E1&, const E1>::type u_; \ 1212 static constexpr bool is_leaf = false; \ 1215 typedef typename E1::value_type value_type; \ 1218 typedef WrapType<typename E1::IntExpr> IntExpr; \ 1219 typedef WrapType<typename E1::UncoupledPatchExpr> UncoupledPatchExpr; \ 1220 typedef WrapType<typename E1::CoupledPatchExpr> CoupledPatchExpr; \ 1222 OpFunc(const E1& u) \ 1224 GeometricFieldExpression \ 1228 UncoupledPatchExpr, \ 1238 auto operator[](const label i) const \ 1240 return BaseFunc(u_[i]); \ 1242 auto size() const noexcept { return u_.size(); } \ 1244 IntExpr internalField() const \ 1246 return IntExpr(u_.internalField()); \ 1249 UncoupledPatchExpr patchField(const label i) const \ 1251 return UncoupledPatchExpr(u_.patchField(i)); \ 1254 CoupledPatchExpr coupledPatchField(const label i) const \ 1256 return CoupledPatchExpr(u_.coupledPatchField(i)); \ 1259 template<class AccessOpOp> \ 1260 auto access(const AccessOpOp& cop, const label i) const \ 1262 return UncoupledPatchExpr(u_.access(cop, i)); \ 1265 template<typename E1> \ 1268 GeometricFieldExpression \ 1271 typename E1::IntExpr, \ 1272 typename E1::UncoupledPatchExpr, \ 1273 typename E1::CoupledPatchExpr, \ 1274 typename E1::value_type \ 1278 return OpFunc<E1>(static_cast<const E1&>(u)); \ 1280 template<class Type, template<class> class PatchField, class GeoMesh> \ 1281 auto Func(GeometricField<Type, PatchField, GeoMesh> const& fld) \ 1283 typedef typename Expression::GeometricFieldConstRefWrap \ 1284 <GeometricField<Type, PatchField, GeoMesh>> E1; \ 1285 return Func(E1(fld)); \ 1288 #undef EXPRESSION_GF_FUNCTION1 1289 #define EXPRESSION_GF_FUNCTION1(Func, BaseFunc, WrapType, OpFunc) \ 1290 template<typename E1> \ 1293 public GeometricFieldExpression \ 1296 WrapType<typename E1::IntExpr>, \ 1297 WrapType<typename E1::UncoupledPatchExpr>, \ 1298 WrapType<typename E1::CoupledPatchExpr>, \ 1299 typename E1::value_type \ 1303 typename std::conditional<E1::is_leaf, const E1&, const E1>::type u_; \ 1306 static constexpr bool is_leaf = false; \ 1309 typedef typename E1::value_type value_type; \ 1312 typedef WrapType<typename E1::IntExpr> IntExpr; \ 1313 typedef WrapType<typename E1::UncoupledPatchExpr> UncoupledPatchExpr; \ 1314 typedef WrapType<typename E1::CoupledPatchExpr> CoupledPatchExpr; \ 1316 OpFunc(const E1& u) \ 1318 GeometricFieldExpression \ 1322 UncoupledPatchExpr, \ 1327 BaseFunc(u.dimensions()), \ 1328 BaseFunc(u.oriented()) \ 1332 auto operator[](const label i) const \ 1334 return BaseFunc(u_[i]); \ 1336 auto size() const noexcept { return u_.size(); } \ 1338 IntExpr internalField() const \ 1340 return IntExpr(u_.internalField()); \ 1343 UncoupledPatchExpr patchField(const label i) const \ 1345 return UncoupledPatchExpr(u_.patchField(i)); \ 1348 CoupledPatchExpr coupledPatchField(const label i) const \ 1350 return CoupledPatchExpr(u_.coupledPatchField(i)); \ 1353 template<class AccessOpOp> \ 1354 auto access(const AccessOpOp& cop, const label i) const \ 1356 return UncoupledPatchExpr(u_.access(cop, i)); \ 1359 template<typename E1> \ 1362 GeometricFieldExpression \ 1365 typename E1::IntExpr, \ 1366 typename E1::UncoupledPatchExpr, \ 1367 typename E1::CoupledPatchExpr, \ 1368 typename E1::value_type \ 1372 return OpFunc<E1>(static_cast<const E1&>(u)); \ 1374 template<class Type, template<class> class PatchField, class GeoMesh> \ 1375 auto Func(GeometricField<Type, PatchField, GeoMesh> const& fld) \ 1377 typedef typename Expression::GeometricFieldConstRefWrap \ 1378 <GeometricField<Type, PatchField, GeoMesh>> E1; \ 1379 return Func(E1(fld)); \ 1458 #undef EXPRESSION_GF_OPERATOR 1459 #define EXPRESSION_GF_OPERATOR(Op, WrapType, OpFunc) \ 1460 template<typename E1, typename E2> \ 1463 public GeometricFieldExpression \ 1468 typename E1::IntExpr, \ 1469 typename E2::IntExpr \ 1473 typename E1::UncoupledPatchExpr, \ 1474 typename E2::UncoupledPatchExpr \ 1478 typename E1::CoupledPatchExpr, \ 1479 typename E2::CoupledPatchExpr \ 1481 typename E1::value_type \ 1485 typename std::conditional<E1::is_leaf, const E1&, const E1>::type u_; \ 1486 typename std::conditional<E2::is_leaf, const E2&, const E2>::type v_; \ 1489 static constexpr bool is_leaf = false; \ 1492 typedef typename E1::value_type value_type; \ 1497 typename E1::IntExpr, \ 1498 typename E2::IntExpr \ 1502 typename E1::UncoupledPatchExpr, \ 1503 typename E2::UncoupledPatchExpr \ 1504 > UncoupledPatchExpr; \ 1507 typename E1::CoupledPatchExpr, \ 1508 typename E2::CoupledPatchExpr \ 1509 > CoupledPatchExpr; \ 1511 OpFunc(const E1& u, const E2& v) \ 1513 GeometricFieldExpression \ 1517 UncoupledPatchExpr, \ 1519 typename E1::value_type \ 1522 u.dimensions() Op v.dimensions(), \ 1523 u.oriented() Op v.oriented() \ 1536 assert(u.size() == -1 || v.size() == -1 || u.size() == v.size()); \ 1538 auto operator[](const label i) const \ 1540 return u_[i] Op v_[i]; \ 1542 auto size() const noexcept { return Foam::max(u_.size(), v_.size()); } \ 1544 IntExpr internalField() const \ 1546 return IntExpr(u_.internalField(), v_.internalField()); \ 1549 UncoupledPatchExpr patchField(const label i) const \ 1551 return UncoupledPatchExpr(u_.patchField(i), v_.patchField(i)); \ 1554 CoupledPatchExpr coupledPatchField(const label i) const \ 1556 return CoupledPatchExpr \ 1558 u_.coupledPatchField(i), \ 1559 v_.coupledPatchField(i) \ 1563 template<class AccessOp> \ 1564 auto access(const AccessOp& cop, const label i) const \ 1566 return UncoupledPatchExpr \ 1568 u_.access(cop, i), \ 1573 template<typename E1, typename E2> \ 1576 GeometricFieldExpression \ 1579 typename E1::IntExpr, \ 1580 typename E1::UncoupledPatchExpr, \ 1581 typename E1::CoupledPatchExpr, \ 1582 typename E1::value_type \ 1584 GeometricFieldExpression \ 1587 typename E2::IntExpr, \ 1588 typename E2::UncoupledPatchExpr, \ 1589 typename E2::CoupledPatchExpr, \ 1590 typename E2::value_type \ 1594 return OpFunc<E1, E2> \ 1596 static_cast<const E1&>(u), \ 1597 static_cast<const E2&>(v) \ 1603 class Type, template<class> class PatchField, class GeoMesh \ 1607 GeometricFieldExpression \ 1610 typename E1::IntExpr, \ 1611 typename E1::UncoupledPatchExpr, \ 1612 typename E1::CoupledPatchExpr, \ 1613 typename E1::value_type \ 1615 GeometricField<Type, PatchField, GeoMesh> const& fld \ 1618 typedef typename Expression::GeometricFieldConstRefWrap \ 1619 <GeometricField<Type, PatchField, GeoMesh>> E2; \ 1620 return operator Op(u, E2(fld)); \ 1624 class Type, template<class> class PatchField, class GeoMesh, \ 1629 GeometricField<Type, PatchField, GeoMesh> const& fld, \ 1630 GeometricFieldExpression \ 1633 typename E1::IntExpr, \ 1634 typename E1::UncoupledPatchExpr, \ 1635 typename E1::CoupledPatchExpr, \ 1636 typename E1::value_type \ 1640 typedef typename Expression::GeometricFieldConstRefWrap \ 1641 <GeometricField<Type, PatchField, GeoMesh>> E2; \ 1642 return operator Op(E2(fld), u); \ 1645 <class Type1, class Type2, template<class> class PatchField, class GeoMesh> \ 1648 GeometricField<Type1, PatchField, GeoMesh> const& u, \ 1649 GeometricField<Type2, PatchField, GeoMesh> const& v \ 1652 typedef typename Expression::GeometricFieldConstRefWrap \ 1653 <GeometricField<Type1, PatchField, GeoMesh>> E1; \ 1654 typedef typename Expression::GeometricFieldConstRefWrap \ 1655 <GeometricField<Type2, PatchField, GeoMesh>> E2; \ 1656 return operator Op(E1(u), E2(v)); \ 1659 template<typename E1, class Type> \ 1662 GeometricFieldExpression \ 1665 typename E1::IntExpr, \ 1666 typename E1::UncoupledPatchExpr, \ 1667 typename E1::CoupledPatchExpr, \ 1668 typename E1::value_type \ 1670 dimensioned<Type> const& v \ 1673 typedef typename Foam::Expression::UniformGeometricFieldWrap2<Type> E2; \ 1674 return operator Op(u, E2(v)); \ 1676 template<typename E1, class Type> \ 1679 dimensioned<Type> const& u, \ 1680 GeometricFieldExpression \ 1683 typename E1::IntExpr, \ 1684 typename E1::UncoupledPatchExpr, \ 1685 typename E1::CoupledPatchExpr, \ 1686 typename E1::value_type \ 1690 typedef typename Foam::Expression::UniformGeometricFieldWrap2<Type> E2; \ 1691 return operator Op(E2(u), v); \ 1696 class Type1, class Type2, template<class> class PatchField, class GeoMesh, \ 1697 class = std::enable_if_t \ 1699 (std::is_arithmetic_v<Type2> || Foam::is_vectorspace_v<Type2>) \ 1704 GeometricField<Type1, PatchField, GeoMesh> const& u, \ 1708 typedef typename Foam::GeometricField<Type1, PatchField, GeoMesh> GeoField;\ 1709 typedef typename Expression::UniformGeometricFieldWrap<GeoField, Type2> E2;\ 1710 return operator Op(u, E2(u, v)); \ 1714 class Type1, class Type2, template<class> class PatchField, class GeoMesh, \ 1715 class = std::enable_if_t \ 1717 (std::is_arithmetic_v<Type2> || Foam::is_vectorspace_v<Type2>) \ 1723 GeometricField<Type1, PatchField, GeoMesh> const& v \ 1726 typedef typename Foam::GeometricField<Type1, PatchField, GeoMesh> GeoField;\ 1727 typedef typename Expression::UniformGeometricFieldWrap<GeoField, Type2> E2;\ 1728 return operator Op(E2(v, u), v); \ 1733 class Type1, class Type2, template<class> class PatchField, class GeoMesh \ 1737 GeometricField<Type1, PatchField, GeoMesh> const& u, \ 1738 dimensioned<Type2> const& v \ 1741 typedef typename Foam::Expression::UniformGeometricFieldWrap \ 1742 <GeometricField<Type1, PatchField, GeoMesh>, Type2> E2; \ 1743 return operator Op(u, E2(u, v)); \ 1747 class Type1, class Type2, template<class> class PatchField, class GeoMesh \ 1751 dimensioned<Type2> const& u, \ 1752 GeometricField<Type1, PatchField, GeoMesh> const& v \ 1755 typedef typename Foam::Expression::UniformGeometricFieldWrap \ 1756 <GeometricField<Type1, PatchField, GeoMesh>, Type2> E2; \ 1757 return operator Op(E2(v, u), v); \ 1762 class E1, class Type2, \ 1763 class = std::enable_if_t \ 1765 (std::is_arithmetic_v<Type2> || Foam::is_vectorspace_v<Type2>) \ 1770 GeometricFieldExpression \ 1773 typename E1::IntExpr, \ 1774 typename E1::UncoupledPatchExpr, \ 1775 typename E1::CoupledPatchExpr, \ 1776 typename E1::value_type \ 1781 typedef typename Foam::Expression::UniformGeometricFieldWrap2<Type2> E2; \ 1782 return operator Op(u, E2(v)); \ 1786 class E1, class Type2, \ 1787 class = std::enable_if_t \ 1789 (std::is_arithmetic_v<Type2> || Foam::is_vectorspace_v<Type2>) \ 1795 GeometricFieldExpression \ 1798 typename E1::IntExpr, \ 1799 typename E1::UncoupledPatchExpr, \ 1800 typename E1::CoupledPatchExpr, \ 1801 typename E1::value_type \ 1805 typedef typename Foam::Expression::UniformGeometricFieldWrap2<Type2> E2; \ 1806 return operator Op(E2(u), v); \ 1810 #undef EXPRESSION_GF_FUNCTION2 1811 #define EXPRESSION_GF_FUNCTION2(Func, BaseFunc, WrapType, OpFunc) \ 1812 template<typename E1, typename E2> \ 1815 public GeometricFieldExpression \ 1820 typename E1::IntExpr, \ 1821 typename E2::IntExpr \ 1825 typename E1::UncoupledPatchExpr, \ 1826 typename E2::UncoupledPatchExpr \ 1830 typename E1::CoupledPatchExpr, \ 1831 typename E2::CoupledPatchExpr \ 1833 typename E1::value_type \ 1837 typename std::conditional<E1::is_leaf, const E1&, const E1>::type u_; \ 1838 typename std::conditional<E2::is_leaf, const E2&, const E2>::type v_; \ 1841 static constexpr bool is_leaf = false; \ 1844 typedef typename E1::value_type value_type; \ 1849 typename E1::IntExpr, \ 1850 typename E2::IntExpr \ 1854 typename E1::UncoupledPatchExpr, \ 1855 typename E2::UncoupledPatchExpr \ 1856 > UncoupledPatchExpr; \ 1859 typename E1::CoupledPatchExpr, \ 1860 typename E2::CoupledPatchExpr \ 1861 > CoupledPatchExpr; \ 1863 OpFunc(const E1& u, const E2& v) \ 1865 GeometricFieldExpression \ 1869 UncoupledPatchExpr, \ 1874 BaseFunc(u.dimensions(), v.dimensions()), \ 1875 BaseFunc(u.oriented(), v.oriented()) \ 1889 auto operator[](const label i) const \ 1891 return BaseFunc(u_[i], v_[i]); \ 1893 auto size() const noexcept {return Foam::max(u_.size(), v_.size()); } \ 1895 IntExpr internalField() const \ 1897 return IntExpr(u_.internalField(), v_.internalField()); \ 1900 UncoupledPatchExpr patchField(const label i) const \ 1902 return UncoupledPatchExpr(u_.patchField(i), v_.patchField(i)); \ 1905 CoupledPatchExpr coupledPatchField(const label i) const \ 1907 return CoupledPatchExpr \ 1909 u_.coupledPatchField(i), \ 1910 v_.coupledPatchField(i) \ 1914 template<class AccessOp> \ 1915 auto access(const AccessOp& cop, const label i) const \ 1917 return UncoupledPatchExpr \ 1919 u_.access(cop, i), \ 1924 template<typename E1, typename E2> \ 1927 GeometricFieldExpression \ 1930 typename E1::IntExpr, \ 1931 typename E1::UncoupledPatchExpr, \ 1932 typename E1::CoupledPatchExpr, \ 1933 typename E1::value_type \ 1935 GeometricFieldExpression \ 1938 typename E2::IntExpr, \ 1939 typename E2::UncoupledPatchExpr, \ 1940 typename E2::CoupledPatchExpr, \ 1941 typename E2::value_type \ 1945 return OpFunc<E1, E2> \ 1947 static_cast<const E1&>(u), \ 1948 static_cast<const E2&>(v) \ 1954 class Type, template<class> class PatchField, class GeoMesh \ 1958 GeometricFieldExpression \ 1961 typename E1::IntExpr, \ 1962 typename E1::UncoupledPatchExpr, \ 1963 typename E1::CoupledPatchExpr, \ 1964 typename E1::value_type \ 1966 GeometricField<Type, PatchField, GeoMesh> const& fld \ 1969 typedef typename Expression::GeometricFieldConstRefWrap \ 1970 <GeometricField<Type, PatchField, GeoMesh>> E2; \ 1971 return Func(u, E2(fld)); \ 1975 class Type, template<class> class PatchField, class GeoMesh, \ 1980 GeometricField<Type, PatchField, GeoMesh> const& fld, \ 1981 GeometricFieldExpression \ 1984 typename E1::IntExpr, \ 1985 typename E1::UncoupledPatchExpr, \ 1986 typename E1::CoupledPatchExpr, \ 1987 typename E1::value_type \ 1991 typedef typename Expression::GeometricFieldConstRefWrap \ 1992 <GeometricField<Type, PatchField, GeoMesh>> E2; \ 1993 return Func(E2(fld), u); \ 1997 class Type, template<class> class PatchField, class GeoMesh \ 2001 GeometricField<Type, PatchField, GeoMesh> const& u, \ 2002 GeometricField<Type, PatchField, GeoMesh> const& v \ 2005 typedef typename Expression::GeometricFieldConstRefWrap \ 2006 <GeometricField<Type, PatchField, GeoMesh>> E2; \ 2007 return Func(E2(u), E2(v)); \ 2012 class Type1, class Type2, template<class> class PatchField, class GeoMesh \ 2016 GeometricField<Type1, PatchField, GeoMesh> const& u, \ 2017 dimensioned<Type2> const& v \ 2020 typedef typename Foam::Expression::UniformGeometricFieldWrap \ 2021 <GeometricField<Type1, PatchField, GeoMesh>, Type2> E2; \ 2022 return Func(u, E2(u,v)); \ 2026 class Type1, class Type2, template<class> class PatchField, class GeoMesh \ 2030 dimensioned<Type2> const& u, \ 2031 GeometricField<Type1, PatchField, GeoMesh> const& v \ 2034 typedef typename Foam::Expression::UniformGeometricFieldWrap \ 2035 <GeometricField<Type1, PatchField, GeoMesh>, Type2> E2; \ 2036 return Func(E2(v, u), v); \ 2038 template<typename E1, class Type> \ 2041 GeometricFieldExpression \ 2044 typename E1::IntExpr, \ 2045 typename E1::UncoupledPatchExpr, \ 2046 typename E1::CoupledPatchExpr, \ 2047 typename E1::value_type \ 2049 dimensioned<Type> const& v \ 2052 typedef typename Foam::Expression::UniformGeometricFieldWrap2<Type> E2; \ 2053 return Func(u, E2(v)); \ 2055 template<typename E1, class Type> \ 2058 dimensioned<Type> const& u, \ 2059 GeometricFieldExpression \ 2062 typename E1::IntExpr, \ 2063 typename E1::UncoupledPatchExpr, \ 2064 typename E1::CoupledPatchExpr, \ 2065 typename E1::value_type \ 2069 typedef typename Foam::Expression::UniformGeometricFieldWrap2<Type> E2; \ 2070 return Func(E2(u), v); \ 2088 #undef EXPRESSION_GF_FUNCTION1_DIMLESS 2100 #undef EXPRESSION_GF_FUNCTION1 2105 #undef EXPRESSION_GF_FUNCTION2 2112 #undef EXPRESSION_GF_OPERATOR 2119 template<
class GeoField,
class Type =
typename GeoField::value_type>
2120 class UniformGeometricFieldWrap
2122 public GeometricFieldExpression
2124 UniformGeometricFieldWrap<GeoField, Type>,
2125 UniformListWrap<Type>,
2126 UniformListWrap<Type>,
2127 UniformListWrap<Type>,
2146 const GeoField& elems_;
2174 const GeoField& elems,
2175 const dimensioned<value_type>& val
2201 return elems_.size();
2206 return IntExpr(elems_.internalField().size(), val_);
2219 template<
class AccessOp>
2220 auto access(
const AccessOp& cop,
const label i)
const 2233 UniformGeometricFieldWrap2<T>,
2242 static constexpr
bool is_leaf =
false;
2326 template<
class AccessOp>
2327 auto access(
const AccessOp& cop,
const label i)
const
const orientedType & oriented() const noexcept
Expression wrap of multiple lists.
auto access(const AccessOp &cop, const label i) const
static constexpr bool is_pointField
True if GeoField is associated with a pointMesh.
static constexpr bool is_leaf
E1::value_type value_type
Type to return for internal field.
ListRefWrap< value_type > UncoupledPatchExpr
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? Or leave as indexing for convenience?
Expression wrap of const reference to UList.
GeoField::value_type value_type
Type to return for internal field.
CoupledPatchExpr coupledPatchField(const label i)
auto cosh(GeometricFieldExpression< E1, typename E1::IntExpr, typename E1::UncoupledPatchExpr, typename E1::CoupledPatchExpr, typename E1::value_type > const &u)
dimensioned< typename typeOfMag< Type >::type > mag(const dimensioned< Type > &dt)
static constexpr bool is_leaf
Have expressions use copy to maintain tmp refCount.
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)
GeometricFieldRefWrap(this_type &elems)
Copy construct.
A 1D array of objects of type <T>, where the size of the vector is known and used for subscript bound...
label max(const labelHashSet &set, label maxValue=labelMin)
Find the max value in labelHashSet, optionally limited by second argument.
dimensionedSymmTensor sqr(const dimensionedVector &dv)
Expression wrap of const tmp to List.
static constexpr bool is_leaf
Expression of GeometricField.
List_add< typename E1::UncoupledPatchExpr, typename E2::UncoupledPatchExpr > UncoupledPatchExpr
IntExpr internalField() const
dimensionedScalar sqrt(const dimensionedScalar &ds)
GeoField & evaluate(GeoField &fld, const bool force=false) const
Helper to evaluate a GeometricField.
List_add< typename E1::CoupledPatchExpr, typename E2::CoupledPatchExpr > CoupledPatchExpr
List_add< typename E1::IntExpr, typename E2::IntExpr > IntExpr
Type to return for patchField.
Generic GeometricField class.
Class to determine the 'oriented' status of surface fields.
Generic dimensioned Type class.
ListConstTmpWrap< Field< value_type > > CoupledPatchExpr
const dimensionSet dimless
Dimensionless.
CoupledPatchExpr coupledPatchField(const label i) const
CoupledPatchExpr coupledPatchField(const label i) const
auto size() const noexcept
ListConstRefWrap< value_type > UncoupledPatchExpr
auto operator[](const label i) const
GeoField this_type
The GeometricField type.
Expression wrap of const tmp to GeometricField.
UncoupledPatchExpr patchField(const label i)
#define EXPRESSION_GF_FUNCTION1(Func, BaseFunc, WrapType, OpFunc)
UncoupledPatchExpr patchField(const label i) const
Expression wrap of const reference to GeometricField.
Type * isA_constCast(const U &obj)
Attempt dynamic_cast to Type followed by a const_cast of the result.
auto mag(GeometricFieldExpression< E1, typename E1::IntExpr, typename E1::UncoupledPatchExpr, typename E1::CoupledPatchExpr, typename E1::value_type > const &u)
Dimension set for the base types, which can be used to implement rigorous dimension checking for alge...
auto size() const noexcept
CoupledPatchExpr coupledPatchField(const label i)
List_negate< typename E1::CoupledPatchExpr > CoupledPatchExpr
value_type operator[](const label i) const
auto operator[](const label i) const
Generic templated field type that is much like a Foam::List except that it is expected to hold numeri...
const dimensionSet & dimensions() const noexcept
ListConstRefWrap< typename Expr::value_type > expr
Fully self-contained constant field wrapper. Not needed?
List_negate< typename E1::UncoupledPatchExpr > UncoupledPatchExpr
auto access(const AccessOp &cop, const label i) const
GeoField::value_type value_type
Type to return for internal field.
ListRefWrap< value_type > IntExpr
Type to return for patchField.
const auto & data() const
#define EXPRESSION_GF_FUNCTION1_DIMLESS(Func, BaseFunc, WrapType, OpFunc)
g_symm< E1 > symm(const GenericExpression< E1 > &u)
auto access(const Op &cop, const label i) const
Type operator[](const label i) const
g_sqr< E1 > sqr(const GenericExpression< E1 > &u)
Expression wrap of tmp to List.
Expression wrap of non-const reference to GeometricField.
label min(const labelHashSet &set, label minValue=labelMax)
Find the min value in labelHashSet, optionally limited by second argument.
dimensionSet pow2(const dimensionSet &ds)
value_type operator[](const label i) const
GeometricFieldConstRefWrap(const this_type &elems)
E1::value_type value_type
Type to return for internal field.
const auto & data() const
const dimensionSet dimensions_
IntExpr internalField() const
auto tanh(GeometricFieldExpression< E1, typename E1::IntExpr, typename E1::UncoupledPatchExpr, typename E1::CoupledPatchExpr, typename E1::value_type > const &u)
auto access(const AccessOp &cop, const label i) const
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)
#define EXPRESSION_GF_FUNCTION2(Func, BaseFunc, WrapType, OpFunc)
auto size() const noexcept
static constexpr bool is_leaf
UncoupledPatchExpr patchField(const label i) const
IntExpr internalField() const
g_pow4< E1 > pow4(const GenericExpression< E1 > &u)
const orientedType oriented_
ListConstRefWrap< value_type > UncoupledPatchExpr
auto access(const AccessOp &cop, const label i) const
GF_add(const E1 &u, const E2 &v)
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
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;for(const word &name :lagrangianScalarNames){ IOField< scalar > fld(IOobject(name, runTime.timeName(), cloud::prefix, mesh, IOobject::MUST_READ, IOobject::NO_WRITE))
IntExpr internalField() const
~GeometricFieldConstTmpWrap()
dimensionedScalar pow3(const dimensionedScalar &ds)
auto sin(GeometricFieldExpression< E1, typename E1::IntExpr, typename E1::UncoupledPatchExpr, typename E1::CoupledPatchExpr, typename E1::value_type > const &u)
CoupledPatchExpr coupledPatchField(const label i) const
GeoField::value_type value_type
Type to return for internal field.
Container & evaluate(Container &lst) const
Helper: assign to passed in list.
auto size() const noexcept
static constexpr bool is_pointField
True if GeoField is associated with a pointMesh.
dimensionedSymmTensor symm(const dimensionedSymmTensor &dt)
auto access(const AccessOp &cop, const label i) const
ListConstRefWrap< value_type > IntExpr
Type to return for patchField.
value_type operator[](const label i) const
UncoupledPatchExpr patchField(const label i) const
dimensionedScalar pow4(const dimensionedScalar &ds)
g_magSqr< E1 > magSqr(const GenericExpression< E1 > &u)
Expression wrap of non-const reference to List.
GeoField this_type
The GeometricField type.
auto cos(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)
static constexpr bool is_pointField
True if GeoField is associated with a pointMesh.
auto sinh(GeometricFieldExpression< E1, typename E1::IntExpr, typename E1::UncoupledPatchExpr, typename E1::CoupledPatchExpr, typename E1::value_type > const &u)
const Type * isA(const U &obj)
Attempt dynamic_cast to Type.
GeometricFieldConstTmpWrap(const tmp< this_type > &elems)
g_pow2< E1 > pow2(const GenericExpression< E1 > &u)
static constexpr bool is_leaf
Generic mesh wrapper used by volMesh, surfaceMesh, pointMesh etc.
UncoupledPatchExpr patchField(const label i)
#define EXPRESSION_GF_OPERATOR(Op, WrapType, OpFunc)
A class for managing temporary objects.
GeometricFieldExpression(const dimensionSet &dimensions, const orientedType oriented)
static constexpr bool is_leaf
Expression templates for List.
ListTmpWrap< Field< value_type > > CoupledPatchExpr
ListConstTmpWrap< Field< value_type > > CoupledPatchExpr
auto size() const noexcept
UncoupledPatchExpr patchField(const label i) const
void evaluate(ListsRefWrap< E > &exprWarp, const Container &ds)
Assignment of selected elements.
static const List< T > & null() noexcept
Return a null List (reference to a nullObject). Behaves like an empty List.
CoupledPatchExpr coupledPatchField(const label i) const
GeoField this_type
The GeometricField type.
dimensioned< typename typeOfMag< Type >::type > magSqr(const dimensioned< Type > &dt)
g_sqrt< E1 > sqrt(const GenericExpression< E1 > &u)
IntExpr internalField() const
auto size() const noexcept
List_negate< typename E1::IntExpr > IntExpr
Type to return for patchField.
ListConstRefWrap< value_type > IntExpr
Type to return for patchField.