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
d6e19bfe
Commit
d6e19bfe
authored
Nov 23, 2018
by
Müller, Felix
Browse files
Added support for PreTreePath argument to makeDiscreteFunction/DOFVectorView; Updated unit test
parent
2b2cfd1d
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/amdis/gridfunctions/DOFVectorView.hpp
View file @
d6e19bfe
...
...
@@ -115,10 +115,11 @@ namespace AMDiS
#endif
/// A Generator for a mutable \ref DOFVectorView
template
<
class
GlobalBasis
,
class
ValueType
,
class
TreePath
>
auto
makeDOFVectorView
(
DOFVector
<
GlobalBasis
,
ValueType
>&
dofVector
,
TreePath
const
&
t
reePath
)
template
<
class
GlobalBasis
,
class
ValueType
,
class
Pre
TreePath
>
auto
makeDOFVectorView
(
DOFVector
<
GlobalBasis
,
ValueType
>&
dofVector
,
Pre
TreePath
const
&
preT
reePath
)
{
return
DOFVectorView
<
GlobalBasis
,
ValueType
,
TreePath
>
{
dofVector
,
treePath
};
auto
treePath
=
makeTreePath
(
preTreePath
);
return
DOFVectorView
<
GlobalBasis
,
ValueType
,
decltype
(
treePath
)
>
{
dofVector
,
treePath
};
}
/// A Generator for a mutable \ref DOFVectorView
...
...
src/amdis/gridfunctions/DiscreteFunction.hpp
View file @
d6e19bfe
...
...
@@ -11,6 +11,7 @@
#include
<amdis/GridFunctions.hpp>
#include
<amdis/utility/FiniteElementType.hpp>
#include
<amdis/utility/TreePath.hpp>
namespace
AMDiS
{
...
...
@@ -126,10 +127,11 @@ namespace AMDiS
#endif
/// A Generator for a \ref DiscreteFunction
template
<
class
GlobalBasis
,
class
ValueType
,
class
TreePath
>
auto
makeDiscreteFunction
(
DOFVector
<
GlobalBasis
,
ValueType
>
const
&
dofVector
,
TreePath
const
&
t
reePath
)
template
<
class
GlobalBasis
,
class
ValueType
,
class
Pre
TreePath
>
auto
makeDiscreteFunction
(
DOFVector
<
GlobalBasis
,
ValueType
>
const
&
dofVector
,
Pre
TreePath
const
&
preT
reePath
)
{
return
DiscreteFunction
<
GlobalBasis
,
ValueType
,
TreePath
>
{
dofVector
,
treePath
};
auto
treePath
=
makeTreePath
(
preTreePath
);
return
DiscreteFunction
<
GlobalBasis
,
ValueType
,
decltype
(
treePath
)
>
{
dofVector
,
treePath
};
}
/// A Generator for a \ref DiscreteFunction
...
...
test/DiscreteFunctionTest.cpp
View file @
d6e19bfe
...
...
@@ -8,6 +8,7 @@
#include
<amdis/ProblemStat.hpp>
#include
<amdis/gridfunctions/DiscreteFunction.hpp>
#include
<amdis/gridfunctions/DOFVectorView.hpp>
#include
<amdis/utility/TreePath.hpp>
#include
"Tests.hpp"
...
...
@@ -48,7 +49,7 @@ int main(int argc, char** argv)
auto
u1
=
makeDOFVectorView
(
U1
);
auto
u2
=
makeDOFVectorView
(
U2
);
auto
expr
=
[](
auto
const
&
x
)
{
return
x
[
0
]
+
x
[
1
];
};
auto
expr
=
[](
auto
const
&
x
)
{
return
1
+
x
[
0
]
+
x
[
1
];
};
u0
.
interpolate_noalias
(
expr
);
u1
.
interpolate
(
expr
);
u2
<<
expr
;
...
...
@@ -56,7 +57,7 @@ int main(int argc, char** argv)
AMDIS_TEST
(
comp
(
U0
,
U1
)
);
AMDIS_TEST
(
comp
(
U0
,
U2
)
);
auto
expr2
=
[](
auto
const
&
x
)
{
return
2
*
x
[
0
]
-
3
*
x
[
1
];
};
auto
expr2
=
[](
auto
const
&
x
)
{
return
1
+
2
*
x
[
0
]
-
3
*
x
[
1
];
};
u0
.
interpolate_noalias
(
u2
+
expr2
);
u1
.
interpolate
(
u1
+
expr2
);
...
...
@@ -65,7 +66,7 @@ int main(int argc, char** argv)
AMDIS_TEST
(
comp
(
U0
,
U1
)
);
AMDIS_TEST
(
comp
(
U0
,
U2
)
);
auto
expr3
=
[](
auto
const
&
x
)
{
return
-
0.5
*
x
[
0
]
-
2
*
x
[
1
];
};
auto
expr3
=
[](
auto
const
&
x
)
{
return
1
-
0.5
*
x
[
0
]
-
2
*
x
[
1
];
};
u0
.
interpolate_noalias
(
u2
-
expr3
);
u1
.
interpolate
(
u1
-
expr3
);
...
...
@@ -100,6 +101,34 @@ int main(int argc, char** argv)
auto
v0
=
makeDOFVectorView
(
V0
);
v0
<<
expr
;
// test makeDiscreteFunction
int
preTP1
=
0
;
std
::
integral_constant
<
std
::
size_t
,
0
>
preTP2
;
auto
tp
=
treepath
(
preTP1
);
auto
W0
=
prob
.
solutionVector
();
auto
W1
=
prob
.
solutionVector
();
auto
W2
=
prob
.
solutionVector
();
auto
w0
=
makeDiscreteFunction
(
W0
,
preTP1
);
auto
w1
=
makeDiscreteFunction
(
W1
,
preTP2
);
auto
w2
=
makeDiscreteFunction
(
W2
,
tp
);
// test makeDOFVectorView with (pre)treepath argument
auto
W3
=
prob
.
solutionVector
();
auto
W4
=
prob
.
solutionVector
();
auto
W5
=
prob
.
solutionVector
();
auto
w3
=
makeDOFVectorView
(
W3
,
preTP1
);
auto
w4
=
makeDOFVectorView
(
W4
,
preTP2
);
auto
w5
=
makeDOFVectorView
(
W5
,
tp
);
auto
w6
=
prob
.
solution
(
tp
);
auto
&
W6
=
prob
.
solutionVector
();
w3
<<
expr
;
w4
<<
expr
;
w5
<<
expr
;
w6
<<
expr
;
AMDIS_TEST
(
comp
(
W3
,
W4
)
);
AMDIS_TEST
(
comp
(
W3
,
W5
)
);
AMDIS_TEST
(
comp
(
W3
,
W6
)
);
AMDiS
::
finalize
();
return
0
;
}
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