23 std::unordered_set<unsigned int >::const_iterator elem_idx_it = restricted_mesh_set->begin();
24 std::unordered_set<unsigned int >::const_iterator elem_idx_it_end = restricted_mesh_set->end();
26 for( ; elem_idx_it != elem_idx_it_end; ++ elem_idx_it)
28 const libMesh::Elem * elem_to_add =
m_Mesh_parent.elem(*elem_idx_it);
38 bool bDoIntersect =
false;
41 std::deque<int> Restriction_Test_Queue;
44 unsigned int treated_from_mesh_preallocation =
m_Mesh_parent.n_elem();
45 std::unordered_set<int> Treated_From_Mesh;
50 Treated_From_Mesh.reserve(treated_from_mesh_preallocation);
52 std::set<unsigned int> Intersecting_elems;
55 unsigned int Tested_idx;
58 unsigned int Candidate_idx;
64 std::set<unsigned int>::iterator it_set_start;
66 libMesh::Mesh::const_element_iterator it_coupling = Coupling_mesh.elements_begin();
67 libMesh::Mesh::const_element_iterator it_coupling_end = Coupling_mesh.elements_end();
71 int nbOfPositiveTests = 1;
73 for( ; it_coupling != it_coupling_end; ++it_coupling)
75 const libMesh::Elem * Query_elem = * it_coupling;
77 Treated_From_Mesh.clear();
82 libMesh::Elem * First_Restriction_elems = NULL;
83 libMesh::Elem * elem_candidate = NULL;
84 it_set_start = Intersecting_elems.begin();
86 for( ; it_set_start != Intersecting_elems.end(); ++it_set_start)
88 Treated_From_Mesh.insert(*it_set_start);
92 for(
unsigned int iii = 0; iii < First_Restriction_elems->n_neighbors(); ++iii)
94 elem_candidate = First_Restriction_elems->neighbor(iii);
95 if(elem_candidate != NULL && Treated_From_Mesh.find(elem_candidate->id())==Treated_From_Mesh.end())
97 Restriction_Test_Queue.push_back(elem_candidate->id());
98 Treated_From_Mesh.insert(elem_candidate->id());
103 while(!Restriction_Test_Queue.empty())
106 Tested_idx = Restriction_Test_Queue[0];
107 Restriction_Test_Queue.pop_front();
108 const libMesh::Elem * Tested_elem =
m_Mesh_parent.elem(Tested_idx);
123 for(
unsigned int iii = 0; iii < Tested_elem->n_neighbors(); ++iii)
125 elem_candidate = Tested_elem->neighbor(iii);
126 if(elem_candidate != NULL)
128 Candidate_idx = elem_candidate->id();
129 if(Treated_From_Mesh.find(Candidate_idx)==Treated_From_Mesh.end())
131 Restriction_Test_Queue.push_back(Candidate_idx);
132 Treated_From_Mesh.insert(Candidate_idx);
144 std::cout <<
" DEBUG: Restriction search results" << std::endl;
145 std::cout <<
" -> Nb. of intersections found : " <<
m_Patch_Elem_indexes.size() << std::endl << std::endl;
147 std::cout <<
" -> Nb. of mesh elements : " <<
m_Mesh_parent.n_elem() << std::endl;
151 std::cout <<
" -> Nb. of mesh nodes : " <<
m_Mesh_parent.n_nodes() << std::endl;
155 std::cout <<
" -> Nb. of tests : " << nbOfTests << std::endl;
156 std::cout <<
" -> Nb. of positive tests : " << nbOfPositiveTests << std::endl;
157 std::cout <<
" -> Positive % : " << 100.*nbOfPositiveTests/nbOfTests <<
" %" << std::endl << std::endl;
166 std::string filename_mesh = filename_base +
".msh";
170 output_mesh.binary() =
true;
171 output_mesh.write(filename_mesh);
173 std::string filename_elements = filename_base +
"_restrict.dat";
175 std::ofstream elems_out(filename_elements);
libMesh::ReplicatedMesh m_Mesh_patch
Patch mesh.
void BuildRestrictionFromSet(const std::unordered_set< unsigned int > *restricted_mesh_set)
Build the restriction of the parent mesh from a given element set. This version is useful if the inte...
libMesh::ReplicatedMesh & restricted_mesh()
Returns the restricted mesh.
std::unordered_set< unsigned int > m_Patch_Elem_indexes
Set of elements inside the patch.
void insert_patch_element(const libMesh::Elem *Patch_elem)
Insert an parent mesh element inside the patch, updating the data structures.
void export_restriction_mesh(const std::string &filename_base)
Export the restricted mesh to a file.
Intersection_Tools m_Intersection_Test
Intersection search and construction tools.
void BuildRestriction(const libMesh::ReplicatedMesh &Coupling_mesh)
Build the restriction of the parent mesh to the coupling region defined by Coupling_mesh.
libMesh::ReplicatedMesh & m_Mesh_parent
Parent mesh.
std::unordered_map< unsigned int, std::unordered_set< unsigned int > > m_Patch_Elem_Neighbours
Element neighbour table for the patch.
std::unordered_set< unsigned int > m_Patch_Node_indexes
Set of nodes inside the patch.
std::unique_ptr< libMesh::PointLocatorBase > m_Parent_Point_Locator
Parent mesh point locator.
bool m_bPrintDebug
Print debug information? Default: false.
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.
const unsigned int m_rank
Parent mesh processor rank.