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
12cb2514
Commit
12cb2514
authored
8 years ago
by
Norihiro Watanabe
Browse files
Options
Downloads
Patches
Plain Diff
SecondaryVariableCollection: move definitions to cpp
parent
c7cf5c11
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
NumLib/Extrapolation/Extrapolator.h
+3
-0
3 additions, 0 deletions
NumLib/Extrapolation/Extrapolator.h
ProcessLib/SecondaryVariable.cpp
+84
-0
84 additions, 0 deletions
ProcessLib/SecondaryVariable.cpp
ProcessLib/SecondaryVariable.h
+3
-61
3 additions, 61 deletions
ProcessLib/SecondaryVariable.h
with
90 additions
and
61 deletions
NumLib/Extrapolation/Extrapolator.h
+
3
−
0
View file @
12cb2514
...
@@ -12,6 +12,9 @@
...
@@ -12,6 +12,9 @@
#include
<vector>
#include
<vector>
#include
<Eigen/Eigen>
#include
"NumLib/NumericsConfig.h"
namespace
NumLib
namespace
NumLib
{
{
...
...
This diff is collapsed.
Click to expand it.
ProcessLib/SecondaryVariable.cpp
0 → 100644
+
84
−
0
View file @
12cb2514
/**
* \copyright
* Copyright (c) 2012-2016, 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
"SecondaryVariable.h"
namespace
ProcessLib
{
SecondaryVariableCollection
::
SecondaryVariableCollection
(
boost
::
optional
<
BaseLib
::
ConfigTree
>
const
&
config
,
std
::
initializer_list
<
std
::
string
>
tag_names
)
{
if
(
!
config
)
return
;
// read which variables are defined in the config
for
(
auto
const
&
tag_name
:
tag_names
)
{
if
(
!
_all_secondary_variables
.
insert
(
tag_name
).
second
)
{
OGS_FATAL
(
"Tag name <%s> has been specified twice as a secondary variable."
);
}
//! \ogs_file_special
if
(
auto
var_name
=
config
->
getConfigParameterOptional
<
std
::
string
>
(
tag_name
))
{
// TODO check primary vars, too
BaseLib
::
insertIfKeyValueUniqueElseError
(
_map_tagname_to_varname
,
tag_name
,
*
var_name
,
"Secondary variable names must be unique."
);
}
}
}
bool
SecondaryVariableCollection
::
variableExists
(
std
::
string
const
&
variable_name
)
const
{
auto
pred
=
[
&
variable_name
](
std
::
pair
<
std
::
string
,
std
::
string
>
const
&
p
)
{
return
p
.
second
==
variable_name
;
};
// check if out_var is a secondary variable
auto
const
&
var
=
std
::
find_if
(
_map_tagname_to_varname
.
cbegin
(),
_map_tagname_to_varname
.
cend
(),
pred
);
return
var
!=
_map_tagname_to_varname
.
cend
();
}
void
SecondaryVariableCollection
::
addSecondaryVariable
(
std
::
string
const
&
tag_name
,
const
unsigned
num_components
,
SecondaryVariableFunctions
&&
fcts
)
{
auto
it
=
_map_tagname_to_varname
.
find
(
tag_name
);
// get user-supplied var_name for the given tag_name
if
(
it
!=
_map_tagname_to_varname
.
end
())
{
auto
const
&
var_name
=
it
->
first
;
if
(
!
_configured_secondary_variables
.
emplace
(
std
::
make_pair
(
var_name
,
SecondaryVariable
{
var_name
,
num_components
,
std
::
move
(
fcts
)}))
.
second
)
{
OGS_FATAL
(
"The secondary variable with name `%s' has already been "
"set up."
,
var_name
.
c_str
());
}
}
else
if
(
_all_secondary_variables
.
find
(
tag_name
)
==
_all_secondary_variables
.
end
())
{
OGS_FATAL
(
"The tag <%s> has not been registered to mark a secondary "
"variable."
,
tag_name
.
c_str
());
}
}
}
// namespace ProcessLib
This diff is collapsed.
Click to expand it.
ProcessLib/SecondaryVariable.h
+
3
−
61
View file @
12cb2514
...
@@ -106,43 +106,13 @@ public:
...
@@ -106,43 +106,13 @@ public:
*/
*/
SecondaryVariableCollection
(
SecondaryVariableCollection
(
boost
::
optional
<
BaseLib
::
ConfigTree
>
const
&
config
,
boost
::
optional
<
BaseLib
::
ConfigTree
>
const
&
config
,
std
::
initializer_list
<
std
::
string
>
tag_names
)
std
::
initializer_list
<
std
::
string
>
tag_names
);
{
if
(
!
config
)
return
;
// read which variables are defined in the config
for
(
auto
const
&
tag_name
:
tag_names
)
{
if
(
!
_all_secondary_variables
.
insert
(
tag_name
).
second
)
{
OGS_FATAL
(
"Tag name <%s> has been specified twice as a secondary variable."
);
}
//! \ogs_file_special
if
(
auto
var_name
=
config
->
getConfigParameterOptional
<
std
::
string
>
(
tag_name
))
{
// TODO check primary vars, too
BaseLib
::
insertIfKeyValueUniqueElseError
(
_map_tagname_to_varname
,
tag_name
,
*
var_name
,
"Secondary variable names must be unique."
);
}
}
}
/*! Tells if a secondary variable with the specified name has been set up.
/*! Tells if a secondary variable with the specified name has been set up.
*
*
* \note \c variable_name is not the tag name in the project file!
* \note \c variable_name is not the tag name in the project file!
*/
*/
bool
variableExists
(
std
::
string
const
&
variable_name
)
const
bool
variableExists
(
std
::
string
const
&
variable_name
)
const
;
{
auto
pred
=
[
&
variable_name
](
std
::
pair
<
std
::
string
,
std
::
string
>
const
&
p
)
{
return
p
.
second
==
variable_name
;
};
// check if out_var is a secondary variable
auto
const
&
var
=
std
::
find_if
(
_map_tagname_to_varname
.
cbegin
(),
_map_tagname_to_varname
.
cend
(),
pred
);
return
var
!=
_map_tagname_to_varname
.
cend
();
}
/*! Set up a secondary variable.
/*! Set up a secondary variable.
*
*
...
@@ -158,35 +128,7 @@ public:
...
@@ -158,35 +128,7 @@ public:
*/
*/
void
addSecondaryVariable
(
std
::
string
const
&
tag_name
,
void
addSecondaryVariable
(
std
::
string
const
&
tag_name
,
const
unsigned
num_components
,
const
unsigned
num_components
,
SecondaryVariableFunctions
&&
fcts
)
SecondaryVariableFunctions
&&
fcts
);
{
auto
it
=
_map_tagname_to_varname
.
find
(
tag_name
);
// get user-supplied var_name for the given tag_name
if
(
it
!=
_map_tagname_to_varname
.
end
())
{
auto
const
&
var_name
=
it
->
first
;
if
(
!
_configured_secondary_variables
.
emplace
(
std
::
make_pair
(
var_name
,
SecondaryVariable
{
var_name
,
num_components
,
std
::
move
(
fcts
)}))
.
second
)
{
OGS_FATAL
(
"The secondary variable with name `%s' has already been "
"set up."
,
var_name
.
c_str
());
}
}
else
if
(
_all_secondary_variables
.
find
(
tag_name
)
==
_all_secondary_variables
.
end
())
{
OGS_FATAL
(
"The tag <%s> has not been registered to mark a secondary "
"variable."
,
tag_name
.
c_str
());
}
}
//! Returns an iterator to the first secondary variable.
//! Returns an iterator to the first secondary variable.
std
::
map
<
std
::
string
,
SecondaryVariable
>::
const_iterator
std
::
map
<
std
::
string
,
SecondaryVariable
>::
const_iterator
...
...
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