Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
dynamic
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
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
MostafaMollaali
dynamic
Commits
758bccde
Commit
758bccde
authored
9 years ago
by
Christoph Lehmann
Browse files
Options
Downloads
Patches
Plain Diff
[PL] pass a list of variables to process constructor
parent
887391d1
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
ProcessLib/GroundwaterFlow/GroundwaterFlowProcess.h
+8
-10
8 additions, 10 deletions
ProcessLib/GroundwaterFlow/GroundwaterFlowProcess.h
ProcessLib/Process.cpp
+23
-4
23 additions, 4 deletions
ProcessLib/Process.cpp
ProcessLib/Process.h
+23
-13
23 additions, 13 deletions
ProcessLib/Process.h
with
54 additions
and
27 deletions
ProcessLib/GroundwaterFlow/GroundwaterFlowProcess.h
+
8
−
10
View file @
758bccde
...
...
@@ -44,13 +44,12 @@ public:
MeshLib
::
Mesh
&
mesh
,
typename
Process
<
GlobalSetup
>::
NonlinearSolver
&
nonlinear_solver
,
std
::
unique_ptr
<
typename
Process
<
GlobalSetup
>::
TimeDiscretization
>&&
time_discretization
,
ProcessVariable
&
variable
,
std
::
vector
<
std
::
reference_wrapper
<
ProcessVariable
>>&&
process_
variable
s
,
GroundwaterFlowProcessData
&&
process_data
)
:
Process
<
GlobalSetup
>
(
mesh
,
nonlinear_solver
,
std
::
move
(
time_discretization
))
:
Process
<
GlobalSetup
>
(
mesh
,
nonlinear_solver
,
std
::
move
(
time_discretization
),
std
::
move
(
process_variables
))
,
_process_data
(
std
::
move
(
process_data
))
{
Base
::
_process_variables
.
emplace_back
(
variable
);
if
(
dynamic_cast
<
NumLib
::
ForwardEuler
<
GlobalVector
>*>
(
&
Base
::
getTimeDiscretization
())
!=
nullptr
)
{
...
...
@@ -169,10 +168,8 @@ createGroundwaterFlowProcess(
DBUG
(
"Create GroundwaterFlowProcess."
);
// Process variable.
ProcessVariable
&
process_variable
=
findProcessVariable
(
config
,
"process_variable"
,
variables
);
DBUG
(
"Associate hydraulic_head with process variable
\'
%s
\'
."
,
process_variable
.
getName
().
c_str
());
auto
process_variables
=
findProcessVariables
(
variables
,
config
,
{
"process_variable"
});
// Hydraulic conductivity parameter.
auto
&
hydraulic_conductivity
=
...
...
@@ -189,9 +186,10 @@ createGroundwaterFlowProcess(
return
std
::
unique_ptr
<
GroundwaterFlowProcess
<
GlobalSetup
>>
{
new
GroundwaterFlowProcess
<
GlobalSetup
>
{
mesh
,
nonlinear_solver
,
std
::
move
(
time_discretization
),
process_variable
,
std
::
move
(
process_variable
s
)
,
std
::
move
(
process_data
)
}};
}
};
}
}
// namespace GroundwaterFlow
...
...
This diff is collapsed.
Click to expand it.
ProcessLib/Process.cpp
+
23
−
4
View file @
758bccde
...
...
@@ -18,11 +18,11 @@
namespace
ProcessLib
{
ProcessVariable
&
findProcessVariable
(
BaseLib
::
ConfigTree
const
&
process_config
,
std
::
string
const
&
tag
,
std
::
vector
<
ProcessVariable
>
const
&
variables
)
std
::
vector
<
ProcessVariable
>
const
&
variables
,
BaseLib
::
ConfigTree
const
&
pv_config
,
std
::
string
const
&
tag
)
{
// Find process variable name in process config.
std
::
string
const
name
=
p
rocess
_config
.
getConfParam
<
std
::
string
>
(
tag
);
std
::
string
const
name
=
p
v
_config
.
getConfParam
<
std
::
string
>
(
tag
);
// Find corresponding variable by name.
auto
variable
=
std
::
find_if
(
variables
.
cbegin
(),
variables
.
cend
(),
...
...
@@ -39,10 +39,29 @@ ProcessVariable& findProcessVariable(
name
.
c_str
(),
tag
.
c_str
());
std
::
abort
();
}
DBUG
(
"Found process variable
\'
%s
\'
."
,
variable
->
getName
().
c_str
());
DBUG
(
"Found process variable
\'
%s
\'
for config tag <%s>."
,
variable
->
getName
().
c_str
(),
tag
.
c_str
());
// Const cast is needed because of variables argument constness.
return
const_cast
<
ProcessVariable
&>
(
*
variable
);
}
std
::
vector
<
std
::
reference_wrapper
<
ProcessVariable
>>
findProcessVariables
(
std
::
vector
<
ProcessVariable
>
const
&
variables
,
BaseLib
::
ConfigTree
const
&
process_config
,
std
::
initializer_list
<
std
::
string
>
tag_names
)
{
std
::
vector
<
std
::
reference_wrapper
<
ProcessVariable
>>
vars
;
vars
.
reserve
(
tag_names
.
size
());
auto
const
pv_conf
=
process_config
.
getConfSubtree
(
"process_variables"
);
for
(
auto
const
&
tag
:
tag_names
)
{
vars
.
emplace_back
(
findProcessVariable
(
variables
,
pv_conf
,
tag
));
}
return
vars
;
}
}
// namespace ProcessLib
This diff is collapsed.
Click to expand it.
ProcessLib/Process.h
+
23
−
13
View file @
758bccde
...
...
@@ -60,10 +60,13 @@ public:
Process
(
MeshLib
::
Mesh
&
mesh
,
NonlinearSolver
&
nonlinear_solver
,
std
::
unique_ptr
<
TimeDiscretization
>&&
time_discretization
)
std
::
unique_ptr
<
TimeDiscretization
>&&
time_discretization
,
std
::
vector
<
std
::
reference_wrapper
<
ProcessVariable
>>&&
process_variables
)
:
_mesh
(
mesh
)
,
_nonlinear_solver
(
nonlinear_solver
)
,
_nonlinear_solver
(
nonlinear_solver
)
,
_time_discretization
(
std
::
move
(
time_discretization
))
,
_process_variables
(
std
::
move
(
process_variables
))
{}
/// Preprocessing before starting assembly for new timestep.
...
...
@@ -340,10 +343,6 @@ private:
*
_local_to_global_index_map
,
_mesh
));
}
protected
:
/// Variables used by this process.
std
::
vector
<
std
::
reference_wrapper
<
ProcessVariable
>>
_process_variables
;
private
:
unsigned
const
_integration_order
=
2
;
...
...
@@ -360,23 +359,34 @@ private:
NonlinearSolver
&
_nonlinear_solver
;
std
::
unique_ptr
<
TimeDiscretization
>
_time_discretization
;
/// Variables used by this process.
std
::
vector
<
std
::
reference_wrapper
<
ProcessVariable
>>
_process_variables
;
};
/// Find a process variable for a name given in the process configuration under
/// the tag.
/// Find process variables in \c variables whose names match the settings under
/// the given \c tag_names in the \c process_config.
///
/// In the process config a process variable is referenced by a name. For
/// example it will be looking for a variable named "H" in the list of process
/// variables when the tag is "hydraulic_head":
/// \code
/// <process>
/// ...
/// <hydraulic_head>H</hydraulic_head>
/// <process_variables>
/// <hydraulic_head>H</hydraulic_head>
/// ...
/// </process_variables>
/// ...
/// </process>
/// \endcode
/// and return a reference to that variable.
ProcessVariable
&
findProcessVariable
(
BaseLib
::
ConfigTree
const
&
process_config
,
std
::
string
const
&
tag
,
std
::
vector
<
ProcessVariable
>
const
&
variables
);
///
/// \return a vector of references to the found variable(s).
std
::
vector
<
std
::
reference_wrapper
<
ProcessVariable
>>
findProcessVariables
(
std
::
vector
<
ProcessVariable
>
const
&
variables
,
BaseLib
::
ConfigTree
const
&
process_config
,
std
::
initializer_list
<
std
::
string
>
tag_names
);
/// Find a parameter of specific type for a name given in the process
/// configuration under the tag.
...
...
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