Commit f0dbbad4 authored by Praetorius, Simon's avatar Praetorius, Simon
Browse files

matrix*vector in expressions allowed

parent f5e1e642
...@@ -651,6 +651,10 @@ FILE(GLOB HEADERS "${SOURCE_DIR}/*.hh") ...@@ -651,6 +651,10 @@ FILE(GLOB HEADERS "${SOURCE_DIR}/*.hh")
INSTALL(FILES ${HEADERS} INSTALL(FILES ${HEADERS}
DESTINATION include/amdis/) DESTINATION include/amdis/)
FILE(GLOB HEADERS "${SOURCE_DIR}/*.hpp")
INSTALL(FILES ${HEADERS}
DESTINATION include/amdis/)
FILE(GLOB HEADERS "${SOURCE_DIR}/parallel/*.h") FILE(GLOB HEADERS "${SOURCE_DIR}/parallel/*.h")
INSTALL(FILES ${HEADERS} INSTALL(FILES ${HEADERS}
DESTINATION include/amdis/parallel/) DESTINATION include/amdis/parallel/)
......
...@@ -33,6 +33,15 @@ ...@@ -33,6 +33,15 @@
namespace AMDiS { namespace AMDiS {
/// Specifies which operation should be done after coarsening
typedef enum{
NO_OPERATION = 0,
COARSE_RESTRICT = 1,
COARSE_INTERPOL = 2,
REFINE_INTERPOL = 4
} RefineCoarsenOperation;
/** \ingroup DOFAdministration /** \ingroup DOFAdministration
* \brief * \brief
* Interface for objects that stores information indexed by DOF indices * Interface for objects that stores information indexed by DOF indices
...@@ -42,6 +51,10 @@ namespace AMDiS { ...@@ -42,6 +51,10 @@ namespace AMDiS {
class DOFIndexedBase class DOFIndexedBase
{ {
public: public:
DOFIndexedBase()
: coarsenOperation(COARSE_INTERPOL),
refineOperation(REFINE_INTERPOL) {}
virtual ~DOFIndexedBase() {} virtual ~DOFIndexedBase() {}
/// Returns the actual size. Must be overriden by sub classes /// Returns the actual size. Must be overriden by sub classes
...@@ -74,9 +87,38 @@ namespace AMDiS { ...@@ -74,9 +87,38 @@ namespace AMDiS {
/// The default behavior is to do nothing. /// The default behavior is to do nothing.
virtual void coarseRestrict(RCNeighbourList&, int) {} virtual void coarseRestrict(RCNeighbourList&, int) {}
/// Sets \ref coarsenOperation to op
inline void setCoarsenOperation(RefineCoarsenOperation op)
{
coarsenOperation = op;
}
/// Returns \ref coarsenOperation
inline RefineCoarsenOperation getCoarsenOperation()
{
return coarsenOperation;
}
/// Sets \ref refineOperation to op
inline void setRefineOperation(RefineCoarsenOperation op)
{
refineOperation = op;
}
/// Returns \ref refineOperation
inline RefineCoarsenOperation getRefineOperation()
{
return refineOperation;
}
/// Returns the finite element space of this DOFIndexed object. Must be /// Returns the finite element space of this DOFIndexed object. Must be
/// overriden in sub classes. /// overriden in sub classes.
virtual const FiniteElemSpace* getFeSpace() const = 0; virtual const FiniteElemSpace* getFeSpace() const = 0;
protected:
/// Specifies what operation should be performed after coarsening
RefineCoarsenOperation coarsenOperation;
RefineCoarsenOperation refineOperation;
}; };
/** \ingroup DOFAdministration /** \ingroup DOFAdministration
......
...@@ -276,14 +276,6 @@ namespace AMDiS { ...@@ -276,14 +276,6 @@ namespace AMDiS {
}; };
/// Specifies which operation should be done after coarsening
typedef enum{
NO_OPERATION = 0,
COARSE_RESTRICT = 1,
COARSE_INTERPOL = 2,
REFINE_INTERPOL = 4
} RefineCoarsenOperation;
/** \ingroup DOFAdministration /** \ingroup DOFAdministration
* \brief * \brief
...@@ -345,8 +337,7 @@ namespace AMDiS { ...@@ -345,8 +337,7 @@ namespace AMDiS {
public: public:
/// Empty constructor. No initialization! /// Empty constructor. No initialization!
DOFVector() DOFVector()
: DOFVectorBase<T>(), : DOFVectorBase<T>()
coarsenOperation(NO_OPERATION)
{} {}
/// Constructs a DOFVector with name n belonging to FiniteElemSpace f /// Constructs a DOFVector with name n belonging to FiniteElemSpace f
...@@ -396,30 +387,6 @@ namespace AMDiS { ...@@ -396,30 +387,6 @@ namespace AMDiS {
virtual void compressDOFIndexed(int first, int last, virtual void compressDOFIndexed(int first, int last,
std::vector<DegreeOfFreedom> &newDof); std::vector<DegreeOfFreedom> &newDof);
/// Sets \ref coarsenOperation to op
inline void setCoarsenOperation(RefineCoarsenOperation op)
{
coarsenOperation = op;
}
/// Returns \ref coarsenOperation
inline RefineCoarsenOperation getCoarsenOperation()
{
return coarsenOperation;
}
/// Sets \ref refineOperation to op
inline void setRefineOperation(RefineCoarsenOperation op)
{
refineOperation = op;
}
/// Returns \ref refineOperation
inline RefineCoarsenOperation getRefineOperation()
{
return refineOperation;
}
/// Restriction after coarsening. Implemented for DOFVector<double> /// Restriction after coarsening. Implemented for DOFVector<double>
inline void coarseRestrict(RCNeighbourList&, int) {} inline void coarseRestrict(RCNeighbourList&, int) {}
...@@ -672,10 +639,6 @@ namespace AMDiS { ...@@ -672,10 +639,6 @@ namespace AMDiS {
/// Data container /// Data container
std::vector<T> vec; std::vector<T> vec;
/// Specifies what operation should be performed after coarsening
RefineCoarsenOperation coarsenOperation;
RefineCoarsenOperation refineOperation;
}; };
......
...@@ -112,9 +112,7 @@ namespace AMDiS { ...@@ -112,9 +112,7 @@ namespace AMDiS {
template<typename T> template<typename T>
DOFVector<T>::DOFVector(const FiniteElemSpace* f, std::string n, bool addToSynch) DOFVector<T>::DOFVector(const FiniteElemSpace* f, std::string n, bool addToSynch)
: DOFVectorBase<T>(f, n), : DOFVectorBase<T>(f, n)
coarsenOperation(COARSE_INTERPOL),
refineOperation(REFINE_INTERPOL)
{ {
vec.resize(0); vec.resize(0);
init(f, n, addToSynch); init(f, n, addToSynch);
...@@ -1041,8 +1039,6 @@ namespace AMDiS { ...@@ -1041,8 +1039,6 @@ namespace AMDiS {
this->nBasFcts = rhs.nBasFcts; this->nBasFcts = rhs.nBasFcts;
vec = rhs.vec; vec = rhs.vec;
this->elementVector.change_dim(this->nBasFcts); this->elementVector.change_dim(this->nBasFcts);
coarsenOperation = rhs.coarsenOperation;
refineOperation = rhs.refineOperation;
this->operators = rhs.operators; this->operators = rhs.operators;
this->operatorFactor = rhs.operatorFactor; this->operatorFactor = rhs.operatorFactor;
......
...@@ -108,9 +108,6 @@ namespace AMDiS { ...@@ -108,9 +108,6 @@ namespace AMDiS {
else else
return Global::getGeo(d, dim); return Global::getGeo(d, dim);
} }
public:
friend class GLWindow;
}; };
......
...@@ -59,26 +59,26 @@ namespace AMDiS { ...@@ -59,26 +59,26 @@ namespace AMDiS {
/// Copy constructor for other of different value_type /// Copy constructor for other of different value_type
// TODO: notwendig? // TODO: notwendig?
template <typename S> // template <typename S>
Vector(Vector<S> const& rhs) // Vector(Vector<S> const& rhs)
: Serializable(), // : Serializable(),
size(rhs.getSize()), // size(rhs.getSize()),
valArray(new T[rhs.getSize()]) // valArray(size ? new T[size] : NULL)
{ // {
setValues(rhs.getValArray()); // setValues(rhs.valArray);
} // }
#if HAS_RVALUE_REFERENCES // #if HAS_RVALUE_REFERENCES
/// move constructor // /// move constructor
Vector(self&& other) // Vector(self&& other)
: Vector() // : Vector()
{ // {
swap(*this, other); // swap(*this, other);
} // }
#endif // #endif
/// Destructor. /// Destructor.
~Vector() virtual ~Vector()
{ {
if (valArray != NULL) { if (valArray != NULL) {
delete [] valArray; delete [] valArray;
...@@ -92,13 +92,13 @@ namespace AMDiS { ...@@ -92,13 +92,13 @@ namespace AMDiS {
} }
/// Change the size of the vector to newSize. /// Change the size of the vector to newSize.
inline void resize(int newSize) inline void resize(int s)
{ {
if (size != newSize && newSize > 0) { if (size != s && s > 0) {
if (valArray != NULL) if (valArray != NULL)
delete [] valArray; delete [] valArray;
valArray = new T[newSize]; valArray = new T[s];
size = newSize; size = s;
} }
} }
...@@ -107,15 +107,21 @@ namespace AMDiS { ...@@ -107,15 +107,21 @@ namespace AMDiS {
typename disable_if< boost::is_same<S, T>, self >::type & typename disable_if< boost::is_same<S, T>, self >::type &
operator=(Vector<S> const& other) operator=(Vector<S> const& other)
{ {
resize(other.getSize()); assert( size == other.getSize() );
// resize(other.getSize());
setValues(other.getValArray()); setValues(other.getValArray());
return *this; return *this;
} }
/// copy assignment operator /// copy assignment operator
self& operator=(self other) // self& operator=(self other)
// {
// swap(*this, other);
self& operator=(self const& other)
{ {
swap(*this, other); assert( size == other.getSize() );
setValues(other.getValArray());
return *this; return *this;
} }
...@@ -149,14 +155,22 @@ namespace AMDiS { ...@@ -149,14 +155,22 @@ namespace AMDiS {
typename enable_if< boost::is_convertible<S, T> >::type typename enable_if< boost::is_convertible<S, T> >::type
set(S value) set(S value)
{ {
std::fill(begin(), end(), value); for (T *thisIt = this->begin(); thisIt != this->end(); ++thisIt)
*thisIt = value;
// std::fill(begin(), end(), value);
} }
/// Sets all entries. /// Sets all entries.
template <typename S> template <typename S>
void setValues(const S* values) inline void setValues(const S* values)
{ {
std::copy(values, values + size, valArray); T *thisIt;
const S *valuesIt;
for (thisIt = this->begin(), valuesIt = values;
thisIt != this->end();
++thisIt, ++valuesIt)
*thisIt = *valuesIt;
// std::copy(values, values + size, valArray);
} }
/// Comparison operator. /// Comparison operator.
...@@ -275,14 +289,14 @@ namespace AMDiS { ...@@ -275,14 +289,14 @@ namespace AMDiS {
cols(other.getNumCols()) cols(other.getNumCols())
{ } { }
#if HAS_RVALUE_REFERENCES // #if HAS_RVALUE_REFERENCES
/// move constructor // /// move constructor
Matrix(self&& other) // Matrix(self&& other)
: Matrix() // : Matrix()
{ // {
swap(*this, other); // swap(*this, other);
} // }
#endif // #endif
/// Changes the size of the matrix to newRows x newCols. /// Changes the size of the matrix to newRows x newCols.
inline void resize(int newRows, int newCols) inline void resize(int newRows, int newCols)
...@@ -294,9 +308,16 @@ namespace AMDiS { ...@@ -294,9 +308,16 @@ namespace AMDiS {
} }
} }
self& operator=(self other) // self& operator=(self other)
// {
// swap(*this, other);
// return *this;
// }
self& operator=(self const& other)
{ {
swap(*this, other); assert( this->size == other.getSize() && rows == other.getNumRows() && cols == other.getNumCols() );
this->setValues(other.getValArray());
return *this; return *this;
} }
...@@ -304,7 +325,8 @@ namespace AMDiS { ...@@ -304,7 +325,8 @@ namespace AMDiS {
template <typename S> template <typename S>
inline self& operator=(const Matrix<S>& other) inline self& operator=(const Matrix<S>& other)
{ {
resize(other.getNumRows(), other.getNumCols()); assert( rows == other.getNumRows() && cols == other.getNumCols() );
// resize(other.getNumRows(), other.getNumCols());
this->setValues(other.getValArray()); this->setValues(other.getValArray());
return *this; return *this;
} }
......
...@@ -55,7 +55,7 @@ namespace AMDiS ...@@ -55,7 +55,7 @@ namespace AMDiS
typedef typename boost::mpl::if_c< (sizeof(T1) > sizeof(T2)), T1, T2 >::type type; typedef typename boost::mpl::if_c< (sizeof(T1) > sizeof(T2)), T1, T2 >::type type;
}; };
#ifdef HAS_CPP11_DECLTYPE #if HAS_DECLTYPE
/// determines the type of the product T1*T2 /// determines the type of the product T1*T2
template<typename T1, typename T2> template<typename T1, typename T2>
...@@ -158,6 +158,15 @@ namespace AMDiS ...@@ -158,6 +158,15 @@ namespace AMDiS
}; };
/// Matrix*Vector => Vector
template<template<class> class MatrixType, typename T1, template<class> class VectorType, typename T2>
struct mult_type_dispatch<MatrixType<T1>, VectorType<T2>, tag::matrix, tag::vector>
{
typedef typename mult_type<T1, T2>::type value_type;
typedef VectorType<value_type> type;
};
// addition types // addition types
// _________________________________________________________________________ // _________________________________________________________________________
template<typename T1, typename T2, typename Category1, typename Category2> template<typename T1, typename T2, typename Category1, typename Category2>
...@@ -215,7 +224,7 @@ namespace AMDiS ...@@ -215,7 +224,7 @@ namespace AMDiS
typedef Container<value_type> type; typedef Container<value_type> type;
}; };
#endif // endif(HAS_CPP11_DECLTYPE) #endif // endif(HAS_DECLTYPE)
} // end namespace traits } // end namespace traits
......
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