| 1 |
#include "stk_middle_mesh/create_mesh.hpp" |
| 2 |
#include "stk_middle_mesh/edge_tracer.hpp" |
| 3 |
#include "stk_middle_mesh/field.hpp" |
| 4 |
#include "gtest/gtest.h" |
| 5 |
#include <limits> |
| 6 |
|
| 7 |
namespace stk { |
| 8 |
namespace middle_mesh { |
| 9 |
namespace impl { |
| 10 |
|
| 11 |
using namespace stk::middle_mesh::predicates::impl; |
| 12 |
|
| 13 |
namespace testing { |
| 14 |
|
| 15 |
|
| 16 |
class EdgeTracerTesterBase |
| 17 |
{ |
| 18 |
protected: |
| 19 |
EdgeTracerTesterBase() |
| 20 |
{} |
| 21 |
|
| 22 |
// forward to private members of class |
| 23 |
std::vector<mesh::MeshEntityPtr> get_elements(mesh::MeshEntityPtr entity) { return tracer->get_elements(entity); } |
| 24 |
std::vector<mesh::MeshEntityPtr> get_excluded_elements(const predicates::impl::PointRecord& prevIntersection, |
| 25 |
const predicates::impl::PointRecord& currentIntersection) |
| 26 |
{ |
| 27 |
return tracer->get_excluded_elements(prevIntersection, currentIntersection); |
| 28 |
} |
| 29 |
|
| 30 |
std::vector<mesh::MeshEntityPtr> get_included_entities(std::vector<mesh::MeshEntityPtr>& allEntities, |
| 31 |
const std::vector<mesh::MeshEntityPtr>& excludedEntities) |
| 32 |
{ |
| 33 |
return tracer->get_included_entities(allEntities, excludedEntities); |
| 34 |
} |
| 35 |
|
| 36 |
bool at_end_of_line(const std::vector<mesh::MeshEntityPtr>& includedElements, |
| 37 |
const predicates::impl::PointRecord& endVert) |
| 38 |
{ |
| 39 |
return tracer->at_end_of_line(includedElements, endVert); |
| 40 |
} |
| 41 |
|
| 42 |
std::vector<mesh::MeshEntityPtr> get_edges(const std::vector<mesh::MeshEntityPtr>& elements) |
| 43 |
{ |
| 44 |
return tracer->get_edges(elements); |
| 45 |
} |
| 46 |
|
| 47 |
std::vector<mesh::MeshEntityPtr> get_excluded_edges(const predicates::impl::PointRecord& record) |
| 48 |
{ |
| 49 |
return tracer->get_excluded_edges(record); |
| 50 |
} |
| 51 |
|
| 52 |
int choose_intersection_with_minimum_angle(const std::vector<double>& alphas, const std::vector<double>& betas, |
| 53 |
const std::vector<int>& intersectionsInRange, |
| 54 |
const std::vector<mesh::MeshEntityPtr>& edges, |
| 55 |
const std::vector<int>& intersectionIdxToEdgeIdx, |
| 56 |
const utils::Point& edgeStartPt, const utils::Point& edgeEndPt) |
| 57 |
{ |
| 58 |
return tracer->choose_intersection_with_minimum_angle(alphas, betas, intersectionsInRange, edges, |
| 59 |
intersectionIdxToEdgeIdx, edgeStartPt, edgeEndPt); |
| 60 |
} |
| 61 |
|
| 62 |
nonconformal4::impl::EdgeIntersection |
| 63 |
create_edge_intersection(mesh::MeshEntityPtr edge, const std::vector<mesh::MeshEntityPtr>& includedElements, |
| 64 |
double alpha, double beta) |
| 65 |
{ |
| 66 |
return tracer->create_edge_intersection(edge, includedElements, alpha, beta); |
| 67 |
} |
| 68 |
|
| 69 |
void trace_edge(const utils::Point& ptStart, const utils::Point& normalStart, |
| 70 |
const predicates::impl::PointRecord& recordStart, const utils::Point& ptEnd, |
| 71 |
const utils::Point& normalEnd, const predicates::impl::PointRecord& recordEnd, |
| 72 |
std::vector<nonconformal4::impl::EdgeIntersection>& intersections) |
| 73 |
{ |
| 74 |
tracer->trace_edge(ptStart, normalStart, recordStart, ptEnd, normalEnd, recordEnd, intersections); |
| 75 |
} |
| 76 |
|
| 77 |
void redistribute_points_near_endpoints(std::vector<nonconformal4::impl::EdgeIntersection>& intersections, |
| 78 |
double eps) |
| 79 |
{ |
| 80 |
tracer->redistribute_points_near_endpoints(intersections, eps); |
| 81 |
} |
| 82 |
|
| 83 |
std::shared_ptr<nonconformal4::impl::EdgeTracer> tracer; |
| 84 |
|
| 85 |
mesh::FieldPtr<utils::Point> create_normal_field(std::shared_ptr<mesh::Mesh> mesh) |
| 86 |
{ |
| 87 |
auto field = mesh::create_field<utils::Point>(mesh, mesh::impl::FieldShape(1, 0, 0), 1); |
| 88 |
for (auto& vert : mesh->get_vertices()) |
| 89 |
if (vert) |
| 90 |
(*field)(vert, 0, 0) = utils::Point(0, 0, 1); |
| 91 |
|
| 92 |
return field; |
| 93 |
} |
| 94 |
}; |
| 95 |
|
| 96 |
} // namespace testing |
| 97 |
|
| 98 |
namespace { |
| 99 |
class EdgeTracerTesterQuad : public ::testing::Test, |
| 100 |
public testing::EdgeTracerTesterBase |
| 101 |
{ |
| 102 |
protected: |
| 103 |
EdgeTracerTesterQuad() |
| 104 |
: mesh(create_test_mesh(false)) |
| 105 |
, mesh1(create_test_mesh(false)) |
| 106 |
{ |
| 107 |
tracer = std::make_shared<nonconformal4::impl::EdgeTracer>(mesh, create_normal_field(mesh), middle_mesh::impl::EdgeTracerTolerances(1e-13)); |
| 108 |
} |
| 109 |
|
| 110 |
std::shared_ptr<mesh::Mesh> create_test_mesh(bool createTris=false) |
| 111 |
{ |
| 112 |
mesh::impl::MeshSpec spec; |
| 113 |
spec.xmin = 0; |
| 114 |
spec.xmax = 1; |
| 115 |
spec.ymin = 0; |
| 116 |
spec.ymax = 1; |
| 117 |
spec.numelX = 3; |
| 118 |
spec.numelY = 3; |
| 119 |
|
| 120 |
auto meshTest = create_mesh( |
| 121 |
spec, [](const utils::Point& pt) { return pt; }, MPI_COMM_SELF, createTris); |
| 122 |
interiorVert = meshTest->get_vertices()[5]; |
| 123 |
assert(interiorVert->count_up() == 4); |
| 124 |
|
| 125 |
interiorEdge = meshTest->get_edges()[6]; |
| 126 |
assert(interiorEdge->count_up() == 2); |
| 127 |
|
| 128 |
interiorEl = meshTest->get_elements()[4]; |
| 129 |
|
| 130 |
return meshTest; |
| 131 |
} |
| 132 |
|
| 133 |
std::shared_ptr<mesh::Mesh> mesh; |
| 134 |
std::shared_ptr<mesh::Mesh> mesh1; |
| 135 |
mesh::MeshEntityPtr interiorVert; |
| 136 |
mesh::MeshEntityPtr interiorEdge; |
| 137 |
mesh::MeshEntityPtr interiorEl; |
| 138 |
}; |
| 139 |
|
| 140 |
class EdgeTracerTesterTri : public ::testing::Test, |
| 141 |
public testing::EdgeTracerTesterBase |
| 142 |
{ |
| 143 |
protected: |
| 144 |
EdgeTracerTesterTri() |
| 145 |
: mesh(create_test_mesh(true)) |
| 146 |
, mesh1(create_test_mesh(true)) |
| 147 |
{ |
| 148 |
tracer = std::make_shared<nonconformal4::impl::EdgeTracer>(mesh, create_normal_field(mesh), middle_mesh::impl::EdgeTracerTolerances(1e-13)); |
| 149 |
} |
| 150 |
|
| 151 |
std::shared_ptr<mesh::Mesh> create_test_mesh(bool createTris=false) |
| 152 |
{ |
| 153 |
mesh::impl::MeshSpec spec; |
| 154 |
spec.xmin = 0; |
| 155 |
spec.xmax = 1; |
| 156 |
spec.ymin = 0; |
| 157 |
spec.ymax = 1; |
| 158 |
spec.numelX = 3; |
| 159 |
spec.numelY = 3; |
| 160 |
|
| 161 |
auto meshTest = create_mesh( |
| 162 |
spec, [](const utils::Point& pt) { return pt; }, MPI_COMM_SELF, createTris); |
| 163 |
|
| 164 |
return meshTest; |
| 165 |
} |
| 166 |
|
| 167 |
std::shared_ptr<mesh::Mesh> mesh; |
| 168 |
std::shared_ptr<mesh::Mesh> mesh1; |
| 169 |
mesh::MeshEntityPtr interiorVert; |
| 170 |
mesh::MeshEntityPtr interiorEdge; |
| 171 |
mesh::MeshEntityPtr interiorEl; |
| 172 |
}; |
| 173 |
|
| 174 |
|
| 175 |
template <typename T> |
| 176 |
void expect_equal(std::vector<T> vec1, std::vector<T> vec2) |
| 177 |
{ |
| 178 |
std::sort(vec1.begin(), vec1.end()); |
| 179 |
std::sort(vec2.begin(), vec2.end()); |
| 180 |
EXPECT_EQ(vec1.size(), vec2.size()); |
| 181 |
for (size_t i = 0; i < vec1.size(); ++i) |
| 182 |
EXPECT_EQ(vec1[i], vec2[i]); |
| 183 |
} |
| 184 |
|
| 185 |
mesh::MeshEntityPtr get_closest_element(std::shared_ptr<mesh::Mesh> mesh, const utils::Point& centroid) |
| 186 |
{ |
| 187 |
double minDist = std::numeric_limits<double>::max(); |
| 188 |
mesh::MeshEntityPtr minEl = nullptr; |
| 189 |
for (auto& el : mesh->get_elements()) |
| 190 |
if (el) |
| 191 |
{ |
| 192 |
utils::Point disp = centroid - compute_centroid(el); |
| 193 |
double dist = std::sqrt(dot(disp, disp)); |
| 194 |
if (dist < minDist) |
| 195 |
{ |
| 196 |
minDist = dist; |
| 197 |
minEl = el; |
| 198 |
} |
| 199 |
} |
| 200 |
|
| 201 |
return minEl; |
| 202 |
} |
| 203 |
|
| 204 |
} // namespace |
| 205 |
|
| 206 |
TEST_F(EdgeTracerTesterQuad, get_entity) |
| 207 |
{ |
| 208 |
if (utils::impl::comm_size(MPI_COMM_WORLD) > 1) |
| 209 |
GTEST_SKIP(); |
| 210 |
|
| 211 |
mesh::MeshEntityPtr el = mesh->get_elements()[0]; |
| 212 |
std::array<mesh::MeshEntityPtr, mesh::MAX_DOWN> verts, edges; |
| 213 |
get_downward(el, 1, edges.data()); |
| 214 |
get_downward(el, 0, verts.data()); |
| 215 |
|
| 216 |
for (size_t i = 0; i < verts.size(); ++i) |
| 217 |
{ |
| 218 |
predicates::impl::PointRecord record(PointClassification::Vert, i, el); |
| 219 |
EXPECT_EQ(get_entity(record), verts[i]); |
| 220 |
} |
| 221 |
|
| 222 |
for (size_t i = 0; i < edges.size(); ++i) |
| 223 |
{ |
| 224 |
predicates::impl::PointRecord record(PointClassification::Edge, i, el); |
| 225 |
EXPECT_EQ(get_entity(record), edges[i]); |
| 226 |
} |
| 227 |
} |
| 228 |
|
| 229 |
TEST_F(EdgeTracerTesterQuad, get_elements) |
| 230 |
{ |
| 231 |
if (utils::impl::comm_size(MPI_COMM_WORLD) > 1) |
| 232 |
GTEST_SKIP(); |
| 233 |
|
| 234 |
mesh::MeshEntityPtr vert = interiorVert; |
| 235 |
std::vector<mesh::MeshEntityPtr> els, elsExpected; |
| 236 |
get_upward(vert, 2, elsExpected); |
| 237 |
els = get_elements(vert); |
| 238 |
expect_equal(els, elsExpected); |
| 239 |
|
| 240 |
mesh::MeshEntityPtr edge = interiorEdge; |
| 241 |
get_upward(edge, 2, elsExpected); |
| 242 |
els = get_elements(edge); |
| 243 |
expect_equal(els, elsExpected); |
| 244 |
} |
| 245 |
|
| 246 |
TEST_F(EdgeTracerTesterQuad, get_excluded_elements_FirstPoint) |
| 247 |
{ |
| 248 |
if (utils::impl::comm_size(MPI_COMM_WORLD) > 1) |
| 249 |
GTEST_SKIP(); |
| 250 |
|
| 251 |
mesh::MeshEntityPtr el = mesh->get_elements()[0]; |
| 252 |
std::vector<mesh::MeshEntityPtr> elements; |
| 253 |
elements = get_excluded_elements(predicates::impl::PointRecord(), |
| 254 |
predicates::impl::PointRecord(PointClassification::Interior, -1, el)); |
| 255 |
expect_equal(elements, {}); |
| 256 |
|
| 257 |
elements = get_excluded_elements(predicates::impl::PointRecord(), |
| 258 |
predicates::impl::PointRecord(PointClassification::Edge, 1, el)); |
| 259 |
expect_equal(elements, {}); |
| 260 |
|
| 261 |
elements = get_excluded_elements(predicates::impl::PointRecord(), |
| 262 |
predicates::impl::PointRecord(PointClassification::Vert, 1, el)); |
| 263 |
expect_equal(elements, {}); |
| 264 |
} |
| 265 |
|
| 266 |
TEST_F(EdgeTracerTesterQuad, get_excluded_elements_SecondPointFromInterior) |
| 267 |
{ |
| 268 |
if (utils::impl::comm_size(MPI_COMM_WORLD) > 1) |
| 269 |
GTEST_SKIP(); |
| 270 |
|
| 271 |
mesh::MeshEntityPtr el = mesh->get_elements()[0]; |
| 272 |
std::vector<mesh::MeshEntityPtr> elements; |
| 273 |
elements = get_excluded_elements(predicates::impl::PointRecord(PointClassification::Interior, -1, el), |
| 274 |
predicates::impl::PointRecord(PointClassification::Vert, 1, el)); |
| 275 |
expect_equal(elements, {el}); |
| 276 |
|
| 277 |
elements = get_excluded_elements(predicates::impl::PointRecord(PointClassification::Interior, -1, el), |
| 278 |
predicates::impl::PointRecord(PointClassification::Edge, 1, el)); |
| 279 |
expect_equal(elements, {el}); |
| 280 |
} |
| 281 |
|
| 282 |
TEST_F(EdgeTracerTesterQuad, get_excluded_elements_TwoEdges) |
| 283 |
{ |
| 284 |
if (utils::impl::comm_size(MPI_COMM_WORLD) > 1) |
| 285 |
GTEST_SKIP(); |
| 286 |
|
| 287 |
std::vector<mesh::MeshEntityPtr> elements; |
| 288 |
elements = get_excluded_elements(predicates::impl::PointRecord(PointClassification::Edge, 0, interiorEl), |
| 289 |
predicates::impl::PointRecord(PointClassification::Edge, 2, interiorEl)); |
| 290 |
expect_equal(elements, {interiorEl}); |
| 291 |
} |
| 292 |
|
| 293 |
TEST_F(EdgeTracerTesterQuad, get_excluded_elements_VertEdge) |
| 294 |
{ |
| 295 |
if (utils::impl::comm_size(MPI_COMM_WORLD) > 1) |
| 296 |
GTEST_SKIP(); |
| 297 |
|
| 298 |
std::vector<mesh::MeshEntityPtr> elements; |
| 299 |
elements = get_excluded_elements(predicates::impl::PointRecord(PointClassification::Vert, 0, interiorEl), |
| 300 |
predicates::impl::PointRecord(PointClassification::Edge, 2, interiorEl)); |
| 301 |
expect_equal(elements, {interiorEl}); |
| 302 |
} |
| 303 |
|
| 304 |
TEST_F(EdgeTracerTesterQuad, get_excluded_elements_EdgeVert) |
| 305 |
{ |
| 306 |
if (utils::impl::comm_size(MPI_COMM_WORLD) > 1) |
| 307 |
GTEST_SKIP(); |
| 308 |
|
| 309 |
std::vector<mesh::MeshEntityPtr> elements; |
| 310 |
elements = get_excluded_elements(predicates::impl::PointRecord(PointClassification::Edge, 0, interiorEl), |
| 311 |
predicates::impl::PointRecord(PointClassification::Vert, 2, interiorEl)); |
| 312 |
expect_equal(elements, {interiorEl}); |
| 313 |
} |
| 314 |
|
| 315 |
TEST_F(EdgeTracerTesterQuad, get_excluded_elements_VertVertDiagonal) |
| 316 |
{ |
| 317 |
if (utils::impl::comm_size(MPI_COMM_WORLD) > 1) |
| 318 |
GTEST_SKIP(); |
| 319 |
|
| 320 |
std::vector<mesh::MeshEntityPtr> elements; |
| 321 |
elements = get_excluded_elements(predicates::impl::PointRecord(PointClassification::Vert, 0, interiorEl), |
| 322 |
predicates::impl::PointRecord(PointClassification::Vert, 2, interiorEl)); |
| 323 |
expect_equal(elements, {interiorEl}); |
| 324 |
} |
| 325 |
|
| 326 |
TEST_F(EdgeTracerTesterQuad, get_excluded_elements_VertVertSharedEdge) |
| 327 |
{ |
| 328 |
if (utils::impl::comm_size(MPI_COMM_WORLD) > 1) |
| 329 |
GTEST_SKIP(); |
| 330 |
|
| 331 |
std::vector<mesh::MeshEntityPtr> elements; |
| 332 |
elements = get_excluded_elements(predicates::impl::PointRecord(PointClassification::Vert, 0, interiorEl), |
| 333 |
predicates::impl::PointRecord(PointClassification::Vert, 1, interiorEl)); |
| 334 |
mesh::MeshEntityPtr edge = interiorEl->get_down(0); |
| 335 |
expect_equal(elements, {edge->get_up(0), edge->get_up(1)}); |
| 336 |
} |
| 337 |
|
| 338 |
TEST_F(EdgeTracerTesterQuad, get_included_entities) |
| 339 |
{ |
| 340 |
if (utils::impl::comm_size(MPI_COMM_WORLD) > 1) |
| 341 |
GTEST_SKIP(); |
| 342 |
|
| 343 |
std::vector<mesh::MeshEntityPtr> allEntities = mesh->get_vertices(); |
| 344 |
std::vector<mesh::MeshEntityPtr> excludedEntities = {mesh->get_vertices()[2], mesh->get_vertices()[7]}; |
| 345 |
std::sort(excludedEntities.begin(), excludedEntities.end(), mesh::MeshEntityCompare()); |
| 346 |
std::vector<mesh::MeshEntityPtr> includedEntities = get_included_entities(allEntities, excludedEntities); |
| 347 |
|
| 348 |
EXPECT_EQ(includedEntities.size(), allEntities.size() - excludedEntities.size()); |
| 349 |
EXPECT_TRUE(std::find(includedEntities.begin(), includedEntities.end(), excludedEntities[0]) == |
| 350 |
includedEntities.end()); |
| 351 |
EXPECT_TRUE(std::find(includedEntities.begin(), includedEntities.end(), excludedEntities[1]) == |
| 352 |
includedEntities.end()); |
| 353 |
} |
| 354 |
|
| 355 |
TEST_F(EdgeTracerTesterQuad, at_end_of_line_Interior) |
| 356 |
{ |
| 357 |
if (utils::impl::comm_size(MPI_COMM_WORLD) > 1) |
| 358 |
GTEST_SKIP(); |
| 359 |
|
| 360 |
std::vector<mesh::MeshEntityPtr> includedEls = {interiorEl}; |
| 361 |
EXPECT_TRUE( |
| 362 |
at_end_of_line(includedEls, predicates::impl::PointRecord(PointClassification::Interior, -1, interiorEl))); |
| 363 |
} |
| 364 |
|
| 365 |
TEST_F(EdgeTracerTesterQuad, at_end_of_line_EdgeSameElement) |
| 366 |
{ |
| 367 |
if (utils::impl::comm_size(MPI_COMM_WORLD) > 1) |
| 368 |
GTEST_SKIP(); |
| 369 |
|
| 370 |
std::vector<mesh::MeshEntityPtr> includedEls = {interiorEl}; |
| 371 |
EXPECT_TRUE(at_end_of_line(includedEls, predicates::impl::PointRecord(PointClassification::Edge, 1, interiorEl))); |
| 372 |
} |
| 373 |
|
| 374 |
TEST_F(EdgeTracerTesterQuad, at_end_of_line_VertSameElement) |
| 375 |
{ |
| 376 |
if (utils::impl::comm_size(MPI_COMM_WORLD) > 1) |
| 377 |
GTEST_SKIP(); |
| 378 |
|
| 379 |
std::vector<mesh::MeshEntityPtr> includedEls = {interiorEl}; |
| 380 |
EXPECT_TRUE(at_end_of_line(includedEls, predicates::impl::PointRecord(PointClassification::Vert, 1, interiorEl))); |
| 381 |
} |
| 382 |
|
| 383 |
TEST_F(EdgeTracerTesterQuad, at_end_of_line_EdgeDifferentElement) |
| 384 |
{ |
| 385 |
if (utils::impl::comm_size(MPI_COMM_WORLD) > 1) |
| 386 |
GTEST_SKIP(); |
| 387 |
|
| 388 |
std::vector<mesh::MeshEntityPtr> includedEls = {interiorEl}; |
| 389 |
int edgeLocalId = 1; |
| 390 |
mesh::MeshEntityPtr edge = interiorEl->get_down(edgeLocalId); |
| 391 |
mesh::MeshEntityPtr otherEl = edge->get_up(0) == interiorEl ? edge->get_up(1) : edge->get_up(0); |
| 392 |
int otherElEdgeLocalId = -1; |
| 393 |
for (int i = 0; i < otherEl->count_down(); ++i) |
| 394 |
if (otherEl->get_down(i) == edge) |
| 395 |
{ |
| 396 |
otherElEdgeLocalId = i; |
| 397 |
break; |
| 398 |
} |
| 399 |
assert(otherElEdgeLocalId != -1); |
| 400 |
|
| 401 |
EXPECT_TRUE(at_end_of_line(includedEls, |
| 402 |
predicates::impl::PointRecord(PointClassification::Edge, otherElEdgeLocalId, otherEl))); |
| 403 |
} |
| 404 |
|
| 405 |
TEST_F(EdgeTracerTesterQuad, at_end_of_line_VertDifferentElement) |
| 406 |
{ |
| 407 |
if (utils::impl::comm_size(MPI_COMM_WORLD) > 1) |
| 408 |
GTEST_SKIP(); |
| 409 |
|
| 410 |
std::vector<mesh::MeshEntityPtr> includedEls = {interiorEl}; |
| 411 |
int vertLocalId = 1; |
| 412 |
|
| 413 |
std::array<mesh::MeshEntityPtr, mesh::MAX_DOWN> elVerts; |
| 414 |
int nverts = get_downward(interiorEl, 0, elVerts.data()); |
| 415 |
mesh::MeshEntityPtr vert = elVerts[vertLocalId]; |
| 416 |
|
| 417 |
std::vector<mesh::MeshEntityPtr> vertEls; |
| 418 |
get_upward(vert, 2, vertEls); |
| 419 |
mesh::MeshEntityPtr otherEl = vertEls[0] == interiorEl ? vertEls[1] : vertEls[0]; |
| 420 |
|
| 421 |
nverts = get_downward(otherEl, 0, elVerts.data()); |
| 422 |
int otherElVertLocalId = -1; |
| 423 |
for (int i = 0; i < nverts; ++i) |
| 424 |
if (elVerts[i] == vert) |
| 425 |
{ |
| 426 |
otherElVertLocalId = i; |
| 427 |
break; |
| 428 |
} |
| 429 |
assert(otherElVertLocalId != -1); |
| 430 |
|
| 431 |
EXPECT_TRUE(at_end_of_line(includedEls, |
| 432 |
predicates::impl::PointRecord(PointClassification::Vert, otherElVertLocalId, otherEl))); |
| 433 |
} |
| 434 |
|
| 435 |
TEST_F(EdgeTracerTesterQuad, get_edges) |
| 436 |
{ |
| 437 |
if (utils::impl::comm_size(MPI_COMM_WORLD) > 1) |
| 438 |
GTEST_SKIP(); |
| 439 |
|
| 440 |
mesh::MeshEntityPtr el1 = interiorEdge->get_up(0); |
| 441 |
mesh::MeshEntityPtr el2 = interiorEdge->get_up(1); |
| 442 |
std::vector<mesh::MeshEntityPtr> els{el1, el2}, edges; |
| 443 |
for (int i = 0; i < el1->count_down(); ++i) |
| 444 |
edges.push_back(el1->get_down(i)); |
| 445 |
|
| 446 |
for (int i = 0; i < el2->count_down(); ++i) |
| 447 |
{ |
| 448 |
mesh::MeshEntityPtr edge = el2->get_down(i); |
| 449 |
if (std::find(edges.begin(), edges.end(), edge) == edges.end()) |
| 450 |
edges.push_back(edge); |
| 451 |
} |
| 452 |
|
| 453 |
std::vector<mesh::MeshEntityPtr> edges2 = get_edges(els); |
| 454 |
expect_equal(edges, edges2); |
| 455 |
} |
| 456 |
|
| 457 |
TEST_F(EdgeTracerTesterQuad, get_excluded_edges) |
| 458 |
{ |
| 459 |
if (utils::impl::comm_size(MPI_COMM_WORLD) > 1) |
| 460 |
GTEST_SKIP(); |
| 461 |
|
| 462 |
std::vector<mesh::MeshEntityPtr> edges; |
| 463 |
edges = get_excluded_edges(predicates::impl::PointRecord(PointClassification::Interior, -1, interiorEl)); |
| 464 |
expect_equal(edges, {}); |
| 465 |
|
| 466 |
edges = get_excluded_edges(predicates::impl::PointRecord(PointClassification::Edge, 0, interiorEl)); |
| 467 |
expect_equal(edges, {interiorEl->get_down(0)}); |
| 468 |
|
| 469 |
std::array<mesh::MeshEntityPtr, mesh::MAX_DOWN> verts; |
| 470 |
get_downward(interiorEl, 0, verts.data()); |
| 471 |
mesh::MeshEntityPtr vert = verts[0]; |
| 472 |
std::vector<mesh::MeshEntityPtr> edgesExpected; |
| 473 |
for (int i = 0; i < vert->count_up(); ++i) |
| 474 |
edgesExpected.push_back(vert->get_up(i)); |
| 475 |
|
| 476 |
edges = get_excluded_edges(predicates::impl::PointRecord(PointClassification::Vert, 0, interiorEl)); |
| 477 |
expect_equal(edges, edgesExpected); |
| 478 |
} |
| 479 |
|
| 480 |
TEST_F(EdgeTracerTesterQuad, getBestIntersectionWhenMultipleInRange) |
| 481 |
{ |
| 482 |
if (utils::impl::comm_size(MPI_COMM_WORLD) > 1) |
| 483 |
GTEST_SKIP(); |
| 484 |
|
| 485 |
auto meshTest = mesh::make_empty_mesh(); |
| 486 |
mesh::MeshEntityPtr v1 = meshTest->create_vertex(0, 0, 0); |
| 487 |
mesh::MeshEntityPtr v2 = meshTest->create_vertex(1, 0, 0); |
| 488 |
mesh::MeshEntityPtr v3 = meshTest->create_vertex(1, 1, 0); |
| 489 |
mesh::MeshEntityPtr edge1 = meshTest->create_edge(v1, v2); |
| 490 |
mesh::MeshEntityPtr edge2 = meshTest->create_edge(v2, v3); |
| 491 |
|
| 492 |
utils::Point inputEdgeStart = utils::Point(0.5, 0.5); |
| 493 |
utils::Point inputEdgeEnd = utils::Point(0.5, -0.5); |
| 494 |
|
| 495 |
std::vector<mesh::MeshEntityPtr> edges = {edge1, edge2}; |
| 496 |
std::vector<double> alphas = {0.25, 0.5, -1, 0.75}; |
| 497 |
std::vector<double> betas = {0.3, 0.5, -12, 0.8}; |
| 498 |
std::vector<int> intersectionsInRange = {0, 1, 3}; |
| 499 |
std::vector<int> intersectionIdxToEdgeIdx = {0, 0, 1, 1}; |
| 500 |
|
| 501 |
int bestIntersectionIdx = choose_intersection_with_minimum_angle( |
| 502 |
alphas, betas, intersectionsInRange, edges, intersectionIdxToEdgeIdx, inputEdgeStart, inputEdgeEnd); |
| 503 |
EXPECT_EQ(bestIntersectionIdx, 1); |
| 504 |
} |
| 505 |
|
| 506 |
TEST_F(EdgeTracerTesterQuad, create_edge_intersection) |
| 507 |
{ |
| 508 |
if (utils::impl::comm_size(MPI_COMM_WORLD) > 1) |
| 509 |
GTEST_SKIP(); |
| 510 |
|
| 511 |
mesh::MeshEntityPtr el1 = interiorEl; |
| 512 |
mesh::MeshEntityPtr commonEdge = interiorEl->get_down(0); |
| 513 |
mesh::MeshEntityPtr el2 = commonEdge->get_up(0) == el1 ? commonEdge->get_up(1) : commonEdge->get_up(0); |
| 514 |
mesh::MeshEntityPtr intersectedEdge = el2->get_down(1); |
| 515 |
double alpha = 0.5, beta = 0.1; |
| 516 |
|
| 517 |
nonconformal4::impl::EdgeIntersection edgeIntersection = |
| 518 |
create_edge_intersection(intersectedEdge, {el1, el2}, alpha, beta); |
| 519 |
EXPECT_EQ(edgeIntersection.record.type, PointClassification::Edge); |
| 520 |
EXPECT_EQ(edgeIntersection.record.id, 1); |
| 521 |
EXPECT_EQ(edgeIntersection.record.el, el2); |
| 522 |
EXPECT_EQ(edgeIntersection.alpha, alpha); |
| 523 |
EXPECT_EQ(edgeIntersection.beta, beta); |
| 524 |
|
| 525 |
beta = 0; |
| 526 |
edgeIntersection = create_edge_intersection(intersectedEdge, {el1, el2}, alpha, beta); |
| 527 |
EXPECT_EQ(edgeIntersection.record.type, PointClassification::Vert); |
| 528 |
EXPECT_EQ(edgeIntersection.record.id, 1); |
| 529 |
EXPECT_EQ(edgeIntersection.record.el, el2); |
| 530 |
EXPECT_EQ(edgeIntersection.alpha, alpha); |
| 531 |
EXPECT_EQ(edgeIntersection.beta, -1); |
| 532 |
} |
| 533 |
|
| 534 |
TEST_F(EdgeTracerTesterQuad, get_entity_id_Verts) |
| 535 |
{ |
| 536 |
if (utils::impl::comm_size(MPI_COMM_WORLD) > 1) |
| 537 |
GTEST_SKIP(); |
| 538 |
|
| 539 |
mesh::MeshEntityPtr el = interiorEl; |
| 540 |
std::array<mesh::MeshEntityPtr, mesh::MAX_DOWN> verts; |
| 541 |
int nverts = get_downward(el, 0, verts.data()); |
| 542 |
|
| 543 |
for (int i = 0; i < nverts; ++i) |
| 544 |
EXPECT_EQ(predicates::impl::get_entity_id(el, verts[i]), i); |
| 545 |
} |
| 546 |
|
| 547 |
TEST_F(EdgeTracerTesterQuad, get_entity_id_Edges) |
| 548 |
{ |
| 549 |
if (utils::impl::comm_size(MPI_COMM_WORLD) > 1) |
| 550 |
GTEST_SKIP(); |
| 551 |
|
| 552 |
mesh::MeshEntityPtr el = interiorEl; |
| 553 |
std::array<mesh::MeshEntityPtr, mesh::MAX_DOWN> edges; |
| 554 |
int nedges = get_downward(el, 0, edges.data()); |
| 555 |
|
| 556 |
for (int i = 0; i < nedges; ++i) |
| 557 |
EXPECT_EQ(predicates::impl::get_entity_id(el, edges[i]), i); |
| 558 |
} |
| 559 |
|
| 560 |
TEST_F(EdgeTracerTesterQuad, trace_edgeThroughEdges) |
| 561 |
{ |
| 562 |
if (utils::impl::comm_size(MPI_COMM_WORLD) > 1) |
| 563 |
GTEST_SKIP(); |
| 564 |
|
| 565 |
utils::Point ptStart(0.25, 0.25), ptEnd(0.75, 0.25), normal(0, 0, 1); |
| 566 |
mesh::MeshEntityPtr elStart = get_closest_element(mesh1, utils::Point(1.0 / 6, 1.0 / 6)); |
| 567 |
mesh::MeshEntityPtr elMiddle = get_closest_element(mesh1, utils::Point(1.0 / 2, 1.0 / 6)); |
| 568 |
mesh::MeshEntityPtr elEnd = get_closest_element(mesh1, utils::Point(5.0 / 6, 1.0 / 6)); |
| 569 |
predicates::impl::PointRecord recordStart(PointClassification::Interior, -1, elStart); |
| 570 |
predicates::impl::PointRecord recordEnd(PointClassification::Interior, -1, elEnd); |
| 571 |
std::vector<nonconformal4::impl::EdgeIntersection> intersections; |
| 572 |
|
| 573 |
trace_edge(ptStart, normal, recordStart, ptEnd, normal, recordEnd, intersections); |
| 574 |
|
| 575 |
EXPECT_EQ(intersections.size(), 2u); |
| 576 |
EXPECT_EQ(intersections[0].record.el, elStart); |
| 577 |
EXPECT_EQ(intersections[0].record.type, PointClassification::Edge); |
| 578 |
EXPECT_EQ(intersections[0].record.id, 1); |
| 579 |
EXPECT_NEAR(intersections[0].alpha, 1.0 / 6, 1e-13); |
| 580 |
EXPECT_NEAR(intersections[0].beta, 0.75, 1e-13); |
| 581 |
|
| 582 |
EXPECT_EQ(intersections[1].record.el, elMiddle); |
| 583 |
EXPECT_EQ(intersections[1].record.type, PointClassification::Edge); |
| 584 |
EXPECT_EQ(intersections[1].record.id, 1); |
| 585 |
EXPECT_NEAR(intersections[1].alpha, 10.0 / 12, 1e-13); |
| 586 |
EXPECT_NEAR(intersections[1].beta, 0.75, 1e-13); |
| 587 |
} |
| 588 |
|
| 589 |
TEST_F(EdgeTracerTesterTri, trace_edgeThroughEdges) |
| 590 |
{ |
| 591 |
if (utils::impl::comm_size(MPI_COMM_WORLD) > 1) |
| 592 |
GTEST_SKIP(); |
| 593 |
|
| 594 |
utils::Point ptStart(0.25, 0.10), ptEnd(0.75, 0.1), normal(0, 0, 1); |
| 595 |
mesh::MeshEntityPtr el1 = get_closest_element(mesh1, utils::Point(2.0 / 9, 1.0 / 9)); |
| 596 |
mesh::MeshEntityPtr el2 = get_closest_element(mesh1, utils::Point(4.0 / 9, 2.0 / 9)); |
| 597 |
mesh::MeshEntityPtr el3 = get_closest_element(mesh1, utils::Point(5.0 / 9, 1.0 / 9)); |
| 598 |
mesh::MeshEntityPtr el4 = get_closest_element(mesh1, utils::Point(7.0 / 9, 2.0 / 9)); |
| 599 |
predicates::impl::PointRecord recordStart(PointClassification::Interior, -1, el1); |
| 600 |
predicates::impl::PointRecord recordEnd(PointClassification::Interior, -1, el4); |
| 601 |
std::vector<nonconformal4::impl::EdgeIntersection> intersections; |
| 602 |
|
| 603 |
trace_edge(ptStart, normal, recordStart, ptEnd, normal, recordEnd, intersections); |
| 604 |
|
| 605 |
EXPECT_EQ(intersections.size(), 3u); |
| 606 |
EXPECT_EQ(intersections[0].record.el, el1); |
| 607 |
EXPECT_EQ(intersections[0].record.type, PointClassification::Edge); |
| 608 |
EXPECT_EQ(intersections[0].record.id, 1); |
| 609 |
EXPECT_NEAR(intersections[0].alpha, 1.0 / 6, 1e-13); |
| 610 |
EXPECT_NEAR(intersections[0].beta, 0.3, 1e-13); |
| 611 |
|
| 612 |
EXPECT_EQ(intersections[1].record.el, el2); |
| 613 |
EXPECT_EQ(intersections[1].record.type, PointClassification::Edge); |
| 614 |
EXPECT_EQ(intersections[1].record.id, 0); |
| 615 |
EXPECT_NEAR(intersections[1].alpha, 2*(0.1 + 1.0/3 - 1.0/4), 1e-13); |
| 616 |
EXPECT_NEAR(intersections[1].beta, 0.3, 1e-13); |
| 617 |
|
| 618 |
EXPECT_EQ(intersections[2].record.el, el3); |
| 619 |
EXPECT_EQ(intersections[2].record.type, PointClassification::Edge); |
| 620 |
EXPECT_EQ(intersections[2].record.id, 1); |
| 621 |
EXPECT_NEAR(intersections[2].alpha, 5.0/6, 1e-13); |
| 622 |
EXPECT_NEAR(intersections[2].beta, 0.3, 1e-13); |
| 623 |
} |
| 624 |
|
| 625 |
TEST_F(EdgeTracerTesterQuad, trace_edgeThroughEdgesStartingFromEdge) |
| 626 |
{ |
| 627 |
if (utils::impl::comm_size(MPI_COMM_WORLD) > 1) |
| 628 |
GTEST_SKIP(); |
| 629 |
|
| 630 |
// both endpoints are on edges |
| 631 |
utils::Point ptStart(0, 0.25), ptEnd(1, 0.25), normal(0, 0, 1); |
| 632 |
mesh::MeshEntityPtr elStart = get_closest_element(mesh1, utils::Point(1.0 / 6, 1.0 / 6)); |
| 633 |
mesh::MeshEntityPtr elMiddle = get_closest_element(mesh1, utils::Point(1.0 / 2, 1.0 / 6)); |
| 634 |
mesh::MeshEntityPtr elEnd = get_closest_element(mesh1, utils::Point(5.0 / 6, 1.0 / 6)); |
| 635 |
predicates::impl::PointRecord recordStart(PointClassification::Edge, 3, elStart); |
| 636 |
predicates::impl::PointRecord recordEnd(PointClassification::Edge, 1, elEnd); |
| 637 |
std::vector<nonconformal4::impl::EdgeIntersection> intersections; |
| 638 |
|
| 639 |
trace_edge(ptStart, normal, recordStart, ptEnd, normal, recordEnd, intersections); |
| 640 |
|
| 641 |
EXPECT_EQ(intersections.size(), 2u); |
| 642 |
EXPECT_EQ(intersections[0].record.el, elStart); |
| 643 |
EXPECT_EQ(intersections[0].record.type, PointClassification::Edge); |
| 644 |
EXPECT_EQ(intersections[0].record.id, 1); |
| 645 |
EXPECT_NEAR(intersections[0].alpha, 1.0 / 3, 1e-13); |
| 646 |
EXPECT_NEAR(intersections[0].beta, 0.75, 1e-13); |
| 647 |
|
| 648 |
EXPECT_EQ(intersections[1].record.el, elMiddle); |
| 649 |
EXPECT_EQ(intersections[1].record.type, PointClassification::Edge); |
| 650 |
EXPECT_EQ(intersections[1].record.id, 1); |
| 651 |
EXPECT_NEAR(intersections[1].alpha, 2.0 / 3, 1e-13); |
| 652 |
EXPECT_NEAR(intersections[1].beta, 0.75, 1e-13); |
| 653 |
} |
| 654 |
|
| 655 |
TEST_F(EdgeTracerTesterQuad, trace_edgeThroughDiagonalVertices) |
| 656 |
{ |
| 657 |
if (utils::impl::comm_size(MPI_COMM_WORLD) > 1) |
| 658 |
GTEST_SKIP(); |
| 659 |
|
| 660 |
utils::Point ptStart(0.25, 0.25), ptEnd(0.75, 0.75), normal(0, 0, 1); |
| 661 |
mesh::MeshEntityPtr elStart = get_closest_element(mesh1, utils::Point(1.0 / 6, 1.0 / 6)); |
| 662 |
mesh::MeshEntityPtr elMiddle = get_closest_element(mesh1, utils::Point(1.0 / 2, 1.0 / 2)); |
| 663 |
mesh::MeshEntityPtr elEnd = get_closest_element(mesh1, utils::Point(5.0 / 6, 5.0 / 6)); |
| 664 |
predicates::impl::PointRecord recordStart(PointClassification::Interior, -1, elStart); |
| 665 |
predicates::impl::PointRecord recordEnd(PointClassification::Interior, -1, elEnd); |
| 666 |
std::vector<nonconformal4::impl::EdgeIntersection> intersections; |
| 667 |
|
| 668 |
trace_edge(ptStart, normal, recordStart, ptEnd, normal, recordEnd, intersections); |
| 669 |
|
| 670 |
EXPECT_EQ(intersections.size(), 2u); |
| 671 |
EXPECT_EQ(intersections[0].record.el, elStart); |
| 672 |
EXPECT_EQ(intersections[0].record.type, PointClassification::Vert); |
| 673 |
EXPECT_EQ(intersections[0].record.id, 2); |
| 674 |
EXPECT_NEAR(intersections[0].alpha, 1.0 / 6, 1e-13); |
| 675 |
EXPECT_NEAR(intersections[0].beta, -1, 1e-13); |
| 676 |
|
| 677 |
EXPECT_EQ(intersections[1].record.el, elMiddle); |
| 678 |
EXPECT_EQ(intersections[1].record.type, PointClassification::Vert); |
| 679 |
EXPECT_EQ(intersections[1].record.id, 2); |
| 680 |
EXPECT_NEAR(intersections[1].alpha, 10.0 / 12, 1e-13); |
| 681 |
EXPECT_NEAR(intersections[1].beta, -1, 1e-13); |
| 682 |
} |
| 683 |
|
| 684 |
TEST_F(EdgeTracerTesterQuad, trace_edgeThroughHorizontalVertices) |
| 685 |
{ |
| 686 |
if (utils::impl::comm_size(MPI_COMM_WORLD) > 1) |
| 687 |
GTEST_SKIP(); |
| 688 |
|
| 689 |
utils::Point ptStart(0.25, 1.0 / 3.0), ptEnd(0.75, 1.0 / 3.0), normal(0, 0, 1); |
| 690 |
mesh::MeshEntityPtr elStart = get_closest_element(mesh1, utils::Point(1.0 / 6, 1.0 / 6)); |
| 691 |
mesh::MeshEntityPtr elMiddle = get_closest_element(mesh1, utils::Point(1.0 / 2, 1.0 / 6)); |
| 692 |
mesh::MeshEntityPtr elEnd = get_closest_element(mesh1, utils::Point(5.0 / 6, 1.0 / 6)); |
| 693 |
predicates::impl::PointRecord recordStart(PointClassification::Edge, 2, elStart); |
| 694 |
predicates::impl::PointRecord recordEnd(PointClassification::Edge, 2, elEnd); |
| 695 |
std::vector<nonconformal4::impl::EdgeIntersection> intersections; |
| 696 |
|
| 697 |
trace_edge(ptStart, normal, recordStart, ptEnd, normal, recordEnd, intersections); |
| 698 |
|
| 699 |
EXPECT_EQ(intersections.size(), 2u); |
| 700 |
EXPECT_EQ(intersections[0].record.el, elStart); |
| 701 |
EXPECT_EQ(intersections[0].record.type, PointClassification::Vert); |
| 702 |
EXPECT_EQ(intersections[0].record.id, 2); |
| 703 |
EXPECT_NEAR(intersections[0].alpha, 1.0 / 6, 1e-13); |
| 704 |
EXPECT_NEAR(intersections[0].beta, -1, 1e-13); |
| 705 |
|
| 706 |
EXPECT_EQ(intersections[1].record.el, elMiddle); |
| 707 |
EXPECT_EQ(intersections[1].record.type, PointClassification::Vert); |
| 708 |
EXPECT_EQ(intersections[1].record.id, 2); |
| 709 |
EXPECT_NEAR(intersections[1].alpha, 10.0 / 12, 1e-13); |
| 710 |
EXPECT_NEAR(intersections[1].beta, -1, 1e-13); |
| 711 |
} |
| 712 |
|
| 713 |
TEST_F(EdgeTracerTesterQuad, trace_edgeBetweenHorizontalVertices) |
| 714 |
{ |
| 715 |
if (utils::impl::comm_size(MPI_COMM_WORLD) > 1) |
| 716 |
GTEST_SKIP(); |
| 717 |
|
| 718 |
utils::Point ptStart(0, 1.0 / 3.0), ptEnd(1, 1.0 / 3.0), normal(0, 0, 1); |
| 719 |
mesh::MeshEntityPtr elStart = get_closest_element(mesh1, utils::Point(1.0 / 6, 1.0 / 6)); |
| 720 |
mesh::MeshEntityPtr elMiddle = get_closest_element(mesh1, utils::Point(1.0 / 2, 1.0 / 6)); |
| 721 |
mesh::MeshEntityPtr elEnd = get_closest_element(mesh1, utils::Point(5.0 / 6, 1.0 / 6)); |
| 722 |
predicates::impl::PointRecord recordStart(PointClassification::Vert, 3, elStart); |
| 723 |
predicates::impl::PointRecord recordEnd(PointClassification::Vert, 2, elEnd); |
| 724 |
std::vector<nonconformal4::impl::EdgeIntersection> intersections; |
| 725 |
|
| 726 |
trace_edge(ptStart, normal, recordStart, ptEnd, normal, recordEnd, intersections); |
| 727 |
|
| 728 |
EXPECT_EQ(intersections.size(), 2u); |
| 729 |
// EXPECT_EQ(intersections[0].record.el, el_start); |
| 730 |
EXPECT_EQ(intersections[0].record.type, PointClassification::Vert); |
| 731 |
// EXPECT_EQ(intersections[0].record.id, 2); |
| 732 |
EXPECT_EQ(get_entity(intersections[0].record), |
| 733 |
get_entity(predicates::impl::PointRecord(PointClassification::Vert, 2, elStart))); |
| 734 |
EXPECT_NEAR(intersections[0].alpha, 1.0 / 3, 1e-13); |
| 735 |
EXPECT_NEAR(intersections[0].beta, -1, 1e-13); |
| 736 |
|
| 737 |
// EXPECT_EQ(intersections[1].record.el, el_middle); |
| 738 |
EXPECT_EQ(intersections[1].record.type, PointClassification::Vert); |
| 739 |
// EXPECT_EQ(intersections[1].record.id, 2); |
| 740 |
EXPECT_EQ(get_entity(intersections[1].record), |
| 741 |
get_entity(predicates::impl::PointRecord(PointClassification::Vert, 2, elMiddle))); |
| 742 |
|
| 743 |
EXPECT_NEAR(intersections[1].alpha, 2.0 / 3, 1e-13); |
| 744 |
EXPECT_NEAR(intersections[1].beta, -1, 1e-13); |
| 745 |
} |
| 746 |
|
| 747 |
// Test cases: |
| 748 |
// 1. If no points within m_eps, do nothing |
| 749 |
// 2. Single point withing range |
| 750 |
// 3. 3 points within range |
| 751 |
TEST_F(EdgeTracerTesterQuad, redistribute_points_near_endpointNoChange) |
| 752 |
{ |
| 753 |
if (utils::impl::comm_size(MPI_COMM_WORLD) > 1) |
| 754 |
GTEST_SKIP(); |
| 755 |
|
| 756 |
std::vector<nonconformal4::impl::EdgeIntersection> intersections; |
| 757 |
intersections.push_back(nonconformal4::impl::EdgeIntersection{predicates::impl::PointRecord(), 0.5, 0.5}); |
| 758 |
|
| 759 |
redistribute_points_near_endpoints(intersections, 0.1); |
| 760 |
|
| 761 |
EXPECT_EQ(intersections[0].alpha, 0.5); |
| 762 |
EXPECT_EQ(intersections[0].beta, 0.5); |
| 763 |
} |
| 764 |
|
| 765 |
TEST_F(EdgeTracerTesterQuad, redistribute_points_near_endpointSinglePointLeft) |
| 766 |
{ |
| 767 |
if (utils::impl::comm_size(MPI_COMM_WORLD) > 1) |
| 768 |
GTEST_SKIP(); |
| 769 |
|
| 770 |
std::vector<nonconformal4::impl::EdgeIntersection> intersections; |
| 771 |
intersections.push_back(nonconformal4::impl::EdgeIntersection{predicates::impl::PointRecord(), 0, 0.5}); |
| 772 |
double eps = 0.1; |
| 773 |
|
| 774 |
redistribute_points_near_endpoints(intersections, eps); |
| 775 |
|
| 776 |
EXPECT_EQ(intersections[0].alpha, eps / 2); |
| 777 |
EXPECT_EQ(intersections[0].beta, 0.5); |
| 778 |
} |
| 779 |
|
| 780 |
TEST_F(EdgeTracerTesterQuad, redistribute_points_near_endpointSinglePointRight) |
| 781 |
{ |
| 782 |
if (utils::impl::comm_size(MPI_COMM_WORLD) > 1) |
| 783 |
GTEST_SKIP(); |
| 784 |
|
| 785 |
std::vector<nonconformal4::impl::EdgeIntersection> intersections; |
| 786 |
intersections.push_back(nonconformal4::impl::EdgeIntersection{predicates::impl::PointRecord(), 1, 0.5}); |
| 787 |
double eps = 0.1; |
| 788 |
|
| 789 |
redistribute_points_near_endpoints(intersections, eps); |
| 790 |
|
| 791 |
EXPECT_EQ(intersections[0].alpha, 1 - eps / 2); |
| 792 |
EXPECT_EQ(intersections[0].beta, 0.5); |
| 793 |
} |
| 794 |
|
| 795 |
TEST_F(EdgeTracerTesterQuad, redistribute_points_near_endpointThreePointsLeft) |
| 796 |
{ |
| 797 |
if (utils::impl::comm_size(MPI_COMM_WORLD) > 1) |
| 798 |
GTEST_SKIP(); |
| 799 |
|
| 800 |
std::vector<nonconformal4::impl::EdgeIntersection> intersections; |
| 801 |
intersections.push_back(nonconformal4::impl::EdgeIntersection{predicates::impl::PointRecord(), 0, 0.5}); |
| 802 |
intersections.push_back(nonconformal4::impl::EdgeIntersection{predicates::impl::PointRecord(), 0, 0.5}); |
| 803 |
intersections.push_back(nonconformal4::impl::EdgeIntersection{predicates::impl::PointRecord(), 0, 0.5}); |
| 804 |
|
| 805 |
double eps = 0.1; |
| 806 |
|
| 807 |
redistribute_points_near_endpoints(intersections, eps); |
| 808 |
|
| 809 |
EXPECT_EQ(intersections[0].alpha, eps / 4); |
| 810 |
EXPECT_EQ(intersections[0].beta, 0.5); |
| 811 |
|
| 812 |
EXPECT_EQ(intersections[1].alpha, eps / 2); |
| 813 |
EXPECT_EQ(intersections[1].beta, 0.5); |
| 814 |
|
| 815 |
EXPECT_EQ(intersections[2].alpha, 3 * eps / 4); |
| 816 |
EXPECT_EQ(intersections[2].beta, 0.5); |
| 817 |
} |
| 818 |
|
| 819 |
TEST_F(EdgeTracerTesterQuad, redistribute_points_near_endpointThreePointsRight) |
| 820 |
{ |
| 821 |
if (utils::impl::comm_size(MPI_COMM_WORLD) > 1) |
| 822 |
GTEST_SKIP(); |
| 823 |
|
| 824 |
std::vector<nonconformal4::impl::EdgeIntersection> intersections; |
| 825 |
intersections.push_back(nonconformal4::impl::EdgeIntersection{predicates::impl::PointRecord(), 1, 0.5}); |
| 826 |
intersections.push_back(nonconformal4::impl::EdgeIntersection{predicates::impl::PointRecord(), 1, 0.5}); |
| 827 |
intersections.push_back(nonconformal4::impl::EdgeIntersection{predicates::impl::PointRecord(), 1, 0.5}); |
| 828 |
|
| 829 |
double eps = 0.1; |
| 830 |
|
| 831 |
redistribute_points_near_endpoints(intersections, eps); |
| 832 |
|
| 833 |
EXPECT_EQ(intersections[0].alpha, 1 - 3 * eps / 4); |
| 834 |
EXPECT_EQ(intersections[0].beta, 0.5); |
| 835 |
|
| 836 |
EXPECT_EQ(intersections[1].alpha, 1 - eps / 2); |
| 837 |
EXPECT_EQ(intersections[1].beta, 0.5); |
| 838 |
|
| 839 |
EXPECT_EQ(intersections[2].alpha, 1 - eps / 4); |
| 840 |
EXPECT_EQ(intersections[2].beta, 0.5); |
| 841 |
} |
| 842 |
|
| 843 |
} // namespace impl |
| 844 |
} // namespace middle_mesh |
| 845 |
} // namespace stk |