Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F91391459
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
Sun, Nov 10, 16:05
Size
6 KB
Mime Type
text/x-c++
Expires
Tue, Nov 12, 16:05 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
22255865
Attached To
rSPECMICP SpecMiCP / ReactMiCP
variables.hpp
View Options
#ifndef SPECMICP_REACTMICP_SATURATED_DIFFUSION_VARIABLES_HPP
#define SPECMICP_REACTMICP_SATURATED_DIFFUSION_VARIABLES_HPP
#include "reactmicp/systems/secondary_variables/secondary.hpp"
#include "specmicp/equilibrium_data.hpp"
#include "reactmicp/meshes/mesh1d.hpp"
#include "reactmicp/systems/saturated_diffusion/transport_parameters.hpp"
namespace
specmicp
{
namespace
reactmicp
{
namespace
systems
{
namespace
siasaturated
{
//! Variables for the SIASaturatedReactiveTransportSolver
class
SIASaturatedVariables
:
public
SecondaryVariables
<
SIASaturatedVariables
>
{
public
:
SIASaturatedVariables
(
RawDatabasePtr
thedatabase
,
std
::
shared_ptr
<
mesh
::
Mesh1D
>
themesh
,
std
::
shared_ptr
<
SaturatedDiffusionTransportParameters
>
theparam
)
:
SecondaryVariables
<
SIASaturatedVariables
>
(
themesh
->
nnodes
(),
thedatabase
),
m_data
(
thedatabase
),
m_mesh
(
themesh
),
m_param
(
theparam
),
m_total_mobile_concentration
(
Vector
((
thedatabase
->
nb_component
-
1
)
*
themesh
->
nnodes
())),
m_speciation_variables
(
Matrix
(
thedatabase
->
nb_component
+
thedatabase
->
nb_mineral
,
themesh
->
nnodes
()))
{}
index_t
get_dof_total_concentration
(
index_t
node
,
index_t
component
)
const
{
specmicp_assert
(
component
>=
1
and
component
<
m_data
->
nb_component
);
specmicp_assert
(
node
>=
0
and
node
<
m_speciation_variables
.
cols
());
return
(
component
+
offset_total_component
())
+
(
m_data
->
nb_component
+
offset_total_component
())
*
node
;
}
//! Return the total mobile concentration of 'component' at 'node'
scalar_t
total_mobile_concentration
(
index_t
node
,
index_t
component
)
const
{
return
m_total_mobile_concentration
.
coeff
(
get_dof_total_concentration
(
node
,
component
));
}
//! Return a reference to the total mobile concentration of 'component' at 'node'
scalar_t
&
total_mobile_concentration
(
index_t
node
,
index_t
component
)
{
return
m_total_mobile_concentration
.
coeffRef
(
get_dof_total_concentration
(
node
,
component
));
}
Vector
&
total_mobile_concentrations
()
{
return
m_total_mobile_concentration
;
}
Eigen
::
Block
<
Vector
,
Eigen
::
Dynamic
,
1
>
total_mobile_concentrations
(
index_t
node
)
{
return
m_total_mobile_concentration
.
segment
(
node
*
(
m_data
->
nb_component
+
offset_total_component
()),
(
m_data
->
nb_component
+
offset_total_component
()));
}
//! Return the concentration of 'component' at 'node'
scalar_t
component_concentration
(
index_t
node
,
index_t
component
)
const
{
specmicp_assert
(
component
>=
1
and
component
<
m_data
->
nb_component
);
specmicp_assert
(
node
>=
0
and
node
<
m_speciation_variables
.
cols
());
return
pow10
(
m_speciation_variables
.
coeff
(
component
+
offset_component
(),
node
));
}
//! Return the concentration of 'component' at 'node'
scalar_t
log_component_concentration
(
index_t
node
,
index_t
component
)
const
{
specmicp_assert
(
component
>=
1
and
component
<
m_data
->
nb_component
);
specmicp_assert
(
node
>=
0
and
node
<
m_speciation_variables
.
cols
());
return
m_speciation_variables
.
coeff
(
component
+
offset_component
(),
node
);
}
//! Return a reference to the concentration of 'component' at 'node'
scalar_t
&
log_component_concentration
(
index_t
node
,
index_t
component
)
{
specmicp_assert
(
component
>=
1
and
component
<
m_data
->
nb_component
);
specmicp_assert
(
node
>=
0
and
node
<
m_speciation_variables
.
cols
());
return
m_speciation_variables
.
coeffRef
(
component
+
offset_component
(),
node
);
}
//! Return the number of moles of 'mineral' at 'node'
scalar_t
mineral_amount
(
index_t
node
,
index_t
mineral
)
const
{
specmicp_assert
(
mineral
>=
0
and
mineral
<
m_data
->
nb_mineral
);
specmicp_assert
(
node
>=
0
and
node
<
m_speciation_variables
.
cols
());
return
m_speciation_variables
.
coeff
(
offset_mineral
()
+
mineral
,
node
);
}
//! Return a reference to the number of moles of 'mineral' at 'node'
scalar_t
&
mineral_amount
(
index_t
node
,
index_t
mineral
)
{
specmicp_assert
(
mineral
>=
0
and
mineral
<
m_data
->
nb_mineral
);
specmicp_assert
(
node
>=
0
and
node
<
m_speciation_variables
.
cols
());
return
m_speciation_variables
.
coeffRef
(
offset_mineral
()
+
mineral
,
node
);
}
//! Reference to the speciation variables
Matrix
&
speciation_variables
()
{
return
m_speciation_variables
;
}
//! Eigen Expression to the speciation variables
Matrix
::
ColXpr
speciation_variables
(
index_t
node
)
{
return
m_speciation_variables
.
col
(
node
);
}
//! Return the chemical composition of a node - needed to initialize the speciation solver
EquilibriumState
equilibrium_composition
(
index_t
node
)
{
return
EquilibriumState
(
m_speciation_variables
.
col
(
node
),
m_secondary_concentration
.
col
(
node
),
m_secondary_variables
.
col
(
node
),
m_ionic_strength
(
node
),
m_data
);
}
//! Update the composition at 'node' using the EquilibriumState instance 'composition'
void
update_composition
(
index_t
node
,
const
EquilibriumState
&
composition
);
//! Return the total moles number for 'component' at 'node' from the speciation
scalar_t
immobile_total_amount
(
index_t
node
,
index_t
component
);
//! Return the mass of water at 'node'
scalar_t
mass_water
(
index_t
node
);
//! Compute the total moles number at 'node' using the transport mobile concentration
void
nodal_update_total_amount
(
index_t
node
,
Vector
&
total_amount
);
// Used in the update FEM->speciation
scalar_t
nodal_component_update_total_amount
(
index_t
node
,
index_t
component
);
private
:
// where the component informations are stored
index_t
offset_total_component
()
const
{
return
-
1
;}
// where the component informations are stored
index_t
offset_component
()
const
{
return
0
;}
// where the mineral informations are stored
index_t
offset_mineral
()
const
{
return
m_data
->
nb_component
+
offset_component
();}
RawDatabasePtr
m_data
;
std
::
shared_ptr
<
mesh
::
Mesh1D
>
m_mesh
;
std
::
shared_ptr
<
SaturatedDiffusionTransportParameters
>
m_param
;
Vector
m_total_mobile_concentration
;
Matrix
m_speciation_variables
;
};
}
// end namespace siasaturated
}
// end namespace systems
}
// end namespace reactmicp
}
// end namespace specmicp
#endif
// SPECMICP_REACTMICP_SATURATED_DIFFUSION_VARIABLES_HPP
Event Timeline
Log In to Comment