#pragma once #include #include #include #include #include #include namespace AMDiS { template template void LinearForm:: addOperator(ContextTag contextTag, Expr const& expr, TreePath path) { static_assert( Concepts::PreTreePath, "path must be a valid treepath, or an integer/index-constant"); auto i = makeTreePath(path); auto node = child(this->basis()->localView().tree(), i); using LocalContext = typename ContextTag::type; using Tr = DefaultAssemblerTraits; auto op = makeLocalOperator(expr, this->basis()->gridView()); auto localAssembler = makeUniquePtr(makeAssembler(std::move(op), node)); operators_[i].push(contextTag, std::move(localAssembler)); } template template )> void LinearForm:: assemble(LocalView const& localView) { elementVector_.resize(localView.size()); elementVector_ = 0; auto const& gv = this->basis()->gridView(); auto const& element = localView.element(); auto geometry = element.geometry(); for_each_node(localView.tree(), [&](auto const& node, auto tp) { auto& rhsOp = operators_[tp]; if (rhsOp) { rhsOp.bind(element, geometry); assembleOperators(gv, element, rhsOp, makeVectorAssembler(node, elementVector_)); rhsOp.unbind(); } }); this->scatter(localView, elementVector_, Assigner::plus_assign{}); } template void LinearForm:: assemble() { auto localView = this->basis()->localView(); this->init(sizeInfo(*this->basis()), true); for (auto const& element : elements(this->basis()->gridView(), typename Traits::PartitionSet{})) { localView.bind(element); this->assemble(localView); localView.unbind(); } this->finish(); } } // end namespace AMDiS