Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
amdis
amdis-core
Commits
bc96d1dc
Commit
bc96d1dc
authored
Feb 08, 2020
by
Praetorius, Simon
Browse files
Cleanup DiscreteFunctions
parent
b749d3f8
Changes
6
Hide whitespace changes
Inline
Side-by-side
src/amdis/common/Tags.hpp
View file @
bc96d1dc
...
...
@@ -11,6 +11,11 @@ namespace AMDiS
struct
matrix
{};
struct
unknown
{};
// tags representing interpolation strategies
struct
average
{};
struct
assign
{};
struct
defaulted
{};
}
// end namespace tag
}
// end namespace AMDiS
src/amdis/functions/Interpolate.hpp
View file @
bc96d1dc
...
...
@@ -12,6 +12,7 @@
#include
<amdis/common/FakeContainer.hpp>
#include
<amdis/common/FieldMatVec.hpp>
#include
<amdis/common/Logical.hpp>
#include
<amdis/common/Tags.hpp>
#include
<amdis/functions/FunctionFromCallable.hpp>
#include
<amdis/functions/HierarchicNodeToRangeMap.hpp>
#include
<amdis/functions/NodeIndices.hpp>
...
...
@@ -22,14 +23,6 @@
namespace
AMDiS
{
namespace
tag
{
struct
average
{};
struct
assign
{};
struct
defaulted
{};
}
// end namespace tag
namespace
Impl
{
template
<
class
B
,
class
Vec
,
class
GF
,
class
TP
,
class
C
,
class
BV
,
class
NTRE
,
class
Assign
>
...
...
src/amdis/gridfunctions/DiscreteFunction.hpp
View file @
bc96d1dc
...
...
@@ -9,7 +9,7 @@
#include
<dune/functions/gridfunctions/gridviewentityset.hh>
#include
<dune/typetree/childextraction.hh>
#include
<amdis/
LinearAlgebra
.hpp>
#include
<amdis/
common/Tags
.hpp>
#include
<amdis/typetree/FiniteElementType.hpp>
#include
<amdis/typetree/RangeType.hpp>
#include
<amdis/typetree/TreePath.hpp>
...
...
@@ -32,18 +32,17 @@ namespace AMDiS
class
DiscreteFunction
;
#if DUNE_HAVE_CXX_CLASS_TEMPLATE_ARGUMENT_DEDUCTION
template
<
class
Coeff
,
class
GB
,
class
TreePath
=
Dune
::
TypeTree
::
Hybrid
TreePath
<
>
>
template
<
class
Coeff
,
class
GB
,
class
TreePath
=
Root
TreePath
>
DiscreteFunction
(
Coeff
&
,
GB
const
&
,
TreePath
=
{})
->
DiscreteFunction
<
Coeff
,
GB
,
TreePath
>
;
->
DiscreteFunction
<
Coeff
,
GB
,
TreePath
_t
<
TreePath
>
>
;
#endif
/// A Generator for a mutable \ref DiscreteFunction
template
<
class
Coeff
,
class
GB
,
class
Path
,
template
<
class
Coeff
,
class
GB
,
class
Path
=
RootTreePath
,
class
=
void_t
<
decltype
(
std
::
declval
<
GB
>().
localView
())
>
>
auto
makeDiscreteFunction
(
Coeff
&
coefficients
,
GB
const
&
basis
,
Path
const
&
path
)
auto
makeDiscreteFunction
(
Coeff
&
coefficients
,
GB
const
&
basis
,
Path
const
&
path
=
{}
)
{
auto
treePath
=
makeTreePath
(
path
);
return
DiscreteFunction
<
Coeff
,
GB
,
decltype
(
treePath
)
>
{
coefficients
,
basis
,
treePath
};
return
DiscreteFunction
<
Coeff
,
GB
,
TreePath_t
<
Path
>>
{
coefficients
,
basis
,
path
};
}
...
...
@@ -61,8 +60,9 @@ namespace AMDiS
public:
/// Constructor. Stores a pointer to the mutable `dofvector`.
DiscreteFunction
(
Coefficients
&
dofVector
,
GlobalBasis
const
&
basis
,
TreePath
const
&
treePath
=
{})
:
Super
(
dofVector
,
basis
,
treePath
)
template
<
class
Path
=
TreePath
>
DiscreteFunction
(
Coefficients
&
dofVector
,
GlobalBasis
const
&
basis
,
Path
const
&
path
=
{})
:
Super
(
dofVector
,
basis
,
path
)
,
mutableCoeff_
(
&
dofVector
)
{}
...
...
@@ -117,7 +117,10 @@ namespace AMDiS
}
/// Return the mutable DOFVector
Coefficients
&
coefficients
()
{
return
*
mutableCoeff_
;
}
Coefficients
&
coefficients
()
{
return
*
mutableCoeff_
;
}
/// Return the const DOFVector
using
Super
::
coefficients
;
...
...
@@ -125,8 +128,8 @@ namespace AMDiS
template
<
class
Path
=
RootTreePath
>
auto
child
(
Path
const
&
path
=
{})
{
auto
&&
tp
=
makeTreePath
(
path
);
return
makeDiscreteFunction
(
*
mutableCoeff_
,
this
->
basis
(),
cat
(
this
->
treePath_
,
tp
)
)
;
auto
tp
=
cat
(
this
->
treePath_
,
makeTreePath
(
path
)
)
;
return
makeDiscreteFunction
(
*
mutableCoeff_
,
this
->
basis
(),
tp
);
}
using
Super
::
child
;
...
...
@@ -142,7 +145,7 @@ namespace AMDiS
private:
using
Coefficients
=
std
::
remove_const_t
<
Coeff
>
;
using
GlobalBasis
=
GB
;
using
ValueType
=
typename
Coeff
::
value_type
;
using
ValueType
=
typename
Coeff
icients
::
value_type
;
using
Tree
=
typename
GlobalBasis
::
LocalView
::
Tree
;
using
SubTree
=
typename
Dune
::
TypeTree
::
ChildForTreePath
<
Tree
,
TreePath
>
;
...
...
@@ -177,12 +180,13 @@ namespace AMDiS
public:
/// Constructor. Stores a pointer to the dofVector and a copy of the treePath.
DiscreteFunction
(
Coefficients
const
&
coefficients
,
GlobalBasis
const
&
basis
,
TreePath
const
&
treePath
=
{})
template
<
class
Path
=
TreePath
>
DiscreteFunction
(
Coefficients
const
&
coefficients
,
GlobalBasis
const
&
basis
,
Path
const
&
path
=
{})
:
coefficients_
(
&
coefficients
)
,
basis_
(
&
basis
)
,
treePath_
(
t
reePath
)
,
treePath_
(
makeT
reePath
(
path
)
)
,
entitySet_
(
basis_
->
gridView
())
,
nodeToRangeEntry_
(
Dune
::
Functions
::
makeDefaultNodeToRangeMap
(
*
basis_
,
treePath
))
,
nodeToRangeEntry_
(
Dune
::
Functions
::
makeDefaultNodeToRangeMap
(
*
basis_
,
treePath
_
))
{}
/// \brief Evaluate DiscreteFunction in global coordinates. NOTE: expensive
...
...
@@ -221,8 +225,8 @@ namespace AMDiS
template
<
class
Path
=
RootTreePath
>
auto
child
(
Path
const
&
path
=
{})
const
{
auto
&&
tp
=
makeTreePath
(
path
);
return
makeDiscreteFunction
(
*
coefficients_
,
*
basis_
,
cat
(
this
->
treePath_
,
tp
)
)
;
auto
tp
=
cat
(
this
->
treePath_
,
makeTreePath
(
path
)
)
;
return
makeDiscreteFunction
(
*
coefficients_
,
*
basis_
,
tp
);
}
protected:
...
...
src/amdis/gridfunctions/DiscreteFunction.inc.hpp
View file @
bc96d1dc
...
...
@@ -6,6 +6,7 @@
#include
<amdis/functions/Interpolate.hpp>
#include
<amdis/gridfunctions/GridFunction.hpp>
#include
<amdis/linearalgebra/VectorFacade.hpp>
namespace
AMDiS
{
...
...
src/amdis/gridfunctions/DiscreteLocalFunction.inc.hpp
View file @
bc96d1dc
#pragma once
#include
<amdis/Output.hpp>
#include
<amdis/common/DerivativeTraits.hpp>
#include
<amdis/common/FieldMatVec.hpp>
#include
<amdis/functions/NodeIndices.hpp>
#include
<amdis/utility/LocalBasisCache.hpp>
#include
<amdis/utility/LocalToGlobalAdapter.hpp>
#include
<dune/common/ftraits.hh>
namespace
AMDiS
{
namespace
Impl
{
// specialization of Coeff has gather method
template
<
class
Coeff
,
class
LocalView
,
class
LocalCoeff
,
class
=
decltype
(
std
::
declval
<
Coeff
>().
gather
(
std
::
declval
<
LocalView
>
(),
std
::
declval
<
LocalCoeff
&>
()))
>
void
gather
(
Coeff
const
&
coeff
,
LocalView
const
&
localView
,
LocalCoeff
&
localCoeff
,
Dune
::
PriorityTag
<
2
>
)
{
coeff
.
gather
(
localView
,
localCoeff
);
}
// fallback implementation
template
<
class
Coeff
,
class
LocalView
,
class
LocalCoeff
>
void
gather
(
Coeff
const
&
coeff
,
LocalView
const
&
localView
,
LocalCoeff
&
localCoeff
,
Dune
::
PriorityTag
<
1
>
)
{
localCoeff
.
resize
(
localView
.
size
());
auto
it
=
localCoeff
.
begin
();
for
(
auto
const
&
idx
:
nodeIndices
(
localView
))
*
it
++
=
coeff
[
idx
];
}
}
// end namespace Impl
template
<
class
Coeff
,
class
GB
,
class
TP
>
class
DiscreteFunction
<
Coeff
const
,
GB
,
TP
>::
LocalFunction
...
...
@@ -42,8 +66,7 @@ public:
void
bind
(
Element
const
&
element
)
{
localView_
.
bind
(
element
);
globalFunction_
.
coefficients
().
gather
(
localView_
,
localCoefficients_
);
Impl
::
gather
(
globalFunction_
.
coefficients
(),
localView_
,
localCoefficients_
,
Dune
::
PriorityTag
<
4
>
{});
bound_
=
true
;
}
...
...
@@ -173,7 +196,7 @@ public:
localView_
.
bind
(
element
);
geometry_
.
emplace
(
element
.
geometry
());
globalFunction_
.
coefficients
()
.
gather
(
localView_
,
localCoefficients_
);
Impl
::
gather
(
globalFunction_
.
coefficients
()
,
localView_
,
localCoefficients_
,
Dune
::
PriorityTag
<
4
>
{}
);
bound_
=
true
;
}
...
...
src/amdis/typetree/TreePath.hpp
View file @
bc96d1dc
...
...
@@ -139,6 +139,10 @@ namespace AMDiS
return
Dune
::
TypeTree
::
hybridTreePath
();
}
/// Type of the generated treepath
template
<
class
PreTreePath
>
using
TreePath_t
=
TYPEOF
(
makeTreePath
(
std
::
declval
<
PreTreePath
>
()));
#endif // DOXYGEN
...
...
Write
Preview
Supports
Markdown
0%
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!
Cancel
Please
register
or
sign in
to comment