From 9dc91b727a3ce1202181f3cea5076d4aacab3f2b Mon Sep 17 00:00:00 2001 From: Jonathan Youett <youett@math.fu-berlin.de> Date: Wed, 10 Oct 2018 10:51:22 +0200 Subject: [PATCH] Allow multiple Dirichlet boundaries with different values --- nonlinelast.cc | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/nonlinelast.cc b/nonlinelast.cc index 36c75b5..32721a5 100644 --- a/nonlinelast.cc +++ b/nonlinelast.cc @@ -84,17 +84,27 @@ int main (int argc, char *argv[]) try #endif } - // Read coarse Dirichlet boundary values - BitSetVector<dim> coarseDirichletNodes; - VectorType coarseDirichletValues; - DirichletBCAssembler<GridType>::assembleDirichletBC(*grid, parameterSet, - coarseDirichletNodes, coarseDirichletValues, - path); - const double scaling = parameterSet.get<double>("scaling"); - coarseDirichletValues *= scaling; - + // Read coarse Dirichlet boundary condition + BitSetVector<dim> coarseDirichletNodes(grid->size(dim),false); + VectorType coarseDirichletValues(grid->size(dim)); + coarseDirichletValues = 0; + + for (int i = 0; i < gridConfig.get<int>("nDirichletConditions"); ++i) { + const auto& dirConfig = gridConfig.sub(formatString("dirichlet%d",i)); + BitSetVector<dim> dirichletNodes; + VectorType dirichletValues; + DirichletBCAssembler<GridType>::assembleDirichletBC(*grid, dirConfig, + dirichletNodes, dirichletValues, path); + auto scaling = dirConfig.get<double>("dvScaling", 1); + + // combine with previous ones + coarseDirichletValues.axpy(scaling, dirichletValues); + for (size_t j = 0; j < dirichletNodes.size(); ++j) + for (int k = 0; k < dim; ++k) + if (dirichletNodes[j][k]) + coarseDirichletNodes[j][k] = true; + } - // ////////////////////// // Uniform refine grid // ///////////////////// -- GitLab