Page MenuHomec4science

init_variables.cpp
No OneTemporary

File Metadata

Created
Thu, Dec 26, 13:18

init_variables.cpp

#include "init_variables.hpp"
#include "variables.hpp"
#include "dfpm/meshes/mesh1d.hpp"
#include "specmicp/adimensional/adimensional_system_solution_extractor.hpp"
namespace specmicp {
namespace reactmicp {
namespace systems {
namespace satdiff {
// SaturatedVariablesFactory::
SaturatedVariablesFactory::SaturatedVariablesFactory(
mesh::Mesh1DPtr the_mesh,
RawDatabasePtr the_database,
units::UnitsSet the_units,
const std::vector<index_t>& list_fixed_nodes,
const std::vector<AdimensionalSystemSolution>& list_initial_states,
const std::vector<int>& index_initial_state
):
m_variable(std::make_shared<SaturatedVariables>(the_mesh, the_database)),
m_database(the_database),
nb_component(the_database->nb_component),
nb_nodes(the_mesh->nb_nodes())
{
init_size();
set_fixed_nodes(list_fixed_nodes);
init_chemistry(the_units, index_initial_state, list_initial_states);
}
void SaturatedVariablesFactory::init_size()
{
index_t main_ndf = nb_nodes*nb_component;
m_variable->displacement() = Vector::Zero(main_ndf);
m_variable->chemistry_rate() = Vector::Zero(main_ndf);
m_variable->transport_rate() = Vector::Zero(main_ndf);
m_variable->predictor() = Vector::Zero(main_ndf);
m_variable->m_upscaling = Vector::Zero(m_variable->ndf_upscaling()*nb_nodes);
}
void SaturatedVariablesFactory::set_fixed_nodes(const std::vector<index_t>& list_fixed_nodes)
{
m_variable->m_is_fixed_composition = std::vector<bool>(nb_nodes, false);
for (index_t node: list_fixed_nodes)
{
m_variable->m_is_fixed_composition[node] = true;
}
}
void SaturatedVariablesFactory::init_chemistry(
units::UnitsSet the_units,
const std::vector<int>& index_initial_state,
const std::vector<AdimensionalSystemSolution>& list_initial_states)
{
m_variable->m_equilibrium_solutions.reserve(nb_nodes);
for (index_t node=0; node<nb_nodes; ++node)
{
m_variable->m_equilibrium_solutions.push_back(list_initial_states[index_initial_state[node]]);
AdimensionalSystemSolutionExtractor extractor(m_variable->m_equilibrium_solutions[node],
m_database, the_units);
scalar_t rho_w = extractor.density_water();
for (index_t component: m_database->range_component())
{
m_variable->aqueous_concentration(node, component, m_variable->displacement())
= rho_w*extractor.total_aqueous_concentration(component);
m_variable->solid_concentration(node, component, m_variable->displacement())
= extractor.total_solid_concentration(component);
}
}
}
} // end namespace satdiff
} // end namespace systems
} // end namespace reactmicp
} // end namespace specmicp

Event Timeline