Skip to content

Commit 8086f50

Browse files
committed
2D anisotropic multiply_tnsr_cmpct
1 parent c6eaeea commit 8086f50

File tree

1 file changed

+48
-2
lines changed

1 file changed

+48
-2
lines changed

libmpdata++/formulae/stress_formulae.hpp

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -493,9 +493,32 @@ namespace libmpdataxx
493493
}
494494

495495
// multiplication of compact vector components by variable anisotropic eddy viscosity
496-
// 3D version
497496
// TODO: when used in tensor multiplication, it is not clear which eddy viscosity components should be used for each term; see Simon and Chow 2021 p. 17
498497
// we opt to use the same approach as therein, i.e. horizontal for all diagonal components; this is controlled by the flag vh
498+
// 2D version
499+
template <int nd, opts_t opts, class arrvec_t, class real_t, class arr_t, class ijk_t>
500+
inline void multiply_vctr_cmpct(const arrvec_t &av,
501+
real_t coeff,
502+
const arrvec_t & k_ma,
503+
const arr_t & rho,
504+
const ijk_t &ijk,
505+
const bool vh = false,
506+
typename std::enable_if<nd == 2>::type* = 0)
507+
{
508+
av[0](ijk[0] + h, ijk[1]) *= coeff *
509+
real_t(0.5) * (k_ma[0](ijk[0] + 1, ijk[1]) + k_ma[0](ijk[0], ijk[1])) *
510+
real_t(0.5) * (G<opts, 0>(rho, ijk[0] + 1, ijk[1]) + G<opts, 0>(rho, ijk[0], ijk[1]));
511+
512+
if(!vh)
513+
av[1](ijk[0], ijk[1] + h) *= coeff *
514+
real_t(0.5) * (k_ma[1](ijk[0], ijk[1] + 1) + k_ma[1](ijk[0], ijk[1])) *
515+
real_t(0.5) * (G<opts, 0>(rho, ijk[0], ijk[1] + 1) + G<opts, 0>(rho, ijk[0], ijk[1]));
516+
else
517+
av[1](ijk[0], ijk[1] + h) *= coeff *
518+
real_t(0.5) * (k_ma[0](ijk[0], ijk[1] + 1) + k_ma[0](ijk[0], ijk[1])) *
519+
real_t(0.5) * (G<opts, 0>(rho, ijk[0], ijk[1] + 1) + G<opts, 0>(rho, ijk[0], ijk[1]));
520+
}
521+
// 3D version
499522
template <int nd, opts_t opts, class arrvec_t, class real_t, class arr_t, class ijk_t>
500523
inline void multiply_vctr_cmpct(const arrvec_t &av,
501524
real_t coeff,
@@ -619,9 +642,32 @@ namespace libmpdataxx
619642
}
620643

621644
// multiplication of compact tensor components by variable anisotropic eddy viscosity
622-
// 3D version
623645
// TODO: it is not clear which eddy viscosity components should be used for each term; see Simon and Chow 2021 p. 17
624646
// we opt to use the same approach as therein
647+
// 2D version
648+
template <int nd, opts_t opts, class arrvec_t, class real_t, class arr_t, class ijk_t>
649+
inline void multiply_tnsr_cmpct(const arrvec_t &av,
650+
const real_t coeff,
651+
const arrvec_t &k_ma,
652+
const arr_t &rho,
653+
const ijk_t &ijk,
654+
typename std::enable_if<nd == 2>::type* = 0)
655+
{
656+
multiply_vctr_cmpct<nd, opts>(av, coeff, k_ma, rho, ijk, true);
657+
av[2](ijk[0] + h, ijk[1] + h) *= coeff *
658+
real_t(0.25) * ( k_ma[1](ijk[0] + 1, ijk[1] )
659+
+ k_ma[1](ijk[0] , ijk[1] )
660+
+ k_ma[1](ijk[0] + 1, ijk[1] + 1)
661+
+ k_ma[1](ijk[0] , ijk[1] + 1)
662+
) *
663+
real_t(0.25) * ( G<opts, 0>(rho, ijk[0] + 1, ijk[1] )
664+
+ G<opts, 0>(rho, ijk[0] , ijk[1] )
665+
+ G<opts, 0>(rho, ijk[0] + 1, ijk[1] + 1)
666+
+ G<opts, 0>(rho, ijk[0] , ijk[1] + 1)
667+
);
668+
}
669+
670+
// 3D version
625671
template <int nd, opts_t opts, class arrvec_t, class real_t, class arr_t, class ijk_t>
626672
inline void multiply_tnsr_cmpct(const arrvec_t &av,
627673
const real_t coeff,

0 commit comments

Comments
 (0)