PeIntersectionRatio.h 3.61 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
//======================================================================================================================
//
//  This file is part of waLBerla. waLBerla is free software: you can
//  redistribute it and/or modify it under the terms of the GNU General Public
//  License as published by the Free Software Foundation, either version 3 of
//  the License, or (at your option) any later version.
//
//  waLBerla is distributed in the hope that it will be useful, but WITHOUT
//  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
//  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
//  for more details.
//
//  You should have received a copy of the GNU General Public License along
//  with waLBerla (see COPYING.txt). If not, see <http://www.gnu.org/licenses/>.
//
//! \file PeIntersectionRatio.h
//! \ingroup pe_coupling
//! \author Christoph Rettinger <christoph.rettinger@fau.de>
//! \brief Specialization of the intersectionRatio function for certain pe bodies
//
//======================================================================================================================

#pragma once

#include "lbm/geometry/IntersectionRatio.h"
#include "pe_coupling/geometry/PeBodyOverlapFunctions.h"

#include "pe/rigidbody/RigidBody.h"
29
30
#include "pe/rigidbody/Ellipsoid.h"
#include "pe/rigidbody/Plane.h"
31
32
33
34
35
36
37
38
39
40
41
#include "pe/rigidbody/Sphere.h"
#include "pe/Types.h"


namespace walberla {
namespace lbm {

real_t intersectionRatioSpherePe( const pe::Sphere & sphere,
                                  const Vector3<real_t> & fluidPoint,
                                  const Vector3<real_t> & direction );

42
43
44
45
46
47
48
real_t intersectionRatioPlanePe( const pe::Plane & plane,
                                 const Vector3<real_t> & fluidPoint,
                                 const Vector3<real_t> & direction );

real_t intersectionRatioEllipsoidPe( const pe::Ellipsoid & ellipsoid,
                                     const Vector3<real_t> & fluidPoint,
                                     const Vector3<real_t> & direction );
49
50
51
52
53
54
55
56
57
58
59
60
61

inline real_t intersectionRatio( const pe::RigidBody & peRigidBody,
                                 const Vector3<real_t> & fluidPoint,
                                 const Vector3<real_t> & direction,
                                 const real_t epsilon )
{
   if( peRigidBody.getTypeID() == pe::Sphere::getStaticTypeID() )
   {
      const pe::Sphere & sphere = static_cast< const pe::Sphere & >( peRigidBody );
      const real_t ratio = intersectionRatioSpherePe( sphere, fluidPoint, direction );
      WALBERLA_ASSERT_LESS_EQUAL( std::fabs( ( fluidPoint + ratio * direction - sphere.getPosition() ).length() - sphere.getRadius() ), epsilon );
      return ratio;
   }
62
63
64
65
66
67
68
69
70
71
72
73
74
   else if ( peRigidBody.getTypeID() == pe::Plane::getStaticTypeID() )
   {
      const pe::Plane & plane = static_cast< const pe::Plane & >( peRigidBody );
      const real_t ratio = intersectionRatioPlanePe( plane, fluidPoint, direction );
      WALBERLA_ASSERT_FLOAT_EQUAL( ( fluidPoint + ratio * direction - plane.getPosition() ) * plane.getNormal(), real_t(0) );
      return ratio;
   }
   else if ( peRigidBody.getTypeID() == pe::Ellipsoid::getStaticTypeID() )
   {
      const pe::Ellipsoid & ellipsoid = static_cast< const pe::Ellipsoid & >( peRigidBody );
      const real_t ratio = intersectionRatioEllipsoidPe( ellipsoid, fluidPoint, direction );
      return ratio;
   }
75
76
77
78
79
80
81
82
83
84
   // Add more pe bodies here if specific intersectionRatio(...) function is available
   else
   {
      return lbm::intersectionRatio< pe::RigidBody >( peRigidBody, fluidPoint, direction, epsilon );
   }
}


} // namespace lbm
} // namespace walberla