51 for(
unsigned int iii = 0; iii < Patch_elem->n_nodes(); ++iii)
59 bool bDoIntersect =
false;
61 std::set<unsigned int> Intersecting_elems;
69 std::deque<int> Patch_Test_Queue;
72 std::unordered_set<int> Treated_From_Mesh(
m_Mesh_parent.n_elem());
75 unsigned int Tested_idx;
78 unsigned int Candidate_idx;
81 libMesh::Elem * First_Patch_elems = NULL;
82 libMesh::Elem * elem_candidate = NULL;
83 std::set<unsigned int>::iterator it_set_start = Intersecting_elems.begin();
84 for( ; it_set_start != Intersecting_elems.end(); ++it_set_start)
86 Treated_From_Mesh.insert(*it_set_start);
90 for(
unsigned int iii = 0; iii < First_Patch_elems->n_neighbors(); ++iii)
92 elem_candidate = First_Patch_elems->neighbor(iii);
93 if(elem_candidate != NULL)
95 Patch_Test_Queue.push_back(elem_candidate->id());
96 Treated_From_Mesh.insert(elem_candidate->id());
103 int nbOfPositiveTests = 1;
105 while(!Patch_Test_Queue.empty())
108 Tested_idx = Patch_Test_Queue[0];
109 Patch_Test_Queue.pop_front();
110 const libMesh::Elem * Tested_elem =
m_Mesh_parent.elem(Tested_idx);
125 for(
unsigned int iii = 0; iii < Tested_elem->n_neighbors(); ++iii)
127 elem_candidate = Tested_elem->neighbor(iii);
128 if(elem_candidate != NULL)
130 Candidate_idx = elem_candidate->id();
131 if(Treated_From_Mesh.find(Candidate_idx)==Treated_From_Mesh.end())
133 Patch_Test_Queue.push_back(Candidate_idx);
134 Treated_From_Mesh.insert(Candidate_idx);
142 std::unordered_set<unsigned int> dummy_neighbour_set(12);
148 libMesh::Elem * elem_neighbour;
149 unsigned int elem_neighbour_id;
151 for( ; it_set != it_set_end; ++it_set)
154 dummy_neighbour_set.clear();
156 for(
unsigned int iii = 0; iii < elem->n_neighbors(); ++iii)
158 elem_neighbour = elem->neighbor(iii);
160 if(elem_neighbour != NULL)
163 elem_neighbour_id = elem_neighbour->id();
167 dummy_neighbour_set.insert(elem_neighbour->id());
171 m_Patch_Elem_Neighbours.insert(std::pair<
unsigned int,std::unordered_set<unsigned int> >(*it_set,dummy_neighbour_set));
179 std::cout <<
" DEBUG: patch search results" << std::endl;
180 std::cout <<
" -> Nb. of intersections found : " <<
m_Patch_Elem_indexes.size() << std::endl << std::endl;
182 std::cout <<
" -> Nb. of mesh elements : " <<
m_Mesh_parent.n_elem() << std::endl;
186 std::cout <<
" -> Nb. of mesh nodes : " <<
m_Mesh_parent.n_nodes() << std::endl;
190 std::cout <<
" -> Nb. of tests : " << nbOfTests << std::endl;
191 std::cout <<
" -> Nb. of positive tests : " << nbOfPositiveTests << std::endl;
192 std::cout <<
" -> Positive % : " << 100.*nbOfPositiveTests/nbOfTests <<
" %" << std::endl << std::endl;
275 std::unordered_set<unsigned int>::iterator it_neigh, it_neigh_end;
284 for( ; it_neigh != it_neigh_end; ++ it_neigh)
305 std::unordered_set<unsigned int>::iterator it_neigh, it_neigh_end;
310 for( ; it_neigh != it_neigh_end; ++ it_neigh)
340 std::unordered_set<unsigned int>::iterator it_idx, it_idx_end;
344 for( ; it_idx != it_idx_end; ++it_idx)
362 std::unordered_set<unsigned int>::iterator it_idx, it_idx_end;
366 for( ; it_idx != it_idx_end; ++it_idx)
412 libMesh::Node * dummyNode = NULL;
413 unsigned int counter = 0;
414 for( ; it_set != it_set_end ; ++it_set)
426 libMesh::Elem * originalElem = NULL;
427 libMesh::Elem * dummyElem = NULL;
430 unsigned int originalNode = 0;
431 unsigned int outputNode = 0;
432 for( ; it_set != it_set_end ; ++it_set)
436 if(originalElem->type() == libMesh::TET4)
440 else if(originalElem->type() == libMesh::HEX8)
449 for(
unsigned int iii = 0; iii < originalElem->n_nodes(); ++iii)
451 originalNode = originalElem->node(iii);
453 dummyElem->set_node(iii) =
m_Mesh_patch.node_ptr(outputNode);
467 std::string filename_mesh = filename_base +
".msh";
470 std::string filename_elements = filename_base +
"_elements__global_to_patch.dat";
471 std::string filename_nodes = filename_base +
"_nodes__global_to_patch.dat";
473 std::ofstream elems_out(filename_elements);
474 std::ofstream nodes_out(filename_nodes);
libMesh::ReplicatedMesh m_Mesh_patch
Patch mesh.
std::unordered_map< unsigned int, int > m_node_map_Patch_to_Parent
Mapping between the patch and parent mesh nodes, using the former as keys.
std::unordered_set< unsigned int > & node_indexes()
Returns the set of nodes inside the patch.
std::unordered_set< unsigned int > m_Patch_Elem_indexes
Set of elements inside the patch.
std::unordered_map< unsigned int, int > m_element_already_treated
[ADV. FRONT] Marks if an element was already treated or not
void set_elem_as_inside_queue(unsigned int elem_id)
[ADV. FRONT] Mark element as already inside the deque of elements to be treated.
std::unordered_map< unsigned int, int > m_node_map_Parent_to_Patch
Mapping between the parent and patch mesh nodes, using the former as keys.
void export_patch_mesh(std::string &filename_base)
Export the patch mesh to a file.
void insert_patch_element(const libMesh::Elem *Patch_elem)
Insert an parent mesh element inside the patch, updating the data structures.
const libMesh::Elem * current_elem_pointer()
unsigned int intersection_queue_extract_front_elem()
[ADV. FRONT] Pop and returns the first element to be treated.
libMesh::ReplicatedMesh & parent_mesh()
Returns the parent mesh.
unsigned int FrontSearch_prepare_for_probed_test()
[ADV. FRONT] Reset the advancing front search data structures, with the exception of list of elements...
std::unordered_map< unsigned int, std::unordered_set< unsigned int > > & patch_elem_neighbours()
Returns the patch mesh element neighbour table.
bool intersection_queue_empty()
[ADV. FRONT] Check if deque of elements to be treated is empty.
Intersection_Tools m_Intersection_Test
Intersection search and construction tools.
bool test_queue_empty()
[ADV. FRONT] Check if deque of elements to be tested is empty.
std::unordered_set< unsigned int > & elem_indexes()
Returns the set of elements inside the patch.
libMesh::ReplicatedMesh & patch_mesh()
Returns the patch mesh.
libMesh::ReplicatedMesh & m_Mesh_parent
Parent mesh.
const libMesh::Elem * elem(unsigned int idx)
std::unordered_map< unsigned int, std::unordered_set< unsigned int > > m_Patch_Elem_Neighbours
Element neighbour table for the patch.
std::unordered_map< unsigned int, int > m_element_inside_intersection_queue
[ADV. FRONT] Marks if an element is already inside "m_element_intersection_queue" ...
unsigned int convert_patch_to_parent_elem_id(unsigned int input)
Convert an element index from the patch mesh to the parent mesh.
std::unordered_set< unsigned int > m_Patch_Node_indexes
Set of nodes inside the patch.
void BuildPatch(const libMesh::Elem *Query_elem)
Build the patch mesh covering a given "Query_elem".
bool set_neighbors_to_search_next_pairs()
[ADV. FRONT] Set the list of neighbors of the current element that must be tested yet...
void set_elem_as_treated(unsigned int elem_id)
[ADV. FRONT] Mark element as already treated.
bool m_bTestNeighsForNewPairs
!!!
void add_neighbors_to_test_list()
[ADV. FRONT] Adds element to test list.
std::unique_ptr< libMesh::PointLocatorBase > m_Parent_Point_Locator
Parent mesh point locator.
unsigned int test_queue_extract_front_elem()
[ADV. FRONT] Pop and returns the first element to be tested.
std::deque< int > m_element_intersection_queue
[ADV. FRONT] Deque containing the elements to be treated.
void FrontSearch_reset()
[ADV. FRONT] Reset the advancing front search data structures, with the exception of list of elements...
unsigned int size()
Returns the number of elements inside the patch.
unsigned int m_working_element_id
[ADV. FRONT] Index of the patch element currently being tested
std::deque< int > m_element_test_queue
[ADV. FRONT] Deque containing the elements to be tested
bool m_bPrintDebug
Print debug information? Default: false.
void intersection_queue_push_back(unsigned int elem_id)
[ADV. FRONT] Push back element to the deque containing the elements to be treated.
std::unordered_set< unsigned int > m_element_neighbours_to_search
[ADV. FRONT] Set containing the current element's neighbors that must be tested yet.
unsigned int current_elem_id()
void build_patch_mesh()
Build a patch mesh from the patch data structures.
std::unordered_map< unsigned int, int > m_elem_map_Patch_to_Parent
Mapping between the patch and parent mesh elements, using the former as keys.
unsigned int convert_parent_to_patch_elem_id(unsigned int input)
Convert an element index from the parent mesh to the patch mesh.
std::unordered_map< unsigned int, int > m_elem_map_Parent_to_Patch
Mapping between the parent and patch mesh elements, using the former as keys.
void FrontSearch_initialize()
[ADV. FRONT] Initialize the advancing front search data structures.
std::unordered_set< unsigned int > & neighbors_to_search_next_pair()
[ADV. FRONT] Returns the current element's neighbors that must be tested yet.