Commit 23e3a357 authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

* Faster assembling for 2D-vecphase

parent 6eda4c4f
...@@ -498,7 +498,7 @@ namespace AMDiS { ...@@ -498,7 +498,7 @@ namespace AMDiS {
const BasisFunction *psi = owner->getRowFESpace()->getBasisFcts(); const BasisFunction *psi = owner->getRowFESpace()->getBasisFcts();
const BasisFunction *phi = owner->getColFESpace()->getBasisFcts(); const BasisFunction *phi = owner->getColFESpace()->getBasisFcts();
double psival; double psival;
double *phival = GET_MEMORY(double, nCol); double *phival = GET_MEMORY(double, nCol);
int nPoints = quadrature->getNumPoints(); int nPoints = quadrature->getNumPoints();
double *c = GET_MEMORY(double, nPoints); double *c = GET_MEMORY(double, nPoints);
...@@ -544,7 +544,7 @@ namespace AMDiS { ...@@ -544,7 +544,7 @@ namespace AMDiS {
for (int i = 0; i < nRow; i++) { for (int i = 0; i < nRow; i++) {
psival = (*(psi->getPhi(i)))(quadrature->getLambda(iq)); psival = (*(psi->getPhi(i)))(quadrature->getLambda(iq));
for (int j = 0; j < nCol; j++) { for (int j = 0; j < nCol; j++) {
(*mat)[i][j] += quadrature->getWeight(iq)*c[iq]*psival*phival[j]; (*mat)[i][j] += quadrature->getWeight(iq) * c[iq] * psival * phival[j];
} }
} }
} }
...@@ -1191,12 +1191,14 @@ namespace AMDiS { ...@@ -1191,12 +1191,14 @@ namespace AMDiS {
Quad2::~Quad2() Quad2::~Quad2()
{ {
int nPoints = quadrature->getNumPoints(); if (!firstCall) {
for (int i = 0; i < static_cast<int>(tmpLALt.size()); i++) { int nPoints = quadrature->getNumPoints();
for (int j = 0; j < nPoints; j++) { for (int i = 0; i < static_cast<int>(tmpLALt.size()); i++) {
DELETE tmpLALt[i][j]; for (int j = 0; j < nPoints; j++) {
DELETE tmpLALt[i][j];
}
DELETE [] tmpLALt[i];
} }
DELETE [] tmpLALt[i];
} }
} }
...@@ -1219,7 +1221,7 @@ namespace AMDiS { ...@@ -1219,7 +1221,7 @@ namespace AMDiS {
} }
DimMat<double> **LALt = tmpLALt[myRank]; DimMat<double> **LALt = tmpLALt[myRank];
for (int i = 0; i < nPoints; i++) { for (int i = 0; i < nPoints; i++) {
LALt[i]->set(0.0); LALt[i]->set(0.0);
} }
...@@ -1227,8 +1229,8 @@ namespace AMDiS { ...@@ -1227,8 +1229,8 @@ namespace AMDiS {
for (int i = 0; i < static_cast<int>(terms[myRank].size()); i++) { for (int i = 0; i < static_cast<int>(terms[myRank].size()); i++) {
(static_cast<SecondOrderTerm*>(terms[myRank][i]))->getLALt(elInfo, nPoints, LALt); (static_cast<SecondOrderTerm*>(terms[myRank][i]))->getLALt(elInfo, nPoints, LALt);
} }
VectorOfFixVecs<DimVec<double> > *grdPsi, *grdPhi; VectorOfFixVecs< DimVec<double> > *grdPsi, *grdPhi;
if (symmetric) { if (symmetric) {
for (int iq = 0; iq < nPoints; iq++) { for (int iq = 0; iq < nPoints; iq++) {
...@@ -1239,10 +1241,11 @@ namespace AMDiS { ...@@ -1239,10 +1241,11 @@ namespace AMDiS {
for (int i = 0; i < nRow; i++) { for (int i = 0; i < nRow; i++) {
(*mat)[i][i] += quadrature->getWeight(iq) * (*mat)[i][i] += quadrature->getWeight(iq) *
((*grdPsi)[i] * ((*LALt[iq]) * (*grdPhi)[i])); xAy((*grdPsi)[i], (*LALt[iq]), (*grdPhi)[i]);
for (int j = i + 1; j < nCol; j++) { for (int j = i + 1; j < nCol; j++) {
double val = quadrature->getWeight(iq) * ((*grdPsi)[i] * ((*LALt[iq]) * (*grdPhi)[j])); double val = quadrature->getWeight(iq) *
xAy((*grdPsi)[i], (*LALt[iq]), (*grdPhi)[j]);
(*mat)[i][j] += val; (*mat)[i][j] += val;
(*mat)[j][i] += val; (*mat)[j][i] += val;
} }
...@@ -1257,8 +1260,8 @@ namespace AMDiS { ...@@ -1257,8 +1260,8 @@ namespace AMDiS {
for (int i = 0; i < nRow; i++) { for (int i = 0; i < nRow; i++) {
for (int j = 0; j < nCol; j++) { for (int j = 0; j < nCol; j++) {
(*mat)[i][j] += quadrature->getWeight(iq) * (*mat)[i][j] += quadrature->getWeight(iq) *
((*grdPsi)[i] * ((*LALt[iq]) * (*grdPhi)[j])); xAy((*grdPsi)[i], (*LALt[iq]), (*grdPhi)[j]);
} }
} }
} }
......
...@@ -440,9 +440,6 @@ namespace AMDiS { ...@@ -440,9 +440,6 @@ namespace AMDiS {
} }
Operator *operat = op ? op : operators[0]; Operator *operat = op ? op : operators[0];
// !!! Do no combine the next two lines into one !!!
// ElementMatrix *elementMatrix = NULL;
operat->getAssembler(omp_get_thread_num())->initElementMatrix(elementMatrix, elInfo); operat->getAssembler(omp_get_thread_num())->initElementMatrix(elementMatrix, elInfo);
if (op) { if (op) {
...@@ -452,17 +449,14 @@ namespace AMDiS { ...@@ -452,17 +449,14 @@ namespace AMDiS {
::std::vector<double*>::iterator factorIt; ::std::vector<double*>::iterator factorIt;
for (it = operators.begin(), factorIt = operatorFactor.begin(); for (it = operators.begin(), factorIt = operatorFactor.begin();
it != operators.end(); it != operators.end();
++it, ++factorIt) ++it, ++factorIt) {
{ (*it)->getElementMatrix(elInfo,
(*it)->getElementMatrix(elInfo, elementMatrix,
elementMatrix, *factorIt ? **factorIt : 1.0);
*factorIt ? **factorIt : 1.0); }
}
} }
addElementMatrix(factor, *elementMatrix, bound); addElementMatrix(factor, *elementMatrix, bound);
// DELETE elementMatrix;
} }
Flag DOFMatrix::getAssembleFlag() Flag DOFMatrix::getAssembleFlag()
......
...@@ -71,9 +71,9 @@ namespace AMDiS { ...@@ -71,9 +71,9 @@ namespace AMDiS {
DOFAdmin *admin = feSpace->getAdmin(); DOFAdmin *admin = feSpace->getAdmin();
// count number of nodes and dofs per node // count number of nodes and dofs per node
::std::vector<int> numNodeDOFs; std::vector<int> numNodeDOFs;
::std::vector<int> numNodePreDOFs; std::vector<int> numNodePreDOFs;
::std::vector<DimVec<double>*> bary; std::vector<DimVec<double>*> bary;
int numNodes = 0; int numNodes = 0;
int numDOFs = 0; int numDOFs = 0;
...@@ -102,7 +102,7 @@ namespace AMDiS { ...@@ -102,7 +102,7 @@ namespace AMDiS {
} }
// traverse mesh // traverse mesh
::std::vector<bool> visited(getUsedSize(), false); std::vector<bool> visited(getUsedSize(), false);
TraverseStack stack; TraverseStack stack;
...@@ -213,10 +213,10 @@ namespace AMDiS { ...@@ -213,10 +213,10 @@ namespace AMDiS {
} }
template<> template<>
const WorldVector<double> *DOFVectorBase<double>::getGrdAtQPs(const ElInfo *elInfo, const WorldVector<double> *DOFVectorBase<double>::getGrdAtQPs(const ElInfo *elInfo,
const Quadrature *quad, const Quadrature *quad,
const FastQuadrature *quadFast, const FastQuadrature *quadFast,
WorldVector<double> *grdAtQPs) const WorldVector<double> *grdAtQPs) const
{ {
FUNCNAME("DOFVector<double>::getGrdAtQPs()"); FUNCNAME("DOFVector<double>::getGrdAtQPs()");
...@@ -231,17 +231,12 @@ namespace AMDiS { ...@@ -231,17 +231,12 @@ namespace AMDiS {
("invalid basis functions"); ("invalid basis functions");
Element *el = elInfo->getElement(); Element *el = elInfo->getElement();
int dim = elInfo->getMesh()->getDim(); int dim = elInfo->getMesh()->getDim();
int dow = Global::getGeo(WORLD); int dow = Global::getGeo(WORLD);
const Quadrature *quadrature = quadFast ? quadFast->getQuadrature() : quad; const Quadrature *quadrature = quadFast ? quadFast->getQuadrature() : quad;
const BasisFunction *basFcts = feSpace->getBasisFcts(); const BasisFunction *basFcts = feSpace->getBasisFcts();
int numPoints = quadrature->getNumPoints(); int numPoints = quadrature->getNumPoints();
static WorldVector<double> *grd = NULL; static WorldVector<double> *grd = NULL;
WorldVector<double> *result; WorldVector<double> *result;
if (grdAtQPs) { if (grdAtQPs) {
...@@ -589,9 +584,9 @@ namespace AMDiS { ...@@ -589,9 +584,9 @@ namespace AMDiS {
} }
// count number of nodes and dofs per node // count number of nodes and dofs per node
::std::vector<int> numNodeDOFs; std::vector<int> numNodeDOFs;
::std::vector<int> numNodePreDOFs; std::vector<int> numNodePreDOFs;
::std::vector<DimVec<double>*> bary; std::vector<DimVec<double>*> bary;
int numNodes = 0; int numNodes = 0;
int numDOFs = 0; int numDOFs = 0;
...@@ -619,7 +614,7 @@ namespace AMDiS { ...@@ -619,7 +614,7 @@ namespace AMDiS {
} }
// traverse mesh // traverse mesh
::std::vector<bool> visited(getUsedSize(), false); std::vector<bool> visited(getUsedSize(), false);
TraverseStack stack; TraverseStack stack;
Flag fillFlag = Mesh::CALL_LEAF_EL | Mesh::FILL_GRD_LAMBDA; Flag fillFlag = Mesh::CALL_LEAF_EL | Mesh::FILL_GRD_LAMBDA;
ElInfo *elInfo = stack.traverseFirst(mesh, -1, fillFlag); ElInfo *elInfo = stack.traverseFirst(mesh, -1, fillFlag);
...@@ -661,8 +656,8 @@ namespace AMDiS { ...@@ -661,8 +656,8 @@ namespace AMDiS {
void DOFVectorDOF::freeDOFContent(DegreeOfFreedom dof) { void DOFVectorDOF::freeDOFContent(DegreeOfFreedom dof) {
::std::vector<DegreeOfFreedom>::iterator it; std::vector<DegreeOfFreedom>::iterator it;
::std::vector<DegreeOfFreedom>::iterator end = vec.end(); std::vector<DegreeOfFreedom>::iterator end = vec.end();
DegreeOfFreedom pos = 0; DegreeOfFreedom pos = 0;
for (it = vec.begin(); it != end; ++it, ++pos) { for (it = vec.begin(); it != end; ++it, ++pos) {
if (*it == dof) *it = pos; if (*it == dof) *it = pos;
......
...@@ -78,7 +78,7 @@ namespace AMDiS { ...@@ -78,7 +78,7 @@ namespace AMDiS {
nBasFcts(0) nBasFcts(0)
{}; {};
DOFVectorBase(const FiniteElemSpace *f, ::std::string n); DOFVectorBase(const FiniteElemSpace *f, std::string n);
virtual ~DOFVectorBase(); virtual ~DOFVectorBase();
...@@ -121,28 +121,28 @@ namespace AMDiS { ...@@ -121,28 +121,28 @@ namespace AMDiS {
operatorEstFactor.push_back(estFactor); operatorEstFactor.push_back(estFactor);
}; };
inline ::std::vector<double*>::iterator getOperatorFactorBegin() { inline std::vector<double*>::iterator getOperatorFactorBegin() {
return operatorFactor.begin(); return operatorFactor.begin();
}; };
inline ::std::vector<double*>::iterator getOperatorFactorEnd() { inline std::vector<double*>::iterator getOperatorFactorEnd() {
return operatorFactor.end(); return operatorFactor.end();
}; };
inline ::std::vector<double*>::iterator getOperatorEstFactorBegin() { inline std::vector<double*>::iterator getOperatorEstFactorBegin() {
return operatorEstFactor.begin(); return operatorEstFactor.begin();
}; };
inline ::std::vector<double*>::iterator getOperatorEstFactorEnd() { inline std::vector<double*>::iterator getOperatorEstFactorEnd() {
return operatorEstFactor.end(); return operatorEstFactor.end();
}; };
inline ::std::vector<Operator*>::iterator getOperatorsBegin() { inline std::vector<Operator*>::iterator getOperatorsBegin() {
return operators.begin(); return operators.begin();
}; };
inline ::std::vector<Operator*>::iterator getOperatorsEnd() { inline std::vector<Operator*>::iterator getOperatorsEnd() {
return operators.end(); return operators.end();
}; };
...@@ -156,22 +156,22 @@ namespace AMDiS { ...@@ -156,22 +156,22 @@ namespace AMDiS {
*/ */
T evalUh(const DimVec<double>& lambda, DegreeOfFreedom* ind); T evalUh(const DimVec<double>& lambda, DegreeOfFreedom* ind);
inline ::std::vector<Operator*>& getOperators() { inline std::vector<Operator*>& getOperators() {
return operators; return operators;
}; };
inline ::std::vector<double*>& getOperatorFactor() { inline std::vector<double*>& getOperatorFactor() {
return operatorFactor; return operatorFactor;
}; };
inline ::std::vector<double*>& getOperatorEstFactor() { inline std::vector<double*>& getOperatorEstFactor() {
return operatorEstFactor; return operatorEstFactor;
}; };
/** \brief /** \brief
* Returns \ref name * Returns \ref name
*/ */
inline const ::std::string& getName() const { inline const std::string& getName() const {
return name; return name;
}; };
...@@ -192,7 +192,7 @@ namespace AMDiS { ...@@ -192,7 +192,7 @@ namespace AMDiS {
/** \brief /** \brief
* *
*/ */
::std::string name; std::string name;
/** \brief /** \brief
* *
...@@ -202,17 +202,17 @@ namespace AMDiS { ...@@ -202,17 +202,17 @@ namespace AMDiS {
/** \brief /** \brief
* *
*/ */
::std::vector<Operator*> operators; std::vector<Operator*> operators;
/** \brief /** \brief
* *
*/ */
::std::vector<double*> operatorFactor; std::vector<double*> operatorFactor;
/** \brief /** \brief
* *
*/ */
::std::vector<double*> operatorEstFactor; std::vector<double*> operatorEstFactor;
/** \brief /** \brief
* *
...@@ -228,7 +228,7 @@ namespace AMDiS { ...@@ -228,7 +228,7 @@ namespace AMDiS {
* Are used to store temporary local dofs of an element. * Are used to store temporary local dofs of an element.
* Thread safe. * Thread safe.
*/ */
::std::vector<DegreeOfFreedom* > localIndices; std::vector<DegreeOfFreedom* > localIndices;
}; };
...@@ -314,12 +314,12 @@ namespace AMDiS { ...@@ -314,12 +314,12 @@ namespace AMDiS {
/** \brief /** \brief
* Constructs a DOFVector with name n belonging to FiniteElemSpace f * Constructs a DOFVector with name n belonging to FiniteElemSpace f
*/ */
DOFVector(const FiniteElemSpace* f, ::std::string n); DOFVector(const FiniteElemSpace* f, std::string n);
/** \brief /** \brief
* Initialization. * Initialization.
*/ */
void init(const FiniteElemSpace* f, ::std::string n); void init(const FiniteElemSpace* f, std::string n);
/** \brief /** \brief
* Copy Constructor * Copy Constructor
...@@ -340,14 +340,14 @@ namespace AMDiS { ...@@ -340,14 +340,14 @@ namespace AMDiS {
/** \brief /** \brief
* Returns iterator to the begin of \ref vec * Returns iterator to the begin of \ref vec
*/ */
typename ::std::vector<T>::iterator begin() { typename std::vector<T>::iterator begin() {
return vec.begin(); return vec.begin();
}; };
/** \brief /** \brief
* Returns iterator to the end of \ref vec * Returns iterator to the end of \ref vec
*/ */
typename ::std::vector<T>::iterator end() { typename std::vector<T>::iterator end() {
return vec.end(); return vec.end();
}; };
...@@ -356,7 +356,7 @@ namespace AMDiS { ...@@ -356,7 +356,7 @@ namespace AMDiS {
* DOFIndexedBase::compress() * DOFIndexedBase::compress()
*/ */
virtual void compressDOFIndexed(int first, int last, virtual void compressDOFIndexed(int first, int last,
::std::vector<DegreeOfFreedom> &newDof); std::vector<DegreeOfFreedom> &newDof);
/** \brief /** \brief
* Sets \ref refineInter to b * Sets \ref refineInter to b
...@@ -399,7 +399,7 @@ namespace AMDiS { ...@@ -399,7 +399,7 @@ namespace AMDiS {
/** \brief /** \brief
* Returns \ref vec * Returns \ref vec
*/ */
::std::vector<T>& getVector() { std::vector<T>& getVector() {
return vec; return vec;
}; };
...@@ -580,13 +580,13 @@ namespace AMDiS { ...@@ -580,13 +580,13 @@ namespace AMDiS {
// ===== Serializable implementation ===== // ===== Serializable implementation =====
void serialize(::std::ostream &out) { void serialize(std::ostream &out) {
unsigned int size = vec.size(); unsigned int size = vec.size();
out.write(reinterpret_cast<const char*>(&size), sizeof(unsigned int)); out.write(reinterpret_cast<const char*>(&size), sizeof(unsigned int));
out.write(reinterpret_cast<const char*>(&(vec[0])), size * sizeof(T)); out.write(reinterpret_cast<const char*>(&(vec[0])), size * sizeof(T));
}; };
void deserialize(::std::istream &in) { void deserialize(std::istream &in) {
unsigned int size; unsigned int size;
in.read(reinterpret_cast<char*>(&size), sizeof(unsigned int)); in.read(reinterpret_cast<char*>(&size), sizeof(unsigned int));
vec.resize(size); vec.resize(size);
...@@ -626,7 +626,7 @@ namespace AMDiS { ...@@ -626,7 +626,7 @@ namespace AMDiS {
/** \brief /** \brief
* Name of this DOFVector * Name of this DOFVector
*/ */
::std::string name; std::string name;
/** \brief /** \brief
* FiniteElemSpace of the vector * FiniteElemSpace of the vector
...@@ -636,7 +636,7 @@ namespace AMDiS { ...@@ -636,7 +636,7 @@ namespace AMDiS {
/** \brief /** \brief
* Data container * Data container
*/ */
::std::vector<T> vec; std::vector<T> vec;
/** \brief /** \brief
* Specifies whether interpolation should be performed after refinement * Specifies whether interpolation should be performed after refinement
...@@ -709,7 +709,7 @@ namespace AMDiS { ...@@ -709,7 +709,7 @@ namespace AMDiS {
* Calls constructor of DOFVector<DegreeOfFreedom> and registers itself * Calls constructor of DOFVector<DegreeOfFreedom> and registers itself
* as DOFContainer at DOFAdmin * as DOFContainer at DOFAdmin
*/ */
DOFVectorDOF(const FiniteElemSpace* feSpace_, ::std::string name_) DOFVectorDOF(const FiniteElemSpace* feSpace_, std::string name_)
: DOFVector<DegreeOfFreedom>(feSpace_, name_) : DOFVector<DegreeOfFreedom>(feSpace_, name_)
{ {
feSpace->getAdmin()->addDOFContainer(this); feSpace->getAdmin()->addDOFContainer(this);
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
namespace AMDiS { namespace AMDiS {
template<typename T> template<typename T>
DOFVectorBase<T>::DOFVectorBase(const FiniteElemSpace *f, ::std::string n) DOFVectorBase<T>::DOFVectorBase(const FiniteElemSpace *f, std::string n)
: feSpace(f), : feSpace(f),
name(n), name(n),
elementVector(NULL), elementVector(NULL),
...@@ -42,7 +42,7 @@ namespace AMDiS { ...@@ -42,7 +42,7 @@ namespace AMDiS {
} }
template<typename T> template<typename T>
DOFVector<T>::DOFVector(const FiniteElemSpace* f, ::std::string n) DOFVector<T>::DOFVector(const FiniteElemSpace* f, std::string n)
: DOFVectorBase<T>(f, n), : DOFVectorBase<T>(f, n),
refineInter(false), refineInter(false),
coarsenOperation(NO_OPERATION) coarsenOperation(NO_OPERATION)
...@@ -51,7 +51,7 @@ namespace AMDiS { ...@@ -51,7 +51,7 @@ namespace AMDiS {
} }
template<typename T> template<typename T>
void DOFVector<T>::init(const FiniteElemSpace* f, ::std::string n) void DOFVector<T>::init(const FiniteElemSpace* f, std::string n)