36 const tmp<LagrangianEqn<Type>>& tA,
37 const tmp<LagrangianEqn<TypeB>>& tB
44 <<
"Operating equations with different meshes"
49 const regIOobject& aPsi =
51 ?
static_cast<const regIOobject&
>(tA().psiSubSubRef_)
53 ?
static_cast<const regIOobject&
>(tA().psiSubSub_)
55 ?
static_cast<const regIOobject&
>(tA().psiSub_)
56 : NullObjectRef<regIOobject>();
57 const regIOobject& bPsi =
59 ?
static_cast<const regIOobject&
>(tB().psiSubSubRef_)
61 ?
static_cast<const regIOobject&
>(tB().psiSubSub_)
63 ?
static_cast<const regIOobject&
>(tB().psiSub_)
64 : NullObjectRef<regIOobject>();
68 <<
"Operating equations with different fields"
75 template<
class OtherType>
78 const tmp<LagrangianEqn<OtherType>>& tOther
81 if (tOther().tDeltaT_.valid())
83 if (!tDeltaT_.valid())
86 tmp<LagrangianSubScalarField>
92 else if (&tDeltaT_() != &tOther().tDeltaT_())
95 <<
"Operating equations with different time-step fields"
103 template<
class OtherType>
106 LagrangianEqn<OtherType>& other
110 other.deltaTSp0Ptr_ = NullObjectPtr<LagrangianDynamicField<scalar>>();
111 other.S0Ptr_ = NullObjectPtr<LagrangianDynamicField<OtherType>>();
116 template<
class OtherType>
119 const tmp<LagrangianEqn<OtherType>>& tOther
124 opClear(tOther.ref());
130 template<
class OtherType>
133 LagrangianEqn<OtherType>& other
137 if (
notNull(other.deltaTSp0Ptr_))
139 LagrangianSubSubField<scalar> deltaTSp0
141 other.mesh().sub(other.deltaTSp0Ptr_->internalField())
146 if (other.deltaTSp.valid()) deltaTSp0 = other.deltaTSp.S();
151 LagrangianSubSubField<Type> S0
153 other.mesh().sub(other.S0Ptr_->internalField())
158 if (other.Su.valid()) S0 += other.Su.S();
159 if (other.Sp.valid()) S0 += other.Sp.Su(other)->S();
167 template<
class OtherType>
170 const tmp<LagrangianEqn<OtherType>>& tOther
175 opFinalise(tOther.ref());
183 template<
template<
class>
class PrimitiveField>
198 deltaTSp0Ptr_(&deltaTSp0),
208 template<
template<
class>
class PrimitiveField>
230 template<
template<
class>
class PrimitiveField>
244 template<
template<
class>
class PrimitiveField>
258 deltaTSp0Ptr_(&deltaTSp0),
268 template<
template<
class>
class PrimitiveField>
282 template<
template<
class>
class PrimitiveField>
308 deltaTSp0Ptr_(&deltaTSp0),
372 tEqn().tDeltaT_.
valid()
376 psiSubSubRef_(tEqn().psiSubSubRef_),
377 psiSubSub_(tEqn().psiSubSub_),
378 psiSub_(tEqn().psiSub_),
382 ? tEqn().deltaTSp0Ptr_
425 tDeltaT_(move(eqn.tDeltaT_)),
426 psiSubSubRef_(eqn.psiSubSubRef_),
427 psiSubSub_(eqn.psiSubSub_),
428 psiSub_(eqn.psiSub_),
429 deltaTSp0Ptr_(eqn.deltaTSp0Ptr_),
431 deltaTSu(move(eqn.deltaTSu)),
432 deltaTSp(move(eqn.deltaTSp)),
461 tA().tDeltaT_.
valid()
467 notNull(tA().psiSubSubRef_) ? tA().psiSubSubRef_
468 :
notNull(tB().psiSubSubRef_) ? tB().psiSubSubRef_
473 notNull(tA().psiSubSub_) ? tA().psiSubSub_
474 :
notNull(tB().psiSubSub_) ? tB().psiSubSub_
479 notNull(tA().psiSub_) ? tA().psiSub_
480 :
notNull(tB().psiSub_) ? tB().psiSub_
533 if (
notNull(tB().deltaTSp0Ptr_))
535 if (
notNull(deltaTSp0Ptr_) && deltaTSp0Ptr_ != tB().deltaTSp0Ptr_)
538 <<
"Operating equations with different previous "
542 if (
isNull(deltaTSp0Ptr_)) deltaTSp0Ptr_ = tB.ref().deltaTSp0Ptr_;
547 if (
notNull(S0Ptr_) && S0Ptr_ != tB().S0Ptr_)
550 <<
"Operating equations with different previous "
554 if (
isNull(S0Ptr_)) S0Ptr_ = tB.ref().S0Ptr_;
564 template<
class EqOp,
class TypeB>
620 if (
notNull(psiSubSub_))
return psiSubSub_;
625 <<
"Requested field from field-less equation"
635 if (
notNull(psiSubSub_))
return psiSubSub_.name();
637 if (
notNull(psiSub_))
return psiSub_.name();
646 if (
notNull(psiSubSub_))
return psiSubSub_.group();
648 if (
notNull(psiSub_))
return psiSub_.group();
655 template<
template<
class>
class PrimitiveField>
665 return &otherPsiIo == &
static_cast<const regIOobject&
>(psiSubSub_);
670 return &otherPsiIo == &
static_cast<const regIOobject&
>(psiSub_);
680 return deltaTSu.valid() || deltaTSp.valid() ||
Su.valid() ||
Sp.valid();
688 if (
Su.valid() && !tDeltaT_.valid())
691 <<
"Cannot evaluate equation " << name_ <<
" for field "
701 if (tDeltaT_.valid()) tResult.
ref() *= tDeltaT_();
702 tResult.
ref() += deltaTSu;
711 if (
Sp.valid() && !tDeltaT_.valid())
714 <<
"Cannot evaluate equation " << name_ <<
" for field "
721 if (tDeltaT_.valid()) tResult.
ref() *= tDeltaT_();
722 tResult.
ref() += deltaTSp;
734 if ((
Su.valid() || tSpH().
valid()) && !tDeltaT_.valid())
737 <<
"Cannot evaluate equation " << name_ <<
" for field "
747 tResult.
ref() += tSpH;
748 if (tDeltaT_.valid()) tResult.
ref() *= tDeltaT_();
749 tResult.
ref() += deltaTSu;
761 if (tSpA().
valid() && !tDeltaT_.valid())
764 <<
"Cannot evaluate equation " << name_ <<
" for field "
773 tResult.
ref() +=
Sp.A();
774 if (tDeltaT_.valid()) tResult.
ref() *= tDeltaT_();
775 tResult.
ref() += deltaTSp;
784 if (!tDeltaT_.valid())
787 <<
"Cannot solve equation " << name_ <<
" for field "
791 if (
isNull(psiSubSubRef_))
794 <<
"Cannot solve equation " << name_ <<
" for constant field "
798 if (!deltaTSp.valid() && !
Sp.valid())
801 <<
"Cannot solve equation " << name_ <<
" for field "
805 if (!deltaTSu.valid() && !
Su.valid())
807 psiSubSubRef_ =
Zero;
811 psiSubSubRef_ = - (allSu()()/allSp()());
815 deltaTSp0Ptr_ = NullObjectPtr<LagrangianDynamicField<scalar>>();
816 S0Ptr_ = NullObjectPtr<LagrangianDynamicField<Type>>();
824 template<
class OtherType>
831 deltaTSp += other.deltaTSp;
838 template<
class OtherType>
850 template<
class OtherType>
857 deltaTSp -= other.deltaTSp;
864 template<
class OtherType>
876 template<
template<
class>
class PrimitiveField>
891 template<
template<
class>
class PrimitiveField>
925 template<
template<
class>
class PrimitiveField>
940 template<
template<
class>
class PrimitiveField>
946 this->operator/=(tS());
977 const tmp<LagrangianEqn<Type>>& tEqn
980 tmp<LagrangianEqn<Type>> tResult(tEqn,
true);
981 tResult.ref().deltaTSu.negate();
982 tResult.ref().deltaTSp.negate();
983 tResult.ref().Su.negate();
984 tResult.ref().Sp.negate();
989 #define LAGRANGIAN_EQN_EQN_OPERATOR(Op, EqOp) \
991 template<class Type, class TypeB> \
992 Foam::tmp<Foam::LagrangianEqn<Type>> Foam::operator Op \
994 const LagrangianEqn<Type>& a, \
995 const LagrangianEqn<TypeB>& b \
998 return tmp<LagrangianEqn<Type>>(a) Op tmp<LagrangianEqn<TypeB>>(b); \
1001 template<class Type, class TypeB> \
1002 Foam::tmp<Foam::LagrangianEqn<Type>> Foam::operator Op \
1004 const tmp<LagrangianEqn<Type>>& tA, \
1005 const LagrangianEqn<TypeB>& b \
1008 return tA Op tmp<LagrangianEqn<TypeB>>(b); \
1011 template<class Type, class TypeB> \
1012 Foam::tmp<Foam::LagrangianEqn<Type>> Foam::operator Op \
1014 const tmp<LagrangianEqn<Type>>& tA, \
1015 const tmp<LagrangianEqn<TypeB>>& tB \
1019 tmp<LagrangianEqn<Type>> \
1021 new LagrangianEqn<Type> \
1027 LagrangianEqn<Type>& a, \
1028 const LagrangianEqn<TypeB>& b \
1037 template<class Type, class TypeB> \
1038 Foam::tmp<Foam::LagrangianEqn<Type>> Foam::operator Op \
1040 const LagrangianEqn<Type>& a, \
1041 const tmp<LagrangianEqn<TypeB>>& tB \
1044 return tmp<LagrangianEqn<Type>>(a) Op tB; \
1047 #define LAGRANGIAN_COMMUTATIVE_EQN_EQN_OPERATOR(Op, EqOp) \
1049 LAGRANGIAN_EQN_EQN_OPERATOR(Op, EqOp) \
1051 template<class Type> \
1052 Foam::tmp<Foam::LagrangianEqn<Type>> Foam::operator Op \
1054 const LagrangianEqn<Type>& a, \
1055 const tmp<LagrangianEqn<Type>>& tB \
1067 #undef LAGRANGIAN_EQN_EQN_OPERATOR
1068 #undef LAGRANGIAN_COMMUTATIVE_EQN_EQN_OPERATOR
1071 #define LAGRANGIAN_EQN_FIELD_OPERATOR(Op, EqOp, LagrangianSubField) \
1073 template<class Type> \
1074 Foam::tmp<Foam::LagrangianEqn<Type>> Foam::operator Op \
1076 const LagrangianEqn<Type>& eqn, \
1077 const LagrangianSubField<Type>& field \
1080 tmp<LagrangianEqn<Type>> tResult(new LagrangianEqn<Type>(eqn)); \
1081 tResult.ref().Su EqOp field; \
1085 template<class Type> \
1086 Foam::tmp<Foam::LagrangianEqn<Type>> Foam::operator Op \
1088 const tmp<LagrangianEqn<Type>>& tEqn, \
1089 const LagrangianSubField<Type>& field \
1092 tmp<LagrangianEqn<Type>> tResult(tEqn, true); \
1093 tResult.ref().Su EqOp field; \
1097 template<class Type> \
1098 Foam::tmp<Foam::LagrangianEqn<Type>> Foam::operator Op \
1100 const tmp<LagrangianEqn<Type>>& tEqn, \
1101 const tmp<LagrangianSubField<Type>>& tField \
1104 tmp<LagrangianEqn<Type>> tResult(tEqn, true); \
1105 tResult.ref().Su EqOp tField; \
1109 template<class Type> \
1110 Foam::tmp<Foam::LagrangianEqn<Type>> Foam::operator Op \
1112 const LagrangianEqn<Type>& eqn, \
1113 const tmp<LagrangianSubField<Type>>& tField \
1116 tmp<LagrangianEqn<Type>> tResult(new LagrangianEqn<Type>(eqn)); \
1117 tResult.ref().Su EqOp tField; \
1121 #define LAGRANGIAN_FIELD_EQN_OPERATOR(Op, EqOp, LagrangianSubField) \
1123 template<class Type> \
1124 Foam::tmp<Foam::LagrangianEqn<Type>> Foam::operator Op \
1126 const LagrangianSubField<Type>& field, \
1127 const LagrangianEqn<Type>& eqn \
1130 tmp<LagrangianEqn<Type>> tResult = \
1131 LagrangianEqn<Type>::NewEmpty(eqn); \
1132 tResult.ref() += field; \
1133 tResult.ref() EqOp eqn; \
1137 template<class Type> \
1138 Foam::tmp<Foam::LagrangianEqn<Type>> Foam::operator Op \
1140 const LagrangianSubField<Type>& field, \
1141 const tmp<LagrangianEqn<Type>>& tEqn \
1144 tmp<LagrangianEqn<Type>> tResult = \
1145 LagrangianEqn<Type>::NewEmpty(tEqn()); \
1146 tResult.ref() += field; \
1147 tResult.ref() EqOp tEqn; \
1151 template<class Type> \
1152 Foam::tmp<Foam::LagrangianEqn<Type>> Foam::operator Op \
1154 const tmp<LagrangianSubField<Type>>& tField, \
1155 const tmp<LagrangianEqn<Type>>& tEqn \
1158 tmp<LagrangianEqn<Type>> tResult = \
1159 LagrangianEqn<Type>::NewEmpty(tEqn()); \
1160 tResult.ref() += tField; \
1161 tResult.ref() EqOp tEqn; \
1165 template<class Type> \
1166 Foam::tmp<Foam::LagrangianEqn<Type>> Foam::operator Op \
1168 const tmp<LagrangianSubField<Type>>& tField, \
1169 const LagrangianEqn<Type>& eqn \
1172 tmp<LagrangianEqn<Type>> tResult = \
1173 LagrangianEqn<Type>::NewEmpty(eqn); \
1174 tResult.ref() += tField; \
1175 tResult.ref() EqOp eqn; \
1197 #undef LAGRANGIAN_EQN_FIELD_OPERATOR
1198 #undef LAGRANGIAN_FIELD_EQN_OPERATOR
1201 #define LAGRANGIAN_EQN_SCALAR_FIELD_OPERATOR(Op, EqOp, LagrangianSubField) \
1203 template<class Type> \
1204 Foam::tmp<Foam::LagrangianEqn<Type>> Foam::operator Op \
1206 const LagrangianEqn<Type>& eqn, \
1207 const LagrangianSubField<scalar>& field \
1210 tmp<LagrangianEqn<Type>> tResult(new LagrangianEqn<Type>(eqn)); \
1211 tResult.ref() EqOp field; \
1215 template<class Type> \
1216 Foam::tmp<Foam::LagrangianEqn<Type>> Foam::operator Op \
1218 const tmp<LagrangianEqn<Type>>& tEqn, \
1219 const LagrangianSubField<scalar>& field \
1222 tmp<LagrangianEqn<Type>> tResult(tEqn, true); \
1223 tResult.ref() EqOp field; \
1227 template<class Type> \
1228 Foam::tmp<Foam::LagrangianEqn<Type>> Foam::operator Op \
1230 const tmp<LagrangianEqn<Type>>& tEqn, \
1231 const tmp<LagrangianSubField<scalar>>& tField \
1234 tmp<LagrangianEqn<Type>> tResult(tEqn, true); \
1235 tResult.ref() EqOp tField; \
1239 template<class Type> \
1240 Foam::tmp<Foam::LagrangianEqn<Type>> Foam::operator Op \
1242 const LagrangianEqn<Type>& eqn, \
1243 const tmp<LagrangianSubField<scalar>>& tField \
1246 tmp<LagrangianEqn<Type>> tResult(new LagrangianEqn<Type>(eqn)); \
1247 tResult.ref() EqOp tField; \
1251 #define LAGRANGIAN_COMMUTATIVE_SCALAR_FIELD_EQN_OPERATOR(Op,LagrangianSubField)\
1253 template<class Type> \
1254 Foam::tmp<Foam::LagrangianEqn<Type>> Foam::operator Op \
1256 const LagrangianSubField<scalar>& field, \
1257 const LagrangianEqn<Type>& eqn \
1260 return eqn Op field; \
1263 template<class Type> \
1264 Foam::tmp<Foam::LagrangianEqn<Type>> Foam::operator Op \
1266 const LagrangianSubField<scalar>& field, \
1267 const tmp<LagrangianEqn<Type>>& tEqn \
1270 return tEqn Op field; \
1273 template<class Type> \
1274 Foam::tmp<Foam::LagrangianEqn<Type>> Foam::operator Op \
1276 const tmp<LagrangianSubField<scalar>>& tField, \
1277 const tmp<LagrangianEqn<Type>>& tEqn \
1280 return tEqn Op tField; \
1283 template<class Type> \
1284 Foam::tmp<Foam::LagrangianEqn<Type>> Foam::operator Op \
1286 const tmp<LagrangianSubField<scalar>>& tField, \
1287 const LagrangianEqn<Type>& eqn \
1290 return eqn Op tField; \
1303 #undef LAGRANGIAN_EQN_SCALAR_FIELD_OPERATOR
1304 #undef LAGRANGIAN_COMMUTATIVE_SCALAR_FIELD_EQN_OPERATOR
#define LAGRANGIAN_EQN_EQN_OPERATOR(Op, EqOp)
#define LAGRANGIAN_COMMUTATIVE_SCALAR_FIELD_EQN_OPERATOR(Op, LagrangianSubField)
#define LAGRANGIAN_COMMUTATIVE_EQN_EQN_OPERATOR(Op, EqOp)
#define LAGRANGIAN_EQN_SCALAR_FIELD_OPERATOR(Op, EqOp, LagrangianSubField)
#define LAGRANGIAN_EQN_FIELD_OPERATOR(Op, EqOp, LagrangianSubField)
#define LAGRANGIAN_FIELD_EQN_OPERATOR(Op, EqOp, LagrangianSubField)
Field with dimensions and associated with geometry type GeoMesh which is used to size the field and a...
Pre-declare SubField and related Field type.
Generic GeometricField class.
Class to store a coefficient of a Lagrangian equation.
Non-templated base class for Lagrangian equations.
This class stores the coefficients of a Lagrangian equation, and facilitates solving that equation an...
word psiGroup() const
Return the field group.
void solve(const bool final)
Solve.
tmp< LagrangianSp< Type > > allSp() const
Return the combined time and non-time implicit coefficient.
bool valid() const
Determine whether this matrix has any valid coefficients.
bool isPsi(const LagrangianSubField< Type, PrimitiveField > &) const
Return whether the given field is that of the equation.
tmp< LagrangianCoeff< scalar, true > > allDiagonalSp() const
Return the combined time and non-time implicit diagonal.
~LagrangianEqn()
Destructor.
friend class LagrangianEqn
Declare friendship with Lagrangian equations of different types.
void operator/=(const LagrangianSubField< scalar, PrimitiveField > &)
Division assignment.
tmp< LagrangianCoeff< Type, false > > allDiagonalSu() const
Return the combined time and non-time explicit diagonal.
tmp< LagrangianSubSubField< Type > > psi() const
Return the field.
void operator*=(const LagrangianSubField< scalar, PrimitiveField > &)
Multiply assignment.
static tmp< LagrangianEqn< Type > > NewEmpty(const LagrangianEqn< Type > &)
Construct from another equation, with empty coefficients.
LagrangianCoeff< Type, false > deltaTSu
Explicit time-coefficient.
const word & psiName() const
Return the field name.
tmp< LagrangianCoeff< Type, false > > allSu() const
Return the combined time and non-time explicit coefficient.
Wrapper around LagrangianCoeff to specialise for the implicit coefficient. Trivial at present....
Mesh that relates to a sub-section of a Lagrangian mesh. This is used to construct fields that relate...
Pre-declare related SubField type.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
A class for managing temporary objects.
T & ref() const
Return non-const reference or generate a fatal error.
A class for handling words, derived from string.
static const word null
An empty word.
A class representing the concept of 0 used to avoid unnecessary manipulations for objects that are kn...
Foam::fvMesh mesh(Foam::IOobject(regionName, runTime.name(), runTime, Foam::IOobject::MUST_READ), false)
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
const volScalarField & psi
bool valid(const PtrList< ModelType > &l)
tmp< VolField< Type > > Su(const VolField< Type > &su, const VolField< Type > &vf)
tmp< VolField< Type > > Sp(const volScalarField &sp, const VolField< Type > &vf)
tmp< fvMatrix< Type > > S(const Pair< tmp< volScalarField::Internal >> &, const VolField< Type > &)
errorManipArg< error, int > exit(error &err, const int errNo=1)
DimensionedField< Type, LagrangianSubMesh, PrimitiveField > LagrangianSubField
DimensionedField< Type, LagrangianSubMesh, SubField > LagrangianSubSubField
void operator*=(Other &, const oneOrTmp< Type > &)
Multiply-assign with an object.
bool notNull(const T &t)
Return true if t is not a reference to the nullObject of type T.
T * NullObjectPtr()
Return pointer to the nullObject of type T.
const T & NullObjectRef()
Return const reference to the nullObject of type T.
T & NullObjectNonConstRef()
Return non-const reference to the nullObject of type T.
word name(const LagrangianState state)
Return a string representation of a Lagrangian state enumeration.
bool isNull(const T &t)
Return true if t is a reference to the nullObject of type T.
void operator+=(fvMatrix< Type > &fvEqn, const CarrierEqn< Type > &cEqn)
Add to a finite-volume equation.
void operator-=(fvMatrix< Type > &fvEqn, const CarrierEqn< Type > &cEqn)
Subtract from a finite-volume equation.
tmp< DimensionedField< Type, GeoMesh, SubField > > toSubField(const DimensionedField< Type, GeoMesh, Field > &)
Return a temporary sub-field from a reference to a field.
Functions to cast/convert dimensioned field references and temporaries based on a primitive field to ...