Page MenuHomec4science

boundary_conditions.cpp
No OneTemporary

File Metadata

Created
Sun, Jun 30, 05:47

boundary_conditions.cpp

/* =============================================================================
Copyright (c) 2014-2017 F. Georget <fabieng@princeton.edu> Princeton University
Copyright (c) 2017 F. Georget <fabien.georget@epfl.ch> EPFL
All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. *
============================================================================= */
#include "boundary_conditions.hpp"
#include "variables.hpp"
#include "dfpm/meshes/mesh1d.hpp"
#include "specmicp_database/database.hpp"
#include "dof_numbering.hpp"
#include "specmicp_common/cached_vector.hpp"
#include "specmicp/adimensional/adimensional_system_structs.hpp"
namespace specmicp {
namespace reactmicp {
namespace systems {
namespace chloride {
// =========== Implementation interface ===================
struct BoundaryConditions::BoundaryConditionsImpl
{
BoundaryConditionsImpl(mesh::Mesh1DPtr amesh, database::RawDatabasePtr adatabase):
m_mesh(amesh),
m_database(adatabase),
m_dof_n(adatabase->nb_component())
{}
std::vector<index_t> get_fixed_dofs();
void fix_node(index_t node); // only fix the values, don't set them
// variables must still be correctly initialized
void fix_all_potentials();
void fix_concentrations_node(index_t node);
void fix_potential_node(index_t node);
mesh::Mesh1DPtr m_mesh;
database::RawDatabasePtr m_database;
DofNumbering m_dof_n;
std::vector<index_t> m_fixed_dofs;
std::vector<index_t> m_node_fixed_chemistry;
};
// ===================== Interface ========================
BoundaryConditions::BoundaryConditions(mesh::Mesh1DPtr amesh, database::RawDatabasePtr adatabase):
AdimReactMiCPConstraints(amesh->nb_nodes()),
m_impl(utils::make_pimpl<BoundaryConditionsImpl>(amesh, adatabase))
{
}
BoundaryConditions::~BoundaryConditions()
{
}
std::vector<index_t> BoundaryConditions::get_fixed_dofs()
{
return m_impl->get_fixed_dofs();
}
void BoundaryConditions::fix_node(index_t node)
{
m_impl->fix_node(node);
}
void BoundaryConditions::fix_concentrations_node(index_t node)
{
m_impl->fix_concentrations_node(node);
}
void BoundaryConditions::fix_potential_node(index_t node)
{
m_impl->fix_potential_node(node);
}
void BoundaryConditions::fix_all_potentials()
{
m_impl->fix_all_potentials();
}
// ================== Implementation ======================
std::vector<index_t> BoundaryConditions::BoundaryConditionsImpl::get_fixed_dofs()
{
return m_fixed_dofs;
}
void BoundaryConditions::BoundaryConditionsImpl::fix_node(index_t node)
{
m_fixed_dofs.reserve(m_fixed_dofs.size() + m_database->nb_aqueous_components() + 1);
for (index_t i: m_database->range_aqueous_component())
{
m_fixed_dofs.push_back(m_dof_n.dof_component(node, i));
}
m_fixed_dofs.push_back(m_dof_n.dof_psi(node));
}
void BoundaryConditions::BoundaryConditionsImpl::fix_concentrations_node(index_t node)
{
m_fixed_dofs.reserve(m_fixed_dofs.size() + m_database->nb_aqueous_components());
for (index_t i: m_database->range_aqueous_component())
{
m_fixed_dofs.push_back(m_dof_n.dof_component(node, i));
}
}
void BoundaryConditions::BoundaryConditionsImpl::fix_potential_node(index_t node)
{
m_fixed_dofs.push_back(m_dof_n.dof_psi(node));
}
void BoundaryConditions::BoundaryConditionsImpl::fix_all_potentials()
{
for (index_t node: m_mesh->range_nodes())
{
m_fixed_dofs.push_back(m_dof_n.dof_psi(node));
}
}
} // namespace chloride
} // namespace systems
} // namespace reactmicp
} // namespace specmicp

Event Timeline