Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F97868631
saturated_react.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
Mon, Jan 6, 23:40
Size
6 KB
Mime Type
text/x-c
Expires
Wed, Jan 8, 23:40 (2 d)
Engine
blob
Format
Raw Data
Handle
23423995
Attached To
rSPECMICP SpecMiCP / ReactMiCP
saturated_react.hpp
View Options
/*-------------------------------------------------------
Copyright (c) 2014,2015 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.
---------------------------------------------------------*/
#ifndef SPECMICP_IO_SATURATEDREACT_HPP
#define SPECMICP_IO_SATURATEDREACT_HPP
#include <iostream>
#include <fstream>
#include "utils/io/units.hpp"
//#include "reactmicp/systems/saturated_react/variablesfwd.hpp"
#include "reactmicp/systems/saturated_react/variables.hpp"
#include <chrono>
#include <ctime>
using
namespace
specmicp
::
reactmicp
::
systems
::
satdiff
;
namespace
specmicp
{
namespace
io
{
static
constexpr
char
field_sep
=
'\t'
;
static
constexpr
char
comment
=
'#'
;
void
print_csv_header
(
std
::
ostream
*
ofile
)
{
std
::
time_t
time
=
std
::
chrono
::
system_clock
::
to_time_t
(
std
::
chrono
::
system_clock
::
now
());
(
*
ofile
)
<<
comment
<<
" - ReactMiCP - "
<<
std
::
ctime
(
&
time
);
}
void
print_components_total_aqueous_concentration
(
RawDatabasePtr
the_database
,
SaturatedVariablesPtr
variables
,
mesh
::
Mesh1DPtr
the_mesh
,
const
units
::
UnitsSet
&
units_set
,
std
::
ostream
*
ofile
)
{
print_csv_header
(
ofile
);
(
*
ofile
)
<<
comment
<<
"units : mol/"
<<
io
::
volume_unit_to_string
(
units_set
.
length
)
<<
std
::
endl
;
(
*
ofile
)
<<
"Position"
;
for
(
index_t
component:
the_database
->
range_aqueous_component
())
{
(
*
ofile
)
<<
field_sep
<<
the_database
->
get_label_component
(
component
);
}
(
*
ofile
)
<<
std
::
endl
;
for
(
index_t
node:
the_mesh
->
range_nodes
())
{
(
*
ofile
)
<<
the_mesh
->
get_position
(
node
);
for
(
index_t
component:
the_database
->
range_aqueous_component
())
{
(
*
ofile
)
<<
field_sep
<<
variables
->
aqueous_concentration
(
node
,
component
);
}
(
*
ofile
)
<<
std
::
endl
;
}
}
void
print_components_total_aqueous_concentration
(
RawDatabasePtr
the_database
,
SaturatedVariablesPtr
variables
,
mesh
::
Mesh1DPtr
the_mesh
,
const
units
::
UnitsSet
&
units_set
,
const
std
::
string
&
filepath
)
{
std
::
ofstream
ofile
(
filepath
);
print_components_total_aqueous_concentration
(
the_database
,
variables
,
the_mesh
,
units_set
,
&
ofile
);
ofile
.
close
();
}
void
print_components_total_solid_concentration
(
RawDatabasePtr
the_database
,
SaturatedVariablesPtr
variables
,
mesh
::
Mesh1DPtr
the_mesh
,
const
units
::
UnitsSet
&
units_set
,
std
::
ostream
*
ofile
)
{
print_csv_header
(
ofile
);
(
*
ofile
)
<<
comment
<<
"units : mol/"
<<
io
::
volume_unit_to_string
(
units_set
.
length
)
<<
std
::
endl
;
(
*
ofile
)
<<
"Position"
;
for
(
index_t
component:
the_database
->
range_aqueous_component
())
{
(
*
ofile
)
<<
field_sep
<<
the_database
->
get_label_component
(
component
);
}
(
*
ofile
)
<<
std
::
endl
;
for
(
index_t
node:
the_mesh
->
range_nodes
())
{
(
*
ofile
)
<<
the_mesh
->
get_position
(
node
);
for
(
index_t
component:
the_database
->
range_aqueous_component
())
{
(
*
ofile
)
<<
field_sep
<<
variables
->
solid_concentration
(
node
,
component
);
}
(
*
ofile
)
<<
std
::
endl
;
}
}
void
print_components_total_solid_concentration
(
RawDatabasePtr
the_database
,
SaturatedVariablesPtr
variables
,
mesh
::
Mesh1DPtr
the_mesh
,
const
units
::
UnitsSet
&
units_set
,
const
std
::
string
&
filepath
)
{
std
::
ofstream
ofile
(
filepath
);
print_components_total_solid_concentration
(
the_database
,
variables
,
the_mesh
,
units_set
,
&
ofile
);
ofile
.
close
();
}
void
print_minerals_profile
(
RawDatabasePtr
the_database
,
SaturatedVariablesPtr
variables
,
mesh
::
Mesh1DPtr
the_mesh
,
std
::
ostream
*
ofile
)
{
print_csv_header
(
ofile
);
(
*
ofile
)
<<
"Position"
;
for
(
index_t
mineral:
the_database
->
range_mineral
())
{
(
*
ofile
)
<<
field_sep
<<
the_database
->
get_label_mineral
(
mineral
);
}
(
*
ofile
)
<<
field_sep
<<
"Porosity"
;
(
*
ofile
)
<<
field_sep
<<
"pH"
;
(
*
ofile
)
<<
std
::
endl
;
for
(
index_t
node:
the_mesh
->
range_nodes
())
{
(
*
ofile
)
<<
the_mesh
->
get_position
(
node
);
AdimensionalSystemSolutionExtractor
extractor
(
variables
->
equilibrium_solution
(
node
),
the_database
,
units
::
UnitsSet
());
for
(
index_t
mineral:
the_database
->
range_mineral
())
{
(
*
ofile
)
<<
field_sep
<<
extractor
.
volume_fraction_mineral
(
mineral
);
}
(
*
ofile
)
<<
field_sep
<<
variables
->
porosity
(
node
);
(
*
ofile
)
<<
field_sep
<<
extractor
.
pH
();
(
*
ofile
)
<<
std
::
endl
;
}
}
void
print_minerals_profile
(
RawDatabasePtr
the_database
,
SaturatedVariablesPtr
variables
,
mesh
::
Mesh1DPtr
the_mesh
,
const
std
::
string
&
filepath
)
{
std
::
ofstream
ofile
(
filepath
);
print_minerals_profile
(
the_database
,
variables
,
the_mesh
,
&
ofile
);
ofile
.
close
();
}
}
// end namespace io
}
// end namespace specmicp
#endif
// SPECMICP_IO_SATURATEDREACT_HPP
Event Timeline
Log In to Comment