174 const int numDOFs = args.
scalar<
int>(
"numDOFs");
175 const xt::pyarray<int> &csrRowIndeces_DofLoops =
176 args.
array<
int>(
"csrRowIndeces_DofLoops");
177 const xt::pyarray<int> &csrColumnOffsets_DofLoops =
178 args.
array<
int>(
"csrColumnOffsets_DofLoops");
179 const xt::pyarray<double> &MassMatrix = args.
array<
double>(
"MassMatrix");
180 const xt::pyarray<double> &lumped_mass_matrix =
181 args.
array<
double>(
"lumped_mass_matrix");
182 const double dt = args.
scalar<
double>(
"dt");
183 const xt::pyarray<double> &h_old = args.
array<
double>(
"h_old");
184 const xt::pyarray<double> &hu_old = args.
array<
double>(
"hu_old");
185 const xt::pyarray<double> &hv_old = args.
array<
double>(
"hv_old");
186 const xt::pyarray<double> &heta_old = args.
array<
double>(
"heta_old");
187 const xt::pyarray<double> &hw_old = args.
array<
double>(
"hw_old");
188 const xt::pyarray<double> &hbeta_old = args.
array<
double>(
"hbeta_old");
189 const xt::pyarray<double> &b_dof = args.
array<
double>(
"b_dof");
190 xt::pyarray<double> &limited_hnp1 = args.
array<
double>(
"limited_hnp1");
191 xt::pyarray<double> &limited_hunp1 = args.
array<
double>(
"limited_hunp1");
192 xt::pyarray<double> &limited_hvnp1 = args.
array<
double>(
"limited_hvnp1");
193 xt::pyarray<double> &limited_hetanp1 =
194 args.
array<
double>(
"limited_hetanp1");
195 xt::pyarray<double> &limited_hwnp1 = args.
array<
double>(
"limited_hwnp1");
196 xt::pyarray<double> &limited_hbetanp1 =
197 args.
array<
double>(
"limited_hbetanp1");
198 const double hEps = args.
scalar<
double>(
"hEps");
199 xt::pyarray<double> &hLow = args.
array<
double>(
"hLow");
200 xt::pyarray<double> &huLow = args.
array<
double>(
"huLow");
201 xt::pyarray<double> &hvLow = args.
array<
double>(
"hvLow");
202 xt::pyarray<double> &hetaLow = args.
array<
double>(
"hetaLow");
203 xt::pyarray<double> &hwLow = args.
array<
double>(
"hwLow");
204 xt::pyarray<double> &hbetaLow = args.
array<
double>(
"hbetaLow");
205 const xt::pyarray<double> &h_min = args.
array<
double>(
"h_min");
206 const xt::pyarray<double> &h_max = args.
array<
double>(
"h_max");
207 const xt::pyarray<double> &heta_min = args.
array<
double>(
"heta_min");
208 const xt::pyarray<double> &heta_max = args.
array<
double>(
"heta_max");
209 const xt::pyarray<double> &kin_max = args.
array<
double>(
"kin_max");
210 const double KE_tiny = args.
scalar<
double>(
"KE_tiny");
211 const xt::pyarray<double> &SourceTerm_h =
212 args.
array<
double>(
"SourceTerm_h");
213 const xt::pyarray<double> &SourceTerm_hu =
214 args.
array<
double>(
"SourceTerm_hu");
215 const xt::pyarray<double> &SourceTerm_hv =
216 args.
array<
double>(
"SourceTerm_hv");
217 const xt::pyarray<double> &SourceTerm_heta =
218 args.
array<
double>(
"SourceTerm_heta");
219 const xt::pyarray<double> &SourceTerm_hw =
220 args.
array<
double>(
"SourceTerm_hw");
221 const xt::pyarray<double> &SourceTerm_hbeta =
222 args.
array<
double>(
"SourceTerm_hbeta");
223 const xt::pyarray<double> &global_entropy_residual =
224 args.
array<
double>(
"global_entropy_residual");
225 const xt::pyarray<double> &Cx = args.
array<
double>(
"Cx");
226 const xt::pyarray<double> &Cy = args.
array<
double>(
"Cy");
227 const xt::pyarray<double> &CTx = args.
array<
double>(
"CTx");
228 const xt::pyarray<double> &CTy = args.
array<
double>(
"CTy");
229 const xt::pyarray<double> &RHS_high_h = args.
array<
double>(
"RHS_high_h");
230 const xt::pyarray<double> &RHS_high_hu = args.
array<
double>(
"RHS_high_hu");
231 const xt::pyarray<double> &RHS_high_hv = args.
array<
double>(
"RHS_high_hv");
232 const xt::pyarray<double> &RHS_high_heta =
233 args.
array<
double>(
"RHS_high_heta");
234 const xt::pyarray<double> &RHS_high_hw = args.
array<
double>(
"RHS_high_hw");
235 const xt::pyarray<double> &RHS_high_hbeta =
236 args.
array<
double>(
"RHS_high_hbeta");
237 const xt::pyarray<double> &extendedSourceTerm_hu =
238 args.
array<
double>(
"extendedSourceTerm_hu");
239 const xt::pyarray<double> &extendedSourceTerm_hv =
240 args.
array<
double>(
"extendedSourceTerm_hv");
241 const xt::pyarray<double> &thetaj_inv = args.
array<
double>(
"thetaj_inv");
242 const xt::pyarray<double> &wall_dof = args.
array<
double>(
"wall_dof");
243 const xt::pyarray<double> &porosity_dof = args.
array<
double>(
"porosity_dof");
244 const double g = args.
scalar<
double>(
"g");
245 const xt::pyarray<double> &inverse_mesh =
246 args.
array<
double>(
"inverse_mesh");
249 std::valarray<double> FCT_h(0., Cx.size()), FCT_hu(0., Cx.size()),
250 FCT_hv(0., Cx.size()), FCT_heta(0., Cx.size()), FCT_hw(0., Cx.size()),
251 FCT_hbeta(0., Cx.size());
257 const int limit_iter_arg = args.
scalar<
int>(
"limit_iter");
258 const int n_limit_iter = args.
scalar<
int>(
"n_limit_iter");
259 xt::pyarray<double> &FCT_all = args.
array<
double>(
"FCT_all");
260 const std::size_t nnz_fct = Cx.size();
266 for (
int i = 0; i < numDOFs && limit_iter_arg == 0; i++) {
268 const double hi = h_old[i];
269 const double one_over_hi =
270 2. * hi / (hi * hi + std::pow(fmax(hi, hEps), 2));
271 const double hui = hu_old[i];
272 const double ui = hui * one_over_hi;
273 const double hvi = hv_old[i];
274 const double vi = hvi * one_over_hi;
275 const double hetai = heta_old[i];
276 const double hwi = hw_old[i];
277 const double hbetai = hbeta_old[i];
278 const double Zi = b_dof[i];
279 const double mi = lumped_mass_matrix[i];
280 const double inv_meshSizei = inverse_mesh[i];
283 for (
int offset = csrRowIndeces_DofLoops[i];
284 offset < csrRowIndeces_DofLoops[i + 1]; offset++) {
285 int j = csrColumnOffsets_DofLoops[offset];
296 const double hj = h_old[j];
297 const double one_over_hj =
298 2. * hj / (hj * hj + std::pow(fmax(hj, hEps), 2));
299 const double huj = hu_old[j];
300 const double uj = huj * one_over_hj;
301 const double hvj = hv_old[j];
302 const double vj = hvj * one_over_hj;
303 const double hetaj = heta_old[j];
304 const double hwj = hw_old[j];
305 const double hbetaj = hbeta_old[j];
306 const double Zj = b_dof[j];
307 const double mj = lumped_mass_matrix[j];
308 const double inv_meshSizej = inverse_mesh[j];
311 const double hStarij = fmax(0., hi + Zi - fmax(Zi, Zj));
312 const double hStarji = fmax(0., hj + Zj - fmax(Zi, Zj));
314 const double hStar_ratio_i = hStarij * one_over_hi;
315 const double hStar_ratio_j = hStarji * one_over_hj;
317 const double huStarij = hui * hStar_ratio_i;
318 const double hvStarij = hvi * hStar_ratio_i;
319 const double hetaStarij = hetai * std::pow(hStar_ratio_i, 2);
320 const double hwStarij = hwi * hStar_ratio_i;
321 const double hbetaStarij = hbetai * hStar_ratio_i;
323 const double huStarji = huj * hStar_ratio_j;
324 const double hvStarji = hvj * hStar_ratio_j;
325 const double hetaStarji = hetaj * std::pow(hStar_ratio_j, 2);
326 const double hwStarji = hwj * hStar_ratio_j;
327 const double hbetaStarji = hbetaj * hStar_ratio_j;
329 const double b_ij = 0. - MassMatrix[ij] / mj;
330 const double b_ji = 0. - MassMatrix[ij] / mi;
334 const double cij_norm = sqrt(Cx[ij] * Cx[ij] + Cy[ij] * Cy[ij]);
335 const double cji_norm = sqrt(CTx[ij] * CTx[ij] + CTy[ij] * CTy[ij]);
336 const double nxij = Cx[ij] / cij_norm;
337 const double nyij = Cy[ij] / cij_norm;
338 const double nxji = CTx[ij] / cji_norm;
339 const double nyji = CTy[ij] / cji_norm;
341 double cxa, cya, cxaT, cyaT;
342 wallCoefficients(i, j, ij, wall_dof, Cx, Cy, CTx, CTy, cxa, cya,
344 const double phibar_ij =
phiBar(i, j, porosity_dof);
345 const double muijL = phibar_ij * fmax(std::abs(ui * cxa + vi * cya),
346 std::abs(uj * cxaT + vj * cyaT));
347 double dijL = phibar_ij * fmax(
349 inv_meshSizei, hj, huj, hvj, hetaj,
350 inv_meshSizej, hEps) *
353 inv_meshSizej, hi, hui, hvi, hetai,
354 inv_meshSizei, hEps) *
358 dijL = std::max(dijL, muijL);
363 std::max(global_entropy_residual[i], global_entropy_residual[j]);
365 const double dijH = std::min(dijL, dEVij);
366 const double muijH = std::min(muijL, dEVij);
368 const double diff_dij_muij = (dijH - dijL) - (muijH - muijL);
369 const double diff_muij = (muijH - muijL);
372 double viscous_terms =
373 diff_dij_muij * (hStarji - hStarij) + diff_muij * (hj - hi);
374 FCT_h[ij] = dt * (b_ij * RHS_high_h[j] - b_ji * RHS_high_h[i] +
378 diff_dij_muij * (huStarji - huStarij) + diff_muij * (huj - hui);
379 FCT_hu[ij] = dt * (b_ij * RHS_high_hu[j] - b_ji * RHS_high_hu[i] +
383 diff_dij_muij * (hvStarji - hvStarij) + diff_muij * (hvj - hvi);
384 FCT_hv[ij] = dt * (b_ij * RHS_high_hv[j] - b_ji * RHS_high_hv[i] +
387 viscous_terms = diff_dij_muij * (hetaStarji - hetaStarij) +
388 diff_muij * (hetaj - hetai);
389 FCT_heta[ij] = dt * (b_ij * RHS_high_heta[j] -
390 b_ji * RHS_high_heta[i] + viscous_terms);
393 diff_dij_muij * (hwStarji - hwStarij) + diff_muij * (hwj - hwi);
394 FCT_hw[ij] = dt * (b_ij * RHS_high_hw[j] - b_ji * RHS_high_hw[i] +
397 viscous_terms = diff_dij_muij * (hbetaStarji - hbetaStarij) +
398 diff_muij * (hbetaj - hbetai);
399 FCT_hbeta[ij] = dt * (b_ij * RHS_high_hbeta[j] -
400 b_ji * RHS_high_hbeta[i] + viscous_terms);
412 if (limit_iter_arg > 0) {
413 for (std::size_t k = 0; k < nnz_fct; k++) {
414 FCT_h[k] = FCT_all[0 * nnz_fct + k];
415 FCT_hu[k] = FCT_all[1 * nnz_fct + k];
416 FCT_hv[k] = FCT_all[2 * nnz_fct + k];
417 FCT_heta[k] = FCT_all[3 * nnz_fct + k];
418 FCT_hw[k] = FCT_all[4 * nnz_fct + k];
419 FCT_hbeta[k] = FCT_all[5 * nnz_fct + k];
424 std::valarray<double> Lij_array(1., Cx.size());
427 const double eps = 1e-14;
430 for (
int limit_iter = limit_iter_arg; limit_iter < limit_iter_arg + 1;
435 for (
int i = 0; i < numDOFs; i++) {
438 const double hLowi = hLow[i];
439 const double huLowi = huLow[i];
440 const double hvLowi = hvLow[i];
441 const double hetaLowi = hetaLow[i];
442 const double kinMaxi = kin_max[i];
443 const double mi = lumped_mass_matrix[i];
446 for (
int offset = csrRowIndeces_DofLoops[i];
447 offset < csrRowIndeces_DofLoops[i + 1]; offset++) {
448 int j = csrColumnOffsets_DofLoops[offset];
453 const double hLowj = hLow[j];
454 const double huLowj = huLow[j];
455 const double hvLowj = hvLow[j];
456 const double hetaLowj = hetaLow[j];
457 const double kinMaxj = kin_max[j];
458 const double mj = lumped_mass_matrix[j];
461 double denom = 1. / (mi * thetaj_inv[i]);
462 const double P_h = FCT_h[ij] * denom;
463 const double P_hu = FCT_hu[ij] * denom;
464 const double P_hv = FCT_hv[ij] * denom;
465 const double P_heta = FCT_heta[ij] * denom;
467 denom = 1. / (mj * thetaj_inv[j]);
468 const double P_h_tr = -FCT_h[ij] * denom;
469 const double P_hu_tr = -FCT_hu[ij] * denom;
470 const double P_hv_tr = -FCT_hv[ij] * denom;
471 const double P_heta_tr = -FCT_heta[ij] * denom;
474 double l_ji_h = Lij_array[ij];
476 const double denominator = 1. / (std::abs(P_h) + eps * h_max[i]);
479 if (hLowi + P_h < h_min[i]) {
480 l_ji_h = std::min((std::abs(h_min[i] - hLowi) + eps * h_min[i]) *
483 }
else if (h_max[i] < hLowi + P_h) {
484 l_ji_h = std::min((std::abs(h_max[i] - hLowi) + eps * h_min[i]) *
490 l_ji_h = (hLowi <= hEps) ? 0. : l_ji_h;
493 l_ji_h = std::min(l_ji_h, 1.);
494 l_ji_h = std::max(l_ji_h, 0.);
496#if IF_LIMITING_DEBUGGING
497 if ((hLowi + l_ji_h * P_h) - h_min[i] < -1e-12) {
498 std::cout <<
" MAJOR BUG 1a " << std::setprecision(15) <<
" \n "
499 <<
" Diff = " << (hLowi + l_ji_h * P_h) - h_min[i]
501 <<
" hLowi = " << hLowi <<
" \n "
502 <<
" h_min = " << h_min[i] <<
" \n "
503 <<
" h_max = " << h_max[i] <<
" \n "
504 <<
" l_ji_h = " << l_ji_h << std::endl;
505 std::cout <<
"LIMIT_ITER " << limit_iter << std::endl;
509 if (h_max[i] - (hLowi + l_ji_h * P_h) < -1e-12) {
510 std::cout <<
" MAJOR BUG 1b " << std::setprecision(15) <<
" \n "
511 <<
" Diff = " << h_max[i] - (hLowi + l_ji_h * P_h)
513 <<
" Soln = " << (hLowi + P_h) <<
" \n "
514 <<
" hLowi = " << hLowi <<
" \n "
515 <<
" h_min = " << h_min[i] <<
" \n "
516 <<
" h_max = " << h_max[i] <<
" \n "
517 <<
" P_h = " << P_h <<
" \n "
518 <<
" l_ji_h = " << l_ji_h << std::endl;
519 std::cout <<
"LIMIT_ITER " << limit_iter << std::endl;
526 double l_ij_h = Lij_array[ij];
528 const double denominator_test =
529 1. / (std::abs(P_h_tr) + eps * h_max[j]);
531 if (hLowj + P_h_tr < h_min[j]) {
532 l_ij_h = std::min((std::abs(h_min[j] - hLowj) + eps * h_min[j]) *
535 }
else if (h_max[j] < hLowj + P_h_tr) {
536 l_ij_h = std::min((std::abs(h_max[j] - hLowj) + eps * h_min[j]) *
542 l_ij_h = (hLowj <= hEps) ? 0. : l_ij_h;
545 l_ij_h = std::min(l_ij_h, 1.);
546 l_ij_h = std::max(l_ij_h, 0.);
548#if IF_LIMITING_DEBUGGING
549 if ((hLowj + l_ij_h * P_h_tr) - h_min[j] < -1e-12) {
550 std::cout <<
" MAJOR BUG 2a " << std::setprecision(15) <<
" \n "
551 <<
" Diff = " << h_min[j] - (hLowj + l_ij_h * P_h_tr)
553 <<
" Soln = " << (hLowj + P_h_tr) <<
" \n "
554 <<
" hLowj = " << hLowj <<
" \n "
555 <<
" h_min = " << h_min[j] <<
" \n "
556 <<
" h_max = " << h_max[j] <<
" \n "
557 <<
" P_h_tr = " << P_h_tr <<
" \n "
558 <<
" l_ij_h = " << l_ij_h << std::endl;
559 std::cout <<
"LIMIT_ITER " << limit_iter << std::endl;
563 if (h_max[j] - (hLowj + l_ij_h * P_h_tr) < -1e-12) {
564 std::cout <<
" MAJOR BUG 2b " << std::setprecision(15) <<
" \n "
565 <<
" Diff = " << h_max[j] - (hLowj + l_ij_h * P_h_tr)
567 <<
" Soln = " << (hLowj + P_h_tr) <<
" \n "
568 <<
" hLowj = " << hLowj <<
" \n "
569 <<
" h_min = " << h_min[j] <<
" \n "
570 <<
" h_max = " << h_max[j] <<
" \n "
571 <<
" P_h_tr = " << P_h_tr <<
" \n "
572 <<
" l_ij_h = " << l_ij_h << std::endl;
573 std::cout <<
"LIMIT_ITER " << limit_iter << std::endl;
580 double l_ji_q1 = l_ji_h;
582 const double denominator =
583 1. / (std::abs(P_heta) + eps * heta_max[i]);
586 if (hetaLowi + P_heta < heta_min[i]) {
588 (std::abs(heta_min[i] - hetaLowi) + eps * heta_min[i]) *
591 }
else if (heta_max[i] < hetaLowi + P_heta) {
593 (std::abs(heta_max[i] - hetaLowi) + eps * heta_min[i]) *
599 l_ji_q1 = (hLowi <= hEps) ? 0. : l_ji_q1;
602 l_ji_q1 = std::min(l_ji_q1, l_ji_h);
605 l_ji_q1 = std::min(l_ji_q1, 1.);
606 l_ji_q1 = std::max(l_ji_q1, 0.);
608#if IF_LIMITING_DEBUGGING
609 if ((hetaLowi + l_ji_q1 * P_heta) - heta_min[i] < -hEps * hEps) {
610 std::cout <<
" MAJOR BUG 3a " << std::setprecision(15) <<
" \n "
611 <<
"New soln " << hetaLowi + l_ji_q1 * P_heta <<
" \n "
612 <<
"hetaLowi " << hetaLowi <<
" \n "
613 <<
"heta_min " << heta_min[i] <<
" \n "
614 <<
"heta_max " << heta_max[i] <<
" \n "
615 <<
"l_ji_q1 " << l_ji_q1 <<
" \n "
616 <<
"test hi " << hLowi << std::endl;
617 if (heta_max[i] > -hEps)
621 if (heta_max[i] - (hetaLowi + l_ji_q1 * P_heta) < -hEps * hEps) {
622 std::cout <<
" MAJOR BUG 3b " << std::setprecision(15) <<
" \n "
623 <<
"New soln " << hetaLowi + l_ji_q1 * P_heta <<
" \n "
624 <<
"hetaLowi " << hetaLowi <<
" \n "
625 <<
"heta_min " << heta_min[i] <<
" \n "
626 <<
"heta_max " << heta_max[i] <<
" \n "
627 <<
"l_ji_q1 " << l_ji_q1 <<
" \n "
628 <<
"test hi " << hLowi << std::endl;
629 if (heta_max[i] > -hEps)
636 double l_ij_q1 = l_ij_h;
638 const double denominator =
639 1. / (std::abs(P_heta_tr) + eps * heta_max[j]);
641 if (hetaLowj + P_heta_tr < heta_min[j]) {
643 (std::abs(heta_min[j] - hetaLowj) + eps * heta_min[j]) *
646 }
else if (heta_max[j] < hetaLowj + P_heta_tr) {
648 (std::abs(heta_max[j] - hetaLowj) + eps * heta_min[j]) *
654 l_ij_q1 = (hLowj <= hEps) ? 0. : l_ij_q1;
657 l_ij_q1 = std::min(l_ij_q1, l_ij_h);
660 l_ij_q1 = std::min(l_ij_q1, 1.0);
661 l_ij_q1 = std::max(l_ij_q1, 0.0);
664#if IF_LIMITING_DEBUGGING
665 if ((hetaLowj + l_ij_q1 * P_heta_tr) - heta_min[j] < -hEps * hEps) {
666 std::cout <<
" MAJOR BUG 4a " << std::setprecision(15) <<
" \n "
667 <<
"New soln " << hetaLowj + l_ij_q1 * P_heta_tr <<
" \n "
668 <<
"hetaLowj " << hetaLowj <<
" \n "
669 <<
"heta_min " << heta_min[j] <<
" \n "
670 <<
"heta_max " << heta_max[j] <<
" \n "
671 <<
"l_ij_q1 " << l_ij_q1 <<
" \n "
672 <<
"test hj " << hLowj << std::endl;
673 if (heta_max[j] > -hEps)
677 if (heta_max[j] - (hetaLowj + l_ij_q1 * P_heta_tr) < -hEps * hEps) {
678 std::cout <<
" MAJOR BUG 4b " << std::setprecision(15) <<
" \n "
679 <<
"New soln " << hetaLowj + l_ij_q1 * P_heta_tr <<
" \n "
680 <<
"hetaLowj " << hetaLowj <<
" \n "
681 <<
"heta_min " << heta_min[j] <<
" \n "
682 <<
"heta_max " << heta_max[j] <<
" \n "
683 <<
"l_ij_q1 " << l_ij_q1 <<
" \n "
684 <<
"test hj " << hLowj << std::endl;
685 if (heta_max[j] > -hEps)
692 double l_ji_K = l_ji_q1;
695 const double h_r = hLowi + l_ji_K * P_h;
696 const double hu_r = huLowi + l_ji_K * P_hu;
697 const double hv_r = hvLowi + l_ji_K * P_hv;
699 kin_max[i] * h_r - 0.5 * (hu_r * hu_r + hv_r * hv_r);
701 l_tmp = (
psi > -KE_tiny) ? l_ji_K : l_tmp;
703 const double ai = -0.5 * (P_hu * P_hu + P_hv * P_hv);
704 const double ai_nudged = std::min(ai, -KE_tiny);
705 const double bi = kinMaxi * P_h - (huLowi * P_hu + hvLowi * P_hv);
707 hLowi * kinMaxi - 0.5 * (huLowi * huLowi + hvLowi * hvLowi);
709 const double delta_i = bi * bi - 4. * ai * ci;
710 const double root_i =
711 0.5 / ai_nudged * (-bi - std::sqrt(std::abs(delta_i)));
714 l_ji_K = (root_i > 0.) ? std::min(root_i, l_ji_K)
715 : std::min(l_tmp, l_ji_K);
719 l_tmp = std::max(l_tmp, l_ji_K);
722 l_tmp = (hLowi * kinMaxi <= KE_tiny) ? 0. : l_tmp;
725 l_tmp = std::min(l_tmp, 1.);
726 l_tmp = std::max(l_tmp, 0.);
730 l_ji_K = std::min(l_tmp, l_ji_q1);
734 double l_ij_K = l_ij_q1;
737 const double h_r = hLowj + l_ij_K * P_h_tr;
738 const double hu_r = huLowj + l_ij_K * P_hu_tr;
739 const double hv_r = hvLowj + l_ij_K * P_hv_tr;
741 kinMaxj * h_r - 0.5 * (hu_r * hu_r + hv_r * hv_r);
743 l_tmp = (
psi > -KE_tiny) ? l_ij_K : l_tmp;
745 const double aj = -0.5 * (P_hu_tr * P_hu_tr + P_hv_tr * P_hv_tr);
746 const double aj_nudged = std::min(aj, -KE_tiny);
748 kinMaxj * P_h_tr - (huLowj * P_hu_tr + hvLowj * P_hv_tr);
750 hLowj * kinMaxj - 0.5 * (huLowj * huLowj + hvLowj * hvLowj);
752 const double delta_j = bj * bj - 4. * aj * cj;
753 const double root_j =
754 0.5 / aj_nudged * (-bj - std::sqrt(std::abs(delta_j)));
757 l_ij_K = (root_j > 0.) ? std::min(root_j, l_ij_K)
758 : std::min(l_tmp, l_ij_K);
762 l_tmp = std::max(l_tmp, l_ij_K);
765 l_tmp = (hLowj * kinMaxj <= KE_tiny) ? 0. : l_tmp;
768 l_tmp = std::min(l_tmp, 1.);
769 l_tmp = std::max(l_tmp, 0.);
773 l_ij_K = std::min(l_tmp, l_ij_q1);
776 Lij_array[ij] = std::min(l_ji_K, l_ij_K);
778#if IF_LIMITING_DEBUGGING
779 if (Lij_array[ij] > 1. || Lij_array[ij] < 0.) {
780 std::cout <<
"\n Problem with limiter! \n " << Lij_array[ij]
781 <<
"\n Aborting! " << std::endl;
790 for (
int i = 0; i < numDOFs; i++) {
792 const double one_over_mi = 1. / lumped_mass_matrix[i];
793 double ith_Limiter_times_FCT_matrix1 = 0.;
794 double ith_Limiter_times_FCT_matrix2 = 0.;
795 double ith_Limiter_times_FCT_matrix3 = 0.;
796 double ith_Limiter_times_FCT_matrix4 = 0.;
797 double ith_Limiter_times_FCT_matrix5 = 0.;
798 double ith_Limiter_times_FCT_matrix6 = 0.;
801 for (
int offset = csrRowIndeces_DofLoops[i];
802 offset < csrRowIndeces_DofLoops[i + 1]; offset++) {
803 int j = csrColumnOffsets_DofLoops[offset];
806 ith_Limiter_times_FCT_matrix1 += Lij_array[ij] * FCT_h[ij];
807 ith_Limiter_times_FCT_matrix2 += Lij_array[ij] * FCT_hu[ij];
808 ith_Limiter_times_FCT_matrix3 += Lij_array[ij] * FCT_hv[ij];
809 ith_Limiter_times_FCT_matrix4 += Lij_array[ij] * FCT_heta[ij];
810 ith_Limiter_times_FCT_matrix5 += Lij_array[ij] * FCT_hw[ij];
811 ith_Limiter_times_FCT_matrix6 += Lij_array[ij] * FCT_hbeta[ij];
818 hLow[i] += one_over_mi * ith_Limiter_times_FCT_matrix1;
819 huLow[i] += one_over_mi * ith_Limiter_times_FCT_matrix2;
820 hvLow[i] += one_over_mi * ith_Limiter_times_FCT_matrix3;
821 hetaLow[i] += one_over_mi * ith_Limiter_times_FCT_matrix4;
822 hwLow[i] += one_over_mi * ith_Limiter_times_FCT_matrix5;
823 hbetaLow[i] += one_over_mi * ith_Limiter_times_FCT_matrix6;
825#if IF_LIMITING_DEBUGGING
826 if (hLow[i] < -hEps) {
828 <<
" \n New intermediated/limited water depth is negative! \n"
829 <<
"new hLow[i] = " << hLow[i] <<
" \n "
830 <<
"-hEps = " << -hEps <<
"\n"
831 <<
"h_min = " << h_min[i] <<
"\n"
832 <<
"h_max = " << h_max[i] <<
"\n"
833 <<
"... Aborting! \n"
837 if (h_max[i] - hLow[i] < -1e-12 || hLow[i] - h_min[i] < -1e-12) {
839 << std::setprecision(15)
840 <<
" --- We have a major problem (h limiting bounds) --- \n "
841 <<
"i = " << i <<
" \n "
842 <<
"hLow[i] = " << hLow[i] <<
" \n "
843 <<
"h_min[i] = " << h_min[i] <<
" \n "
844 <<
"h_max[i] = " << h_max[i] <<
" \n "
845 <<
"Diff max = " << h_max[i] - hLow[i] <<
" \n "
846 <<
"Diff min = " << hLow[i] - h_min[i] <<
" \n " << std::endl;
847 std::cout <<
"LIMIT_ITER " << limit_iter << std::endl;
851 if (heta_max[i] - hetaLow[i] < -hEps * hEps ||
852 hetaLow[i] - heta_min[i] < -hEps * hEps) {
854 << std::setprecision(15)
855 <<
" --- We have a major problem (heta limiting bounds) --- \n
857 <<
"hetaLow[i] = " << hetaLow[i] <<
" \n "
858 <<
"heta_min[i] = " << heta_min[i] <<
" \n "
859 <<
"heta_max[i] = " << heta_max[i] <<
" \n "
860 <<
"Diff max = " << heta_max[i] - hetaLow[i] <<
" \n "
861 <<
"Diff min = " << hetaLow[i] - heta_min[i] <<
" \n "
869 FCT_h = (1. - Lij_array) * FCT_h;
870 FCT_hu = (1. - Lij_array) * FCT_hu;
871 FCT_hv = (1. - Lij_array) * FCT_hv;
872 FCT_heta = (1. - Lij_array) * FCT_heta;
873 FCT_hw = (1. - Lij_array) * FCT_hw;
874 FCT_hbeta = (1. - Lij_array) * FCT_hbeta;
877 if (limit_iter_arg < n_limit_iter - 1) {
878 for (std::size_t k = 0; k < nnz_fct; k++) {
879 FCT_all[0 * nnz_fct + k] = FCT_h[k];
880 FCT_all[1 * nnz_fct + k] = FCT_hu[k];
881 FCT_all[2 * nnz_fct + k] = FCT_hv[k];
882 FCT_all[3 * nnz_fct + k] = FCT_heta[k];
883 FCT_all[4 * nnz_fct + k] = FCT_hw[k];
884 FCT_all[5 * nnz_fct + k] = FCT_hbeta[k];
890 for (
int i = 0; i < numDOFs; i++) {
892 const double one_over_mi = 1. / lumped_mass_matrix[i];
894 limited_hnp1[i] = hLow[i] + dt * one_over_mi * SourceTerm_h[i];
895 limited_hunp1[i] = huLow[i] + dt * one_over_mi * extendedSourceTerm_hu[i];
896 limited_hvnp1[i] = hvLow[i] + dt * one_over_mi * extendedSourceTerm_hv[i];
897 limited_hetanp1[i] = hetaLow[i] + dt * one_over_mi * SourceTerm_heta[i];
898 limited_hwnp1[i] = hwLow[i] + dt * one_over_mi * SourceTerm_hw[i];
899 limited_hbetanp1[i] =
900 hbetaLow[i] + dt * one_over_mi * SourceTerm_hbeta[i];
902 if (limited_hnp1[i] < -hEps) {
904 <<
" !!!! Limited water height is negative: !!!! \n"
905 <<
" hLim = " << limited_hnp1[i] <<
"\n"
906 <<
" hEps = " << hEps <<
"\n"
907 <<
" h_min = " << h_min[i] <<
"\n"
908 <<
" h_max = " << h_max[i] <<
"\n"
909 <<
" !!!! ABORTING !!!! \n"
914 if (limited_hnp1[i] < hEps) {
915 limited_hnp1[i] = 0.;
918 const double aux = fmax(limited_hnp1[i], hEps);
919 limited_hunp1[i] *= 2. * std::pow(limited_hnp1[i],
VEL_FIX_POWER) /
922 limited_hvnp1[i] *= 2. * std::pow(limited_hnp1[i],
VEL_FIX_POWER) /
925 limited_hwnp1[i] *= 2. * std::pow(limited_hnp1[i],
VEL_FIX_POWER) /
928 limited_hbetanp1[i] *= 2. * std::pow(limited_hnp1[i],
VEL_FIX_POWER) /
1300 const double g = args.
scalar<
double>(
"g");
1301 const xt::pyarray<double> &h_dof_old = args.
array<
double>(
"h_dof_old");
1302 const xt::pyarray<double> &hu_dof_old = args.
array<
double>(
"hu_dof_old");
1303 const xt::pyarray<double> &hv_dof_old = args.
array<
double>(
"hv_dof_old");
1304 const xt::pyarray<double> &heta_dof_old =
1305 args.
array<
double>(
"heta_dof_old");
1306 const xt::pyarray<double> &hw_dof_old = args.
array<
double>(
"hw_dof_old");
1307 const xt::pyarray<double> &hbeta_dof_old =
1308 args.
array<
double>(
"hbeta_dof_old");
1309 const xt::pyarray<double> &b_dof = args.
array<
double>(
"b_dof");
1310 const xt::pyarray<double> &Cx = args.
array<
double>(
"Cx");
1311 const xt::pyarray<double> &Cy = args.
array<
double>(
"Cy");
1312 const xt::pyarray<double> &CTx = args.
array<
double>(
"CTx");
1313 const xt::pyarray<double> &CTy = args.
array<
double>(
"CTy");
1314 const int numDOFsPerEqn = args.
scalar<
int>(
"numDOFsPerEqn");
1315 const xt::pyarray<int> &csrRowIndeces_DofLoops =
1316 args.
array<
int>(
"csrRowIndeces_DofLoops");
1317 const xt::pyarray<int> &csrColumnOffsets_DofLoops =
1318 args.
array<
int>(
"csrColumnOffsets_DofLoops");
1319 const xt::pyarray<double> &lumped_mass_matrix =
1320 args.
array<
double>(
"lumped_mass_matrix");
1321 const double hEps = args.
scalar<
double>(
"hEps");
1322 xt::pyarray<double> &SourceTerm_h = args.
array<
double>(
"SourceTerm_h");
1323 xt::pyarray<double> &SourceTerm_hu = args.
array<
double>(
"SourceTerm_hu");
1324 xt::pyarray<double> &SourceTerm_hv = args.
array<
double>(
"SourceTerm_hv");
1325 xt::pyarray<double> &SourceTerm_heta =
1326 args.
array<
double>(
"SourceTerm_heta");
1327 xt::pyarray<double> &SourceTerm_hw = args.
array<
double>(
"SourceTerm_hw");
1328 xt::pyarray<double> &SourceTerm_hbeta =
1329 args.
array<
double>(
"SourceTerm_hbeta");
1330 const double dt = args.
scalar<
double>(
"dt");
1331 const double mannings = args.
scalar<
double>(
"mannings");
1332 const int lstage = args.
scalar<
int>(
"lstage");
1333 xt::pyarray<double> &global_entropy_residual =
1334 args.
array<
double>(
"global_entropy_residual");
1335 const double dij_small = args.
scalar<
double>(
"dij_small");
1336 xt::pyarray<double> &hLow = args.
array<
double>(
"hLow");
1337 xt::pyarray<double> &huLow = args.
array<
double>(
"huLow");
1338 xt::pyarray<double> &hvLow = args.
array<
double>(
"hvLow");
1339 xt::pyarray<double> &hetaLow = args.
array<
double>(
"hetaLow");
1340 xt::pyarray<double> &hwLow = args.
array<
double>(
"hwLow");
1341 xt::pyarray<double> &hbetaLow = args.
array<
double>(
"hbetaLow");
1342 xt::pyarray<double> &h_min = args.
array<
double>(
"h_min");
1343 xt::pyarray<double> &h_max = args.
array<
double>(
"h_max");
1344 xt::pyarray<double> &heta_min = args.
array<
double>(
"heta_min");
1345 xt::pyarray<double> &heta_max = args.
array<
double>(
"heta_max");
1346 xt::pyarray<double> &kin_max = args.
array<
double>(
"kin_max");
1347 const xt::pyarray<double> &x_values = args.
array<
double>(
"x_values");
1348 const xt::pyarray<double> &inverse_mesh =
1349 args.
array<
double>(
"inverse_mesh");
1350 const double h0_max = args.
scalar<
double>(
"h0_max");
1351 xt::pyarray<double> &RHS_high_h = args.
array<
double>(
"RHS_high_h");
1352 xt::pyarray<double> &RHS_high_hu = args.
array<
double>(
"RHS_high_hu");
1353 xt::pyarray<double> &RHS_high_hv = args.
array<
double>(
"RHS_high_hv");
1354 xt::pyarray<double> &RHS_high_heta = args.
array<
double>(
"RHS_high_heta");
1355 xt::pyarray<double> &RHS_high_hw = args.
array<
double>(
"RHS_high_hw");
1356 xt::pyarray<double> &RHS_high_hbeta = args.
array<
double>(
"RHS_high_hbeta");
1357 xt::pyarray<double> &extendedSourceTerm_hu =
1358 args.
array<
double>(
"extendedSourceTerm_hu");
1359 xt::pyarray<double> &extendedSourceTerm_hv =
1360 args.
array<
double>(
"extendedSourceTerm_hv");
1361 double size_of_domain = args.
scalar<
double>(
"size_of_domain");
1362 xt::pyarray<double> &delta_Sqd_h = args.
array<
double>(
"delta_Sqd_h");
1363 xt::pyarray<double> &delta_Sqd_heta = args.
array<
double>(
"delta_Sqd_heta");
1364 const double gen_length = args.
scalar<
double>(
"gen_length");
1365 const double gen_start = args.
scalar<
double>(
"gen_start");
1366 const double abs_length = args.
scalar<
double>(
"abs_length");
1367 const double abs_start = args.
scalar<
double>(
"abs_start");
1370 xt::pyarray<double> &h_wave = args.
array<
double>(
"h_wave");
1371 xt::pyarray<double> &h_u_wave = args.
array<
double>(
"h_u_wave");
1372 xt::pyarray<double> &h_v_wave = args.
array<
double>(
"h_v_wave");
1373 xt::pyarray<double> &h_eta_wave = args.
array<
double>(
"h_eta_wave");
1374 xt::pyarray<double> &h_w_wave = args.
array<
double>(
"h_w_wave");
1375 xt::pyarray<double> &h_beta_wave = args.
array<
double>(
"h_beta_wave");
1377 const xt::pyarray<double> &wall_dof = args.
array<
double>(
"wall_dof");
1380 const xt::pyarray<double> &porosity_dof = args.
array<
double>(
"porosity_dof");
1381 const xt::pyarray<double> &drag_alpha_dof =
1382 args.
array<
double>(
"drag_alpha_dof");
1383 const xt::pyarray<double> &drag_beta_dof = args.
array<
double>(
"drag_beta_dof");
1387 const double n2 = std::pow(mannings, 2.);
1388 const double gamma = 4. / 3;
1389 const double xi = 10.;
1390 const double alpha = 0.005;
1404 std::valarray<double> hBT(0., Cx.size()), huBT(0., Cx.size()),
1405 hvBT(0., Cx.size()), hetaBT(0., Cx.size()), hwBT(0., Cx.size()),
1406 hbetaBT(0., Cx.size()), dLow(0., Cx.size());
1409 std::valarray<double> bar_deltaSqd_h(0., numDOFsPerEqn),
1410 bar_deltaSqd_heta(0., numDOFsPerEqn);
1412 double high_viscosity_h, high_viscosity_hu, high_viscosity_hv,
1413 high_viscosity_heta, high_viscosity_hw, high_viscosity_hbeta;
1418 std::valarray<double> wall_nx(0., numDOFsPerEqn), wall_ny(0., numDOFsPerEqn);
1421 for (
int i = 0; i < numDOFsPerEqn; i++)
1422 for (
int offset = csrRowIndeces_DofLoops[i];
1423 offset < csrRowIndeces_DofLoops[i + 1]; offset++) {
1424 if (wall_dof[i] > 0.5) {
1425 wall_nx[i] += CTx[ij_w];
1426 wall_ny[i] += CTy[ij_w];
1438 for (
int i = 0; i < numDOFsPerEqn; i++) {
1441 const double hi = h_dof_old[i];
1442 const double hui = hu_dof_old[i];
1443 const double hvi = hv_dof_old[i];
1444 const double hetai = heta_dof_old[i];
1445 const double hwi = hw_dof_old[i];
1446 const double hbetai = hbeta_dof_old[i];
1447 const double Zi = b_dof[i];
1448 const double mi = lumped_mass_matrix[i];
1449 const double one_over_hiReg =
1450 2. * hi / (hi * hi + std::pow(fmax(hi, hEps), 2));
1451 const double ui = hui * one_over_hiReg;
1452 const double vi = hvi * one_over_hiReg;
1453 const double etai = hetai * one_over_hiReg;
1454 const double inv_meshSizei = inverse_mesh[i];
1455 const double x_i = x_values[i];
1458 SourceTerm_h[i] = 0.;
1459 SourceTerm_hu[i] = 0.;
1460 SourceTerm_hv[i] = 0.;
1461 SourceTerm_heta[i] = 0.;
1462 SourceTerm_hw[i] = 0.;
1463 SourceTerm_hbeta[i] = 0.;
1467 -(
LAMBDA_MGN * g / 3. * inv_meshSizei) * 6. * hi * (hetai - hi * hi);
1469 double diff_over_h_i = (hetai - hi * hi) * one_over_hiReg;
1470 if (hetai > std::pow(hi, 2.0)) {
1471 pTildei = -(
LAMBDA_MGN * g / 3.0 * inv_meshSizei) * 2.0 *
1472 diff_over_h_i * (etai * etai + etai * hi + hi * hi);
1477 const double pressure_i = 0.5 * g * hi * hi + pTildei;
1480 extendedSourceTerm_hu[i] = 0.;
1481 extendedSourceTerm_hv[i] = 0.;
1486 const double veli_norm = std::sqrt(ui * ui + vi * vi);
1487 const double hi_to_the_gamma = std::pow(fmax(hi, hEps), gamma);
1488 const double friction_aux =
1491 : (2 * g * n2 * veli_norm * mi /
1493 fmax(hi_to_the_gamma, xi * g * n2 * dt * veli_norm)));
1494 SourceTerm_hu[i] = -friction_aux * hui;
1495 SourceTerm_hv[i] = -friction_aux * hvi;
1499 const double phi_i = porosity_dof[i];
1502 (drag_alpha_dof[i] + drag_beta_dof[i] * veli_norm) / phi_i;
1504 const double drag_aux = 2. * K * mi / (1. + fmax(1., xi * dt * K));
1505 SourceTerm_hu[i] -= drag_aux * hui;
1506 SourceTerm_hv[i] -= drag_aux * hvi;
1512 extendedSourceTerm_hu[i] += SourceTerm_hu[i];
1513 extendedSourceTerm_hv[i] += SourceTerm_hv[i];
1516 double sum_flux_h = 0.;
1517 double sum_flux_hu = 0.;
1518 double sum_flux_hv = 0.;
1519 double sum_flux_heta = 0.;
1520 double sum_flux_hw = 0.;
1521 double sum_flux_hbeta = 0.;
1524 high_viscosity_h = 0.;
1525 high_viscosity_hu = 0.;
1526 high_viscosity_hv = 0.;
1527 high_viscosity_heta = 0.;
1528 high_viscosity_hw = 0.;
1529 high_viscosity_hbeta = 0.;
1532 double grad_Z_x_i = 0.;
1533 double grad_Z_y_i = 0.;
1535 const double card_inv =
1536 1. / (csrRowIndeces_DofLoops[i + 1] - csrRowIndeces_DofLoops[i]);
1539 for (
int offset = csrRowIndeces_DofLoops[i];
1540 offset < csrRowIndeces_DofLoops[i + 1]; offset++) {
1541 const int j = csrColumnOffsets_DofLoops[offset];
1544 const double hj = h_dof_old[j];
1545 const double huj = hu_dof_old[j];
1546 const double hvj = hv_dof_old[j];
1547 const double hetaj = heta_dof_old[j];
1548 const double hwj = hw_dof_old[j];
1549 const double hbetaj = hbeta_dof_old[j];
1550 const double Zj = b_dof[j];
1551 const double one_over_hjReg =
1552 2. * hj / (hj * hj + std::pow(fmax(hj, hEps), 2));
1553 const double uj = huj * one_over_hjReg;
1554 const double vj = hvj * one_over_hjReg;
1555 const double etaj = hetaj * one_over_hjReg;
1556 const double mj = lumped_mass_matrix[j];
1557 const double inv_meshSizej = inverse_mesh[j];
1560 grad_Z_x_i += Zj * Cx[ij];
1561 grad_Z_y_i += Zj * Cy[ij];
1564 double pTildej = -(
LAMBDA_MGN * g / 3. * inv_meshSizej) * 6. * hj *
1567 double diff_over_h_j = (hetaj - hj * hj) * one_over_hjReg;
1568 if (hetaj > std::pow(hj, 2.0)) {
1569 pTildej = -(
LAMBDA_MGN * g / 3.0 * inv_meshSizej) * 2.0 *
1570 diff_over_h_j * (etaj * etaj + etaj * hj + hj * hj);
1575 const double pressure_j = 0.5 * g * hj * hj + pTildej;
1578 extendedSourceTerm_hu[i] +=
1579 phi_i * g * (-hi * Zj + 0.5 * (hj - hi) * (hj - hi)) * Cx[ij];
1580 extendedSourceTerm_hv[i] +=
1581 phi_i * g * (-hi * Zj + 0.5 * (hj - hi) * (hj - hi)) * Cy[ij];
1582 const double phi_j = porosity_dof[j];
1585 double cxa, cya, cxaT, cyaT;
1586 wallCoefficients(i, j, ij, wall_dof, Cx, Cy, CTx, CTy, cxa, cya, cxaT,
1591 const double flux_h = (phi_j * hj * uj - phi_i * hi * ui) * cxa +
1592 (phi_j * hj * vj - phi_i * hi * vi) * cya;
1594 const double aux_hu = (phi_j * uj * huj - phi_i * ui * hui) * cxa +
1595 (phi_j * vj * huj - phi_i * vi * hui) * cya;
1596 const double flux_hu =
1597 aux_hu + phi_i * (pressure_j - pressure_i) * Cx[ij];
1599 const double aux_hv = (phi_j * uj * hvj - phi_i * ui * hvi) * cxa +
1600 (phi_j * vj * hvj - phi_i * vi * hvi) * cya;
1601 const double flux_hv =
1602 aux_hv + phi_i * (pressure_j - pressure_i) * Cy[ij];
1604 const double flux_heta =
1605 (phi_j * uj * hj * etaj - phi_i * ui * hi * etai) * cxa +
1606 (phi_j * vj * hj * etaj - phi_i * vi * hi * etai) * cya;
1607 const double flux_hw = (phi_j * uj * hwj - phi_i * ui * hwi) * cxa +
1608 (phi_j * vj * hwj - phi_i * vi * hwi) * cya;
1610 const double flux_hbeta =
1611 (phi_j * uj * hbetaj - phi_i * ui * hbetai) * cxa +
1612 (phi_j * vj * hbetaj - phi_i * vi * hbetai) * cya;
1616 sum_flux_h += flux_h;
1617 sum_flux_hu += aux_hu + phi_i * (g * hi * (hj + Zj) + pTildej) * Cx[ij];
1618 sum_flux_hv += aux_hv + phi_i * (g * hi * (hj + Zj) + pTildej) * Cy[ij];
1619 sum_flux_heta += flux_heta;
1620 sum_flux_hw += flux_hw;
1621 sum_flux_hbeta += flux_hbeta;
1625 double muLij = 0., muHij = 0.;
1626 double dLowij = 0., dLij = 0., dHij = 0.;
1630 bar_deltaSqd_h[i] += 0.5 * delta_Sqd_h[j] + 0.5 * delta_Sqd_h[i];
1631 bar_deltaSqd_heta[i] +=
1632 0.5 * delta_Sqd_heta[j] + 0.5 * delta_Sqd_heta[i];
1635 const double cij_norm = sqrt(Cx[ij] * Cx[ij] + Cy[ij] * Cy[ij]);
1636 const double cji_norm = sqrt(CTx[ij] * CTx[ij] + CTy[ij] * CTy[ij]);
1637 const double nxij = Cx[ij] / cij_norm;
1638 const double nyij = Cy[ij] / cij_norm;
1639 const double nxji = CTx[ij] / cji_norm;
1640 const double nyji = CTy[ij] / cji_norm;
1642 g, nxij, nyij, hi, hui, hvi, hetai, inv_meshSizei,
1643 hj, huj, hvj, hetaj, inv_meshSizej, hEps) *
1646 g, nxji, nyji, hj, huj, hvj, hetaj, inv_meshSizej,
1647 hi, hui, hvi, hetai, inv_meshSizei, hEps) *
1651 muLij = fmax(std::abs(ui * cxa + vi * cya),
1652 std::abs(uj * cxaT + vj * cyaT));
1653 const double phibar_ij =
phiBar(i, j, porosity_dof);
1654 dLowij *= phibar_ij;
1656 dLij = fmax(dLowij, muLij);
1662 const double dEVij =
1664 fmax(global_entropy_residual[i], global_entropy_residual[j]);
1665 dHij = fmin(dLij, dEVij);
1666 muHij = fmin(muLij, dEVij);
1670 const double hStarij = fmax(0., hi + Zi - fmax(Zi, Zj));
1671 const double hStarji = fmax(0., hj + Zj - fmax(Zi, Zj));
1672 const double hStar_ratio_i = hStarij * one_over_hiReg;
1673 const double hStar_ratio_j = hStarji * one_over_hjReg;
1675 const double huStarij = hui * hStar_ratio_i;
1676 const double hvStarij = hvi * hStar_ratio_i;
1677 const double hetaStarij = hetai * std::pow(hStar_ratio_i, 2);
1678 const double hwStarij = hwi * hStar_ratio_i;
1679 const double hbetaStarij = hbetai * hStar_ratio_i;
1681 const double huStarji = huj * hStar_ratio_j;
1682 const double hvStarji = hvj * hStar_ratio_j;
1683 const double hetaStarji = hetaj * std::pow(hStar_ratio_j, 2);
1684 const double hwStarji = hwj * hStar_ratio_j;
1685 const double hbetaStarji = hbetaj * hStar_ratio_j;
1689 double hBar_ij = 0., hTilde_ij = 0., huBar_ij = 0., huTilde_ij = 0.,
1690 hvBar_ij = 0., hvTilde_ij = 0., hetaBar_ij = 0.,
1691 hetaTilde_ij = 0., hwBar_ij = 0., hwTilde_ij = 0.,
1692 hbetaBar_ij = 0., hbetaTilde_ij = 0.;
1694 const double half_dij_inv = -0.5 / fmax(dLij, dij_small);
1695 const double visc_ratio = -half_dij_inv * (dLij - muLij);
1698 hBar_ij = half_dij_inv * flux_h + 0.5 * (hj + hi);
1699 hTilde_ij = visc_ratio * (hStarji - hj - (hStarij - hi));
1702 huBar_ij = half_dij_inv * flux_hu + 0.5 * (huj + hui);
1703 huTilde_ij = visc_ratio * (huStarji - huj - (huStarij - hui));
1706 hvBar_ij = half_dij_inv * flux_hv + 0.5 * (hvj + hvi);
1707 hvTilde_ij = visc_ratio * (hvStarji - hvj - (hvStarij - hvi));
1710 hetaBar_ij = half_dij_inv * flux_heta + 0.5 * (hetaj + hetai);
1712 visc_ratio * (hetaStarji - hetaj - (hetaStarij - hetai));
1715 hwBar_ij = half_dij_inv * flux_hw + 0.5 * (hwj + hwi);
1716 hwTilde_ij = visc_ratio * (hwStarji - hwj - (hwStarij - hwi));
1719 hbetaBar_ij = half_dij_inv * flux_hbeta + 0.5 * (hbetaj + hbetai);
1721 visc_ratio * (hbetaStarji - hbetaj - (hbetaStarij - hbetai));
1725 hBT[ij] = std::max(hBar_ij + hTilde_ij, 0.);
1726 huBT[ij] = huBar_ij + huTilde_ij;
1727 hvBT[ij] = hvBar_ij + hvTilde_ij;
1728 hetaBT[ij] = hetaBar_ij + hetaTilde_ij;
1729 hwBT[ij] = hwBar_ij + hwTilde_ij;
1730 hbetaBT[ij] = hbetaBar_ij + hbetaTilde_ij;
1735 (dHij - muHij) * (hStarji - hStarij) + muHij * (hj - hi);
1737 high_viscosity_hu +=
1738 (dHij - muHij) * (huStarji - huStarij) + muHij * (huj - hui);
1740 high_viscosity_hv +=
1741 (dHij - muHij) * (hvStarji - hvStarij) + muHij * (hvj - hvi);
1743 high_viscosity_heta += (dHij - muHij) * (hetaStarji - hetaStarij) +
1744 muHij * (hetaj - hetai);
1746 high_viscosity_hw +=
1747 (dHij - muHij) * (hwStarji - hwStarij) + muHij * (hwj - hwi);
1749 high_viscosity_hbeta += (dHij - muHij) * (hbetaStarji - hbetaStarij) +
1750 muHij * (hbetaj - hbetai);
1760 hbetaBT[ij] = hbetai;
1768 if (wall_dof[i] > 0.5) {
1769 const double un_i = phi_i * (ui * wall_nx[i] + vi * wall_ny[i]);
1770 sum_flux_h -= un_i * hi;
1771 sum_flux_hu -= un_i * hui;
1772 sum_flux_hv -= un_i * hvi;
1773 sum_flux_heta -= un_i * hi * etai;
1774 sum_flux_hw -= un_i * hwi;
1775 sum_flux_hbeta -= un_i * hbetai;
1779 bar_deltaSqd_h[i] *= card_inv * 0.5;
1780 bar_deltaSqd_heta[i] *= card_inv * 0.5;
1784 double hSqd_GammaPi = 6.0 * (hetai - hi * hi);
1786 const double diff_over_h_i = (hetai - hi * hi) * one_over_hiReg;
1787 if (hetai > std::pow(hi, 2.0)) {
1788 hSqd_GammaPi = 6.0 * etai * diff_over_h_i;
1795 const double q_dot_gradZ =
1796 phi_i * (hui * grad_Z_x_i + hvi * grad_Z_y_i);
1797 const double R1 = hwi - 1.5 * q_dot_gradZ / mi;
1798 const double R2 =
LAMBDA_MGN * g * inv_meshSizei * hSqd_GammaPi;
1799 const double R3 =
LAMBDA_MGN * std::sqrt(g * h0_max) * inv_meshSizei *
1800 (q_dot_gradZ / mi - hbetai);
1802 SourceTerm_h[i] += 0.;
1806 const double topo_disp_x = phi_i * (0.5 * R2 - 0.25 * R3) * grad_Z_x_i;
1807 const double topo_disp_y = phi_i * (0.5 * R2 - 0.25 * R3) * grad_Z_y_i;
1808 SourceTerm_hu[i] += topo_disp_x;
1809 SourceTerm_hv[i] += topo_disp_y;
1810 extendedSourceTerm_hu[i] += topo_disp_x;
1811 extendedSourceTerm_hv[i] += topo_disp_y;
1812 SourceTerm_heta[i] += mi * R1;
1813 SourceTerm_hw[i] += -mi * R2;
1814 SourceTerm_hbeta[i] += mi * R3;
1817 if (gen_length > 0.) {
1818 const double shift = -(gen_start - gen_length);
1819 const double xhat = (x_i + shift) / gen_length;
1820 const double function_gen =
relaxation(xhat, alpha);
1822 SourceTerm_h[i] += -mi * std::sqrt(g * h0_max) * inv_meshSizei *
1823 function_gen * (hi - h_wave[i]);
1824 SourceTerm_hu[i] += -mi * std::sqrt(g * h0_max) * inv_meshSizei *
1825 function_gen * (hui - h_u_wave[i]);
1826 SourceTerm_hv[i] += -mi * std::sqrt(g * h0_max) * inv_meshSizei *
1827 function_gen * (hvi - h_v_wave[i]);
1828 SourceTerm_heta[i] += -mi * std::sqrt(g * h0_max) * inv_meshSizei *
1829 function_gen * (hetai - h_eta_wave[i]);
1830 SourceTerm_hw[i] += -mi * std::sqrt(g * h0_max) * inv_meshSizei *
1831 function_gen * (hwi - h_w_wave[i]);
1832 SourceTerm_hbeta[i] += -mi * std::sqrt(g * h0_max) * inv_meshSizei *
1833 function_gen * (hbetai - 0.);
1835 extendedSourceTerm_hu[i] += -mi * std::sqrt(g * h0_max) *
1836 inv_meshSizei * function_gen *
1837 (hui - h_u_wave[i]);
1838 extendedSourceTerm_hv[i] += -mi * std::sqrt(g * h0_max) *
1839 inv_meshSizei * function_gen *
1840 (hvi - h_v_wave[i]);
1843 if (abs_length > 0.) {
1844 const double shift = (abs_start + abs_length);
1845 const double xhat = (shift - x_i) / abs_length;
1846 const double function_gen =
relaxation(xhat, alpha);
1848 SourceTerm_hu[i] += -mi * std::sqrt(g * h0_max) * inv_meshSizei *
1849 function_gen * (hui - 0.);
1850 SourceTerm_hv[i] += -mi * std::sqrt(g * h0_max) * inv_meshSizei *
1851 function_gen * (hvi - 0.);
1852 SourceTerm_hw[i] += -mi * std::sqrt(g * h0_max) * inv_meshSizei *
1853 function_gen * (hwi - 0.);
1854 SourceTerm_hbeta[i] += -mi * std::sqrt(g * h0_max) * inv_meshSizei *
1855 function_gen * (hbetai - 0.);
1857 extendedSourceTerm_hu[i] += -mi * std::sqrt(g * h0_max) *
1858 inv_meshSizei * function_gen * (hui - 0.);
1859 extendedSourceTerm_hv[i] += -mi * std::sqrt(g * h0_max) *
1860 inv_meshSizei * function_gen * (hvi - 0.);
1865 RHS_high_h[i] = SourceTerm_h[i] - sum_flux_h + high_viscosity_h;
1866 RHS_high_hu[i] = SourceTerm_hu[i] - sum_flux_hu + high_viscosity_hu;
1867 RHS_high_hv[i] = SourceTerm_hv[i] - sum_flux_hv + high_viscosity_hv;
1869 SourceTerm_heta[i] - sum_flux_heta + high_viscosity_heta;
1870 RHS_high_hw[i] = SourceTerm_hw[i] - sum_flux_hw + high_viscosity_hw;
1872 SourceTerm_hbeta[i] - sum_flux_hbeta + high_viscosity_hbeta;
1879 for (
int i = 0; i < numDOFsPerEqn; i++) {
1882 const double hi = h_dof_old[i];
1883 const double hu_i = hu_dof_old[i];
1884 const double hv_i = hv_dof_old[i];
1885 const double hetai = heta_dof_old[i];
1886 const double hwi = hw_dof_old[i];
1887 const double hbetai = hbeta_dof_old[i];
1888 const double one_over_hi =
1889 2. * hi / (hi * hi + std::pow(fmax(hi, hEps), 2));
1890 const double u_i = hu_i * one_over_hi;
1891 const double v_i = hv_i * one_over_hi;
1892 const double kin_i = 0.5 * hi * (u_i * u_i + v_i * v_i);
1893 const double mi = lumped_mass_matrix[i];
1898 heta_min[i] = hetai;
1899 heta_max[i] = hetai;
1903 double sum_dij = 0.;
1904 double sum_dij_hbar = 0.;
1905 double sum_dij_hubar = 0.;
1906 double sum_dij_hvbar = 0.;
1907 double sum_dij_hetabar = 0.;
1908 double sum_dij_hwbar = 0.;
1909 double sum_dij_hbetabar = 0.;
1912 for (
int offset = csrRowIndeces_DofLoops[i];
1913 offset < csrRowIndeces_DofLoops[i + 1]; offset++) {
1914 const int j = csrColumnOffsets_DofLoops[offset];
1916 const double one_over_hBT =
1918 (hBT[ij] * hBT[ij] + std::pow(fmax(hBT[ij], hEps), 2));
1919 const double psi_ij =
1920 0.5 * one_over_hBT * (huBT[ij] * huBT[ij] + hvBT[ij] * hvBT[ij]);
1923 h_min[i] = std::min(h_min[i], hBT[ij]);
1924 h_max[i] = std::max(h_max[i], hBT[ij]);
1925 heta_min[i] = std::min(heta_min[i], hetaBT[ij]);
1926 heta_max[i] = std::max(heta_max[i], hetaBT[ij]);
1927 kin_max[i] = fmax(psi_ij, kin_max[i]);
1930 sum_dij += dLow[ij];
1931 sum_dij_hbar += dLow[ij] * hBT[ij];
1932 sum_dij_hubar += dLow[ij] * huBT[ij];
1933 sum_dij_hvbar += dLow[ij] * hvBT[ij];
1934 sum_dij_hetabar += dLow[ij] * hetaBT[ij];
1935 sum_dij_hwbar += dLow[ij] * hwBT[ij];
1936 sum_dij_hbetabar += dLow[ij] * hbetaBT[ij];
1943 const double cfl_condition = (1. - dt / mi * 2. * sum_dij);
1946 hLow[i] = hi * cfl_condition + dt / mi * (2. * sum_dij_hbar);
1947 huLow[i] = hu_i * cfl_condition + dt / mi * (2. * sum_dij_hubar);
1948 hvLow[i] = hv_i * cfl_condition + dt / mi * (2. * sum_dij_hvbar);
1949 hetaLow[i] = hetai * cfl_condition + dt / mi * (2. * sum_dij_hetabar);
1950 hwLow[i] = hwi * cfl_condition + dt / mi * (2. * sum_dij_hwbar);
1951 hbetaLow[i] = hbetai * cfl_condition + dt / mi * (2. * sum_dij_hbetabar);
1956 if (wall_dof[i] > 0.5) {
1958 porosity_dof[i] * (u_i * wall_nx[i] + v_i * wall_ny[i]);
1959 const double etai_w =
1960 hetai * one_over_hi;
1961 hLow[i] += dt / mi * un_i * hi;
1962 huLow[i] += dt / mi * un_i * hu_i;
1963 hvLow[i] += dt / mi * un_i * hv_i;
1964 hetaLow[i] += dt / mi * un_i * hi * etai_w;
1965 hwLow[i] += dt / mi * un_i * hwi;
1966 hbetaLow[i] += dt / mi * un_i * hbetai;
1967 h_min[i] = std::min(h_min[i], hLow[i]);
1968 h_max[i] = std::max(h_max[i], hLow[i]);
1969 heta_min[i] = std::min(heta_min[i], hetaLow[i]);
1970 heta_max[i] = std::max(heta_max[i], hetaLow[i]);
1971 const double one_over_hLow =
1973 (hLow[i] * hLow[i] + std::pow(fmax(hLow[i], hEps), 2));
1974 kin_max[i] = fmax(kin_max[i],
1975 0.5 * one_over_hLow *
1976 (huLow[i] * huLow[i] + hvLow[i] * hvLow[i]));
1980 if (dt < 1e-2 && hLow[i] < -hEps) {
1981 std::cout <<
"Low-order water depth is negative !!! " << hLow[i] <<
"\n"
1982 <<
"hLow[i] + hEps !!! " << hLow[i] + hEps
1984 <<
"hEps !!! " << hEps <<
"\n"
1985 <<
" ... aborting!" << std::endl;
1988 if (hLow[i] <= hEps) {
1995 if (h_min[i] < 0.) {
1997 <<
" Minimum water depth is negative !!! " << h_min[i]
1999 <<
" hLow[i] !!! " << hLow[i] <<
"\n "
2004 if (h_min[i] <= hEps) {
2010 if (h_max[i] < 0.) {
2011 std::cout <<
" Maximum water depth is negative !!! " << h_max[i] <<
"\n"
2012 <<
" hLow[i] !!! " << hLow[i] <<
"\n "
2013 <<
" ... aborting!" << std::endl;
2016 if (h_max[i] <= hEps) {
2024 const double s_i = std::pow(std::sqrt(std::sqrt(mi / size_of_domain)), 3);
2025 const double urelax_i = 1. + s_i;
2026 const double drelax_i = 1. - s_i;
2029 std::max((1. + std::sqrt(mi / size_of_domain)) * kin_max[i], 0.);
2031 std::max(drelax_i * h_min[i], h_min[i] - std::abs(bar_deltaSqd_h[i]));
2033 std::min(urelax_i * h_max[i], h_max[i] + std::abs(bar_deltaSqd_h[i]));
2034 heta_min[i] = std::max(drelax_i * heta_min[i],
2035 heta_min[i] - std::abs(bar_deltaSqd_heta[i]));
2036 heta_max[i] = std::min(urelax_i * heta_max[i],
2037 heta_max[i] + std::abs(bar_deltaSqd_heta[i]));
2040 if (hLow[i] > h_max[i] || hLow[i] < h_min[i]) {
2041 std::cout <<
" --- We have a major problem (h bounds) --- "
2042 << std::setprecision(15) << std::endl;
2043 std::cout <<
"hLow[i] = " << hLow[i] <<
" \n "
2044 <<
"h_min[i] = " << h_min[i] <<
" \n "
2045 <<
"h_max[i] = " << h_max[i] <<
" \n "
2046 <<
"Diff max = " << h_max[i] - hLow[i] <<
" \n "
2047 <<
"Diff min = " << hLow[i] - h_min[i] <<
" \n " << std::endl;
2050 if (heta_max[i] - hetaLow[i] < -hEps * hEps ||
2051 hetaLow[i] - heta_min[i] < -hEps * hEps) {
2052 std::cout <<
" --- We have a major problem (heta bounds) --- "
2053 << std::setprecision(15) << std::endl;
2054 std::cout <<
"hetaLow[i] = " << hetaLow[i] <<
" \n "
2055 <<
"heta_min[i] = " << heta_min[i] <<
" \n "
2056 <<
"heta_max[i] = " << heta_max[i] <<
" \n "
2057 <<
"Diff max = " << heta_max[i] - hetaLow[i] <<
" \n "
2058 <<
"Diff min = " << hetaLow[i] - heta_min[i] <<
" \n "
2068 xt::pyarray<double> &mesh_trial_ref = args.
array<
double>(
"mesh_trial_ref");
2069 xt::pyarray<double> &mesh_grad_trial_ref =
2070 args.
array<
double>(
"mesh_grad_trial_ref");
2071 xt::pyarray<double> &mesh_dof = args.
array<
double>(
"mesh_dof");
2072 xt::pyarray<int> &mesh_l2g = args.
array<
int>(
"mesh_l2g");
2073 xt::pyarray<double> &dV_ref = args.
array<
double>(
"dV_ref");
2074 xt::pyarray<double> &h_trial_ref = args.
array<
double>(
"h_trial_ref");
2075 xt::pyarray<double> &h_grad_trial_ref =
2076 args.
array<
double>(
"h_grad_trial_ref");
2077 xt::pyarray<double> &h_test_ref = args.
array<
double>(
"h_test_ref");
2078 xt::pyarray<double> &h_grad_test_ref =
2079 args.
array<
double>(
"h_grad_test_ref");
2080 xt::pyarray<double> &vel_trial_ref = args.
array<
double>(
"vel_trial_ref");
2081 xt::pyarray<double> &vel_grad_trial_ref =
2082 args.
array<
double>(
"vel_grad_trial_ref");
2083 xt::pyarray<double> &vel_test_ref = args.
array<
double>(
"vel_test_ref");
2084 xt::pyarray<double> &vel_grad_test_ref =
2085 args.
array<
double>(
"vel_grad_test_ref");
2086 xt::pyarray<double> &mesh_trial_trace_ref =
2087 args.
array<
double>(
"mesh_trial_trace_ref");
2088 xt::pyarray<double> &mesh_grad_trial_trace_ref =
2089 args.
array<
double>(
"mesh_grad_trial_trace_ref");
2090 xt::pyarray<double> &h_trial_trace_ref =
2091 args.
array<
double>(
"h_trial_trace_ref");
2092 xt::pyarray<double> &h_grad_trial_trace_ref =
2093 args.
array<
double>(
"h_grad_trial_trace_ref");
2094 xt::pyarray<double> &h_test_trace_ref =
2095 args.
array<
double>(
"h_test_trace_ref");
2096 xt::pyarray<double> &h_grad_test_trace_ref =
2097 args.
array<
double>(
"h_grad_test_trace_ref");
2098 xt::pyarray<double> &vel_trial_trace_ref =
2099 args.
array<
double>(
"vel_trial_trace_ref");
2100 xt::pyarray<double> &vel_grad_trial_trace_ref =
2101 args.
array<
double>(
"vel_grad_trial_trace_ref");
2102 xt::pyarray<double> &vel_test_trace_ref =
2103 args.
array<
double>(
"vel_test_trace_ref");
2104 xt::pyarray<double> &vel_grad_test_trace_ref =
2105 args.
array<
double>(
"vel_grad_test_trace_ref");
2106 xt::pyarray<double> &normal_ref = args.
array<
double>(
"normal_ref");
2107 xt::pyarray<double> &boundaryJac_ref =
2108 args.
array<
double>(
"boundaryJac_ref");
2109 xt::pyarray<double> &elementDiameter =
2110 args.
array<
double>(
"elementDiameter");
2111 int nElements_global = args.
scalar<
int>(
"nElements_global");
2112 double g = args.
scalar<
double>(
"g");
2113 xt::pyarray<double> &porosity_dof = args.
array<
double>(
"porosity_dof");
2114 xt::pyarray<int> &h_l2g = args.
array<
int>(
"h_l2g");
2115 xt::pyarray<int> &vel_l2g = args.
array<
int>(
"vel_l2g");
2116 xt::pyarray<double> &h_dof_old = args.
array<
double>(
"h_dof_old");
2117 xt::pyarray<double> &hu_dof_old = args.
array<
double>(
"hu_dof_old");
2118 xt::pyarray<double> &hv_dof_old = args.
array<
double>(
"hv_dof_old");
2119 xt::pyarray<double> &heta_dof_old = args.
array<
double>(
"heta_dof_old");
2120 xt::pyarray<double> &hw_dof_old = args.
array<
double>(
"hw_dof_old");
2121 xt::pyarray<double> &hbeta_dof_old = args.
array<
double>(
"hbeta_dof_old");
2122 xt::pyarray<double> &b_dof = args.
array<
double>(
"b_dof");
2123 xt::pyarray<double> &h_dof = args.
array<
double>(
"h_dof");
2124 xt::pyarray<double> &hu_dof = args.
array<
double>(
"hu_dof");
2125 xt::pyarray<double> &hv_dof = args.
array<
double>(
"hv_dof");
2126 xt::pyarray<double> &heta_dof = args.
array<
double>(
"heta_dof");
2127 xt::pyarray<double> &hw_dof = args.
array<
double>(
"hw_dof");
2128 xt::pyarray<double> &hbeta_dof = args.
array<
double>(
"hbeta_dof");
2129 xt::pyarray<double> &q_cfl = args.
array<
double>(
"q_cfl");
2130 xt::pyarray<int> &sdInfo_hu_hu_rowptr =
2131 args.
array<
int>(
"sdInfo_hu_hu_rowptr");
2132 xt::pyarray<int> &sdInfo_hu_hu_colind =
2133 args.
array<
int>(
"sdInfo_hu_hu_colind");
2134 xt::pyarray<int> &sdInfo_hu_hv_rowptr =
2135 args.
array<
int>(
"sdInfo_hu_hv_rowptr");
2136 xt::pyarray<int> &sdInfo_hu_hv_colind =
2137 args.
array<
int>(
"sdInfo_hu_hv_colind");
2138 xt::pyarray<int> &sdInfo_hv_hv_rowptr =
2139 args.
array<
int>(
"sdInfo_hv_hv_rowptr");
2140 xt::pyarray<int> &sdInfo_hv_hv_colind =
2141 args.
array<
int>(
"sdInfo_hv_hv_colind");
2142 xt::pyarray<int> &sdInfo_hv_hu_rowptr =
2143 args.
array<
int>(
"sdInfo_hv_hu_rowptr");
2144 xt::pyarray<int> &sdInfo_hv_hu_colind =
2145 args.
array<
int>(
"sdInfo_hv_hu_colind");
2146 int offset_h = args.
scalar<
int>(
"offset_h");
2147 int offset_hu = args.
scalar<
int>(
"offset_hu");
2148 int offset_hv = args.
scalar<
int>(
"offset_hv");
2149 int offset_heta = args.
scalar<
int>(
"offset_heta");
2150 int offset_hw = args.
scalar<
int>(
"offset_hw");
2151 int offset_hbeta = args.
scalar<
int>(
"offset_hbeta");
2152 int stride_h = args.
scalar<
int>(
"stride_h");
2153 int stride_hu = args.
scalar<
int>(
"stride_hu");
2154 int stride_hv = args.
scalar<
int>(
"stride_hv");
2155 int stride_heta = args.
scalar<
int>(
"stride_heta");
2156 int stride_hw = args.
scalar<
int>(
"stride_hw");
2157 int stride_hbeta = args.
scalar<
int>(
"stride_hbeta");
2158 xt::pyarray<double> &globalResidual = args.
array<
double>(
"globalResidual");
2159 int nExteriorElementBoundaries_global =
2160 args.
scalar<
int>(
"nExteriorElementBoundaries_global");
2161 xt::pyarray<int> &exteriorElementBoundariesArray =
2162 args.
array<
int>(
"exteriorElementBoundariesArray");
2163 xt::pyarray<int> &elementBoundaryElementsArray =
2164 args.
array<
int>(
"elementBoundaryElementsArray");
2165 xt::pyarray<int> &elementBoundaryLocalElementBoundariesArray =
2166 args.
array<
int>(
"elementBoundaryLocalElementBoundariesArray");
2167 xt::pyarray<int> &isDOFBoundary_h = args.
array<
int>(
"isDOFBoundary_h");
2168 xt::pyarray<int> &isDOFBoundary_hu = args.
array<
int>(
"isDOFBoundary_hu");
2169 xt::pyarray<int> &isDOFBoundary_hv = args.
array<
int>(
"isDOFBoundary_hv");
2170 xt::pyarray<int> &isAdvectiveFluxBoundary_h =
2171 args.
array<
int>(
"isAdvectiveFluxBoundary_h");
2172 xt::pyarray<int> &isAdvectiveFluxBoundary_hu =
2173 args.
array<
int>(
"isAdvectiveFluxBoundary_hu");
2174 xt::pyarray<int> &isAdvectiveFluxBoundary_hv =
2175 args.
array<
int>(
"isAdvectiveFluxBoundary_hv");
2176 xt::pyarray<int> &isDiffusiveFluxBoundary_hu =
2177 args.
array<
int>(
"isDiffusiveFluxBoundary_hu");
2178 xt::pyarray<int> &isDiffusiveFluxBoundary_hv =
2179 args.
array<
int>(
"isDiffusiveFluxBoundary_hv");
2180 xt::pyarray<double> &ebqe_bc_h_ext = args.
array<
double>(
"ebqe_bc_h_ext");
2181 xt::pyarray<double> &ebqe_bc_flux_mass_ext =
2182 args.
array<
double>(
"ebqe_bc_flux_mass_ext");
2183 xt::pyarray<double> &ebqe_bc_flux_mom_hu_adv_ext =
2184 args.
array<
double>(
"ebqe_bc_flux_mom_hu_adv_ext");
2185 xt::pyarray<double> &ebqe_bc_flux_mom_hv_adv_ext =
2186 args.
array<
double>(
"ebqe_bc_flux_mom_hv_adv_ext");
2187 xt::pyarray<double> &ebqe_bc_hu_ext = args.
array<
double>(
"ebqe_bc_hu_ext");
2188 xt::pyarray<double> &ebqe_bc_flux_hu_diff_ext =
2189 args.
array<
double>(
"ebqe_bc_flux_hu_diff_ext");
2190 xt::pyarray<double> &ebqe_penalty_ext =
2191 args.
array<
double>(
"ebqe_penalty_ext");
2192 xt::pyarray<double> &ebqe_bc_hv_ext = args.
array<
double>(
"ebqe_bc_hv_ext");
2193 xt::pyarray<double> &ebqe_bc_flux_hv_diff_ext =
2194 args.
array<
double>(
"ebqe_bc_flux_hv_diff_ext");
2195 xt::pyarray<double> &q_velocity = args.
array<
double>(
"q_velocity");
2196 xt::pyarray<double> &ebqe_velocity = args.
array<
double>(
"ebqe_velocity");
2197 xt::pyarray<double> &flux = args.
array<
double>(
"flux");
2198 xt::pyarray<double> &elementResidual_h_save =
2199 args.
array<
double>(
"elementResidual_h_save");
2200 const xt::pyarray<double> &Cx = args.
array<
double>(
"Cx");
2201 const xt::pyarray<double> &Cy = args.
array<
double>(
"Cy");
2202 const xt::pyarray<double> &CTx = args.
array<
double>(
"CTx");
2203 const xt::pyarray<double> &CTy = args.
array<
double>(
"CTy");
2204 const int numDOFsPerEqn = args.
scalar<
int>(
"numDOFsPerEqn");
2205 const xt::pyarray<int> &csrRowIndeces_DofLoops =
2206 args.
array<
int>(
"csrRowIndeces_DofLoops");
2207 const xt::pyarray<int> &csrColumnOffsets_DofLoops =
2208 args.
array<
int>(
"csrColumnOffsets_DofLoops");
2209 const xt::pyarray<double> &lumped_mass_matrix =
2210 args.
array<
double>(
"lumped_mass_matrix");
2211 const double cfl_run = args.
scalar<
double>(
"cfl_run");
2212 const double hEps = args.
scalar<
double>(
"hEps");
2213 xt::pyarray<double> &hnp1_at_quad_point =
2214 args.
array<
double>(
"hnp1_at_quad_point");
2215 xt::pyarray<double> &hunp1_at_quad_point =
2216 args.
array<
double>(
"hunp1_at_quad_point");
2217 xt::pyarray<double> &hvnp1_at_quad_point =
2218 args.
array<
double>(
"hvnp1_at_quad_point");
2219 xt::pyarray<double> &hetanp1_at_quad_point =
2220 args.
array<
double>(
"hetanp1_at_quad_point");
2221 xt::pyarray<double> &hwnp1_at_quad_point =
2222 args.
array<
double>(
"hwnp1_at_quad_point");
2223 xt::pyarray<double> &hbetanp1_at_quad_point =
2224 args.
array<
double>(
"hbetanp1_at_quad_point");
2225 int LUMPED_MASS_MATRIX = args.
scalar<
int>(
"LUMPED_MASS_MATRIX");
2226 double dt = args.
scalar<
double>(
"dt");
2227 xt::pyarray<double> &quantDOFs = args.
array<
double>(
"quantDOFs");
2228 int SECOND_CALL_CALCULATE_RESIDUAL =
2229 args.
scalar<
int>(
"SECOND_CALL_CALCULATE_RESIDUAL");
2230 int COMPUTE_NORMALS = args.
scalar<
int>(
"COMPUTE_NORMALS");
2231 xt::pyarray<double> &normalx = args.
array<
double>(
"normalx");
2232 xt::pyarray<double> &normaly = args.
array<
double>(
"normaly");
2233 const int lstage = args.
scalar<
int>(
"lstage");
2234 const xt::pyarray<double> &MassMatrix = args.
array<
double>(
"MassMatrix");
2235 const xt::pyarray<double> &RHS_high_h = args.
array<
double>(
"RHS_high_h");
2236 const xt::pyarray<double> &RHS_high_hu = args.
array<
double>(
"RHS_high_hu");
2237 const xt::pyarray<double> &RHS_high_hv = args.
array<
double>(
"RHS_high_hv");
2238 const xt::pyarray<double> &RHS_high_heta =
2239 args.
array<
double>(
"RHS_high_heta");
2240 const xt::pyarray<double> &RHS_high_hw = args.
array<
double>(
"RHS_high_hw");
2241 const xt::pyarray<double> &RHS_high_hbeta =
2242 args.
array<
double>(
"RHS_high_hbeta");
2251 for (
int eN = 0; eN < nElements_global; eN++) {
2253 double elementResidual_h[nDOF_test_element],
2254 elementResidual_hu[nDOF_test_element],
2255 elementResidual_hv[nDOF_test_element],
2256 elementResidual_heta[nDOF_test_element],
2257 elementResidual_hw[nDOF_test_element],
2258 elementResidual_hbeta[nDOF_test_element];
2260 for (
int i = 0; i < nDOF_test_element; i++) {
2261 elementResidual_h[i] = 0.0;
2262 elementResidual_hu[i] = 0.0;
2263 elementResidual_hv[i] = 0.0;
2264 elementResidual_heta[i] = 0.0;
2265 elementResidual_hw[i] = 0.0;
2266 elementResidual_hbeta[i] = 0.0;
2271 for (
int k = 0; k < nQuadraturePoints_element; k++) {
2273 int eN_k = eN * nQuadraturePoints_element + k,
2274 eN_k_nSpace = eN_k * nSpace,
2275 eN_nDOF_trial_element = eN * nDOF_trial_element;
2276 double h = 0.0, hu = 0.0, hv = 0.0, heta = 0.0, hw = 0.0,
2278 h_old = 0.0, hu_old = 0.0, hv_old = 0.0, heta_old = 0.0,
2281 jac[nSpace * nSpace], jacDet, jacInv[nSpace * nSpace],
2282 h_test_dV[nDOF_trial_element], dV, x, y,
xt, yt;
2284 ck.calculateMapping_element(
2285 eN, k, mesh_dof.data(), mesh_l2g.data(), mesh_trial_ref.data(),
2286 mesh_grad_trial_ref.data(), jac, jacDet, jacInv, x, y);
2288 dV = fabs(jacDet) * dV_ref[k];
2292 ck.valFromDOF(porosity_dof.data(),
2293 &h_l2g.data()[eN * nDOF_trial_element],
2294 &h_trial_ref.data()[k * nDOF_trial_element], phi_q);
2298 ck.valFromDOF(h_dof.data(), &h_l2g.data()[eN_nDOF_trial_element],
2299 &h_trial_ref.data()[k * nDOF_trial_element], h);
2300 ck.valFromDOF(hu_dof.data(), &vel_l2g[eN_nDOF_trial_element],
2301 &vel_trial_ref.data()[k * nDOF_trial_element], hu);
2302 ck.valFromDOF(hv_dof.data(), &vel_l2g[eN_nDOF_trial_element],
2303 &vel_trial_ref.data()[k * nDOF_trial_element], hv);
2304 ck.valFromDOF(heta_dof.data(), &vel_l2g.data()[eN_nDOF_trial_element],
2305 &vel_trial_ref.data()[k * nDOF_trial_element], heta);
2306 ck.valFromDOF(hw_dof.data(), &vel_l2g.data()[eN_nDOF_trial_element],
2307 &vel_trial_ref.data()[k * nDOF_trial_element], hw);
2308 ck.valFromDOF(hbeta_dof.data(), &vel_l2g.data()[eN_nDOF_trial_element],
2309 &vel_trial_ref.data()[k * nDOF_trial_element], hbeta);
2311 ck.valFromDOF(h_dof_old.data(), &h_l2g.data()[eN_nDOF_trial_element],
2312 &h_trial_ref.data()[k * nDOF_trial_element], h_old);
2313 ck.valFromDOF(hu_dof_old.data(), &vel_l2g.data()[eN_nDOF_trial_element],
2314 &vel_trial_ref.data()[k * nDOF_trial_element], hu_old);
2315 ck.valFromDOF(hv_dof_old.data(), &vel_l2g.data()[eN_nDOF_trial_element],
2316 &vel_trial_ref.data()[k * nDOF_trial_element], hv_old);
2317 ck.valFromDOF(heta_dof_old.data(), &vel_l2g[eN_nDOF_trial_element],
2318 &vel_trial_ref.data()[k * nDOF_trial_element], heta_old);
2319 ck.valFromDOF(hw_dof_old.data(), &vel_l2g.data()[eN_nDOF_trial_element],
2320 &vel_trial_ref.data()[k * nDOF_trial_element], hw_old);
2321 ck.valFromDOF(hbeta_dof_old.data(),
2322 &vel_l2g.data()[eN_nDOF_trial_element],
2323 &vel_trial_ref.data()[k * nDOF_trial_element], hbeta_old);
2325 calculateCFL(elementDiameter.data()[eN], g, h_old, hu_old, hv_old, hEps,
2328 for (
int j = 0; j < nDOF_trial_element; j++)
2329 h_test_dV[j] = h_test_ref[k * nDOF_trial_element + j] * dV;
2332 q_velocity[eN_k_nSpace + 0] =
2333 2 * h / (h * h + std::pow(fmax(h, hEps), 2)) * hu;
2334 q_velocity[eN_k_nSpace + 1] =
2335 2 * h / (h * h + std::pow(fmax(h, hEps), 2)) * hv;
2336 hnp1_at_quad_point[eN_k] = h;
2337 hunp1_at_quad_point[eN_k] = hu;
2338 hvnp1_at_quad_point[eN_k] = hv;
2339 hetanp1_at_quad_point[eN_k] = heta;
2340 hwnp1_at_quad_point[eN_k] = hw;
2341 hbetanp1_at_quad_point[eN_k] = hbeta;
2343 for (
int i = 0; i < nDOF_test_element; i++) {
2345 elementResidual_h[i] += (h - h_old) * h_test_dV[i];
2346 elementResidual_hu[i] += (hu - hu_old) * h_test_dV[i];
2347 elementResidual_hv[i] += (hv - hv_old) * h_test_dV[i];
2348 elementResidual_heta[i] += (heta - heta_old) * h_test_dV[i];
2349 elementResidual_hw[i] += (hw - hw_old) * h_test_dV[i];
2350 elementResidual_hbeta[i] += (hbeta - hbeta_old) * h_test_dV[i];
2354 for (
int i = 0; i < nDOF_test_element; i++) {
2355 int eN_i = eN * nDOF_test_element + i;
2358 int h_gi = h_l2g[eN_i];
2361 globalResidual[offset_h + stride_h * h_gi] += elementResidual_h[i];
2362 globalResidual[offset_hu + stride_hu * h_gi] += elementResidual_hu[i];
2363 globalResidual[offset_hv + stride_hv * h_gi] += elementResidual_hv[i];
2364 globalResidual[offset_heta + stride_heta * h_gi] +=
2365 elementResidual_heta[i];
2366 globalResidual[offset_hw + stride_hw * h_gi] += elementResidual_hw[i];
2367 globalResidual[offset_hbeta + stride_hbeta * h_gi] +=
2368 elementResidual_hbeta[i];
2373 if (SECOND_CALL_CALCULATE_RESIDUAL == 0)
2382 for (
int i = 0; i < numDOFsPerEqn; i++) {
2385 const double hi = h_dof_old[i];
2386 const double hui = hu_dof_old[i];
2387 const double hvi = hv_dof_old[i];
2388 const double hetai = heta_dof_old[i];
2389 const double hwi = hw_dof_old[i];
2390 const double hbetai = hbeta_dof_old[i];
2391 const double mi = lumped_mass_matrix[i];
2393 double sum_RHS_h = 0.;
2394 double sum_RHS_hu = 0.;
2395 double sum_RHS_hv = 0.;
2396 double sum_RHS_heta = 0.;
2397 double sum_RHS_hw = 0.;
2398 double sum_RHS_hbeta = 0.;
2400 double b_ij = 0., b_ji = 0.;
2403 for (
int offset = csrRowIndeces_DofLoops[i];
2404 offset < csrRowIndeces_DofLoops[i + 1]; offset++) {
2406 int j = csrColumnOffsets_DofLoops[offset];
2409 const double mj = lumped_mass_matrix[j];
2413 b_ij = (0. - MassMatrix[ij] / mj);
2414 b_ji = (0. - MassMatrix[ij] / mi);
2416 b_ij = (1. - MassMatrix[ij] / mj);
2417 b_ji = (1. - MassMatrix[ij] / mi);
2421 sum_RHS_h += b_ij * RHS_high_h[j] - b_ji * RHS_high_h[i];
2422 sum_RHS_hu += b_ij * RHS_high_hu[j] - b_ji * RHS_high_hu[i];
2423 sum_RHS_hv += b_ij * RHS_high_hv[j] - b_ji * RHS_high_hv[i];
2424 sum_RHS_heta += b_ij * RHS_high_heta[j] - b_ji * RHS_high_heta[i];
2425 sum_RHS_hw += b_ij * RHS_high_hw[j] - b_ji * RHS_high_hw[i];
2426 sum_RHS_hbeta += b_ij * RHS_high_hbeta[j] - b_ji * RHS_high_hbeta[i];
2434 globalResidual[offset_h + stride_h * i] =
2435 hi + dt / mi * (RHS_high_h[i] + sum_RHS_h);
2437 globalResidual[offset_hu + stride_hu * i] =
2438 hui + dt / mi * (RHS_high_hu[i] + sum_RHS_hu);
2440 globalResidual[offset_hv + stride_hv * i] =
2441 hvi + dt / mi * (RHS_high_hv[i] + sum_RHS_hv);
2443 globalResidual[offset_heta + stride_heta * i] =
2444 hetai + dt / mi * (RHS_high_heta[i] + sum_RHS_heta);
2446 globalResidual[offset_hw + stride_hw * i] =
2447 hwi + dt / mi * (RHS_high_hw[i] + sum_RHS_hw);
2449 globalResidual[offset_hbeta + stride_hbeta * i] =
2450 hbetai + dt / mi * (RHS_high_hbeta[i] + sum_RHS_hbeta);
2453 if (globalResidual[offset_h + stride_h * i] >= -hEps &&
2454 globalResidual[offset_h + stride_h * i] < hEps) {
2455 globalResidual[offset_h + stride_h * i] = 0.;
2462 if (COMPUTE_NORMALS == 1) {
2465 for (
int ebNE = 0; ebNE < nExteriorElementBoundaries_global; ebNE++) {
2467 ebN = exteriorElementBoundariesArray[ebNE],
2468 eN = elementBoundaryElementsArray[ebN * 2 + 0],
2469 ebN_local = elementBoundaryLocalElementBoundariesArray[ebN * 2 + 0];
2476 ebN_local * nQuadraturePoints_elementBoundary + kb;
2477 double jac_ext[nSpace * nSpace], jacDet_ext,
2478 jacInv_ext[nSpace * nSpace], boundaryJac[nSpace * (nSpace - 1)],
2479 metricTensor[(nSpace - 1) * (nSpace - 1)], metricTensorDetSqrt,
2483 ck.calculateMapping_elementBoundary(
2484 eN, ebN_local, kb, ebN_local_kb, mesh_dof.data(), mesh_l2g.data(),
2485 mesh_trial_trace_ref.data(), mesh_grad_trial_trace_ref.data(),
2486 boundaryJac_ref.data(), jac_ext, jacDet_ext, jacInv_ext,
2487 boundaryJac, metricTensor, metricTensorDetSqrt, normal_ref.data(),
2488 normal, x_ext, y_ext);
2491 for (
int i = 0; i < nDOF_test_element; i++) {
2492 int eN_i = eN * nDOF_test_element + i;
2493 int gi = h_l2g[eN_i];
2494 normalx[gi] += 0.5 * normal[0] * (i == ebN_local ? 0. : 1.);
2495 normaly[gi] += 0.5 * normal[1] * (i == ebN_local ? 0. : 1.);
2499 for (
int gi = 0; gi < numDOFsPerEqn; gi++) {
2500 double norm_factor =
2501 sqrt(std::pow(normalx[gi], 2) + std::pow(normaly[gi], 2));
2502 if (norm_factor != 0) {
2503 normalx[gi] /= norm_factor;
2504 normaly[gi] /= norm_factor;
2512 xt::pyarray<double> &mesh_trial_ref = args.
array<
double>(
"mesh_trial_ref");
2513 xt::pyarray<double> &mesh_grad_trial_ref =
2514 args.
array<
double>(
"mesh_grad_trial_ref");
2515 xt::pyarray<double> &mesh_dof = args.
array<
double>(
"mesh_dof");
2516 xt::pyarray<double> &mesh_velocity_dof =
2517 args.
array<
double>(
"mesh_velocity_dof");
2518 double MOVING_DOMAIN = args.
scalar<
double>(
"MOVING_DOMAIN");
2519 xt::pyarray<int> &mesh_l2g = args.
array<
int>(
"mesh_l2g");
2520 xt::pyarray<double> &dV_ref = args.
array<
double>(
"dV_ref");
2521 xt::pyarray<double> &h_trial_ref = args.
array<
double>(
"h_trial_ref");
2522 xt::pyarray<double> &h_grad_trial_ref =
2523 args.
array<
double>(
"h_grad_trial_ref");
2524 xt::pyarray<double> &h_test_ref = args.
array<
double>(
"h_test_ref");
2525 xt::pyarray<double> &h_grad_test_ref =
2526 args.
array<
double>(
"h_grad_test_ref");
2527 xt::pyarray<double> &vel_trial_ref = args.
array<
double>(
"vel_trial_ref");
2528 xt::pyarray<double> &vel_grad_trial_ref =
2529 args.
array<
double>(
"vel_grad_trial_ref");
2530 xt::pyarray<double> &vel_test_ref = args.
array<
double>(
"vel_test_ref");
2531 xt::pyarray<double> &vel_grad_test_ref =
2532 args.
array<
double>(
"vel_grad_test_ref");
2533 xt::pyarray<double> &mesh_trial_trace_ref =
2534 args.
array<
double>(
"mesh_trial_trace_ref");
2535 xt::pyarray<double> &mesh_grad_trial_trace_ref =
2536 args.
array<
double>(
"mesh_grad_trial_trace_ref");
2537 xt::pyarray<double> &dS_ref = args.
array<
double>(
"dS_ref");
2538 xt::pyarray<double> &h_trial_trace_ref =
2539 args.
array<
double>(
"h_trial_trace_ref");
2540 xt::pyarray<double> &h_grad_trial_trace_ref =
2541 args.
array<
double>(
"h_grad_trial_trace_ref");
2542 xt::pyarray<double> &h_test_trace_ref =
2543 args.
array<
double>(
"h_test_trace_ref");
2544 xt::pyarray<double> &h_grad_test_trace_ref =
2545 args.
array<
double>(
"h_grad_test_trace_ref");
2546 xt::pyarray<double> &vel_trial_trace_ref =
2547 args.
array<
double>(
"vel_trial_trace_ref");
2548 xt::pyarray<double> &vel_grad_trial_trace_ref =
2549 args.
array<
double>(
"vel_grad_trial_trace_ref");
2550 xt::pyarray<double> &vel_test_trace_ref =
2551 args.
array<
double>(
"vel_test_trace_ref");
2552 xt::pyarray<double> &vel_grad_test_trace_ref =
2553 args.
array<
double>(
"vel_grad_test_trace_ref");
2554 xt::pyarray<double> &normal_ref = args.
array<
double>(
"normal_ref");
2555 xt::pyarray<double> &boundaryJac_ref =
2556 args.
array<
double>(
"boundaryJac_ref");
2557 xt::pyarray<double> &elementDiameter =
2558 args.
array<
double>(
"elementDiameter");
2559 int nElements_global = args.
scalar<
int>(
"nElements_global");
2560 double g = args.
scalar<
double>(
"g");
2561 xt::pyarray<int> &h_l2g = args.
array<
int>(
"h_l2g");
2562 xt::pyarray<int> &vel_l2g = args.
array<
int>(
"vel_l2g");
2563 xt::pyarray<double> &b_dof = args.
array<
double>(
"b_dof");
2564 xt::pyarray<double> &h_dof = args.
array<
double>(
"h_dof");
2565 xt::pyarray<double> &hu_dof = args.
array<
double>(
"hu_dof");
2566 xt::pyarray<double> &hv_dof = args.
array<
double>(
"hv_dof");
2567 xt::pyarray<double> &heta_dof = args.
array<
double>(
"heta_dof");
2568 xt::pyarray<double> &hw_dof = args.
array<
double>(
"hw_dof");
2569 xt::pyarray<double> &hbeta_dof = args.
array<
double>(
"hbeta_dof");
2570 xt::pyarray<double> &q_cfl = args.
array<
double>(
"q_cfl");
2571 xt::pyarray<int> &sdInfo_hu_hu_rowptr =
2572 args.
array<
int>(
"sdInfo_hu_hu_rowptr");
2573 xt::pyarray<int> &sdInfo_hu_hu_colind =
2574 args.
array<
int>(
"sdInfo_hu_hu_colind");
2575 xt::pyarray<int> &sdInfo_hu_hv_rowptr =
2576 args.
array<
int>(
"sdInfo_hu_hv_rowptr");
2577 xt::pyarray<int> &sdInfo_hu_hv_colind =
2578 args.
array<
int>(
"sdInfo_hu_hv_colind");
2579 xt::pyarray<int> &sdInfo_hv_hv_rowptr =
2580 args.
array<
int>(
"sdInfo_hv_hv_rowptr");
2581 xt::pyarray<int> &sdInfo_hv_hv_colind =
2582 args.
array<
int>(
"sdInfo_hv_hv_colind");
2583 xt::pyarray<int> &sdInfo_hv_hu_rowptr =
2584 args.
array<
int>(
"sdInfo_hv_hu_rowptr");
2585 xt::pyarray<int> &sdInfo_hv_hu_colind =
2586 args.
array<
int>(
"sdInfo_hv_hu_colind");
2587 xt::pyarray<int> &csrRowIndeces_h_h = args.
array<
int>(
"csrRowIndeces_h_h");
2588 xt::pyarray<int> &csrColumnOffsets_h_h =
2589 args.
array<
int>(
"csrColumnOffsets_h_h");
2590 xt::pyarray<int> &csrRowIndeces_h_hu =
2591 args.
array<
int>(
"csrRowIndeces_h_hu");
2592 xt::pyarray<int> &csrColumnOffsets_h_hu =
2593 args.
array<
int>(
"csrColumnOffsets_h_hu");
2594 xt::pyarray<int> &csrRowIndeces_h_hv =
2595 args.
array<
int>(
"csrRowIndeces_h_hv");
2596 xt::pyarray<int> &csrColumnOffsets_h_hv =
2597 args.
array<
int>(
"csrColumnOffsets_h_hv");
2598 xt::pyarray<int> &csrRowIndeces_h_heta =
2599 args.
array<
int>(
"csrRowIndeces_h_heta");
2600 xt::pyarray<int> &csrColumnOffsets_h_heta =
2601 args.
array<
int>(
"csrColumnOffsets_h_heta");
2602 xt::pyarray<int> &csrRowIndeces_h_hw =
2603 args.
array<
int>(
"csrRowIndeces_h_hw");
2604 xt::pyarray<int> &csrColumnOffsets_h_hw =
2605 args.
array<
int>(
"csrColumnOffsets_h_hw");
2606 xt::pyarray<int> &csrRowIndeces_h_hbeta =
2607 args.
array<
int>(
"csrRowIndeces_h_hbeta");
2608 xt::pyarray<int> &csrColumnOffsets_h_hbeta =
2609 args.
array<
int>(
"csrColumnOffsets_h_hbeta");
2610 xt::pyarray<int> &csrRowIndeces_hu_h =
2611 args.
array<
int>(
"csrRowIndeces_hu_h");
2612 xt::pyarray<int> &csrColumnOffsets_hu_h =
2613 args.
array<
int>(
"csrColumnOffsets_hu_h");
2614 xt::pyarray<int> &csrRowIndeces_hu_hu =
2615 args.
array<
int>(
"csrRowIndeces_hu_hu");
2616 xt::pyarray<int> &csrColumnOffsets_hu_hu =
2617 args.
array<
int>(
"csrColumnOffsets_hu_hu");
2618 xt::pyarray<int> &csrRowIndeces_hu_hv =
2619 args.
array<
int>(
"csrRowIndeces_hu_hv");
2620 xt::pyarray<int> &csrColumnOffsets_hu_hv =
2621 args.
array<
int>(
"csrColumnOffsets_hu_hv");
2622 xt::pyarray<int> &csrRowIndeces_hu_heta =
2623 args.
array<
int>(
"csrRowIndeces_hu_heta");
2624 xt::pyarray<int> &csrColumnOffsets_hu_heta =
2625 args.
array<
int>(
"csrColumnOffsets_hu_heta");
2626 xt::pyarray<int> &csrRowIndeces_hu_hw =
2627 args.
array<
int>(
"csrRowIndeces_hu_hw");
2628 xt::pyarray<int> &csrColumnOffsets_hu_hw =
2629 args.
array<
int>(
"csrColumnOffsets_hu_hw");
2630 xt::pyarray<int> &csrRowIndeces_hu_hbeta =
2631 args.
array<
int>(
"csrRowIndeces_hu_hbeta");
2632 xt::pyarray<int> &csrColumnOffsets_hu_hbeta =
2633 args.
array<
int>(
"csrColumnOffsets_hu_hbeta");
2634 xt::pyarray<int> &csrRowIndeces_hv_h =
2635 args.
array<
int>(
"csrRowIndeces_hv_h");
2636 xt::pyarray<int> &csrColumnOffsets_hv_h =
2637 args.
array<
int>(
"csrColumnOffsets_hv_h");
2638 xt::pyarray<int> &csrRowIndeces_hv_hu =
2639 args.
array<
int>(
"csrRowIndeces_hv_hu");
2640 xt::pyarray<int> &csrColumnOffsets_hv_hu =
2641 args.
array<
int>(
"csrColumnOffsets_hv_hu");
2642 xt::pyarray<int> &csrRowIndeces_hv_hv =
2643 args.
array<
int>(
"csrRowIndeces_hv_hv");
2644 xt::pyarray<int> &csrColumnOffsets_hv_hv =
2645 args.
array<
int>(
"csrColumnOffsets_hv_hv");
2646 xt::pyarray<int> &csrRowIndeces_hv_heta =
2647 args.
array<
int>(
"csrRowIndeces_hv_heta");
2648 xt::pyarray<int> &csrColumnOffsets_hv_heta =
2649 args.
array<
int>(
"csrColumnOffsets_hv_heta");
2650 xt::pyarray<int> &csrRowIndeces_hv_hw =
2651 args.
array<
int>(
"csrRowIndeces_hv_hw");
2652 xt::pyarray<int> &csrColumnOffsets_hv_hw =
2653 args.
array<
int>(
"csrColumnOffsets_hv_hw");
2654 xt::pyarray<int> &csrRowIndeces_hv_hbeta =
2655 args.
array<
int>(
"csrRowIndeces_hv_hbeta");
2656 xt::pyarray<int> &csrColumnOffsets_hv_hbeta =
2657 args.
array<
int>(
"csrColumnOffsets_hv_hbeta");
2658 xt::pyarray<int> &csrRowIndeces_heta_h =
2659 args.
array<
int>(
"csrRowIndeces_heta_h");
2660 xt::pyarray<int> &csrColumnOffsets_heta_h =
2661 args.
array<
int>(
"csrColumnOffsets_heta_h");
2662 xt::pyarray<int> &csrRowIndeces_heta_hu =
2663 args.
array<
int>(
"csrRowIndeces_heta_hu");
2664 xt::pyarray<int> &csrColumnOffsets_heta_hu =
2665 args.
array<
int>(
"csrColumnOffsets_heta_hu");
2666 xt::pyarray<int> &csrRowIndeces_heta_hv =
2667 args.
array<
int>(
"csrRowIndeces_heta_hv");
2668 xt::pyarray<int> &csrColumnOffsets_heta_hv =
2669 args.
array<
int>(
"csrColumnOffsets_heta_hv");
2670 xt::pyarray<int> &csrRowIndeces_heta_heta =
2671 args.
array<
int>(
"csrRowIndeces_heta_heta");
2672 xt::pyarray<int> &csrColumnOffsets_heta_heta =
2673 args.
array<
int>(
"csrColumnOffsets_heta_heta");
2674 xt::pyarray<int> &csrRowIndeces_heta_hw =
2675 args.
array<
int>(
"csrRowIndeces_heta_hw");
2676 xt::pyarray<int> &csrColumnOffsets_heta_hw =
2677 args.
array<
int>(
"csrColumnOffsets_heta_hw");
2678 xt::pyarray<int> &csrRowIndeces_heta_hbeta =
2679 args.
array<
int>(
"csrRowIndeces_heta_hbeta");
2680 xt::pyarray<int> &csrColumnOffsets_heta_hbeta =
2681 args.
array<
int>(
"csrColumnOffsets_heta_hbeta");
2682 xt::pyarray<int> &csrRowIndeces_hw_h =
2683 args.
array<
int>(
"csrRowIndeces_hw_h");
2684 xt::pyarray<int> &csrColumnOffsets_hw_h =
2685 args.
array<
int>(
"csrColumnOffsets_hw_h");
2686 xt::pyarray<int> &csrRowIndeces_hw_hu =
2687 args.
array<
int>(
"csrRowIndeces_hw_hu");
2688 xt::pyarray<int> &csrColumnOffsets_hw_hu =
2689 args.
array<
int>(
"csrColumnOffsets_hw_hu");
2690 xt::pyarray<int> &csrRowIndeces_hw_hv =
2691 args.
array<
int>(
"csrRowIndeces_hw_hv");
2692 xt::pyarray<int> &csrColumnOffsets_hw_hv =
2693 args.
array<
int>(
"csrColumnOffsets_hw_hv");
2694 xt::pyarray<int> &csrRowIndeces_hw_heta =
2695 args.
array<
int>(
"csrRowIndeces_hw_heta");
2696 xt::pyarray<int> &csrColumnOffsets_hw_heta =
2697 args.
array<
int>(
"csrColumnOffsets_hw_heta");
2698 xt::pyarray<int> &csrRowIndeces_hw_hw =
2699 args.
array<
int>(
"csrRowIndeces_hw_hw");
2700 xt::pyarray<int> &csrColumnOffsets_hw_hw =
2701 args.
array<
int>(
"csrColumnOffsets_hw_hw");
2702 xt::pyarray<int> &csrRowIndeces_hw_hbeta =
2703 args.
array<
int>(
"csrRowIndeces_hw_hbeta");
2704 xt::pyarray<int> &csrColumnOffsets_hw_hbeta =
2705 args.
array<
int>(
"csrColumnOffsets_hw_hbeta");
2707 xt::pyarray<int> &csrRowIndeces_hbeta_h =
2708 args.
array<
int>(
"csrRowIndeces_hbeta_h");
2709 xt::pyarray<int> &csrColumnOffsets_hbeta_h =
2710 args.
array<
int>(
"csrColumnOffsets_hbeta_h");
2711 xt::pyarray<int> &csrRowIndeces_hbeta_hu =
2712 args.
array<
int>(
"csrRowIndeces_hbeta_hu");
2713 xt::pyarray<int> &csrColumnOffsets_hbeta_hu =
2714 args.
array<
int>(
"csrColumnOffsets_hbeta_hu");
2715 xt::pyarray<int> &csrRowIndeces_hbeta_hv =
2716 args.
array<
int>(
"csrRowIndeces_hbeta_hv");
2717 xt::pyarray<int> &csrColumnOffsets_hbeta_hv =
2718 args.
array<
int>(
"csrColumnOffsets_hbeta_hv");
2719 xt::pyarray<int> &csrRowIndeces_hbeta_heta =
2720 args.
array<
int>(
"csrRowIndeces_hbeta_heta");
2721 xt::pyarray<int> &csrColumnOffsets_hbeta_heta =
2722 args.
array<
int>(
"csrColumnOffsets_hbeta_heta");
2723 xt::pyarray<int> &csrRowIndeces_hbeta_hw =
2724 args.
array<
int>(
"csrRowIndeces_hbeta_hw");
2725 xt::pyarray<int> &csrColumnOffsets_hbeta_hw =
2726 args.
array<
int>(
"csrColumnOffsets_hbeta_hw");
2727 xt::pyarray<int> &csrRowIndeces_hbeta_hbeta =
2728 args.
array<
int>(
"csrRowIndeces_hbeta_hbeta");
2729 xt::pyarray<int> &csrColumnOffsets_hbeta_hbeta =
2730 args.
array<
int>(
"csrColumnOffsets_hbeta_hbeta");
2731 xt::pyarray<double> &globalJacobian = args.
array<
double>(
"globalJacobian");
2732 xt::pyarray<double> &porosity_dof = args.
array<
double>(
"porosity_dof");
2733 int nExteriorElementBoundaries_global =
2734 args.
scalar<
int>(
"nExteriorElementBoundaries_global");
2735 xt::pyarray<int> &exteriorElementBoundariesArray =
2736 args.
array<
int>(
"exteriorElementBoundariesArray");
2737 xt::pyarray<int> &elementBoundaryElementsArray =
2738 args.
array<
int>(
"elementBoundaryElementsArray");
2739 xt::pyarray<int> &elementBoundaryLocalElementBoundariesArray =
2740 args.
array<
int>(
"elementBoundaryLocalElementBoundariesArray");
2741 xt::pyarray<int> &isDOFBoundary_h = args.
array<
int>(
"isDOFBoundary_h");
2742 xt::pyarray<int> &isDOFBoundary_hu = args.
array<
int>(
"isDOFBoundary_hu");
2743 xt::pyarray<int> &isDOFBoundary_hv = args.
array<
int>(
"isDOFBoundary_hv");
2744 xt::pyarray<int> &isAdvectiveFluxBoundary_h =
2745 args.
array<
int>(
"isAdvectiveFluxBoundary_h");
2746 xt::pyarray<int> &isAdvectiveFluxBoundary_hu =
2747 args.
array<
int>(
"isAdvectiveFluxBoundary_hu");
2748 xt::pyarray<int> &isAdvectiveFluxBoundary_hv =
2749 args.
array<
int>(
"isAdvectiveFluxBoundary_hv");
2750 xt::pyarray<int> &isDiffusiveFluxBoundary_hu =
2751 args.
array<
int>(
"isDiffusiveFluxBoundary_hu");
2752 xt::pyarray<int> &isDiffusiveFluxBoundary_hv =
2753 args.
array<
int>(
"isDiffusiveFluxBoundary_hv");
2754 xt::pyarray<double> &ebqe_bc_h_ext = args.
array<
double>(
"ebqe_bc_h_ext");
2755 xt::pyarray<double> &ebqe_bc_flux_mass_ext =
2756 args.
array<
double>(
"ebqe_bc_flux_mass_ext");
2757 xt::pyarray<double> &ebqe_bc_flux_mom_hu_adv_ext =
2758 args.
array<
double>(
"ebqe_bc_flux_mom_hu_adv_ext");
2759 xt::pyarray<double> &ebqe_bc_flux_mom_hv_adv_ext =
2760 args.
array<
double>(
"ebqe_bc_flux_mom_hv_adv_ext");
2761 xt::pyarray<double> &ebqe_bc_hu_ext = args.
array<
double>(
"ebqe_bc_hu_ext");
2762 xt::pyarray<double> &ebqe_bc_flux_hu_diff_ext =
2763 args.
array<
double>(
"ebqe_bc_flux_hu_diff_ext");
2764 xt::pyarray<double> &ebqe_penalty_ext =
2765 args.
array<
double>(
"ebqe_penalty_ext");
2766 xt::pyarray<double> &ebqe_bc_hv_ext = args.
array<
double>(
"ebqe_bc_hv_ext");
2767 xt::pyarray<double> &ebqe_bc_flux_hv_diff_ext =
2768 args.
array<
double>(
"ebqe_bc_flux_hv_diff_ext");
2769 xt::pyarray<int> &csrColumnOffsets_eb_h_h =
2770 args.
array<
int>(
"csrColumnOffsets_eb_h_h");
2771 xt::pyarray<int> &csrColumnOffsets_eb_h_hu =
2772 args.
array<
int>(
"csrColumnOffsets_eb_h_hu");
2773 xt::pyarray<int> &csrColumnOffsets_eb_h_hv =
2774 args.
array<
int>(
"csrColumnOffsets_eb_h_hv");
2775 xt::pyarray<int> &csrColumnOffsets_eb_hu_h =
2776 args.
array<
int>(
"csrColumnOffsets_eb_hu_h");
2777 xt::pyarray<int> &csrColumnOffsets_eb_hu_hu =
2778 args.
array<
int>(
"csrColumnOffsets_eb_hu_hu");
2779 xt::pyarray<int> &csrColumnOffsets_eb_hu_hv =
2780 args.
array<
int>(
"csrColumnOffsets_eb_hu_hv");
2781 xt::pyarray<int> &csrColumnOffsets_eb_hv_h =
2782 args.
array<
int>(
"csrColumnOffsets_eb_hv_h");
2783 xt::pyarray<int> &csrColumnOffsets_eb_hv_hu =
2784 args.
array<
int>(
"csrColumnOffsets_eb_hv_hu");
2785 xt::pyarray<int> &csrColumnOffsets_eb_hv_hv =
2786 args.
array<
int>(
"csrColumnOffsets_eb_hv_hv");
2787 double dt = args.
scalar<
double>(
"dt");
2792 for (
int eN = 0; eN < nElements_global; eN++) {
2793 double elementJacobian_h_h[nDOF_test_element]
2794 [nDOF_trial_element],
2795 elementJacobian_hu_hu[nDOF_test_element][nDOF_trial_element],
2796 elementJacobian_hv_hv[nDOF_test_element][nDOF_trial_element],
2797 elementJacobian_heta_heta[nDOF_test_element][nDOF_trial_element],
2798 elementJacobian_hw_hw[nDOF_test_element][nDOF_trial_element],
2799 elementJacobian_hbeta_hbeta[nDOF_test_element][nDOF_trial_element];
2800 for (
int i = 0; i < nDOF_test_element; i++)
2801 for (
int j = 0; j < nDOF_trial_element; j++) {
2802 elementJacobian_h_h[i][j] = 0.0;
2803 elementJacobian_hu_hu[i][j] = 0.0;
2804 elementJacobian_hv_hv[i][j] = 0.0;
2805 elementJacobian_heta_heta[i][j] = 0.0;
2806 elementJacobian_hw_hw[i][j] = 0.0;
2807 elementJacobian_hbeta_hbeta[i][j] = 0.0;
2809 for (
int k = 0; k < nQuadraturePoints_element; k++) {
2810 int eN_k = eN * nQuadraturePoints_element +
2812 eN_k_nSpace = eN_k * nSpace,
2813 eN_nDOF_trial_element =
2814 eN * nDOF_trial_element;
2818 double jac[nSpace * nSpace], jacDet, jacInv[nSpace * nSpace],
2819 dV, h_test_dV[nDOF_test_element], vel_test_dV[nDOF_test_element], x,
2822 ck.calculateMapping_element(
2823 eN, k, mesh_dof.data(), mesh_l2g.data(), mesh_trial_ref.data(),
2824 mesh_grad_trial_ref.data(), jac, jacDet, jacInv, x, y);
2826 dV = fabs(jacDet) * dV_ref[k];
2830 ck.valFromDOF(porosity_dof.data(),
2831 &h_l2g.data()[eN * nDOF_trial_element],
2832 &h_trial_ref.data()[k * nDOF_trial_element], phi_q);
2836 for (
int j = 0; j < nDOF_trial_element; j++) {
2837 h_test_dV[j] = h_test_ref[k * nDOF_trial_element + j] * dV;
2838 vel_test_dV[j] = vel_test_ref[k * nDOF_trial_element + j] * dV;
2840 for (
int i = 0; i < nDOF_test_element; i++) {
2841 int i_nSpace = i * nSpace;
2842 for (
int j = 0; j < nDOF_trial_element; j++) {
2843 int j_nSpace = j * nSpace;
2844 elementJacobian_h_h[i][j] +=
2845 h_trial_ref[k * nDOF_trial_element + j] * h_test_dV[i];
2846 elementJacobian_hu_hu[i][j] +=
2847 vel_trial_ref[k * nDOF_trial_element + j] * vel_test_dV[i];
2848 elementJacobian_hv_hv[i][j] +=
2849 vel_trial_ref[k * nDOF_trial_element + j] * vel_test_dV[i];
2850 elementJacobian_heta_heta[i][j] +=
2851 vel_trial_ref[k * nDOF_trial_element + j] * vel_test_dV[i];
2852 elementJacobian_hw_hw[i][j] +=
2853 vel_trial_ref[k * nDOF_trial_element + j] * vel_test_dV[i];
2854 elementJacobian_hbeta_hbeta[i][j] +=
2855 vel_trial_ref[k * nDOF_trial_element + j] * vel_test_dV[i];
2862 for (
int i = 0; i < nDOF_test_element; i++) {
2863 int eN_i = eN * nDOF_test_element + i;
2864 for (
int j = 0; j < nDOF_trial_element; j++) {
2865 int eN_i_j = eN_i * nDOF_trial_element + j;
2866 globalJacobian[csrRowIndeces_h_h[eN_i] +
2867 csrColumnOffsets_h_h[eN_i_j]] +=
2868 elementJacobian_h_h[i][j];
2869 globalJacobian[csrRowIndeces_hu_hu[eN_i] +
2870 csrColumnOffsets_hu_hu[eN_i_j]] +=
2871 elementJacobian_hu_hu[i][j];
2872 globalJacobian[csrRowIndeces_hv_hv[eN_i] +
2873 csrColumnOffsets_hv_hv[eN_i_j]] +=
2874 elementJacobian_hv_hv[i][j];
2875 globalJacobian[csrRowIndeces_heta_heta[eN_i] +
2876 csrColumnOffsets_heta_heta[eN_i_j]] +=
2877 elementJacobian_heta_heta[i][j];
2878 globalJacobian[csrRowIndeces_hw_hw[eN_i] +
2879 csrColumnOffsets_hw_hw[eN_i_j]] +=
2880 elementJacobian_hw_hw[i][j];
2881 globalJacobian[csrRowIndeces_hbeta_hbeta[eN_i] +
2882 csrColumnOffsets_hbeta_hbeta[eN_i_j]] +=
2883 elementJacobian_hbeta_hbeta[i][j];
2890 xt::pyarray<double> &mesh_trial_ref = args.
array<
double>(
"mesh_trial_ref");
2891 xt::pyarray<double> &mesh_grad_trial_ref =
2892 args.
array<
double>(
"mesh_grad_trial_ref");
2893 xt::pyarray<double> &mesh_dof = args.
array<
double>(
"mesh_dof");
2894 xt::pyarray<double> &mesh_velocity_dof =
2895 args.
array<
double>(
"mesh_velocity_dof");
2896 double MOVING_DOMAIN = args.
scalar<
double>(
"MOVING_DOMAIN");
2897 xt::pyarray<int> &mesh_l2g = args.
array<
int>(
"mesh_l2g");
2898 xt::pyarray<double> &dV_ref = args.
array<
double>(
"dV_ref");
2899 xt::pyarray<double> &h_trial_ref = args.
array<
double>(
"h_trial_ref");
2900 xt::pyarray<double> &h_grad_trial_ref =
2901 args.
array<
double>(
"h_grad_trial_ref");
2902 xt::pyarray<double> &h_test_ref = args.
array<
double>(
"h_test_ref");
2903 xt::pyarray<double> &h_grad_test_ref =
2904 args.
array<
double>(
"h_grad_test_ref");
2905 xt::pyarray<double> &vel_trial_ref = args.
array<
double>(
"vel_trial_ref");
2906 xt::pyarray<double> &vel_grad_trial_ref =
2907 args.
array<
double>(
"vel_grad_trial_ref");
2908 xt::pyarray<double> &vel_test_ref = args.
array<
double>(
"vel_test_ref");
2909 xt::pyarray<double> &vel_grad_test_ref =
2910 args.
array<
double>(
"vel_grad_test_ref");
2911 xt::pyarray<double> &mesh_trial_trace_ref =
2912 args.
array<
double>(
"mesh_trial_trace_ref");
2913 xt::pyarray<double> &mesh_grad_trial_trace_ref =
2914 args.
array<
double>(
"mesh_grad_trial_trace_ref");
2915 xt::pyarray<double> &dS_ref = args.
array<
double>(
"dS_ref");
2916 xt::pyarray<double> &h_trial_trace_ref =
2917 args.
array<
double>(
"h_trial_trace_ref");
2918 xt::pyarray<double> &h_grad_trial_trace_ref =
2919 args.
array<
double>(
"h_grad_trial_trace_ref");
2920 xt::pyarray<double> &h_test_trace_ref =
2921 args.
array<
double>(
"h_test_trace_ref");
2922 xt::pyarray<double> &h_grad_test_trace_ref =
2923 args.
array<
double>(
"h_grad_test_trace_ref");
2924 xt::pyarray<double> &vel_trial_trace_ref =
2925 args.
array<
double>(
"vel_trial_trace_ref");
2926 xt::pyarray<double> &vel_grad_trial_trace_ref =
2927 args.
array<
double>(
"vel_grad_trial_trace_ref");
2928 xt::pyarray<double> &vel_test_trace_ref =
2929 args.
array<
double>(
"vel_test_trace_ref");
2930 xt::pyarray<double> &vel_grad_test_trace_ref =
2931 args.
array<
double>(
"vel_grad_test_trace_ref");
2932 xt::pyarray<double> &normal_ref = args.
array<
double>(
"normal_ref");
2933 xt::pyarray<double> &boundaryJac_ref =
2934 args.
array<
double>(
"boundaryJac_ref");
2935 xt::pyarray<double> &elementDiameter =
2936 args.
array<
double>(
"elementDiameter");
2937 int nElements_global = args.
scalar<
int>(
"nElements_global");
2938 double g = args.
scalar<
double>(
"g");
2939 xt::pyarray<int> &h_l2g = args.
array<
int>(
"h_l2g");
2940 xt::pyarray<int> &vel_l2g = args.
array<
int>(
"vel_l2g");
2941 xt::pyarray<double> &b_dof = args.
array<
double>(
"b_dof");
2942 xt::pyarray<double> &h_dof = args.
array<
double>(
"h_dof");
2943 xt::pyarray<double> &hu_dof = args.
array<
double>(
"hu_dof");
2944 xt::pyarray<double> &hv_dof = args.
array<
double>(
"hv_dof");
2945 xt::pyarray<double> &q_cfl = args.
array<
double>(
"q_cfl");
2946 xt::pyarray<int> &sdInfo_hu_hu_rowptr =
2947 args.
array<
int>(
"sdInfo_hu_hu_rowptr");
2948 xt::pyarray<int> &sdInfo_hu_hu_colind =
2949 args.
array<
int>(
"sdInfo_hu_hu_colind");
2950 xt::pyarray<int> &sdInfo_hu_hv_rowptr =
2951 args.
array<
int>(
"sdInfo_hu_hv_rowptr");
2952 xt::pyarray<int> &sdInfo_hu_hv_colind =
2953 args.
array<
int>(
"sdInfo_hu_hv_colind");
2954 xt::pyarray<int> &sdInfo_hv_hv_rowptr =
2955 args.
array<
int>(
"sdInfo_hv_hv_rowptr");
2956 xt::pyarray<int> &sdInfo_hv_hv_colind =
2957 args.
array<
int>(
"sdInfo_hv_hv_colind");
2958 xt::pyarray<int> &sdInfo_hv_hu_rowptr =
2959 args.
array<
int>(
"sdInfo_hv_hu_rowptr");
2960 xt::pyarray<int> &sdInfo_hv_hu_colind =
2961 args.
array<
int>(
"sdInfo_hv_hu_colind");
2963 xt::pyarray<int> &csrRowIndeces_h_h = args.
array<
int>(
"csrRowIndeces_h_h");
2964 xt::pyarray<int> &csrColumnOffsets_h_h =
2965 args.
array<
int>(
"csrColumnOffsets_h_h");
2966 xt::pyarray<int> &csrRowIndeces_h_hu =
2967 args.
array<
int>(
"csrRowIndeces_h_hu");
2968 xt::pyarray<int> &csrColumnOffsets_h_hu =
2969 args.
array<
int>(
"csrColumnOffsets_h_hu");
2970 xt::pyarray<int> &csrRowIndeces_h_hv =
2971 args.
array<
int>(
"csrRowIndeces_h_hv");
2972 xt::pyarray<int> &csrColumnOffsets_h_hv =
2973 args.
array<
int>(
"csrColumnOffsets_h_hv");
2974 xt::pyarray<int> &csrRowIndeces_h_heta =
2975 args.
array<
int>(
"csrRowIndeces_h_heta");
2976 xt::pyarray<int> &csrColumnOffsets_h_heta =
2977 args.
array<
int>(
"csrColumnOffsets_h_heta");
2978 xt::pyarray<int> &csrRowIndeces_h_hw =
2979 args.
array<
int>(
"csrRowIndeces_h_hw");
2980 xt::pyarray<int> &csrColumnOffsets_h_hw =
2981 args.
array<
int>(
"csrColumnOffsets_h_hw");
2983 xt::pyarray<int> &csrRowIndeces_hu_h =
2984 args.
array<
int>(
"csrRowIndeces_hu_h");
2985 xt::pyarray<int> &csrColumnOffsets_hu_h =
2986 args.
array<
int>(
"csrColumnOffsets_hu_h");
2987 xt::pyarray<int> &csrRowIndeces_hu_hu =
2988 args.
array<
int>(
"csrRowIndeces_hu_hu");
2989 xt::pyarray<int> &csrColumnOffsets_hu_hu =
2990 args.
array<
int>(
"csrColumnOffsets_hu_hu");
2991 xt::pyarray<int> &csrRowIndeces_hu_hv =
2992 args.
array<
int>(
"csrRowIndeces_hu_hv");
2993 xt::pyarray<int> &csrColumnOffsets_hu_hv =
2994 args.
array<
int>(
"csrColumnOffsets_hu_hv");
2995 xt::pyarray<int> &csrRowIndeces_hu_heta =
2996 args.
array<
int>(
"csrRowIndeces_hu_heta");
2997 xt::pyarray<int> &csrColumnOffsets_hu_heta =
2998 args.
array<
int>(
"csrColumnOffsets_hu_heta");
2999 xt::pyarray<int> &csrRowIndeces_hu_hw =
3000 args.
array<
int>(
"csrRowIndeces_hu_hw");
3001 xt::pyarray<int> &csrColumnOffsets_hu_hw =
3002 args.
array<
int>(
"csrColumnOffsets_hu_hw");
3004 xt::pyarray<int> &csrRowIndeces_hv_h =
3005 args.
array<
int>(
"csrRowIndeces_hv_h");
3006 xt::pyarray<int> &csrColumnOffsets_hv_h =
3007 args.
array<
int>(
"csrColumnOffsets_hv_h");
3008 xt::pyarray<int> &csrRowIndeces_hv_hu =
3009 args.
array<
int>(
"csrRowIndeces_hv_hu");
3010 xt::pyarray<int> &csrColumnOffsets_hv_hu =
3011 args.
array<
int>(
"csrColumnOffsets_hv_hu");
3012 xt::pyarray<int> &csrRowIndeces_hv_hv =
3013 args.
array<
int>(
"csrRowIndeces_hv_hv");
3014 xt::pyarray<int> &csrColumnOffsets_hv_hv =
3015 args.
array<
int>(
"csrColumnOffsets_hv_hv");
3016 xt::pyarray<int> &csrRowIndeces_hv_heta =
3017 args.
array<
int>(
"csrRowIndeces_hv_heta");
3018 xt::pyarray<int> &csrColumnOffsets_hv_heta =
3019 args.
array<
int>(
"csrColumnOffsets_hv_heta");
3020 xt::pyarray<int> &csrRowIndeces_hv_hw =
3021 args.
array<
int>(
"csrRowIndeces_hv_hw");
3022 xt::pyarray<int> &csrColumnOffsets_hv_hw =
3023 args.
array<
int>(
"csrColumnOffsets_hv_hw");
3025 xt::pyarray<int> &csrRowIndeces_heta_h =
3026 args.
array<
int>(
"csrRowIndeces_heta_h");
3027 xt::pyarray<int> &csrColumnOffsets_heta_h =
3028 args.
array<
int>(
"csrColumnOffsets_heta_h");
3029 xt::pyarray<int> &csrRowIndeces_heta_hu =
3030 args.
array<
int>(
"csrRowIndeces_heta_hu");
3031 xt::pyarray<int> &csrColumnOffsets_heta_hu =
3032 args.
array<
int>(
"csrColumnOffsets_heta_hu");
3033 xt::pyarray<int> &csrRowIndeces_heta_hv =
3034 args.
array<
int>(
"csrRowIndeces_heta_hv");
3035 xt::pyarray<int> &csrColumnOffsets_heta_hv =
3036 args.
array<
int>(
"csrColumnOffsets_heta_hv");
3037 xt::pyarray<int> &csrRowIndeces_heta_heta =
3038 args.
array<
int>(
"csrRowIndeces_heta_heta");
3039 xt::pyarray<int> &csrColumnOffsets_heta_heta =
3040 args.
array<
int>(
"csrColumnOffsets_heta_heta");
3041 xt::pyarray<int> &csrRowIndeces_heta_hw =
3042 args.
array<
int>(
"csrRowIndeces_heta_hw");
3043 xt::pyarray<int> &csrColumnOffsets_heta_hw =
3044 args.
array<
int>(
"csrColumnOffsets_heta_hw");
3046 xt::pyarray<int> &csrRowIndeces_hw_h =
3047 args.
array<
int>(
"csrRowIndeces_hw_h");
3048 xt::pyarray<int> &csrColumnOffsets_hw_h =
3049 args.
array<
int>(
"csrColumnOffsets_hw_h");
3050 xt::pyarray<int> &csrRowIndeces_hw_hu =
3051 args.
array<
int>(
"csrRowIndeces_hw_hu");
3052 xt::pyarray<int> &csrColumnOffsets_hw_hu =
3053 args.
array<
int>(
"csrColumnOffsets_hw_hu");
3054 xt::pyarray<int> &csrRowIndeces_hw_hv =
3055 args.
array<
int>(
"csrRowIndeces_hw_hv");
3056 xt::pyarray<int> &csrColumnOffsets_hw_hv =
3057 args.
array<
int>(
"csrColumnOffsets_hw_hv");
3058 xt::pyarray<int> &csrRowIndeces_hw_heta =
3059 args.
array<
int>(
"csrRowIndeces_hw_heta");
3060 xt::pyarray<int> &csrColumnOffsets_hw_heta =
3061 args.
array<
int>(
"csrColumnOffsets_hw_heta");
3062 xt::pyarray<int> &csrRowIndeces_hw_hw =
3063 args.
array<
int>(
"csrRowIndeces_hw_hw");
3064 xt::pyarray<int> &csrColumnOffsets_hw_hw =
3065 args.
array<
int>(
"csrColumnOffsets_hw_hw");
3066 xt::pyarray<int> &csrRowIndeces_hbeta_hbeta =
3067 args.
array<
int>(
"csrRowIndeces_hbeta_hbeta");
3068 xt::pyarray<int> &csrColumnOffsets_hbeta_hbeta =
3069 args.
array<
int>(
"csrColumnOffsets_hbeta_hbeta");
3070 xt::pyarray<double> &globalJacobian = args.
array<
double>(
"globalJacobian");
3071 xt::pyarray<double> &porosity_dof = args.
array<
double>(
"porosity_dof");
3072 int nExteriorElementBoundaries_global =
3073 args.
scalar<
int>(
"nExteriorElementBoundaries_global");
3074 xt::pyarray<int> &exteriorElementBoundariesArray =
3075 args.
array<
int>(
"exteriorElementBoundariesArray");
3076 xt::pyarray<int> &elementBoundaryElementsArray =
3077 args.
array<
int>(
"elementBoundaryElementsArray");
3078 xt::pyarray<int> &elementBoundaryLocalElementBoundariesArray =
3079 args.
array<
int>(
"elementBoundaryLocalElementBoundariesArray");
3080 xt::pyarray<int> &isDOFBoundary_h = args.
array<
int>(
"isDOFBoundary_h");
3081 xt::pyarray<int> &isDOFBoundary_hu = args.
array<
int>(
"isDOFBoundary_hu");
3082 xt::pyarray<int> &isDOFBoundary_hv = args.
array<
int>(
"isDOFBoundary_hv");
3083 xt::pyarray<int> &isAdvectiveFluxBoundary_h =
3084 args.
array<
int>(
"isAdvectiveFluxBoundary_h");
3085 xt::pyarray<int> &isAdvectiveFluxBoundary_hu =
3086 args.
array<
int>(
"isAdvectiveFluxBoundary_hu");
3087 xt::pyarray<int> &isAdvectiveFluxBoundary_hv =
3088 args.
array<
int>(
"isAdvectiveFluxBoundary_hv");
3089 xt::pyarray<int> &isDiffusiveFluxBoundary_hu =
3090 args.
array<
int>(
"isDiffusiveFluxBoundary_hu");
3091 xt::pyarray<int> &isDiffusiveFluxBoundary_hv =
3092 args.
array<
int>(
"isDiffusiveFluxBoundary_hv");
3093 xt::pyarray<double> &ebqe_bc_h_ext = args.
array<
double>(
"ebqe_bc_h_ext");
3094 xt::pyarray<double> &ebqe_bc_flux_mass_ext =
3095 args.
array<
double>(
"ebqe_bc_flux_mass_ext");
3096 xt::pyarray<double> &ebqe_bc_flux_mom_hu_adv_ext =
3097 args.
array<
double>(
"ebqe_bc_flux_mom_hu_adv_ext");
3098 xt::pyarray<double> &ebqe_bc_flux_mom_hv_adv_ext =
3099 args.
array<
double>(
"ebqe_bc_flux_mom_hv_adv_ext");
3100 xt::pyarray<double> &ebqe_bc_hu_ext = args.
array<
double>(
"ebqe_bc_hu_ext");
3101 xt::pyarray<double> &ebqe_bc_flux_hu_diff_ext =
3102 args.
array<
double>(
"ebqe_bc_flux_hu_diff_ext");
3103 xt::pyarray<double> &ebqe_penalty_ext =
3104 args.
array<
double>(
"ebqe_penalty_ext");
3105 xt::pyarray<double> &ebqe_bc_hv_ext = args.
array<
double>(
"ebqe_bc_hv_ext");
3106 xt::pyarray<double> &ebqe_bc_flux_hv_diff_ext =
3107 args.
array<
double>(
"ebqe_bc_flux_hv_diff_ext");
3108 xt::pyarray<int> &csrColumnOffsets_eb_h_h =
3109 args.
array<
int>(
"csrColumnOffsets_eb_h_h");
3110 xt::pyarray<int> &csrColumnOffsets_eb_h_hu =
3111 args.
array<
int>(
"csrColumnOffsets_eb_h_hu");
3112 xt::pyarray<int> &csrColumnOffsets_eb_h_hv =
3113 args.
array<
int>(
"csrColumnOffsets_eb_h_hv");
3114 xt::pyarray<int> &csrColumnOffsets_eb_hu_h =
3115 args.
array<
int>(
"csrColumnOffsets_eb_hu_h");
3116 xt::pyarray<int> &csrColumnOffsets_eb_hu_hu =
3117 args.
array<
int>(
"csrColumnOffsets_eb_hu_hu");
3118 xt::pyarray<int> &csrColumnOffsets_eb_hu_hv =
3119 args.
array<
int>(
"csrColumnOffsets_eb_hu_hv");
3120 xt::pyarray<int> &csrColumnOffsets_eb_hv_h =
3121 args.
array<
int>(
"csrColumnOffsets_eb_hv_h");
3122 xt::pyarray<int> &csrColumnOffsets_eb_hv_hu =
3123 args.
array<
int>(
"csrColumnOffsets_eb_hv_hu");
3124 xt::pyarray<int> &csrColumnOffsets_eb_hv_hv =
3125 args.
array<
int>(
"csrColumnOffsets_eb_hv_hv");
3126 double dt = args.
scalar<
double>(
"dt");
3131 for (
int eN = 0; eN < nElements_global; eN++) {
3132 double elementJacobian_h_h[nDOF_test_element]
3133 [nDOF_trial_element],
3134 elementJacobian_hu_hu[nDOF_test_element][nDOF_trial_element],
3135 elementJacobian_hv_hv[nDOF_test_element][nDOF_trial_element],
3136 elementJacobian_heta_heta[nDOF_test_element][nDOF_trial_element],
3137 elementJacobian_hw_hw[nDOF_test_element][nDOF_trial_element],
3138 elementJacobian_hbeta_hbeta[nDOF_test_element][nDOF_trial_element];
3139 for (
int i = 0; i < nDOF_test_element; i++)
3140 for (
int j = 0; j < nDOF_trial_element; j++) {
3141 elementJacobian_h_h[i][j] = 0.0;
3142 elementJacobian_hu_hu[i][j] = 0.0;
3143 elementJacobian_hv_hv[i][j] = 0.0;
3144 elementJacobian_heta_heta[i][j] = 0.0;
3145 elementJacobian_hw_hw[i][j] = 0.0;
3146 elementJacobian_hbeta_hbeta[i][j] = 0.0;
3148 for (
int k = 0; k < nQuadraturePoints_element; k++) {
3149 int eN_k = eN * nQuadraturePoints_element +
3151 eN_k_nSpace = eN_k * nSpace,
3152 eN_nDOF_trial_element =
3153 eN * nDOF_trial_element;
3157 double jac[nSpace * nSpace], jacDet, jacInv[nSpace * nSpace],
3158 dV, h_test_dV[nDOF_test_element], vel_test_dV[nDOF_test_element], x,
3161 ck.calculateMapping_element(
3162 eN, k, mesh_dof.data(), mesh_l2g.data(), mesh_trial_ref.data(),
3163 mesh_grad_trial_ref.data(), jac, jacDet, jacInv, x, y);
3165 dV = fabs(jacDet) * dV_ref[k];
3169 ck.valFromDOF(porosity_dof.data(),
3170 &h_l2g.data()[eN * nDOF_trial_element],
3171 &h_trial_ref.data()[k * nDOF_trial_element], phi_q);
3175 for (
int j = 0; j < nDOF_trial_element; j++) {
3176 h_test_dV[j] = h_test_ref[k * nDOF_trial_element + j] * dV;
3177 vel_test_dV[j] = vel_test_ref[k * nDOF_trial_element + j] * dV;
3180 for (
int i = 0; i < nDOF_test_element; i++) {
3181 int i_nSpace = i * nSpace;
3182 for (
int j = 0; j < nDOF_trial_element; j++) {
3183 int j_nSpace = j * nSpace;
3184 elementJacobian_h_h[i][j] += (i == j ? 1.0 : 0.0) * h_test_dV[i];
3185 elementJacobian_hu_hu[i][j] +=
3186 (i == j ? 1.0 : 0.0) * vel_test_dV[i];
3187 elementJacobian_hv_hv[i][j] +=
3188 (i == j ? 1.0 : 0.0) * vel_test_dV[i];
3189 elementJacobian_heta_heta[i][j] +=
3190 (i == j ? 1.0 : 0.0) * vel_test_dV[i];
3191 elementJacobian_hw_hw[i][j] +=
3192 (i == j ? 1.0 : 0.0) * vel_test_dV[i];
3193 elementJacobian_hbeta_hbeta[i][j] +=
3194 (i == j ? 1.0 : 0.0) * vel_test_dV[i];
3201 for (
int i = 0; i < nDOF_test_element; i++) {
3202 int eN_i = eN * nDOF_test_element + i;
3203 for (
int j = 0; j < nDOF_trial_element; j++) {
3204 int eN_i_j = eN_i * nDOF_trial_element + j;
3205 globalJacobian[csrRowIndeces_h_h[eN_i] +
3206 csrColumnOffsets_h_h[eN_i_j]] +=
3207 elementJacobian_h_h[i][j];
3208 globalJacobian[csrRowIndeces_hu_hu[eN_i] +
3209 csrColumnOffsets_hu_hu[eN_i_j]] +=
3210 elementJacobian_hu_hu[i][j];
3211 globalJacobian[csrRowIndeces_hv_hv[eN_i] +
3212 csrColumnOffsets_hv_hv[eN_i_j]] +=
3213 elementJacobian_hv_hv[i][j];
3214 globalJacobian[csrRowIndeces_heta_heta[eN_i] +
3215 csrColumnOffsets_heta_heta[eN_i_j]] +=
3216 elementJacobian_heta_heta[i][j];
3217 globalJacobian[csrRowIndeces_hw_hw[eN_i] +
3218 csrColumnOffsets_hw_hw[eN_i_j]] +=
3219 elementJacobian_hw_hw[i][j];
3220 globalJacobian[csrRowIndeces_hbeta_hbeta[eN_i] +
3221 csrColumnOffsets_hbeta_hbeta[eN_i_j]] +=
3222 elementJacobian_hbeta_hbeta[i][j];