Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dune-xt
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
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
ag-ohlberger
dune-community
dune-xt
Commits
261e7012
Commit
261e7012
authored
7 years ago
by
Dr. Felix Tobias Schindler
Browse files
Options
Downloads
Patches
Plain Diff
[boundaryinfo.normalbased] implement create()
parent
7f76bf77
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
dune/xt/grid/boundaryinfo/normalbased.hh
+67
-6
67 additions, 6 deletions
dune/xt/grid/boundaryinfo/normalbased.hh
dune/xt/grid/exceptions.hh
+5
-0
5 additions, 0 deletions
dune/xt/grid/exceptions.hh
with
72 additions
and
6 deletions
dune/xt/grid/boundaryinfo/normalbased.hh
+
67
−
6
View file @
261e7012
...
...
@@ -17,6 +17,7 @@
#include
<dune/xt/common/configuration.hh>
#include
<dune/xt/common/exceptions.hh>
#include
<dune/xt/common/memory.hh>
#include
<dune/xt/grid/exceptions.hh>
#include
"interfaces.hh"
#include
"types.hh"
...
...
@@ -30,12 +31,14 @@ static inline Common::Configuration normalbased_boundaryinfo_default_config()
{
Common
::
Configuration
config
;
config
[
"type"
]
=
"xt.grid.boundaryinfo.normalbased"
;
config
[
"default"
]
=
"dirichlet"
;
config
[
"default"
]
=
NoBoundary
().
id
()
;
config
[
"compare_tolerance"
]
=
"1e-10"
;
config
[
"neumann.0"
]
=
"[1 0 0 0]"
;
config
[
"0."
+
DirichletBoundary
().
id
()]
=
"[1 0 0 0]"
;
config
[
"1."
+
NeumannBoundary
().
id
()]
=
"[0 1 0 0]"
;
return
config
;
}
// We do not want to add a virtual destructor (to be able to use this as constexpr),
// so just silence the warning.
#if (defined(BOOST_CLANG) && BOOST_CLANG) || (defined(BOOST_GCC) && BOOST_GCC)
...
...
@@ -72,12 +75,70 @@ public:
DUNE_THROW
(
NotImplemented
,
"Until we have a factory for BoundaryTypes!"
);
const
Common
::
Configuration
default_cfg
=
normalbased_boundaryinfo_default_config
();
// get tolerance and default
const
DomainFieldType
tol
=
cfg
.
get
(
"compare_tolerance"
,
default_cfg
.
get
<
DomainFieldType
>
(
"compare_tolerance"
));
// ...
const
auto
tol
=
cfg
.
get
(
"compare_tolerance"
,
default_cfg
.
get
<
DomainFieldType
>
(
"compare_tolerance"
));
const
auto
default_type
=
cfg
.
get
(
"default"
,
default_cfg
.
get
<
std
::
string
>
(
"default"
));
// create
auto
ret
=
std
::
make_unique
<
ThisType
>
(
tol
/*,
default
=*/
);
auto
ret
=
std
::
make_unique
<
ThisType
>
(
tol
,
make_boundary_type
(
default
_type
)
);
// get other normals and boundary types and register
// ...
bool
search_for_types
=
true
;
size_t
counter
=
0
;
std
::
unique_ptr
<
BoundaryType
>
boundary_type
(
nullptr
);
WorldType
normal
;
while
(
search_for_types
)
{
if
(
cfg
.
has_sub
(
Common
::
to_string
(
counter
)))
{
const
Common
::
Configuration
sub_cfg
=
cfg
.
sub
(
Common
::
to_string
(
counter
));
if
(
sub_cfg
.
getValueKeys
().
size
()
!=
1
)
DUNE_THROW
(
Exceptions
::
boundary_info_error
,
"while processing sub config "
<<
counter
<<
" of cfg (see below): could not parse give config."
<<
"For each normal, you have to provide a sub config with exactly "
"one key/value pair, where the key determines the BoundaryType "
"and the value determines the normal (see below for a valid default config)."
<<
"
\n\n
This was the given config:
\n
"
<<
cfg
<<
"
\n\n
This is a suitable default config:
\n
"
<<
default_cfg
);
const
auto
boundary_type_key
=
sub_cfg
.
getValueKeys
()[
0
];
try
{
boundary_type
=
std
::
unique_ptr
<
BoundaryType
>
(
make_boundary_type
(
boundary_type_key
));
}
catch
(
const
Exceptions
::
boundary_type_error
&
ee
)
{
DUNE_THROW
(
Exceptions
::
boundary_info_error
,
"while processing sub config "
<<
counter
<<
" of cfg (see below): given key is not a valid BoundaryType (see below for the original error)."
<<
"For each normal, you have to provide a sub config with exactly "
"one key/value pair, where the key determines the BoundaryType "
"and the value determines the normal (see below for a valid default config)."
<<
"
\n\n
This was the given config:
\n
"
<<
cfg
<<
"
\n\n
This is a suitable default config:
\n
"
<<
default_cfg
<<
"
\n
n This was the original error:
\n
"
<<
ee
.
what
());
}
try
{
normal
=
sub_cfg
.
get
<
WorldType
>
(
boundary_type_key
);
}
catch
(
const
Common
::
Exceptions
::
configuration_error
&
ee
)
{
DUNE_THROW
(
Exceptions
::
boundary_info_error
,
"while processing sub config "
<<
counter
<<
" of cfg (see below): given value is not a valid normal (see below for the original error)."
<<
"For each normal, you have to provide a sub config with exactly "
"one key/value pair, where the key determines the BoundaryType "
"and the value determines the normal (see below for a valid default config)."
<<
"
\n\n
This was the given config:
\n
"
<<
cfg
<<
"
\n\n
This is a suitable default config:
\n
"
<<
default_cfg
<<
"
\n
n This was the original error:
\n
"
<<
ee
.
what
());
}
ret
->
register_new_normal
(
normal
,
boundary_type
->
copy
());
}
++
counter
;
}
// return
return
ret
;
}
// ... create(...)
...
...
This diff is collapsed.
Click to expand it.
dune/xt/grid/exceptions.hh
+
5
−
0
View file @
261e7012
...
...
@@ -23,6 +23,11 @@ class boundary_type_error : public Dune::Exception
};
class
boundary_info_error
:
public
Dune
::
Exception
{
};
}
// namespace Exceptions
}
// namespace Grid
}
// namespace XT
...
...
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