Commit 9692c1a2 authored by Thomas Witkowski's avatar Thomas Witkowski
Browse files

* Small bugfix for compiling without OpenMP

parent 3b97cf2b
...@@ -6,18 +6,31 @@ ...@@ -6,18 +6,31 @@
namespace AMDiS { namespace AMDiS {
DirichletBC::DirichletBC(BoundaryType type, DirichletBC::DirichletBC(BoundaryType type,
AbstractFunction<double, WorldVector<double> > *fct,
FiniteElemSpace *rowFESpace,
FiniteElemSpace *colFESpace)
: BoundaryCondition(type, rowFESpace, colFESpace),
f(fct),
dofVec(NULL)
{
worldCoords.resize(omp_get_max_threads());
};
DirichletBC::DirichletBC(BoundaryType type,
DOFVectorBase<double> *vec) DOFVectorBase<double> *vec)
: BoundaryCondition(type, vec->getFESpace()), : BoundaryCondition(type, vec->getFESpace()),
f(NULL), f(NULL),
dofVec(vec) dofVec(vec)
{} {
worldCoords.resize(omp_get_max_threads());
}
void DirichletBC::fillBoundaryCondition(DOFMatrix* matrix, void DirichletBC::fillBoundaryCondition(DOFMatrix* matrix,
ElInfo* elInfo, ElInfo* elInfo,
const DegreeOfFreedom* dofIndices, const DegreeOfFreedom* dofIndices,
const BoundaryType* localBound, const BoundaryType* localBound,
int nBasFcts) int nBasFcts)
{ {
FUNCNAME("DirichletBC::fillBoundaryCondition()"); FUNCNAME("DirichletBC::fillBoundaryCondition()");
...@@ -25,11 +38,11 @@ namespace AMDiS { ...@@ -25,11 +38,11 @@ namespace AMDiS {
("invalid row fe space\n"); ("invalid row fe space\n");
} }
void DirichletBC::fillBoundaryCondition(DOFVectorBase<double>* vector, void DirichletBC::fillBoundaryCondition(DOFVectorBase<double>* vector,
ElInfo* elInfo, ElInfo* elInfo,
const DegreeOfFreedom* dofIndices, const DegreeOfFreedom* dofIndices,
const BoundaryType* localBound, const BoundaryType* localBound,
int nBasFcts) int nBasFcts)
{ {
FUNCNAME("DirichletBC::fillBoundaryCondition()"); FUNCNAME("DirichletBC::fillBoundaryCondition()");
...@@ -37,12 +50,14 @@ namespace AMDiS { ...@@ -37,12 +50,14 @@ namespace AMDiS {
("invalid row fe space\n"); ("invalid row fe space\n");
const BasisFunction *basFcts = rowFESpace->getBasisFcts(); const BasisFunction *basFcts = rowFESpace->getBasisFcts();
int myRank = omp_get_thread_num();
for (int i = 0; i < nBasFcts; i++) { for (int i = 0; i < nBasFcts; i++) {
if (localBound[i] == boundaryType) { if (localBound[i] == boundaryType) {
if (f) { if (f) {
DimVec<double> *coords = basFcts->getCoords(i); DimVec<double> *coords = basFcts->getCoords(i);
const WorldVector<double> *worldCoords = elInfo->coordToWorld(*coords, NULL); elInfo->coordToWorld(*coords, &(worldCoords[myRank]));
double fAtCoords = (*f)(*worldCoords); double fAtCoords = (*f)(worldCoords[myRank]);
(*vector)[dofIndices[i]] = fAtCoords; (*vector)[dofIndices[i]] = fAtCoords;
} }
if (dofVec) { if (dofVec) {
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include "BoundaryCondition.h" #include "BoundaryCondition.h"
#include "AbstractFunction.h" #include "AbstractFunction.h"
#include "OpenMP.h"
namespace AMDiS { namespace AMDiS {
...@@ -49,38 +50,34 @@ namespace AMDiS { ...@@ -49,38 +50,34 @@ namespace AMDiS {
/** \brief /** \brief
* Constructor. * Constructor.
*/ */
DirichletBC(BoundaryType type, DirichletBC(BoundaryType type,
AbstractFunction<double, WorldVector<double> > *fct, AbstractFunction<double, WorldVector<double> > *fct,
FiniteElemSpace *rowFESpace, FiniteElemSpace *rowFESpace,
FiniteElemSpace *colFESpace = NULL) FiniteElemSpace *colFESpace = NULL);
: BoundaryCondition(type, rowFESpace, colFESpace),
f(fct),
dofVec(NULL)
{};
/** \brief /** \brief
* Constructor. * Constructor.
*/ */
DirichletBC(BoundaryType type, DirichletBC(BoundaryType type,
DOFVectorBase<double> *vec); DOFVectorBase<double> *vec);
/** \brief /** \brief
* Implementation of BoundaryCondition::fillBoundaryCondition(). * Implementation of BoundaryCondition::fillBoundaryCondition().
*/ */
void fillBoundaryCondition(DOFMatrix* matrix, void fillBoundaryCondition(DOFMatrix* matrix,
ElInfo* elInfo, ElInfo* elInfo,
const DegreeOfFreedom* dofIndices, const DegreeOfFreedom* dofIndices,
const BoundaryType* localBound, const BoundaryType* localBound,
int nBasFcts); int nBasFcts);
/** \brief /** \brief
* Implementation of BoundaryCondition::fillBoundaryCondition(). * Implementation of BoundaryCondition::fillBoundaryCondition().
*/ */
void fillBoundaryCondition(DOFVectorBase<double>* vector, void fillBoundaryCondition(DOFVectorBase<double>* vector,
ElInfo* elInfo, ElInfo* elInfo,
const DegreeOfFreedom* dofIndices, const DegreeOfFreedom* dofIndices,
const BoundaryType* localBound, const BoundaryType* localBound,
int nBasFcts); int nBasFcts);
/** \brief /** \brief
* Implementation of BoundaryCondition::boundResidual(). * Implementation of BoundaryCondition::boundResidual().
...@@ -109,6 +106,8 @@ namespace AMDiS { ...@@ -109,6 +106,8 @@ namespace AMDiS {
*/ */
AbstractFunction<double, WorldVector<double> > *f; AbstractFunction<double, WorldVector<double> > *f;
std::vector<WorldVector<double> > worldCoords;
/** \brief /** \brief
* DOFVector containing the boundary values * DOFVector containing the boundary values
*/ */
......
...@@ -62,8 +62,8 @@ namespace AMDiS { ...@@ -62,8 +62,8 @@ namespace AMDiS {
{ {
int dim = l.getSize() - 1; int dim = l.getSize() - 1;
static WorldVector<double> world[4]; static WorldVector<double> world;
WorldVector<double> *ret = w ? w : &world[omp_get_thread_num()]; WorldVector<double> *ret = w ? w : &world;
double c = l[0]; double c = l[0];
for (int j = 0; j < dimOfWorld; j++) for (int j = 0; j < dimOfWorld; j++)
......
...@@ -764,13 +764,14 @@ namespace AMDiS { ...@@ -764,13 +764,14 @@ namespace AMDiS {
if (solution_->getDOFVector(i)->getBoundaryManager()) if (solution_->getDOFVector(i)->getBoundaryManager())
solution_->getDOFVector(i)->getBoundaryManager()-> solution_->getDOFVector(i)->getBoundaryManager()->
fillBoundaryConditions(elInfo, solution_->getDOFVector(i)); fillBoundaryConditions(elInfo, solution_->getDOFVector(i));
elInfo = stack.traverseNext(elInfo); elInfo = stack.traverseNext(elInfo);
} }
if (rhs_->getDOFVector(i)->getBoundaryManager()) if (rhs_->getDOFVector(i)->getBoundaryManager())
rhs_->getDOFVector(i)->getBoundaryManager()->exitVector(rhs_->getDOFVector(i)); rhs_->getDOFVector(i)->getBoundaryManager()->exitVector(rhs_->getDOFVector(i));
if (solution_->getDOFVector(i)->getBoundaryManager()) if (solution_->getDOFVector(i)->getBoundaryManager())
solution_->getDOFVector(i)->getBoundaryManager()->exitVector(solution_->getDOFVector(i)); solution_->getDOFVector(i)->getBoundaryManager()->exitVector(solution_->getDOFVector(i));
} }
#ifdef _OPENMP #ifdef _OPENMP
...@@ -939,9 +940,16 @@ namespace AMDiS { ...@@ -939,9 +940,16 @@ namespace AMDiS {
{ {
Mesh *mesh = feSpace->getMesh(); Mesh *mesh = feSpace->getMesh();
const BasisFunction *basisFcts = feSpace->getBasisFcts(); const BasisFunction *basisFcts = feSpace->getBasisFcts();
#ifdef _OPENMP
TraverseParallelStack stack; TraverseParallelStack stack;
#else
TraverseStack stack;
#endif
#ifdef _OPENMP
#pragma omp parallel #pragma omp parallel
#endif
{ {
BoundaryType *bound = useGetBound_ ? GET_MEMORY(BoundaryType, basisFcts->getNumber()) : NULL; BoundaryType *bound = useGetBound_ ? GET_MEMORY(BoundaryType, basisFcts->getNumber()) : NULL;
...@@ -1004,7 +1012,9 @@ namespace AMDiS { ...@@ -1004,7 +1012,9 @@ namespace AMDiS {
// the same time. // the same time.
if (matrix) { if (matrix) {
#ifdef _OPENMP
#pragma omp critical #pragma omp critical
#endif
{ {
addDOFMatrix(matrix, tmpMatrix); addDOFMatrix(matrix, tmpMatrix);
...@@ -1016,7 +1026,9 @@ namespace AMDiS { ...@@ -1016,7 +1026,9 @@ namespace AMDiS {
} }
if (vector) { if (vector) {
#ifdef _OPENMP
#pragma omp critical #pragma omp critical
#endif
*vector += *tmpVector; *vector += *tmpVector;
DELETE tmpVector; DELETE tmpVector;
......
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