#pragma once #include #include "Log.hpp" namespace AMDiS { template template void DirichletBC::init(bool apply, RowFeSpace const& rowFeSpace, ColFeSpace const& colFeSpace, DOFMatrix* matrix, DOFVector* rhs, DOFVector* solution) { using Dune::Functions::interpolate; if (!initialized) { interpolate(rowFeSpace, dirichletNodes, predicate); initialized = true; } } template template void DirichletBC::finish(bool apply, RowFeSpace const& rowFeSpace, ColFeSpace const& colFeSpace, DOFMatrix* matrix, DOFVector* rhs, DOFVector* solution) { using Dune::Functions::interpolate; AMDIS_TEST_EXIT( initialized, "Boundary condition not initialized!" ); // loop over the matrix rows for (size_t i = 0; i < matrix->N(); ++i) { if (dirichletNodes[i]) { auto cIt = (*matrix)[i].begin(); auto cEndIt = (*matrix)[i].end(); // loop over nonzero matrix entries in current row for (; cIt != cEndIt; ++cIt) *cIt = (apply && i == cIt.index()) ? 1.0 : 0.0; } } if (apply) { interpolate(rowFeSpace, *rhs, values, dirichletNodes); interpolate(colFeSpace, *solution, values, dirichletNodes); } } } // end namespace AMDiS