34 std::vector<std::size_t> nodeTags;
35 std::vector<double> coord;
36 std::vector<double> paramCoord;
37 gmsh::model::mesh::getNodes(nodeTags, coord, paramCoord);
39 std::unordered_map<std::size_t, std::size_t> tagToIdx;
40 tagToIdx.reserve(nodeTags.size());
41 for (
size_t i = 0; i < nodeTags.size(); ++i)
42 tagToIdx[nodeTags[i]] = i;
44 std::vector<util::Point> nodes(nodeTags.size());
45 for (
size_t i = 0; i < nodeTags.size(); ++i)
46 nodes[i] =
util::Point(coord[3 * i], coord[3 * i + 1], coord[3 * i + 2]);
48 std::vector<int> elementTypes;
49 std::vector<std::vector<std::size_t>> elementTags, elementNodeTags;
50 gmsh::model::mesh::getElements(elementTypes, elementTags, elementNodeTags, -1, -1);
52 bool hasTetra =
false;
53 for (
size_t t = 0; t < elementTypes.size(); ++t) {
61 std::vector<size_t> enc;
62 for (
size_t t = 0; t < elementTypes.size(); ++t) {
65 const auto &nt = elementNodeTags[t];
66 for (
size_t j = 0; j < nt.size(); j += 4) {
67 enc.push_back(tagToIdx.at(nt[j]));
68 enc.push_back(tagToIdx.at(nt[j + 1]));
69 enc.push_back(tagToIdx.at(nt[j + 2]));
70 enc.push_back(tagToIdx.at(nt[j + 3]));
74 throw std::runtime_error(
"fillMeshFromActiveGmshModel: no Gmsh tetrahedron elements found.");
79 std::vector<size_t> enc;
80 for (
size_t t = 0; t < elementTypes.size(); ++t) {
83 const auto &nt = elementNodeTags[t];
84 for (
size_t j = 0; j < nt.size(); j += 3) {
85 enc.push_back(tagToIdx.at(nt[j]));
86 enc.push_back(tagToIdx.at(nt[j + 1]));
87 enc.push_back(tagToIdx.at(nt[j + 2]));
92 throw std::runtime_error(
"fillMeshFromActiveGmshModel: no Gmsh triangle elements found.");
void loadFromTetraElements3D(std::vector< util::Point > nodes, std::vector< size_t > enc, const inp::MeshDeck *meshDeck, const inp::ModelDeck *modelDeck)
Populate mesh from 3D tetrahedron data (0-based node indices in enc) without reading a file.
void loadFromTriangleElements2D(std::vector< util::Point > nodes, std::vector< size_t > enc, const inp::MeshDeck *meshDeck, const inp::ModelDeck *modelDeck)
Populate mesh from 2D triangle data (0-based node indices in enc) without reading a file.