MCPcopy Create free account
hub / github.com/IBAMR/IBAMR / solveBodySystem

Method solveBodySystem

src/IB/DirectMobilitySolver.cpp:322–373  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

320} // solveSystem
321
322bool
323DirectMobilitySolver::solveBodySystem(Vec x, Vec b)
324{
325 IBAMR_TIMER_START(t_solve_body_system);
326
327 // Initialize the solver, when necessary.
328 const bool deallocate_after_solve = !d_is_initialized;
329 if (deallocate_after_solve) initializeSolverState(x, b);
330
331 const int rank = IBTK_MPI::getRank();
332 static const int data_depth = s_max_free_dofs;
333
334 for (const auto& petsc_mat_pair : d_petsc_mat_map)
335 {
336 const std::string& mat_name = petsc_mat_pair.first;
337 Mat& mat = d_petsc_mat_map[mat_name].second;
338 const MobilityMatrixInverseType& inv_type = d_mat_inv_type_map[mat_name].second;
339 const std::vector<std::vector<unsigned>>& struct_ids = d_mat_actual_id_map[mat_name];
340 const int mat_size = d_mat_parts_map[mat_name] * data_depth;
341 const int managing_proc = d_mat_proc_map[mat_name];
342 const int num_structs = static_cast<int>(struct_ids.size());
343
344 for (int k = 0; k < num_structs; ++k)
345 {
346 std::vector<double> rhs;
347 if (rank == managing_proc) rhs.resize(mat_size);
348 d_cib_strategy->copyFreeDOFsVecToArray(b, rhs.data(), struct_ids[k], managing_proc);
349 if (!d_recompute_mob_mat)
350 {
351 d_cib_strategy->rotateArray(rhs.data(),
352 struct_ids[k],
353 /*use_transpose*/ true,
354 managing_proc,
355 data_depth);
356 }
357 if (rank == managing_proc) computeSolution(mat, inv_type, d_ipiv_map[mat_name].second.data(), rhs.data());
358 if (!d_recompute_mob_mat)
359 {
360 d_cib_strategy->rotateArray(rhs.data(),
361 struct_ids[k],
362 /*use_transpose*/ false,
363 managing_proc,
364 data_depth);
365 }
366 d_cib_strategy->copyFreeDOFsArrayToVec(x, rhs.data(), struct_ids[k], managing_proc);
367 }
368 }
369
370 IBAMR_TIMER_STOP(t_solve_body_system);
371
372 return true;
373} // solveBodySystem
374
375void
376DirectMobilitySolver::initializeSolverState(Vec x, Vec /*b*/)

Callers 1

PCApply_KFBMSolverMethod · 0.80

Calls 6

sizeMethod · 0.45
resizeMethod · 0.45
dataMethod · 0.45
rotateArrayMethod · 0.45

Tested by

no test coverage detected