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
wenqing
ogs
Commits
b16e41d3
Commit
b16e41d3
authored
8 years ago
by
Christoph Lehmann
Browse files
Options
Downloads
Patches
Plain Diff
[PL] made check of secondary variables config more strict.
parent
2df6d8b4
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ProcessLib/ProcessOutput.h
+4
-5
4 additions, 5 deletions
ProcessLib/ProcessOutput.h
ProcessLib/SecondaryVariable.h
+47
-19
47 additions, 19 deletions
ProcessLib/SecondaryVariable.h
with
51 additions
and
24 deletions
ProcessLib/ProcessOutput.h
+
4
−
5
View file @
b16e41d3
...
@@ -234,13 +234,12 @@ void doProcessOutput(
...
@@ -234,13 +234,12 @@ void doProcessOutput(
}
}
};
};
for
(
auto
const
&
var
:
secondary_variables
)
for
(
auto
const
&
elem
:
secondary_variables
)
{
{
auto
const
var_name
=
secondary_variables
.
getMappedName
(
var
.
name
);
auto
const
&
var_name
=
elem
.
first
;
if
(
output_variables
.
find
(
var_name
)
if
(
output_variables
.
find
(
var_name
)
!=
output_variables
.
cend
())
!=
output_variables
.
cend
())
{
{
add_secondary_var
(
var
,
var_name
);
add_secondary_var
(
elem
.
second
,
var_name
);
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
ProcessLib/SecondaryVariable.h
+
47
−
19
View file @
b16e41d3
...
@@ -115,6 +115,12 @@ public:
...
@@ -115,6 +115,12 @@ public:
// read which variables are defined in the config
// read which variables are defined in the config
for
(
auto
const
&
tag_name
:
tag_names
)
{
for
(
auto
const
&
tag_name
:
tag_names
)
{
if
(
!
_all_secondary_variables
.
insert
(
tag_name
).
second
)
{
ERR
(
"Tag name <%s> has been specified twice as a secondary variable."
);
std
::
abort
();
}
//! \ogs_file_special
//! \ogs_file_special
if
(
auto
var_name
=
config
->
getConfParamOptional
<
std
::
string
>
(
tag_name
))
if
(
auto
var_name
=
config
->
getConfParamOptional
<
std
::
string
>
(
tag_name
))
{
{
...
@@ -145,46 +151,64 @@ public:
...
@@ -145,46 +151,64 @@ public:
/*! Set up a secondary variable.
/*! Set up a secondary variable.
*
*
* \param tag_name the tag in the project file associated with this secondary variable.
* \param tag_name the tag in the project file associated with this
* secondary variable.
* \param num_components the variable's number of components.
* \param num_components the variable's number of components.
* \param fcts functions that compute the variable.
* \param fcts functions that compute the variable.
*
*
* \note
* \note
* Only variables requested by the user in the project file will be configured.
* Only variables requested by the user in the project file will be
* configured.
* All other variables are silently ignored.
* All other variables are silently ignored.
*/
*/
void
addSecondaryVariable
(
void
addSecondaryVariable
(
std
::
string
const
&
tag_name
,
std
::
string
const
&
tag_name
,
const
unsigned
num_components
,
const
unsigned
num_components
,
SecondaryVariableFunctions
<
GlobalVector
>&&
fcts
)
SecondaryVariableFunctions
<
GlobalVector
>&&
fcts
)
{
{
auto
it
=
_map_tagname_to_varname
.
find
(
tag_name
);
auto
it
=
_map_tagname_to_varname
.
find
(
tag_name
);
// get user-supplied var_name for the given tag_name
// get user-supplied var_name for the given tag_name
if
(
it
!=
_map_tagname_to_varname
.
end
())
{
if
(
it
!=
_map_tagname_to_varname
.
end
())
{
auto
const
&
var_name
=
it
->
first
;
auto
const
&
var_name
=
it
->
first
;
// TODO make sure the same variable is not pushed twice
_secondary_variables
.
push_back
(
{
var_name
,
num_components
,
std
::
move
(
fcts
)});
}
}
std
::
string
const
&
getMappedName
(
std
::
string
const
&
tag_name
)
if
(
!
_configured_secondary_variables
{
.
emplace
(
std
::
make_pair
(
return
_map_tagname_to_varname
[
tag_name
];
var_name
,
SecondaryVariable
<
GlobalVector
>
{
var_name
,
num_components
,
std
::
move
(
fcts
)}))
.
second
)
{
ERR
(
"The secondary variable with name `%s' has already been "
"set up."
,
var_name
.
c_str
());
std
::
abort
();
}
}
else
if
(
_all_secondary_variables
.
find
(
tag_name
)
==
_all_secondary_variables
.
end
())
{
ERR
(
"The tag <%s> has not been registered to mark a secondary "
"variable."
,
tag_name
.
c_str
());
std
::
abort
();
}
}
}
//! Returns an iterator to the first secondary variable.
//! Returns an iterator to the first secondary variable.
typename
std
::
vector
<
SecondaryVariable
<
GlobalVector
>>::
const_iterator
typename
std
::
map
<
std
::
string
,
SecondaryVariable
<
GlobalVector
>>::
const_iterator
begin
()
const
begin
()
const
{
{
return
_secondary_variables
.
begin
();
return
_configured
_secondary_variables
.
begin
();
}
}
//! Returns an iterator past the last secondary variable.
//! Returns an iterator past the last secondary variable.
typename
std
::
vector
<
SecondaryVariable
<
GlobalVector
>>::
const_iterator
typename
std
::
map
<
std
::
string
,
SecondaryVariable
<
GlobalVector
>>::
const_iterator
end
()
const
end
()
const
{
{
return
_secondary_variables
.
end
();
return
_configured
_secondary_variables
.
end
();
}
}
private
:
private
:
...
@@ -192,7 +216,11 @@ private:
...
@@ -192,7 +216,11 @@ private:
std
::
map
<
std
::
string
,
std
::
string
>
_map_tagname_to_varname
;
std
::
map
<
std
::
string
,
std
::
string
>
_map_tagname_to_varname
;
//! Collection of all configured secondary variables.
//! Collection of all configured secondary variables.
std
::
vector
<
SecondaryVariable
<
GlobalVector
>>
_secondary_variables
;
//! Maps the variable name to the corresponding SecondaryVariable.
std
::
map
<
std
::
string
,
SecondaryVariable
<
GlobalVector
>>
_configured_secondary_variables
;
//! Set of all tags available as a secondary variable.
std
::
set
<
std
::
string
>
_all_secondary_variables
;
};
};
...
...
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