| 1 |
#include <stk_util/stk_config.h> |
| 2 |
#include "stk_middle_mesh/create_mesh.hpp" |
| 3 |
#include "stk_middle_mesh/incremental_mesh_boundary_snapper.hpp" |
| 4 |
#include "stk_middle_mesh/mesh_io.hpp" |
| 5 |
#include "stk_middle_mesh/nonconformal4.hpp" |
| 6 |
#include "stk_util/parallel/ParallelReduce.hpp" |
| 7 |
#include "util/meshes.hpp" |
| 8 |
#include "util/nonconformal_interface_helpers.hpp" |
| 9 |
#include "stk_middle_mesh/application_interface.hpp" |
| 10 |
#include "gtest/gtest.h" |
| 11 |
#include <cmath> |
| 12 |
|
| 13 |
|
| 14 |
#ifdef STK_BUILT_FOR_SIERRA |
| 15 |
#include "stk_middle_mesh_util/create_stk_mesh.hpp" |
| 16 |
#include "stk_middle_mesh_util/exodus_writer.hpp" |
| 17 |
|
| 18 |
namespace stk { |
| 19 |
namespace middle_mesh { |
| 20 |
|
| 21 |
using namespace nonconformal4::impl; |
| 22 |
using namespace utils::impl; |
| 23 |
using namespace mesh::impl; |
| 24 |
using stk_interface::StkMeshCreator; |
| 25 |
|
| 26 |
namespace { |
| 27 |
|
| 28 |
class CommSplitter |
| 29 |
{ |
| 30 |
public: |
| 31 |
CommSplitter() |
| 32 |
{ |
| 33 |
split_comm_world(); |
| 34 |
} |
| 35 |
|
| 36 |
~CommSplitter() { MPI_Comm_free(&m_splitComm); } |
| 37 |
|
| 38 |
int get_color() const { return m_color; } |
| 39 |
|
| 40 |
MPI_Comm get_comm() const { return m_splitComm; } |
| 41 |
|
| 42 |
private: |
| 43 |
|
| 44 |
void split_comm_world() |
| 45 |
{ |
| 46 |
int commWorldSize = utils::impl::comm_size(MPI_COMM_WORLD); |
| 47 |
MPI_Comm newComm; |
| 48 |
int color = 0; |
| 49 |
std::cout << "commWorldSize = " << commWorldSize << std::endl; |
| 50 |
if (commWorldSize == 1) |
| 51 |
{ |
| 52 |
MPI_Comm_dup(MPI_COMM_WORLD, &newComm); |
| 53 |
} else |
| 54 |
{ |
| 55 |
int nprocs1 = commWorldSize / 2 + (commWorldSize % 2); |
| 56 |
//int nprocs2 = commWorldSize / 2; |
| 57 |
|
| 58 |
color = utils::impl::comm_rank(MPI_COMM_WORLD) < nprocs1 ? 0 : 1; |
| 59 |
std::cout << "nprocs1 = " << nprocs1 << ", color = " << color << std::endl; |
| 60 |
|
| 61 |
MPI_Comm_split(MPI_COMM_WORLD, color, 0, &newComm); |
| 62 |
} |
| 63 |
|
| 64 |
m_color = color; |
| 65 |
m_splitComm = newComm; |
| 66 |
} |
| 67 |
|
| 68 |
int m_color; |
| 69 |
MPI_Comm m_splitComm; |
| 70 |
|
| 71 |
}; |
| 72 |
|
| 73 |
|
| 74 |
} |
| 75 |
|
| 76 |
TEST(Interface, EigthSphereNewQuad) |
| 77 |
{ |
| 78 |
// project coordinates onto sector of a sphere. Change the size of |
| 79 |
// the mesh2 sector to test different kinds of topology interactions |
| 80 |
|
| 81 |
int commSize = comm_size(MPI_COMM_WORLD); |
| 82 |
int commRank = comm_rank(MPI_COMM_WORLD); |
| 83 |
if (commSize > 4) |
| 84 |
GTEST_SKIP(); |
| 85 |
|
| 86 |
std::cout << std::setprecision(16) << std::endl; |
| 87 |
int nmeshes = 50; // 60; // Note: this breaks on mesh 51 |
| 88 |
CommSplitter commSplitter; |
| 89 |
|
| 90 |
for (int i = 0 /* 0 */; i < nmeshes; ++i) |
| 91 |
{ |
| 92 |
if (commRank == 0) |
| 93 |
{ |
| 94 |
std::cout << "mesh " << i << " / " << nmeshes << std::endl; |
| 95 |
} |
| 96 |
|
| 97 |
std::shared_ptr<mesh::Mesh> mesh1, mesh2; |
| 98 |
|
| 99 |
// std::cout << "creating mesh1" << std::endl; |
| 100 |
if (commSize == 1 || commSplitter.get_color() == 0) |
| 101 |
{ |
| 102 |
mesh1 = create_eigth_sphere(5, 5, 0.5, 1.5, commSplitter.get_comm()); |
| 103 |
} |
| 104 |
|
| 105 |
if (commSize == 1 || commSplitter.get_color() == 1) |
| 106 |
{ |
| 107 |
mesh2 = create_eigth_sphere(5 + i, 5 + i, 0.5, 1.5, commSplitter.get_comm()); |
| 108 |
} |
| 109 |
|
| 110 |
// print_vert_edges("mesh1_initial", mesh1); |
| 111 |
// print_vert_edges("mesh2_initial", mesh2); |
| 112 |
|
| 113 |
double eps = 1e-12; |
| 114 |
MiddleGridOpts opts; |
| 115 |
opts.normalProjectionOpts.classifierTolerances = impl::PointClassifierNormalWrapperTolerances(eps); |
| 116 |
opts.normalProjectionOpts.classifierTolerances.normalInterpolationTolerances.pointClassifierTol = 5e-8; |
| 117 |
opts.normalProjectionOpts.edgeTracerTolerances = impl::EdgeTracerTolerances(eps); |
| 118 |
auto interface = application_interface_factory(ApplicationInterfaceType::Parallel, mesh1, mesh2, |
| 119 |
MPI_COMM_WORLD, nullptr, ParallelSearchOpts(), |
| 120 |
VolumeSnapOpts(), |
| 121 |
BoundarySnapAndQualityImprovementOpts(), |
| 122 |
opts); |
| 123 |
|
| 124 |
interface->create_middle_grid(); |
| 125 |
|
| 126 |
if (mesh1) |
| 127 |
{ |
| 128 |
auto middleMesh1 = interface->get_middle_grid_for_mesh1(); |
| 129 |
auto mesh1Class = interface->get_mesh1_classification(); |
| 130 |
auto mesh1InverseClassification = interface->compute_mesh1_inverse_classification(); |
| 131 |
test_util::test_every_element_classified(middleMesh1, mesh1Class); |
| 132 |
test_util::test_area_per_element(mesh1, mesh1InverseClassification); |
| 133 |
} |
| 134 |
|
| 135 |
if (mesh2) |
| 136 |
{ |
| 137 |
auto middleMesh2 = interface->get_middle_grid_for_mesh2(); |
| 138 |
auto mesh2Class = interface->get_mesh2_classification(); |
| 139 |
test_util::test_every_element_classified(middleMesh2, mesh2Class); |
| 140 |
} |
| 141 |
} |
| 142 |
} |
| 143 |
|
| 144 |
TEST(Interface, EigthSphereNewTri) |
| 145 |
{ |
| 146 |
// project coordinates onto sector of a sphere. Change the size of |
| 147 |
// the mesh2 sector to test different kinds of topology interactions |
| 148 |
|
| 149 |
int commSize = comm_size(MPI_COMM_WORLD); |
| 150 |
int commRank = comm_rank(MPI_COMM_WORLD); |
| 151 |
if (commSize > 4) |
| 152 |
GTEST_SKIP(); |
| 153 |
|
| 154 |
std::cout << std::setprecision(16) << std::endl; |
| 155 |
int nmeshes = 50; // 60; // Note: this breaks on mesh 51 |
| 156 |
CommSplitter commSplitter; |
| 157 |
|
| 158 |
for (int i = 0 /* 0 */; i < nmeshes; ++i) |
| 159 |
{ |
| 160 |
if (commRank == 0) |
| 161 |
{ |
| 162 |
std::cout << "mesh " << i << " / " << nmeshes << std::endl; |
| 163 |
} |
| 164 |
|
| 165 |
std::shared_ptr<mesh::Mesh> mesh1, mesh2; |
| 166 |
|
| 167 |
// std::cout << "creating mesh1" << std::endl; |
| 168 |
if (commSize == 1 || commSplitter.get_color() == 0) |
| 169 |
{ |
| 170 |
mesh1 = create_eigth_sphere(5, 5, 0.5, 1.5, commSplitter.get_comm(), true); |
| 171 |
} |
| 172 |
|
| 173 |
if (commSize == 1 || commSplitter.get_color() == 1) |
| 174 |
{ |
| 175 |
mesh2 = create_eigth_sphere(5 + i, 5 + i, 0.5, 1.5, commSplitter.get_comm(), true); |
| 176 |
} |
| 177 |
|
| 178 |
// print_vert_edges("mesh1_initial", mesh1); |
| 179 |
// print_vert_edges("mesh2_initial", mesh2); |
| 180 |
|
| 181 |
double eps = 1e-12; |
| 182 |
MiddleGridOpts opts; |
| 183 |
opts.normalProjectionOpts.classifierTolerances = impl::PointClassifierNormalWrapperTolerances(eps); |
| 184 |
opts.normalProjectionOpts.classifierTolerances.normalInterpolationTolerances.pointClassifierTol = 5e-8; |
| 185 |
opts.normalProjectionOpts.edgeTracerTolerances = impl::EdgeTracerTolerances(eps); |
| 186 |
auto interface = application_interface_factory(ApplicationInterfaceType::Parallel, mesh1, mesh2, |
| 187 |
MPI_COMM_WORLD, nullptr, ParallelSearchOpts(), |
| 188 |
VolumeSnapOpts(), |
| 189 |
BoundarySnapAndQualityImprovementOpts(), |
| 190 |
opts); |
| 191 |
|
| 192 |
interface->create_middle_grid(); |
| 193 |
|
| 194 |
if (mesh1) |
| 195 |
{ |
| 196 |
auto middleMesh1 = interface->get_middle_grid_for_mesh1(); |
| 197 |
auto mesh1Class = interface->get_mesh1_classification(); |
| 198 |
auto mesh1InverseClassification = interface->compute_mesh1_inverse_classification(); |
| 199 |
test_util::test_every_element_classified(middleMesh1, mesh1Class); |
| 200 |
test_util::test_area_per_element(mesh1, mesh1InverseClassification); |
| 201 |
} |
| 202 |
|
| 203 |
if (mesh2) |
| 204 |
{ |
| 205 |
auto middleMesh2 = interface->get_middle_grid_for_mesh2(); |
| 206 |
auto mesh2Class = interface->get_mesh2_classification(); |
| 207 |
test_util::test_every_element_classified(middleMesh2, mesh2Class); |
| 208 |
} |
| 209 |
} |
| 210 |
} |
| 211 |
|
| 212 |
TEST(Interface, RefiningNewQuad) |
| 213 |
{ |
| 214 |
int commSize = comm_size(MPI_COMM_WORLD); |
| 215 |
int commRank = comm_rank(MPI_COMM_WORLD); |
| 216 |
if (comm_size(MPI_COMM_WORLD) > 4) |
| 217 |
GTEST_SKIP(); |
| 218 |
|
| 219 |
std::cout << std::setprecision(16) << std::endl; |
| 220 |
int nmeshes = 60; |
| 221 |
|
| 222 |
CommSplitter commSplitter; |
| 223 |
|
| 224 |
for (int i = 0; i < nmeshes; ++i) |
| 225 |
{ |
| 226 |
if (commRank == 0) |
| 227 |
{ |
| 228 |
std::cout << "mesh " << i + 1 << " / " << nmeshes << std::endl; |
| 229 |
} |
| 230 |
mesh::impl::MeshSpec spec, spec2; |
| 231 |
spec.numelX = 5; |
| 232 |
spec.numelY = 5; |
| 233 |
spec.xmin = 0; |
| 234 |
spec.xmax = 1; |
| 235 |
spec.ymin = 0; |
| 236 |
spec.ymax = 1; |
| 237 |
|
| 238 |
spec2.numelX = 5 + i; |
| 239 |
spec2.numelY = 5 + i; |
| 240 |
spec2.xmin = 0; |
| 241 |
spec2.xmax = 1; |
| 242 |
spec2.ymin = 0; |
| 243 |
spec2.ymax = 1; |
| 244 |
|
| 245 |
auto func = [&](const utils::Point& pt) { return utils::Point(pt.x, 0, pt.y); }; |
| 246 |
std::shared_ptr<mesh::Mesh> mesh1, mesh2; |
| 247 |
|
| 248 |
// std::cout << "creating mesh1" << std::endl; |
| 249 |
if (commSize == 1 || commSplitter.get_color() == 0) |
| 250 |
mesh1 = create_mesh(spec, func, commSplitter.get_comm()); |
| 251 |
|
| 252 |
// std::cout << "\ncreating mesh2" << std::endl; |
| 253 |
if (commSize == 1 || commSplitter.get_color() == 1) |
| 254 |
mesh2 = create_mesh(spec2, func, commSplitter.get_comm()); |
| 255 |
|
| 256 |
mesh::impl::ElementOperations2D elemOps; |
| 257 |
double mesh1Area = stk::get_global_sum(MPI_COMM_WORLD, mesh1 ? elemOps.compute_area(mesh1) : 0.0); |
| 258 |
double mesh2Area = stk::get_global_sum(MPI_COMM_WORLD, mesh2 ? elemOps.compute_area(mesh2) : 0.0); |
| 259 |
EXPECT_FLOAT_EQ(mesh1Area, mesh2Area); |
| 260 |
|
| 261 |
double eps = 1e-12; |
| 262 |
BoundarySnapAndQualityImprovementOpts snapOpts; |
| 263 |
snapOpts.type = BoundarySnapAndQualityImprovementType::None; |
| 264 |
|
| 265 |
MiddleGridOpts middleMeshOpts; |
| 266 |
middleMeshOpts.normalProjectionOpts.classifierTolerances = impl::PointClassifierNormalWrapperTolerances(eps); |
| 267 |
middleMeshOpts.normalProjectionOpts.edgeTracerTolerances = impl::EdgeTracerTolerances(eps); |
| 268 |
auto interface = application_interface_factory(ApplicationInterfaceType::Parallel, mesh1, mesh2, |
| 269 |
MPI_COMM_WORLD, nullptr, ParallelSearchOpts(), |
| 270 |
VolumeSnapOpts(), |
| 271 |
snapOpts, |
| 272 |
middleMeshOpts); |
| 273 |
|
| 274 |
interface->create_middle_grid(); |
| 275 |
|
| 276 |
if (mesh1) |
| 277 |
{ |
| 278 |
auto middleMesh1 = interface->get_middle_grid_for_mesh1(); |
| 279 |
auto mesh1Class = interface->get_mesh1_classification(); |
| 280 |
auto mesh1InverseClassification = interface->compute_mesh1_inverse_classification(); |
| 281 |
test_util::test_every_element_classified(middleMesh1, mesh1Class); |
| 282 |
test_util::test_area_per_element(mesh1, mesh1InverseClassification); |
| 283 |
} |
| 284 |
|
| 285 |
if (mesh2) |
| 286 |
{ |
| 287 |
auto middleMesh2 = interface->get_middle_grid_for_mesh2(); |
| 288 |
auto mesh2Class = interface->get_mesh2_classification(); |
| 289 |
test_util::test_every_element_classified(middleMesh2, mesh2Class); |
| 290 |
} |
| 291 |
} |
| 292 |
} |
| 293 |
|
| 294 |
TEST(Interface, RefiningNewTri) |
| 295 |
{ |
| 296 |
int commSize = comm_size(MPI_COMM_WORLD); |
| 297 |
int commRank = comm_rank(MPI_COMM_WORLD); |
| 298 |
if (comm_size(MPI_COMM_WORLD) > 4) |
| 299 |
GTEST_SKIP(); |
| 300 |
|
| 301 |
std::cout << std::setprecision(16) << std::endl; |
| 302 |
int nmeshes = 60; |
| 303 |
|
| 304 |
CommSplitter commSplitter; |
| 305 |
|
| 306 |
for (int i = 0; i < nmeshes; ++i) |
| 307 |
{ |
| 308 |
if (commRank == 0) |
| 309 |
{ |
| 310 |
std::cout << "mesh " << i + 1 << " / " << nmeshes << std::endl; |
| 311 |
} |
| 312 |
mesh::impl::MeshSpec spec, spec2; |
| 313 |
spec.numelX = 5; |
| 314 |
spec.numelY = 5; |
| 315 |
spec.xmin = 0; |
| 316 |
spec.xmax = 1; |
| 317 |
spec.ymin = 0; |
| 318 |
spec.ymax = 1; |
| 319 |
|
| 320 |
spec2.numelX = 5 + i; |
| 321 |
spec2.numelY = 5 + i; |
| 322 |
spec2.xmin = 0; |
| 323 |
spec2.xmax = 1; |
| 324 |
spec2.ymin = 0; |
| 325 |
spec2.ymax = 1; |
| 326 |
|
| 327 |
auto func = [&](const utils::Point& pt) { return utils::Point(pt.x, 0, pt.y); }; |
| 328 |
std::shared_ptr<mesh::Mesh> mesh1, mesh2; |
| 329 |
|
| 330 |
// std::cout << "creating mesh1" << std::endl; |
| 331 |
if (commSize == 1 || commSplitter.get_color() == 0) |
| 332 |
mesh1 = create_mesh(spec, func, commSplitter.get_comm(), true); |
| 333 |
|
| 334 |
// std::cout << "\ncreating mesh2" << std::endl; |
| 335 |
if (commSize == 1 || commSplitter.get_color() == 1) |
| 336 |
mesh2 = create_mesh(spec2, func, commSplitter.get_comm(), true); |
| 337 |
|
| 338 |
mesh::impl::ElementOperations2D elemOps; |
| 339 |
double mesh1Area = stk::get_global_sum(MPI_COMM_WORLD, mesh1 ? elemOps.compute_area(mesh1) : 0.0); |
| 340 |
double mesh2Area = stk::get_global_sum(MPI_COMM_WORLD, mesh2 ? elemOps.compute_area(mesh2) : 0.0); |
| 341 |
EXPECT_FLOAT_EQ(mesh1Area, mesh2Area); |
| 342 |
|
| 343 |
double eps = 1e-12; |
| 344 |
BoundarySnapAndQualityImprovementOpts snapOpts; |
| 345 |
snapOpts.type = BoundarySnapAndQualityImprovementType::None; |
| 346 |
|
| 347 |
MiddleGridOpts middleMeshOpts; |
| 348 |
middleMeshOpts.normalProjectionOpts.classifierTolerances = impl::PointClassifierNormalWrapperTolerances(eps); |
| 349 |
middleMeshOpts.normalProjectionOpts.edgeTracerTolerances = impl::EdgeTracerTolerances(eps); |
| 350 |
auto interface = application_interface_factory(ApplicationInterfaceType::Parallel, mesh1, mesh2, |
| 351 |
MPI_COMM_WORLD, nullptr, ParallelSearchOpts(), |
| 352 |
VolumeSnapOpts(), |
| 353 |
snapOpts, |
| 354 |
middleMeshOpts); |
| 355 |
|
| 356 |
interface->create_middle_grid(); |
| 357 |
|
| 358 |
if (mesh1) |
| 359 |
{ |
| 360 |
auto middleMesh1 = interface->get_middle_grid_for_mesh1(); |
| 361 |
auto mesh1Class = interface->get_mesh1_classification(); |
| 362 |
auto mesh1InverseClassification = interface->compute_mesh1_inverse_classification(); |
| 363 |
test_util::test_every_element_classified(middleMesh1, mesh1Class); |
| 364 |
test_util::test_area_per_element(mesh1, mesh1InverseClassification); |
| 365 |
} |
| 366 |
|
| 367 |
if (mesh2) |
| 368 |
{ |
| 369 |
auto middleMesh2 = interface->get_middle_grid_for_mesh2(); |
| 370 |
auto mesh2Class = interface->get_mesh2_classification(); |
| 371 |
test_util::test_every_element_classified(middleMesh2, mesh2Class); |
| 372 |
} |
| 373 |
} |
| 374 |
} |
| 375 |
|
| 376 |
TEST(Interface, AnnulusRotationNewQuad) |
| 377 |
{ |
| 378 |
int commSize = comm_size(MPI_COMM_WORLD); |
| 379 |
int commRank = comm_rank(MPI_COMM_WORLD); |
| 380 |
if (commSize > 4) |
| 381 |
GTEST_SKIP(); |
| 382 |
|
| 383 |
// project coordinates onto sector of a sphere. Change the size of |
| 384 |
// the mesh2 sector to test different kinds of topology interactions |
| 385 |
CommSplitter commSplitter; |
| 386 |
|
| 387 |
std::cout << std::setprecision(16) << std::endl; |
| 388 |
double pi = std::atan(1) * 4; |
| 389 |
int nmeshes = 640; |
| 390 |
double dtheta = pi / (16 * nmeshes); |
| 391 |
|
| 392 |
for (int i = 1; i < nmeshes; ++i) |
| 393 |
{ |
| 394 |
if (commRank == 0) |
| 395 |
{ |
| 396 |
std::cout << "mesh " << i + 1 << " / " << nmeshes << std::endl; |
| 397 |
std::cout << "dtheta = " << i * dtheta * 180.0 / pi << std::endl; |
| 398 |
} |
| 399 |
|
| 400 |
std::shared_ptr<mesh::Mesh> mesh1, mesh2; |
| 401 |
|
| 402 |
// std::cout << "creating mesh1" << std::endl; |
| 403 |
if (commSize == 1 || commSplitter.get_color() == 0) |
| 404 |
mesh1 = impl::make_annulus_mesh(10, 10, 0.5, 1.5, 0, commSplitter.get_comm()); |
| 405 |
|
| 406 |
// std::cout << "\ncreating mesh2" << std::endl; |
| 407 |
if (commSize == 1 || commSplitter.get_color() == 0) |
| 408 |
mesh2 = impl::make_annulus_mesh(13, 13, 0.5, 1.5, i * dtheta, commSplitter.get_comm()); |
| 409 |
|
| 410 |
double eps = 1e-12; |
| 411 |
MiddleGridOpts opts; |
| 412 |
opts.normalProjectionOpts.classifierTolerances = impl::PointClassifierNormalWrapperTolerances(eps); |
| 413 |
opts.normalProjectionOpts.edgeTracerTolerances = impl::EdgeTracerTolerances(eps); |
| 414 |
auto interface = application_interface_factory(ApplicationInterfaceType::Parallel, mesh1, mesh2, |
| 415 |
MPI_COMM_WORLD, nullptr, ParallelSearchOpts(), |
| 416 |
VolumeSnapOpts(), |
| 417 |
BoundarySnapAndQualityImprovementOpts(), |
| 418 |
opts); |
| 419 |
interface->create_middle_grid(); |
| 420 |
|
| 421 |
if (mesh1) |
| 422 |
{ |
| 423 |
auto middleMesh1 = interface->get_middle_grid_for_mesh1(); |
| 424 |
auto mesh1Class = interface->get_mesh1_classification(); |
| 425 |
auto mesh1InverseClassification = interface->compute_mesh1_inverse_classification(); |
| 426 |
EXPECT_GE(middleMesh1->get_elements().size(), mesh1->get_elements().size()); |
| 427 |
test_util::test_every_element_classified(middleMesh1, mesh1Class); |
| 428 |
test_util::test_area_per_element(mesh1, mesh1InverseClassification); |
| 429 |
} |
| 430 |
|
| 431 |
if (mesh2) |
| 432 |
{ |
| 433 |
auto middleMesh2 = interface->get_middle_grid_for_mesh2(); |
| 434 |
auto mesh2Class = interface->get_mesh2_classification(); |
| 435 |
test_util::test_every_element_classified(middleMesh2, mesh2Class); |
| 436 |
} |
| 437 |
} |
| 438 |
} |
| 439 |
|
| 440 |
TEST(Interface, AnnulusRotationNewTri) |
| 441 |
{ |
| 442 |
int commSize = comm_size(MPI_COMM_WORLD); |
| 443 |
int commRank = comm_rank(MPI_COMM_WORLD); |
| 444 |
if (commSize > 4) |
| 445 |
GTEST_SKIP(); |
| 446 |
|
| 447 |
// project coordinates onto sector of a sphere. Change the size of |
| 448 |
// the mesh2 sector to test different kinds of topology interactions |
| 449 |
CommSplitter commSplitter; |
| 450 |
|
| 451 |
std::cout << std::setprecision(16) << std::endl; |
| 452 |
double pi = std::atan(1) * 4; |
| 453 |
int nmeshes = 640; |
| 454 |
double dtheta = pi / (16 * nmeshes); |
| 455 |
|
| 456 |
for (int i = 1; i < nmeshes; ++i) |
| 457 |
{ |
| 458 |
if (commRank == 0) |
| 459 |
{ |
| 460 |
std::cout << "mesh " << i + 1 << " / " << nmeshes << std::endl; |
| 461 |
std::cout << "dtheta = " << i * dtheta * 180.0 / pi << std::endl; |
| 462 |
} |
| 463 |
|
| 464 |
std::shared_ptr<mesh::Mesh> mesh1, mesh2; |
| 465 |
|
| 466 |
// std::cout << "creating mesh1" << std::endl; |
| 467 |
if (commSize == 1 || commSplitter.get_color() == 0) |
| 468 |
mesh1 = impl::make_annulus_mesh(10, 10, 0.5, 1.5, 0, commSplitter.get_comm(), true); |
| 469 |
|
| 470 |
// std::cout << "\ncreating mesh2" << std::endl; |
| 471 |
if (commSize == 1 || commSplitter.get_color() == 0) |
| 472 |
mesh2 = impl::make_annulus_mesh(13, 13, 0.5, 1.5, i * dtheta, commSplitter.get_comm(), true); |
| 473 |
|
| 474 |
double eps = 1e-12; |
| 475 |
MiddleGridOpts opts; |
| 476 |
opts.normalProjectionOpts.classifierTolerances = impl::PointClassifierNormalWrapperTolerances(eps); |
| 477 |
opts.normalProjectionOpts.edgeTracerTolerances = impl::EdgeTracerTolerances(eps); |
| 478 |
auto interface = application_interface_factory(ApplicationInterfaceType::Parallel, mesh1, mesh2, |
| 479 |
MPI_COMM_WORLD, nullptr, ParallelSearchOpts(), |
| 480 |
VolumeSnapOpts(), |
| 481 |
BoundarySnapAndQualityImprovementOpts(), |
| 482 |
opts); |
| 483 |
interface->create_middle_grid(); |
| 484 |
|
| 485 |
if (mesh1) |
| 486 |
{ |
| 487 |
auto middleMesh1 = interface->get_middle_grid_for_mesh1(); |
| 488 |
auto mesh1Class = interface->get_mesh1_classification(); |
| 489 |
auto mesh1InverseClassification = interface->compute_mesh1_inverse_classification(); |
| 490 |
EXPECT_GE(middleMesh1->get_elements().size(), mesh1->get_elements().size()); |
| 491 |
test_util::test_every_element_classified(middleMesh1, mesh1Class); |
| 492 |
test_util::test_area_per_element(mesh1, mesh1InverseClassification); |
| 493 |
} |
| 494 |
|
| 495 |
if (mesh2) |
| 496 |
{ |
| 497 |
auto middleMesh2 = interface->get_middle_grid_for_mesh2(); |
| 498 |
auto mesh2Class = interface->get_mesh2_classification(); |
| 499 |
test_util::test_every_element_classified(middleMesh2, mesh2Class); |
| 500 |
} |
| 501 |
} |
| 502 |
} |
| 503 |
|
| 504 |
TEST(Interface, EllipsoidNewQuad) |
| 505 |
{ |
| 506 |
int commSize = comm_size(MPI_COMM_WORLD); |
| 507 |
int commRank = comm_rank(MPI_COMM_WORLD); |
| 508 |
if (commSize > 4) |
| 509 |
GTEST_SKIP(); |
| 510 |
// project coordinates onto an ellipsoid |
| 511 |
|
| 512 |
CommSplitter commSplitter; |
| 513 |
|
| 514 |
std::cout << std::setprecision(16) << std::endl; |
| 515 |
int nmeshes = 29; // 60; |
| 516 |
double zscale = 2; |
| 517 |
|
| 518 |
for (int i = 1 /* 0 */; i < nmeshes; ++i) |
| 519 |
{ |
| 520 |
if (commRank == 0) |
| 521 |
{ |
| 522 |
std::cout << "mesh " << i + 1 << " / " << nmeshes << std::endl; |
| 523 |
} |
| 524 |
mesh::impl::MeshSpec spec, spec2; |
| 525 |
spec.numelX = 5; |
| 526 |
spec.numelY = 5; |
| 527 |
spec.xmin = -0.75; //-1; |
| 528 |
spec.xmax = 0.75; // 1; |
| 529 |
spec.ymin = -0.75; //-1; |
| 530 |
spec.ymax = 0.75; // 1; |
| 531 |
|
| 532 |
spec2.numelX = 5 + i; |
| 533 |
spec2.numelY = 5 + i; |
| 534 |
spec2.xmin = -0.75; //-1; |
| 535 |
spec2.xmax = 0.75; // 1; |
| 536 |
spec2.ymin = -0.75; //-1; |
| 537 |
spec2.ymax = 0.75; // 1; |
| 538 |
|
| 539 |
auto func = [&](const utils::Point& pt) { |
| 540 |
double x = pt.x; |
| 541 |
double y = pt.y; |
| 542 |
|
| 543 |
double xprime = x * std::sqrt(std::max(1 - y * y / 2, 0.0)); |
| 544 |
double yprime = y * std::sqrt(std::max(1 - x * x / 2, 0.0)); |
| 545 |
double zprime = zscale * std::sqrt(std::max(1 - x * x - y * y, 0.0)); |
| 546 |
utils::Point pt2(xprime, yprime, zprime); |
| 547 |
return pt2; |
| 548 |
}; |
| 549 |
|
| 550 |
std::shared_ptr<mesh::Mesh> mesh1, mesh2; |
| 551 |
|
| 552 |
// std::cout << "creating mesh1" << std::endl; |
| 553 |
if (commSize == 1 || commSplitter.get_color() == 0) |
| 554 |
mesh1 = create_mesh(spec, func, commSplitter.get_comm()); |
| 555 |
|
| 556 |
// std::cout << "\ncreating mesh2" << std::endl; |
| 557 |
if (commSize == 1 || commSplitter.get_color() == 0) |
| 558 |
mesh2 = create_mesh(spec2, func, commSplitter.get_comm()); |
| 559 |
|
| 560 |
// print_vert_edges("mesh1_initial", mesh1); |
| 561 |
// print_vert_edges("mesh2_initial", mesh2); |
| 562 |
|
| 563 |
double eps = 1e-12; |
| 564 |
MiddleGridOpts opts; |
| 565 |
opts.normalProjectionOpts.classifierTolerances = impl::PointClassifierNormalWrapperTolerances(eps); |
| 566 |
opts.normalProjectionOpts.edgeTracerTolerances = impl::EdgeTracerTolerances(eps); |
| 567 |
auto interface = application_interface_factory(ApplicationInterfaceType::Parallel, mesh1, mesh2, |
| 568 |
MPI_COMM_WORLD, nullptr, ParallelSearchOpts(), |
| 569 |
VolumeSnapOpts(), |
| 570 |
BoundarySnapAndQualityImprovementOpts(), |
| 571 |
opts); |
| 572 |
|
| 573 |
interface->create_middle_grid(); |
| 574 |
|
| 575 |
if (mesh1) |
| 576 |
{ |
| 577 |
auto middleMesh1 = interface->get_middle_grid_for_mesh1(); |
| 578 |
auto mesh1Class = interface->get_mesh1_classification(); |
| 579 |
auto mesh1InverseClassification = interface->compute_mesh1_inverse_classification(); |
| 580 |
EXPECT_GE(middleMesh1->get_elements().size(), mesh1->get_elements().size()); |
| 581 |
test_util::test_every_element_classified(middleMesh1, mesh1Class); |
| 582 |
test_util::test_area_per_element(mesh1, mesh1InverseClassification); |
| 583 |
} |
| 584 |
|
| 585 |
if (mesh2) |
| 586 |
{ |
| 587 |
auto middleMesh2 = interface->get_middle_grid_for_mesh2(); |
| 588 |
auto mesh2Class = interface->get_mesh2_classification(); |
| 589 |
test_util::test_every_element_classified(middleMesh2, mesh2Class); |
| 590 |
} |
| 591 |
} |
| 592 |
} |
| 593 |
|
| 594 |
|
| 595 |
TEST(Interface, EllipsoidNewTri) |
| 596 |
{ |
| 597 |
int commSize = comm_size(MPI_COMM_WORLD); |
| 598 |
int commRank = comm_rank(MPI_COMM_WORLD); |
| 599 |
if (commSize > 4) |
| 600 |
GTEST_SKIP(); |
| 601 |
// project coordinates onto an ellipsoid |
| 602 |
|
| 603 |
CommSplitter commSplitter; |
| 604 |
|
| 605 |
std::cout << std::setprecision(16) << std::endl; |
| 606 |
int nmeshes = 29; // 60; |
| 607 |
double zscale = 2; |
| 608 |
|
| 609 |
for (int i = 1 /* 0 */; i < nmeshes; ++i) |
| 610 |
{ |
| 611 |
if (commRank == 0) |
| 612 |
{ |
| 613 |
std::cout << "mesh " << i + 1 << " / " << nmeshes << std::endl; |
| 614 |
} |
| 615 |
mesh::impl::MeshSpec spec, spec2; |
| 616 |
spec.numelX = 5; |
| 617 |
spec.numelY = 5; |
| 618 |
spec.xmin = -0.75; //-1; |
| 619 |
spec.xmax = 0.75; // 1; |
| 620 |
spec.ymin = -0.75; //-1; |
| 621 |
spec.ymax = 0.75; // 1; |
| 622 |
|
| 623 |
spec2.numelX = 5 + i; |
| 624 |
spec2.numelY = 5 + i; |
| 625 |
spec2.xmin = -0.75; //-1; |
| 626 |
spec2.xmax = 0.75; // 1; |
| 627 |
spec2.ymin = -0.75; //-1; |
| 628 |
spec2.ymax = 0.75; // 1; |
| 629 |
|
| 630 |
auto func = [&](const utils::Point& pt) { |
| 631 |
double x = pt.x; |
| 632 |
double y = pt.y; |
| 633 |
|
| 634 |
double xprime = x * std::sqrt(std::max(1 - y * y / 2, 0.0)); |
| 635 |
double yprime = y * std::sqrt(std::max(1 - x * x / 2, 0.0)); |
| 636 |
double zprime = zscale * std::sqrt(std::max(1 - x * x - y * y, 0.0)); |
| 637 |
utils::Point pt2(xprime, yprime, zprime); |
| 638 |
return pt2; |
| 639 |
}; |
| 640 |
|
| 641 |
std::shared_ptr<mesh::Mesh> mesh1, mesh2; |
| 642 |
|
| 643 |
// std::cout << "creating mesh1" << std::endl; |
| 644 |
if (commSize == 1 || commSplitter.get_color() == 0) |
| 645 |
mesh1 = create_mesh(spec, func, commSplitter.get_comm(), true); |
| 646 |
|
| 647 |
// std::cout << "\ncreating mesh2" << std::endl; |
| 648 |
if (commSize == 1 || commSplitter.get_color() == 0) |
| 649 |
mesh2 = create_mesh(spec2, func, commSplitter.get_comm(), true); |
| 650 |
|
| 651 |
// print_vert_edges("mesh1_initial", mesh1); |
| 652 |
// print_vert_edges("mesh2_initial", mesh2); |
| 653 |
|
| 654 |
double eps = 1e-12; |
| 655 |
MiddleGridOpts opts; |
| 656 |
opts.normalProjectionOpts.classifierTolerances = impl::PointClassifierNormalWrapperTolerances(eps); |
| 657 |
opts.normalProjectionOpts.edgeTracerTolerances = impl::EdgeTracerTolerances(eps); |
| 658 |
auto interface = application_interface_factory(ApplicationInterfaceType::Parallel, mesh1, mesh2, |
| 659 |
MPI_COMM_WORLD, nullptr, ParallelSearchOpts(), |
| 660 |
VolumeSnapOpts(), |
| 661 |
BoundarySnapAndQualityImprovementOpts(), |
| 662 |
opts); |
| 663 |
|
| 664 |
interface->create_middle_grid(); |
| 665 |
|
| 666 |
if (mesh1) |
| 667 |
{ |
| 668 |
auto middleMesh1 = interface->get_middle_grid_for_mesh1(); |
| 669 |
auto mesh1Class = interface->get_mesh1_classification(); |
| 670 |
auto mesh1InverseClassification = interface->compute_mesh1_inverse_classification(); |
| 671 |
EXPECT_GE(middleMesh1->get_elements().size(), mesh1->get_elements().size()); |
| 672 |
test_util::test_every_element_classified(middleMesh1, mesh1Class); |
| 673 |
test_util::test_area_per_element(mesh1, mesh1InverseClassification); |
| 674 |
} |
| 675 |
|
| 676 |
if (mesh2) |
| 677 |
{ |
| 678 |
auto middleMesh2 = interface->get_middle_grid_for_mesh2(); |
| 679 |
auto mesh2Class = interface->get_mesh2_classification(); |
| 680 |
test_util::test_every_element_classified(middleMesh2, mesh2Class); |
| 681 |
} |
| 682 |
} |
| 683 |
} |
| 684 |
|
| 685 |
#ifdef STK_BUILT_FOR_SIERRA |
| 686 |
|
| 687 |
TEST(Interface, EllipsoidFromCADNewQuad) |
| 688 |
{ |
| 689 |
// project coordinates onto an ellipsoid |
| 690 |
int commSize = comm_size(MPI_COMM_WORLD); |
| 691 |
int commRank = comm_rank(MPI_COMM_WORLD); |
| 692 |
if (commSize > 4) |
| 693 |
GTEST_SKIP(); |
| 694 |
|
| 695 |
CommSplitter commSplitter; |
| 696 |
|
| 697 |
|
| 698 |
std::cout << std::setprecision(16) << std::endl; |
| 699 |
std::string meshPath = "./"; |
| 700 |
std::vector<std::string> fnames = {//"half_ellipsoid_2_0.5_quad.g", |
| 701 |
"half_ellipsoid_2_0.4_quad.g", "half_ellipsoid_2_0.3_quad.g", |
| 702 |
"half_ellipsoid_2_0.2_quad.g", "half_ellipsoid_2_0.1_quad.g", |
| 703 |
"half_ellipsoid_2_0.04_quad.g"}; |
| 704 |
int nmeshes = fnames.size(); |
| 705 |
|
| 706 |
for (int i = 1 /* 1 */; i < nmeshes; ++i) |
| 707 |
{ |
| 708 |
if (commRank == 0) |
| 709 |
{ |
| 710 |
std::cout << "mesh " << i << " / " << nmeshes << std::endl; |
| 711 |
} |
| 712 |
std::shared_ptr<mesh::Mesh> mesh1, mesh2; |
| 713 |
|
| 714 |
if (commSize == 1 || commSplitter.get_color() == 0) |
| 715 |
{ |
| 716 |
stk_interface::StkMeshCreator creator1(meshPath + fnames[0], "RIB", commSplitter.get_comm()); |
| 717 |
mesh1 = creator1.create_mesh_from_part("block_1").mesh; |
| 718 |
} |
| 719 |
|
| 720 |
if (commSize == 1 || commSplitter.get_color() == 1) |
| 721 |
{ |
| 722 |
stk_interface::StkMeshCreator creator2(meshPath + fnames[i], "RIB", commSplitter.get_comm()); |
| 723 |
mesh2 = creator2.create_mesh_from_part("block_1").mesh; |
| 724 |
} |
| 725 |
|
| 726 |
|
| 727 |
// print_vert_edges("mesh1_initial", mesh1); |
| 728 |
// print_vert_edges("mesh2_initial", mesh2); |
| 729 |
|
| 730 |
double eps = 1e-12; |
| 731 |
MiddleGridOpts opts; |
| 732 |
opts.normalProjectionOpts.classifierTolerances = impl::PointClassifierNormalWrapperTolerances(eps); |
| 733 |
opts.normalProjectionOpts.edgeTracerTolerances = impl::EdgeTracerTolerances(eps); |
| 734 |
auto interface = application_interface_factory(ApplicationInterfaceType::Parallel, mesh1, mesh2, |
| 735 |
MPI_COMM_WORLD, nullptr, ParallelSearchOpts(), |
| 736 |
VolumeSnapOpts(), |
| 737 |
BoundarySnapAndQualityImprovementOpts(), |
| 738 |
opts); |
| 739 |
|
| 740 |
interface->create_middle_grid(); |
| 741 |
|
| 742 |
if (mesh1) |
| 743 |
{ |
| 744 |
auto middleMesh1 = interface->get_middle_grid_for_mesh1(); |
| 745 |
auto mesh1Class = interface->get_mesh1_classification(); |
| 746 |
auto mesh1InverseClassification = interface->compute_mesh1_inverse_classification(); |
| 747 |
EXPECT_GE(middleMesh1->get_elements().size(), mesh1->get_elements().size()); |
| 748 |
test_util::test_every_element_classified(middleMesh1, mesh1Class); |
| 749 |
test_util::test_area_per_element(mesh1, mesh1InverseClassification); |
| 750 |
} |
| 751 |
|
| 752 |
if (mesh2) |
| 753 |
{ |
| 754 |
auto middleMesh2 = interface->get_middle_grid_for_mesh2(); |
| 755 |
auto mesh2Class = interface->get_mesh2_classification(); |
| 756 |
test_util::test_every_element_classified(middleMesh2, mesh2Class); |
| 757 |
} |
| 758 |
} |
| 759 |
} |
| 760 |
|
| 761 |
TEST(Interface, EllipsoidFromCADNewTri) |
| 762 |
{ |
| 763 |
// project coordinates onto an ellipsoid |
| 764 |
int commSize = comm_size(MPI_COMM_WORLD); |
| 765 |
int commRank = comm_rank(MPI_COMM_WORLD); |
| 766 |
if (commSize > 4) |
| 767 |
GTEST_SKIP(); |
| 768 |
|
| 769 |
CommSplitter commSplitter; |
| 770 |
|
| 771 |
|
| 772 |
std::cout << std::setprecision(16) << std::endl; |
| 773 |
std::string meshPath = "./"; |
| 774 |
std::vector<std::string> fnames = {//"half_ellipsoid_2_0.5_tri.g", |
| 775 |
"half_ellipsoid_2_0.4_tri.g", "half_ellipsoid_2_0.3_tri.g", |
| 776 |
"half_ellipsoid_2_0.2_tri.g", "half_ellipsoid_2_0.1_tri.g", |
| 777 |
"half_ellipsoid_2_0.04_tri.g"}; |
| 778 |
int nmeshes = fnames.size(); |
| 779 |
|
| 780 |
for (int i = 1 /* 1 */; i < nmeshes; ++i) |
| 781 |
{ |
| 782 |
if (commRank == 0) |
| 783 |
{ |
| 784 |
std::cout << "mesh " << i << " / " << nmeshes << std::endl; |
| 785 |
} |
| 786 |
std::shared_ptr<mesh::Mesh> mesh1, mesh2; |
| 787 |
|
| 788 |
if (commSize == 1 || commSplitter.get_color() == 0) |
| 789 |
{ |
| 790 |
stk_interface::StkMeshCreator creator1(meshPath + fnames[0], "RIB", commSplitter.get_comm()); |
| 791 |
mesh1 = creator1.create_mesh_from_part("block_1").mesh; |
| 792 |
} |
| 793 |
|
| 794 |
if (commSize == 1 || commSplitter.get_color() == 1) |
| 795 |
{ |
| 796 |
stk_interface::StkMeshCreator creator2(meshPath + fnames[i], "RIB", commSplitter.get_comm()); |
| 797 |
mesh2 = creator2.create_mesh_from_part("block_1").mesh; |
| 798 |
} |
| 799 |
|
| 800 |
|
| 801 |
// print_vert_edges("mesh1_initial", mesh1); |
| 802 |
// print_vert_edges("mesh2_initial", mesh2); |
| 803 |
|
| 804 |
double eps = 1e-12; |
| 805 |
MiddleGridOpts opts; |
| 806 |
opts.normalProjectionOpts.classifierTolerances = impl::PointClassifierNormalWrapperTolerances(eps); |
| 807 |
opts.normalProjectionOpts.edgeTracerTolerances = impl::EdgeTracerTolerances(eps); |
| 808 |
auto interface = application_interface_factory(ApplicationInterfaceType::Parallel, mesh1, mesh2, |
| 809 |
MPI_COMM_WORLD, nullptr, ParallelSearchOpts(), |
| 810 |
VolumeSnapOpts(), |
| 811 |
BoundarySnapAndQualityImprovementOpts(), |
| 812 |
opts); |
| 813 |
|
| 814 |
interface->create_middle_grid(); |
| 815 |
|
| 816 |
if (mesh1) |
| 817 |
{ |
| 818 |
auto middleMesh1 = interface->get_middle_grid_for_mesh1(); |
| 819 |
auto mesh1Class = interface->get_mesh1_classification(); |
| 820 |
auto mesh1InverseClassification = interface->compute_mesh1_inverse_classification(); |
| 821 |
EXPECT_GE(middleMesh1->get_elements().size(), mesh1->get_elements().size()); |
| 822 |
test_util::test_every_element_classified(middleMesh1, mesh1Class); |
| 823 |
test_util::test_area_per_element(mesh1, mesh1InverseClassification); |
| 824 |
} |
| 825 |
|
| 826 |
if (mesh2) |
| 827 |
{ |
| 828 |
auto middleMesh2 = interface->get_middle_grid_for_mesh2(); |
| 829 |
auto mesh2Class = interface->get_mesh2_classification(); |
| 830 |
test_util::test_every_element_classified(middleMesh2, mesh2Class); |
| 831 |
} |
| 832 |
} |
| 833 |
} |
| 834 |
|
| 835 |
#endif |
| 836 |
|
| 837 |
TEST(Interface, AnnulusRefiningNewQuad) |
| 838 |
{ |
| 839 |
int commSize = comm_size(MPI_COMM_WORLD); |
| 840 |
int commRank = comm_rank(MPI_COMM_WORLD); |
| 841 |
if (commSize > 4) |
| 842 |
GTEST_SKIP(); |
| 843 |
|
| 844 |
std::cout << std::setprecision(16) << std::endl; |
| 845 |
int nmeshes = 20; // 20; |
| 846 |
CommSplitter commSplitter; |
| 847 |
|
| 848 |
for (int i = 1 /*1 */; i < nmeshes; ++i) |
| 849 |
{ |
| 850 |
if (commRank == 0) |
| 851 |
{ |
| 852 |
std::cout << "mesh " << i + 1 << " / " << nmeshes << std::endl; |
| 853 |
} |
| 854 |
|
| 855 |
std::shared_ptr<mesh::Mesh> mesh1, mesh2; |
| 856 |
|
| 857 |
if (commSize == 1 || commSplitter.get_color() == 0) |
| 858 |
{ |
| 859 |
mesh1 = impl::make_annulus_mesh(5, 5, 0.5, 1.5, 0, commSplitter.get_comm()); |
| 860 |
} |
| 861 |
|
| 862 |
if (commSize == 1 || commSplitter.get_color() == 1) |
| 863 |
{ |
| 864 |
mesh2 = impl::make_annulus_mesh(5 + i, 5 + i, 0.5, 1.5, 0, commSplitter.get_comm()); |
| 865 |
} |
| 866 |
|
| 867 |
double eps = 1e-12; |
| 868 |
MiddleGridOpts opts; |
| 869 |
opts.normalProjectionOpts.classifierTolerances = impl::PointClassifierNormalWrapperTolerances(eps); |
| 870 |
opts.normalProjectionOpts.edgeTracerTolerances = impl::EdgeTracerTolerances(eps); |
| 871 |
|
| 872 |
auto interface = application_interface_factory(ApplicationInterfaceType::Parallel, mesh1, mesh2, |
| 873 |
MPI_COMM_WORLD, nullptr, ParallelSearchOpts(), |
| 874 |
VolumeSnapOpts(), |
| 875 |
BoundarySnapAndQualityImprovementOpts(), |
| 876 |
opts); |
| 877 |
|
| 878 |
interface->create_middle_grid(); |
| 879 |
|
| 880 |
if (mesh1) |
| 881 |
{ |
| 882 |
auto middleMesh1 = interface->get_middle_grid_for_mesh1(); |
| 883 |
auto mesh1Class = interface->get_mesh1_classification(); |
| 884 |
auto mesh1InverseClassification = interface->compute_mesh1_inverse_classification(); |
| 885 |
EXPECT_GE(middleMesh1->get_elements().size(), mesh1->get_elements().size()); |
| 886 |
test_util::test_every_element_classified(middleMesh1, mesh1Class); |
| 887 |
test_util::test_area_per_element(mesh1, mesh1InverseClassification); |
| 888 |
} |
| 889 |
|
| 890 |
if (mesh2) |
| 891 |
{ |
| 892 |
auto middleMesh2 = interface->get_middle_grid_for_mesh2(); |
| 893 |
auto mesh2Class = interface->get_mesh2_classification(); |
| 894 |
test_util::test_every_element_classified(middleMesh2, mesh2Class); |
| 895 |
} |
| 896 |
} |
| 897 |
} |
| 898 |
|
| 899 |
TEST(Interface, AnnulusRefiningNewTri) |
| 900 |
{ |
| 901 |
int commSize = comm_size(MPI_COMM_WORLD); |
| 902 |
int commRank = comm_rank(MPI_COMM_WORLD); |
| 903 |
if (commSize > 4) |
| 904 |
GTEST_SKIP(); |
| 905 |
|
| 906 |
std::cout << std::setprecision(16) << std::endl; |
| 907 |
int nmeshes = 20; // 20; |
| 908 |
CommSplitter commSplitter; |
| 909 |
|
| 910 |
for (int i = 1 /*1 */; i < nmeshes; ++i) |
| 911 |
{ |
| 912 |
if (commRank == 0) |
| 913 |
{ |
| 914 |
std::cout << "mesh " << i + 1 << " / " << nmeshes << std::endl; |
| 915 |
} |
| 916 |
|
| 917 |
std::shared_ptr<mesh::Mesh> mesh1, mesh2; |
| 918 |
|
| 919 |
if (commSize == 1 || commSplitter.get_color() == 0) |
| 920 |
{ |
| 921 |
mesh1 = impl::make_annulus_mesh(5, 5, 0.5, 1.5, 0, commSplitter.get_comm(), true); |
| 922 |
} |
| 923 |
|
| 924 |
if (commSize == 1 || commSplitter.get_color() == 1) |
| 925 |
{ |
| 926 |
mesh2 = impl::make_annulus_mesh(5 + i, 5 + i, 0.5, 1.5, 0, commSplitter.get_comm(), true); |
| 927 |
} |
| 928 |
|
| 929 |
double eps = 1e-12; |
| 930 |
MiddleGridOpts opts; |
| 931 |
opts.normalProjectionOpts.classifierTolerances = impl::PointClassifierNormalWrapperTolerances(eps); |
| 932 |
opts.normalProjectionOpts.edgeTracerTolerances = impl::EdgeTracerTolerances(eps); |
| 933 |
|
| 934 |
auto interface = application_interface_factory(ApplicationInterfaceType::Parallel, mesh1, mesh2, |
| 935 |
MPI_COMM_WORLD, nullptr, ParallelSearchOpts(), |
| 936 |
VolumeSnapOpts(), |
| 937 |
BoundarySnapAndQualityImprovementOpts(), |
| 938 |
opts); |
| 939 |
|
| 940 |
interface->create_middle_grid(); |
| 941 |
|
| 942 |
if (mesh1) |
| 943 |
{ |
| 944 |
auto middleMesh1 = interface->get_middle_grid_for_mesh1(); |
| 945 |
auto mesh1Class = interface->get_mesh1_classification(); |
| 946 |
auto mesh1InverseClassification = interface->compute_mesh1_inverse_classification(); |
| 947 |
EXPECT_GE(middleMesh1->get_elements().size(), mesh1->get_elements().size()); |
| 948 |
test_util::test_every_element_classified(middleMesh1, mesh1Class); |
| 949 |
test_util::test_area_per_element(mesh1, mesh1InverseClassification); |
| 950 |
} |
| 951 |
|
| 952 |
if (mesh2) |
| 953 |
{ |
| 954 |
auto middleMesh2 = interface->get_middle_grid_for_mesh2(); |
| 955 |
auto mesh2Class = interface->get_mesh2_classification(); |
| 956 |
test_util::test_every_element_classified(middleMesh2, mesh2Class); |
| 957 |
} |
| 958 |
} |
| 959 |
} |
| 960 |
|
| 961 |
|
| 962 |
} // namespace middle_mesh |
| 963 |
} // namespace stk |
| 964 |
|
| 965 |
#endif |