ENH: supplementary vector comparison methods

- background: for some application it can be useful to have fully
  sorted points. i.e., sorted by x, followed by y, followed by z.

  The default VectorSpace 'operator<' compares *all*
  components. This is seen by the following comparisons

  1.  a = (-2.2 -3.3 -4.4)
      b = (-1.1 -2.2 3.3)

      (a < b) : True
      Each 'a' component is less than each 'b' component

  2.  a = (-2.2 -3.3 -4.4)
      b = (-2.2 3.3 4.4)

      (a < b) : False
      The a.x() is not less than b.x()

  The static definitions 'less_xyz', 'less_yzx', 'less_zxy'
  instead use comparison of the next components as tie breakers
  (like a lexicographic sort).
  - same type of definition that Pair and Tuple2 use.

      a = (-2.2 -3.3 -4.4)
      b = (-2.2 3.3 4.4)

      vector::less_xyz(a, b) : True
      The a.x() == b.x(), but a.y() < b.y()

   They can be used directly as comparators:

      pointField points = ...;

      std::sort(points.begin(), points.end(), vector::less_zxy);

ENH: make VectorSpace named access methods noexcept.

   Since the addressing range is restricted to enumerated offsets
   (eg, X/Y/Z) into storage, always remains in-range.
   Possible to make constexpr with future C++ versions.

STYLE: VectorSpace 'operator>' defined using 'operator<'

- standard rewriting rule
This commit is contained in:
Mark Olesen
2022-10-17 10:41:05 +02:00
parent 371795840c
commit c973066646
50 changed files with 475 additions and 1352 deletions

View File

@ -135,14 +135,14 @@ Foam::Polynomial<PolySize>::Polynomial(const word& name, Istream& is)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
template<int PolySize>
bool Foam::Polynomial<PolySize>::logActive() const
bool Foam::Polynomial<PolySize>::logActive() const noexcept
{
return logActive_;
}
template<int PolySize>
Foam::scalar Foam::Polynomial<PolySize>::logCoeff() const
Foam::scalar Foam::Polynomial<PolySize>::logCoeff() const noexcept
{
return logCoeff_;
}

View File

@ -50,8 +50,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef Polynomial_H
#define Polynomial_H
#ifndef Foam_Polynomial_H
#define Foam_Polynomial_H
#include "word.H"
#include "scalar.H"
@ -125,10 +125,10 @@ public:
// Access
//- Return true if the log term is active
bool logActive() const;
bool logActive() const noexcept;
//- Return the log coefficient
scalar logCoeff() const;
scalar logCoeff() const noexcept;
// Evaluation