Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs-feliks
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
Feliks Kiszkurno
ogs-feliks
Commits
496bb2c0
Commit
496bb2c0
authored
9 years ago
by
Dmitri Naumov
Browse files
Options
Downloads
Patches
Plain Diff
[PL] Add MeshPropertyInitialCondition.
parent
f0a5dad7
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/InitialCondition.cpp
+30
-0
30 additions, 0 deletions
ProcessLib/InitialCondition.cpp
ProcessLib/InitialCondition.h
+32
-0
32 additions, 0 deletions
ProcessLib/InitialCondition.h
ProcessLib/ProcessVariable.cpp
+5
-0
5 additions, 0 deletions
ProcessLib/ProcessVariable.cpp
with
67 additions
and
0 deletions
ProcessLib/InitialCondition.cpp
+
30
−
0
View file @
496bb2c0
...
@@ -36,4 +36,34 @@ std::unique_ptr<InitialCondition> createUniformInitialCondition(
...
@@ -36,4 +36,34 @@ std::unique_ptr<InitialCondition> createUniformInitialCondition(
new
UniformInitialCondition
(
*
value
));
new
UniformInitialCondition
(
*
value
));
}
}
std
::
unique_ptr
<
InitialCondition
>
createMeshPropertyInitialCondition
(
ConfigTree
const
&
config
,
MeshLib
::
Mesh
const
&
mesh
)
{
auto
field_name
=
config
.
get_optional
<
std
::
string
>
(
"field_name"
);
if
(
!
field_name
)
{
ERR
(
"Could not find required parameter field_name."
);
std
::
abort
();
}
DBUG
(
"Using field_name %s"
,
field_name
->
c_str
());
if
(
!
mesh
.
getProperties
().
hasPropertyVector
(
*
field_name
))
{
ERR
(
"The required property %s does not exists in the mesh."
,
field_name
->
c_str
());
std
::
abort
();
}
auto
const
&
property
=
mesh
.
getProperties
().
template
getPropertyVector
<
double
>(
*
field_name
);
if
(
!
property
)
{
ERR
(
"The required property %s is not of the requested type."
,
field_name
->
c_str
());
std
::
abort
();
}
return
std
::
unique_ptr
<
InitialCondition
>
(
new
MeshPropertyInitialCondition
(
*
property
));
}
}
// namespace ProcessLib
}
// namespace ProcessLib
This diff is collapsed.
Click to expand it.
ProcessLib/InitialCondition.h
+
32
−
0
View file @
496bb2c0
...
@@ -10,10 +10,18 @@
...
@@ -10,10 +10,18 @@
#ifndef PROCESS_LIB_INITIAL_CONDITION_H_
#ifndef PROCESS_LIB_INITIAL_CONDITION_H_
#define PROCESS_LIB_INITIAL_CONDITION_H_
#define PROCESS_LIB_INITIAL_CONDITION_H_
#include
<cassert>
#include
<boost/property_tree/ptree_fwd.hpp>
#include
<boost/property_tree/ptree_fwd.hpp>
#include
"MeshLib/Node.h"
#include
"MeshLib/Node.h"
#include
"MeshLib/PropertyVector.h"
#include
"MeshLib/PropertyVector.h"
namespace
MeshLib
{
template
<
typename
>
class
PropertyVector
;
class
Mesh
;
}
namespace
ProcessLib
namespace
ProcessLib
{
{
/// The InitialCondition is a base class for spatial distributions of values
/// The InitialCondition is a base class for spatial distributions of values
...
@@ -47,6 +55,30 @@ using ConfigTree = boost::property_tree::ptree;
...
@@ -47,6 +55,30 @@ using ConfigTree = boost::property_tree::ptree;
std
::
unique_ptr
<
InitialCondition
>
createUniformInitialCondition
(
std
::
unique_ptr
<
InitialCondition
>
createUniformInitialCondition
(
ConfigTree
const
&
config
);
ConfigTree
const
&
config
);
/// Distribution of values given by a mesh property defined on nodes.
class
MeshPropertyInitialCondition
:
public
InitialCondition
{
public:
MeshPropertyInitialCondition
(
MeshLib
::
PropertyVector
<
double
>
const
&
property
)
:
_property
(
property
)
{
assert
(
_property
.
getMeshItemType
()
==
MeshLib
::
MeshItemType
::
Node
);
}
virtual
double
getValue
(
MeshLib
::
Node
const
&
n
)
const
override
{
return
_property
[
n
.
getID
()];
}
private
:
MeshLib
::
PropertyVector
<
double
>
const
&
_property
;
};
/// Construct a MeshPropertyInitialCondition from configuration.
std
::
unique_ptr
<
InitialCondition
>
createMeshPropertyInitialCondition
(
ConfigTree
const
&
config
,
MeshLib
::
Mesh
const
&
mesh
);
}
// namespace ProcessLib
}
// namespace ProcessLib
#endif // PROCESS_LIB_INITIAL_CONDITION_H_
#endif // PROCESS_LIB_INITIAL_CONDITION_H_
This diff is collapsed.
Click to expand it.
ProcessLib/ProcessVariable.cpp
+
5
−
0
View file @
496bb2c0
...
@@ -40,6 +40,11 @@ ProcessVariable::ProcessVariable(ConfigTree const& config,
...
@@ -40,6 +40,11 @@ ProcessVariable::ProcessVariable(ConfigTree const& config,
_initial_condition
=
_initial_condition
=
createUniformInitialCondition
(
ic_config
->
second
);
createUniformInitialCondition
(
ic_config
->
second
);
}
}
if
(
type
==
"MeshProperty"
)
{
_initial_condition
=
createMeshPropertyInitialCondition
(
ic_config
->
second
,
_mesh
);
}
else
else
{
{
ERR
(
"Unknown type of the initial condition."
);
ERR
(
"Unknown type of the initial condition."
);
...
...
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