| 627 | } // computeDiffusionCoefficient |
| 628 | |
| 629 | void |
| 630 | BrinkmanAdvDiffBcHelper::computeForcing(int F_idx, Pointer<CellVariable<NDIM, double>> Q_var) |
| 631 | { |
| 632 | #if !defined(NDEBUG) |
| 633 | TBOX_ASSERT(d_Q_bc.find(Q_var) != d_Q_bc.end()); |
| 634 | #endif |
| 635 | VariableDatabase<NDIM>* var_db = VariableDatabase<NDIM>::getDatabase(); |
| 636 | std::vector<BCProperties> brinkman_zones = d_Q_bc[Q_var]; |
| 637 | |
| 638 | Pointer<PatchHierarchy<NDIM>> patch_hierarchy = d_adv_diff_solver->getPatchHierarchy(); |
| 639 | const int coarsest_ln = 0; |
| 640 | const int finest_ln = patch_hierarchy->getFinestLevelNumber(); |
| 641 | |
| 642 | HierarchyCellDataOpsReal<NDIM, double> hier_cc_data_ops(patch_hierarchy, coarsest_ln, finest_ln); |
| 643 | hier_cc_data_ops.setToScalar(F_idx, 0.0); |
| 644 | |
| 645 | // First, deal with Dirichlet, spatially constant g, which can be computed pointwise. |
| 646 | for (int ln = coarsest_ln; ln <= finest_ln; ++ln) |
| 647 | { |
| 648 | Pointer<PatchLevel<NDIM>> level = patch_hierarchy->getPatchLevel(ln); |
| 649 | for (PatchLevel<NDIM>::Iterator p(level); p; p++) |
| 650 | { |
| 651 | Pointer<Patch<NDIM>> patch = level->getPatch(p()); |
| 652 | const Pointer<CartesianPatchGeometry<NDIM>> patch_geom = patch->getPatchGeometry(); |
| 653 | const Box<NDIM>& patch_box = patch->getBox(); |
| 654 | const double* patch_dx = patch_geom->getDx(); |
| 655 | double vol_cell = 1.0; |
| 656 | for (int d = 0; d < NDIM; ++d) vol_cell *= patch_dx[d]; |
| 657 | |
| 658 | Pointer<CellData<NDIM, double>> F_data = patch->getPatchData(F_idx); |
| 659 | |
| 660 | for (Box<NDIM>::Iterator it(patch_box); it; it++) |
| 661 | { |
| 662 | CellIndex<NDIM> ci(it()); |
| 663 | |
| 664 | // Loop over all the level sets and add up their contributions. |
| 665 | // TODO: Pointwise check that level sets don't overlap |
| 666 | double brinkman_forcing = 0.0; |
| 667 | for (const auto& bc_prop : brinkman_zones) |
| 668 | { |
| 669 | // Get the BC specifications for each zone. |
| 670 | Pointer<CellVariable<NDIM, double>> ls_solid_var = bc_prop.ls_solid_var; |
| 671 | AdvDiffBrinkmanPenalizationBcType bc_type = bc_prop.bc_type; |
| 672 | double bc_val = bc_prop.bc_val; |
| 673 | double eta = bc_prop.eta; |
| 674 | |
| 675 | bool requires_callback = bc_prop.callback != nullptr; |
| 676 | double num_interface_cells = bc_prop.num_interface_cells; |
| 677 | const double alpha = num_interface_cells * std::pow(vol_cell, 1.0 / static_cast<double>(NDIM)); |
| 678 | |
| 679 | if (requires_callback) continue; |
| 680 | #if !defined(NDEBUG) |
| 681 | TBOX_ASSERT(!requires_callback); |
| 682 | #endif |
| 683 | const int phi_idx = |
| 684 | var_db->mapVariableAndContextToIndex(ls_solid_var, d_adv_diff_solver->getNewContext()); |
| 685 | Pointer<CellData<NDIM, double>> ls_solid_data = patch->getPatchData(phi_idx); |
| 686 | double phi = (*ls_solid_data)(ci); |
no test coverage detected