12#ifndef DUMUX_DISCRETIZATION_QUADRATURE_RULES_HH
13#define DUMUX_DISCRETIZATION_QUADRATURE_RULES_HH
17#include <dune/common/std/type_traits.hh>
18#include <dune/geometry/quadraturerules.hh>
22#include <dumux/common/concepts/ipdata_.hh>
37 using Scalar =
typename IpData::GlobalPosition::value_type;
41 : weight_(w), ipData_(std::move(ip))
44 const Scalar&
weight()
const {
return weight_; }
45 const IpData&
ipData()
const {
return ipData_; }
52namespace QuadratureRules {
78template<
class GridView,
95template<
class FVElementGeometry>
98template<
class FVElementGeometry>
101template<
class FVElementGeometry>
104template<
class FVElementGeometry>
107template<
class FVElementGeometry>
111template<
class FVElementGeometry>
117template<
class FVElementGeometry>
123template<
class FVElementGeometry>
129template<
class FVElementGeometry>
135template<
class FVElementGeometry>
141template<
class Gr
idView>
143 typename GridView::template Codim<0>::Entity::Geometry::LocalCoordinate,
144 typename GridView::template Codim<0>::Entity::Geometry::GlobalCoordinate,
149template<
class Gr
idView>
151 typename GridView::template Codim<0>::Entity::Geometry::LocalCoordinate,
152 typename GridView::template Codim<0>::Entity::Geometry::GlobalCoordinate
158template<
class FVElementGeometry>
160 const typename FVElementGeometry::SubControlVolume& scv,
163 using GridGeometry =
typename FVElementGeometry::GridGeometry;
164 using GridView =
typename GridGeometry::GridView;
167 const auto& elementGeo = fvGeometry.elementGeometry();
168 const auto ipGlobal = scv.center();
169 const auto ipLocal = elementGeo.local(ipGlobal);
170 const auto localDofIdx = scv.localDofIndex();
172 std::array<QuadraturePointData<QIpData>, 1> result{{
179template<
int order,
class FVElementGeometry>
181 const typename FVElementGeometry::SubControlVolume& scv,
184 using GridGeometry =
typename FVElementGeometry::GridGeometry;
185 using GridView =
typename GridGeometry::GridView;
189 auto scvGeo = fvGeometry.geometry(scv);
190 const auto& elementGeo = fvGeometry.elementGeometry();
191 auto quad = Dune::QuadratureRules<typename GridView::ctype, GridView::dimension>::rule(scvGeo.type(), order);
192 const auto localDofIdx = scv.localDofIndex();
194 return std::views::iota(0u, quad.size())
195 | std::views::transform([quad = std::move(quad), scvGeo = std::move(scvGeo), &elementGeo, localDofIdx](
const auto idx) {
196 const auto& qp = quad[idx];
197 const auto ipGlobal = scvGeo.global(qp.position());
198 const auto ipLocal = elementGeo.local(ipGlobal);
200 qp.weight() * Extrusion::integrationElement(scvGeo, qp.position()),
201 QIpData(idx, ipLocal, ipGlobal, localDofIdx)
207template<
class FVElementGeometry>
209 const typename FVElementGeometry::SubControlVolumeFace& scvf,
212 using GridGeometry =
typename FVElementGeometry::GridGeometry;
213 using GridView =
typename GridGeometry::GridView;
217 const auto& elementGeo = fvGeometry.elementGeometry();
218 const auto ipGlobal = scvf.ipGlobal();
219 const auto ipLocal = elementGeo.local(ipGlobal);
221 std::array<QuadraturePointData<QFaceIpData>, 1> result{{
222 {Extrusion::area(fvGeometry, scvf), QFaceIpData(0, scvf.unitOuterNormal(), scvf.index(), ipLocal, ipGlobal)}
228template<
int order,
class FVElementGeometry>
230 const typename FVElementGeometry::SubControlVolumeFace& scvf,
233 using GridGeometry =
typename FVElementGeometry::GridGeometry;
234 using GridView =
typename GridGeometry::GridView;
240 auto scvfGeo = fvGeometry.geometry(scvf);
241 const auto& elementGeo = fvGeometry.elementGeometry();
242 auto quad = Dune::QuadratureRules<typename GridView::ctype, GridView::dimension-1>::rule(scvfGeo.type(), order);
243 auto normal = scvf.unitOuterNormal();
244 const auto scvfIndex = scvf.index();
246 return std::views::iota(0u, quad.size())
247 | std::views::transform([quad = std::move(quad), scvfGeo = std::move(scvfGeo), &elementGeo,
normal = std::move(
normal), scvfIndex](
const auto idx) {
248 const auto& qp = quad[idx];
249 const auto ipGlobal = scvfGeo.global(qp.position());
250 const auto ipLocal = elementGeo.local(ipGlobal);
252 qp.weight() * Extrusion::integrationElement(scvfGeo, qp.position()),
253 QFaceIpData(idx, normal, scvfIndex, ipLocal, ipGlobal)
259template<
class FVElementGeometry>
261 const typename FVElementGeometry::Element& element,
264 using GridGeometry =
typename FVElementGeometry::GridGeometry;
265 using GridView =
typename GridGeometry::GridView;
269 const auto& elementGeo = fvGeometry.elementGeometry();
270 const auto ipGlobal = elementGeo.center();
271 const auto ipLocal = elementGeo.local(ipGlobal);
273 std::array<Dumux::QuadraturePointData<QIpData>, 1> result{{
280template<
int order,
class FVElementGeometry>
282 const typename FVElementGeometry::Element& element,
285 using GridGeometry =
typename FVElementGeometry::GridGeometry;
286 using GridView =
typename GridGeometry::GridView;
290 const auto& elementGeo = fvGeometry.elementGeometry();
291 auto quad = Dune::QuadratureRules<typename GridView::ctype, GridView::dimension>::rule(elementGeo.type(), order);
293 return std::views::iota(0u, quad.size())
294 | std::views::transform([quad = std::move(quad), &elementGeo](
const auto idx) {
295 const auto& qp = quad[idx];
296 const auto ipGlobal = elementGeo.global(qp.position());
297 const auto ipLocal = qp.position();
299 qp.weight() * Extrusion::integrationElement(elementGeo, qp.position()),
300 QIpData(idx, ipLocal, ipGlobal)
306template<
class FVElementGeometry>
308 const typename FVElementGeometry::GridGeometry::GridView::Intersection& is,
312 using GridGeometry =
typename FVElementGeometry::GridGeometry;
313 using GridView =
typename GridGeometry::GridView;
321 const auto& elementGeo = fvGeometry.elementGeometry();
322 const auto isGeometry = is.geometry();
323 const auto ipGlobal = isGeometry.center();
324 const auto ipLocal = elementGeo.local(ipGlobal);
326 std::array<Dumux::QuadraturePointData<QFaceIpData>, 1> result{{
327 {Extrusion::area(fvGeometry, isGeometry),
328 QFaceIpData(0, is.centerUnitOuterNormal(), BFlag{ is }, is.indexInInside(), ipLocal, ipGlobal)}
334template<
int order,
class FVElementGeometry>
336 const typename FVElementGeometry::GridGeometry::GridView::Intersection& is,
340 using GridGeometry =
typename FVElementGeometry::GridGeometry;
341 using GridView =
typename GridGeometry::GridView;
349 const auto& elementGeo = fvGeometry.elementGeometry();
350 auto isGeometry = is.geometry();
351 auto quad = Dune::QuadratureRules<typename GridView::ctype, GridView::dimension-1>::rule(isGeometry.type(), order);
352 auto normal = is.centerUnitOuterNormal();
353 auto bFlag = BFlag{ is };
354 auto index = is.indexInInside();
356 return std::views::iota(0u, quad.size())
357 | std::views::transform(
358 [quad = std::move(quad), isGeometry = std::move(isGeometry), &elementGeo,
normal = std::move(
normal),
359 bFlag = std::move(bFlag), index](
const auto idx) {
360 const auto& qp = quad[idx];
361 const auto ipGlobal = isGeometry.global(qp.position());
362 const auto ipLocal = elementGeo.local(ipGlobal);
364 qp.weight() * Extrusion::integrationElement(isGeometry, qp.position()),
365 QFaceIpData(idx, normal, bFlag, index, ipLocal, ipGlobal)
371template<
class FVElementGeometry>
373 const typename FVElementGeometry::GridGeometry::BoundaryFace& boundaryFace,
376 using GridGeometry =
typename FVElementGeometry::GridGeometry;
377 using GridView =
typename GridGeometry::GridView;
383 const auto& elementGeo = fvGeometry.elementGeometry();
384 const auto ipGlobal = boundaryFace.center();
385 const auto ipLocal = elementGeo.local(ipGlobal);
387 std::array<QuadraturePointData<QBFIpData>, 1> result{{
388 {Extrusion::area(fvGeometry, boundaryFace), QBFIpData(0, boundaryFace.unitOuterNormal(), boundaryFace.index(), ipLocal, ipGlobal)}
394template<
int order,
class FVElementGeometry>
396 const typename FVElementGeometry::GridGeometry::BoundaryFace& boundaryFace,
399 using GridGeometry =
typename FVElementGeometry::GridGeometry;
400 using GridView =
typename GridGeometry::GridView;
406 auto bfGeo = fvGeometry.geometry(boundaryFace);
407 const auto& elementGeo = fvGeometry.elementGeometry();
408 auto quad = Dune::QuadratureRules<typename GridView::ctype, GridView::dimension-1>::rule(bfGeo.type(), order);
409 auto normal = boundaryFace.unitOuterNormal();
410 const auto bfIdx = boundaryFace.index();
412 return std::views::iota(0u, quad.size())
413 | std::views::transform([quad = std::move(quad), bfGeo = std::move(bfGeo), &elementGeo,
normal = std::move(
normal), bfIdx](
const auto idx) {
414 const auto& qp = quad[idx];
415 const auto ipGlobal = bfGeo.global(qp.position());
416 const auto ipLocal = elementGeo.local(ipGlobal);
418 qp.weight() * Extrusion::integrationElement(bfGeo, qp.position()),
419 QBFIpData(idx, normal, bfIdx, ipLocal, ipGlobal)
425template<
class FVElementGeometry>
426auto quadratureRule(
const FVElementGeometry& fvGeometry,
const typename FVElementGeometry::SubControlVolume& scv)
432template<
class FVElementGeometry>
433auto quadratureRule(
const FVElementGeometry& fvGeometry,
const typename FVElementGeometry::SubControlVolumeFace& scvf)
439template<
class FVElementGeometry>
440auto quadratureRule(
const FVElementGeometry& fvGeometry,
const typename FVElementGeometry::Element& element)
446template<
class FVElementGeometry>
447auto quadratureRule(
const FVElementGeometry& fvGeometry,
const typename FVElementGeometry::GridGeometry::GridView::Intersection& intersection)
453template<
class FVElementGeometry>
454auto quadratureRule(
const FVElementGeometry& fvGeometry,
const typename FVElementGeometry::GridGeometry::BoundaryFace& boundaryFace)
Boundary flag to store e.g. in sub control volume faces.
Boundary flag to store e.g. in sub control volume faces.
Definition: boundaryflag.hh:58
An interpolation point related to a face of an element.
Definition: cvfe/interpolationpointdata.hh:109
Wraps interpolation point data and adds a quadrature point index for use in quadrature loops.
Definition: cvfe/interpolationpointdata.hh:141
An interpolation point related to an element that includes global and local positions.
Definition: cvfe/interpolationpointdata.hh:31
An interpolation point related to a localDof of an element, giving its global and local positions.
Definition: cvfe/interpolationpointdata.hh:60
Traits extracting the public Extrusion type from T Defaults to NoExtrusion if no such type is found.
Definition: extrusion.hh:225
An interpolation point related to a boundary face.
Definition: fem/interpolationpointdata.hh:144
An interpolation point related to an intersection.
Definition: fem/interpolationpointdata.hh:107
Quadrature point data with weight and interpolation point info.
Definition: quadraturerules.hh:36
const Scalar & weight() const
Definition: quadraturerules.hh:44
QuadraturePointData(Scalar w, IpData ip)
Definition: quadraturerules.hh:40
const IpData & ipData() const
Definition: quadraturerules.hh:45
Classes representing interpolation point data for control-volume finite element schemes.
Helper classes to compute the integration elements.
Shape functions and gradients at an interpolation point.
Vector normal(const Vector &v)
Create a vector normal to the given one (v is expected to be non-zero)
Definition: normal.hh:26
auto volume(const Geometry &geo, unsigned int integrationOrder=4)
The volume of a given geometry.
Definition: volume.hh:159
typename FVElementGeometry::ScvQuadratureRule DefinesScvQuadratureRuleType
Definition: quadraturerules.hh:96
Dune::Std::detected_or_t< QuadratureRules::MidpointQuadrature, DefinesScvfQuadratureRuleType, FVElementGeometry > ScvfQuadratureRuleType
Get ScvfQuadratureRule type (default is MidpointQuadrature)
Definition: quadraturerules.hh:120
typename FVElementGeometry::ElementQuadratureRule DefinesElementQuadratureRuleType
Definition: quadraturerules.hh:102
Dune::Std::detected_or_t< QuadratureRules::MidpointQuadrature, DefinesElementQuadratureRuleType, FVElementGeometry > ElementQuadratureRuleType
Get ElementQuadratureRule type (default is MidpointQuadrature)
Definition: quadraturerules.hh:126
Dune::Std::detected_or_t< QuadratureRules::MidpointQuadrature, DefinesScvQuadratureRuleType, FVElementGeometry > ScvQuadratureRuleType
Get ScvQuadratureRule type (default is MidpointQuadrature)
Definition: quadraturerules.hh:114
Dune::Std::detected_or_t< QuadratureRules::MidpointQuadrature, DefinesIntersectionQuadratureRuleType, FVElementGeometry > IntersectionQuadratureRuleType
Get IntersectionQuadratureRule type (default is MidpointQuadrature)
Definition: quadraturerules.hh:132
typename FVElementGeometry::ScvfQuadratureRule DefinesScvfQuadratureRuleType
Definition: quadraturerules.hh:99
typename FVElementGeometry::IntersectionQuadratureRule DefinesIntersectionQuadratureRuleType
Definition: quadraturerules.hh:105
Dune::Std::detected_or_t< QuadratureRules::MidpointQuadrature, DefinesBoundaryFaceQuadratureRuleType, FVElementGeometry > BoundaryFaceQuadratureRuleType
Get BoundaryFaceQuadratureRule type (default is MidpointQuadrature)
Definition: quadraturerules.hh:138
typename FVElementGeometry::BoundaryFaceQuadratureRule DefinesBoundaryFaceQuadratureRuleType
Definition: quadraturerules.hh:108
auto quadratureRule(const FVElementGeometry &fvGeometry, const typename FVElementGeometry::SubControlVolume &scv, QuadratureRules::MidpointQuadrature)
Midpoint quadrature for scv.
Definition: quadraturerules.hh:159
typename Extrusion< T >::type Extrusion_t
Convenience alias for obtaining the extrusion type.
Definition: extrusion.hh:236
Quadrature rule traits for discretization schemes.
Definition: quadraturerules.hh:85
ElementRule ElementQuadratureRule
Definition: quadraturerules.hh:88
BoundaryFaceRule BoundaryFaceQuadratureRule
Definition: quadraturerules.hh:90
ScvRule ScvQuadratureRule
Definition: quadraturerules.hh:86
IntersectionRule IntersectionQuadratureRule
Definition: quadraturerules.hh:89
ScvfRule ScvfQuadratureRule
Definition: quadraturerules.hh:87
unsigned int LocalIndex
Definition: indextraits.hh:28
Dune-based quadrature rule with specified order.
Definition: quadraturerules.hh:66
static constexpr int quadratureOrder
Definition: quadraturerules.hh:67
Midpoint quadrature rule that uses scv/scvf centers.
Definition: quadraturerules.hh:58
Helper class to create (named and comparable) tagged types Tags any given type. The tagged type is eq...
Definition: tag.hh:30
Helper class to create (named and comparable) tagged types.