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

Method solveSystem

src/IB/CIBStaggeredStokesSolver.cpp:256–377  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

254} // setPhysicalBoundaryHelper
255
256bool
257CIBStaggeredStokesSolver::solveSystem(SAMRAIVectorReal<NDIM, double>& x, SAMRAIVectorReal<NDIM, double>& b)
258{
259 // Create packaged vectors for the Saddle point solver.
260 d_x_wide->copyVector(Pointer<SAMRAIVectorReal<NDIM, double>>(&x, false));
261 d_b_wide->copyVector(Pointer<SAMRAIVectorReal<NDIM, double>>(&b, false));
262
263 // Wrap SAMRAI vector into PETSc Vec
264 Vec u_p = PETScSAMRAIVectorReal::createPETScVector(d_x_wide);
265 Vec g_h = PETScSAMRAIVectorReal::createPETScVector(d_b_wide);
266
267 // Get the Lagrange multiplier that maintains the rigidity constraint.
268 // NOTE: We need L at new time to solve for it.
269 Vec L;
270 d_cib_strategy->getConstraintForce(&L, d_new_time);
271
272 // Get the free body velocities to solve for.
273 // NOTE: We need U at new time in the solver.
274 Vec U;
275 d_cib_strategy->getFreeRigidVelocities(&U, d_new_time);
276
277 // Set the imposed velocity for all bodies in the RHS.
278 Vec V;
279 VecDuplicate(L, &V);
280 for (unsigned part = 0; part < d_num_rigid_parts; ++part)
281 {
282 RigidDOFVector U_part;
283 d_cib_strategy->getNewRigidBodyVelocity(part, U_part);
284
285 // Zero-out free velocities.
286 int num_free_dofs = 0;
287 const FreeRigidDOFVector& solve_dofs = d_cib_strategy->getSolveRigidBodyVelocity(part, num_free_dofs);
288 for (int k = 0; k < s_max_free_dofs; ++k)
289 {
290 if (solve_dofs[k]) U_part[k] = 0.0;
291 }
292
293 const double interp_scale = d_sp_solver->getInterpScale();
294 U_part *= -interp_scale;
295 d_cib_strategy->setRigidBodyVelocity(part, U_part, V);
296 }
297
298 // Get the net external force and torque on the bodies.
299 Vec F;
300 d_cib_strategy->getNetExternalForceTorque(&F, d_new_time);
301
302 // Create multivector to pass it to the saddle point solver.
303 std::vector<Vec> vx(3), vb(3);
304 vx[0] = u_p;
305 vx[1] = L;
306 vx[2] = U;
307 vb[0] = g_h;
308 vb[1] = V;
309 vb[2] = F;
310
311 Vec mv_x, mv_b;
312 VecCreateNest(PETSC_COMM_WORLD, 3, nullptr, &vx[0], &mv_x);
313 VecCreateNest(PETSC_COMM_WORLD, 3, nullptr, &vb[0], &mv_b);

Callers

nothing calls this directly

Calls 13

getConstraintForceMethod · 0.80
getInterpScaleMethod · 0.80
getPatchLevelMethod · 0.80
fillDataMethod · 0.80
setRigidBodyVelocityMethod · 0.45
getPatchHierarchyMethod · 0.45

Tested by

no test coverage detected