Commit 4c469863 authored by Praetorius, Simon's avatar Praetorius, Simon

diff_expressions updated

parent 31c48ebd
......@@ -60,4 +60,36 @@ namespace AMDiS {
return elInfo;
}
ElInfo *ParametricSimple::addParametricInfo(ElInfo *elInfo)
{
elInfo->setParametric(true);
int dow = Global::getGeo(WORLD);
Element *element = elInfo->getElement();
const DegreeOfFreedom **dof = element->getDof();
for (int i = 0; i < elInfo->getElement()->getGeo(VERTEX); i++) {
if (elInfo->getFillFlag().isSet(Mesh::FILL_COORDS))
elInfo->getCoord(i) = dofCoords[dof[i][0]];
if (elInfo->getFillFlag().isSet(Mesh::FILL_OPP_COORDS)) {
TEST_EXIT(elInfo->getFillFlag().isSet(Mesh::FILL_NEIGH))
("FILL_NEIGH not set\n");
if (elInfo->getNeighbour(i)) {
const DegreeOfFreedom **neighDof = elInfo->getNeighbour(i)->getDof();
elInfo->getOppCoord(i) = dofCoords[neighDof[elInfo->getOppVertex(i)][0]];
}
}
}
return elInfo;
}
ElInfo *ParametricSimple::removeParametricInfo(ElInfo *elInfo)
{
elInfo->setParametric(false);
return elInfo;
}
}
......@@ -85,6 +85,26 @@ namespace AMDiS {
WorldVector<DOFVector<double>*> *dofCoords_;
};
/// Implementation of linear parametric elements.
class ParametricSimple : public Parametric
{
public:
/// Constructor. \ref dofCoords are set to coords.
ParametricSimple(DOFVector<WorldVector<double> > const& coords)
: dofCoords(coords)
{}
/// Implementation of \ref Parametric::addParametricInfo().
ElInfo *addParametricInfo(ElInfo *elInfo);
/// Implementation of \ref Parametric::removeParametricInfo().
ElInfo *removeParametricInfo(ElInfo *elInfo);
protected:
/// Pointer to a DOFVector of world coordinates.
DOFVector<WorldVector<double> > const& dofCoords;
};
}
#endif
......@@ -96,7 +96,7 @@ namespace AMDiS
inline value_type operator()(const int& iq) const { return x[iq]; }
std::string str() { return "X"; }
std::string str() const { return "X"; }
};
......@@ -165,7 +165,7 @@ namespace AMDiS
inline double operator()(const int& iq) const { return x[iq][I]; }
std::string str() { return std::string("X<") + boost::lexical_cast<std::string>(I) + ">"; }
std::string str() const { return std::string("X<") + boost::lexical_cast<std::string>(I) + ">"; }
};
......@@ -211,7 +211,7 @@ namespace AMDiS
inline value_type operator()(const int& iq) const { return normal; }
std::string str() { return "N"; }
std::string str() const { return "N"; }
};
......@@ -257,7 +257,7 @@ namespace AMDiS
inline value_type operator()(const int& iq) const { return normal[I]; }
std::string str() { return std::string("N<") + boost::lexical_cast<std::string>(I) + ">"; }
std::string str() const { return std::string("N<") + boost::lexical_cast<std::string>(I) + ">"; }
};
......@@ -293,7 +293,7 @@ namespace AMDiS
inline value_type operator()(const int& iq) const { return elementNormal; }
std::string str() { return "M"; }
std::string str() const { return "M"; }
};
......@@ -330,7 +330,7 @@ namespace AMDiS
inline value_type operator()(const int& iq) const { return elementNormal[I]; }
std::string str() { return std::string("M<") + boost::lexical_cast<std::string>(I) + ">"; }
std::string str() const { return std::string("M<") + boost::lexical_cast<std::string>(I) + ">"; }
};
} // end namespace expressions
......
......@@ -223,6 +223,30 @@ namespace AMDiS
return simplify(simplify(diff<Id>(t.term1,d)) + simplify(diff<Id>(t.term2,d)));
}
};
template<typename Id, typename Term1, typename Term2, typename Direction>
class Diff< Id, Subtract<Term1, Term2>, Direction >
{
typedef typename Simplify< typename Diff<Id, Term1>::type >::type D1;
typedef typename Simplify< typename Diff<Id, Term2>::type >::type D2;
typedef typename Simplify< typename Diff<Id, Term1, Direction>::dir_type >::type D1_;
typedef typename Simplify< typename Diff<Id, Term2, Direction>::dir_type >::type D2_;
public:
typedef Subtract<Term1, Term2> original_type;
typedef typename Simplify< Subtract< D1, D2 > >::type type;
typedef typename Simplify< Subtract< D1_, D2_ > >::type dir_type;
static type eval(original_type const& t)
{
return simplify(simplify(diff<Id>(t.term1)) - simplify(diff<Id>(t.term2)));
}
static dir_type eval(original_type const& t, Direction const& d)
{
return simplify(simplify(diff<Id>(t.term1,d)) - simplify(diff<Id>(t.term2,d)));
}
};
template<typename Id, typename Term, typename Direction>
struct Diff< Id, Negative<Term>, Direction >
......
......@@ -285,6 +285,19 @@ namespace AMDiS
}
inline value_type operator()(const int& iq) const { return eval(iq, int_<N>()); }
template <int I>
std::string str(int_<I>) const
{
return str(int_<I-1>()) + ", " + std::get<I>(super::term_tuple).str();
}
std::string str(int_<0>) const
{
return std::get<0>(super::term_tuple).str();
}
std::string str() const { return std::string("F(") + str(int_<N-1>()) + ")"; }
};
template<typename F, typename Term>
......
......@@ -139,6 +139,25 @@ namespace AMDiS
static type eval(Add<CValue<0>, Term> const& t)
{ return simplify(t.term2); }
};
/// X - 0 -> X
template<typename Term>
struct Simplify< Subtract<Term, CValue<0> >, typename boost::enable_if_c<!traits::is_ct_value<Term>::value>::type >
{
typedef typename Simplify<Term>::type type;
static type eval(Subtract<Term, CValue<0> > const& t)
{ return simplify(t.term1); }
};
/// 0 - X -> -X
template<typename Term>
struct Simplify< Subtract<CValue<0>, Term>, typename boost::enable_if_c<!traits::is_ct_value<Term>::value>::type >
{
typedef Negative<typename Simplify<Term>::type> type;
static type eval(Subtract<CValue<0>, Term> const& t)
{ return -simplify(t.term2); }
};
/// X * 0 -> 0
template<typename Term>
......
......@@ -72,9 +72,6 @@ namespace AMDiS {
void ProblemNonLin::solve(AdaptInfo *adaptInfo, bool b0, bool b1)
{
TEST_EXIT(nonLinSolver)("no non-linear solver!\n");
MSG("HERE A\n");
nonLinSolver->solve(solverMatrix, *solution, *rhs, adaptInfo, this);
}
......
......@@ -55,7 +55,7 @@ namespace AMDiS { namespace Parallel {
ifstream file;
file.open(partitioningFile.c_str());
TEST_EXIT(file.is_open())("Should not happen!\n");
TEST_EXIT(file.is_open())("Could not open initial partitioning file '%s'\n", partitioningFile.c_str());
int nElements = 0;
file >> nElements;
......
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