Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
speeds.h
Go to the documentation of this file.
1 /* *******************************************************************
2  * Rocstar Simulation Suite *
3  * Copyright@2015, Illinois Rocstar LLC. All rights reserved. *
4  * *
5  * Illinois Rocstar LLC *
6  * Champaign, IL *
7  * www.illinoisrocstar.com *
8  * sales@illinoisrocstar.com *
9  * *
10  * License: See LICENSE file in top level of distribution package or *
11  * http://opensource.org/licenses/NCSA *
12  *********************************************************************/
13 /* *******************************************************************
14  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
15  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
16  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
17  * NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
18  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
20  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
21  * USE OR OTHER DEALINGS WITH THE SOFTWARE. *
22  *********************************************************************/
23 // $Id: speeds.h,v 1.6 2008/12/06 08:45:28 mtcampbe Exp $
24 
25 #ifndef _SPEEDS_H_
26 #define _SPEEDS_H_
27 
28 #include "propbasic.h"
29 
31 
32 class Speed {
33 public:
34  Speed() {}
35  virtual ~Speed() {}
36 
37  // Obtain the velocity (vector) at a given point.
38  // The appropriate functions must be defined by the sub-class, or a
39  // runtime error (assertion failure) will occur.
40  virtual Vector_3 get_velocity( const Point_3 &p, double t) const
41  { assert(false); return Vector_3(0,0,0); }
42 };
43 
44 // Define translation speed.
45 class Translate_speed : public Speed {
46 public:
47  explicit Translate_speed( double s, bool b=false) : _spd(s) {}
48  virtual ~Translate_speed() {}
49 
50  Vector_3 get_velocity( const Point_3 &, double t) const
51  { return Vector_3(_spd,0,0); }
52 
53 protected:
54  const double _spd;
55 };
56 
57 // Define rotation speed with z=0.
58 class Rotate_speed : public Speed {
59 public:
60  explicit Rotate_speed() {}
61  virtual ~Rotate_speed() {}
62 
63  Vector_3 get_velocity( const Point_3 &pnt, double t) const {
64 
65  return Vector_3(-pnt[1], pnt[0], 0);
66  }
67 };
68 
69 class Vortex_flow : public Speed {
70 public:
71  // T is the reversal time
72  explicit Vortex_flow( double T=2) : _t(T>0?T:2) {}
73  virtual ~Vortex_flow() {}
74 
75  Vector_3 get_velocity( const Point_3 &p, double t) const {
76  const double pi = 3.14159265358979;
77 
78  Vector_3 v;
79  v[0] = square(std::sin(pi*p[0]))*(std::sin(2*pi*p[2])-std::sin(2*pi*p[1]));
80  v[1] = square(std::sin(pi*p[1]))*(std::sin(2*pi*p[0])-std::sin(2*pi*p[2]));
81  v[2] = square(std::sin(pi*p[2]))*(std::sin(2*pi*p[1])-std::sin(2*pi*p[0]));
82 
83  double s;
84  if ( _t<0) s = std::cos(pi*(0.5-t/_t));
85  else s = std::cos(pi*t/_t);
86 
87  return (v *= s);
88  }
89 
90 protected:
91  double square( double x) const { return x*x; }
92  double _t;
93 };
94 
95 class LeVeque_flow : public Speed {
96 public:
97  // T is the reversal time
98  explicit LeVeque_flow( double T=3) : _t(T) {}
99  virtual ~LeVeque_flow() {}
100 
101  Vector_3 get_velocity( const Point_3 &p, double t) const {
102  const double pi = 3.14159265358979;
103 
104  Vector_3 v;
105  v[0] = 2*square(std::sin(pi*p[0]))*std::sin(2*pi*p[1])*std::sin(2*pi*p[2]);
106  v[1] = -std::sin(2*pi*p[0])*square(std::sin(pi*p[1]))*std::sin(2*pi*p[2]);
107  v[2] = -std::sin(2*pi*p[0])*std::sin(2*pi*p[1])*square(std::sin(pi*p[2]));
108 
109  double s;
110  if ( _t<0) s = std::cos(pi*(0.5-t/_t));
111  else s = std::cos(pi*t/_t);
112 
113  return (v *= s);
114  }
115 
116 protected:
117  double square( double x) const { return x*x; }
118  double _t;
119 };
120 
121 
123 
124 #endif // _SPPEDS_H_
125 
126 
127 
128 
129 
130 
#define PROP_END_NAMESPACE
Definition: propbasic.h:29
Rotate_speed()
Definition: speeds.h:60
#define PROP_BEGIN_NAMESPACE
Definition: propbasic.h:28
double s
Definition: blastest.C:80
double _t
Definition: speeds.h:92
virtual ~Speed()
Definition: speeds.h:35
SURF::Vector_3< Real > Vector_3
Definition: rfc_basic.h:42
virtual ~LeVeque_flow()
Definition: speeds.h:99
double square(double x) const
Definition: speeds.h:117
Definition: speeds.h:32
*********************************************************************Illinois Open Source License ****University of Illinois NCSA **Open Source License University of Illinois All rights reserved ****Developed free of to any person **obtaining a copy of this software and associated documentation to deal with the Software without including without limitation the rights to and or **sell copies of the and to permit persons to whom the **Software is furnished to do subject to the following this list of conditions and the following disclaimers ****Redistributions in binary form must reproduce the above **copyright this list of conditions and the following **disclaimers in the documentation and or other materials **provided with the distribution ****Neither the names of the Center for Simulation of Advanced the University of nor the names of its **contributors may be used to endorse or promote products derived **from this Software without specific prior written permission ****THE SOFTWARE IS PROVIDED AS WITHOUT WARRANTY OF ANY **EXPRESS OR INCLUDING BUT NOT LIMITED TO THE WARRANTIES **OF FITNESS FOR A PARTICULAR PURPOSE AND **NONINFRINGEMENT IN NO EVENT SHALL THE CONTRIBUTORS OR **COPYRIGHT HOLDERS BE LIABLE FOR ANY DAMAGES OR OTHER WHETHER IN AN ACTION OF TORT OR **ARISING OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE **USE OR OTHER DEALINGS WITH THE SOFTWARE v
Definition: roccomf90.h:20
Point object that represents a single point.
Definition: datatypedef.h:68
Vector_3 get_velocity(const Point_3 &, double t) const
Definition: speeds.h:50
NT & sin
virtual Vector_3 get_velocity(const Point_3 &p, double t) const
Definition: speeds.h:40
void int int REAL * x
Definition: read.cpp:74
Speed()
Definition: speeds.h:34
const double _spd
Definition: speeds.h:54
Vector_3 get_velocity(const Point_3 &pnt, double t) const
Definition: speeds.h:63
double square(double x) const
Definition: speeds.h:91
virtual ~Translate_speed()
Definition: speeds.h:48
virtual ~Vortex_flow()
Definition: speeds.h:73
Translate_speed(double s, bool b=false)
Definition: speeds.h:47
LeVeque_flow(double T=3)
Definition: speeds.h:98
virtual ~Rotate_speed()
Definition: speeds.h:61
const double pi
Vector_3 get_velocity(const Point_3 &p, double t) const
Definition: speeds.h:75
Vector_3 get_velocity(const Point_3 &p, double t) const
Definition: speeds.h:101
Some basic geometric data types.
Definition: mapbasic.h:54
Vortex_flow(double T=2)
Definition: speeds.h:72
double _t
Definition: speeds.h:118
NT & cos