#pragma once #include #include #include #include #include namespace AMDiS { template template void BiLinearForm:: addOperator(ContextTag contextTag, Expr const& expr, RowTreePath row, ColTreePath col) { static_assert( Concepts::PreTreePath, "row must be a valid treepath, or an integer/index-constant"); static_assert( Concepts::PreTreePath, "col must be a valid treepath, or an integer/index-constant"); auto i = makeTreePath(row); auto node_i = child(this->rowBasis().localView().treeCache(), i); auto j = makeTreePath(col); auto node_j = child(this->colBasis().localView().treeCache(), j); using LocalContext = typename ContextTag::type; using Tr = DefaultAssemblerTraits; auto op = makeLocalOperator(expr, this->rowBasis().gridView()); auto localAssembler = makeUniquePtr(makeAssembler(std::move(op), node_i, node_j)); operators_[i][j].push(contextTag, std::move(localAssembler)); updatePattern_ = true; } template template ), REQUIRES_(Concepts::LocalView)> void BiLinearForm:: assemble(RowLocalView const& rowLocalView, ColLocalView const& colLocalView) { elementMatrix_.resize(rowLocalView.size(), colLocalView.size()); elementMatrix_ = 0; auto const& gv = this->rowBasis().gridView(); auto const& element = rowLocalView.element(); auto geometry = element.geometry(); for_each_node(rowLocalView.treeCache(), [&](auto const& rowNode, auto rowTp) { for_each_node(colLocalView.treeCache(), [&](auto const& colNode, auto colTp) { auto& matOp = operators_[rowTp][colTp]; if (matOp) { matOp.bind(element, geometry); assembleOperators(gv, element, matOp, makeMatrixAssembler(rowNode, colNode, elementMatrix_)); matOp.unbind(); } }); }); this->scatter(rowLocalView, colLocalView, elementMatrix_); } template void BiLinearForm:: assemble() { auto rowLocalView = this->rowBasis().localView(); auto colLocalView = this->colBasis().localView(); this->init(); for (auto const& element : elements(this->rowBasis().gridView(), typename Traits::PartitionSet{})) { rowLocalView.bind(element); if (this->rowBasis() == this->colBasis()) this->assemble(rowLocalView, rowLocalView); else { colLocalView.bind(element); this->assemble(rowLocalView, colLocalView); colLocalView.unbind(); } rowLocalView.unbind(); } this->finish(); } } // end namespace AMDiS