Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F80820793
test_configuration.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, Sep 2, 18:31
Size
3 KB
Mime Type
text/x-c
Expires
Wed, Sep 4, 18:31 (2 d)
Engine
blob
Format
Raw Data
Handle
20444696
Attached To
rSPECMICP SpecMiCP / ReactMiCP
test_configuration.cpp
View Options
#include <catch.hpp>
#include "dfpm/meshes/mesh1d.hpp"
#include "dfpm/io/configuration.hpp"
#include "specmicp_common/io/safe_config.hpp"
TEST_CASE("Configuration", "[meshes],[io],[configuration]") {
SECTION("Uniform mesh")
{
const char * conf_str =
R"(
mesh:
type: uniform_mesh
uniform_mesh:
dx: 1.0
section: 2.0
nb_nodes: 50
)";
auto conf = specmicp::io::YAMLConfigFile::load_from_string(conf_str);
auto the_mesh = specmicp::io::configure_mesh(conf.get_section("mesh"));
REQUIRE(the_mesh->nb_nodes() == 50);
CHECK(the_mesh->get_dx(0) == 1.0);
CHECK(the_mesh->get_position(0) == 0.0);
CHECK(the_mesh->get_position(1) == 1.0);
CHECK(the_mesh->get_position(49) == 49.0);
CHECK(the_mesh->get_face_area(0) == 2.0);
}
SECTION("Ramp mesh") {
const char * conf_str =
R"(
mesh:
type: ramp_mesh
ramp_mesh:
min_dx: 1.0
max_dx: 5.0
section: 2.0
length_ramp: 10
length_plateau: 50
)";
auto conf = specmicp::io::YAMLConfigFile::load_from_string(conf_str);
auto the_mesh = specmicp::io::configure_mesh(conf.get_section("mesh"));
REQUIRE(the_mesh->get_dx(0) == 1.0);
REQUIRE(the_mesh->get_dx(the_mesh->nb_nodes()-2) == 5.0);
}
SECTION("Uniform axisymmetric mesh") {
const char * conf_str =
R"(
mesh:
type: uniform_axisymmetric
uniform_axisymmetric:
radius: 100.0
nb_nodes: 10
height: 3.0
)";
auto conf = specmicp::io::YAMLConfigFile::load_from_string(conf_str);
auto the_mesh = specmicp::io::configure_mesh(conf.get_section("mesh"));
REQUIRE(the_mesh->nb_nodes() == 10);
CHECK(the_mesh->get_dx(0) == Approx(100.0/9.0));
CHECK(the_mesh->get_position(0) == 100.0);
CHECK(the_mesh->get_position(9) == Approx(0.0));
double sum = 0.0;
for (auto e: the_mesh->range_elements())
{
sum += the_mesh->get_volume_element(e);
}
CHECK(sum == Approx(M_PI*std::pow(100.0, 2)*3.0));
}
SECTION("Custom node mesh") {
const char * conf_str =
R"(
mesh:
type: custom_nodes
custom_nodes:
coordinates: [0.0, 0.1, 0.3, 0.5, 1.0, 1.3, 1.4, 1.5]
section: 2.0
)";
auto conf = specmicp::io::YAMLConfigFile::load_from_string(conf_str);
auto the_mesh = specmicp::io::configure_mesh(conf.get_section("mesh"));
REQUIRE(the_mesh->nb_nodes() == 8);
REQUIRE(the_mesh->nb_elements() == 7);
CHECK(the_mesh->get_dx(0) == Approx(0.1));
CHECK(the_mesh->get_dx(1) == Approx(0.2));
CHECK(the_mesh->get_dx(3) == Approx(0.5));
CHECK(the_mesh->get_position(1) == 0.1);
CHECK(the_mesh->get_position(2) == 0.3);
CHECK(the_mesh->get_position(7) == 1.5);
CHECK(the_mesh->get_volume_element(0) == Approx(0.2));
CHECK(the_mesh->get_volume_element(1) == Approx(0.4));
}
}
Event Timeline
Log In to Comment