Skip to content

Commit

Permalink
adding boundary node counter-clockwise ordering to element matching (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
zasexton committed Oct 19, 2023
1 parent ca53ab3 commit fd04be0
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 22 deletions.
3 changes: 3 additions & 0 deletions Code/Source/svFSI/ComMod.h
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,9 @@ class mshType
/// @brief IB: Mesh size parameter
double dx = 0.0;

/// @breif ordering: node ordering for boundaries
std::vector<std::vector<int>> ordering;

/// @brief Element distribution between processors
Vector<int> eDist;

Expand Down
29 changes: 7 additions & 22 deletions Code/Source/svFSI/load_msh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,30 +188,12 @@ void read_sv(Simulation* simulation, mshType& mesh, const MeshParameters* mesh_p
face_nodes(i) = i;
mask[i] = 0;
}
// This line calculates the number of combinations of nodes composing unique faces
int n_comb = (std::tgamma(mesh.eNoN + 1) / std::tgamma(mesh.fa[0].eNoN + 1)) * std::tgamma(mesh.eNoN - mesh.fa[0].eNoN + 1);
Array<int> face_hash(mesh.fa[0].eNoN, n_comb);
for (int i = 0; i < mesh.fa[0].eNoN; i++) {
mask[i] = 1;
}
std::sort(mask.begin(), mask.end());
int count = 0;
do {
int j = 0;
for (int i = 0; i < mesh.eNoN; i++) {
if (mask[i] == 1) {
face_hash(j, count) = face_nodes(i);
j++;
}
}
count++;
} while (std::next_permutation(mask.begin(), mask.end()));

for (int i = 0; i < mesh.gnEl; i++) {
for (int j = 0; j < n_comb; j++) {
for (unsigned int j = 0; j < mesh.ordering.size(); j++) {
std::vector<int> element_nodes;
for (int k = 0; k < mesh.fa[0].eNoN; k++) {
element_nodes.push_back(mesh.gIEN(face_hash(k, j), i));
for (unsigned int k = 0; k < mesh.ordering[j].size(); k++) {
element_nodes.push_back(mesh.gIEN(mesh.ordering[j][k], i));
}
std::sort(element_nodes.begin(), element_nodes.end());
std::string key = "";
Expand Down Expand Up @@ -249,10 +231,13 @@ void read_sv(Simulation* simulation, mshType& mesh, const MeshParameters* mesh_p
}
face.gE(e) = mesh_element_set[key];
}
nn::select_eleb(simulation, mesh, face);
}
}
}
for (int i = 0; i<mesh.nFa; i++){
auto &face = mesh.fa[i];
nn::select_eleb(simulation, mesh, face);
}
}
};

35 changes: 35 additions & 0 deletions Code/Source/svFSI/vtk_xml_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include <string>
#include <map>
#include <vector>

namespace vtk_xml_parser {

Expand All @@ -38,6 +39,32 @@ std::map<unsigned char,int> vtk_cell_to_elem {
{VTK_WEDGE, 6}
};

std::map<unsigned char, std::vector<std::vector<int>>> vtk_cell_ordering {
{VTK_HEXAHEDRON, {{0,3,2,1},
{4,5,6,7},
{0,1,5,4},
{1,2,6,5},
{2,3,7,6},
{3,0,4,7}}},
{VTK_LINE, {{0},
{1}}},
{VTK_QUAD, {{0,1},
{1,2},
{2,3},
{3,0}}},
{VTK_TETRA, {{0,1,2},
{0,1,3},
{1,2,3},
{2,0,3}}},
{VTK_TRIANGLE, {{0,1},
{1,2},
{2,0}}},
{VTK_WEDGE, {{0,1,2},
{3,4,5},
{0,1,4,3},
{1,2,5,4},
{2,0,3,5}}}
};
/// Names of data arrays store in VTK mesh files.
const std::string NODE_IDS_NAME("GlobalNodeID");
const std::string ELEMENT_IDS_NAME("GlobalElementID");
Expand Down Expand Up @@ -194,18 +221,25 @@ void store_element_conn(vtkSmartPointer<vtkUnstructuredGrid> vtk_ugrid, mshType&
#endif

int np_elem = 0;
std::vector<std::vector<int>> ordering;
if (num_line != 0) {
np_elem = vtk_cell_to_elem[VTK_LINE];
ordering = vtk_cell_ordering[VTK_LINE];
} if (num_hex != 0) {
np_elem = vtk_cell_to_elem[VTK_HEXAHEDRON];
ordering = vtk_cell_ordering[VTK_HEXAHEDRON];
} if (num_quad != 0) {
np_elem = vtk_cell_to_elem[VTK_QUAD];
ordering = vtk_cell_ordering[VTK_QUAD];
} if (num_tet != 0) {
np_elem = vtk_cell_to_elem[VTK_TETRA];
ordering = vtk_cell_ordering[VTK_TETRA];
} if (num_tri != 0) {
np_elem = vtk_cell_to_elem[VTK_TRIANGLE];
ordering = vtk_cell_ordering[VTK_TRIANGLE];
} if (num_wedge != 0) {
np_elem = vtk_cell_to_elem[VTK_WEDGE];
ordering = vtk_cell_ordering[VTK_WEDGE];
}

// For higher-order elements with mid-side nodes.
Expand All @@ -219,6 +253,7 @@ void store_element_conn(vtkSmartPointer<vtkUnstructuredGrid> vtk_ugrid, mshType&
mesh.gnEl = num_elems;
mesh.eNoN = np_elem;
mesh.gIEN = Array<int>(np_elem, num_elems);
mesh.ordering = ordering;

#ifdef debug_store_element_conn
std::cout << "[store_element_conn] np_elem: " << np_elem << std::endl;
Expand Down

0 comments on commit fd04be0

Please sign in to comment.