PetIBM 0.5.4
Toolbox and applications of the immersed-boundary method for distributed-memory architectures
cartesianmesh3d_dirichlet.cpp
Go to the documentation of this file.
1
8#include <petsc.h>
9
10#include <gtest/gtest.h>
11#include <yaml-cpp/yaml.h>
12
13#include <petibm/mesh.h>
14
15using namespace petibm;
16
17class CartesianMeshTest3D : public ::testing::Test
18{
19protected:
20 CartesianMeshTest3D(){};
21
22 virtual ~CartesianMeshTest3D(){};
23
24 virtual void SetUp()
25 {
26 using namespace YAML;
27
28 Node config;
29
30 config["mesh"].push_back(Node(NodeType::Map));
31 config["mesh"][0]["direction"] = "x";
32 config["mesh"][1]["direction"] = "y";
33 config["mesh"][2]["direction"] = "z";
34 for (unsigned int i = 0; i < 3; ++i)
35 {
36 config["mesh"][i]["start"] = "0.1";
37 config["mesh"][i]["subDomains"].push_back(Node(NodeType::Map));
38 config["mesh"][i]["subDomains"][0]["end"] = 1.1;
39 config["mesh"][i]["subDomains"][0]["cells"] = 10;
40 config["mesh"][i]["subDomains"][0]["stretchRatio"] = 1.0;
41 }
42
43 config["flow"] = YAML::Node(NodeType::Map);
44 config["flow"]["boundaryConditions"].push_back(Node(NodeType::Map));
45 config["flow"]["boundaryConditions"][0]["location"] = "xMinus";
46 config["flow"]["boundaryConditions"][1]["location"] = "xPlus";
47 config["flow"]["boundaryConditions"][2]["location"] = "yMinus";
48 config["flow"]["boundaryConditions"][3]["location"] = "yPlus";
49 config["flow"]["boundaryConditions"][4]["location"] = "zMinus";
50 config["flow"]["boundaryConditions"][5]["location"] = "zPlus";
51
52 for (unsigned int i = 0; i < 4; ++i)
53 {
54 config["flow"]["boundaryConditions"][i]["u"][0] = "DIRICHLET";
55 config["flow"]["boundaryConditions"][i]["u"][1] = 0.0;
56 config["flow"]["boundaryConditions"][i]["v"][0] = "DIRICHLET";
57 config["flow"]["boundaryConditions"][i]["v"][1] = 0.0;
58 config["flow"]["boundaryConditions"][i]["w"][0] = "DIRICHLET";
59 config["flow"]["boundaryConditions"][i]["w"][1] = 0.0;
60 }
61 config["flow"]["boundaryConditions"][3]["u"][1] = 1.0;
62
63 for (unsigned int i = 4; i < 6; ++i)
64 {
65 config["flow"]["boundaryConditions"][i]["u"][0] = "PERIODIC";
66 config["flow"]["boundaryConditions"][i]["u"][1] = 0.0;
67 config["flow"]["boundaryConditions"][i]["v"][0] = "PERIODIC";
68 config["flow"]["boundaryConditions"][i]["v"][1] = 0.0;
69 config["flow"]["boundaryConditions"][i]["w"][0] = "PERIODIC";
70 config["flow"]["boundaryConditions"][i]["w"][1] = 0.0;
71 }
72
73 petibm::mesh::createMesh(PETSC_COMM_WORLD, config, mesh);
74 };
75
76 virtual void TearDown(){};
77
78 type::Mesh mesh;
79}; // CartesianMeshTest
80
81TEST_F(CartesianMeshTest3D, init3D)
82{
83 // check dimension
84 ASSERT_EQ(3, mesh->dim);
85 // check domain limits
86 for (unsigned int d = 0; d < 3; d++)
87 {
88 ASSERT_EQ(0.1, mesh->min[d]);
89 ASSERT_EQ(1.1, mesh->max[d]);
90 }
91 // check number of points for each field
92 std::vector<PetscReal> n_exp(3);
93 // for x-velocity
94 n_exp = {9, 10, 10};
95 for (unsigned int d = 0; d < 3; d++) ASSERT_EQ(n_exp[d], mesh->n[0][d]);
96 // for y-velocity
97 n_exp = {10, 9, 10};
98 for (unsigned int d = 0; d < 3; d++) ASSERT_EQ(n_exp[d], mesh->n[1][d]);
99 // for z-velocity
100 n_exp = {10, 10, 10};
101 for (unsigned int d = 0; d < 3; d++) ASSERT_EQ(n_exp[d], mesh->n[2][d]);
102 // for pressure
103 n_exp = {10, 10, 10};
104 for (unsigned int d = 0; d < 3; d++) ASSERT_EQ(n_exp[d], mesh->n[3][d]);
105 // for vertices
106 n_exp = {11, 11, 11};
107 for (unsigned int d = 0; d < 3; d++) ASSERT_EQ(n_exp[d], mesh->n[4][d]);
108}
TEST_F(CartesianMeshTest3D, init3D)
std::shared_ptr< mesh::MeshBase > Mesh
Type definition of Mesh.
Definition: mesh.h:348
PetscErrorCode createMesh(const MPI_Comm &comm, const YAML::Node &node, type::Mesh &mesh)
Factory function for creating a Mesh object.
Definition: mesh.cpp:86
Prototype of mesh::MeshBase, type::Mesh, and factory function.
Definition: parser.cpp:45
A toolbox for building flow solvers.
Definition: bodypack.h:52