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 15 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 21 of file WeightedPoint.h.

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

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 42 of file WeightedPoint.h.

43 : weight_{weight}, dim_{0}
44 {
45 // fill with NaN for safety reasons
46 coords_.fill(std::numeric_limits<double>::quiet_NaN());
47 }

References coords_, dim_, and weight_.

Member Function Documentation

◆ data()

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

Definition at line 74 of file WeightedPoint.h.

74{ 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 79 of file WeightedPoint.h.

79{ 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 69 of file WeightedPoint.h.

70 {
71 return !(*this == other);
72 }

References WeightedPoint().

◆ operator==()

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

Definition at line 49 of file WeightedPoint.h.

50 {
51 if (weight_ != other.weight_)
52 {
53 return false;
54 }
55 if (dim_ != other.dim_)
56 {
57 return false;
58 }
59 for (std::size_t comp = 0; comp < dim_; ++comp)
60 {
61 if (coords_[comp] != other.coords_[comp])
62 {
63 return false;
64 }
65 }
66 return true;
67 }

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 82 of file WeightedPoint.h.

83 {
84 return coords_[coord_idx];
85 }

References coords_.

Member Data Documentation

◆ coords_

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

Definition at line 89 of file WeightedPoint.h.

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

◆ dim_

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

Definition at line 90 of file WeightedPoint.h.

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

◆ weight_

double MathLib::WeightedPoint::weight_
private

Definition at line 88 of file WeightedPoint.h.

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


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