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
6a7e53cd
Commit
6a7e53cd
authored
6 years ago
by
Dmitri Naumov
Browse files
Options
Downloads
Patches
Plain Diff
[PL] PV: Extract findMeshInConfig().
Removing most of the code duplication in the BCs/STs creation.
parent
7fb10158
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ProcessLib/ProcessVariable.cpp
+57
-66
57 additions, 66 deletions
ProcessLib/ProcessVariable.cpp
with
57 additions
and
66 deletions
ProcessLib/ProcessVariable.cpp
+
57
−
66
View file @
6a7e53cd
...
...
@@ -19,6 +19,59 @@
#include
"ProcessLib/SourceTerms/NodalSourceTerm.h"
#include
"ProcessLib/Utils/ProcessUtils.h"
namespace
{
MeshLib
::
Mesh
const
&
findMeshInConfig
(
BaseLib
::
ConfigTree
const
&
config
,
std
::
vector
<
std
::
unique_ptr
<
MeshLib
::
Mesh
>>
const
&
meshes
)
{
//
// Get the mesh name from the config.
//
std
::
string
mesh_name
;
// Either given directly in <mesh> or constructed
// from <geometrical_set>_<geometry>.
auto
optional_mesh_name
=
//! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__mesh}
config
.
getConfigParameterOptional
<
std
::
string
>
(
"mesh"
);
if
(
optional_mesh_name
)
{
mesh_name
=
*
optional_mesh_name
;
}
else
{
// Looking for the mesh created before for the given geometry.
auto
const
geometrical_set_name
=
//! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__geometrical_set}
config
.
getConfigParameter
<
std
::
string
>
(
"geometrical_set"
);
auto
const
geometry_name
=
//! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__geometry}
config
.
getConfigParameter
<
std
::
string
>
(
"geometry"
);
mesh_name
=
geometrical_set_name
+
"_"
+
geometry_name
;
}
//
// Find and extract mesh from the list of meshes.
//
auto
const
mesh_it
=
std
::
find_if
(
begin
(
meshes
),
end
(
meshes
),
[
&
mesh_name
](
auto
const
&
mesh
)
{
assert
(
mesh
!=
nullptr
);
return
mesh
->
getName
()
==
mesh_name
;
});
if
(
mesh_it
==
end
(
meshes
))
{
OGS_FATAL
(
"Required mesh with name '%s' not found."
,
mesh_name
.
c_str
());
}
auto
const
&
mesh
=
**
mesh_it
;
DBUG
(
"Found mesh '%s' with id %d."
,
mesh
.
getName
().
c_str
(),
mesh
.
getID
());
return
mesh
;
}
}
// namespace
namespace
ProcessLib
{
ProcessVariable
::
ProcessVariable
(
...
...
@@ -51,43 +104,7 @@ ProcessVariable::ProcessVariable(
//! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition}
bcs_config
->
getConfigSubtreeList
(
"boundary_condition"
))
{
std
::
string
bc_mesh_name
;
// Either given directly in <mesh> or constructed
// from <geometrical_set>_<geometry>.
auto
optional_bc_mesh_name
=
bc_config
.
getConfigParameterOptional
<
std
::
string
>
(
"mesh"
);
if
(
optional_bc_mesh_name
)
{
bc_mesh_name
=
*
optional_bc_mesh_name
;
}
else
{
// Looking for the mesh created before for the given geometry.
auto
const
geometrical_set_name
=
//! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__geometrical_set}
bc_config
.
getConfigParameter
<
std
::
string
>
(
"geometrical_set"
);
auto
const
geometry_name
=
//! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__geometry}
bc_config
.
getConfigParameter
<
std
::
string
>
(
"geometry"
);
bc_mesh_name
=
geometrical_set_name
+
"_"
+
geometry_name
;
}
auto
const
mesh_it
=
std
::
find_if
(
begin
(
meshes
),
end
(
meshes
),
[
&
bc_mesh_name
](
auto
const
&
mesh
)
{
assert
(
mesh
!=
nullptr
);
return
mesh
->
getName
()
==
bc_mesh_name
;
});
if
(
mesh_it
==
end
(
meshes
))
{
OGS_FATAL
(
"Required mesh with name '%s' not found."
,
bc_mesh_name
.
c_str
());
}
MeshLib
::
Mesh
const
&
bc_mesh
=
**
mesh_it
;
DBUG
(
"Found mesh '%s' with id %d."
,
bc_mesh
.
getName
().
c_str
(),
bc_mesh
.
getID
());
auto
const
&
mesh
=
findMeshInConfig
(
bc_config
,
meshes
);
auto
component_id
=
//! \ogs_file_param{prj__process_variables__process_variable__boundary_conditions__boundary_condition__component}
bc_config
.
getConfigParameterOptional
<
int
>
(
"component"
);
...
...
@@ -96,8 +113,7 @@ ProcessVariable::ProcessVariable(
// default value for single component vars.
component_id
=
0
;
_bc_configs
.
emplace_back
(
std
::
move
(
bc_config
),
bc_mesh
,
component_id
);
_bc_configs
.
emplace_back
(
std
::
move
(
bc_config
),
mesh
,
component_id
);
}
}
else
{
INFO
(
"No boundary conditions found."
);
...
...
@@ -111,32 +127,7 @@ ProcessVariable::ProcessVariable(
//! \ogs_file_param{prj__process_variables__process_variable__source_terms__source_term}
sts_config
->
getConfigSubtreeList
(
"source_term"
))
{
// TODO (naumov) Remove code duplication with the bc_config parsing.
auto
const
geometrical_set_name
=
//! \ogs_file_param{prj__process_variables__process_variable__source_terms__source_term__geometrical_set}
st_config
.
getConfigParameter
<
std
::
string
>
(
"geometrical_set"
);
auto
const
geometry_name
=
//! \ogs_file_param{prj__process_variables__process_variable__source_terms__source_term__geometry}
st_config
.
getConfigParameter
<
std
::
string
>
(
"geometry"
);
auto
const
full_geometry_name
=
geometrical_set_name
+
"_"
+
geometry_name
;
auto
const
mesh_it
=
std
::
find_if
(
begin
(
meshes
),
end
(
meshes
),
[
&
full_geometry_name
](
auto
const
&
mesh
)
{
assert
(
mesh
!=
nullptr
);
return
mesh
->
getName
()
==
full_geometry_name
;
});
if
(
mesh_it
==
end
(
meshes
))
{
OGS_FATAL
(
"Required mesh with name '%s' not found."
,
full_geometry_name
.
c_str
());
}
MeshLib
::
Mesh
const
&
bc_mesh
=
**
mesh_it
;
DBUG
(
"Found mesh '%s' with id %d."
,
bc_mesh
.
getName
().
c_str
(),
bc_mesh
.
getID
());
MeshLib
::
Mesh
const
&
mesh
=
findMeshInConfig
(
st_config
,
meshes
);
auto
component_id
=
//! \ogs_file_param{prj__process_variables__process_variable__source_terms__source_term__component}
st_config
.
getConfigParameterOptional
<
int
>
(
"component"
);
...
...
@@ -145,7 +136,7 @@ ProcessVariable::ProcessVariable(
// default value for single component vars.
component_id
=
0
;
_source_term_configs
.
emplace_back
(
std
::
move
(
st_config
),
bc_
mesh
,
_source_term_configs
.
emplace_back
(
std
::
move
(
st_config
),
mesh
,
component_id
);
}
}
else
{
...
...
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