mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
BUG: array-bound error for SphericalTensor component-wise functions
STYEL: use constexpr for VectorSpaceOps
This commit is contained in:
@ -157,6 +157,34 @@ inline Cmpt magSqr(const SphericalTensor<Cmpt>& st)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Cmpt>
|
||||||
|
inline Cmpt cmptMax(const SphericalTensor<Cmpt>& st)
|
||||||
|
{
|
||||||
|
return st.ii();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Cmpt>
|
||||||
|
inline Cmpt cmptMin(const SphericalTensor<Cmpt>& st)
|
||||||
|
{
|
||||||
|
return st.ii();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Cmpt>
|
||||||
|
inline Cmpt cmptSum(const SphericalTensor<Cmpt>& st)
|
||||||
|
{
|
||||||
|
return 3*st.ii();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
template<class Cmpt>
|
||||||
|
inline Cmpt cmptAv(const SphericalTensor<Cmpt>& st)
|
||||||
|
{
|
||||||
|
return st.ii();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
//- Return the trace of a spherical tensor
|
//- Return the trace of a spherical tensor
|
||||||
template<class Cmpt>
|
template<class Cmpt>
|
||||||
inline Cmpt tr(const SphericalTensor<Cmpt>& st)
|
inline Cmpt tr(const SphericalTensor<Cmpt>& st)
|
||||||
|
|||||||
@ -44,27 +44,37 @@ class VectorSpaceOps
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
||||||
static const int endLoop = (I < N-1) ? 1 : 0;
|
//- End for next loop. Is 0 for loop termination.
|
||||||
|
static constexpr direction loopN() noexcept
|
||||||
|
{
|
||||||
|
return (I+1 < N) ? N : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//- Index for next loop. Is 0 for loop termination.
|
||||||
|
static constexpr direction loopI1() noexcept
|
||||||
|
{
|
||||||
|
return (I+1 < N) ? I+1 : 0;
|
||||||
|
}
|
||||||
|
|
||||||
template<class V, class S, class EqOp>
|
template<class V, class S, class EqOp>
|
||||||
static inline void eqOpS(V& vs, const S& s, EqOp eo)
|
static inline void eqOpS(V& vs, const S& s, EqOp eo)
|
||||||
{
|
{
|
||||||
eo(vs.v_[I], s);
|
eo(vs.v_[I], s);
|
||||||
VectorSpaceOps<endLoop*N, endLoop*(I+1)>::eqOpS(vs, s, eo);
|
VectorSpaceOps<loopN(), loopI1()>::eqOpS(vs, s, eo);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class S, class V, class EqOp>
|
template<class S, class V, class EqOp>
|
||||||
static inline void SeqOp(S& s, const V& vs, EqOp eo)
|
static inline void SeqOp(S& s, const V& vs, EqOp eo)
|
||||||
{
|
{
|
||||||
eo(s, vs.v_[I]);
|
eo(s, vs.v_[I]);
|
||||||
VectorSpaceOps<endLoop*N, endLoop*(I+1)>::SeqOp(s, vs, eo);
|
VectorSpaceOps<loopN(), loopI1()>::SeqOp(s, vs, eo);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class V1, class V2, class EqOp>
|
template<class V1, class V2, class EqOp>
|
||||||
static inline void eqOp(V1& vs1, const V2& vs2, EqOp eo)
|
static inline void eqOp(V1& vs1, const V2& vs2, EqOp eo)
|
||||||
{
|
{
|
||||||
eo(vs1.v_[I], vs2.v_[I]);
|
eo(vs1.v_[I], vs2.v_[I]);
|
||||||
VectorSpaceOps<endLoop*N, endLoop*(I+1)>::eqOp(vs1, vs2, eo);
|
VectorSpaceOps<loopN(), loopI1()>::eqOp(vs1, vs2, eo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -72,25 +82,26 @@ public:
|
|||||||
static inline void opVS(V& vs, const V1& vs1, const S& s, Op o)
|
static inline void opVS(V& vs, const V1& vs1, const S& s, Op o)
|
||||||
{
|
{
|
||||||
vs.v_[I] = o(vs1.v_[I], s);
|
vs.v_[I] = o(vs1.v_[I], s);
|
||||||
VectorSpaceOps<endLoop*N, endLoop*(I+1)>::opVS(vs, vs1, s, o);
|
VectorSpaceOps<loopN(), loopI1()>::opVS(vs, vs1, s, o);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class V, class S, class V1, class Op>
|
template<class V, class S, class V1, class Op>
|
||||||
static inline void opSV(V& vs, const S& s, const V1& vs1, Op o)
|
static inline void opSV(V& vs, const S& s, const V1& vs1, Op o)
|
||||||
{
|
{
|
||||||
vs.v_[I] = o(s, vs1.v_[I]);
|
vs.v_[I] = o(s, vs1.v_[I]);
|
||||||
VectorSpaceOps<endLoop*N, endLoop*(I+1)>::opSV(vs, s, vs1, o);
|
VectorSpaceOps<loopN(), loopI1()>::opSV(vs, s, vs1, o);
|
||||||
}
|
}
|
||||||
|
|
||||||
template<class V, class V1, class Op>
|
template<class V, class V1, class Op>
|
||||||
static inline void op(V& vs, const V1& vs1, const V1& vs2, Op o)
|
static inline void op(V& vs, const V1& vs1, const V1& vs2, Op o)
|
||||||
{
|
{
|
||||||
vs.v_[I] = o(vs1.v_[I], vs2.v_[I]);
|
vs.v_[I] = o(vs1.v_[I], vs2.v_[I]);
|
||||||
VectorSpaceOps<endLoop*N, endLoop*(I+1)>::op(vs, vs1, vs2, o);
|
VectorSpaceOps<loopN(), loopI1()>::op(vs, vs1, vs2, o);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
//- Specialization for loop termination of vector space ops
|
||||||
template<>
|
template<>
|
||||||
class VectorSpaceOps<0, 0>
|
class VectorSpaceOps<0, 0>
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user