diff --git a/AMDiS/src/DirichletBC.cc b/AMDiS/src/DirichletBC.cc index be0b9deb48cafe1f2e57f1554d30b65e2183b077..ea8fdab07bab76e31fd5ca70939ec4391b47e51a 100644 --- a/AMDiS/src/DirichletBC.cc +++ b/AMDiS/src/DirichletBC.cc @@ -19,15 +19,16 @@ namespace AMDiS { worldCoords.resize(omp_get_overall_max_threads()); } + DirichletBC::DirichletBC(BoundaryType type, - DOFVectorBase<double> *vec) - : BoundaryCondition(type, vec->getFESpace()), + DOFVectorBase<double> *vec, + bool apply) + : BoundaryCondition(type, vec->getFESpace(), vec->getFESpace()), f(NULL), dofVec(vec), - applyBC(true) - { - worldCoords.resize(omp_get_overall_max_threads()); - } + applyBC(apply) + {} + void DirichletBC::fillBoundaryCondition(DOFMatrix* matrix, ElInfo* elInfo, @@ -39,6 +40,7 @@ namespace AMDiS { TEST_EXIT_DBG(matrix->getRowFESpace() == rowFESpace)("invalid row fe space\n"); } + void DirichletBC::fillBoundaryCondition(DOFVectorBase<double>* vector, ElInfo* elInfo, const DegreeOfFreedom* dofIndices, diff --git a/AMDiS/src/DirichletBC.h b/AMDiS/src/DirichletBC.h index 23ae3d8560155f119111d97dc5831ba602c2519f..eac7566a211a36f574f8a78d626bdef3170b1d98 100644 --- a/AMDiS/src/DirichletBC.h +++ b/AMDiS/src/DirichletBC.h @@ -49,7 +49,8 @@ namespace AMDiS { /// Constructor. DirichletBC(BoundaryType type, - DOFVectorBase<double> *vec); + DOFVectorBase<double> *vec, + bool apply = true); /// Implementation of BoundaryCondition::fillBoundaryCondition(). void fillBoundaryCondition(DOFMatrix* matrix, diff --git a/AMDiS/src/ProblemVec.cc b/AMDiS/src/ProblemVec.cc index 76ca18b22fd46a8a8bc442073660bc1c25346864..40b6b4ad20b0f54ec96f394cb3663fd300c09aae 100644 --- a/AMDiS/src/ProblemVec.cc +++ b/AMDiS/src/ProblemVec.cc @@ -1189,14 +1189,39 @@ namespace AMDiS { DirichletBC *dirichletNotApply = new DirichletBC(type, b, componentSpaces[row], componentSpaces[col], false); - for (int i = 0; i < nComponents; i++) { - if (systemMatrix && (*systemMatrix)[row][i]) { + for (int i = 0; i < nComponents; i++) + if (systemMatrix && (*systemMatrix)[row][i]) + if (i == col) + (*systemMatrix)[row][i]->getBoundaryManager()->addBoundaryCondition(dirichletApply); + else + (*systemMatrix)[row][i]->getBoundaryManager()->addBoundaryCondition(dirichletNotApply); + + if (rhs) + rhs->getDOFVector(row)->getBoundaryManager()->addBoundaryCondition(dirichletApply); + if (solution) + solution->getDOFVector(row)->getBoundaryManager()->addBoundaryCondition(dirichletApply); + } + + + void ProblemVec::addDirichletBC(BoundaryType type, int row, int col, + DOFVector<double> *vec) + { + FUNCNAME("ProblemVec::addDirichletBC()"); + + TEST_EXIT(row >= 0 && row < nComponents)("Wrong row number: %d\n", row); + TEST_EXIT(col >= 0 && col < nComponents)("Wrong col number: %d\n", col); + + boundaryConditionSet = true; + + DirichletBC *dirichletApply = new DirichletBC(type, vec, true); + DirichletBC *dirichletNotApply = new DirichletBC(type, vec, false); + + for (int i = 0; i < nComponents; i++) + if (systemMatrix && (*systemMatrix)[row][i]) if (i == col) (*systemMatrix)[row][i]->getBoundaryManager()->addBoundaryCondition(dirichletApply); else (*systemMatrix)[row][i]->getBoundaryManager()->addBoundaryCondition(dirichletNotApply); - } - } if (rhs) rhs->getDOFVector(row)->getBoundaryManager()->addBoundaryCondition(dirichletApply); diff --git a/AMDiS/src/ProblemVec.h b/AMDiS/src/ProblemVec.h index 9aac3317410c068c354b57915198dde8c1255de8..499687027d4ff3cfea69ca911d739c1a565bbdbd 100644 --- a/AMDiS/src/ProblemVec.h +++ b/AMDiS/src/ProblemVec.h @@ -244,6 +244,9 @@ namespace AMDiS { virtual void addDirichletBC(BoundaryType type, int row, int col, AbstractFunction<double, WorldVector<double> > *b); + virtual void addDirichletBC(BoundaryType type, int row, int col, + DOFVector<double> *vec); + /// Adds neumann boundary conditions. virtual void addNeumannBC(BoundaryType type, int row, int col, AbstractFunction<double, WorldVector<double> > *n);