Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
amdis
amdis-core
Commits
6b3c8bca
Commit
6b3c8bca
authored
Sep 03, 2020
by
Praetorius, Simon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
make ProblemStat constructible from pre-basis factory
parent
43cefbd6
Pipeline
#4683
failed with stage
in 41 minutes and 54 seconds
Changes
7
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
94 additions
and
34 deletions
+94
-34
amdis/MeshCreator.hpp
amdis/MeshCreator.hpp
+6
-4
amdis/ProblemStat.hpp
amdis/ProblemStat.hpp
+44
-5
amdis/common/Concepts.hpp
amdis/common/Concepts.hpp
+15
-0
amdis/common/TypeTraits.hpp
amdis/common/TypeTraits.hpp
+23
-5
amdis/functions/GlobalIdSet.hpp
amdis/functions/GlobalIdSet.hpp
+1
-1
amdis/functions/ParallelGlobalBasis.hpp
amdis/functions/ParallelGlobalBasis.hpp
+0
-11
examples/convection_diffusion.cc
examples/convection_diffusion.cc
+5
-8
No files found.
amdis/MeshCreator.hpp
View file @
6b3c8bca
...
...
@@ -36,14 +36,16 @@ namespace Dune
namespace
AMDiS
{
/// A creator class for dune grids.
template
<
class
G
rid
>
template
<
class
G
>
struct
MeshCreator
{
enum
{
dimension
=
Grid
::
dimension
};
enum
{
dimworld
=
Grid
::
dimensionworld
};
enum
{
dimension
=
G
::
dimension
};
enum
{
dimworld
=
G
::
dimensionworld
};
using
Grid
=
AdaptiveGrid_t
<
G
>
;
using
HostGrid
=
typename
Grid
::
HostGrid
;
using
ctype
=
typename
Grid
::
ctype
;
using
HostGrid
=
typename
AdaptiveGrid_t
<
Grid
>::
HostGrid
;
/// Construct a new MeshCreator
/**
...
...
amdis/ProblemStat.hpp
View file @
6b3c8bca
...
...
@@ -101,15 +101,27 @@ namespace AMDiS
adoptGrid
(
wrap_or_share
(
FWD
(
grid
)));
}
/// \brief Constructor taking a grid and basis
/// \brief Constructor taking a grid and basis
.
/// Wraps both in shared pointers.
template
<
class
Grid_
,
class
Basis_
>
template
<
class
Grid_
,
class
Basis_
,
class
B_
=
Underlying_t
<
Basis_
>,
REQUIRES
(
Concepts
::
GlobalBasis
<
B_
>
)
>
ProblemStat
(
std
::
string
const
&
name
,
Grid_
&&
grid
,
Basis_
&&
globalBasis
)
:
ProblemStat
(
name
,
FWD
(
grid
))
{
adoptGlobalBasis
(
wrap_or_share
(
FWD
(
globalBasis
)));
}
/// \brief Constructor taking a grid and pre-basis factory to create a global basis
/// on the fly.
template
<
class
Grid_
,
class
PBF_
,
class
GV_
=
typename
Underlying_t
<
Grid_
>
::
LeafGridView
,
REQUIRES
(
Concepts
::
PreBasisFactory
<
PBF_
,
GV_
>
)
>
ProblemStat
(
std
::
string
const
&
name
,
Grid_
&&
grid
,
PBF_
const
&
preBasisFactory
)
:
ProblemStat
(
name
,
FWD
(
grid
))
{
adoptGlobalBasis
(
makeSharedPtr
(
ParallelGlobalBasis
{
grid_
->
leafGridView
(),
preBasisFactory
}));
}
/// \brief Initialisation of the problem.
/**
...
...
@@ -511,10 +523,37 @@ namespace AMDiS
};
namespace
Impl
{
template
<
class
Grid
,
class
B
,
class
=
void
>
struct
DeducedProblemTraits
;
template
<
class
Grid
,
class
PB
>
struct
DeducedProblemTraits
<
Grid
,
ParallelGlobalBasis
<
PB
>
,
void
>
{
using
type
=
DefaultProblemTraits
<
ParallelGlobalBasis
<
PB
>>
;
};
template
<
class
G
,
class
PBF
>
struct
DeducedProblemTraits
<
G
,
PBF
,
std
::
enable_if_t
<
Concepts
::
PreBasisFactory
<
PBF
,
typename
G
::
LeafGridView
>>>
{
using
Grid
=
AdaptiveGrid_t
<
G
>
;
using
GridView
=
typename
Grid
::
LeafGridView
;
using
Basis
=
decltype
(
ParallelGlobalBasis
{
std
::
declval
<
GridView
>
(),
std
::
declval
<
PBF
>
()});
using
type
=
DefaultProblemTraits
<
Basis
>
;
};
template
<
class
Grid
,
class
Basis
>
using
DeducedProblemTraits_t
=
typename
DeducedProblemTraits
<
Grid
,
Basis
>::
type
;
}
// Deduction guide
template
<
class
Grid
,
class
Global
Basis
>
ProblemStat
(
std
::
string
const
&
name
,
Grid
&
grid
,
Global
Basis
&
globalBasis
)
->
ProblemStat
<
DefaultProblemTraits
<
Global
Basis
>>
;
template
<
class
Grid
,
class
Basis
>
ProblemStat
(
std
::
string
name
,
Grid
&
&
grid
,
Basis
&
&
globalBasis
)
->
ProblemStat
<
Impl
::
DeducedProblemTraits_t
<
Underlying_t
<
Grid
>
,
Underlying_t
<
Basis
>>
>
;
// mark templates as explicitly instantiated in cpp file
...
...
amdis/common/Concepts.hpp
View file @
6b3c8bca
...
...
@@ -82,6 +82,15 @@ namespace AMDiS
);
};
template
<
class
MultiIndex
>
struct
PreBasisFactory
{
template
<
class
PBF
,
class
GV
>
auto
require
(
PBF
const
&
pbf
,
GV
const
&
gridView
)
->
decltype
(
pbf
.
template
makePreBasis
<
MultiIndex
>(
gridView
)
);
};
}
// end namespace Definition
#endif // DOXYGEN
...
...
@@ -183,6 +192,12 @@ namespace AMDiS
template
<
class
GB
,
class
GV
=
typename
GB
::
GridView
>
using
GlobalBasis_t
=
models_t
<
Dune
::
Functions
::
Concept
::
GlobalBasis
<
GV
>
(
GB
)
>
;
template
<
class
PBF
,
class
GV
,
class
MultiIndex
=
std
::
array
<
std
::
size_t
,
1
>
>
constexpr
bool
PreBasisFactory
=
models
<
Definition
::
PreBasisFactory
<
MultiIndex
>
(
PBF
,
GV
)
>
;
template
<
class
PBF
,
class
GV
,
class
MultiIndex
=
std
::
array
<
std
::
size_t
,
1
>
>
using
PreBasisFactory_t
=
models_t
<
Definition
::
PreBasisFactory
<
MultiIndex
>
(
PBF
,
GV
)
>
;
/** @} **/
}
// end namespace Concepts
...
...
amdis/common/TypeTraits.hpp
View file @
6b3c8bca
...
...
@@ -28,31 +28,43 @@ namespace AMDiS
template
<
class
T
>
struct
UnderlyingType
{
using
type
=
remove_cvref_t
<
T
>
;
using
type
=
T
;
};
template
<
class
T
>
struct
UnderlyingType
<
const
T
>
{
using
type
=
typename
UnderlyingType
<
T
>::
type
;
};
template
<
class
T
>
struct
UnderlyingType
<
T
&>
{
using
type
=
typename
UnderlyingType
<
T
>::
type
;
};
template
<
class
T
>
struct
UnderlyingType
<
T
*>
{
using
type
=
remove_cvref_t
<
T
>
;
using
type
=
typename
UnderlyingType
<
T
>::
type
;
};
template
<
class
T
>
struct
UnderlyingType
<
std
::
reference_wrapper
<
T
>>
{
using
type
=
remove_cvref_t
<
T
>
;
using
type
=
typename
UnderlyingType
<
T
>::
type
;
};
template
<
class
T
>
struct
UnderlyingType
<
std
::
shared_ptr
<
T
>>
{
using
type
=
remove_cvref_t
<
T
>
;
using
type
=
typename
UnderlyingType
<
T
>::
type
;
};
template
<
class
T
>
struct
UnderlyingType
<
std
::
unique_ptr
<
T
>>
{
using
type
=
remove_cvref_t
<
T
>
;
using
type
=
typename
UnderlyingType
<
T
>::
type
;
};
}
...
...
@@ -97,6 +109,12 @@ namespace AMDiS
return
std
::
make_unique
<
TYPEOF
(
obj
)
>
(
FWD
(
obj
));
}
template
<
class
Obj
>
auto
makeSharedPtr
(
Obj
&&
obj
)
{
return
std
::
make_shared
<
TYPEOF
(
obj
)
>
(
FWD
(
obj
));
}
template
<
bool
...
b
>
using
enable_if_all_t
=
std
::
enable_if_t
<
std
::
is_same_v
<
std
::
integer_sequence
<
bool
,
true
,
b
...
>
,
...
...
amdis/functions/GlobalIdSet.hpp
View file @
6b3c8bca
...
...
@@ -211,7 +211,7 @@ namespace AMDiS
using
GridView
=
typename
PreBasis
::
GridView
;
using
size_type
=
std
::
size_t
;
static_assert
(
Node
::
isLeaf
,
"Generic NodeIdSet implemented for LeafNodes only. Provide a spcialization for your node!"
);
static_assert
(
Node
::
isLeaf
,
"Generic NodeIdSet implemented for LeafNodes only. Provide a sp
e
cialization for your node!"
);
private:
static
constexpr
int
dim
=
GridView
::
template
Codim
<
0
>
::
Entity
::
mydimension
;
...
...
amdis/functions/ParallelGlobalBasis.hpp
View file @
6b3c8bca
...
...
@@ -106,17 +106,6 @@ namespace AMDiS
preBasisFactory
.
template
makePreBasis
<
MultiIndex
<
PBF
>
>
(
gridView
))
{}
/// Converting constructor from dune-functions style basis.
/**
* This will create a new ParallelGlobalBasis. The pre-basis is copied from the constructor
* argument and a new communication object is built.
*/
template
<
class
GB_
,
REQUIRES
(
Concepts
::
GlobalBasis
<
GB_
,
GridView
>)
>
ParallelGlobalBasis
(
std
::
string
const
&
name
,
GB_
&&
from
)
:
ParallelGlobalBasis
(
name
,
from
.
gridView
().
grid
(),
from
.
preBasis
())
{}
/// Construct this global basis with empty name
template
<
class
Arg
,
class
...
Args
,
REQUIRES
(
!
std
::
is_same_v
<
std
::
string
,
remove_cvref_t
<
Arg
>
>
)
>
...
...
examples/convection_diffusion.cc
View file @
6b3c8bca
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <iostream>
#include <amdis/AMDiS.hpp>
...
...
@@ -9,16 +7,15 @@
using
namespace
AMDiS
;
// 1 component with polynomial degree 1
//using Grid = Dune::AlbertaGrid<GRIDDIM, WORLDDIM>;
using
ElliptParam
=
YaspGridBasis
<
GRIDDIM
,
1
>
;
using
ElliptProblem
=
ProblemStat
<
ElliptParam
>
;
int
main
(
int
argc
,
char
**
argv
)
{
Environment
env
(
argc
,
argv
);
ElliptProblem
prob
(
"ellipt"
);
// create a grid by inspecting the initfile parameters
Dune
::
YaspGrid
<
2
>
grid
({
1.0
,
1.0
},
{
4u
,
4u
});
using
namespace
Dune
::
Functions
::
BasisFactory
;
ProblemStat
prob
(
"ellipt"
,
grid
,
lagrange
<
1
>
());
prob
.
initialize
(
INIT_ALL
);
// -div(A*grad(u)) + div(b*u) + c*u = f
...
...
Write
Preview
Markdown
is supported
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