OGS
ProcessLib::LIE::anonymous_namespace{MeshUtils.cpp} Namespace Reference

Classes

class  IsCrackTip
 

Functions

void findFracutreIntersections (MeshLib::Mesh const &mesh, std::vector< int > const &vec_fracture_mat_IDs, std::vector< std::vector< MeshLib::Node * > > const &vec_fracture_nodes, std::vector< std::vector< MeshLib::Element * > > &intersected_fracture_elements, std::vector< std::pair< std::size_t, std::vector< int > > > &vec_branch_nodeID_matIDs, std::vector< std::pair< std::size_t, std::vector< int > > > &vec_junction_nodeID_matIDs)
 

Function Documentation

◆ findFracutreIntersections()

void ProcessLib::LIE::anonymous_namespace{MeshUtils.cpp}::findFracutreIntersections ( MeshLib::Mesh const & mesh,
std::vector< int > const & vec_fracture_mat_IDs,
std::vector< std::vector< MeshLib::Node * > > const & vec_fracture_nodes,
std::vector< std::vector< MeshLib::Element * > > & intersected_fracture_elements,
std::vector< std::pair< std::size_t, std::vector< int > > > & vec_branch_nodeID_matIDs,
std::vector< std::pair< std::size_t, std::vector< int > > > & vec_junction_nodeID_matIDs )

Definition at line 70 of file MeshUtils.cpp.

78{
79 auto const n_fractures = vec_fracture_mat_IDs.size();
80 std::map<unsigned, unsigned> matID_to_fid;
81 for (unsigned i = 0; i < n_fractures; i++)
82 {
83 matID_to_fid[vec_fracture_mat_IDs[i]] = i;
84 }
85
86 // make a vector all fracture nodes
87 std::vector<std::size_t> all_fracture_nodes;
88 for (auto& vec : vec_fracture_nodes)
89 {
90 transform(cbegin(vec), cend(vec), back_inserter(all_fracture_nodes),
91 [](auto* const n) { return n->getID(); });
92 }
93
94 // create a table of a node id and connected material IDs
95 std::map<std::size_t, std::vector<std::size_t>> frac_nodeID_to_matIDs;
96 for (unsigned i = 0; i < n_fractures; i++)
97 {
98 for (auto* node : vec_fracture_nodes[i])
99 {
100 frac_nodeID_to_matIDs[node->getID()].push_back(
101 vec_fracture_mat_IDs[i]);
102 }
103 }
104
105 auto const* const opt_material_ids = MeshLib::materialIDs(mesh);
106
107 // find branch/junction nodes which connect to multiple fractures
108 intersected_fracture_elements.resize(n_fractures);
109 for (auto frac_nodeID_to_matID : frac_nodeID_to_matIDs)
110 {
111 auto nodeID = frac_nodeID_to_matID.first;
112 auto const* node = mesh.getNode(frac_nodeID_to_matID.first);
113 auto const& matIDs = frac_nodeID_to_matID.second;
114 if (matIDs.size() < 2)
115 {
116 continue; // no intersection
117 }
118
119 auto const elements_connected_to_node =
120 mesh.getElementsConnectedToNode(*node);
121 std::vector<MeshLib::Element*> conn_fracture_elements;
122 {
123 for (auto const* e : elements_connected_to_node)
124 {
125 if (e->getDimension() == (mesh.getDimension() - 1))
126 {
127 conn_fracture_elements.push_back(
128 const_cast<MeshLib::Element*>(e));
129 }
130 }
131 }
132
133 std::map<int, int> vec_matID_counts;
134 {
135 for (auto matid : matIDs)
136 {
137 vec_matID_counts[matid] = 0;
138 }
139
140 for (auto const* e : conn_fracture_elements)
141 {
142 auto matid = (*opt_material_ids)[e->getID()];
143 vec_matID_counts[matid]++;
144 }
145 }
146
147 for (auto matid : matIDs)
148 {
149 auto fid = matID_to_fid[matid];
150 for (auto* e : conn_fracture_elements)
151 {
152 auto e_matid = (*opt_material_ids)[e->getID()];
153 if (matID_to_fid[e_matid] != fid)
154 { // only slave elements
155 intersected_fracture_elements[fid].push_back(e);
156 }
157 }
158 }
159
160 bool isBranch = false;
161 {
162 for (auto vec_matID_count : vec_matID_counts)
163 {
164 auto count = vec_matID_count.second;
165 if (count % 2 == 1)
166 {
167 isBranch = true;
168 break;
169 }
170 }
171 }
172
173 if (isBranch)
174 {
175 std::vector<int> branch_matIDs(2);
176 for (auto vec_matID_count : vec_matID_counts)
177 {
178 auto matid = vec_matID_count.first;
179 auto count = vec_matID_count.second;
180 if (count % 2 == 0)
181 {
182 branch_matIDs[0] = matid; // master
183 }
184 else
185 {
186 branch_matIDs[1] = matid; // slave
187 }
188 }
189 vec_branch_nodeID_matIDs.emplace_back(nodeID, branch_matIDs);
190 }
191 else
192 {
193 std::vector<int> junction_matIDs(2);
194 junction_matIDs[0] = std::min(vec_matID_counts.begin()->first,
195 vec_matID_counts.rbegin()->first);
196 junction_matIDs[1] = std::max(vec_matID_counts.begin()->first,
197 vec_matID_counts.rbegin()->first);
198 vec_junction_nodeID_matIDs.emplace_back(nodeID, junction_matIDs);
199 }
200 }
201
202 for (auto& elements : intersected_fracture_elements)
203 {
205 }
206
207 DBUG("-> found {:d} branches and {:d} junctions",
208 vec_branch_nodeID_matIDs.size(), vec_junction_nodeID_matIDs.size());
209}
void DBUG(fmt::format_string< Args... > fmt, Args &&... args)
Definition Logging.h:30
void makeVectorUnique(std::vector< T > &v)
Definition Algorithm.h:176
PropertyVector< int > const * materialIDs(Mesh const &mesh)
Definition Mesh.cpp:268

References DBUG(), findFracutreIntersections(), MeshLib::Mesh::getDimension(), MeshLib::Mesh::getElementsConnectedToNode(), MeshLib::Mesh::getNode(), BaseLib::makeVectorUnique(), and MeshLib::materialIDs().

Referenced by findFracutreIntersections().