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>
WeightedPoint (std::array< double, dim > const &coords, double const weight)

WeightedPoint (double const weight)
Constructs a 0D weighted point.

bool operator== (WeightedPoint const &other) const

bool operator!= (WeightedPoint const &other) const

const double * data () const

double getWeight () const

std::size_t getDimension () const
The point dimension, i.e., the number of its coordinates.

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_

## ◆ WeightedPoint() [1/2]

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

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

Definition at line 27 of file WeightedPoint.h.

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

References coords_.

## ◆ WeightedPoint() [2/2]

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

Constructs a 0D weighted point.

Definition at line 47 of file WeightedPoint.h.

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

References coords_.

## ◆ data()

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

Definition at line 78 of file WeightedPoint.h.

78{ return coords_.data(); }

References coords_.

## ◆ getDimension()

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

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

Definition at line 83 of file WeightedPoint.h.

83{ return dim_; }

References dim_.

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

## ◆ operator!=()

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

Definition at line 73 of file WeightedPoint.h.

74 {
75 return !(*this == other);
76 }

## ◆ operator==()

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

Definition at line 53 of file WeightedPoint.h.

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

References coords_, dim_, and weight_.

## ◆ operator[]()

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

Access a specific coordinate.

Definition at line 86 of file WeightedPoint.h.

87 {
88 return coords_[coord_idx];
89 }

References coords_.

## ◆ coords_

 std::array MathLib::WeightedPoint::coords_
private

Definition at line 93 of file WeightedPoint.h.

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

## ◆ dim_

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

Definition at line 94 of file WeightedPoint.h.

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

## ◆ weight_

 double MathLib::WeightedPoint::weight_
private

Definition at line 92 of file WeightedPoint.h.

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

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