Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F101005164
boundary_conditions.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
Tue, Feb 4, 17:55
Size
5 KB
Mime Type
text/x-c
Expires
Thu, Feb 6, 17:55 (2 d)
Engine
blob
Format
Raw Data
Handle
24072453
Attached To
rSPECMICP SpecMiCP / ReactMiCP
boundary_conditions.cpp
View Options
/* =============================================================================
Copyright (c) 2014 - 2016
F. Georget <fabieng@princeton.edu> Princeton University
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 "specmicp/adimensional/adimensional_system_structs.hpp"
#include "utils/cached_vector.hpp"
#include "utils/compat.hpp"
namespace specmicp {
namespace reactmicp {
namespace systems {
namespace unsaturated {
enum class NodeType {
Normal,
FixedNode,
GasNode
};
struct BoundaryConditions::BoundaryConditionsImpl
{
BoundaryConditionsImpl(uindex_t nb_nodes):
m_types(nb_nodes, NodeType::Normal),
m_constraints(nb_nodes, "default", AdimensionalSystemConstraints())
{}
std::vector<NodeType> m_types;
utils::NameCachedVector<AdimensionalSystemConstraints> m_constraints;
};
//BoundaryConditions::BoundaryConditions():
// m_impl(nullptr)
//{}
BoundaryConditions::BoundaryConditions(uindex_t nb_nodes):
m_impl(utils::make_pimpl<BoundaryConditionsImpl>(nb_nodes))
{}
BoundaryConditions::~BoundaryConditions() = default;
void BoundaryConditions::add_gas_node(uindex_t node) {
m_impl->m_types[node] = NodeType::GasNode;
}
void BoundaryConditions::add_gas_nodes(const std::vector<uindex_t>& nodes) {
for (auto node: nodes)
add_gas_node(node);
}
void BoundaryConditions::add_fixed_node(uindex_t node) {
m_impl->m_types[node] = NodeType::FixedNode;
}
void BoundaryConditions::add_fixed_nodes(const std::vector<uindex_t>& nodes) {
for (auto node: nodes)
add_fixed_node(node);
}
bool BoundaryConditions::is_gas_node(uindex_t node) const {
return (m_impl->m_types[node] == NodeType::GasNode);
}
bool BoundaryConditions::is_fixed_node(uindex_t node) const {
return (m_impl->m_types[node] == NodeType::FixedNode);
}
bool BoundaryConditions::is_normal_node(uindex_t node) const {
return (m_impl->m_types[node] == NodeType::Normal);
}
bool BoundaryConditions::has_constraint(const std::string &name) const {
return m_impl->m_constraints.has_value(name);
}
const AdimensionalSystemConstraints&
BoundaryConditions::get_constraint(uindex_t node) const {
return m_impl->m_constraints[node];
}
AdimensionalSystemConstraints&
BoundaryConditions::get_constraint(uindex_t node) {
return m_impl->m_constraints[node];
}
const AdimensionalSystemConstraints&
BoundaryConditions::get_constraint(const std::string& name) const {
return m_impl->m_constraints.get(name);
}
AdimensionalSystemConstraints&
BoundaryConditions::get_constraint(const std::string& name) {
return m_impl->m_constraints.get(name);
}
AdimensionalSystemConstraints& BoundaryConditions::fork_constraint(
uindex_t node,
const std::string& name
) {
return m_impl->m_constraints.fork(node, name);
}
AdimensionalSystemConstraints& BoundaryConditions::fork_constraint(
const std::string& old_name,
const std::string& new_name
) {
m_impl->m_constraints.fork(old_name, new_name);
return m_impl->m_constraints.get(new_name);
}
AdimensionalSystemConstraints& BoundaryConditions::add_constraint(
const std::string& name
) {
m_impl->m_constraints.emplace_back_cache(name);
return m_impl->m_constraints.get(name);
}
void BoundaryConditions::set_constraint(uindex_t node, const std::string& name) {
return m_impl->m_constraints.set(node, name);
}
std::vector<index_t> BoundaryConditions::get_fixed_nodes() {
std::vector<index_t> fixed_nodes;
fixed_nodes.reserve(5);
for (auto it=m_impl->m_types.cbegin(); it!=m_impl->m_types.cend(); ++it) {
if(*it == NodeType::FixedNode) {
fixed_nodes.push_back(it - m_impl->m_types.cbegin());
}
}
return fixed_nodes;
}
std::vector<index_t> BoundaryConditions::get_gas_nodes() {
std::vector<index_t> gas_nodes;
gas_nodes.reserve(5);
for (auto it=m_impl->m_types.cbegin(); it!=m_impl->m_types.cend(); ++it) {
if(*it == NodeType::GasNode) {
gas_nodes.push_back(it - m_impl->m_types.cbegin());
}
}
return gas_nodes;
}
} //end namespace unsaturated
} //end namespace systems
} //end namespace reactmicp
} //end namespace specmicp
Event Timeline
Log In to Comment