本文整理汇总了C++中Patch::checkAllocated方法的典型用法代码示例。如果您正苦于以下问题:C++ Patch::checkAllocated方法的具体用法?C++ Patch::checkAllocated怎么用?C++ Patch::checkAllocated使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Patch
的用法示例。
在下文中一共展示了Patch::checkAllocated方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: b
//.........这里部分代码省略.........
fdata->getPointer(1, d),
#if (NDIM == 3)
fdata->getPointer(2, d),
#endif
fdata_ghosts,
fdata->getBox().lower()(0),
fdata->getBox().upper()(0),
fdata->getBox().lower()(1),
fdata->getBox().upper()(1),
#if (NDIM == 3)
fdata->getBox().lower()(2),
fdata->getBox().upper()(2),
#endif
correction_box.lower()(0),
correction_box.upper()(0),
correction_box.lower()(1),
correction_box.upper()(1),
#if (NDIM == 3)
correction_box.lower()(2),
correction_box.upper()(2),
#endif
ratio,
dx_fine);
}
}
else
{
// Setup an intermediate patch.
const Box<NDIM> intermediate_patch_box = Box<NDIM>::refine(coarse.getBox(), 2);
Patch<NDIM> intermediate(intermediate_patch_box, coarse.getPatchDescriptor());
intermediate.allocatePatchData(d_u_dst_idx);
// Setup a patch geometry object for the intermediate patch.
Pointer<CartesianPatchGeometry<NDIM> > pgeom_coarse = coarse.getPatchGeometry();
const IntVector<NDIM>& ratio_to_level_zero_coarse = pgeom_coarse->getRatio();
Array<Array<bool> > touches_regular_bdry(NDIM), touches_periodic_bdry(NDIM);
for (int axis = 0; axis < NDIM; ++axis)
{
touches_regular_bdry[axis].resizeArray(2);
touches_periodic_bdry[axis].resizeArray(2);
for (int upperlower = 0; upperlower < 2; ++upperlower)
{
touches_regular_bdry[axis][upperlower] = pgeom_coarse->getTouchesRegularBoundary(axis, upperlower);
touches_periodic_bdry[axis][upperlower] = pgeom_coarse->getTouchesPeriodicBoundary(axis, upperlower);
}
}
const double* const dx_coarse = pgeom_coarse->getDx();
const IntVector<NDIM> ratio_to_level_zero_intermediate = ratio_to_level_zero_coarse * 2;
double dx_intermediate[NDIM], x_lower_intermediate[NDIM], x_upper_intermediate[NDIM];
for (int d = 0; d < NDIM; ++d)
{
dx_intermediate[d] = 0.5 * dx_coarse[d];
x_lower_intermediate[d] = pgeom_coarse->getXLower()[d];
x_upper_intermediate[d] = pgeom_coarse->getXUpper()[d];
}
intermediate.setPatchGeometry(new CartesianPatchGeometry<NDIM>(ratio_to_level_zero_intermediate,
touches_regular_bdry,
touches_periodic_bdry,
dx_intermediate,
x_lower_intermediate,
x_upper_intermediate));
// The intermediate box where we need to fill data must be large enough
// to provide ghost cell values for the fine fill box.
const Box<NDIM> intermediate_box = Box<NDIM>::grow(Box<NDIM>::coarsen(fine_box, ratio / 2), 2);
// Setup the original velocity and indicator data.
if (fine.checkAllocated(d_u_src_idx) && fine.checkAllocated(d_indicator_idx))
{
intermediate.allocatePatchData(d_u_src_idx);
intermediate.allocatePatchData(d_indicator_idx);
Pointer<SideData<NDIM, double> > u_src_idata = intermediate.getPatchData(d_u_src_idx);
Pointer<SideData<NDIM, double> > indicator_idata = intermediate.getPatchData(d_indicator_idx);
u_src_idata->fillAll(std::numeric_limits<double>::quiet_NaN());
indicator_idata->fillAll(-1.0);
#if !defined(NDEBUG)
Pointer<SideData<NDIM, double> > u_src_fdata = fine.getPatchData(d_u_src_idx);
Pointer<SideData<NDIM, double> > indicator_fdata = fine.getPatchData(d_indicator_idx);
TBOX_ASSERT(u_src_fdata->getGhostBox().contains(Box<NDIM>::refine(intermediate_box, ratio / 2)));
TBOX_ASSERT(indicator_fdata->getGhostBox().contains(Box<NDIM>::refine(intermediate_box, ratio / 2)));
#endif
d_coarsen_op->coarsen(intermediate, fine, d_u_src_idx, d_u_src_idx, intermediate_box, ratio / 2);
d_coarsen_op->coarsen(intermediate, fine, d_indicator_idx, d_indicator_idx, intermediate_box, ratio / 2);
}
// Recursively refine from the coarse patch to the fine patch.
postprocessRefine(intermediate, coarse, intermediate_box, 2);
postprocessRefine(fine, intermediate, fine_box, ratio / 2);
// Deallocate any allocated patch data.
intermediate.deallocatePatchData(d_u_dst_idx);
if (fine.checkAllocated(d_u_src_idx) && fine.checkAllocated(d_indicator_idx))
{
intermediate.deallocatePatchData(d_u_src_idx);
intermediate.deallocatePatchData(d_indicator_idx);
}
}
return;
} // postprocessRefine