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

Method initializeSolverState

src/IB/CIBStaggeredStokesSolver.cpp:137–224  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135} // getSaddlePointSolver
136
137void
138CIBStaggeredStokesSolver::initializeSolverState(const SAMRAIVectorReal<NDIM, double>& x,
139 const SAMRAIVectorReal<NDIM, double>& b)
140{
141 // Deallocate the solver state if the solver is already initialized.
142 if (d_is_initialized)
143 {
144 d_reinitializing_solver = true;
145 deallocateSolverState();
146 }
147
148 // Wrap Eulerian data into PETSc Vecs.
149 Pointer<PatchHierarchy<NDIM>> hierarchy = x.getPatchHierarchy();
150 const int coarsest_ln = x.getCoarsestLevelNumber();
151 const int finest_ln = x.getFinestLevelNumber();
152
153 for (int ln = coarsest_ln; ln <= finest_ln; ++ln)
154 {
155 Pointer<PatchLevel<NDIM>> level = hierarchy->getPatchLevel(ln);
156 if (!level->checkAllocated(d_wide_u_idx)) level->allocatePatchData(d_wide_u_idx);
157 if (!level->checkAllocated(d_wide_f_idx)) level->allocatePatchData(d_wide_f_idx);
158 }
159
160 Pointer<CellVariable<NDIM, double>> x_p_cc_var = x.getComponentVariable(1);
161 Pointer<CellVariable<NDIM, double>> b_p_cc_var = b.getComponentVariable(1);
162 const int x_p_idx = x.getComponentDescriptorIndex(1);
163 const int b_p_idx = b.getComponentDescriptorIndex(1);
164
165 d_x_wide = new SAMRAIVectorReal<NDIM, double>(x.getName() + "_wide_x", hierarchy, coarsest_ln, finest_ln);
166 d_b_wide = new SAMRAIVectorReal<NDIM, double>(b.getName() + "_wide_b", hierarchy, coarsest_ln, finest_ln);
167
168 d_x_wide->addComponent(d_wide_u_var, d_wide_u_idx, x.getControlVolumeIndex(0));
169 d_x_wide->addComponent(x_p_cc_var, x_p_idx, x.getControlVolumeIndex(1));
170 d_b_wide->addComponent(d_wide_f_var, d_wide_f_idx, b.getControlVolumeIndex(0));
171 d_b_wide->addComponent(b_p_cc_var, b_p_idx, b.getControlVolumeIndex(1));
172
173 // Wrap SAMRAI vector into PETSc Vec
174 Vec u_p = PETScSAMRAIVectorReal::createPETScVector(d_x_wide);
175 Vec g_h = PETScSAMRAIVectorReal::createPETScVector(d_b_wide);
176
177 // Get the Lagrange multiplier that maintains the rigidity constraint.
178 // NOTE: The current time corresponds to the time at which solver is initialized
179 // which maybe different from the current time of the timestep being integrated upon.
180 Vec L;
181 d_cib_strategy->getConstraintForce(&L, d_current_time);
182
183 // Create a vector of the type imposed velocity at the material/nodal points for RHS.
184 // NOTE: In the initialization stage we do not need an actual velocity vector, a reference
185 // to L should suffice to know the required structure.
186 Vec V = L;
187
188 // Get the rigid body velocities that need to be solved for.
189 // NOTE: The current time corresponds to the time at which solver is initialized
190 // which maybe different from the current time of the timestep being integrated upon.
191 Vec U;
192 d_cib_strategy->getFreeRigidVelocities(&U, d_current_time);
193
194 // Create a vector that contains net external force and torque on the body.

Callers

nothing calls this directly

Calls 7

getPatchLevelMethod · 0.80
allocatePatchDataMethod · 0.80
getConstraintForceMethod · 0.80
getPatchHierarchyMethod · 0.45
getFinestLevelNumberMethod · 0.45

Tested by

no test coverage detected