@@ -22,9 +22,10 @@ namespace libmpdataxx
2222 using real_t = typename ct_params_t ::real_t ;
2323
2424 protected:
25+
2526 // member fields
2627 real_t prandtl_num;
27- typename parent_t ::arr_t &rcdsn_num, &full_tht, &tdef_sq, &mix_len, &hflux_srfc;
28+ typename parent_t ::arr_t &rcdsn_num, &full_tht, &tdef_sq, &mix_len, &mix_len_h, &mix_len_v, & hflux_srfc;
2829 arrvec_t <typename parent_t ::arr_t > &grad_tht;
2930
3031 template <int nd = ct_params_t ::n_dims>
@@ -74,20 +75,48 @@ namespace libmpdataxx
7475
7576 calc_rcdsn_num ();
7677
77- this ->k_m (this ->ijk ) = where (
78+ if constexpr (static_cast <sgs_scheme_t >(ct_params_t ::sgs_scheme) == smg)
79+ this ->k_m (this ->ijk ) = where (
7880 rcdsn_num (this ->ijk ) / prandtl_num < 1 ,
7981 pow (this ->smg_c * mix_len (this ->ijk ), 2 )
8082 * sqrt (tdef_sq (this ->ijk ) * (1 - rcdsn_num (this ->ijk ) / prandtl_num)),
8183 0
8284 );
85+ else // smgani
86+ {
87+ this ->k_m [0 ](this ->ijk ) = where (
88+ rcdsn_num (this ->ijk ) / prandtl_num < 1 ,
89+ pow (this ->smg_c * mix_len_h (this ->ijk ), 2 )
90+ * sqrt (tdef_sq (this ->ijk ) * (1 - rcdsn_num (this ->ijk ) / prandtl_num)),
91+ 0
92+ );
93+ this ->k_m [1 ](this ->ijk ) = where (
94+ rcdsn_num (this ->ijk ) / prandtl_num < 1 ,
95+ pow (this ->smg_c * mix_len_v (this ->ijk ), 2 )
96+ * sqrt (tdef_sq (this ->ijk ) * (1 - rcdsn_num (this ->ijk ) / prandtl_num)),
97+ 0
98+ );
99+ }
83100 // one level above surface
84101 auto ijp1 = this ->ijk ;
85102 ijp1.lbound (ct_params_t ::n_dims - 1 ) = 1 ;
86103 ijp1.ubound (ct_params_t ::n_dims - 1 ) = 1 ;
87104
88- this ->k_m (ij) = this ->k_m (ijp1);
105+ if constexpr (static_cast <sgs_scheme_t >(ct_params_t ::sgs_scheme) == smg)
106+ this ->k_m (ij) = this ->k_m (ijp1);
107+ else
108+ {
109+ this ->k_m [0 ](ij) = this ->k_m [0 ](ijp1);
110+ this ->k_m [1 ](ij) = this ->k_m [1 ](ijp1);
111+ }
89112
90- this ->xchng_sclr (this ->k_m , this ->ijk , 1 );
113+ if constexpr (static_cast <sgs_scheme_t >(ct_params_t ::sgs_scheme) == smg)
114+ this ->xchng_sclr (this ->k_m , this ->ijk , 1 );
115+ else
116+ {
117+ this ->xchng_sclr (this ->k_m [0 ], this ->ijk , 1 );
118+ this ->xchng_sclr (this ->k_m [1 ], this ->ijk , 1 );
119+ }
91120
92121 // havo to use modified ijkm due to shared-memory parallelisation, otherwise overlapping ranges
93122 // would lead to double multiplications
@@ -129,10 +158,12 @@ namespace libmpdataxx
129158 prandtl_num (p.prandtl_num),
130159 rcdsn_num (args.mem->tmp[__FILE__][0 ][0 ]),
131160 full_tht (args.mem->tmp[__FILE__][1 ][0 ]),
132- tdef_sq (args.mem->tmp[__FILE__][2 ][0 ]),
133- mix_len (args.mem->tmp[__FILE__][3 ][0 ]),
134- grad_tht (args.mem->tmp[__FILE__][4 ]),
135- hflux_srfc (args.mem->tmp[__FILE__][5 ][0 ])
161+ mix_len (args.mem->tmp[__FILE__][2 ][0 ]),
162+ mix_len_h (args.mem->tmp[__FILE__][3 ][0 ]),
163+ mix_len_v (args.mem->tmp[__FILE__][4 ][0 ]),
164+ grad_tht (args.mem->tmp[__FILE__][5 ]),
165+ hflux_srfc (args.mem->tmp[__FILE__][6 ][0 ]),
166+ tdef_sq (args.mem->tmp[__FILE__][7 ][0 ])
136167 {
137168 // assert(prandtl_num != 0);
138169 }
@@ -142,10 +173,12 @@ namespace libmpdataxx
142173 parent_t::alloc (mem, n_iters);
143174 parent_t::alloc_tmp_sclr (mem, __FILE__, 1 ); // rcdsn_num
144175 parent_t::alloc_tmp_sclr (mem, __FILE__, 1 ); // full_tht
145- parent_t::alloc_tmp_sclr (mem, __FILE__, 1 ); // tdef_sq
146- parent_t::alloc_tmp_sclr (mem, __FILE__, 1 , " mix_len" );
176+ parent_t::alloc_tmp_sclr (mem, __FILE__, 1 , " mix_len" ); // used in smg
177+ parent_t::alloc_tmp_sclr (mem, __FILE__, 1 , " mix_len_h" ); // used in smganiso, needs to be named; TODO: separate smg and smagni into two classes to avoid allocating too much memory
178+ parent_t::alloc_tmp_sclr (mem, __FILE__, 1 , " mix_len_v" ); // ditto
147179 parent_t::alloc_tmp_vctr (mem, __FILE__); // grad_tht
148180 parent_t::alloc_tmp_sclr (mem, __FILE__, 1 , " " , true ); // hflux_srfc
181+ parent_t::alloc_tmp_sclr (mem, __FILE__, 1 ); // tdef_sq
149182 }
150183 };
151184 } // namespace detail
0 commit comments