void OsdMeshData::prepare() { if (_needsInitializeMesh) { initializeMesh(); } }
void OsdPtexMeshData::prepare() { if (_needsInitializeMesh) { initializeMesh(); initializeIndexBuffer(); } }
//================================================================================ //! メソッド名 CMESH_BASE::コンストラクタ // // 機能 Xファイルをロードして初期化 // 引数 inDev Direct3Dデバイス // inName Xファイルの名称 // inResource メッシュフォルダ名 // inTexture テクスチャフォルダ名 // 更新 2007/12/08 <新規> //================================================================================ CMESH_BASE::CMESH_BASE( CONST DEV inDev, CONST LPSTR inName, CONST LPSTR inResource, CONST LPSTR inTexture) { // 属性の初期化 startMeshInitialize(); // メッシュの初期化 initializeMesh(inDev, inName, inResource, inTexture); }
bool ShockBaseClass::getLocalSurfaces(Real t,std::vector<LocalSurface>& localSurfaces,uint32_t& N_shockCells,int refinements) { // Create shock mesh: if (initializeMesh(t,refinements) == false) { simClasses->logger << "(SEP SHOCK BASE) ERROR: Failed to create shock mesh" << endl << write; return false; } uint64_t N_surfaces = 0; const vector<Real>& faceData = getFaceData(N_surfaces); const vector<Real>& nodeCoordinates = getNodeCoordinates(); const vector<uint32_t>& cellConnectivity = getCellConnectivity(); N_shockCells = N_surfaces; // Iterate over all shock surface elements. If the element is on a cell hosted on // this process (determined by cell centroid), inject particles to it: size_t connIndex = 0; for (size_t s=0; s<N_surfaces; ++s) { const size_t areaIndex = s * ucdmesh::facedataelement::SIZE; const size_t connSize = cellConnectivity[connIndex+1]+2; const size_t node1 = cellConnectivity[connIndex+2]; const size_t node2 = cellConnectivity[connIndex+3]; const size_t node3 = cellConnectivity[connIndex+4]; Real centroid[3]; centroid[0] = (nodeCoordinates[3*node1+0] + nodeCoordinates[3*node2+0] + nodeCoordinates[3*node3+0])/3; centroid[1] = (nodeCoordinates[3*node1+1] + nodeCoordinates[3*node2+1] + nodeCoordinates[3*node3+1])/3; centroid[2] = (nodeCoordinates[3*node1+2] + nodeCoordinates[3*node2+2] + nodeCoordinates[3*node3+2])/3; Real normal[3]; normal[0] = faceData[areaIndex + ucdmesh::facedataelement::NORMAL_X]; normal[1] = faceData[areaIndex + ucdmesh::facedataelement::NORMAL_Y]; normal[2] = faceData[areaIndex + ucdmesh::facedataelement::NORMAL_Z]; // Convert centroid position to logical coordinates and check that it // is inside simulation domain (coords are not inf): Real logical[3]; Real xy,r,theta,phi; Real spherCentroid[3]; switch (simControl.coordinateSystem) { case sep::UNKNOWN: finalizeMesh(); return false; break; case sep::CARTESIAN: getLogicalCoordinates(sim,centroid,logical); if (logical[0] == numeric_limits<Real>::infinity()) { connIndex += connSize; continue; } break; case sep::CYLINDRICAL: finalizeMesh(); return false; break; case sep::SPHERICAL: // Need to convert to spherical coordinates first: xy = centroid[0]*centroid[0] + centroid[1]*centroid[1]; r = xy + centroid[2]*centroid[2]; r = sqrt(r); xy = sqrt(xy); theta = acos(centroid[2]/r); phi = acos(centroid[0] / xy); if (centroid[1] < 0.0) phi = -phi; spherCentroid[0] = r; spherCentroid[1] = theta; spherCentroid[2] = phi; // Check logical coords: getLogicalCoordinates(sim,spherCentroid,logical); if (logical[0] == std::numeric_limits<Real>::infinity()) { connIndex += connSize; continue; } break; default: finalizeMesh(); return false; break; } // Check that injection position is in upstream side: Real d_shock = getSquaredDistanceToShock(t,logical); bool acceptSurface = true; while (d_shock <= 1.0) { // Move injection point to the direction of shock normal: for (int i=0; i<3; ++i) centroid[i] += (0.1+1.001*fabs(d_shock))*normal[i]; switch (simControl.coordinateSystem) { case sep::UNKNOWN: finalizeMesh(); return false; break; case sep::CARTESIAN: getLogicalCoordinates(sim,centroid,logical); if (logical[0] == std::numeric_limits<Real>::infinity()) { acceptSurface = false; } break; case sep::CYLINDRICAL: finalizeMesh(); return false; break; case sep::SPHERICAL: xy = centroid[0]*centroid[0] + centroid[1]*centroid[1]; r = sqrt(xy + centroid[2]*centroid[2]); xy = sqrt(xy); theta = acos(centroid[2]/r); phi = acos(centroid[0] / xy); if (centroid[1] < 0.0) phi = -phi; spherCentroid[0] = r; spherCentroid[1] = theta; spherCentroid[2] = phi; getLogicalCoordinates(sim,spherCentroid,logical); if (logical[0] == numeric_limits<Real>::infinity()) acceptSurface = false; break; default: finalizeMesh(); return false; break; } if (acceptSurface == false) break; d_shock = simControl.shock->getSquaredDistanceToShock(t,logical); } if (acceptSurface == false) { connIndex += connSize; continue; } // Calculate cell indices: int32_t i_block = static_cast<int32_t>(logical[0]) / block::WIDTH_X; int32_t j_block = static_cast<int32_t>(logical[1]) / block::WIDTH_Y; int32_t k_block = static_cast<int32_t>(logical[2]) / block::WIDTH_Z; // Calculate block global index and check if this process has it: pargrid::CellID blockGID = block::calculateGlobalIndex(*sim,i_block,j_block,k_block); pargrid::CellID blockLID = simClasses->pargrid.getLocalID(blockGID); if (blockLID == pargrid::INVALID_CELLID) { connIndex += connSize; continue; } if (simClasses->pargrid.getHosts()[blockLID] != sim->mpiRank) { connIndex += connSize; continue; } // Surface accepted, add to output vector: LocalSurface surface; surface.localID = blockLID; surface.globalID = blockGID; for (int i=0; i<3; ++i) surface.position[i] = logical[i]; surface.area = faceData[areaIndex+ucdmesh::facedataelement::AREA]; surface.zoneIndex = s; localSurfaces.push_back(surface); connIndex += connSize; } if (finalizeMesh() == false) return false; return true; }