void INSStaggeredVCStokesOperator::initializeOperatorState( const SAMRAIVectorReal<NDIM,double>& in, const SAMRAIVectorReal<NDIM,double>& /*out*/) { IBAMR_TIMER_START(t_initialize_operator_state); if (d_is_initialized) deallocateOperatorState(); d_x_scratch = in.cloneVector("INSStaggeredVCStokesOperator::x_scratch"); d_x_scratch->allocateVectorData(); typedef HierarchyGhostCellInterpolation::InterpolationTransactionComponent InterpolationTransactionComponent; InterpolationTransactionComponent U_scratch_component(d_x_scratch->getComponentDescriptorIndex(0), U_DATA_COARSEN_TYPE, BDRY_EXTRAP_TYPE, CONSISTENT_TYPE_2_BDRY); InterpolationTransactionComponent P_scratch_component(d_x_scratch->getComponentDescriptorIndex(1), P_DATA_COARSEN_TYPE, BDRY_EXTRAP_TYPE, CONSISTENT_TYPE_2_BDRY); InterpolationTransactionComponent mu_component(d_mu_data_idx, MU_DATA_COARSEN_TYPE, BDRY_EXTRAP_TYPE, CONSISTENT_TYPE_2_BDRY); std::vector<InterpolationTransactionComponent> U_P_MU_components(3); U_P_MU_components[0] = U_scratch_component; U_P_MU_components[1] = P_scratch_component; U_P_MU_components[2] = mu_component; d_U_P_MU_bdry_fill_op = new HierarchyGhostCellInterpolation(); d_U_P_MU_bdry_fill_op->initializeOperatorState(U_P_MU_components, d_x_scratch->getPatchHierarchy()); d_is_initialized = true; IBAMR_TIMER_STOP(t_initialize_operator_state); return; }// initializeOperatorState
void StaggeredStokesProjectionPreconditioner::initializeSolverState(const SAMRAIVectorReal<NDIM, double>& x, const SAMRAIVectorReal<NDIM, double>& b) { IBAMR_TIMER_START(t_initialize_solver_state); if (d_is_initialized) deallocateSolverState(); // Parent class initialization. StaggeredStokesBlockPreconditioner::initializeSolverState(x, b); // Setup hierarchy operators. Pointer<VariableFillPattern<NDIM> > fill_pattern = new CellNoCornersFillPattern(CELLG, false, false, true); typedef HierarchyGhostCellInterpolation::InterpolationTransactionComponent InterpolationTransactionComponent; InterpolationTransactionComponent P_scratch_component(d_Phi_scratch_idx, DATA_REFINE_TYPE, USE_CF_INTERPOLATION, DATA_COARSEN_TYPE, BDRY_EXTRAP_TYPE, CONSISTENT_TYPE_2_BDRY, d_P_bc_coef, fill_pattern); d_Phi_bdry_fill_op = new HierarchyGhostCellInterpolation(); d_Phi_bdry_fill_op->setHomogeneousBc(true); d_Phi_bdry_fill_op->initializeOperatorState(P_scratch_component, d_hierarchy); d_is_initialized = true; IBAMR_TIMER_STOP(t_initialize_solver_state); return; } // initializeSolverState
void INSStaggeredVCStokesOperator::apply( const bool /*homogeneous_bc*/, SAMRAIVectorReal<NDIM,double>& x, SAMRAIVectorReal<NDIM,double>& y) { IBAMR_TIMER_START(t_apply); // Get the vector components. // const int U_in_idx = x.getComponentDescriptorIndex(0); // const int P_in_idx = x.getComponentDescriptorIndex(1); const int U_out_idx = y.getComponentDescriptorIndex(0); const int P_out_idx = y.getComponentDescriptorIndex(1); const int U_scratch_idx = d_x_scratch->getComponentDescriptorIndex(0); const int P_scratch_idx = d_x_scratch->getComponentDescriptorIndex(1); const Pointer<Variable<NDIM> >& U_out_var = y.getComponentVariable(0); const Pointer<Variable<NDIM> >& P_out_var = y.getComponentVariable(1); Pointer<SideVariable<NDIM,double> > U_out_sc_var = U_out_var; Pointer<CellVariable<NDIM,double> > P_out_cc_var = P_out_var; const Pointer<Variable<NDIM> >& U_scratch_var = d_x_scratch->getComponentVariable(0); const Pointer<Variable<NDIM> >& P_scratch_var = d_x_scratch->getComponentVariable(1); Pointer<SideVariable<NDIM,double> > U_scratch_sc_var = U_scratch_var; Pointer<CellVariable<NDIM,double> > P_scratch_cc_var = P_scratch_var; d_x_scratch->copyVector(Pointer<SAMRAIVectorReal<NDIM,double> >(&x,false)); // Reset the interpolation operators and fill the data. typedef HierarchyGhostCellInterpolation::InterpolationTransactionComponent InterpolationTransactionComponent; InterpolationTransactionComponent U_scratch_component(U_scratch_idx, U_DATA_COARSEN_TYPE, BDRY_EXTRAP_TYPE, CONSISTENT_TYPE_2_BDRY); InterpolationTransactionComponent P_scratch_component(P_scratch_idx, P_DATA_COARSEN_TYPE, BDRY_EXTRAP_TYPE, CONSISTENT_TYPE_2_BDRY); InterpolationTransactionComponent mu_component(d_mu_data_idx, MU_DATA_COARSEN_TYPE, BDRY_EXTRAP_TYPE, CONSISTENT_TYPE_2_BDRY); std::vector<InterpolationTransactionComponent> U_P_MU_components(3); U_P_MU_components[0] = U_scratch_component; U_P_MU_components[1] = P_scratch_component; U_P_MU_components[2] = mu_component; d_U_P_MU_bdry_fill_op->resetTransactionComponents(U_P_MU_components); d_U_P_MU_bdry_fill_op->fillData(d_new_time); // Setup hierarchy data ops object for U. HierarchyDataOpsManager<NDIM>* hier_ops_manager = HierarchyDataOpsManager<NDIM>::getManager(); Pointer<PatchHierarchy<NDIM> > hierarchy = y.getPatchHierarchy(); Pointer<HierarchySideDataOpsReal<NDIM,double> > hier_sc_data_ops = hier_ops_manager->getOperationsDouble(U_out_var, hierarchy, true); // Compute the action of the operator: // A*[u;p] = [(rho/dt)*u-0.5*div*(mu*(grad u + (grad u)^T)) + grad p; -div u]. // static const bool cf_bdry_synch = true; d_hier_math_ops->pointwiseMultiply( U_out_idx, U_out_sc_var, d_rho_data_idx, d_rho_var, U_scratch_idx, U_scratch_sc_var, 0.0, -1, NULL); d_hier_math_ops->vc_laplace( U_out_idx, U_out_sc_var, -0.5, 0.0, d_mu_data_idx, d_mu_var, U_scratch_idx, U_scratch_sc_var, d_no_fill_op, d_new_time, 1.0/d_dt, U_out_idx, U_out_sc_var); d_hier_math_ops->grad( U_out_idx, U_out_sc_var, cf_bdry_synch, 1.0, P_scratch_idx, P_scratch_cc_var, d_no_fill_op, d_new_time, 1.0, U_out_idx, U_out_sc_var); d_hier_math_ops->div( P_out_idx, P_out_cc_var, -1.0, U_scratch_idx, U_scratch_sc_var, d_no_fill_op, d_new_time, cf_bdry_synch); IBAMR_TIMER_STOP(t_apply); return; }// apply