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 {
(!adoptFlag.isSet(INIT_MESH) &&
(initFlag.isSet(INIT_SYSTEM) || initFlag.isSet(INIT_FE_SPACE))))
createMesh();
// NOTE: why using CREATE_MESH with adoptFlag.isSet(INIT_MESH) ???
// (since then meshes is replaced by the adoptProblem.meshes)
if (adoptProblem &&
(adoptFlag.isSet(INIT_MESH) ||
adoptFlag.isSet(INIT_SYSTEM) ||
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();
componentMeshes.clear();
if (meshes.size() == 1)
componentMeshes.resize(nComponents, meshes[0]);
else if (adoptProblem->getNumComponents() >= nComponents) {
......@@ -194,7 +200,7 @@ namespace AMDiS {
}
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 {
public StandardProblemIteration
{
using ProblemStatType::getName;
using ProblemStatSeq::info;
/// Constructor
ProblemStat(std::string nameStr,
......
......@@ -99,6 +99,9 @@ namespace AMDiS
namespace result_of
{
template<class T>
struct void_{ typedef void type; };
/// extract result type from function pointers
template <class FPtr>
struct Function;
......@@ -115,11 +118,11 @@ namespace AMDiS
typedef R type;
};
template<class T>
template <class T>
typename Function<T>::type function_helper(T);
/// extract result type from functors
template <class F>
template <class F, class Eanbled = void>
struct Functor
{
typedef decltype(function_helper(&F::operator())) type;
......@@ -130,6 +133,19 @@ namespace AMDiS
{
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
......@@ -180,22 +196,23 @@ namespace AMDiS
/// Operator term with arbitrary number of sub-term (expressions)
template<typename... Terms>
template <class... Terms>
struct LazyOperatorTerms : public LazyOperatorTermBase
{
std::tuple<Terms...> term_tuple;
template<typename... Terms_>
template <class... Terms_>
LazyOperatorTerms(Terms_... terms_)
: term_tuple(terms_...) {}
: term_tuple(terms_...)
{ }
template<typename List>
template <class List>
inline void 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,
SubAssembler* subAssembler, Quadrature *quad,
const BasisFunction *basisFct = NULL)
......@@ -203,7 +220,7 @@ namespace AMDiS
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,
SubAssembler* subAssembler, Quadrature *quad,
const BasisFunction *basisFct = NULL)
......@@ -221,7 +238,7 @@ namespace AMDiS
namespace expressions
{
/// Functor that takes arbitrary number of arguments
template<typename F, typename... Terms>
template <class F, class... Terms>
struct FunctionN : public LazyOperatorTerms<Terms...>
{
typedef LazyOperatorTerms<Terms...> super;
......@@ -232,19 +249,19 @@ namespace AMDiS
F f; ///< the functor
template<typename... Terms_>
FunctionN(const F& f_, Terms_... terms_)
template <class... Terms_>
FunctionN(F&& f_, Terms_... terms_)
: super(terms_...), f(f_) {}
// call f.getDegree() function
template<int I, typename... Terms_>
int getDegree(int_<I>, const Terms_&... terms) const
template<int I, class... Terms_>
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_>
int getDegree(int_<0>, const Terms_&... terms) const
template <class... Terms_>
int getDegree(int_<0>, Terms_&&... terms) const
{
return traits::functor_degree<F>::eval(f, terms.getDegree()...);
}
......@@ -255,14 +272,14 @@ namespace AMDiS
}
// call f.operator()(...)
template<int I, typename... Terms_>
inline value_type eval(const int& iq, int_<I>, const Terms_&... terms) const
template <int I, class... Terms_>
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_>
inline value_type eval(const int& iq, int_<0>, Terms_... terms) const
template <class... Terms_>
inline value_type eval(const int& iq, int_<0>, Terms_&&... terms) const
{
return f(terms(iq)...); // f(term1(iq), term2(iq), term3(iq),...)
}
......@@ -284,7 +301,7 @@ namespace AMDiS
/// A wrapper functor for AMDiS::AbstractFunctions
template<typename TOut, typename TIn>
template <class TOut, class TIn>
struct Wrapper : public FunctorBase
{
typedef TOut result_type;
......@@ -300,6 +317,53 @@ namespace AMDiS
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
......@@ -357,6 +421,20 @@ namespace AMDiS
inline expressions::Wrapper<TOut,TIn> wrap(AbstractFunction<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
#endif // AMDIS_FUNCTOR_N_EXPRESSION_HPP
......@@ -504,7 +504,7 @@ namespace AMDiS { namespace io {
for (size_t i = 0; i < size; i++)
values[i] = static_cast<double>(data[i]);
delete data;
delete [] data;
}
void readFile(string filename, Mesh *mesh,
......
......@@ -541,7 +541,7 @@ namespace AMDiS { namespace io {
data[i] = static_cast<T>(values[i]);
file.write(reinterpret_cast<char*>(&data[0]), sizeof(T) * size);
delete[] data;
delete [] data;
return sizeof(T) * size;
}
......
......@@ -43,8 +43,8 @@
#include <boost/lexical_cast.hpp>
#ifdef HAVE_COMPRESSION
#include <boost/iostreams/filter/gzip.hpp>
#include <boost/iostreams/filter/bzip2.hpp>
// #include <boost/iostreams/filter/gzip.hpp>
// #include <boost/iostreams/filter/bzip2.hpp>
#endif
#include "DOFVector.h"
......@@ -68,18 +68,18 @@ namespace AMDiS
boost::iostreams::filtering_ostream file;
#ifdef HAVE_COMPRESSION
switch (compress) {
case GZIP:
file.push(boost::iostreams::gzip_compressor());
name.append(".gz");
break;
case BZIP2:
file.push(boost::iostreams::bzip2_compressor());
name.append(".bz2");
break;
default:
break;
}
// switch (compress) {
// case GZIP:
// file.push(boost::iostreams::gzip_compressor());
// name.append(".gz");
// break;
// case BZIP2:
// file.push(boost::iostreams::bzip2_compressor());
// name.append(".bz2");
// break;
// default:
// break;
// }
#endif
{
......
......@@ -130,7 +130,7 @@ namespace AMDiS {
/// Constructor for block-matrices
BlockMapper(const SolverMatrix<Matrix<DOFMatrix* > >& sm )
: nComp(sm.getOriginalMat()->getSize()),
: nComp(sm.getOriginalMat()->getNumRows()),
rowOffset(0), colOffset(0), nrow(0), ncol(0), sizes(nComp)
{
const Matrix<DOFMatrix* >& orMat(*sm.getOriginalMat());
......@@ -144,7 +144,7 @@ namespace AMDiS {
/// Constructor for block-matrices
BlockMapper(const Matrix<DOFMatrix*>& orMat )
: nComp(orMat.getSize()),
: nComp(orMat.getNumRows()),
rowOffset(0), colOffset(0), nrow(0), ncol(0), sizes(nComp)
{
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