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
241aa9bf
Commit
241aa9bf
authored
4 years ago
by
Dr. Felix Tobias Schindler
Browse files
Options
Downloads
Patches
Plain Diff
[grid.element] add sub_entity_center to select codim at runtime
parent
761f6186
No related branches found
No related tags found
3 merge requests
!41
Fix compilation with icc, several other changes
,
!39
Make functions copyable
,
!35
dailywork-ftschindler
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dune/xt/grid/element.hh
+76
-0
76 additions, 0 deletions
dune/xt/grid/element.hh
with
76 additions
and
0 deletions
dune/xt/grid/element.hh
0 → 100644
+
76
−
0
View file @
241aa9bf
// This file is part of the dune-xt project:
// https://github.com/dune-community/dune-xt
// Copyright 2009-2020 dune-xt developers and contributors. All rights reserved.
// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)
// or GPL-2.0+ (http://opensource.org/licenses/gpl-license)
// with "runtime exception" (http://www.dune-project.org/license.html)
// Authors:
// Felix Schindler (2020)
#ifndef DUNE_XT_GRID_ELEMENT_HH
#define DUNE_XT_GRID_ELEMENT_HH
#include
<dune/grid/common/entity.hh>
#include
<dune/xt/common/numeric_cast.hh>
#include
<dune/xt/grid/type_traits.hh>
namespace
Dune
{
namespace
XT
{
namespace
Grid
{
template
<
class
E
>
class
SubEntityCenter
{
static_assert
(
is_entity
<
E
>::
value
,
""
);
using
G
=
extract_grid_t
<
E
>
;
using
D
=
typename
G
::
ctype
;
static
const
constexpr
size_t
d
=
G
::
dimension
;
template
<
int
cd
=
d
,
bool
anything
=
true
>
struct
subEntity
{
static
FieldVector
<
D
,
d
>
center
(
const
E
&
element
,
const
int
codim
,
const
size_t
i
)
{
if
(
codim
==
cd
)
{
DUNE_THROW_IF
(
i
>=
element
.
subEntities
(
codim
),
Common
::
Exceptions
::
index_out_of_range
,
"element.subEntities("
<<
codim
<<
") = "
<<
element
.
subEntities
(
codim
)
<<
"
\n
i = "
<<
i
);
return
element
.
subEntity
<
cd
>
(
i
).
geometry
().
center
();
}
else
return
subEntity
<
cd
-
1
>::
center
(
element
,
codim
,
i
);
}
// ... center(...)
};
// struct subEntity
template
<
bool
anything
>
struct
subEntity
<
0
,
anything
>
{
static
FieldVector
<
D
,
d
>
center
(
const
E
&
element
,
const
int
codim
,
const
size_t
i
)
{
DUNE_THROW_IF
(
codim
!=
0
,
Common
::
Exceptions
::
internal_error
,
"This must not happen"
);
return
element
.
subEntity
<
0
>
(
i
).
geometry
().
center
();
}
};
// struct subEntity
public
:
static
FieldVector
<
D
,
d
>
get
(
const
E
&
element
,
const
int
codim
,
const
size_t
i
)
{
return
subEntity
<>::
center
(
element
,
codim
,
i
);
}
};
// class SubEntityCenter
template
<
int
dim
,
class
GridImp
,
template
<
int
,
int
,
class
>
class
EntityImp
>
FieldVector
<
typename
GridImp
::
ctype
,
GridImp
::
dimension
>
sub_entity_center
(
const
Dune
::
Entity
<
0
,
dim
,
GridImp
,
EntityImp
>
element
,
const
int
codim
,
const
size_t
i
)
{
return
SubEntityCenter
<
Dune
::
Entity
<
0
,
dim
,
GridImp
,
EntityImp
>>::
get
(
element
,
codim
,
i
);
}
}
// namespace Grid
}
// namespace XT
}
// namespace Dune
#endif // DUNE_XT_GRID_ELEMENT_HH
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