Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
iwr
dune-curvedgrid
Commits
ce73bdd6
Commit
ce73bdd6
authored
Apr 06, 2020
by
Praetorius, Simon
Browse files
generator function and constructor template deduction guides added
parent
43286ee4
Changes
5
Hide whitespace changes
Inline
Side-by-side
dune/curvedsurfacegrid/CMakeLists.txt
View file @
ce73bdd6
...
...
@@ -2,6 +2,7 @@
install
(
FILES
backuprestore.hh
capabilities.hh
concepts.hh
coordfunctionimplementations.hh
coordprovider.hh
curvedsurfacegrid.hh
...
...
dune/curvedsurfacegrid/concepts.hh
0 → 100644
View file @
ce73bdd6
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifndef DUNE_CURVED_SURFACE_GRID_CONCEPTS_HH
#define DUNE_CURVED_SURFACE_GRID_CONCEPTS_HH
#include
<dune/common/concept.hh>
#include
<dune/curvedsurfacegrid/gridfunctions/gridentityset.hh>
#include
<dune/functions/common/functionconcepts.hh>
namespace
Dune
{
namespace
Concept
{
template
<
class
LocalContext
>
struct
LocalFunction
{
using
LocalCoordinate
=
typename
LocalContext
::
Geometry
::
LocalCoordinate
;
template
<
class
LF
>
auto
require
(
LF
&&
lf
)
->
decltype
(
lf
.
bind
(
std
::
declval
<
LocalContext
>
()),
lf
.
unbind
(),
lf
.
localContext
(),
requireConcept
<
Dune
::
Functions
::
Concept
::
Callable
<
LocalCoordinate
>>
(
lf
),
requireConvertible
<
LocalContext
>
(
lf
.
localContext
())
);
};
template
<
class
LF
,
class
LocalContext
>
constexpr
bool
isLocalFunction
()
{
return
models
<
Concept
::
LocalFunction
<
LocalContext
>
,
LF
>
();
}
template
<
class
HostGrid
>
struct
GridFunction
{
using
EntitySet
=
GridEntitySet
<
HostGrid
,
0
>
;
using
LocalContext
=
typename
EntitySet
::
Element
;
using
GlobalCoordinate
=
typename
EntitySet
::
GlobalCoordinate
;
template
<
class
GF
>
auto
require
(
GF
&&
gf
)
->
decltype
(
localFunction
(
gf
),
gf
.
entitySet
(),
requireConcept
<
Dune
::
Functions
::
Concept
::
Callable
<
GlobalCoordinate
>>
(
gf
),
requireConcept
<
LocalFunction
<
LocalContext
>>
(
localFunction
(
gf
))
);
};
template
<
class
GF
,
class
HostGrid
>
constexpr
bool
isGridFunction
()
{
return
models
<
Concept
::
GridFunction
<
HostGrid
>
,
GF
>
();
}
}
// end namespace Concept
}
// end namespace Dune
#endif // DUNE_CURVED_SURFACE_GRID_CONCEPTS_HH
\ No newline at end of file
dune/curvedsurfacegrid/grid.hh
View file @
ce73bdd6
...
...
@@ -8,10 +8,13 @@
#include
<dune/grid/common/grid.hh>
#include
<dune/curvedsurfacegrid/concepts.hh>
#include
<dune/curvedsurfacegrid/gridfamily.hh>
#include
<dune/curvedsurfacegrid/backuprestore.hh>
#include
<dune/curvedsurfacegrid/datahandle.hh>
#include
<dune/curvedsurfacegrid/gridfunctions/analyticgridfunction.hh>
#include
<dune/curvedsurfacegrid/gridfunctions/gridfunction.hh>
#include
<dune/functions/common/functionconcepts.hh>
#include
<dune/grid/geometrygrid/identity.hh>
#include
<dune/grid/geometrygrid/persistentcontainer.hh>
#include
<dune/grid/geometrygrid/grid.hh>
...
...
@@ -47,18 +50,42 @@ namespace Dune
* of a CurvedGeometry.
*
* \tparam GF GridViewFunction defined on a (flat) hostgrid
* \tparam
order
Polynomial order of local lagrange basis functions to use when approximating
* \tparam
ORDER
Polynomial order of local lagrange basis functions to use when approximating
* the curved geometry. [optional]
*
* \nosubgrouping
*/
template
<
class
GF
,
int
order
=
-
1
>
template
<
class
GF
,
int
ORDER
=
-
1
>
class
CurvedSurfaceGrid
;
//! Generator for CurvedSurfaceGrid from a grid-functions
template
<
class
HostGrid
,
class
GF
,
int
ORDER
=
-
1
,
std
::
enable_if_t
<
Dune
::
Concept
::
isGridFunction
<
GF
,
HostGrid
>(),
int
>
=
0
>
auto
curedSurfaceGrid
(
HostGrid
&
hostGrid
,
GF
&&
gridFunction
)
{
static_assert
(
std
::
is_same
<
HostGrid
,
GridOf_t
<
std
::
decay_t
<
GF
>>>::
value
,
"GridFunction must be defined on the HostGrid"
);
return
CurvedSurfaceGrid
<
std
::
decay_t
<
GF
>
,
ORDER
>
{
hostGrid
,
std
::
forward
<
GF
>
(
gridFunction
)};
}
//! Generator for CurvedSurfaceGrid from a callable
template
<
class
HostGrid
,
class
F
,
int
ORDER
=
-
1
,
std
::
enable_if_t
<
not
Dune
::
Concept
::
isGridFunction
<
F
,
HostGrid
>(),
int
>
=
0
>
auto
curedSurfaceGrid
(
HostGrid
&
hostGrid
,
F
&&
callable
)
{
using
GlobalCoordinate
=
typename
GridEntitySet
<
HostGrid
,
0
>::
GlobalCoordinate
;
static_assert
(
Functions
::
Concept
::
isCallable
<
F
,
GlobalCoordinate
>
(),
"Function must be callable"
);
auto
gridFct
=
analyticGridFunction
<
HostGrid
>
(
std
::
forward
<
F
>
(
callable
));
return
CurvedSurfaceGrid
<
decltype
(
gridFct
),
ORDER
>
{
hostGrid
,
std
::
move
(
gridFct
)};
}
template
<
class
GF
,
int
ORDER
>
class
CurvedSurfaceGrid
:
public
CurvedSurfaceGridBase
<
GF
,
order
>
,
public
CGeo
::
BackupRestoreFacilities
<
CurvedSurfaceGrid
<
GF
,
order
>
>
:
public
CurvedSurfaceGridBase
<
GF
,
ORDER
>
,
public
CGeo
::
BackupRestoreFacilities
<
CurvedSurfaceGrid
<
GF
,
ORDER
>
>
{
using
Self
=
CurvedSurfaceGrid
;
using
Super
=
CurvedSurfaceGridBase
<
GF
,
order
>
;
using
Super
=
CurvedSurfaceGridBase
<
GF
,
ORDER
>
;
// friend declarations
template
<
class
,
class
>
friend
class
CGeo
::
IdSet
;
...
...
@@ -66,7 +93,7 @@ namespace Dune
public:
using
GridFunction
=
GF
;
using
GridFamily
=
CGeo
::
GridFamily
<
GF
,
order
>
;
using
GridFamily
=
CGeo
::
GridFamily
<
GF
,
ORDER
>
;
/** \name Traits
* \{ */
...
...
@@ -194,13 +221,19 @@ namespace Dune
* If the gridFunction is passed by (non-const) reference it is stored as a non-destroying shared_ptr.
* Otherwise it is copied or moved into a new object (stored as shared_ptr as well).
*/
template
<
class
GF_
>
CurvedSurfaceGrid
(
HostGrid
&
hostGrid
,
GF_
&&
gridFunction
)
template
<
class
GF_
,
std
::
enable_if_t
<
std
::
is_same
<
GF
,
std
::
decay_t
<
GF_
>
>::
value
,
int
>
=
0
>
CurvedSurfaceGrid
(
HostGrid
&
hostGrid
,
GF_
&&
gridFunction
,
std
::
integral_constant
<
int
,
ORDER
>
=
{})
:
hostGrid_
(
hostGrid
)
,
gridFunction_
(
wrap_or_move
(
std
::
forward
<
GF_
>
(
gridFunction
)))
,
levelIndexSets_
(
hostGrid_
.
maxLevel
()
+
1
,
nullptr
)
{}
template
<
class
F_
,
std
::
enable_if_t
<
std
::
is_same
<
GF
,
AnalyticGridFunction
<
HostGrid
,
std
::
decay_t
<
F_
>
>>::
value
,
int
>
=
0
>
CurvedSurfaceGrid
(
HostGrid
&
hostGrid
,
F_
&&
callable
,
std
::
integral_constant
<
int
,
ORDER
>
=
{})
:
CurvedSurfaceGrid
(
hostGrid
,
analyticGridFunction
<
HostGrid
>
(
std
::
forward
<
F_
>
(
callable
)))
{}
//! destructor
~
CurvedSurfaceGrid
()
...
...
@@ -550,13 +583,18 @@ namespace Dune
mutable
typename
GeometryCache
<
std
::
make_integer_sequence
<
int
,
Traits
::
dimension
+
1
>>::
type
geometryCache_
;
};
//! Deduction guide for CurvedSurfaceGrid from a grid-functions or callables
template
<
class
HostGrid
,
class
GF
,
int
ORDER
=
-
1
>
CurvedSurfaceGrid
(
HostGrid
&
hostGrid
,
GF
&&
gridFunction
,
std
::
integral_constant
<
int
,
ORDER
>
=
{})
->
CurvedSurfaceGrid
<
GridFunctionOf_t
<
HostGrid
,
std
::
decay_t
<
GF
>>
,
ORDER
>
;
// CurvedSurfaceGrid::Codim
// ------------------------
template
<
class
GridFunction
,
int
order
>
template
<
class
GridFunction
,
int
ORDER
>
template
<
int
codim
>
struct
CurvedSurfaceGrid
<
GridFunction
,
order
>::
Codim
struct
CurvedSurfaceGrid
<
GridFunction
,
ORDER
>::
Codim
:
public
Super
::
template
Codim
<
codim
>
{
/** \name Entity types
...
...
dune/curvedsurfacegrid/gridfunctions/gridfunction.hh
View file @
ce73bdd6
...
...
@@ -4,6 +4,8 @@
#define DUNE_CURVED_SURFACE_GRID_GRIDFUNCTION_HH
#include
<type_traits>
#include
<dune/curvedsurfacegrid/concepts.hh>
#include
<dune/curvedsurfacegrid/gridfunctions/analyticgridfunction.hh>
namespace
Dune
{
...
...
@@ -29,6 +31,12 @@ namespace Dune
template
<
class
GF
>
using
GridOf_t
=
typename
Impl
::
GridOf
<
typename
GF
::
EntitySet
>::
type
;
template
<
class
HostGrid
,
class
GF
>
using
GridFunctionOf_t
=
std
::
conditional_t
<
Dune
::
Concept
::
isGridFunction
<
GF
,
HostGrid
>
(),
GF
,
AnalyticGridFunction
<
HostGrid
,
GF
>>
;
}
// end namespace Dune
#endif // DUNE_CURVED_SURFACE_GRID_GRIDFUNCTION_HH
dune/curvedsurfacegrid/test/convergence.cc
View file @
ce73bdd6
...
...
@@ -7,7 +7,6 @@
#include
<iostream>
#include
<dune/common/parallel/mpihelper.hh>
// An initializer of MPI
#include
<dune/curvedsurfacegrid/curvedsurfacegrid.hh>
#include
<dune/curvedsurfacegrid/gridfunctions/analyticgridfunction.hh>
#include
<dune/geometry/quadraturerules.hh>
#include
<dune/grid/io/file/gmshreader.hh>
#include
<dune/localfunctions/lagrange/pk.hh>
...
...
@@ -178,11 +177,9 @@ int main(int argc, char** argv)
return
out
;
}
);
//auto sphereGridFct = Functions::makeAnalyticGridViewFunction(sphere, hostGrid->leafGridView());
auto
sphereGridFct
=
analyticGridFunction
<
HostGrid
>
(
sphere
);
using
Grid
=
CurvedSurfaceGrid
<
decltype
(
sphereGridFct
)
>
;
Grid
grid
(
*
hostGrid
,
sphereGridFct
);
CurvedSurfaceGrid
grid
(
*
hostGrid
,
sphere
)
;
using
Grid
=
decltype
(
grid
);
std
::
vector
<
typename
Grid
::
ctype
>
inf_errors
,
L2_errors
,
normal_errors
,
curvature_errors
,
edge_lengths
;
for
(
int
i
=
0
;
i
<
num_levels
;
++
i
)
{
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment