1#ifndef __DUNE_ACFEM_L2_SCALAR_PRODUCT_FUNCTIONAL_HH__
2#define __DUNE_ACFEM_L2_SCALAR_PRODUCT_FUNCTIONAL_HH__
4#include "linearfunctional.hh"
5#include "../../models/boundaryindicator.hh"
6#include "../../common/quadrature.hh"
7#include "../../functions/gridfunctionexpression.hh"
8#include "../../functions/boundaryfunctionexpression.hh"
22 template<
class DiscreteFunctionSpace,
24 class BndryIndicator = EntireBoundaryIndicatorType,
25 template<
class>
class QuadratureTraits = DefaultQuadratureTraits>
26 class L2BoundaryFunctional;
28 template<
class DiscreteFunctionSpace,
31 template<
class>
class QuadratureTraits>
32 class LocalL2BoundaryFunctional;
34 template<
class DiscreteFunctionSpace,
37 template<
class>
class QuadratureTraits>
38 struct L2BoundaryFunctionalTraits
40 LinearFunctionalTraitsDefault<
41 L2BoundaryFunctional<DiscreteFunctionSpace,
45 LocalL2BoundaryFunctional<DiscreteFunctionSpace,
51 typedef L2BoundaryFunctionalTraits ThisType;
60 ZeroFunctionalExpression<DiscreteFunctionSpace, ThisType>,
61 DiscreteLinearFunctionalExpression<DiscreteFunctionSpace, ThisType>
66 template<
class DiscreteFunctionSpace,
69 template<
class>
class QuadratureTraits>
70 class L2BoundaryFunctional
71 :
public L2BoundaryFunctionalTraits<DiscreteFunctionSpace,
74 QuadratureTraits>::ExpressionBaseType
76 typedef L2BoundaryFunctional ThisType;
79 L2BoundaryFunctionalTraits<DiscreteFunctionSpace, GridFunction, BndryIndicator, QuadratureTraits>
81 typedef GridFunction L2FunctionType;
82 typedef BndryIndicator OuterIndicatorType;
84 typedef typename TraitsType::ExpressionBaseType BaseType;
87 decltype(std::declval<OuterIndicatorType>() * std::declval<L2FunctionType>())
89 typedef typename BndryFunctionType::IndicatorType IndicatorType;
90 typedef DiscreteFunctionSpace DiscreteFunctionSpaceType;
91 typedef typename DiscreteFunctionSpaceType::FunctionSpaceType FunctionSpaceType;
93 Fem::Function<typename L2FunctionType::FunctionSpaceType, L2FunctionType>
94 L2FunctionInterfaceType;
96 Fem::DiscreteFunctionSpaceInterface<typename DiscreteFunctionSpaceType::Traits>
97 DiscreteFunctionSpaceInterfaceType;
99 BoundaryIndicatorInterface<OuterIndicatorType>
100 IndicatorInterfaceType;
102 L2BoundaryFunctional(
const DiscreteFunctionSpaceInterfaceType& space,
103 const L2FunctionInterfaceType& L2Fct,
104 const IndicatorInterfaceType& indicator = OuterIndicatorType(),
105 unsigned degree = 2*DiscreteFunctionSpaceType::polynomialOrder)
106 : BaseType(static_cast<const DiscreteFunctionSpaceType&>(space)),
111 using BaseType::operator();
112 using BaseType::coefficients;
113 using BaseType::space;
114 using BaseType::localFunctional;
116 std::string name()
const
118 return "[" + bndryFct_().name() +
", . ]";
121 const BndryFunctionType& function()
const
126 unsigned quadratureDegree()
const
131 const IndicatorType& indicator()
const
133 return function().indicator();
136 IndicatorType& indicator()
138 return function().indicator();
142 ExpressionStorage<BndryFunctionType> bndryFct_;
143 const unsigned degree_;
146 template<
class DiscreteFunctionSpace,
148 class BndryIndicator,
149 template<
class>
class QuadratureTraits>
150 class LocalL2BoundaryFunctional
151 :
public LocalLinearFunctionalDefault<DiscreteFunctionSpace,
152 L2BoundaryFunctionalTraits<DiscreteFunctionSpace,
159 L2BoundaryFunctionalTraits<DiscreteFunctionSpace,
165 typedef LocalL2BoundaryFunctional ThisType;
166 typedef LocalLinearFunctionalDefault<DiscreteFunctionSpace, TraitsType> BaseType;
169 L2BoundaryFunctional<DiscreteFunctionSpace, GridFunction, BndryIndicator, QuadratureTraits>
171 typedef DiscreteFunctionSpace DiscreteFunctionSpaceType;
172 typedef typename DiscreteFunctionSpaceType::EntityType EntityType;
173 typedef typename DiscreteFunctionSpaceType::RangeFieldType FieldType;
174 typedef FieldType RangeType;
176 typedef typename FunctionalType::IndicatorType IndicatorType;
177 typedef typename FunctionalType::BndryFunctionType BndryFunctionType;
178 typedef typename BndryFunctionType::LocalFunctionType LocalBndryFunctionType;
179 typedef typename DiscreteFunctionSpaceType::GridPartType GridPartType;
180 typedef QuadratureTraits<GridPartType> QuadratureTraitsType;
181 typedef typename QuadratureTraitsType::BulkQuadratureType QuadratureType;
182 typedef typename QuadratureTraitsType::BulkMassQuadratureType MassQuadratureType;
183 typedef typename QuadratureTraitsType::FaceQuadratureType FaceQuadratureType;
184 typedef typename QuadratureTraitsType::FaceMassQuadratureType FaceMassQuadratureType;
186 typedef Dune::Fem::IntersectionQuadrature<FaceMassQuadratureType, true> IntersectionMassQuadratureType;
187 typedef typename IntersectionMassQuadratureType::FaceQuadratureType BndryMassQuadratureType;
190 LocalL2BoundaryFunctional(
const FunctionalType& phi)
192 bndryLocal_(phi.function()),
193 indicator_(phi.function().indicator()),
194 gridPart_(phi.space().gridPart()),
195 degree_(phi.quadratureDegree())
198 LocalL2BoundaryFunctional(
const EntityType& entity,
const FunctionalType& phi)
199 : BaseType(entity, phi),
200 bndryLocal_(phi.function()),
201 indicator_(phi.function().indicator()),
202 gridPart_(phi.space().gridPart()),
203 degree_(phi.quadratureDegree())
208 template<
class LocalFunction>
209 RangeType operator()(
const LocalFunction& wLocal)
const
211 if (ExpressionTraits<IndicatorType>::isZero) {
216 const auto& entity = wLocal.entity();
218 if (!entity.hasBoundaryIntersections()) {
225 template<
class LocalFunction>
226 void coefficients(
const RangeType& c, LocalFunction& coeffs)
const
228 if (ExpressionTraits<IndicatorType>::isZero) {
232 const auto& entity = coeffs.entity();
234 if (!entity.hasBoundaryIntersections()) {
238 const auto iend = gridPart_.iend(entity);
239 for (
auto it = gridPart_.ibegin(entity); it != iend; ++it) {
241 const auto &intersection = *it;
243 if (intersection.neighbor() || !intersection.boundary()) {
247 if (!indicator_.applies(intersection)) {
251 bndryLocal_.init(entity, intersection);
253 const int quadOrder = degree_;
255 IntersectionMassQuadratureType intersectionQuad(gridPart_, intersection, quadOrder);
256 const BndryMassQuadratureType &bndryQuad = intersectionQuad.inside();
257 const int numQuadraturePoints = bndryQuad.nop();
259 for (
int pt = 0; pt < numQuadraturePoints; ++pt) {
262 const double weight = bndryQuad.weight(pt);
265 const double integrationElement = intersection.geometry().integrationElement(bndryQuad.localPoint(pt));
267 typename LocalBndryFunctionType::RangeType f;
268 bndryLocal_.evaluate(bndryQuad[pt], f);
269 f *= weight * integrationElement * c;
270 coeffs.axpy(bndryQuad[pt], f);
278 template<
class LocalFunction>
284 using BaseType::operator();
285 using BaseType::functional;
286 using BaseType::entity;
289 using BaseType::entity_;
290 mutable LocalBndryFunctionType bndryLocal_;
291 const IndicatorType& indicator_;
292 const GridPartType& gridPart_;
293 const unsigned degree_;
void coefficients(const RangeType &c, LocalFunction &coeffs) const
Definition: linearfunctional.hh:443
void coefficients(LocalFunction &coeffs) const
Compute the basis representation, which means: do the assembling stuff.
Definition: linearfunctional.hh:436
RangeType operator()(const LocalFunction &arg) const
Compute the value.
Definition: linearfunctional.hh:410
constexpr bool isZero(Expression &&)
Specialize to evaluate to true for zero expressions.
Definition: expressionoperations.hh:469
const Implementation & asImp(const Fem::BartonNackmanInterface< Interface, Implementation > &arg)
Up-cast to the implementation for any Fem::BartonNackmanInterface.
Definition: expressionoperations.hh:71