144 const std::pair<unsigned, unsigned> merged_nodes_pair,
145 const bool elementIndexIsRemapped)
147 const unsigned element_index = pElement->
GetIndex();
148 const unsigned element_num_edges = pElement->
GetNumEdges();
149 std::vector<long> edge_mapping(element_num_edges, -1);
150 std::vector<unsigned> edge_status(element_num_edges, 0);
153 for (
unsigned i = 0; i < oldIds.size(); ++i)
158 edge_mapping[index] = i;
159 edge_status[index] = 0;
163 const unsigned node_A_index = merged_nodes_pair.first;
164 const unsigned node_B_index = merged_nodes_pair.second;
167 bool is_B_upper = node_B_index > node_A_index;
168 if (node_A_index == 0)
170 is_B_upper = node_B_index == 1;
172 if (node_B_index == 0)
177 is_B_upper = node_A_index != 1;
180 unsigned lower_node = node_A_index;
181 unsigned upper_node = node_B_index;
184 lower_node = node_B_index;
185 upper_node = node_A_index;
189 unsigned prev_edge = 0;
197 prev_edge = element_num_edges - 2;
199 else if (upper_node == 1)
201 prev_edge = element_num_edges - 1;
205 prev_edge = upper_node - 2;
210 if (upper_node == 0 || upper_node == 1)
212 prev_edge = element_num_edges - 1;
216 prev_edge = upper_node - 2;
219 const unsigned next_edge = (prev_edge + 1) % element_num_edges;
222 edge_status[prev_edge] = 3;
223 edge_status[next_edge] = 3;
230 edge_mapping[next_edge] = node_B_index;
239 edge_mapping[prev_edge] = element_num_edges;
243 edge_mapping[prev_edge] = lower_node - 1;
247 for (
unsigned i = 0; i < edge_mapping.size(); ++i)
249 assert(edge_mapping[i] >= 0);
253 mEdgeOperations.emplace_back(EDGE_OPERATION_NODE_MERGE, element_index, remap_info, elementIndexIsRemapped);
258 const unsigned edgeIndex,
259 const double insertedNodeRelPosition,
260 const bool elementIndexIsRemapped)
262 const unsigned element_index = pElement->
GetIndex();
263 const unsigned element_num_edges = pElement->
GetNumEdges();
264 std::vector<double> thetas(element_num_edges);
265 std::vector<long> edge_mapping(element_num_edges);
266 std::vector<unsigned> edge_status(element_num_edges, 0);
269 const unsigned split_1 = edgeIndex;
270 const unsigned split_2 = edgeIndex + 1;
271 edge_status[split_1] = 1;
272 edge_status[split_2] = 1;
273 thetas[split_1] = insertedNodeRelPosition;
274 thetas[split_2] = 1.0 - insertedNodeRelPosition;
276 for (
unsigned i = 0; i < element_num_edges; ++i)
278 edge_mapping[i] = i - count;
279 if (edge_status[i] == 1)
287 mEdgeOperations.emplace_back(EDGE_OPERATION_SPLIT, element_index, remap_info, elementIndexIsRemapped);
295 const unsigned num_edges_1 = pElement1->
GetNumEdges();
296 const unsigned num_edges_2 = pElement2->
GetNumEdges();
297 std::vector<long> edge_mapping_1(num_edges_1, -2);
298 std::vector<long> edge_mapping_2(num_edges_2, -2);
299 std::vector<unsigned> edge_status_1(num_edges_1);
300 std::vector<unsigned> edge_status_2(num_edges_2);
302 std::vector<unsigned> old_split_edges(rOldIds.size());
304 for (
unsigned i = 0; i < rOldIds.size(); ++i)
306 old_split_edges[i] = i;
310 [[maybe_unused]]
unsigned counter_1 = 0;
311 [[maybe_unused]]
unsigned counter_2 = 0;
315 for (
unsigned i = 0; i < rOldIds.size(); ++i)
321 auto position = std::find(old_split_edges.begin(), old_split_edges.end(), i);
326 edge_mapping_1[index_1] = i;
327 edge_status_1[index_1] = 0;
328 old_split_edges.erase(position);
333 edge_mapping_2[index_2] = i;
334 edge_status_2[index_2] = 0;
335 old_split_edges.erase(position);
340 assert(old_split_edges.size() == 2);
343 assert(counter_1 == num_edges_1 - 3);
344 assert(counter_2 == num_edges_2 - 3);
347 std::vector<double> thetas_1(num_edges_1);
348 std::vector<double> thetas_2(num_edges_2);
352 std::vector<unsigned> old_split_edges_1(old_split_edges);
353 for (
unsigned i = 0; i < num_edges_1; ++i)
355 if (edge_mapping_1[i] == -2)
357 auto p_node_1 = pElement1->
GetEdge(i)->GetNode(0);
358 auto p_node_2 = pElement1->
GetEdge(i)->GetNode(1);
359 bool split_edge_found =
false;
360 for (
unsigned j = 0; j < old_split_edges_1.size(); ++j)
362 auto old_edge = (*mpEdgeHelper)[rOldIds[old_split_edges_1[j]]];
363 if (old_edge->ContainsNode(p_node_1) || old_edge->ContainsNode(p_node_2))
365 edge_mapping_1[i] = old_split_edges_1[j];
366 edge_status_1[i] = 1;
368 split_edge_found =
true;
369 thetas_1[i] = pElement1->
GetEdge(i)->rGetLength() / old_edge->rGetLength();
370 old_split_edges_1.erase(old_split_edges_1.begin() + j);
374 if (!split_edge_found)
376 edge_mapping_1[i] = -1;
377 edge_status_1[i] = 2;
383 for (
unsigned i = 0; i < num_edges_2; ++i)
385 if (edge_mapping_2[i] == -2)
387 auto p_node_1 = pElement2->
GetEdge(i)->GetNode(0);
388 auto p_node_2 = pElement2->
GetEdge(i)->GetNode(1);
389 bool split_edge_found =
false;
390 for (
unsigned j = 0; j < old_split_edges.size(); ++j)
392 auto old_edge = (*mpEdgeHelper)[rOldIds[old_split_edges[j]]];
393 if (old_edge->ContainsNode(p_node_1) || old_edge->ContainsNode(p_node_2))
395 edge_mapping_2[i] = old_split_edges[j];
396 edge_status_2[i] = 1;
398 split_edge_found =
true;
399 thetas_2[i] = pElement2->
GetEdge(i)->rGetLength() / old_edge->rGetLength();
400 old_split_edges.erase(old_split_edges.begin() + j);
404 if (!split_edge_found)
406 edge_mapping_2[i] = -1;
407 edge_status_2[i] = 2;
412 assert(old_split_edges_1.empty());
413 assert(old_split_edges.empty());
416 assert(counter_1 == num_edges_1);
417 assert(counter_2 == num_edges_2);
423 mEdgeOperations.emplace_back(pElement1->
GetIndex(), pElement2->
GetIndex(), remap_info_1, remap_info_2);
428 const unsigned edgeIndex)
430 const unsigned element_index = pElement->
GetIndex();
431 const unsigned num_edges = pElement->
GetNumEdges();
432 std::vector<long> edge_mapping(num_edges, 0);
433 std::vector<unsigned> edge_status(num_edges);
434 for (
unsigned i = 0; i < edgeIndex; ++i)
439 edge_mapping[edgeIndex] = -1;
440 edge_status[edgeIndex] = 2;
441 for (
unsigned i = edgeIndex + 1; i < num_edges; ++i)
443 edge_mapping[i] = i - 1;
448 mEdgeOperations.emplace_back(EDGE_OPERATION_ADD, element_index, remap_info);
453 const unsigned nodeIndex)
455 const unsigned element_index = pElement->
GetIndex();
456 const unsigned num_edges = pElement->
GetNumEdges();
457 std::vector<long> edge_mapping(num_edges, 0);
458 std::vector<unsigned> edge_status(num_edges, 0);
462 unsigned low_edge = (nodeIndex + num_edges) % (num_edges + 1);
463 unsigned high_edge = nodeIndex;
466 if (low_edge > high_edge)
468 edge_status[low_edge - 1] = 4;
469 for (
unsigned i = 0; i < num_edges; ++i)
471 edge_mapping[i] = i + 1;
473 edge_mapping[low_edge - 1] = low_edge;
477 edge_status[low_edge] = 4;
478 for (
unsigned i = 0; i < high_edge; ++i)
482 for (
unsigned i = high_edge; i < num_edges; ++i)
484 edge_mapping[i] = i + 1;
489 mEdgeOperations.emplace_back(EDGE_OPERATION_MERGE, element_index, remap_info);