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

Method setDataOnPatchHierarchy

src/adv_diff/AdvDiffStochasticForcing.cpp:143–352  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141} // isTimeDependent
142
143void
144AdvDiffStochasticForcing::setDataOnPatchHierarchy(const int data_idx,
145 Pointer<Variable<NDIM>> var,
146 Pointer<PatchHierarchy<NDIM>> hierarchy,
147 const double data_time,
148 const bool initial_time,
149 const int coarsest_ln_in,
150 const int finest_ln_in)
151{
152 const int coarsest_ln = (coarsest_ln_in == IBTK::invalid_level_number ? 0 : coarsest_ln_in);
153 const int finest_ln =
154 (finest_ln_in == IBTK::invalid_level_number ? hierarchy->getFinestLevelNumber() : finest_ln_in);
155 const int cycle_num = d_adv_diff_solver->getCurrentCycleNumber();
156 if (!initial_time)
157 {
158#if !defined(NDEBUG)
159 TBOX_ASSERT(cycle_num >= 0);
160#endif
161 // Allocate data to store components of the stochastic stress components.
162 for (int level_num = coarsest_ln; level_num <= finest_ln; ++level_num)
163 {
164 Pointer<PatchLevel<NDIM>> level = hierarchy->getPatchLevel(level_num);
165 if (!level->checkAllocated(d_C_current_cc_idx)) level->allocatePatchData(d_C_current_cc_idx);
166 if (!level->checkAllocated(d_C_half_cc_idx)) level->allocatePatchData(d_C_half_cc_idx);
167 if (!level->checkAllocated(d_C_new_cc_idx)) level->allocatePatchData(d_C_new_cc_idx);
168 if (!level->checkAllocated(d_F_sc_idx)) level->allocatePatchData(d_F_sc_idx);
169 for (int k = 0; k < d_num_rand_vals; ++k)
170 if (!level->checkAllocated(d_F_sc_idxs[k])) level->allocatePatchData(d_F_sc_idxs[k]);
171 }
172
173 // Set concentration value used to compute concentration-dependent flux
174 // scaling.
175 const double dt = d_adv_diff_solver->getCurrentTimeStepSize();
176 const double current_time = d_adv_diff_solver->getIntegratorTime();
177 const double half_time = current_time + 0.5 * dt;
178 const double new_time = current_time + dt;
179 HierarchyDataOpsManager<NDIM>* hier_data_ops_manager = HierarchyDataOpsManager<NDIM>::getManager();
180 Pointer<HierarchyDataOpsReal<NDIM, double>> hier_cc_data_ops =
181 hier_data_ops_manager->getOperationsDouble(d_C_cc_var,
182 hierarchy,
183 /*get_unique*/ true);
184 VariableDatabase<NDIM>* var_db = VariableDatabase<NDIM>::getDatabase();
185 const int C_current_idx = var_db->mapVariableAndContextToIndex(d_C_var, d_adv_diff_solver->getCurrentContext());
186 const int C_new_idx = var_db->mapVariableAndContextToIndex(d_C_var, d_adv_diff_solver->getNewContext());
187 using InterpolationTransactionComponent = HierarchyGhostCellInterpolation::InterpolationTransactionComponent;
188 std::vector<InterpolationTransactionComponent> ghost_fill_components(1);
189 HierarchyGhostCellInterpolation ghost_fill_op;
190 const std::vector<RobinBcCoefStrategy<NDIM>*>& C_bc_coef = d_adv_diff_solver->getPhysicalBcCoefs(d_C_var);
191 const TimeSteppingType convective_time_stepping_type =
192 d_adv_diff_solver->getConvectiveTimeSteppingType(d_C_var);
193 switch (convective_time_stepping_type)
194 {
195 case FORWARD_EULER:
196 hier_cc_data_ops->copyData(d_C_current_cc_idx, C_current_idx);
197 ghost_fill_components[0] =
198 InterpolationTransactionComponent(d_C_current_cc_idx, "NONE", false, "NONE", "NONE", false, C_bc_coef);
199 ghost_fill_op.initializeOperatorState(ghost_fill_components, hierarchy);
200 ghost_fill_op.fillData(current_time);

Calls 15

getCurrentCycleNumberMethod · 0.80
getPatchLevelMethod · 0.80
allocatePatchDataMethod · 0.80
getIntegratorTimeMethod · 0.80
getCurrentContextMethod · 0.80
getNewContextMethod · 0.80
getPhysicalBcCoefsMethod · 0.80
fillDataMethod · 0.80
genrandnFunction · 0.70
getFinestLevelNumberMethod · 0.45

Tested by

no test coverage detected