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 1eb6b83f authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

GenericOperatorTerm added - provides a math-like syntax for adding terms

parent 68db6597
......@@ -123,14 +123,14 @@ template<typename T>
struct Diff : public BinaryAbstractFunction<T,T,T>
{
Diff(int degree = 1) : BinaryAbstractFunction<T,T,T>(degree) {}
T operator()(const T &v1, const T &v2) const { return abs(v1-v2); }
T operator()(const T &v1, const T &v2) const { return std::abs(v1-v2); }
};
template<typename T=double>
struct Abs : public AbstractFunction<T,T>
{
Abs(int degree = 1) : AbstractFunction<T,T>(degree) {}
T operator()(const T &v) const { return abs(v); }
T operator()(const T &v) const { return std::abs(v); }
};
template<typename T=double>
......@@ -151,35 +151,36 @@ template<typename T=double>
struct Sqrt : public AbstractFunction<T,T>
{
Sqrt(int degree = 4) : AbstractFunction<T,T>(degree) {}
T operator()(const T &v) const { return sqrt(v); }
T operator()(const T &v) const { return std::sqrt(v); }
};
namespace detail {
template<int p>
template<int p, typename T>
struct Pow
{
template<typename T>
static T eval(const T& v) { return v*Pow<p-1>::eval(v); }
typedef typename AMDiS::ProductType<T, typename Pow<p-1,T>::result_type>::type result_type;
static result_type eval(const T& v) { return v*Pow<p-1,T>::eval(v); }
};
template<>
struct Pow<1> {
template<typename T>
static T eval(const T& v) { return v; }
template<typename T>
struct Pow<1,T> {
typedef T result_type;
static result_type eval(const T& v) { return v; }
};
template<>
struct Pow<0> {
template<typename T>
static T eval(const T& v) { return 1.0; }
template<typename T>
struct Pow<0, T> {
typedef double result_type;
static result_type eval(const T& v) { return 1.0; }
};
}
template<int p, typename T=double>
struct Pow : public AbstractFunction<T,T>
struct Pow : public AbstractFunction<typename detail::Pow<p,T>::result_type, T>
{
Pow(double factor_=1.0, int degree = p) : AbstractFunction<T,T>(degree), factor(factor_) {}
T operator()(const T &v) const { return factor * detail::Pow<p>::eval(v); }
typedef typename detail::Pow<p,T>::result_type result_type;
Pow(double factor_=1.0, int degree = p) : AbstractFunction<result_type,T>(degree), factor(factor_) {}
result_type operator()(const T &v) const { return factor * detail::Pow<p,T>::eval(v); }
private:
double factor;
};
......@@ -188,7 +189,7 @@ template<typename T1, typename T2 = ProductType<T1, T1> >
struct Norm2 : public AbstractFunction<T1, T2>
{
Norm2(int degree = 4) : AbstractFunction<T1, T2>(degree) {}
T1 operator()(const T2 &v) const { return sqrt(v*v); }
T1 operator()(const T2 &v) const { return std::sqrt(v*v); }
};
template<typename T1, typename T2>
......@@ -202,7 +203,7 @@ template<typename T>
struct Norm2_comp2 : public BinaryAbstractFunction<T,T,T>
{
Norm2_comp2(int degree = 4) : BinaryAbstractFunction<T,T,T>(degree) {}
T operator()(const T &v1, const T &v2) const { return sqrt(sqr(v1)+sqr(v2)); }
T operator()(const T &v1, const T &v2) const { return std::sqrt(sqr(v1)+sqr(v2)); }
};
template<typename T>
......@@ -216,7 +217,7 @@ template<typename T>
struct Norm2_comp3 : public TertiaryAbstractFunction<T,T,T,T>
{
Norm2_comp3(int degree = 4) : TertiaryAbstractFunction<T,T,T,T>(degree) {}
T operator()(const T &v1, const T &v2, const T &v3) const { return sqrt(sqr(v1)+sqr(v2)+sqr(v3)); }
T operator()(const T &v1, const T &v2, const T &v3) const { return std::sqrt(sqr(v1)+sqr(v2)+sqr(v3)); }
};
template<typename T>
......@@ -229,7 +230,7 @@ struct Norm2Sqr_comp3 : public TertiaryAbstractFunction<T,T,T,T>
template<typename T>
struct L1Diff : public BinaryAbstractFunction<T,T,T>
{
T operator()(const T &v1, const T &v2) const { return abs(v1-v2); }
T operator()(const T &v1, const T &v2) const { return std::abs(v1-v2); }
};
template<typename TOut, typename T=TOut>
......
This diff is collapsed.
......@@ -71,7 +71,9 @@ namespace AMDiS {
deserialized(false),
computeExactError(false),
boundaryConditionSet(false),
writeAsmInfo(false)
writeAsmInfo(false),
solutionTime(0.0),
buildTime(0.0)
{
Parameters::get(name + "->components", nComponents);
TEST_EXIT(nComponents > 0)("No value set for parameter \"%s->components\"!\n",
......@@ -666,6 +668,7 @@ namespace AMDiS {
INFO(info, 8)("solution of discrete system needed %.5f seconds\n",
t.elapsed());
solutionTime = t.elapsed();
adaptInfo->setSolverIterations(solver->getIterations());
adaptInfo->setMaxSolverIterations(solver->getMaxIterations());
......@@ -924,6 +927,7 @@ namespace AMDiS {
MPI::COMM_WORLD.Barrier();
#endif
INFO(info, 8)("buildAfterCoarsen needed %.5f seconds\n", t.elapsed());
buildTime = t.elapsed();
}
......
......@@ -547,6 +547,16 @@ namespace AMDiS {
{
return fileWriters;
}
double getSolutionTime()
{
return solutionTime;
}
double getBuildTime()
{
return buildTime;
}
protected:
/// If the exact solution is known, the problem can compute the exact
......@@ -664,6 +674,9 @@ namespace AMDiS {
bool writeAsmInfo;
std::map<Operator*, std::vector<OperatorPos> > operators;
double solutionTime;
double buildTime;
};
#ifndef HAVE_PARALLEL_DOMAIN_AMDIS
......
......@@ -51,9 +51,9 @@ namespace AMDiS {
double operator()(const WorldVector<double>& y,
const WorldVector<double>& z) const
{
double result = pow(y[0] - z[0], exponent[0]);
double result = std::pow(y[0] - z[0], double(exponent[0]));
for (int i = 1; i < exponent.size(); i++)
result *= pow(y[i] - z[i], exponent[i]);
result *= std::pow(y[i] - z[i], double(exponent[i]));
return result;
}
......
......@@ -99,20 +99,20 @@ namespace AMDiS {
public:
/// Constructor.
VecAtQP_ZOT(DOFVectorBase<double> *dv,
AbstractFunction<double, double> *ab = nullptr,
AbstractFunction<double, double> *ab = NULL,
double factor_ = 1.0
);
/// Implementation of \ref OperatorTerm::initElement().
void initElement(const ElInfo* elInfo,
SubAssembler* subAssembler,
Quadrature *quad = nullptr);
Quadrature *quad = NULL);
/// Implementation of \ref OperatorTerm::initElement() for multiple meshes.
void initElement(const ElInfo* smallElInfo,
const ElInfo* largeElInfo,
SubAssembler* subAssembler,
Quadrature *quad = nullptr);
Quadrature *quad = NULL);
/// Implements ZeroOrderTerm::getC().
void getC(const ElInfo *, int nPoints, ElementVector& C);
......@@ -160,7 +160,7 @@ namespace AMDiS {
/// Implementation of \ref OperatorTerm::initElement().
void initElement(const ElInfo* elInfo, SubAssembler* subAssembler,
Quadrature *quad = nullptr);
Quadrature *quad = NULL);
/// Implements ZeroOrderTerm::getC().
void getC(const ElInfo *, int nPoints, ElementVector& C);
......@@ -203,19 +203,19 @@ namespace AMDiS {
/// Constructor.
Vec2AtQP_ZOT(DOFVectorBase<double> *dv1,
DOFVectorBase<double> *dv2,
BinaryAbstractFunction<double, double, double> *f = nullptr,
BinaryAbstractFunction<double, double, double> *f = NULL,
double factor_ = 1.0
);
/// Implementation of \ref OperatorTerm::initElement().
void initElement(const ElInfo* elInfo, SubAssembler* subAssembler,
Quadrature *quad = nullptr);
Quadrature *quad = NULL);
/// Implementation of \ref OperatorTerm::initElement() for multilpe meshes.
void initElement(const ElInfo* smallElInfo,
const ElInfo* largeElInfo,
SubAssembler* subAssembler,
Quadrature *quad = nullptr);
Quadrature *quad = NULL);
/// Implements ZeroOrderTerm::getC().
void getC(const ElInfo *, int nPoints, ElementVector& C);
......@@ -260,13 +260,13 @@ namespace AMDiS {
Vec3AtQP_ZOT(DOFVectorBase<double> *dv1,
DOFVectorBase<double> *dv2,
DOFVectorBase<double> *dv3,
TertiaryAbstractFunction<double, double, double, double> *f = nullptr,
TertiaryAbstractFunction<double, double, double, double> *f = NULL,
double factor_ = 1.0
);
/// Implementation of \ref OperatorTerm::initElement().
void initElement(const ElInfo* elInfo, SubAssembler* subAssembler,
Quadrature *quad = nullptr);
Quadrature *quad = NULL);
/// Implements ZeroOrderTerm::getC().
void getC(const ElInfo *, int nPoints, ElementVector& C);
......@@ -309,7 +309,7 @@ namespace AMDiS {
/// Implementation of \ref OperatorTerm::initElement().
void initElement(const ElInfo* elInfo, SubAssembler* subAssembler,
Quadrature *quad = nullptr);
Quadrature *quad = NULL);
/// Implements ZeroOrderTerm::getC().
void getC(const ElInfo *elInfo, int nPoints, ElementVector& C);
......@@ -349,7 +349,7 @@ namespace AMDiS {
/// Implementation of \ref OperatorTerm::initElement().
void initElement(const ElInfo* elInfo, SubAssembler* subAssembler,
Quadrature *quad = nullptr);
Quadrature *quad = NULL);
/// Implements ZeroOrderTerm::getC().
void getC(const ElInfo *, int nPoints, ElementVector& C);
......@@ -392,7 +392,7 @@ namespace AMDiS {
/// Implementation of \ref OperatorTerm::initElement().
void initElement(const ElInfo* elInfo, SubAssembler* subAssembler,
Quadrature *quad = nullptr);
Quadrature *quad = NULL);
/// Implements ZeroOrderTerm::getC().
void getC(const ElInfo *, int nPoints, ElementVector& C);
......@@ -433,7 +433,7 @@ namespace AMDiS {
/// Implementation of \ref OperatorTerm::initElement().
void initElement(const ElInfo* elInfo, SubAssembler* subAssembler,
Quadrature *quad = nullptr);
Quadrature *quad = NULL);
/// Implements ZeroOrderTerm::getC().
void getC(const ElInfo *, int nPoints, ElementVector& C);
......@@ -477,7 +477,7 @@ namespace AMDiS {
/// Implementation of \ref OperatorTerm::initElement().
void initElement(const ElInfo* elInfo, SubAssembler* subAssembler,
Quadrature *quad = nullptr);
Quadrature *quad = NULL);
/// Implements ZeroOrderTerm::getC().
void getC(const ElInfo *elInfo, int nPoints, ElementVector& C);
......@@ -519,7 +519,7 @@ namespace AMDiS {
/// Implementation of \ref OperatorTerm::initElement().
void initElement(const ElInfo* elInfo, SubAssembler* subAssembler,
Quadrature *quad = nullptr);
Quadrature *quad = NULL);
/// Implements ZeroOrderTerm::getC().
void getC(const ElInfo *, int nPoints, ElementVector& C);
......@@ -557,7 +557,7 @@ namespace AMDiS {
/// Implementation of \ref OperatorTerm::initElement().
void initElement(const ElInfo* elInfo, SubAssembler* subAssembler,
Quadrature *quad = nullptr);
Quadrature *quad = NULL);
/// Implements ZeroOrderTerm::getC().
void getC(const ElInfo *, int nPoints, ElementVector& C);
......@@ -599,7 +599,7 @@ namespace AMDiS {
/// Implementation of \ref OperatorTerm::initElement().
void initElement(const ElInfo* elInfo, SubAssembler* subAssembler,
Quadrature *quad = nullptr);
Quadrature *quad = NULL);
/// Implements ZeroOrderTerm::getC().
void getC(const ElInfo *, int nPoints, ElementVector& C);
......@@ -645,7 +645,7 @@ namespace AMDiS {
/// Implementation of \ref OperatorTerm::initElement().
void initElement(const ElInfo* elInfo, SubAssembler* subAssembler,
Quadrature *quad = nullptr);
Quadrature *quad = NULL);
/// Implements ZeroOrderTerm::getC().
void getC(const ElInfo *, int nPoints, ElementVector& C);
......@@ -679,7 +679,7 @@ namespace AMDiS {
/// Implementation of \ref OperatorTerm::initElement().
void initElement(const ElInfo* elInfo, SubAssembler* subAssembler,
Quadrature *quad = nullptr);
Quadrature *quad = NULL);
/// Implements ZeroOrderTerm::getC().
void getC(const ElInfo *, int nPoints, ElementVector& C);
......@@ -710,12 +710,12 @@ namespace AMDiS {
/// Constructor.
VecDivergence_ZOT(int nComponents,
DOFVectorBase<double> *vec0,
DOFVectorBase<double> *vec1 = nullptr,
DOFVectorBase<double> *vec2 = nullptr);
DOFVectorBase<double> *vec1 = NULL,
DOFVectorBase<double> *vec2 = NULL);
/// Implementation of \ref OperatorTerm::initElement().
void initElement(const ElInfo* elInfo, SubAssembler* subAssembler,
Quadrature *quad = nullptr);
Quadrature *quad = NULL);
/// Implements ZeroOrderTerm::getC().
void getC(const ElInfo *, int nPoints, ElementVector& C);
......@@ -747,7 +747,7 @@ namespace AMDiS {
/// Implementation of \ref OperatorTerm::initElement().
void initElement(const ElInfo* elInfo, SubAssembler* subAssembler,
Quadrature *quad = nullptr);
Quadrature *quad = NULL);
/// Implements ZeroOrderTerm::getC().
void getC(const ElInfo *, int nPoints, ElementVector& C);
......@@ -786,7 +786,7 @@ namespace AMDiS {
QuartAbstractFunction<double, double, double, WorldVector<double>, WorldVector<double> > *af);
void initElement(const ElInfo* elInfo, SubAssembler* subAssembler,
Quadrature *quad = nullptr);
Quadrature *quad = NULL);
void getC(const ElInfo *, int nPoints, ElementVector& C);
......@@ -816,7 +816,7 @@ namespace AMDiS {
TertiaryAbstractFunction<double, double, double, WorldVector<double> > *f);
void initElement(const ElInfo* elInfo, SubAssembler* subAssembler,
Quadrature *quad = nullptr);
Quadrature *quad = NULL);
void getC(const ElInfo *, int nPoints, ElementVector& C);
......@@ -850,7 +850,7 @@ namespace AMDiS {
/// Implementation of \ref OperatorTerm::initElement().
void initElement(const ElInfo* elInfo, SubAssembler* subAssembler,
Quadrature *quad = nullptr);
Quadrature *quad = NULL);
/// Implements ZeroOrderTerm::getC().
void getC(const ElInfo *, int nPoints, ElementVector& C);
......@@ -899,7 +899,7 @@ namespace AMDiS {
/// Implementation of \ref OperatorTerm::initElement().
void initElement(const ElInfo* elInfo, SubAssembler* subAssembler,
Quadrature *quad = nullptr);
Quadrature *quad = NULL);
/// Implements ZeroOrderTerm::getC().
void getC(const ElInfo *, int nPoints, ElementVector& C);
......@@ -950,7 +950,7 @@ namespace AMDiS {
/// Implementation of \ref OperatorTerm::initElement().
void initElement(const ElInfo* elInfo,
SubAssembler* subAssembler,
Quadrature *quad = nullptr);
Quadrature *quad = NULL);
/// Implements ZeroOrderTerm::getC().
void getC(const ElInfo *, int nPoints, ElementVector& C);
......
/******************************************************************************
*
* AMDiS - Adaptive multidimensional simulations
*
* Copyright (C) 2013 Dresden University of Technology. All Rights Reserved.
* Web: https://fusionforge.zih.tu-dresden.de/projects/amdis
*
* Authors:
* Simon Vey, Thomas Witkowski, Andreas Naumann, Simon Praetorius, et al.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
*
* This file is part of AMDiS
*
* See also license.opensource.txt in the distribution.
*
******************************************************************************/
/** \file AtomicExpression.h */
#ifndef AMDIS_ATOMIC_EXPRESSION_H
#define AMDIS_ATOMIC_EXPRESSION_H
#include "AMDiS_fwd.h"
#include "LazyOperatorTerm.h"
#include "ValueTypes.h"
#include <boost/static_assert.hpp>
#include "ValueOf.h"
#include "GradientOf.h"
namespace AMDiS {
namespace result_of {
struct Coords : public LazyOperatorTermBase
{
typedef WorldVector<double> value_type;
mutable mtl::dense_vector<WorldVector<double> > x;
Coords() {}
template<typename List>
void insertFeSpaces(List& feSpaces) const {}
int getDegree() const
{
return 1;
}
template<typename OT>
void initElement(OT& ot, const ElInfo* elInfo,
SubAssembler* subAssembler, Quadrature *quad)
{
subAssembler->getCoordsAtQPs(elInfo, quad, x);
}
template<typename OT>
void initElement(OT& ot, const ElInfo* smallElInfo, const ElInfo* largeElInfo,
SubAssembler* subAssembler, Quadrature *quad)
{
subAssembler->getCoordsAtQPs(smallElInfo, quad, x);
}
inline value_type operator()(const int& iq) const { return x[iq]; }
inline value_type eval(const int& iq) const { return x[iq]; }
inline value_type derivative(const int& iq, int identifier) const { WorldVector<double> vec0; vec0.set(0.0); return vec0; }
};
template<int I>
struct Coord : public LazyOperatorTermBase
{
typedef double value_type;
mutable mtl::dense_vector<WorldVector<double> > x;
Coord() {}
template<typename List>
void insertFeSpaces(List& feSpaces) const {}
int getDegree() const
{
return 1;
}
template<typename OT>
void initElement(OT& ot, const ElInfo* elInfo,
SubAssembler* subAssembler, Quadrature *quad)
{
subAssembler->getCoordsAtQPs(elInfo, quad, x);
}
template<typename OT>
void initElement(OT& ot, const ElInfo* smallElInfo, const ElInfo* largeElInfo,
SubAssembler* subAssembler, Quadrature *quad)
{
subAssembler->getCoordsAtQPs(smallElInfo, quad, x);
}
inline double operator()(const int& iq) const { return x[iq][I]; }
inline double eval(const int& iq) const { return x[iq][I]; }
inline double derivative(const int& iq, int identifier) const { return 0.0; }
};
template<typename T>
struct Const : public LazyOperatorTermBase
{
typedef T value_type;
T value;
Const(const T& value_) : value(value_) {}
template<typename List>
void insertFeSpaces(List& feSpaces) const {}
int getDegree() const
{
return 0;
}
template<typename OT>
void initElement(OT& ot, const ElInfo* elInfo,
SubAssembler* subAssembler, Quadrature *quad) {}
template<typename OT>
void initElement(OT& ot, const ElInfo* smallElInfo, const ElInfo* largeElInfo,
SubAssembler* subAssembler, Quadrature *quad) {}
inline value_type operator()(const int& iq) const { return value; }
inline value_type eval(const int& iq) const { return value; }
inline value_type derivative(const int& iq, int identifier) const { return 0.0; }
};
///
template<typename Term>
struct Jacobian : public LazyOperatorTerm1<Term>
{
typedef LazyOperatorTerm1<Term> super;
typedef typename Term::value_type value_type;
const int I;
Jacobian(const Term& term_, int I_) : super(term_), I(I_) {}
int getDegree() const
{
// TODO: eventuell noch Polynomgrad der Ableitung extra bestimmen
return super::term.getDegree();
}
inline value_type operator()(const int& iq) const { return super::term.derivative(iq, I); }
};
}
result_of::Coords X() { return result_of::Coords(); }
template<int I>
result_of::Coord<I> X() { return result_of::Coord<I>(); }
template<typename T>
result_of::Const<T> constant(const T& value) { return result_of::Const<T>(value); }
namespace Private {
template<typename Term>
inline typename boost::enable_if<
typename boost::is_base_of<LazyOperatorTermBase, Term>::type,
result_of::Jacobian<Term> >::type
jacobian(const Term& t, int I) { return result_of::Jacobian<Term>(t, I); }
}
} // end namespace AMDiS
#endif
\ No newline at end of file
/******************************************************************************
*
* AMDiS - Adaptive multidimensional simulations
*
* Copyright (C) 2013 Dresden University of Technology. All Rights Reserved.
* Web: https://fusionforge.zih.tu-dresden.de/projects/amdis
*
* Authors:
* Simon Vey, Thomas Witkowski, Andreas Naumann, Simon Praetorius, et al.
*
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
*
*
* This file is part of AMDiS
*
* See also license.opensource.txt in the distribution.
*
******************************************************************************/