// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void AdjustVolumeOrigin::updateSurfaceMesh() { int err = 0; std::stringstream ss; setErrorCondition(err); SurfaceMeshDataContainer* m = getSurfaceMeshDataContainer(); if(NULL == m) { setErrorCondition(-999); notifyErrorMessage("The SurfaceMeshing DataContainer Object was NULL", -999); return; } setErrorCondition(0); notifyStatusMessage("Starting"); #ifdef DREAM3D_USE_PARALLEL_ALGORITHMS tbb::task_scheduler_init init; bool doParallel = true; #endif DREAM3D::SurfaceMesh::VertListPointer_t nodesPtr = getSurfaceMeshDataContainer()->getVertices(); DREAM3D::SurfaceMesh::Vert_t* nodes = nodesPtr->GetPointer(0); // First get the min/max coords. float min[3] = { std::numeric_limits<float>::max(), std::numeric_limits<float>::max(), std::numeric_limits<float>::max() }; // float max[3] = { std::numeric_limits<float>::min(), std::numeric_limits<float>::min(), std::numeric_limits<float>::min() }; size_t count = nodesPtr->GetNumberOfTuples(); for (size_t i = 0; i < count; i++) { // if (nodes[i].pos[0] > max[0]) { max[0] = nodes[i].pos[0]; } // if (nodes[i].pos[1] > max[1]) { max[1] = nodes[i].pos[1]; } // if (nodes[i].pos[2] > max[2]) { max[2] = nodes[i].pos[2]; } if (nodes[i].pos[0] < min[0]) { min[0] = nodes[i].pos[0]; } if (nodes[i].pos[1] < min[1]) { min[1] = nodes[i].pos[1]; } if (nodes[i].pos[2] < min[2]) { min[2] = nodes[i].pos[2]; } } float delta[3] = {min[0] - m_Origin.x, min[1] - m_Origin.y, min[2] - m_Origin.z }; #ifdef DREAM3D_USE_PARALLEL_ALGORITHMS if (doParallel == true) { tbb::parallel_for(tbb::blocked_range<size_t>(0, count), Detail::UpdateVerticesImpl(nodesPtr, delta), tbb::auto_partitioner()); } else #endif { Detail::UpdateVerticesImpl serial(nodesPtr, delta); serial.generate(0, count); } }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void AbaqusSurfaceMeshWriter::execute() { int err = 0; std::stringstream ss; SurfaceMeshDataContainer* sm = getSurfaceMeshDataContainer(); dataCheck(false, 1, 1, 1); if(getErrorCondition() < 0) { return; } // Make sure any directory path is also available as the user may have just typed // in a path without actually creating the full path std::string parentPath = MXAFileInfo::parentPath(getOutputFile()); if(!MXADir::mkdir(parentPath, true)) { std::stringstream ss; ss << "Error creating parent path '" << parentPath << "'"; notifyErrorMessage(ss.str(), -1); setErrorCondition(-1); return; } DREAM3D::SurfaceMesh::VertListPointer_t nodesPtr = sm->getVertices(); DREAM3D::SurfaceMesh::FaceListPointer_t trianglePtr = sm->getFaces(); // Get the Labels(GrainIds or Region Ids) for the triangles Int32ArrayType::Pointer faceLabelsPtr = boost::dynamic_pointer_cast<Int32ArrayType>(sm->getFaceData(DREAM3D::FaceData::SurfaceMeshFaceLabels)); int32_t* faceLabels = faceLabelsPtr->GetPointer(0); // Store all the unique Spins std::set<int> uniqueSpins; for (int i = 0; i < trianglePtr->GetNumberOfTuples(); i++) { uniqueSpins.insert(faceLabels[i*2]); uniqueSpins.insert(faceLabels[i*2+1]); } FILE* f = fopen(m_OutputFile.c_str(), "wb"); ScopedFileMonitor fileMonitor(f); err = writeHeader(f, nodesPtr->GetNumberOfTuples(), trianglePtr->GetNumberOfTuples(), uniqueSpins.size()-1); err = writeNodes(f); err = writeTriangles(f); err = writeGrains(f); setErrorCondition(0); notifyStatusMessage("Complete"); return; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- int AbaqusSurfaceMeshWriter::writeNodes(FILE* f) { DREAM3D::SurfaceMesh::VertListPointer_t nodesPtr = getSurfaceMeshDataContainer()->getVertices(); DREAM3D::SurfaceMesh::Vert_t* nodes = nodesPtr->GetPointer(0); size_t numNodes = nodesPtr->GetNumberOfTuples(); int err = 0; fprintf(f, "*Node,NSET=NALL\n"); //1, 72.520433763730, 70.306420652241, 100.000000000000 for(size_t i = 1; i <= numNodes; ++i) { DREAM3D::SurfaceMesh::Vert_t& n = nodes[i-1]; fprintf(f, "%lu, %0.6f, %0.6f, %0.6f\n", i, n.pos[0], n.pos[1], n.pos[2]); } return err; }
// ----------------------------------------------------------------------------- // // ----------------------------------------------------------------------------- void SurfaceMeshDataContainerWriter::writeXdmfGridHeader() { if (m_WriteXdmfFile == false || m_XdmfPtr == NULL) { return; } DREAM3D::SurfaceMesh::FaceListPointer_t faces = getSurfaceMeshDataContainer()->getFaces(); if (NULL == faces.get()) { return; } DREAM3D::SurfaceMesh::VertListPointer_t verts = getSurfaceMeshDataContainer()->getVertices(); if(NULL == verts.get()) { return; } std::ostream& out = *m_XdmfPtr; out << " <Grid Name=\"SurfaceMesh DataContainer\">" << std::endl; out << " <Topology TopologyType=\"Triangle\" NumberOfElements=\"" << faces->GetNumberOfTuples() << "\">" << std::endl; out << " <DataItem Format=\"HDF\" NumberType=\"Int\" Dimensions=\"" << faces->GetNumberOfTuples() << " 3\">" << std::endl; ssize_t nameSize = H5Fget_name(m_HdfFileId, NULL, 0) + 1; std::vector<char> nameBuffer(nameSize, 0); nameSize = H5Fget_name(m_HdfFileId, &(nameBuffer.front()), nameSize); std::string hdfFileName(&(nameBuffer.front()), nameSize); hdfFileName = MXAFileInfo::filename(hdfFileName); out << " " << hdfFileName << ":/SurfaceMeshDataContainer/Faces" << std::endl; out << " </DataItem>" << std::endl; out << " </Topology>" << std::endl; out << " <Geometry Type=\"XYZ\">" << std::endl; out << " <DataItem Format=\"HDF\" Dimensions=\"" << verts->GetNumberOfTuples() << " 3\" NumberType=\"Float\" Precision=\"4\">" << std::endl; out << " " << hdfFileName << ":/SurfaceMeshDataContainer/Vertices" << std::endl; out << " </DataItem>" << std::endl; out << " </Geometry>" << std::endl; out << "" << std::endl; }