Liebe Gitlab-Nutzer, lieber Gitlab-Nutzer, es ist nun möglich sich mittels des ZIH-Logins/LDAP an unserem Dienst anzumelden. Ein Anmelden über dieses erzeugt ein neues Konto. Das alte Konto ist über den Reiter "Standard" erreichbar. Die Administratoren

Dear Gitlab user, it is now possible to log in to our service using the ZIH login/LDAP. Logging in via this will create a new account. The old account can be accessed via the "Standard" tab. The administrators

Commit d6e19bfe authored by Müller, Felix's avatar Müller, Felix
Browse files

Added support for PreTreePath argument to makeDiscreteFunction/DOFVectorView; Updated unit test

parent 2b2cfd1d
Pipeline #1458 passed with stage
in 20 minutes and 56 seconds
......@@ -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& treePath)
template <class GlobalBasis, class ValueType, class PreTreePath>
auto makeDOFVectorView(DOFVector<GlobalBasis, ValueType>& dofVector, PreTreePath const& preTreePath)
{
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
......
......@@ -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& treePath)
template <class GlobalBasis, class ValueType, class PreTreePath>
auto makeDiscreteFunction(DOFVector<GlobalBasis, ValueType> const& dofVector, PreTreePath const& preTreePath)
{
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
......
......@@ -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;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment