Page MenuHomec4science

boundary_conditions.cpp
No OneTemporary

File Metadata

Created
Fri, Nov 29, 03:20

boundary_conditions.cpp

#include "catch.hpp"
#include "reactmicp/systems/chloride/boundary_conditions.hpp"
#include "dfpm/meshes/mesh1d.hpp"
#include "specmicp_database/database.hpp"
#include "specmicp/adimensional/adimensional_system_solver_structs.hpp"
#include <vector>
#include <algorithm>
using namespace specmicp;
using namespace specmicp::reactmicp::systems::chloride;
static mesh::Mesh1DPtr get_mesh(index_t nb_nodes)
{
mesh::Uniform1DMeshGeometry amesh;
amesh.dx = 1.0;
amesh.section = 1.0;
amesh.nb_nodes = nb_nodes;
return mesh::uniform_mesh1d(amesh);
}
static specmicp::database::RawDatabasePtr get_database()
{
static database::RawDatabasePtr raw_data {nullptr};
if (raw_data == nullptr)
{
specmicp::database::Database thedatabase(TEST_CEMDATA_PATH);
thedatabase.keep_only_components({"H2O","Na[+]", "Cl[-]"});
thedatabase.remove_half_cell_reactions();
raw_data = thedatabase.get_database();
raw_data->freeze_db();
}
return raw_data;
}
TEST_CASE("Boundary Conditions", "[Transport,Chemistry]") {
SECTION ("Boundary Conditions") {
index_t nb_nodes = 10;
auto amesh = get_mesh(nb_nodes);
auto adatabase = get_database();
BoundaryConditions bcs(amesh, adatabase);
bcs.fix_concentrations_node(2);
bcs.fix_node(0);
bcs.fix_potential_node(1);
std::vector<index_t> fixed = bcs.get_fixed_dofs();
std::vector<index_t> fixed_to_check = {0, 1, 2, 5, 6, 7};
for (auto dof: fixed) {
auto ret = std::count(fixed_to_check.begin(), fixed_to_check.end(), dof);
REQUIRE(ret == 1);
}
REQUIRE(bcs.has_constraint("default"));
AdimensionalSystemConstraints& fixed_adim = bcs.fork_constraint("default", "fixed");
fixed_adim.set_fixed_saturation(0.5);
bcs.set_constraint(2, "fixed");
AdimensionalSystemConstraints& fixed_adim_check = bcs.get_constraint(2);
CHECK(fixed_adim_check.water_parameter == 0.5);
}
}

Event Timeline