33 if (tensorCoeff_.valid())
return;
35 if (!scalarCoeff_.valid())
return;
37 tensorCoeff_ +=
tensor::I*scalarCoeff_.S();
54 const LagrangianEqnBase& eqn,
55 const LagrangianSp<vector>& coeff
58 tmp<LagrangianSp<
vector>>::refCount(),
59 scalarCoeff_(eqn, coeff.scalarCoeff_),
60 tensorCoeff_(eqn, coeff.tensorCoeff_)
66 const LagrangianEqnBase& eqn,
67 LagrangianSp<vector>& coeff,
71 scalarCoeff_(eqn, coeff.scalarCoeff_, reuse),
72 tensorCoeff_(eqn, coeff.tensorCoeff_, reuse)
78 tmp<LagrangianSp<
vector>>::refCount(),
79 scalarCoeff_(move(coeff.scalarCoeff_)),
80 tensorCoeff_(move(coeff.tensorCoeff_))
88 return scalarCoeff_.eqn();
96 || tensorCoeff_.valid();
102 scalarCoeff_.negate();
103 tensorCoeff_.negate();
112 ? tmp<LagrangianCoeff<scalar, true>>
114 new LagrangianCoeff<scalar, true>
117 (1.0/3.0)*
tr(tensorCoeff_.S())
120 : tmp<LagrangianCoeff<scalar, true>>(scalarCoeff_);
127 const LagrangianEqn<vector>& eqn =
128 static_cast<const LagrangianEqn<vector>&
>(this->eqn());
131 tmp<LagrangianCoeff<vector, false>>
134 ?
new LagrangianCoeff<vector, false>
137 dev2(tensorCoeff_.S()) & eqn.psi()
139 : new LagrangianCoeff<
vector, false>(eqn)
147 return Su(
static_cast<const LagrangianEqn<vector>&
>(this->eqn()));
155 tmp<LagrangianCoeff<vector, false>>
158 ?
new LagrangianCoeff<vector, false>
162 ? tensorCoeff_.S() & eqn.psi()
163 : scalarCoeff_.S()*eqn.psi()
165 : new LagrangianCoeff<
vector, false>(eqn)
174 const LagrangianCoeff<scalar, true>& coeff
177 if (!coeff.valid())
return;
184 const LagrangianCoeff<tensor, true>& coeff
187 if (!coeff.valid())
return;
194 const LagrangianSp<vector>&
Sp
197 if (
Sp.tensorCoeff_.valid())
201 if (
Sp.scalarCoeff_.valid())
210 if (tensorCoeff_.valid())
234 const LagrangianCoeff<scalar, true>& coeff
237 if (!coeff.valid())
return;
244 const LagrangianCoeff<tensor, true>& coeff
247 if (!coeff.valid())
return;
254 const LagrangianSp<vector>&
Sp
257 if (
Sp.tensorCoeff_.valid())
261 if (
Sp.scalarCoeff_.valid())
270 if (tensorCoeff_.valid())
314 if (
Sp.tensorCoeff_.valid())
316 return inv(
Sp.tensorCoeff_.S()) &
Su.S();
320 return Su.S()/
Sp.scalarCoeff_.S();
Class to store a coefficient of a Lagrangian equation.
bool valid() const
Determine whether this coefficient has values or not.
const LagrangianEqnBase & eqn() const
Access the equation.
void operator/=(const LagrangianSubField< scalar, PrimitiveField > &)
Division assignment.
void operator*=(const LagrangianSubField< scalar, PrimitiveField > &)
Multiply assignment.
void negate()
In-place negation.
Non-templated base class for Lagrangian equations.
Wrapper around LagrangianCoeff to specialise for the implicit coefficient. Trivial at present....
tmp< LagrangianCoeff< Type, false > > H() const
Return the scalar off-diagonal coefficients.
tmp< LagrangianCoeff< Type, false > > Su() const
Return the equivalent explicit coefficient.
tmp< LagrangianCoeff< scalar, true > > A() const
Return the scalar diagonal coefficient.
void operator+=(const LagrangianSp< OtherType > &)
Addition assignment.
LagrangianSp(const LagrangianEqnBase &, const LagrangianSp< Type > &Sp)
Construct as copy.
void operator-=(const LagrangianSp< OtherType > &Sp)
Subtraction assignment.
A class for managing temporary objects.
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)
void dev2(pointPatchField< tensor > &, const pointPatchField< tensor > &)
static const Identity< scalar > I
void tr(pointPatchField< scalar > &, const pointPatchField< tensor > &)
Vector< scalar > vector
A scalar version of the templated Vector.
void inv(pointPatchField< tensor > &, const pointPatchField< tensor > &)
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.