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

Method solveSystem

src/IB/DirectMobilitySolver.cpp:269–320  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

267} // setTimeInterval
268
269bool
270DirectMobilitySolver::solveSystem(Vec x, Vec b)
271{
272 IBAMR_TIMER_START(t_solve_system);
273
274 // Initialize the solver, when necessary.
275 const bool deallocate_after_solve = !d_is_initialized;
276 if (deallocate_after_solve) initializeSolverState(x, b);
277
278 const int rank = IBTK_MPI::getRank();
279 static const int data_depth = NDIM;
280
281 for (const auto& petsc_mat_pair : d_petsc_mat_map)
282 {
283 const std::string& mat_name = petsc_mat_pair.first;
284 Mat& mat = d_petsc_mat_map[mat_name].first;
285 const MobilityMatrixInverseType& inv_type = d_mat_inv_type_map[mat_name].first;
286 const std::vector<std::vector<unsigned>>& struct_ids = d_mat_actual_id_map[mat_name];
287 const int managing_proc = d_mat_proc_map[mat_name];
288 const int mat_size = d_mat_nodes_map[mat_name] * data_depth;
289 const int num_structs = static_cast<int>(struct_ids.size());
290
291 for (int k = 0; k < num_structs; ++k)
292 {
293 std::vector<double> rhs;
294 if (rank == managing_proc) rhs.resize(mat_size);
295 d_cib_strategy->copyVecToArray(b, rhs.data(), struct_ids[k], data_depth, managing_proc);
296 if (!d_recompute_mob_mat)
297 {
298 d_cib_strategy->rotateArray(rhs.data(),
299 struct_ids[k],
300 /*use_transpose*/ true,
301 managing_proc,
302 data_depth);
303 }
304 if (rank == managing_proc) computeSolution(mat, inv_type, d_ipiv_map[mat_name].first.data(), rhs.data());
305 if (!d_recompute_mob_mat)
306 {
307 d_cib_strategy->rotateArray(rhs.data(),
308 struct_ids[k],
309 /*use_transpose*/ false,
310 managing_proc,
311 data_depth);
312 }
313 d_cib_strategy->copyArrayToVec(x, rhs.data(), struct_ids[k], data_depth, managing_proc);
314 }
315 }
316
317 IBAMR_TIMER_STOP(t_solve_system);
318
319 return true;
320} // solveSystem
321
322bool
323DirectMobilitySolver::solveBodySystem(Vec x, Vec b)

Calls 6

sizeMethod · 0.45
resizeMethod · 0.45
copyVecToArrayMethod · 0.45
dataMethod · 0.45
rotateArrayMethod · 0.45
copyArrayToVecMethod · 0.45

Tested by

no test coverage detected