16 #ifndef dealii_point_h
17 #define dealii_point_h
25 #include <boost/geometry/core/cs.hpp>
26 #include <boost/geometry/geometries/point.hpp>
107 template <
int dim,
typename Number =
double>
148 Point(
const Number x,
const Number y);
160 Point(
const Number x,
const Number y,
const Number z);
165 template <std::size_t dummy_dim,
166 std::enable_if_t<(dim == dummy_dim) && (dummy_dim != 0),
int> = 0>
167 Point(
const boost::geometry::model::
168 point<Number, dummy_dim, boost::geometry::cs::cartesian> &boost_pt);
201 template <
typename OtherNumber>
265 template <
typename OtherNumber>
277 template <
typename OtherNumber>
335 template <
class Archive>
346 template <
int dim,
typename Number>
353 template <
int dim,
typename Number>
356 const
Tensor<1, dim, Number> &t)
357 :
Tensor<1, dim, Number>(t)
362 template <
int dim,
typename Number>
368 "You can only initialize Point<1> objects using the constructor "
369 "that takes only one argument. Point<dim> objects with dim!=1 "
370 "require initialization with the constructor that takes 'dim' "
388 template <
int dim,
typename Number>
395 "You can only initialize Point<2> objects using the constructor "
396 "that takes two arguments. Point<dim> objects with dim!=2 "
397 "require initialization with the constructor that takes 'dim' "
403 constexpr
unsigned int y_index = (dim < 2) ? 0 : 1;
405 this->
values[y_index] = y;
410 template <
int dim,
typename Number>
418 "You can only initialize Point<3> objects using the constructor "
419 "that takes three arguments. Point<dim> objects with dim!=3 "
420 "require initialization with the constructor that takes 'dim' "
426 constexpr
unsigned int y_index = (dim < 2) ? 0 : 1;
427 constexpr
unsigned int z_index = (dim < 3) ? 0 : 2;
429 this->
values[y_index] = y;
430 this->
values[z_index] = z;
435 template <
int dim,
typename Number>
437 template <std::
size_t dummy_dim,
438 std::enable_if_t<(dim == dummy_dim) && (dummy_dim != 0),
int>>
440 const
boost::geometry::model::
444 this->
values[0] = boost::geometry::get<0>(boost_pt);
445 constexpr
unsigned int y_index = (dim < 2) ? 0 : 1;
446 constexpr
unsigned int z_index = (dim < 3) ? 0 : 2;
449 this->
values[y_index] = boost::geometry::get<y_index>(boost_pt);
452 this->
values[z_index] = boost::geometry::get<z_index>(boost_pt);
457 template <
int dim,
typename Number>
468 template <
int dim,
typename Number>
471 const
unsigned int index)
const
474 return this->
values[index];
479 template <
int dim,
typename Number>
482 const
unsigned int index)
485 return this->
values[index];
490 template <
int dim,
typename Number>
492 template <typename OtherNumber>
494 const
Tensor<1, dim, OtherNumber> &p)
502 template <
int dim,
typename Number>
505 const
Tensor<1, dim, Number> &p)
const
514 template <
int dim,
typename Number>
517 const
Point<dim, Number> &p)
const
524 template <
int dim,
typename Number>
527 const
Tensor<1, dim, Number> &p)
const
536 template <
int dim,
typename Number>
542 for (
unsigned int i = 0; i < dim; ++i)
543 result.
values[i] = -this->values[i];
549 template <
int dim,
typename Number>
551 template <typename OtherNumber>
555 type>
Point<dim, Number>::operator*(const OtherNumber factor)
const
558 for (
unsigned int i = 0; i < dim; ++i)
559 tmp[i] = this->
operator[](i) * factor;
565 template <
int dim,
typename Number>
567 template <typename OtherNumber>
571 type>
Point<dim, Number>::operator/(const OtherNumber factor)
const
578 ::operator/(base_object, factor));
583 template <
int dim,
typename Number>
586 const
Tensor<1, dim, Number> &p)
const
588 Number res = Number();
589 for (
unsigned int i = 0; i < dim; ++i)
590 res += this->
operator[](i) * p[i];
595 template <
int dim,
typename Number>
598 Point<dim, Number>::square()
const
600 return this->norm_square();
605 template <
int dim,
typename Number>
608 Point<dim, Number>::distance(const
Point<dim, Number> &p)
const
615 template <
int dim,
typename Number>
618 Point<dim, Number>::distance_square(const
Point<dim, Number> &p)
const
621 for (
unsigned int i = 0; i < dim; ++i)
623 const Number diff =
static_cast<Number
>(this->
values[i]) - p(i);
632 template <
int dim,
typename Number>
634 template <class Archive>
635 inline
void Point<dim, Number>::serialize(Archive &ar, const
unsigned int)
655 template <
int dim,
typename Number,
typename OtherNumber>
672 template <
int dim,
typename Number>
674 inline std::ostream &
675 operator<<(std::ostream &out, const
Point<dim, Number> &p)
677 for (
unsigned int i = 0; i < dim - 1; ++i)
690 template <
int dim,
typename Number>
692 inline std::istream &
693 operator>>(std::istream &in,
Point<dim, Number> &p)
695 for (
unsigned int i = 0; i < dim; ++i)
709 template <
typename Number>
710 inline std::ostream &
OutputOperator< VectorType > & operator<<(OutputOperator< VectorType > &out, unsigned int step)
numbers::NumberTraits< Number >::real_type distance_square(const Point< dim, Number > &p) const
Point< dim, typename ProductType< Number, typename EnableIfScalar< OtherNumber >::type >::type > operator/(const OtherNumber) const
Tensor< 1, dim, Number > operator-(const Point< dim, Number > &) const
Point< dim, typename ProductType< Number, typename EnableIfScalar< OtherNumber >::type >::type > operator*(const OtherNumber) const
Number operator*(const Tensor< 1, dim, Number > &p) const
Number & operator()(const unsigned int index)
numbers::NumberTraits< Number >::real_type distance(const Point< dim, Number > &p) const
Point(const boost::geometry::model::point< Number, dummy_dim, boost::geometry::cs::cartesian > &boost_pt)
Point(const Tensor< 1, dim, Number > &)
Point(const Number x, const Number y, const Number z)
Point< dim, Number > & operator=(const Tensor< 1, dim, OtherNumber > &p)
Point< dim, Number > operator-(const Tensor< 1, dim, Number > &) const
void serialize(Archive &ar, const unsigned int version)
numbers::NumberTraits< Number >::real_type square() const
Point< dim, Number > operator-() const
Point< dim, Number > operator+(const Tensor< 1, dim, Number > &) const
Point(const Number x, const Number y)
static Point< dim, Number > unit_vector(const unsigned int i)
Number operator()(const unsigned int index) const
Point< dim, typename ProductType< Number, typename EnableIfScalar< OtherNumber >::type >::type > operator*(const OtherNumber factor, const Point< dim, Number > &p)
SymmetricTensor< rank, dim, Number > sum(const SymmetricTensor< rank, dim, Number > &local, const MPI_Comm &mpi_communicator)
constexpr Tensor & operator=(const Tensor< rank_, dim, OtherNumber > &rhs)
Tensor< rank_ - 1, dim, Number > values[(dim !=0) ? dim :1]
#define DEAL_II_ALWAYS_INLINE
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_CXX20_REQUIRES(condition)
#define DEAL_II_NAMESPACE_CLOSE
#define Assert(cond, exc)
static ::ExceptionBase & ExcNotImplemented()
#define AssertIndexRange(index, range)
static ::ExceptionBase & ExcMessage(std::string arg1)
Point< spacedim > point(const gp_Pnt &p, const double tolerance=1e-10)
#define DEAL_II_HOST_DEVICE
::VectorizedArray< Number, width > sqrt(const ::VectorizedArray< Number, width > &)
static constexpr DEAL_II_HOST_DEVICE_ALWAYS_INLINE const T & value(const T &t)
static constexpr real_type abs_square(const number &x)