Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F86697449
diffusion_numbering.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, Oct 8, 02:30
Size
5 KB
Mime Type
text/x-c
Expires
Thu, Oct 10, 02:30 (2 d)
Engine
blob
Format
Raw Data
Handle
21461340
Attached To
rSPECMICP SpecMiCP / ReactMiCP
diffusion_numbering.cpp
View Options
/*-------------------------------------------------------
- Module : reactmicp/systems/diffusion
- File : diffusion_numbering.cpp
- Author : Fabien Georget
Copyright (c) 2014, Fabien 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:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* 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.
* Neither the name of the Princeton University 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 OWNER 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 "diffusion_numbering.hpp"
#include "reactmicp/meshes/mesh1d.hpp"
namespace
specmicp
{
namespace
reactmicp
{
namespace
systems
{
namespace
diffusion
{
// Boundary Condition
void
BoundaryCondition
::
fix_all
()
{
if
(
not
composition
.
is_valid
())
throw
std
::
runtime_error
(
"The composition has not been correctly initialized"
);
std
::
shared_ptr
<
database
::
DataContainer
>
data
=
composition
.
get_database
();
component
.
reserve
(
data
->
nb_component
-
1
);
tot_mobile_concentration
.
reserve
(
data
->
nb_component
-
1
);
mineral
.
reserve
(
data
->
nb_mineral
);
for
(
int
comp:
data
->
range_aqueous_component
())
{
component
.
push_back
(
comp
);
tot_mobile_concentration
.
push_back
(
comp
);
}
for
(
int
min:
data
->
range_mineral
())
{
mineral
.
push_back
(
min
);
}
}
// Diffusion numbering
DiffusionNumbering
::
DiffusionNumbering
(
ind_t
number_nodes
,
ind_t
number_aqueous_component
,
ind_t
number_mineral
,
const
ListBoundaryCondition
&
list_bc
,
Variables
&
variable
)
:
nb_aq_component
(
number_aqueous_component
),
nb_mineral
(
number_mineral
),
nb_ndf
(
2
*
number_aqueous_component
+
number_mineral
),
m_ideq
(
nb_ndf
,
number_nodes
)
{
number_equations
(
list_bc
,
variable
);
}
void
DiffusionNumbering
::
number_equations
(
const
ListBoundaryCondition
&
list_bc
,
Variables
&
variable
)
{
initialize_variable
(
variable
);
// First we parse the bcs, to find the correct bc to apply
parse_bcs
(
list_bc
,
variable
);
// Then we number the equations
do_numbering
();
}
void
DiffusionNumbering
::
initialize_variable
(
Variables
&
variable
)
{
variable
.
displacement
=
Vector
::
Zero
(
m_ideq
.
rows
()
*
m_ideq
.
cols
());
variable
.
velocity
=
Vector
::
Zero
(
m_ideq
.
rows
()
*
m_ideq
.
cols
());
}
void
DiffusionNumbering
::
parse_bcs
(
const
ListBoundaryCondition
&
list_bc
,
Variables
&
variable
)
{
variable
.
displacement
.
setZero
();
variable
.
velocity
.
setZero
();
m_ideq
.
setZero
();
m_nodes_with_bc
.
reserve
(
list_bc
.
size
());
for
(
BoundaryCondition
bc:
list_bc
)
{
const
ind_t
node
=
bc
.
node
;
m_nodes_with_bc
.
push_back
(
node
);
for
(
ind_t
component:
bc
.
tot_mobile_concentration
)
{
m_ideq
(
get_ndof_diffusion
(
component
),
node
)
=
no_equation
;
mobile_total_concentration
(
node
,
component
,
variable
)
=
bc
.
composition
.
total_aqueous_concentration_component
(
component
);
}
for
(
ind_t
component:
bc
.
component
)
{
m_ideq
(
get_ndof_massbalance
(
component
),
node
)
=
no_equation
;
component_concentration
(
node
,
component
,
variable
)
=
std
::
log10
(
bc
.
composition
.
molality_component
(
component
));
}
for
(
ind_t
mineral:
bc
.
mineral
)
{
m_ideq
(
get_ndof_mineral
(
mineral
),
node
)
=
no_equation
;
mole_mineral
(
node
,
mineral
,
variable
)
=
bc
.
composition
.
moles_mineral
(
mineral
);
}
}
//
for
(
int
node
=
0
;
node
<
m_ideq
.
cols
();
++
node
)
{
for
(
ind_t
component
=
1
;
component
<
5
;
++
component
)
{
// m_ideq(get_ndof_diffusion(component), node) = no_equation;
// m_ideq(get_ndof_massbalance(component), node) = no_equation;
}
for
(
ind_t
mineral
=
0
;
mineral
<
5
;
++
mineral
)
{
// m_ideq(get_ndof_mineral(mineral), node) = no_equation;
}
}
}
void
DiffusionNumbering
::
do_numbering
()
{
ind_t
neq
=
0
;
for
(
ind_t
node
=
0
;
node
<
m_ideq
.
cols
();
++
node
)
{
for
(
ind_t
df
=
0
;
df
<
get_ndf
();
++
df
)
{
if
(
m_ideq
(
df
,
node
)
!=
no_equation
)
{
m_ideq
(
df
,
node
)
=
neq
;
++
neq
;
}
}
}
nb_neq
=
neq
;
}
//! \brief Return true if the node has a boundary condition
double
DiffusionNumbering
::
node_has_bc
(
ind_t
node
)
{
auto
search
=
std
::
find
(
m_nodes_with_bc
.
begin
(),
m_nodes_with_bc
.
end
(),
node
);
if
(
search
==
m_nodes_with_bc
.
end
())
return
false
;
else
return
true
;
}
}
// end namespace diffusion
}
// end namespace systems
}
// end namespace reactmicp
}
// end namespace specmicp
Event Timeline
Log In to Comment