Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91209218
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
Sat, Nov 9, 00:09
Size
12 KB
Mime Type
text/x-c++
Expires
Mon, Nov 11, 00:09 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
22220712
Attached To
rSPECMICP SpecMiCP / ReactMiCP
variables.hpp
View Options
/* =============================================================================
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. *
============================================================================= */
#ifndef REACTMICP_CHLORIDE_VARIABLES_HPP
#define REACTMICP_CHLORIDE_VARIABLES_HPP
#include "specmicp_common/types.hpp"
#include "reactmicp/solver/staggers_base/variables_base.hpp"
#include "specmicp_database/database_holder.hpp"
#include "specmicp/adimensional/adimensional_system_solution.hpp"
#include "specmicp/adimensional/adimensional_system_solution_extractor.hpp"
#include "dfpm/meshes/mesh1d.hpp"
#include "dof_numbering.hpp"
#include <functional>
namespace
specmicp
{
namespace
reactmicp
{
namespace
systems
{
//! \namespace specmicp::reactmicp::systems::chloride
//! \brief The chloride system
//!
//! A system to describe saturated reactive advection diffusion with
//! species-dependent diffusion coefficients
namespace
chloride
{
class
ChlorideVariablesInit
;
//! \brief The variables for the chloride system
//!
//! Shared between the staggers
class
SPECMICP_DLL_PUBLIC
ChlorideVariables:
public
solver
::
VariablesBase
,
public
database
::
DatabaseHolder
,
public
units
::
UnitBaseClass
{
public
:
ChlorideVariables
(
RawDatabasePtr
adata
,
mesh
::
Mesh1DPtr
amesh
,
const
units
::
UnitsSet
&
units
);
// interface
// =========
void
reset_main_variables
()
override
;
// numbering
// =========
//! \brief The total number of degree of freedom per node
index_t
ndof
()
const
{
return
m_numbering
.
ndof
();
}
//! \brief The total number of degree of freedom
index_t
tot_dof
()
const
{
return
ndof
()
*
m_mesh
->
nb_nodes
();
}
//! \brief The number of degree of freedom per element
index_t
tot_edof
()
const
{
return
m_mesh
->
nen
*
ndof
();
}
//! \brief The number of degree of freedom per element
index_t
edof
()
const
{
return
m_numbering
.
edof
();
}
//! \brief The nodal degree of freedom for a total concentration
index_t
ndof_component
(
index_t
component
)
const
{
return
m_numbering
.
nodal_dof_component
(
component
);
}
//! \brief The nodal degree of freedom of the potential
index_t
ndof_potential
()
const
{
return
m_numbering
.
nodal_dof_psi
();
}
//! \brief The element degree of freedom for a total concentration
index_t
edof_component
(
index_t
enode
,
index_t
component
)
const
{
return
m_numbering
.
element_dof_component
(
enode
,
component
);
}
//! \brief The nodal degree of freedom of the potential
index_t
edof_potential
(
index_t
enode
)
const
{
return
m_numbering
.
element_dof_psi
(
enode
);
}
//! \brief The degree of freedom for a total concentration
index_t
dof_component
(
index_t
node
,
index_t
component
)
const
{
return
m_numbering
.
dof_component
(
node
,
component
);
}
//! \brief The degree of freedom for the potential
index_t
dof_potential
(
index_t
node
)
const
{
return
m_numbering
.
dof_psi
(
node
);
}
//! \brief Return dof from nodal dof
index_t
ndof_to_dof
(
index_t
node
,
index_t
nod_dof
)
{
return
nod_dof
+
node
*
ndof
();
}
//! \brief Return element dof from nodal dof
index_t
ndof_to_edof
(
index_t
enode
,
index_t
nod_dof
)
{
return
nod_dof
+
enode
*
ndof
();
}
mesh
::
Mesh1DPtr
get_mesh
()
{
return
m_mesh
;
}
// Primary
// =======
//! \brief The vector of main variables
Vector
&
main_variables
()
{
return
m_main_variables
;
}
//! \brief Return a total mobile concentration
scalar_t
total_mobile_concentration
(
index_t
node
,
index_t
component
)
const
{
return
m_main_variables
(
dof_component
(
node
,
component
));
}
//! \brief Return the potential
scalar_t
potential
(
index_t
node
)
const
{
return
m_main_variables
(
dof_potential
(
node
));
}
//! \brief The predictors of the main variables
Vector
&
predictors
()
{
return
m_predictors
;
}
//! \brief The rates of the main variables
Vector
&
velocities
()
{
return
m_velocities
;
}
//! \brief Return the vector of total immobile concentrations
Vector
&
total_immobile_concentration
()
{
return
m_total_immobile_concs
;
}
scalar_t
total_immobile_concentration
(
index_t
node
,
index_t
component
)
const
{
return
m_total_immobile_concs
(
dof_component
(
node
,
component
));
}
//! \brief The fluid velocity (constant over the domain)
scalar_t
fluid_velocity
()
const
{
return
m_fluid_vel
;
}
//! \brief Return the values for the dofs of an element
Vector
get_element_dofs
(
index_t
element
,
const
Vector
&
values
)
const
;
//! \brief Return the values for the dofs of a node
Vector
get_nodal_dofs
(
index_t
node
,
const
Vector
&
values
)
const
;
// Secondary
// =========
//! \brief Return the porosities
Vector
&
porosity
()
{
return
m_porosity
;
}
//! \brief Return the porosity at 'node'
scalar_t
porosity
(
index_t
node
)
const
{
return
m_porosity
(
node
);
}
//! \brief Return the time derivative of the porosity
scalar_t
velocity_porosity
(
index_t
node
)
const
{
return
m_velocity_porosity
(
node
);
}
//! \brief Return the time derivative of the porosity
scalar_t
predictor_porosity
(
index_t
node
)
const
{
return
m_velocity_porosity
(
node
);
}
//! \brief Return the specmicp solution for 'node'
AdimensionalSystemSolution
adim_solution
(
index_t
node
)
const
{
return
m_adim_solution
[
node
];
}
//! \brief Return the specmicp solution for 'node'
AdimensionalSystemSolution
&
adim_solution
(
index_t
node
)
{
return
m_adim_solution
[
node
];
}
//! \brief Set the adimensional solution
void
set_adim_solution
(
index_t
node
,
AdimensionalSystemSolution
&&
solution
)
{
m_adim_solution
[
node
]
=
std
::
move
(
solution
);
}
//! \brief Set the adimensional solution
void
set_adim_solution
(
index_t
node
,
AdimensionalSystemSolution
&
solution
)
{
m_adim_solution
[
node
]
=
solution
;
}
//! \brief Return the inert volume fraction for 'node'
scalar_t
inert_volume_fraction
(
index_t
node
)
const
{
return
m_inert_volume_fractions
(
node
);
}
//! \brief Return the inert volume fraction for 'node'
scalar_t
&
inert_volume_fraction
(
index_t
node
)
{
return
m_inert_volume_fractions
(
node
);
}
// Tertiary
// ========
Vector
&
resistance_factor
()
{
return
m_resistance_factor
;
}
//! \brief Return the diffusion coefficient resistance factor for 'node'
scalar_t
resistance_factor
(
scalar_t
node
)
const
{
return
m_resistance_factor
(
node
);
}
//! \brief Return the intrinsic diffusion coefficient for a component
scalar_t
intrinsic_diff_coeff_component
(
index_t
i
)
const
{
return
m_intrinsic_diffusion_i
(
i
);
}
//! \brief Return the intrinsic diffusion coefficient for a secodnar aqueous species
scalar_t
intrinsic_diff_coeff_aqueous
(
index_t
j
)
const
{
return
m_intrinsic_diffusion_j
(
j
);
}
//! \brief Return the water density
scalar_t
rho_w
()
const
{
return
m_constants
.
rho_w
;
}
//! \brief Return the Faraday constant
scalar_t
faraday
()
const
{
return
m_constants
.
faraday
;
}
//! \brief Return the product R*T
scalar_t
rt
()
const
{
return
m_constants
.
rt
;
}
//! \brief Return the transport rate of 'component' at 'node'
scalar_t
transport_rate
(
index_t
node
,
index_t
component
)
const
{
return
m_transport_rates
(
dof_component
(
node
,
component
));
}
//! \brief Return the transport rate of 'dof_c'
//!
//! 'dof_c' must be a valid degree of freedom for a total concentration
scalar_t
transport_rate
(
index_t
dof_c
)
const
{
return
m_transport_rates
(
dof_c
);
}
scalar_t
&
transport_rate
(
index_t
dof_c
)
{
return
m_transport_rates
(
dof_c
);
}
Vector
&
transport_rates
()
{
return
m_transport_rates
;
}
//! \brief Return the chemistry rate of 'component' at 'node'
scalar_t
chemistry_rate
(
index_t
node
,
index_t
component
)
const
{
return
m_chemistry_rates
(
dof_component
(
node
,
component
));
}
//! \brief Return the chemistry rate of 'dof_c'
//!
//! 'dof_c' must be a valid degree of freedom for a total concentration
scalar_t
chemistry_rate
(
index_t
dof_c
)
const
{
return
m_chemistry_rates
(
dof_c
);
}
scalar_t
&
chemistry_rate
(
index_t
dof_c
)
{
return
m_chemistry_rates
(
dof_c
);
}
Vector
&
chemistry_rates
()
{
return
m_chemistry_rates
;
}
Vector
&
current
()
{
return
m_current
;
}
private
:
// data
mesh
::
Mesh1DPtr
m_mesh
;
//!< The mesh
DofNumbering
m_numbering
;
//!< Relation between database and dof numbering
// primary
Vector
m_main_variables
;
//!< The vector of main variables (ndofx1)
Vector
m_predictors
;
//!< The vector of predictors (ndofx1)
Vector
m_velocities
;
//!< The vector of velocities (nodfx1)
Vector
m_total_immobile_concs
;
//!< The total immobile concentrations (ndofx1)
Vector
m_predictor_immobile
;
//!< Predictor for the immobile concentrations (ndofx1)
Vector
m_velocity_immobile
;
//!< Velocity vector for the immobile concentration (ndofx1)
// secondary
Vector
m_porosity
;
//!< The porosity (nnpx1)
Vector
m_predictor_porosity
;
//!< Predictor for the porosity (nnpx1)
Vector
m_velocity_porosity
;
//!< Velocity for the porosity (nnpx1)
Vector
m_inert_volume_fractions
;
//!< The volume fraction of inert solid phases (nnpx1)
std
::
vector
<
AdimensionalSystemSolution
>
m_adim_solution
;
//!< The SpecMiCP solutions
Vector
m_transport_rates
;
//!< The transport rates for the coupling (ndofx1)
Vector
m_chemistry_rates
;
//!< The chemistry rates for the coupling (ndofx1)
// tertiary
Vector
m_intrinsic_diffusion_i
;
//!< Intrinsic diffusion coefficient for a component (Ncx1)
Vector
m_intrinsic_diffusion_j
;
//!< Intrinsic diffusion coefficient for a secondary aqueous species (Nrx1)
Vector
m_resistance_factor
;
//!< Diffusion coefficient resistance factor (nnpx1)
scalar_t
m_fluid_vel
{
0
};
//!< The velocity of the liquid phase
Vector
m_current
;
// !< The current
struct
ConstantBox
{
scalar_t
rho_w
{
0
};
//!< density of water (scaled)
scalar_t
faraday
{
0
};
//!< Faraday's constant (scaled)
scalar_t
rt
{
0
};
//!< R*T constant (not scaled)
ConstantBox
(
const
units
::
UnitsSet
&
tunits
);
};
ConstantBox
m_constants
;
//!< The set of constants
friend
class
ChlorideVariablesInterface
;
};
//! \brief Shared pointer the unsaturated variables
using
ChlorideVariablesPtr
=
std
::
shared_ptr
<
ChlorideVariables
>
;
//! \brief Cast from base variable
inline
ChlorideVariablesPtr
cast_from_base
(
std
::
shared_ptr
<
solver
::
VariablesBase
>
ptr
)
{
return
std
::
static_pointer_cast
<
ChlorideVariables
>
(
ptr
);
}
//! \brief Cast from base variable
inline
ChlorideVariables
*
const
cast_from_base
(
solver
::
VariablesBase
*
const
ptr
)
{
return
static_cast
<
ChlorideVariables
*
const
>
(
ptr
);
}
}
// namespace chloride
}
// namespace systems
}
// namespace reactmicp
}
// namespace specmicp
#endif
// REACTMICP_CHLORIDE_VARIABLES_HPP
Event Timeline
Log In to Comment