| 1 |
#ifndef TEST_MESHES_H |
| 2 |
#define TEST_MESHES_H |
| 3 |
|
| 4 |
#include "stk_middle_mesh/create_mesh.hpp" |
| 5 |
|
| 6 |
namespace stk { |
| 7 |
namespace middle_mesh { |
| 8 |
namespace impl { |
| 9 |
|
| 10 |
extern const double PI; |
| 11 |
|
| 12 |
// makes a mesh where the x,y coordinates form an annulus |
| 13 |
// dtheta: theta offset applied to all theta values except those |
| 14 |
// at theta = 0 (or 2pi) |
| 15 |
// func2: is a function z = f(x, y) that determines the z coordinate |
| 16 |
template <typename T> |
| 17 |
std::shared_ptr<mesh::Mesh> make_annulus_mesh(const int nelemR, const int nelemTheta, const double rIn, |
| 18 |
const double rOut, double dtheta, MPI_Comm comm, bool createTriangles, |
| 19 |
T func2) |
| 20 |
{ |
| 21 |
assert(rIn > 0); |
| 22 |
assert(rOut > rIn); |
| 23 |
|
| 24 |
mesh::impl::MeshSpec spec; |
| 25 |
spec.numelX = nelemR; |
| 26 |
spec.numelY = nelemTheta; |
| 27 |
spec.xmin = rIn; |
| 28 |
spec.xmax = rOut; |
| 29 |
spec.ymin = 0; |
| 30 |
spec.ymax = 2 * PI; |
| 31 |
spec.yPeriodic = true; |
| 32 |
|
| 33 |
auto func = [&](const utils::Point& pt) { |
| 34 |
// interpret x and y as r and theta |
| 35 |
double r = pt.x; |
| 36 |
double theta = pt.y; |
| 37 |
if (std::fmod(theta, 2 * PI) > 1e-12) |
| 38 |
theta += dtheta; |
| 39 |
|
| 40 |
double x = r * std::cos(theta); |
| 41 |
double y = r * std::sin(theta); |
| 42 |
double z = func2(x, y); |
| 43 |
utils::Point pt2(x, y, z); |
| 44 |
return pt2; |
| 45 |
}; |
| 46 |
|
| 47 |
return mesh::impl::create_mesh(spec, func, comm, createTriangles); |
| 48 |
} |
| 49 |
|
| 50 |
std::shared_ptr<mesh::Mesh> make_annulus_mesh(const int elemR, const int nelemTheta, const double rIn, |
| 51 |
const double rOut, double dtheta, MPI_Comm comm = MPI_COMM_WORLD, bool createTriangles=false); |
| 52 |
|
| 53 |
} // namespace impl |
| 54 |
} // namespace middle_mesh |
| 55 |
} // namespace stk |
| 56 |
#endif |