Commit 1cd71562 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

small errors in Arh3Reader/ rh3Writer corrected and ProblemStat::initialize...

small errors in Arh3Reader/ rh3Writer corrected and ProblemStat::initialize modified to allow bahavior as in previous versions, for expressions::functors a degree mapper was added and the BlockMapper now is initialized with the correct number of components
parent b617e3e5
...@@ -174,13 +174,19 @@ namespace AMDiS { ...@@ -174,13 +174,19 @@ namespace AMDiS {
(!adoptFlag.isSet(INIT_MESH) && (!adoptFlag.isSet(INIT_MESH) &&
(initFlag.isSet(INIT_SYSTEM) || initFlag.isSet(INIT_FE_SPACE)))) (initFlag.isSet(INIT_SYSTEM) || initFlag.isSet(INIT_FE_SPACE))))
createMesh(); createMesh();
// NOTE: why using CREATE_MESH with adoptFlag.isSet(INIT_MESH) ???
// (since then meshes is replaced by the adoptProblem.meshes)
if (adoptProblem && if (adoptProblem &&
(adoptFlag.isSet(INIT_MESH) || (adoptFlag.isSet(INIT_MESH) ||
adoptFlag.isSet(INIT_SYSTEM) || adoptFlag.isSet(INIT_SYSTEM) ||
adoptFlag.isSet(INIT_FE_SPACE))) adoptFlag.isSet(INIT_FE_SPACE)))
{ {
if (meshes.size() != 0) {
WARNING("meshes created, by using CREATE_MESH, but overwritten, by using adoptFlag.isSet(INIT_MESH)\n");
}
meshes = adoptProblem->getMeshes(); meshes = adoptProblem->getMeshes();
componentMeshes.clear();
if (meshes.size() == 1) if (meshes.size() == 1)
componentMeshes.resize(nComponents, meshes[0]); componentMeshes.resize(nComponents, meshes[0]);
else if (adoptProblem->getNumComponents() >= nComponents) { else if (adoptProblem->getNumComponents() >= nComponents) {
...@@ -194,7 +200,7 @@ namespace AMDiS { ...@@ -194,7 +200,7 @@ namespace AMDiS {
} }
if (nAddComponents > 0) { if (nAddComponents > 0) {
WARNING("Additional meshed can not be adopted from adoptProblem. You have to initialize these meshes manually!\n"); WARNING("Additional meshes can not be adopted from adoptProblem. You have to initialize these meshes manually!\n");
} }
} }
} }
......
...@@ -697,6 +697,7 @@ namespace AMDiS { ...@@ -697,6 +697,7 @@ namespace AMDiS {
public StandardProblemIteration public StandardProblemIteration
{ {
using ProblemStatType::getName; using ProblemStatType::getName;
using ProblemStatSeq::info;
/// Constructor /// Constructor
ProblemStat(std::string nameStr, ProblemStat(std::string nameStr,
......
...@@ -99,6 +99,9 @@ namespace AMDiS ...@@ -99,6 +99,9 @@ namespace AMDiS
namespace result_of namespace result_of
{ {
template<class T>
struct void_{ typedef void type; };
/// extract result type from function pointers /// extract result type from function pointers
template <class FPtr> template <class FPtr>
struct Function; struct Function;
...@@ -115,11 +118,11 @@ namespace AMDiS ...@@ -115,11 +118,11 @@ namespace AMDiS
typedef R type; typedef R type;
}; };
template<class T> template <class T>
typename Function<T>::type function_helper(T); typename Function<T>::type function_helper(T);
/// extract result type from functors /// extract result type from functors
template <class F> template <class F, class Eanbled = void>
struct Functor struct Functor
{ {
typedef decltype(function_helper(&F::operator())) type; typedef decltype(function_helper(&F::operator())) type;
...@@ -130,6 +133,19 @@ namespace AMDiS ...@@ -130,6 +133,19 @@ namespace AMDiS
{ {
typedef R type; typedef R type;
}; };
template <class F>
struct Functor<F, typename void_<typename F::value_type>::type>
{
typedef typename F::value_type type;
};
template <class F>
struct Functor<F, typename void_<typename F::result_type>::type>
{
typedef typename F::result_type type;
};
} // end namespace result_of } // end namespace result_of
...@@ -180,22 +196,23 @@ namespace AMDiS ...@@ -180,22 +196,23 @@ namespace AMDiS
/// Operator term with arbitrary number of sub-term (expressions) /// Operator term with arbitrary number of sub-term (expressions)
template<typename... Terms> template <class... Terms>
struct LazyOperatorTerms : public LazyOperatorTermBase struct LazyOperatorTerms : public LazyOperatorTermBase
{ {
std::tuple<Terms...> term_tuple; std::tuple<Terms...> term_tuple;
template<typename... Terms_> template <class... Terms_>
LazyOperatorTerms(Terms_... terms_) LazyOperatorTerms(Terms_... terms_)
: term_tuple(terms_...) {} : term_tuple(terms_...)
{ }
template<typename List> template <class List>
inline void insertFeSpaces(List& feSpaces) inline void insertFeSpaces(List& feSpaces)
{ {
for_each(term_tuple, detail::InsertFeSpaces<List>(feSpaces)); for_each(term_tuple, detail::InsertFeSpaces<List>(feSpaces));
} }
template<typename OT> template <class OT>
inline void initElement(OT* ot, const ElInfo* elInfo, inline void initElement(OT* ot, const ElInfo* elInfo,
SubAssembler* subAssembler, Quadrature *quad, SubAssembler* subAssembler, Quadrature *quad,
const BasisFunction *basisFct = NULL) const BasisFunction *basisFct = NULL)
...@@ -203,7 +220,7 @@ namespace AMDiS ...@@ -203,7 +220,7 @@ namespace AMDiS
for_each(term_tuple, detail::InitElement<OT>(ot, elInfo, subAssembler, quad, basisFct)); for_each(term_tuple, detail::InitElement<OT>(ot, elInfo, subAssembler, quad, basisFct));
} }
template<typename OT> template <class OT>
inline void initElement(OT* ot, const ElInfo* smallElInfo, const ElInfo* largeElInfo, inline void initElement(OT* ot, const ElInfo* smallElInfo, const ElInfo* largeElInfo,
SubAssembler* subAssembler, Quadrature *quad, SubAssembler* subAssembler, Quadrature *quad,
const BasisFunction *basisFct = NULL) const BasisFunction *basisFct = NULL)
...@@ -221,7 +238,7 @@ namespace AMDiS ...@@ -221,7 +238,7 @@ namespace AMDiS
namespace expressions namespace expressions
{ {
/// Functor that takes arbitrary number of arguments /// Functor that takes arbitrary number of arguments
template<typename F, typename... Terms> template <class F, class... Terms>
struct FunctionN : public LazyOperatorTerms<Terms...> struct FunctionN : public LazyOperatorTerms<Terms...>
{ {
typedef LazyOperatorTerms<Terms...> super; typedef LazyOperatorTerms<Terms...> super;
...@@ -232,19 +249,19 @@ namespace AMDiS ...@@ -232,19 +249,19 @@ namespace AMDiS
F f; ///< the functor F f; ///< the functor
template<typename... Terms_> template <class... Terms_>
FunctionN(const F& f_, Terms_... terms_) FunctionN(F&& f_, Terms_... terms_)
: super(terms_...), f(f_) {} : super(terms_...), f(f_) {}
// call f.getDegree() function // call f.getDegree() function
template<int I, typename... Terms_> template<int I, class... Terms_>
int getDegree(int_<I>, const Terms_&... terms) const int getDegree(int_<I>, Terms_&&... terms) const
{ {
return getDegree(int_<I-1>(), std::get<I-1>(super::term_tuple), terms...); return getDegree(int_<I-1>(), std::get<I-1>(super::term_tuple), std::forward<Terms_>(terms)...);
} }
template<typename... Terms_> template <class... Terms_>
int getDegree(int_<0>, const Terms_&... terms) const int getDegree(int_<0>, Terms_&&... terms) const
{ {
return traits::functor_degree<F>::eval(f, terms.getDegree()...); return traits::functor_degree<F>::eval(f, terms.getDegree()...);
} }
...@@ -255,14 +272,14 @@ namespace AMDiS ...@@ -255,14 +272,14 @@ namespace AMDiS
} }
// call f.operator()(...) // call f.operator()(...)
template<int I, typename... Terms_> template <int I, class... Terms_>
inline value_type eval(const int& iq, int_<I>, const Terms_&... terms) const inline value_type eval(const int& iq, int_<I>, Terms_&&... terms) const
{ {
return eval(iq, int_<I-1>(), std::get<I-1>(super::term_tuple), terms...); return eval(iq, int_<I-1>(), std::get<I-1>(super::term_tuple), std::forward<Terms_>(terms)...);
} }
template<typename... Terms_> template <class... Terms_>
inline value_type eval(const int& iq, int_<0>, Terms_... terms) const inline value_type eval(const int& iq, int_<0>, Terms_&&... terms) const
{ {
return f(terms(iq)...); // f(term1(iq), term2(iq), term3(iq),...) return f(terms(iq)...); // f(term1(iq), term2(iq), term3(iq),...)
} }
...@@ -284,7 +301,7 @@ namespace AMDiS ...@@ -284,7 +301,7 @@ namespace AMDiS
/// A wrapper functor for AMDiS::AbstractFunctions /// A wrapper functor for AMDiS::AbstractFunctions
template<typename TOut, typename TIn> template <class TOut, class TIn>
struct Wrapper : public FunctorBase struct Wrapper : public FunctorBase
{ {
typedef TOut result_type; typedef TOut result_type;
...@@ -300,6 +317,53 @@ namespace AMDiS ...@@ -300,6 +317,53 @@ namespace AMDiS
AbstractFunction<TOut, TIn>* fct; AbstractFunction<TOut, TIn>* fct;
}; };
template <int D, class F>
struct DegreeWrapper : public FunctorBase
{
typedef typename result_of::Functor<F>::type result_type;
DegreeWrapper(F&& fct_) : fct(fct_) {}
template <class... Int>
int getDegree(Int... degrees) const { return D; }
template <class... Ts>
result_type operator()(Ts&&... args) const
{
return fct(args...);
}
protected:
F fct;
};
template <class F, class DegF>
struct DegreeWrapper2 : public FunctorBase
{
typedef typename result_of::Functor<F>::type result_type;
DegreeWrapper2(F&& fct_, DegF&& degfct_)
: fct(fct_), degfct(degfct_) {}
template <class... Int>
int getDegree(Int... degrees) const
{
return degfct(degrees...);
}
template <class... Ts>
result_type operator()(Ts&&... args) const
{
return fct(args...);
}
protected:
F fct;
DegF degfct;
};
} // end namespace expressions } // end namespace expressions
...@@ -357,6 +421,20 @@ namespace AMDiS ...@@ -357,6 +421,20 @@ namespace AMDiS
inline expressions::Wrapper<TOut,TIn> wrap(AbstractFunction<TOut, TIn>* fct) inline expressions::Wrapper<TOut,TIn> wrap(AbstractFunction<TOut, TIn>* fct)
{ return expressions::Wrapper<TOut,TIn>(fct); } { return expressions::Wrapper<TOut,TIn>(fct); }
template <int Degree, class F>
inline expressions::DegreeWrapper<Degree, F>
deg(F&& fct)
{
return expressions::DegreeWrapper<Degree, F>(std::forward<F>(fct));
}
template <class F, class DegF>
inline expressions::DegreeWrapper2<F, DegF>
deg(F&& fct, DegF&& degfct)
{
return expressions::DegreeWrapper2<F, DegF>(std::forward<F>(fct), std::forward<DegF>(degfct));
}
} // end namespace AMDiS } // end namespace AMDiS
#endif // AMDIS_FUNCTOR_N_EXPRESSION_HPP #endif // AMDIS_FUNCTOR_N_EXPRESSION_HPP
...@@ -504,7 +504,7 @@ namespace AMDiS { namespace io { ...@@ -504,7 +504,7 @@ namespace AMDiS { namespace io {
for (size_t i = 0; i < size; i++) for (size_t i = 0; i < size; i++)
values[i] = static_cast<double>(data[i]); values[i] = static_cast<double>(data[i]);
delete data; delete [] data;
} }
void readFile(string filename, Mesh *mesh, void readFile(string filename, Mesh *mesh,
......
...@@ -541,7 +541,7 @@ namespace AMDiS { namespace io { ...@@ -541,7 +541,7 @@ namespace AMDiS { namespace io {
data[i] = static_cast<T>(values[i]); data[i] = static_cast<T>(values[i]);
file.write(reinterpret_cast<char*>(&data[0]), sizeof(T) * size); file.write(reinterpret_cast<char*>(&data[0]), sizeof(T) * size);
delete[] data; delete [] data;
return sizeof(T) * size; return sizeof(T) * size;
} }
......
...@@ -43,8 +43,8 @@ ...@@ -43,8 +43,8 @@
#include <boost/lexical_cast.hpp> #include <boost/lexical_cast.hpp>
#ifdef HAVE_COMPRESSION #ifdef HAVE_COMPRESSION
#include <boost/iostreams/filter/gzip.hpp> // #include <boost/iostreams/filter/gzip.hpp>
#include <boost/iostreams/filter/bzip2.hpp> // #include <boost/iostreams/filter/bzip2.hpp>
#endif #endif
#include "DOFVector.h" #include "DOFVector.h"
...@@ -68,18 +68,18 @@ namespace AMDiS ...@@ -68,18 +68,18 @@ namespace AMDiS
boost::iostreams::filtering_ostream file; boost::iostreams::filtering_ostream file;
#ifdef HAVE_COMPRESSION #ifdef HAVE_COMPRESSION
switch (compress) { // switch (compress) {
case GZIP: // case GZIP:
file.push(boost::iostreams::gzip_compressor()); // file.push(boost::iostreams::gzip_compressor());
name.append(".gz"); // name.append(".gz");
break; // break;
case BZIP2: // case BZIP2:
file.push(boost::iostreams::bzip2_compressor()); // file.push(boost::iostreams::bzip2_compressor());
name.append(".bz2"); // name.append(".bz2");
break; // break;
default: // default:
break; // break;
} // }
#endif #endif
{ {
......
...@@ -130,7 +130,7 @@ namespace AMDiS { ...@@ -130,7 +130,7 @@ namespace AMDiS {
/// Constructor for block-matrices /// Constructor for block-matrices
BlockMapper(const SolverMatrix<Matrix<DOFMatrix* > >& sm ) BlockMapper(const SolverMatrix<Matrix<DOFMatrix* > >& sm )
: nComp(sm.getOriginalMat()->getSize()), : nComp(sm.getOriginalMat()->getNumRows()),
rowOffset(0), colOffset(0), nrow(0), ncol(0), sizes(nComp) rowOffset(0), colOffset(0), nrow(0), ncol(0), sizes(nComp)
{ {
const Matrix<DOFMatrix* >& orMat(*sm.getOriginalMat()); const Matrix<DOFMatrix* >& orMat(*sm.getOriginalMat());
...@@ -144,7 +144,7 @@ namespace AMDiS { ...@@ -144,7 +144,7 @@ namespace AMDiS {
/// Constructor for block-matrices /// Constructor for block-matrices
BlockMapper(const Matrix<DOFMatrix*>& orMat ) BlockMapper(const Matrix<DOFMatrix*>& orMat )
: nComp(orMat.getSize()), : nComp(orMat.getNumRows()),
rowOffset(0), colOffset(0), nrow(0), ncol(0), sizes(nComp) rowOffset(0), colOffset(0), nrow(0), ncol(0), sizes(nComp)
{ {
const int ns = orMat.getNumRows(); const int ns = orMat.getNumRows();
......
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