Loading...
Searching...
No Matches
geo_element_contains.cc
Go to the documentation of this file.
// x in K ?
// where x is a point and K a geo_element
//
// TODO: omega.order == 1 only: not valid for curved elements
// ---------------------------------------------------------------------
#include "rheolef/geo_element_contains.h"
namespace rheolef { namespace details {
template <class T, class M>
bool
point_belongs_to_e (
const geo_element& K,
const disarray<point_basic<T>,M>& node,
const point_basic<T>& x)
{
const point_basic<T>& p0 = node.dis_at(K[0]);
const point_basic<T>& p1 = node.dis_at(K[1]);
return x[0] >= p0[0] && x[0] <= p1[0];
}
template <class T, class M>
bool
point_belongs_to_t (
const geo_element& K,
const disarray<point_basic<T>,M>& node,
const point_basic<T>& x)
{
static const T eps = 1e3*std::numeric_limits<T>::epsilon();
const point_basic<T>& p0 = node.dis_at(K[0]);
const point_basic<T>& p1 = node.dis_at(K[1]);
const point_basic<T>& p2 = node.dis_at(K[2]);
if (orient2d( x, p1, p2) < -eps) return false;
if (orient2d(p0, x, p2) < -eps) return false;
if (orient2d(p0, p1, x) < -eps) return false;
return true;
}
template <class T, class M>
bool
point_belongs_to_q (
const geo_element& K,
const disarray<point_basic<T>,M>& node,
const point_basic<T>& x)
{
static const T eps = 1e3*std::numeric_limits<T>::epsilon();
const point_basic<T>& p0 = node.dis_at(K[0]);
const point_basic<T>& p1 = node.dis_at(K[1]);
const point_basic<T>& p2 = node.dis_at(K[2]);
const point_basic<T>& p3 = node.dis_at(K[3]);
if (orient2d(x, p0, p1) < -eps) return false;
if (orient2d(x, p1, p2) < -eps) return false;
if (orient2d(x, p2, p3) < -eps) return false;
if (orient2d(x, p3, p0) < -eps) return false;
return true;
}
template <class T, class M>
bool
point_belongs_to_T (
const geo_element& K,
const disarray<point_basic<T>,M>& node,
const point_basic<T>& x)
{
static const T eps = 1e3*std::numeric_limits<T>::epsilon();
const point_basic<T>& p0 = node.dis_at(K[0]);
const point_basic<T>& p1 = node.dis_at(K[1]);
const point_basic<T>& p2 = node.dis_at(K[2]);
const point_basic<T>& p3 = node.dis_at(K[3]);
if (orient3d( x, p1, p2, p3) < -eps) return false;
if (orient3d(p0, x, p2, p3) < -eps) return false;
if (orient3d(p0, p1, x, p3) < -eps) return false;
if (orient3d(p0, p1, p2, x) < -eps) return false;
return true;
}
template <class T, class M>
bool
point_belongs_to_H (
const geo_element& K,
const disarray<point_basic<T>,M>& node,
const point_basic<T>& x)
{
typedef reference_element::size_type size_type;
static const T eps = 1e3*std::numeric_limits<T>::epsilon();
const point_basic<T>& p0 = node.dis_at(K[0]);
const point_basic<T>& p1 = node.dis_at(K[1]);
const point_basic<T>& p2 = node.dis_at(K[2]);
const point_basic<T>& p3 = node.dis_at(K[3]);
const point_basic<T>& p4 = node.dis_at(K[4]);
const point_basic<T>& p5 = node.dis_at(K[5]);
const point_basic<T>& p6 = node.dis_at(K[6]);
const point_basic<T>& p7 = node.dis_at(K[7]);
const point_basic<T>* q[8] = {&p0, &p1, &p2, &p3, &p4, &p5, &p6, &p7};
for (size_type loc_isid = 0, loc_nsid = 6; loc_isid < loc_nsid; loc_isid++) {
size_type j0 = reference_element_H::subgeo_local_node (1, 2, loc_isid, 0);
size_type j1 = reference_element_H::subgeo_local_node (1, 2, loc_isid, 1);
size_type j2 = reference_element_H::subgeo_local_node (1, 2, loc_isid, 2);
if (orient3d(x, *(q[j0]), *(q[j1]), *(q[j2])) < -eps) return false;
}
return true;
}
template <class T, class M>
bool
point_belongs_to_P (
const geo_element& K,
const disarray<point_basic<T>,M>& node,
const point_basic<T>& x)
{
typedef reference_element::size_type size_type;
static const T eps = 1e3*std::numeric_limits<T>::epsilon();
const point_basic<T>& p0 = node.dis_at(K[0]);
const point_basic<T>& p1 = node.dis_at(K[1]);
const point_basic<T>& p2 = node.dis_at(K[2]);
const point_basic<T>& p3 = node.dis_at(K[3]);
const point_basic<T>& p4 = node.dis_at(K[4]);
const point_basic<T>& p5 = node.dis_at(K[5]);
const point_basic<T>* q[6] = {&p0, &p1, &p2, &p3, &p4, &p5};
for (size_type loc_isid = 0, loc_nsid = 5; loc_isid < loc_nsid; loc_isid++) {
size_type j0 = reference_element_P::subgeo_local_node (1, 2, loc_isid, 0);
size_type j1 = reference_element_P::subgeo_local_node (1, 2, loc_isid, 1);
size_type j2 = reference_element_P::subgeo_local_node (1, 2, loc_isid, 2);
if (orient3d(x, *(q[j0]), *(q[j1]), *(q[j2])) < -eps) return false;
}
return true;
}
template <class T, class M>
bool
contains (
const geo_element& K,
const disarray<point_basic<T>,M>& node,
const point_basic<T>& x)
{
switch (K.variant()) {
case reference_element::e: return point_belongs_to_e (K, node, x);
case reference_element::t: return point_belongs_to_t (K, node, x);
case reference_element::q: return point_belongs_to_q (K, node, x);
case reference_element::T: return point_belongs_to_T (K, node, x);
case reference_element::P: return point_belongs_to_P (K, node, x);
case reference_element::H: return point_belongs_to_H (K, node, x);
default: error_macro ("unsupported element type '" << K.name() << "'"); return false;
}
}
// ----------------------------------------------------------------------------
// instanciation in library
// ----------------------------------------------------------------------------
#define _RHEOLEF_instanciation(T,M) \
template bool contains ( \
const geo_element& , \
const disarray<point_basic<T>,M>&, \
const point_basic<T>&);
_RHEOLEF_instanciation(Float,sequential)
#ifdef _RHEOLEF_HAVE_MPI
_RHEOLEF_instanciation(Float,distributed)
#endif // _RHEOLEF_HAVE_MPI
#undef _RHEOLEF_instanciation
}} // namespace rheolef::details
_RHEOLEF_instanciation
#define _RHEOLEF_instanciation(T, M, A)
Definition asr.cc:223
size_type
field::size_type size_type
Definition branch.cc:430
Float
see the Float page for the full documentation
rheolef::disarray
see the disarray page for the full documentation
Definition disarray.h:497
rheolef::geo_element
see the geo_element page for the full documentation
Definition geo_element.h:102
rheolef::geo_element::variant
variant_type variant() const
Definition geo_element.h:161
rheolef::geo_element::name
char name() const
Definition geo_element.h:169
rheolef::point_basic
Definition point.h:86
rheolef::reference_element_H::subgeo_local_node
static size_type subgeo_local_node(size_type order, size_type side_dim, size_type loc_isid, size_type loc_jsidnod)
Definition reference_element.cc:750
rheolef::reference_element_P::subgeo_local_node
static size_type subgeo_local_node(size_type order, size_type side_dim, size_type loc_isid, size_type loc_jsidnod)
Definition reference_element.cc:651
rheolef::reference_element::H
static const variant_type H
Definition reference_element.h:81
rheolef::reference_element::q
static const variant_type q
Definition reference_element.h:78
rheolef::reference_element::e
static const variant_type e
Definition reference_element.h:76
rheolef::reference_element::size_type
std::vector< int >::size_type size_type
Definition reference_element.h:71
rheolef::reference_element::T
static const variant_type T
Definition reference_element.h:79
rheolef::reference_element::P
static const variant_type P
Definition reference_element.h:80
rheolef::reference_element::t
static const variant_type t
Definition reference_element.h:77
error_macro
#define error_macro(message)
Definition dis_macros.h:49
T
Expr1::float_type T
Definition field_expr.h:230
rheolef::details::contains
bool contains(const geo_element &K, const disarray< point_basic< T >, M > &node, const point_basic< T > &x)
Definition geo_element_contains.cc:144
rheolef::details::point_belongs_to_t
bool point_belongs_to_t(const geo_element &K, const disarray< point_basic< T >, M > &node, const point_basic< T > &x)
Definition geo_element_contains.cc:42
rheolef::details::point_belongs_to_H
bool point_belongs_to_H(const geo_element &K, const disarray< point_basic< T >, M > &node, const point_basic< T > &x)
Definition geo_element_contains.cc:94
rheolef::details::point_belongs_to_q
bool point_belongs_to_q(const geo_element &K, const disarray< point_basic< T >, M > &node, const point_basic< T > &x)
Definition geo_element_contains.cc:58
rheolef::details::point_belongs_to_T
bool point_belongs_to_T(const geo_element &K, const disarray< point_basic< T >, M > &node, const point_basic< T > &x)
Definition geo_element_contains.cc:76
rheolef::details::point_belongs_to_P
bool point_belongs_to_P(const geo_element &K, const disarray< point_basic< T >, M > &node, const point_basic< T > &x)
Definition geo_element_contains.cc:120
rheolef::details::point_belongs_to_e
bool point_belongs_to_e(const geo_element &K, const disarray< point_basic< T >, M > &node, const point_basic< T > &x)
Definition geo_element_contains.cc:31
rheolef
This file is part of Rheolef.
Definition compiler_eigen.h:39
rheolef::orient2d
T orient2d(const point_basic< T > &a, const point_basic< T > &b, const point_basic< T > &c)
Definition point_predicate.cc:107
rheolef::orient3d
T orient3d(const point_basic< T > &a, const point_basic< T > &b, const point_basic< T > &c, const point_basic< T > &d)
Definition point_predicate.cc:124
M
Expr1::memory_type M
Definition vec_expr_v2.h:416