OGS
MathLib::WeightedPoint Class Reference

Detailed Description

Represents a point of a certain dimension that has a weight attached.

Used, e.g., in numerical quadrature.

Definition at line 21 of file WeightedPoint.h.

#include <WeightedPoint.h>

Public Member Functions

template<std::size_t dim>
constexpr WeightedPoint (std::array< double, dim > const &coords, double const weight)
constexpr WeightedPoint (double const weight)
 Constructs a 0D weighted point.
constexpr bool operator== (WeightedPoint const &other) const
constexpr bool operator!= (WeightedPoint const &other) const
constexpr const double * data () const
constexpr double getWeight () const
constexpr std::size_t getDimension () const
 The point dimension, i.e., the number of its coordinates.
constexpr double operator[] (std::size_t coord_idx) const
 Access a specific coordinate.

Private Attributes

double weight_
std::array< double, 3 > coords_
std::size_t dim_

Constructor & Destructor Documentation

◆ WeightedPoint() [1/2]

template<std::size_t dim>
MathLib::WeightedPoint::WeightedPoint ( std::array< double, dim > const & coords,
double const weight )
inlineconstexpr

Constructs a 0...3D weighted point depending on the passed coordinates array.

Definition at line 27 of file WeightedPoint.h.

29 : weight_{weight}, dim_{dim}
30 {
31 static_assert(dim <= 3);
32 std::size_t i = 0;
33 if constexpr (dim > 0) // avoids compiler warning
34 {
35 for (; i < dim; ++i)
36 {
37 coords_[i] = coords[i];
38 }
39 }
40 for (; i < 3; ++i)
41 {
42 // fill the rest with NaN for safety reasons
43 coords_[i] = std::numeric_limits<double>::quiet_NaN();
44 }
45 }
std::array< double, 3 > coords_
constexpr ranges::views::view_closure coords
Definition Mesh.h:234

References coords_, dim_, and weight_.

Referenced by operator!=(), and operator==().

◆ WeightedPoint() [2/2]

MathLib::WeightedPoint::WeightedPoint ( double const weight)
inlineexplicitconstexpr

Constructs a 0D weighted point.

Definition at line 48 of file WeightedPoint.h.

49 : weight_{weight}, dim_{0}
50 {
51 // fill with NaN for safety reasons
52 coords_.fill(std::numeric_limits<double>::quiet_NaN());
53 }

References coords_, dim_, and weight_.

Member Function Documentation

◆ data()

const double * MathLib::WeightedPoint::data ( ) const
inlineconstexpr

Definition at line 80 of file WeightedPoint.h.

80{ return coords_.data(); }

References coords_.

◆ getDimension()

std::size_t MathLib::WeightedPoint::getDimension ( ) const
inlineconstexpr

The point dimension, i.e., the number of its coordinates.

Definition at line 85 of file WeightedPoint.h.

85{ return dim_; }

References dim_.

Referenced by MeshLib::getBulkElementPoint(), and MathLib::operator<<().

◆ getWeight()

◆ operator!=()

bool MathLib::WeightedPoint::operator!= ( WeightedPoint const & other) const
inlineconstexpr

Definition at line 75 of file WeightedPoint.h.

76 {
77 return !(*this == other);
78 }

References WeightedPoint().

◆ operator==()

bool MathLib::WeightedPoint::operator== ( WeightedPoint const & other) const
inlineconstexpr

Definition at line 55 of file WeightedPoint.h.

56 {
57 if (weight_ != other.weight_)
58 {
59 return false;
60 }
61 if (dim_ != other.dim_)
62 {
63 return false;
64 }
65 for (std::size_t comp = 0; comp < dim_; ++comp)
66 {
67 if (coords_[comp] != other.coords_[comp])
68 {
69 return false;
70 }
71 }
72 return true;
73 }

References WeightedPoint(), coords_, dim_, and weight_.

◆ operator[]()

double MathLib::WeightedPoint::operator[] ( std::size_t coord_idx) const
inlineconstexpr

Access a specific coordinate.

Definition at line 88 of file WeightedPoint.h.

89 {
90 return coords_[coord_idx];
91 }

References coords_.

Member Data Documentation

◆ coords_

std::array<double, 3> MathLib::WeightedPoint::coords_
private

Definition at line 95 of file WeightedPoint.h.

Referenced by WeightedPoint(), WeightedPoint(), data(), operator==(), and operator[]().

◆ dim_

std::size_t MathLib::WeightedPoint::dim_
private

Definition at line 96 of file WeightedPoint.h.

Referenced by WeightedPoint(), WeightedPoint(), getDimension(), and operator==().

◆ weight_

double MathLib::WeightedPoint::weight_
private

Definition at line 94 of file WeightedPoint.h.

Referenced by WeightedPoint(), WeightedPoint(), getWeight(), and operator==().


The documentation for this class was generated from the following file: