PetIBM 0.5.4
Toolbox and applications of the immersed-boundary method for distributed-memory architectures
singleboundary_test.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#include <petibm/parser.h>
16
17using namespace petibm;
18
19class SingleBoundaryTest : public ::testing::Test
20{
21protected:
22 SingleBoundaryTest(){};
23
24 virtual ~SingleBoundaryTest(){};
25
26 virtual void SetUp()
27 {
28 using namespace YAML;
29
30 Node config;
31 type::Mesh mesh;
32
33 config["mesh"].push_back(Node(NodeType::Map));
34 config["mesh"][0]["direction"] = "x";
35 config["mesh"][1]["direction"] = "y";
36 config["mesh"][2]["direction"] = "z";
37 for (unsigned int i = 0; i < 3; ++i)
38 {
39 config["mesh"][i]["start"] = "0.1";
40 config["mesh"][i]["subDomains"].push_back(Node(NodeType::Map));
41 config["mesh"][i]["subDomains"][0]["end"] = 1.1;
42 config["mesh"][i]["subDomains"][0]["cells"] = 10;
43 config["mesh"][i]["subDomains"][0]["stretchRatio"] = 1.0;
44 }
45
46 config["flow"] = YAML::Node(NodeType::Map);
47 config["flow"]["boundaryConditions"].push_back(Node(NodeType::Map));
48 config["flow"]["boundaryConditions"][0]["location"] = "xMinus";
49 config["flow"]["boundaryConditions"][1]["location"] = "xPlus";
50 config["flow"]["boundaryConditions"][2]["location"] = "yMinus";
51 config["flow"]["boundaryConditions"][3]["location"] = "yPlus";
52 config["flow"]["boundaryConditions"][4]["location"] = "zMinus";
53 config["flow"]["boundaryConditions"][5]["location"] = "zPlus";
54
55 for (unsigned int i = 0; i < 4; ++i)
56 {
57 config["flow"]["boundaryConditions"][i]["u"][0] = "DIRICHLET";
58 config["flow"]["boundaryConditions"][i]["u"][1] = 0.0;
59 config["flow"]["boundaryConditions"][i]["v"][0] = "DIRICHLET";
60 config["flow"]["boundaryConditions"][i]["v"][1] = 0.0;
61 config["flow"]["boundaryConditions"][i]["w"][0] = "DIRICHLET";
62 config["flow"]["boundaryConditions"][i]["w"][1] = 0.0;
63 }
64 config["flow"]["boundaryConditions"][3]["u"][1] = 1.0;
65
66 for (unsigned int i = 4; i < 6; ++i)
67 {
68 config["flow"]["boundaryConditions"][i]["u"][0] = "PERIODIC";
69 config["flow"]["boundaryConditions"][i]["u"][1] = 0.0;
70 config["flow"]["boundaryConditions"][i]["v"][0] = "PERIODIC";
71 config["flow"]["boundaryConditions"][i]["v"][1] = 0.0;
72 config["flow"]["boundaryConditions"][i]["w"][0] = "PERIODIC";
73 config["flow"]["boundaryConditions"][i]["w"][1] = 0.0;
74 }
75
76 petibm::mesh::createMesh(PETSC_COMM_WORLD, config, mesh);
79 type::BCType::DIRICHLET, boundary);
80 };
81
82 virtual void TearDown(){};
83
84 type::SingleBoundary boundary;
85}; // SingleBoundaryTest
86
87TEST_F(SingleBoundaryTest, init)
88{
89 ASSERT_EQ(3, boundary->dim);
90 ASSERT_EQ(type::BCLoc::XMINUS, boundary->loc);
91 PetscMPIInt size;
92 MPI_Comm_size(PETSC_COMM_WORLD, &size);
93 if (size == 1) ASSERT_EQ(PETSC_TRUE, boundary->onThisProc);
94 ASSERT_EQ(type::BCType::DIRICHLET, boundary->type);
95 ASSERT_EQ(0.0, boundary->value);
96}
97
98// Run all tests
99int main(int argc, char **argv)
100{
101 PetscErrorCode ierr, status;
102
103 ::testing::InitGoogleTest(&argc, argv);
104 ierr = PetscInitialize(&argc, &argv, nullptr, nullptr); CHKERRQ(ierr);
105 status = RUN_ALL_TESTS();
106 ierr = PetscFinalize(); CHKERRQ(ierr);
107
108 return status;
109} // main
std::shared_ptr< boundary::SingleBoundaryBase > SingleBoundary
Definition of type petibm::type::SingleBoundary.
PetscErrorCode createSingleBoundary(const type::Mesh &mesh, const type::BCLoc &loc, const type::Field &field, const PetscReal &value, const type::BCType &bcType, type::SingleBoundary &singleBd)
Factory function for creating a SingleBoundary object.
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
@ DIRICHLET
Definition: type.h:97
@ XMINUS
Definition: type.h:109
Prototype of mesh::MeshBase, type::Mesh, and factory function.
Definition: parser.cpp:45
A toolbox for building flow solvers.
Definition: bodypack.h:52
Prototypes of parser functions.
Definition of the class SingleBoundaryBase.
int main(int argc, char **argv)
TEST_F(SingleBoundaryTest, init)