Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F101151208
variables.hpp
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
Thu, Feb 6, 06:04
Size
9 KB
Mime Type
text/x-c++
Expires
Sat, Feb 8, 06:04 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
24102850
Attached To
rSPECMICP SpecMiCP / ReactMiCP
variables.hpp
View Options
/* =============================================================================
Copyright (c)
2014-2017 F. Georget <fabieng@princeton.edu> Princeton University
2017-2021 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. *
============================================================================= */
#ifndef SPECMICP_REACTMICP_SINGLE_VARIABLES_HPP
#define SPECMICP_REACTMICP_SINGLE_VARIABLES_HPP
#include <vector>
#include "specmicp_common/types.hpp"
#include "reactmicp/solver/staggers_base/variables_base.hpp"
#include "specmicp_database/database_fwd.hpp"
#include "dfpm/meshes/mesh1dfwd.hpp"
namespace specmicp {
namespace reactmicp {
namespace solver {
using VariablesBasePtr = std::shared_ptr<VariablesBase>;
}
} // end namespace reactmicp
} // end namespace specmicp
namespace specmicp {
namespace reactmicp {
namespace systems {
namespace single {
//! \brief Variables for the saturated reactive transport system
//!
//! Contain all the variables that need to be shared between the staggers
class SPECMICP_DLL_PUBLIC SingleVariables: public solver::VariablesBase
{
// SingleVariablesFactory should be the class to use to inialize
// the variables correctly
friend class SingleVariablesFactory;
public:
//! \brief Constructor
SingleVariables(
mesh::Mesh1DPtr the_mesh);
//! \brief Return the mesh
mesh::Mesh1DPtr get_mesh() {return m_mesh;}
//! \brief Return the number of components
index_t nb_component() {return 1;}
//! \brief Return the number of nodes
index_t nb_nodes() {return m_is_fixed_composition.size();}
//! \brief Return true if 'node' has a fixed composition
index_t is_fixed_composition(index_t node) {return m_is_fixed_composition[node];}
// Main variables
// ==============
//! \brief Return the main variable vector
Vector& displacement() {return m_displacement;}
//! \brief Return the main variable vector at the beginning of the timestep
Vector& predictor() {return m_predictor;}
//! \brief Return the velocity of the main variables
Vector& velocity() {return m_velocity;}
//! \brief Return the rate of change of the main variables due to the transport operator
Vector& transport_rate() {return m_transport_rate;}
//! \brief Return the rate of change of the main variables due to the chemistry operator
Vector& chemistry_rate() {return m_chemistry_rate;}
// Access to main variables
// ========================
//! \brief Return the number of degree of freedom (per node) in the main variables vector
index_t ndf() {return 2;} // fluid_conc and bound_conc
//! \brief Return the offset of 'node' in the main variables vector
index_t offset_node(index_t node) {return node*ndf();}
//! \brief Return the offset of the aqueous concentration variables in the main variables vector
index_t offset_fluid_concentration() {return 0;}
//! \brief Return the offset of the aqueous concentrations variables in the main variables vector
index_t offset_fluid_concentration(index_t node) {
return offset_fluid_concentration()+offset_node(node);
}
//! \brief Return the offset of the bound concentration variables in the main variables vector
index_t offset_bound_concentration() {return 1;}
//! \brief Return the offset of the bound concentrations variables in the main variables vector
index_t offset_bound_concentration(index_t node) {
return offset_bound_concentration()+offset_node(node);
}
//! \brief Return the degree of freedom number for the fluid concentration at 'node'
index_t dof_fluid_concentration(index_t node) {
return offset_fluid_concentration(node);
}
//! \brief Return the degree of freedom number for the bound concentration at 'node'
index_t dof_bound_concentration(index_t node) {
return offset_bound_concentration(node);
}
//! \brief Return the fluid concentration at 'node' in 'var'
//!
//! 'var' is any of the main variables vector, it may be a velocity vector
scalar_t& fluid_concentration(index_t node, Vector& var) {
return var(dof_fluid_concentration(node));
}
//! \brief Return the fluid concentration at 'node' in main variables
scalar_t& fluid_concentration(index_t node) {
return m_displacement(dof_fluid_concentration(node));
}
//! \brief Return the bound concentration at 'node' in 'var'
//!
//! 'var' is any of the main variables vector, it may be a velocity vector
scalar_t& bound_concentration(index_t node, Vector& var){
return var(dof_bound_concentration(node));
}
//! \brief Return the solid concentration at 'node' in main variables
//!
//! 'var' is any of the main variables vector, it may be a velocity vector
scalar_t& bound_concentration(index_t node){
return m_displacement(dof_bound_concentration(node));
}
//! \brief Return a vector containing the total concentrations computed from the main variables
//!
//! This is to be used to restart the chemistry computation
Vector total_concentrations(index_t node);
// Chemistry variables
// ===================
//! \brief Return the chemistry variables
Vector chemistry_variables() {return m_chemistry_variables;}
// Upscaling
// =========
//! \brief Return the offset for 'node' in the upscaling variables vector
index_t offset_node_upscaling(index_t node) {return ndf_upscaling()*node;}
//! \brief Return the number fo degree of freedom (per node) for the upscaling vector
index_t ndf_upscaling() {return 5;}
//! \brief Refturn the dof for the diffusion coefficient at 'node'
index_t dof_diffusion_coefficient(index_t node) {return 0 + offset_node_upscaling(node);}
//! \brief Return the degree of freedom for the porosity at 'node'
index_t dof_porosity(index_t node) {return 1 + offset_node_upscaling(node);}
//! \brief Return the degree of freedom of the porosity velocity at 'node'
index_t dof_vel_porosity(index_t node) {return 2 + offset_node_upscaling(node);}
//! \brief Return the degree of freedom of the saturation at 'node'
index_t dof_saturation(index_t node) {return 3 + offset_node_upscaling(node);}
//! \brief Return the degree of freedom of the saturation velocity at 'node'
index_t dof_vel_saturation(index_t node) {return 4 + offset_node_upscaling(node);}
//! \brief Return the diffusion coefficient at 'node'
scalar_t& diffusion_coefficient(index_t node) {return m_upscaling(dof_diffusion_coefficient(node));}
//! \brief Return the porosity at 'node'
scalar_t& porosity(index_t node) {return m_upscaling(dof_porosity(node));}
//! \brief Return the rate of change of the porosity at 'node'
scalar_t& vel_porosity(index_t node) {return m_upscaling(dof_vel_porosity(node));}
//! \brief Return the saturation at 'node'
scalar_t& saturation(index_t node) {return m_upscaling(dof_saturation(node));}
//! \brief Return the saturation velocity at 'node'
scalar_t& vel_saturation(index_t node) {return m_upscaling(dof_vel_saturation(node));}
//! \brief Return the vector of upscaling variables
Vector& upscaling_variables() {return m_upscaling;}
//! \brief Reset the main variables
void reset_main_variables() override;
private:
// ############ //
// Attributes //
// ############ //
mesh::Mesh1DPtr m_mesh;
std::vector<bool> m_is_fixed_composition;
// Main variables
// ==============
Vector m_displacement;
Vector m_predictor;
Vector m_velocity;
Vector m_transport_rate;
Vector m_chemistry_rate;
// Chemistry variables
// ===================
Vector m_chemistry_variables;
// Upscaling
// =========
Vector m_upscaling;
};
} // namespace single
} // namespace systems
} // namespace reactmicp
} // namespace specmicp
#endif // SPECMICP_REACTMICP_SINGLE_VARIABLES_HPP
Event Timeline
Log In to Comment