Commit 27235c55 authored by Thomas Witkowski's avatar Thomas Witkowski

Parallel type changes.

parent a8523376
......@@ -97,6 +97,10 @@ namespace AMDiS {
class VertexInfo;
class VertexVector;
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
class FeSpaceDofMap;
#endif
struct BoundaryObject;
struct AtomicBoundary;
......
......@@ -26,6 +26,9 @@
#include "BoundaryManager.h"
#include "Assembler.h"
#include "Serializer.h"
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
#include "parallel/ParallelDofMapping.h"
#endif
namespace AMDiS {
......@@ -233,8 +236,9 @@ namespace AMDiS {
if (condition && condition->isDirichlet()) {
if (condition->applyBoundaryCondition()) {
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
if ((*rankDofs)[rowIndices[i]])
if (dofMap->isRankDof(rowIndices[i]))
applyDBCs.insert(static_cast<int>(row));
#else
applyDBCs.insert(static_cast<int>(row));
......@@ -514,4 +518,10 @@ namespace AMDiS {
inserter = new inserter_type(matrix, nnz_per_row);
}
void DOFMatrix::setDofMap(FeSpaceDofMap& m)
{
dofMap = &m;
}
}
......@@ -39,6 +39,8 @@
namespace AMDiS {
using namespace std;
/** \ingroup DOFAdministration
* \brief
* A DOFMatrix is a sparse matrix representation for matrices that work
......@@ -65,18 +67,17 @@ namespace AMDiS {
/// Symbolic constant for an unused matrix entry
static const int UNUSED_ENTRY = -1;
/** \brief
* Symbolic constant for an unused entry which is not followed by any
* used entry in this row
*/
/// Symbolic constant for an unused entry which is not followed by any
/// used entry in this row
static const int NO_MORE_ENTRIES = -2;
public:
DOFMatrix();
/// Constructs a DOFMatrix with name n and the given row and olumn FeSpaces.
DOFMatrix(const FiniteElemSpace* rowFeSpace, const FiniteElemSpace* colFeSpace,
std::string n = "");
DOFMatrix(const FiniteElemSpace* rowFeSpace,
const FiniteElemSpace* colFeSpace,
string n = "");
/// Copy-Constructor
DOFMatrix(const DOFMatrix& rhs);
......@@ -102,15 +103,15 @@ namespace AMDiS {
}
// Only to get rid of the abstract functions, I hope they are not used
std::vector<bool>::iterator begin()
vector<bool>::iterator begin()
{
ERROR_EXIT("Shouldn't be used, only fake."); std::vector<bool> v;
ERROR_EXIT("Shouldn't be used, only fake."); vector<bool> v;
return v.begin();
}
std::vector<bool>::iterator end()
vector<bool>::iterator end()
{
ERROR_EXIT("Shouldn't be used, only fake."); std::vector<bool> v;
ERROR_EXIT("Shouldn't be used, only fake."); vector<bool> v;
return v.end();
}
......@@ -128,7 +129,7 @@ namespace AMDiS {
}
/// DOFMatrix does not need to be compressed before assembling, when using MTL4.
void compressDOFIndexed(int first, int last, std::vector<DegreeOfFreedom> &newDOF)
void compressDOFIndexed(int first, int last, vector<DegreeOfFreedom> &newDOF)
{}
/// Implements DOFIndexedBase::freeDOFContent()
......@@ -152,39 +153,38 @@ namespace AMDiS {
/// Multiplication with a scalar.
void scal(double s);
/** \brief
* Adds an operator to the DOFMatrix. A factor, that is multipled
* to the operator, and a multilier factor for the estimator may be
* also given.
*/
void addOperator(Operator *op, double* factor = NULL, double* estFactor = NULL);
/// Adds an operator to the DOFMatrix. A factor, that is multipled to the
/// operator, and a multilier factor for the estimator may be also given.
void addOperator(Operator *op,
double* factor = NULL,
double* estFactor = NULL);
inline std::vector<double*>::iterator getOperatorFactorBegin()
inline vector<double*>::iterator getOperatorFactorBegin()
{
return operatorFactor.begin();
}
inline std::vector<double*>::iterator getOperatorFactorEnd()
inline vector<double*>::iterator getOperatorFactorEnd()
{
return operatorFactor.end();
}
inline std::vector<double*>::iterator getOperatorEstFactorBegin()
inline vector<double*>::iterator getOperatorEstFactorBegin()
{
return operatorEstFactor.begin();
}
inline std::vector<double*>::iterator getOperatorEstFactorEnd()
inline vector<double*>::iterator getOperatorEstFactorEnd()
{
return operatorEstFactor.end();
}
inline std::vector<Operator*>::iterator getOperatorsBegin()
inline vector<Operator*>::iterator getOperatorsBegin()
{
return operators.begin();
}
inline std::vector<Operator*>::iterator getOperatorsEnd()
inline vector<Operator*>::iterator getOperatorsEnd()
{
return operators.end();
}
......@@ -237,11 +237,9 @@ namespace AMDiS {
ElInfo* rowElInfo,
ElInfo* colElInfo);
/* \brief
* That function must be called after the matrix assembling has been finished.
* This makes it possible to start some cleanup or matrix data compressing
* procedures.
*/
/// That function must be called after the matrix assembling has been
/// finished. This makes it possible to start some cleanup or matrix
/// data compressing procedures.
void finishAssembling();
/** \brief
......@@ -252,10 +250,8 @@ namespace AMDiS {
*/
void startInsertion(int nnz_per_row = 10);
/** \brief
* Finishes insertion. For compressed matrix types, this is where the
* compression happens.
*/
/// Finishes insertion. For compressed matrix types, this is where the
/// compression happens.
void finishInsertion()
{
FUNCNAME("DOFMatrix::finishInsertion()");
......@@ -266,10 +262,8 @@ namespace AMDiS {
inserter= 0;
}
/** \brief
* Returns whether restriction should be performed after coarsening
* (false by default)
*/
/// Returns whether restriction should be performed after coarsening
/// (false by default)
virtual bool coarseRestrict()
{
return false;
......@@ -299,17 +293,15 @@ namespace AMDiS {
return num_rows(matrix);
}
/** \brief
* Returns the number of used rows (equal to number of used DOFs in
* the row FE space).
*/
/// Returns the number of used rows (equal to number of used DOFs in
/// the row FE space).
inline int getUsedSize() const
{
return rowFeSpace->getAdmin()->getUsedSize();
}
/// Returns \ref name
inline std::string getName() const
inline string getName() const
{
return name;
}
......@@ -326,10 +318,8 @@ namespace AMDiS {
/// Changes col at logical indices a,b to c
void changeColOfEntry(DegreeOfFreedom a, DegreeOfFreedom b, DegreeOfFreedom c);
/** \brief
* Creates an entry with logical indices irow, icol if there is no entry
* yet. Than sign * entry is added to the value at this logical indices
*/
/// Creates an entry with logical indices irow, icol if there is no entry
/// yet. Than sign * entry is added to the value at this logical indices
void addSparseDOFEntry(double sign,
int irow, int jcol, double entry,
bool add = true);
......@@ -350,17 +340,17 @@ namespace AMDiS {
bool symmetric();
inline std::vector<Operator*>& getOperators()
inline vector<Operator*>& getOperators()
{
return operators;
}
inline std::vector<double*>& getOperatorFactor()
inline vector<double*>& getOperatorFactor()
{
return operatorFactor;
}
inline std::vector<double*>& getOperatorEstFactor()
inline vector<double*>& getOperatorEstFactor()
{
return operatorEstFactor;
}
......@@ -399,65 +389,53 @@ namespace AMDiS {
}
/// Writes the matrix to an output stream.
void serialize(std::ostream &out);
void serialize(ostream &out);
/// Reads a matrix from an input stream.
void deserialize(std::istream &in);
void deserialize(istream &in);
///
int memsize();
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
void setRankDofs(std::map<DegreeOfFreedom, bool>& dofmap)
{
rankDofs = &dofmap;
}
void setDofMap(FeSpaceDofMap& m);
#endif
protected:
/** \brief
* Pointer to a FiniteElemSpace with information about corresponding row DOFs
* and basis functions
*/
/// Pointer to a FiniteElemSpace with information about corresponding row DOFs
/// and basis functions
const FiniteElemSpace *rowFeSpace;
/** \brief
* Pointer to a FiniteElemSpace with information about corresponding
* column DOFs and basis functions
*/
/// Pointer to a FiniteElemSpace with information about corresponding
/// column DOFs and basis functions
const FiniteElemSpace *colFeSpace;
/// Name of the DOFMatrix
std::string name;
string name;
/// Sparse matrix, type is a template parameter by default compressed2D<double>
/// Sparse matrix, type is a template parameter by
/// default compressed2D<double>
base_matrix_type matrix;
/// Used while mesh traversal
static DOFMatrix *traversePtr;
/** \brief
* Pointers to all operators of the equation systems. Are used in the
* assembling process.
*/
std::vector<Operator*> operators;
/// Pointers to all operators of the equation systems. Are used in the
/// assembling process.
vector<Operator*> operators;
/** \brief
* Defines for each operator a factor which is used to scal the element
* matrix after the assembling process of the operator.
*/
std::vector<double*> operatorFactor;
/// Defines for each operator a factor which is used to scal the element
/// matrix after the assembling process of the operator.
vector<double*> operatorFactor;
///
std::vector<double*> operatorEstFactor;
vector<double*> operatorEstFactor;
///
BoundaryManager *boundaryManager;
/** \brief
* If false, the matrix is a diagonal matrix within a matrix of DOF matrices.
* Otherwise the value is true, and the matrix is an off-diagonal matrix.
*/
/// If false, the matrix is a diagonal matrix within a matrix of DOF matrices.
/// Otherwise the value is true, and the matrix is an off-diagonal matrix.
bool coupleMatrix;
/// Temporary variable used in assemble()
......@@ -470,10 +448,10 @@ namespace AMDiS {
int nCol;
/// Maps local row indices of an element to global matrix indices.
std::vector<DegreeOfFreedom> rowIndices;
vector<DegreeOfFreedom> rowIndices;
/// Maps local col indices of an element to global matrix indices.
std::vector<DegreeOfFreedom> colIndices;
vector<DegreeOfFreedom> colIndices;
/* \brief
* A set of row indices. When assembling the DOF matrix, all rows, that
......@@ -492,10 +470,10 @@ namespace AMDiS {
int nnzPerRow;
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
/// Stores for the DOFs of the row FE spaces whether they are owned by the
/// rank or not. This is used to ensure that Dirichlet BC is handled
/// correctly in parallel computations.
std::map<DegreeOfFreedom, bool> *rankDofs;
/// Is used in parallel computations to check whether specific DOFs in the
/// row FE spaces are owned by the rank or not. This is used to ensure that
/// Dirichlet BC is handled correctly in parallel computations.
FeSpaceDofMap *dofMap;
#endif
/// Inserter object: implemented as pointer, allocated and deallocated as needed
......
......@@ -42,9 +42,14 @@
#include "BasisFunction.h"
#include "FiniteElemSpace.h"
#include "SurfaceQuadrature.h"
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
#include "parallel/ParallelDofMapping.h"
#endif
namespace AMDiS {
using namespace std;
template<typename T>
class DOFVectorBase : public DOFIndexed<T>
{
......@@ -57,25 +62,21 @@ namespace AMDiS {
nBasFcts(0)
{
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
rankDofs = NULL;
dofMap = NULL;
#endif
}
DOFVectorBase(const FiniteElemSpace *f, std::string n);
DOFVectorBase(const FiniteElemSpace *f, string n);
virtual ~DOFVectorBase();
/** \brief
* For the given element, this function returns an array of all DOFs of this
* DOFVector that are defined on this element.
*/
/// For the given element, this function returns an array of all DOFs of
/// this DOFVector that are defined on this element.
virtual void getLocalVector(const Element *el,
mtl::dense_vector<T>& localVec) const;
/** \brief
* Evaluates the DOF vector at a set of quadrature points defined on the
* given element.
*/
/// Evaluates the DOF vector at a set of quadrature points defined on the
/// given element.
void getVecAtQPs(const ElInfo *elInfo,
const Quadrature *quad,
const FastQuadrature *quadFast,
......@@ -87,10 +88,8 @@ namespace AMDiS {
const FastQuadrature *quadFast,
mtl::dense_vector<T>& vecAtQPs) const;
/** \brief
* Evaluates the gradient of a DOF vector at a set of quadrature points defined on the
* given element.
*/
/// Evaluates the gradient of a DOF vector at a set of quadrature points
/// defined on the given element.
void getGrdAtQPs( const ElInfo *elInfo,
const Quadrature *quad,
const FastQuadrature *quadFast,
......@@ -102,10 +101,8 @@ namespace AMDiS {
const FastQuadrature *quadFast,
mtl::dense_vector<typename GradientType<T>::type> &grdAtQPs) const;
/** \brief
* Evaluates the comp'th component of the derivative of a DOF vector at a set of quadrature points defined on the
* given element.
*/
/// Evaluates the comp'th component of the derivative of a DOF vector at a
/// set of quadrature points defined on the given element.
void getDerivativeAtQPs( const ElInfo *elInfo,
const Quadrature *quad,
const FastQuadrature *quadFast,
......@@ -119,10 +116,8 @@ namespace AMDiS {
int comp,
mtl::dense_vector<T> &derivativeAtQPs) const;
/** \brief
* Evaluates the jacobian of a DOF vector at a set of quadrature points defined on the
* given element.
*/
/// Evaluates the jacobian of a DOF vector at a set of quadrature points
/// defined on the given element.
void getD2AtQPs(const ElInfo *elInfo,
const Quadrature *quad,
const FastQuadrature *quadFast,
......@@ -134,10 +129,8 @@ namespace AMDiS {
return feSpace;
}
/** \brief
* Assembles the element vector for the given ellement and adds the
* element matrix to the current DOF vector.
*/
/// Assembles the element vector for the given ellement and adds the
/// element matrix to the current DOF vector.
void assemble(T factor, ElInfo *elInfo,
const BoundaryType *bound,
Operator *op = NULL);
......@@ -154,11 +147,9 @@ namespace AMDiS {
ElInfo *elInfo,
bool add = true);
/* \brief
* That function must be called after the matrix assembling has been finished.
* This makes it possible to start some cleanup or matrix data compressing
* procedures.
*/
/// That function must be called after the matrix assembling has been
/// finished. This makes it possible to start some cleanup or matrix
/// data compressing procedures.
void finishAssembling();
inline void addOperator(Operator* op,
......@@ -170,33 +161,33 @@ namespace AMDiS {
operatorEstFactor.push_back(estFactor);
}
inline std::vector<double*>::iterator getOperatorFactorBegin()
inline vector<double*>::iterator getOperatorFactorBegin()
{
return operatorFactor.begin();
}
inline std::vector<double*>::iterator getOperatorFactorEnd()
inline vector<double*>::iterator getOperatorFactorEnd()
{
return operatorFactor.end();
}
inline std::vector<double*>::iterator getOperatorEstFactorBegin()
inline vector<double*>::iterator getOperatorEstFactorBegin()
{
return operatorEstFactor.begin();
}
inline std::vector<double*>::iterator getOperatorEstFactorEnd()
inline vector<double*>::iterator getOperatorEstFactorEnd()
{
return operatorEstFactor.end();
}
inline std::vector<Operator*>::iterator getOperatorsBegin()
inline vector<Operator*>::iterator getOperatorsBegin()
{
return operators.begin();
}
inline std::vector<Operator*>::iterator getOperatorsEnd()
inline vector<Operator*>::iterator getOperatorsEnd()
{
return operators.end();
}
......@@ -211,28 +202,28 @@ namespace AMDiS {
*/
T evalUh(const DimVec<double>& lambda, DegreeOfFreedom* ind);
inline std::vector<Operator*>& getOperators()
inline vector<Operator*>& getOperators()
{
return operators;
}
inline std::vector<double*>& getOperatorFactor()
inline vector<double*>& getOperatorFactor()
{
return operatorFactor;
}
inline std::vector<double*>& getOperatorEstFactor()
inline vector<double*>& getOperatorEstFactor()
{
return operatorEstFactor;
}
/// Returns \ref name
inline std::string getName() const
inline string getName() const
{
return name;
}
inline void setName(std::string n)
inline void setName(string n)
{
name = n;
}
......@@ -248,16 +239,16 @@ namespace AMDiS {
}
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
inline void setRankDofs(std::map<DegreeOfFreedom, bool> &dofmap)
void setDofMap(FeSpaceDofMap& m)
{
rankDofs = &dofmap;
dofMap = &m;
}
inline bool isRankDof(DegreeOfFreedom dof)
{
TEST_EXIT_DBG(rankDofs)("No rank dofs set!\n");
TEST_EXIT_DBG(dofMap)("No rank dofs set!\n");
return (*rankDofs)[dof];
return dofMap->isRankDof(dof);
}
#endif
......@@ -266,19 +257,19 @@ namespace AMDiS {
const FiniteElemSpace *feSpace;
///
std::string name;
string name;
///
ElementVector elementVector;
///
std::vector<Operator*> operators;
vector<Operator*> operators;
///
std::vector<double*> operatorFactor;
vector<double*> operatorFactor;
///
std::vector<double*> operatorEstFactor;
vector<double*> operatorEstFactor;
///
BoundaryManager *boundaryManager;
......@@ -290,7 +281,7 @@ namespace AMDiS {
int dim;
#ifdef HAVE_PARALLEL_DOMAIN_AMDIS
std::map<DegreeOfFreedom, bool> *rankDofs;
FeSpaceDofMap *dofMap;
#endif
};
......@@ -362,10 +353,10 @@ namespace AMDiS {
{}
/// Constructs a DOFVector with name n belonging to FiniteElemSpace f
DOFVector(const FiniteElemSpace* f, std::string n);
DOFVector(const FiniteElemSpace* f, string n);
/// Initialization.
void init(const FiniteElemSpace* f, std::string n);
void init(const FiniteElemSpace* f, string n);
/// Copy Constructor
DOFVector(const DOFVector& rhs)
......@@ -380,23 +371,21 @@ namespace AMDiS {
virtual ~DOFVector();
/// Returns iterator to the begin of \ref vec
typename std::vector<T>::iterator begin()
typename vector<T>::iterator begin()
{
return vec.begin();
}
/// Returns iterator to the end of \ref vec
typename std::vector<T>::iterator end()
typename vector<T>::iterator end()
{
return vec.end();
}
/** \brief
* Used by DOFAdmin to compress this DOFVector. Implementation of
* DOFIndexedBase::compress()
*/
/// Used by DOFAdmin to compress this DOFVector. Implementation of
/// \ref DOFIndexedBase::compress()
virtual void compressDOFIndexed(int first, int last,
std::vector<DegreeOfFreedom> &newDof);
vector<DegreeOfFreedom> &newDof);
/// Sets \ref coarsenOperation to op
inline void setCoarsenOperation(CoarsenOperation op)
......@@ -417,7 +406,7 @@ namespace AMDiS {
inline void refineInterpol(RCNeighbourList&, int) {}
/// Returns \ref vec
std::vector<T>& getVector()
vector<T>& getVector()
{
return vec;
}
......@@ -489,10 +478,8 @@ namespace AMDiS {
double Int(int meshLevel, Quadrature* q = NULL) const;
/** \brief
* Calculates Integral of this DOFVector over parts of the domain
* boundary, indicated by boundaryType. Implemented for DOFVector<double>
**/
/// Calculates Integral of this DOFVector over parts of the domain
/// boundary, indicated by boundaryType. Implemented for DOFVector<double>
T IntOnBoundary(BoundaryType boundary, Quadrature* q = NULL) const
{
FUNCNAME("DOFVector::IntOnBoundary())");
......@@ -500,11 +487,9 @@ namespace AMDiS {
return 0.0;
}
/** \brief