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

* Faster assembling for 2D-vecphase

parent 6eda4c4f
...@@ -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,6 +1191,7 @@ namespace AMDiS { ...@@ -1191,6 +1191,7 @@ namespace AMDiS {
Quad2::~Quad2() Quad2::~Quad2()
{ {
if (!firstCall) {
int nPoints = quadrature->getNumPoints(); int nPoints = quadrature->getNumPoints();
for (int i = 0; i < static_cast<int>(tmpLALt.size()); i++) { for (int i = 0; i < static_cast<int>(tmpLALt.size()); i++) {
for (int j = 0; j < nPoints; j++) { for (int j = 0; j < nPoints; j++) {
...@@ -1199,6 +1200,7 @@ namespace AMDiS { ...@@ -1199,6 +1200,7 @@ namespace AMDiS {
DELETE [] tmpLALt[i]; DELETE [] tmpLALt[i];
} }
} }
}
void Quad2::calculateElementMatrix(const ElInfo *elInfo, ElementMatrix *mat) void Quad2::calculateElementMatrix(const ElInfo *elInfo, ElementMatrix *mat)
{ {
...@@ -1228,7 +1230,7 @@ namespace AMDiS { ...@@ -1228,7 +1230,7 @@ namespace AMDiS {
(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;
} }
...@@ -1258,7 +1261,7 @@ namespace AMDiS { ...@@ -1258,7 +1261,7 @@ 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;
...@@ -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)
{ {
name = n; name = n;
feSpace = f; feSpace = f;
...@@ -244,7 +244,7 @@ namespace AMDiS { ...@@ -244,7 +244,7 @@ namespace AMDiS {
T m; T m;
Iterator vecIterator(const_cast<DOFIndexed<T>*>(dynamic_cast<const DOFIndexed<T>*>(this)), USED_DOFS); Iterator vecIterator(const_cast<DOFIndexed<T>*>(dynamic_cast<const DOFIndexed<T>*>(this)), USED_DOFS);
for (vecIterator.reset(), m = *vecIterator; !vecIterator.end(); ++vecIterator) { for (vecIterator.reset(), m = *vecIterator; !vecIterator.end(); ++vecIterator) {
m = ::std::min(m, *vecIterator); m = std::min(m, *vecIterator);
} }
return m; return m;
...@@ -264,7 +264,7 @@ namespace AMDiS { ...@@ -264,7 +264,7 @@ namespace AMDiS {
T m; T m;
Iterator vecIterator(const_cast<DOFIndexed<T>*>(dynamic_cast<const DOFIndexed<T>*>(this)), USED_DOFS); Iterator vecIterator(const_cast<DOFIndexed<T>*>(dynamic_cast<const DOFIndexed<T>*>(this)), USED_DOFS);
for (vecIterator.reset(), m = *vecIterator; !vecIterator.end(); ++vecIterator) { for (vecIterator.reset(), m = *vecIterator; !vecIterator.end(); ++vecIterator) {
m = ::std::max(m, *vecIterator); m = std::max(m, *vecIterator);
} }
return m; return m;
...@@ -338,7 +338,7 @@ namespace AMDiS { ...@@ -338,7 +338,7 @@ namespace AMDiS {
++rowIterator, ++vecIterator) { ++rowIterator, ++vecIterator) {
sum = 0; sum = 0;
row = &(a[rowIterator.getDOFIndex()]); row = &(a[rowIterator.getDOFIndex()]);
for(::std::vector<MatEntry>::iterator colIterator = rowIterator->begin(); for(std::vector<MatEntry>::iterator colIterator = rowIterator->begin();
colIterator != rowIterator->end(); colIterator != rowIterator->end();
colIterator++) { colIterator++) {
jcol = colIterator->col; jcol = colIterator->col;
...@@ -367,7 +367,7 @@ namespace AMDiS { ...@@ -367,7 +367,7 @@ namespace AMDiS {
++rowIterator, ++xIterator) { ++rowIterator, ++xIterator) {