本文整理汇总了C++中hier::Patch::checkAllocated方法的典型用法代码示例。如果您正苦于以下问题:C++ Patch::checkAllocated方法的具体用法?C++ Patch::checkAllocated怎么用?C++ Patch::checkAllocated使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类hier::Patch
的用法示例。
在下文中一共展示了Patch::checkAllocated方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: buildSShellGridOnPatch
void MblkGeometry::buildSShellGridOnPatch(
const hier::Patch& patch,
const hier::Box& domain,
const int xyz_id,
const int level_number,
const int block_number)
{
bool xyz_allocated = patch.checkAllocated(xyz_id);
if (!xyz_allocated) {
TBOX_ERROR("xyz data not allocated" << std::endl);
//patch.allocatePatchData(xyz_id);
}
boost::shared_ptr<pdat::NodeData<double> > xyz(
BOOST_CAST<pdat::NodeData<double>, hier::PatchData>(
patch.getPatchData(xyz_id)));
TBOX_ASSERT(xyz);
if (d_dim == tbox::Dimension(3)) {
const hier::Index ifirst = patch.getBox().lower();
const hier::Index ilast = patch.getBox().upper();
hier::IntVector nghost_cells = xyz->getGhostCellWidth();
//int imin = ifirst(0);
//int imax = ilast(0) + 1;
//int jmin = ifirst(1);
//int jmax = ilast(1) + 1;
//int kmin = ifirst(2);
//int kmax = ilast(2) + 1;
//int nx = imax - imin + 1;
//int ny = jmax - jmin + 1;
//int nxny = nx*ny;
int nd_imin = ifirst(0) - nghost_cells(0);
int nd_imax = ilast(0) + 1 + nghost_cells(0);
int nd_jmin = ifirst(1) - nghost_cells(1);
int nd_jmax = ilast(1) + 1 + nghost_cells(1);
int nd_kmin = ifirst(2) - nghost_cells(2);
int nd_kmax = ilast(2) + 1 + nghost_cells(2);
int nd_nx = nd_imax - nd_imin + 1;
int nd_ny = nd_jmax - nd_jmin + 1;
int nd_nxny = nd_nx * nd_ny;
double* x = xyz->getPointer(0);
double* y = xyz->getPointer(1);
double* z = xyz->getPointer(2);
bool found = false;
int nrad = (domain.upper(0) - domain.lower(0) + 1);
int nth = (domain.upper(1) - domain.lower(1) + 1);
int nphi = (domain.upper(2) - domain.lower(2) + 1);
/*
* If its a solid shell, its a single block and dx = dr, dth, dphi
*/
if (d_sshell_type == "SOLID") {
d_dx[level_number][block_number][0] = (d_sshell_rmax - d_sshell_rmin) / (double)nrad;
d_dx[level_number][block_number][1] =
2.0 * tbox::MathUtilities<double>::Abs(d_sangle_thmin)
/ (double)nth;
d_dx[level_number][block_number][2] =
2.0 * tbox::MathUtilities<double>::Abs(d_sangle_thmin)
/ (double)nphi;
//
// step in a radial direction in x and set y and z appropriately
// for a solid angle we go -th to th and -phi to phi
//
for (int k = nd_kmin; k <= nd_kmax; ++k) {
for (int j = nd_jmin; j <= nd_jmax; ++j) {
double theta = d_sangle_thmin + j * d_dx[level_number][block_number][1]; // dx used for dth
double phi = d_sangle_thmin + k * d_dx[level_number][block_number][2];
double xface = cos(theta) * cos(phi);
double yface = sin(theta) * cos(phi);
double zface = sin(phi);
for (int i = nd_imin; i <= nd_imax; ++i) {
int ind = POLY3(i,
j,
k,
nd_imin,
nd_jmin,
nd_kmin,
nd_nx,
nd_nxny);
double r = d_sshell_rmin + d_dx[level_number][block_number][0] * (i);
double xx = r * xface;
double yy = r * yface;
double zz = r * zface;
//.........这里部分代码省略.........