| 1381 | } // calculateMomentumOfKinematicsVelocity |
| 1382 | |
| 1383 | void |
| 1384 | ConstraintIBMethod::calculateVolumeElement() |
| 1385 | { |
| 1386 | using StructureParameters = ConstraintIBKinematics::StructureParameters; |
| 1387 | |
| 1388 | // Initialize variables and variable contexts associated with Eulerian |
| 1389 | // tracking of the Lagrangian points. |
| 1390 | VariableDatabase<NDIM>* var_db = VariableDatabase<NDIM>::getDatabase(); |
| 1391 | const IntVector<NDIM> cell_ghosts = 0; |
| 1392 | Pointer<CellVariable<NDIM, int>> vol_cc_var = new CellVariable<NDIM, int>(d_object_name + "::vol_cc_var"); |
| 1393 | const int vol_cc_scratch_idx = var_db->registerVariableAndContext(vol_cc_var, d_scratch_context, cell_ghosts); |
| 1394 | |
| 1395 | const int coarsest_ln = 0; |
| 1396 | const int finest_ln = d_hierarchy->getFinestLevelNumber(); |
| 1397 | for (int ln = coarsest_ln; ln <= finest_ln; ++ln) |
| 1398 | { |
| 1399 | if (!d_l_data_manager->levelContainsLagrangianData(ln)) continue; |
| 1400 | Pointer<PatchLevel<NDIM>> level = d_hierarchy->getPatchLevel(ln); |
| 1401 | level->allocatePatchData(vol_cc_scratch_idx, 0.0); |
| 1402 | for (PatchLevel<NDIM>::Iterator p(level); p; p++) |
| 1403 | { |
| 1404 | Pointer<Patch<NDIM>> patch = level->getPatch(p()); |
| 1405 | Pointer<CellData<NDIM, int>> vol_cc_scratch_idx_data = patch->getPatchData(vol_cc_scratch_idx); |
| 1406 | vol_cc_scratch_idx_data->fill(0, 0); |
| 1407 | } |
| 1408 | } |
| 1409 | |
| 1410 | const int lag_node_index_idx = d_l_data_manager->getLNodePatchDescriptorIndex(); |
| 1411 | for (int ln = coarsest_ln; ln <= finest_ln; ++ln) |
| 1412 | { |
| 1413 | if (!d_l_data_manager->levelContainsLagrangianData(ln)) continue; |
| 1414 | |
| 1415 | // Get LData corresponding to the present position of the structures. |
| 1416 | const boost::multi_array_ref<double, 2>& X_data = *d_l_data_manager->getLData("X", ln)->getLocalFormVecArray(); |
| 1417 | Pointer<PatchLevel<NDIM>> level = d_hierarchy->getPatchLevel(ln); |
| 1418 | |
| 1419 | // Get structures on this level. |
| 1420 | const std::vector<int> structIDs = d_l_data_manager->getLagrangianStructureIDs(ln); |
| 1421 | const size_t structs_on_this_ln = structIDs.size(); |
| 1422 | for (size_t struct_no = 0; struct_no < structs_on_this_ln; ++struct_no) |
| 1423 | { |
| 1424 | // If the volume element has already been set, then skip the volume |
| 1425 | // computation |
| 1426 | if (d_vol_element_is_set[struct_no]) |
| 1427 | { |
| 1428 | tbox::plog << "Skipping volume element computation for structure no. " << struct_no << std::endl; |
| 1429 | tbox::pout << "Skipping volume element computation for structure no. " << struct_no << std::endl; |
| 1430 | continue; |
| 1431 | } |
| 1432 | std::pair<int, int> lag_idx_range = |
| 1433 | d_l_data_manager->getLagrangianStructureIndexRange(structIDs[struct_no], ln); |
| 1434 | Pointer<ConstraintIBKinematics> ptr_ib_kinematics = |
| 1435 | *std::find_if(d_ib_kinematics.begin(), d_ib_kinematics.end(), find_struct_handle(lag_idx_range)); |
| 1436 | const int location_struct_handle = |
| 1437 | find_struct_handle_position(d_ib_kinematics.begin(), d_ib_kinematics.end(), ptr_ib_kinematics); |
| 1438 | |
| 1439 | for (PatchLevel<NDIM>::Iterator p(level); p; p++) |
| 1440 | { |
nothing calls this directly
no test coverage detected