Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dmitri Naumov
ogs
Commits
a8cd638f
Commit
a8cd638f
authored
5 years ago
by
renchao.lu
Committed by
Dmitri Naumov
5 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[CL] Create class Output.
parent
5c7511e4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
ChemistryLib/CreateOutput.cpp
+59
-0
59 additions, 0 deletions
ChemistryLib/CreateOutput.cpp
ChemistryLib/CreateOutput.h
+26
-0
26 additions, 0 deletions
ChemistryLib/CreateOutput.h
ChemistryLib/Output.h
+100
-0
100 additions, 0 deletions
ChemistryLib/Output.h
with
185 additions
and
0 deletions
ChemistryLib/CreateOutput.cpp
0 → 100644
+
59
−
0
View file @
a8cd638f
/**
* \copyright
* Copyright (c) 2012-2019, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#include
<numeric>
#include
"CreateOutput.h"
namespace
ChemistryLib
{
std
::
unique_ptr
<
Output
>
createOutput
(
std
::
vector
<
Component
>
const
&
components
,
std
::
vector
<
EquilibriumPhase
>
const
&
equilibrium_phases
,
std
::
vector
<
KineticReactant
>
const
&
kinetic_reactants
,
std
::
string
const
&
project_file_name
)
{
// Mark which phreeqc output items will be held.
std
::
vector
<
OutputItem
>
accepted_items
{{
"pH"
,
ItemType
::
pH
},
{
"pe"
,
ItemType
::
pe
}};
for
(
auto
const
&
component
:
components
)
accepted_items
.
emplace_back
(
component
.
name
,
ItemType
::
Component
);
for
(
auto
const
&
equilibrium_phase
:
equilibrium_phases
)
accepted_items
.
emplace_back
(
equilibrium_phase
.
name
,
ItemType
::
EquilibriumPhase
);
for
(
auto
const
&
kinetic_reactant
:
kinetic_reactants
)
accepted_items
.
emplace_back
(
kinetic_reactant
.
name
,
ItemType
::
KineticReactant
);
// Record ids of which phreeqc output items will be dropped.
BasicOutputSetups
basic_output_setups
(
project_file_name
);
auto
const
num_dropped_basic_items
=
basic_output_setups
.
getNumberOfDroppedItems
();
std
::
vector
<
int
>
dropped_item_ids
(
num_dropped_basic_items
);
std
::
iota
(
dropped_item_ids
.
begin
(),
dropped_item_ids
.
end
(),
0
);
auto
const
num_dvalue_equilibrium_phases
=
equilibrium_phases
.
size
();
auto
const
num_dvalue_kinetic_reactants
=
kinetic_reactants
.
size
();
int
const
num_dvalue_items
=
num_dvalue_equilibrium_phases
+
num_dvalue_kinetic_reactants
;
auto
const
num_basic_items
=
basic_output_setups
.
getNumberOfItemsInDisplay
();
auto
const
num_components
=
components
.
size
();
auto
dvalue_item_id
=
num_basic_items
+
num_components
+
1
;
for
(
int
i
=
0
;
i
<
num_dvalue_items
;
++
i
)
{
dropped_item_ids
.
push_back
(
dvalue_item_id
);
dvalue_item_id
+=
2
*
(
i
+
1
);
}
return
std
::
make_unique
<
Output
>
(
basic_output_setups
,
std
::
move
(
accepted_items
),
std
::
move
(
dropped_item_ids
));
}
}
// namespace ChemistryLib
This diff is collapsed.
Click to expand it.
ChemistryLib/CreateOutput.h
0 → 100644
+
26
−
0
View file @
a8cd638f
/**
* \copyright
* Copyright (c) 2012-2019, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#pragma once
#include
<memory>
#include
"Output.h"
#include
"PhreeqcIOData/AqueousSolution.h"
#include
"PhreeqcIOData/EquilibriumPhase.h"
#include
"PhreeqcIOData/KineticReactant.h"
namespace
ChemistryLib
{
std
::
unique_ptr
<
Output
>
createOutput
(
std
::
vector
<
Component
>
const
&
components
,
std
::
vector
<
EquilibriumPhase
>
const
&
equilibrium_phases
,
std
::
vector
<
KineticReactant
>
const
&
kinetic_reactants
,
std
::
string
const
&
project_file_name
);
}
// namespace ChemistryLib
This diff is collapsed.
Click to expand it.
ChemistryLib/Output.h
0 → 100644
+
100
−
0
View file @
a8cd638f
/**
* \copyright
* Copyright (c) 2012-2019, OpenGeoSys Community (http://www.opengeosys.org)
* Distributed under a Modified BSD License.
* See accompanying file LICENSE.txt or
* http://www.opengeosys.org/project/license
*
*/
#pragma once
#include
<algorithm>
#include
<string>
#include
<vector>
namespace
ChemistryLib
{
class
BasicOutputSetups
{
public:
BasicOutputSetups
(
std
::
string
const
&
project_file_name
)
:
output_file
(
project_file_name
+
"_phreeqc.out"
)
{
}
int
getNumberOfItemsInDisplay
()
{
return
display_simulation_id
+
display_state
+
display_solution_id
+
display_distance
+
display_current_time
+
display_time_step
+
display_pH
+
display_pe
;
}
int
getNumberOfDroppedItems
()
{
return
display_simulation_id
+
display_state
+
display_solution_id
+
display_distance
+
display_current_time
+
display_time_step
;
}
std
::
string
const
output_file
;
private
:
static
const
bool
display_simulation_id
=
false
;
static
const
bool
display_state
=
true
;
static
const
bool
display_solution_id
=
true
;
static
const
bool
display_distance
=
false
;
static
const
bool
display_current_time
=
false
;
static
const
bool
display_time_step
=
false
;
static
const
bool
display_pH
=
true
;
static
const
bool
display_pe
=
true
;
static
const
bool
use_high_precision
=
true
;
};
enum
class
ItemType
{
pH
,
pe
,
Component
,
EquilibriumPhase
,
KineticReactant
};
struct
OutputItem
{
OutputItem
(
std
::
string
name_
,
ItemType
item_type_
)
:
name
(
std
::
move
(
name_
)),
item_type
(
item_type_
)
{
}
std
::
string
const
name
;
ItemType
const
item_type
;
};
struct
Output
{
Output
(
BasicOutputSetups
basic_output_setups_
,
std
::
vector
<
OutputItem
>&&
accepted_items_
,
std
::
vector
<
int
>&&
dropped_item_ids_
)
:
basic_output_setups
(
basic_output_setups_
),
accepted_items
(
std
::
move
(
accepted_items_
)),
dropped_item_ids
(
std
::
move
(
dropped_item_ids_
))
{
}
std
::
vector
<
OutputItem
>
getOutputItemsByItemType
(
ItemType
item_type
)
const
{
std
::
vector
<
OutputItem
>
matching_items
;
std
::
copy_if
(
accepted_items
.
cbegin
(),
accepted_items
.
cend
(),
std
::
back_inserter
(
matching_items
),
[
&
item_type
](
OutputItem
const
&
accepted_item
)
{
return
accepted_item
.
item_type
==
item_type
;
});
return
matching_items
;
}
BasicOutputSetups
const
basic_output_setups
;
std
::
vector
<
OutputItem
>
const
accepted_items
;
std
::
vector
<
int
>
const
dropped_item_ids
;
};
}
// namespace ChemistryLib
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment