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
amdis
amdis-core
Commits
52d5d039
Commit
52d5d039
authored
Oct 23, 2018
by
Praetorius, Simon
Browse files
Merge branch 'feature/dofvector_global_evaluation' into 'develop'
Feature/dofvector global evaluation See merge request spraetor/dune-amdis!48
parents
4fa922eb
f9bee36d
Changes
10
Hide whitespace changes
Inline
Side-by-side
src/amdis/FileWriter.hpp
View file @
52d5d039
...
...
@@ -12,7 +12,7 @@
#include
<amdis/Initfile.hpp>
#include
<amdis/common/Size.hpp>
#include
<amdis/common/ValueCategory.hpp>
#include
<amdis/gridfunctions/D
OFVectorView
.hpp>
#include
<amdis/gridfunctions/D
iscreteFunction
.hpp>
#include
<amdis/io/FileWriterInterface.hpp>
#include
<amdis/utility/Filesystem.hpp>
...
...
@@ -43,14 +43,17 @@ namespace AMDiS
constexpr
std
::
size_t
VTKFieldSize
=
Size
<
Range
>
;
template
<
class
G
lobalBasis
,
class
RangeType
,
class
T
reePath
>
template
<
class
G
B
,
class
VT
,
class
T
P
>
class
FileWriter
:
public
FileWriterInterface
{
private:
// typedefs and static constants
using
GlobalBasis
=
GB
;
using
ValueType
=
VT
;
using
TreePath
=
TP
;
private:
using
GridView
=
typename
GlobalBasis
::
GridView
;
using
Vector
=
DOFVectorConstView
<
GlobalBasis
,
RangeType
,
TreePath
>
;
using
Range
=
typename
Vector
::
Range
;
using
Range
=
typename
DiscreteFunction
<
GB
,
VT
,
TP
>::
Range
;
/// Dimension of the mesh
static
constexpr
int
dim
=
GridView
::
dimension
;
...
...
@@ -60,33 +63,32 @@ namespace AMDiS
public:
/// Constructor.
FileWriter
(
std
::
string
const
&
baseName
,
Vector
const
&
dofvector
)
:
FileWriterInterface
(
baseName
)
,
dofvector_
(
dofvector
)
FileWriter
(
std
::
string
const
&
name
,
DiscreteFunction
<
GB
,
VT
,
TP
>
const
&
discreteFct
)
:
FileWriterInterface
(
name
)
,
discreteFct_
(
discreteFct
)
,
animation_
(
false
)
{
Parameters
::
get
(
baseN
ame
+
"->ParaView animation"
,
animation_
);
Parameters
::
get
(
n
ame
+
"->ParaView animation"
,
animation_
);
int
m
=
Parameters
::
get
<
int
>
(
baseN
ame
+
"->ParaView mode"
).
value_or
(
0
);
int
m
=
Parameters
::
get
<
int
>
(
n
ame
+
"->ParaView mode"
).
value_or
(
0
);
mode_
=
(
m
==
0
?
Dune
::
VTK
::
ascii
:
Dune
::
VTK
::
appendedraw
);
init
(
baseN
ame
,
ValueCategory_t
<
Range
>
{});
init
(
n
ame
,
ValueCategory_t
<
Range
>
{});
}
template
<
class
ValueCat
>
void
init
(
std
::
string
const
&
baseName
,
ValueCat
)
{
int
subSampling
=
Parameters
::
get
<
int
>
(
baseName
+
"->subsampling"
)
.
value_or
(
0
)
;
if
(
subSampling
>
0
)
vtkWriter_
=
std
::
make_shared
<
Dune
::
SubsamplingVTKWriter
<
GridView
>>
(
gridView
(),
subSampling
);
auto
subSampling
=
Parameters
::
get
<
int
>
(
baseName
+
"->subsampling"
);
if
(
subSampling
)
vtkWriter_
=
std
::
make_shared
<
Dune
::
SubsamplingVTKWriter
<
GridView
>>
(
gridView
(),
subSampling
.
value
()
);
else
vtkWriter_
=
std
::
make_shared
<
Dune
::
VTKWriter
<
GridView
>>
(
gridView
());
if
(
animation_
)
vtkSeqWriter_
=
std
::
make_shared
<
Dune
::
VTKSequenceWriter
<
GridView
>>
(
vtkWriter_
,
filename_
,
dir_
,
""
);
vtkWriter_
->
addVertexData
(
d
ofvector
_
,
Dune
::
VTK
::
FieldInfo
(
name_
,
VTKFieldType
<
Range
>
,
VTKFieldSize
<
Range
>
));
vtkWriter_
->
addVertexData
(
d
iscreteFct
_
,
Dune
::
VTK
::
FieldInfo
(
name_
,
VTKFieldType
<
Range
>
,
VTKFieldSize
<
Range
>
));
}
void
init
(
std
::
string
const
&
,
tag
::
unknown
)
{}
...
...
@@ -105,11 +107,11 @@ namespace AMDiS
protected:
GridView
const
&
gridView
()
const
{
return
d
ofvector
_
.
basis
().
gridView
();
return
d
iscreteFct
_
.
basis
().
gridView
();
}
private:
Vector
dofvector
_
;
DiscreteFunction
<
GB
,
VT
,
TP
>
discreteFct
_
;
std
::
shared_ptr
<
Dune
::
VTKWriter
<
GridView
>>
vtkWriter_
;
std
::
shared_ptr
<
Dune
::
VTKSequenceWriter
<
GridView
>>
vtkSeqWriter_
;
...
...
@@ -122,12 +124,12 @@ namespace AMDiS
};
template
<
class
GlobalBasis
,
class
Rang
e
,
class
TreePath
>
std
::
shared_ptr
<
FileWriter
<
GlobalBasis
,
Rang
e
,
TreePath
>>
makeFileWriterPtr
(
std
::
string
baseN
ame
,
D
OFVectorConstView
<
GlobalBasis
,
Rang
e
,
TreePath
>
const
&
d
ofvector
)
template
<
class
GlobalBasis
,
class
ValueTyp
e
,
class
TreePath
>
std
::
shared_ptr
<
FileWriter
<
GlobalBasis
,
ValueTyp
e
,
TreePath
>>
makeFileWriterPtr
(
std
::
string
const
&
n
ame
,
D
iscreteFunction
<
GlobalBasis
,
ValueTyp
e
,
TreePath
>
const
&
d
iscreteFct
)
{
return
std
::
make_shared
<
FileWriter
<
GlobalBasis
,
Rang
e
,
TreePath
>>
(
baseN
ame
,
d
ofvector
);
return
std
::
make_shared
<
FileWriter
<
GlobalBasis
,
ValueTyp
e
,
TreePath
>>
(
n
ame
,
d
iscreteFct
);
}
}
// end namespace AMDiS
src/amdis/ProblemStat.hpp
View file @
52d5d039
...
...
@@ -32,6 +32,7 @@
#include
<amdis/common/Utility.hpp>
#include
<amdis/GridFunctions.hpp>
#include
<amdis/gridfunctions/DiscreteFunction.hpp>
#include
<amdis/gridfunctions/DOFVectorView.hpp>
#include
<amdis/io/FileWriterInterface.hpp>
...
...
@@ -198,7 +199,7 @@ namespace AMDiS
auto
getSolution
(
TreePath
const
&
path
=
{})
const
{
auto
&&
tp
=
makeTreePath
(
path
);
return
makeD
OFVectorView
(
*
solution_
,
tp
);
return
makeD
iscreteFunction
(
*
solution_
,
tp
);
}
...
...
src/amdis/gridfunctions/CMakeLists.txt
View file @
52d5d039
...
...
@@ -5,8 +5,9 @@ install(FILES
ConstantGridFunction.hpp
CoordsGridFunction.hpp
DerivativeGridFunction.hpp
DiscreteFunction.hpp
DiscreteFunction.inc.hpp
DOFVectorView.hpp
DOFVectorView.inc.hpp
FunctorGridFunction.hpp
GridFunctionConcepts.hpp
Integrate.hpp
...
...
src/amdis/gridfunctions/DOFVectorView.hpp
View file @
52d5d039
#pragma once
#include
<vector>
#include
<dune/common/std/optional.hh>
#include
<dune/functions/common/defaultderivativetraits.hh>
#include
<dune/functions/common/treedata.hh>
#include
<dune/functions/functionspacebases/defaultnodetorangemap.hh>
#include
<dune/functions/functionspacebases/flatvectorview.hh>
#include
<dune/functions/gridfunctions/gridviewentityset.hh>
#include
<dune/typetree/childextraction.hh>
#include
<amdis/GridFunctions.hpp>
#include
<amdis/
utility/FiniteElementType
.hpp>
#include
<amdis/
gridfunctions/DiscreteFunction
.hpp>
namespace
AMDiS
{
/**
* \addtogroup GridFunctions
* @{
**/
template
<
class
GlobalBasisType
,
class
RangeType
,
class
TreePathType
>
class
DOFVectorConstView
/// A mutable view on the subspace of a DOFVector, \relates DiscreteFunction
template
<
class
GB
,
class
VT
,
class
TP
>
class
DOFVectorView
:
public
DiscreteFunction
<
GB
,
VT
,
TP
>
{
public:
using
GlobalBasis
=
GlobalBasisType
;
using
TreePath
=
TreePathType
;
using
Tree
=
typename
GlobalBasis
::
LocalView
::
Tree
;
using
SubTree
=
typename
Dune
::
TypeTree
::
ChildForTreePath
<
Tree
,
TreePath
>
;
using
NodeToRangeEntry
=
Dune
::
Functions
::
DefaultNodeToRangeMap
<
SubTree
>
;
using
GridView
=
typename
GlobalBasis
::
GridView
;
using
EntitySet
=
Dune
::
Functions
::
GridViewEntitySet
<
GridView
,
0
>
;
using
Domain
=
typename
EntitySet
::
GlobalCoordinate
;
using
Range
=
RangeType_t
<
SubTree
>
;
static_assert
(
std
::
is_arithmetic
<
RangeType
>::
value
,
""
);
// Don't know how to determine Range with non-trivial RangeType
using
RawSignature
=
typename
Dune
::
Functions
::
SignatureTraits
<
Range
(
Domain
)
>::
RawSignature
;
using
DerivativeTraits
=
Dune
::
Functions
::
DefaultDerivativeTraits
<
RawSignature
>
;
using
DerivativeRange
=
typename
DerivativeTraits
::
Range
;
using
LocalDomain
=
typename
EntitySet
::
LocalCoordinate
;
using
Element
=
typename
EntitySet
::
Element
;
using
Geometry
=
typename
Element
::
Geometry
;
enum
{
hasDerivative
=
false
};
public:
// a local view on the gradients
/// A LocalFunction representing the derivative of the DOFVector
class
GradientLocalFunction
{
public:
using
Domain
=
LocalDomain
;
using
Range
=
DerivativeRange
;
enum
{
hasDerivative
=
false
};
private:
using
LocalView
=
typename
GlobalBasis
::
LocalView
;
template
<
class
LeafNode
>
using
LocalBasisJacobian
=
typename
LeafNode
::
FiniteElement
::
Traits
::
LocalBasisType
::
Traits
::
JacobianType
;
template
<
class
Node
>
using
NodeData
=
typename
std
::
vector
<
LocalBasisJacobian
<
Node
>>
;
using
ReferenceGradientContainer
=
Dune
::
Functions
::
TreeData
<
SubTree
,
NodeData
,
true
>
;
public:
GradientLocalFunction
(
DOFVectorConstView
const
&
globalFunction
)
:
globalFunction_
(
&
globalFunction
)
,
localView_
(
globalFunction_
->
basis
().
localView
())
,
subTree_
(
&
Dune
::
TypeTree
::
child
(
localView_
.
tree
(),
globalFunction_
->
treePath
()))
{
referenceGradientContainer_
.
init
(
*
subTree_
);
}
void
bind
(
Element
const
&
element
)
{
localView_
.
bind
(
element
);
geometry_
.
emplace
(
element
.
geometry
());
bound_
=
true
;
}
void
unbind
()
{
localView_
.
unbind
();
geometry_
.
reset
();
bound_
=
false
;
}
/// Evaluate Gradient at bound element in local coordinates
Range
operator
()(
Domain
const
&
x
)
const
;
friend
int
order
(
GradientLocalFunction
const
&
self
)
{
assert
(
self
.
bound_
);
return
std
::
max
(
0
,
polynomialDegree
(
*
self
.
subTree_
)
-
1
);
}
/// Return the bound element
Element
const
&
localContext
()
const
{
assert
(
bound_
);
return
localView_
.
element
();
}
private:
DOFVectorConstView
const
*
globalFunction_
;
LocalView
localView_
;
SubTree
const
*
subTree_
;
mutable
ReferenceGradientContainer
referenceGradientContainer_
;
Dune
::
Std
::
optional
<
Geometry
>
geometry_
;
bool
bound_
=
false
;
};
public:
// a local view on the values
/// A LocalFunction, i.e., an element local view on the DOFVector
class
LocalFunction
{
public:
using
Domain
=
typename
DOFVectorConstView
::
LocalDomain
;
using
Range
=
typename
DOFVectorConstView
::
Range
;
enum
{
hasDerivative
=
true
};
private:
using
LocalView
=
typename
GlobalBasis
::
LocalView
;
template
<
class
LeafNode
>
using
LocalBasisRange
=
RangeType_t
<
LeafNode
>
;
// = typename LeafNode::FiniteElement::Traits::LocalBasisType::Traits::RangeType;
template
<
class
Node
>
using
NodeData
=
typename
std
::
vector
<
LocalBasisRange
<
Node
>>
;
using
ShapeFunctionValueContainer
=
Dune
::
Functions
::
TreeData
<
SubTree
,
NodeData
,
true
>
;
public:
LocalFunction
(
DOFVectorConstView
const
&
globalFunction
)
:
globalFunction_
(
&
globalFunction
)
,
localView_
(
globalFunction_
->
basis
().
localView
())
,
subTree_
(
&
Dune
::
TypeTree
::
child
(
localView_
.
tree
(),
globalFunction_
->
treePath
()))
{
shapeFunctionValueContainer_
.
init
(
*
subTree_
);
}
void
bind
(
Element
const
&
element
)
{
localView_
.
bind
(
element
);
bound_
=
true
;
}
void
unbind
()
{
localView_
.
unbind
();
bound_
=
false
;
}
/// Evaluate LocalFunction at bound element in local coordinates
Range
operator
()(
Domain
const
&
x
)
const
;
/// \brief Create a LocalFunction representing the gradient. \relates GradientLocalFunction
friend
GradientLocalFunction
derivative
(
LocalFunction
const
&
localFunction
)
{
static_assert
(
isValidRange
<
DerivativeTraits
>
(),
"Derivative of DOFVector not defined."
);
return
GradientLocalFunction
{
*
localFunction
.
globalFunction_
};
}
friend
int
order
(
LocalFunction
const
&
self
)
{
assert
(
self
.
bound_
);
return
polynomialDegree
(
*
self
.
subTree_
);
}
/// Return the bound element
Element
const
&
localContext
()
const
{
assert
(
bound_
);
return
localView_
.
element
();
}
private:
DOFVectorConstView
const
*
globalFunction_
;
LocalView
localView_
;
SubTree
const
*
subTree_
;
mutable
ShapeFunctionValueContainer
shapeFunctionValueContainer_
;
bool
bound_
=
false
;
};
using
Self
=
DOFVectorView
;
using
Super
=
DiscreteFunction
<
GB
,
VT
,
TP
>
;
using
GlobalBasis
=
GB
;
using
TreePath
=
TP
;
public:
/// Constructor. Stores a pointer to the dofVector and a copy of the treePath.
DOFVectorConstView
(
DOFVector
<
GlobalBasis
,
RangeType
>
const
&
dofVector
,
TreePath
const
&
treePath
)
:
dofVector_
(
&
dofVector
)
,
treePath_
(
treePath
)
,
entitySet_
(
dofVector
.
basis
().
gridView
())
,
nodeToRangeEntry_
(
Dune
::
Functions
::
makeDefaultNodeToRangeMap
(
dofVector
.
basis
(),
treePath
))
/// Constructor forwards to the treePath constructor, with empty TreePath
DOFVectorView
(
DOFVector
<
GB
,
VT
>&
dofVector
)
:
DOFVectorView
{
dofVector
,
Dune
::
TypeTree
::
hybridTreePath
()}
{}
/// Evaluate the view on this DOFVector in global coordinates
Range
operator
()(
Domain
const
&
x
)
const
{
error_exit
(
"Not implemented."
);
return
Range
(
0
);
}
/// \brief Create a local function for this view on the DOFVector. \relates LocalFunction
friend
LocalFunction
localFunction
(
DOFVectorConstView
const
&
self
)
{
return
LocalFunction
{
self
};
}
EntitySet
const
&
entitySet
()
const
{
return
entitySet_
;
}
public:
/// Return global basis
GlobalBasis
const
&
basis
()
const
{
return
dofVector_
->
basis
();
}
/// Return treePath associated with this view
TreePath
const
&
treePath
()
const
{
return
treePath_
;
}
/// Return const coefficient vector
DOFVector
<
GlobalBasis
,
RangeType
>
const
&
coefficients
()
const
{
return
*
dofVector_
;
}
protected:
DOFVector
<
GlobalBasis
,
RangeType
>
const
*
dofVector_
;
TreePath
const
treePath_
;
EntitySet
entitySet_
;
NodeToRangeEntry
nodeToRangeEntry_
;
};
// A mutable version of DOFVectorView
template
<
class
GlobalBasisType
,
class
RangeType
,
class
TreePathType
>
class
DOFVectorMutableView
:
public
DOFVectorConstView
<
GlobalBasisType
,
RangeType
,
TreePathType
>
{
using
Super
=
DOFVectorConstView
<
GlobalBasisType
,
RangeType
,
TreePathType
>
;
using
GlobalBasis
=
GlobalBasisType
;
using
TreePath
=
TreePathType
;
public:
/// Constructor. Stores a pointer to the mutable `dofvector`.
DOFVector
Mutable
View
(
DOFVector
<
G
lobalBasis
,
RangeType
>&
dofVector
,
T
reePath
const
&
treePath
)
DOFVectorView
(
DOFVector
<
G
B
,
VT
>&
dofVector
,
T
P
const
&
treePath
)
:
Super
(
dofVector
,
treePath
)
,
mutableDofVector_
(
&
dofVector
)
{}
public:
/// Interpolation of GridFunction to DOFVector
/// \brief Interpolation of GridFunction to DOFVector, assuming that there is no
/// reference to this DOFVector in the expression.
/**
* **Example:**
* ```
* auto v = makeDOFVectorView(prob.getSolutionVector(),0);
* v.interpolate([](auto const& x) { return x[0]; });
* ```
**/
template
<
class
Expr
>
DOFVectorMutableView
&
interpolate
(
Expr
&&
expr
)
void
interpolate
_noalias
(
Expr
&&
expr
)
{
auto
const
&
basis
=
Super
::
basis
();
auto
const
&
treePath
=
Super
::
treePath
();
auto
const
&
basis
=
this
->
basis
();
auto
const
&
treePath
=
this
->
treePath
();
auto
&&
gridFct
=
makeGridFunction
(
std
::
forward
<
Expr
>
(
expr
),
basis
.
gridView
());
DOFVector
<
GlobalBasis
,
RangeType
>
tmp
(
*
mutableDofVector_
);
Dune
::
Functions
::
interpolate
(
basis
,
treePath
,
tmp
,
std
::
forward
<
decltype
(
gridFct
)
>
(
gridFct
));
Dune
::
Functions
::
interpolate
(
basis
,
treePath
,
coefficients
(),
std
::
forward
<
decltype
(
gridFct
)
>
(
gridFct
));
}
/// \brief Interpolation of GridFunction to DOFVector
/**
* **Example:**
* ```
* auto v = makeDOFVectorView(prob.getSolutionVector(),0);
* v.interpolate(v + [](auto const& x) { return x[0]; });
* ```
* Allows to have a reference to the DOFVector in the expression, e.g. as
* \ref DiscreteFunction or \ref gradientAtQP() of a DiscreteFunction.
**/
template
<
class
Expr
>
void
interpolate
(
Expr
&&
expr
)
{
// create temporary copy of data
DOFVector
<
GB
,
VT
>
tmp
(
coefficients
());
Self
tmpView
{
tmp
,
this
->
treePath
()};
tmpView
.
interpolate_noalias
(
std
::
forward
<
Expr
>
(
expr
));
// move data from temporary vector into stored DOFVector
mutableDofVector_
->
vector
()
=
std
::
move
(
tmp
.
vector
());
coefficients
().
vector
()
=
std
::
move
(
tmp
.
vector
());
}
/// \brief Interpolation of GridFunction to DOFVector, alias to \ref interpolate()
template
<
class
Expr
>
DOFVectorView
&
operator
<<
(
Expr
&&
expr
)
{
interpolate
(
expr
);
return
*
this
;
}
/// \brief interpolate `(*this) + expr` to DOFVector
template
<
class
Expr
>
DOFVector
Mutable
View
&
operator
<<
(
Expr
&&
expr
)
DOFVectorView
&
operator
+=
(
Expr
&&
expr
)
{
return
interpolate
(
expr
);
interpolate
((
*
this
)
+
expr
);
return
*
this
;
}
/// \brief interpolate `(*this) - expr` to DOFVector
template
<
class
Expr
>
DOFVectorView
&
operator
-=
(
Expr
&&
expr
)
{
interpolate
((
*
this
)
-
expr
);
return
*
this
;
}
/// Return the mutable DOFVector
DOFVector
<
G
lobalBasis
,
RangeType
>&
coefficients
()
{
return
*
mutableDofVector_
;
}
DOFVector
<
G
B
,
VT
>&
coefficients
()
{
return
*
mutableDofVector_
;
}
/// Return the const DOFVector
using
Super
::
coefficients
;
protected:
DOFVector
<
G
lobalBasis
,
RangeType
>*
mutableDofVector_
;
DOFVector
<
G
B
,
VT
>*
mutableDofVector_
;
};
/** @} **/
#ifndef DOXYGEN
// A Generator for a const \ref DOFVectorView.
template
<
class
GlobalBasis
,
class
RangeType
,
class
TreePath
>
auto
makeDOFVectorView
(
DOFVector
<
GlobalBasis
,
RangeType
>
const
&
dofVector
,
TreePath
const
&
treePath
)
{
return
DOFVectorConstView
<
GlobalBasis
,
RangeType
,
TreePath
>
{
dofVector
,
treePath
};
}
// A Generator for a mutable \ref DOFVectorView.
template
<
class
GlobalBasis
,
class
RangeType
,
class
TreePath
>
auto
makeDOFVectorView
(
DOFVector
<
GlobalBasis
,
RangeType
>&
dofVector
,
TreePath
const
&
treePath
)
{
return
DOFVectorMutableView
<
GlobalBasis
,
RangeType
,
TreePath
>
{
dofVector
,
treePath
};
}
#if DUNE_HAVE_CXX_CLASS_TEMPLATE_ARGUMENT_DEDUCTION
// Deduction guide for DOFVectorView class
template
<
class
GlobalBasis
,
class
ValueType
>
DOFVectorView
(
DOFVector
<
GlobalBasis
,
ValueType
>&
dofVector
)
->
DOFVectorView
<
GlobalBasis
,
ValueType
,
Dune
::
TypeTree
::
HybridTreePath
<>>
;
#endif
// A Generator for a
const
\ref DOFVectorView
.
template
<
class
GlobalBasis
,
class
Rang
eType
>
auto
makeDOFVectorView
(
DOFVector
<
GlobalBasis
,
Rang
eType
>
const
&
dofVector
)
//
/
A Generator for a
mutable
\ref DOFVectorView
template
<
class
GlobalBasis
,
class
Valu
eType
,
class
TreePath
>
auto
makeDOFVectorView
(
DOFVector
<
GlobalBasis
,
Valu
eType
>&
dofVector
,
TreePath
const
&
treePath
)
{
auto
treePath
=
Dune
::
TypeTree
::
hybridTreePath
();
return
DOFVectorConstView
<
GlobalBasis
,
RangeType
,
decltype
(
treePath
)
>
{
dofVector
,
treePath
};
return
DOFVectorView
<
GlobalBasis
,
ValueType
,
TreePath
>
{
dofVector
,
treePath
};
}
// A Generator for a mutable \ref DOFVectorView
.
template
<
class
GlobalBasis
,
class
Rang
eType
>
auto
makeDOFVectorView
(
DOFVector
<
GlobalBasis
,
Rang
eType
>&
dofVector
)
//
/
A Generator for a mutable \ref DOFVectorView
template
<
class
GlobalBasis
,
class
Valu
eType
>
auto
makeDOFVectorView
(
DOFVector
<
GlobalBasis
,
Valu
eType
>&
dofVector
)
{
auto
treePath
=
Dune
::
TypeTree
::
hybridTreePath
();
return
DOFVector
Mutable
View
<
GlobalBasis
,
Rang
eType
,
decltype
(
t
reePath
)
>
{
dofVector
,
treePath
};
return
DOFVectorView
<
GlobalBasis
,
Valu
eType
,
Dune
::
TypeTree
::
HybridT
reePath
<>
>
{
dofVector
,
treePath
};
}
#endif
}
// end namespace AMDiS
#include
"DOFVectorView.inc.hpp"
src/amdis/gridfunctions/DerivativeGridFunction.hpp
View file @
52d5d039
...
...
@@ -3,6 +3,7 @@
#include
<type_traits>
#include
<dune/functions/common/defaultderivativetraits.hh>
#include
<dune/grid/utility/hierarchicsearch.hh>
#include
<amdis/gridfunctions/GridFunctionConcepts.hpp>
...
...
@@ -52,11 +53,22 @@ namespace AMDiS
static_assert
(
isValidRange
<
DerivativeTraits
>
(),
"Derivative of GridFunction not defined"
);
}
///
NOTE: no global derivative availabl
e
///
Evaluate derivative in global coordinates. NOTE: expensiv
e
Range
operator
()(
Domain
const
&
x
)
const
{
error_exit
(
"Not implemented"
);
return
Range
(
0
);
auto
gv
=
entitySet
().
gridView
();
using
GridView
=
decltype
(
gv
);
using
Grid
=
typename
GridView
::
Grid
;
using
IS
=
typename
GridView
::
IndexSet
;
Dune
::
HierarchicSearch
<
Grid
,
IS
>
hsearch
{
gv
.
grid
(),
gv
.
indexSet
()};
auto
element
=
hsearch
.
findEntity
(
x
);
auto
geometry
=
element
.
geometry
();
auto
localFct
=
derivative
(
localFunction
(
gridFct_
));
localFct
.
bind
(
element
);
return
localFct
(
geometry
.
local
(
x
));
}
/// Return the derivative-localFunction of the GridFunction.
...
...
src/amdis/gridfunctions/DiscreteFunction.hpp
0 → 100644
View file @
52d5d039
#pragma once
#include
<vector>