Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PointPropagate.C
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: PointPropagate.C,v 1.4 2008/12/06 08:45:28 mtcampbe Exp $
24 
25 #include "PointPropagate.h"
26 #include "../Rocsurf/include/Generic_element_2.h"
27 
29 
30 // Perform time integration at a specific point.
32 time_integrate( const Point_3 &p, const Speed &s,
33  double t, double dt, int order) {
34  Vector_3 disp1 = dt*s.get_velocity( p, t);
35 
36  // If first order, using Euler's method
37  if ( order <= 1) { return disp1; }
38 
39  // Otherwise, use fourth-order Runge-Kutta.
40  Vector_3 disp2 = dt*s.get_velocity( p+0.5*disp1, t+0.5*dt);
41  Vector_3 disp3 = dt*s.get_velocity( p+0.5*disp2, t+0.5*dt);
42  Vector_3 disp4 = dt*s.get_velocity( p+disp3, t+dt);
43 
44  return (disp1+disp4)/6+(disp2+disp3)/3;
45 }
46 
47 // Propagate the Gauss points of a given element.
49 propagate_gp_of_element(const Point_3 *pnts, COM::Element_node_enumerator &ene,
50  const Speed &s, double t, double dt, Vector_3 *disps) {
51 
52  // Only support triangular elements now
53  COM_assertion( ene.size_of_edges()==3);
54 
55  // Evaluate current face normal
56  COM::Element_node_vectors_k_const<Point_3> ps; ps.set( pnts, ene, 1);
57  SURF::Generic_element_2 e(ene.size_of_edges(), ene.size_of_nodes());
58 
59  // Look through the Gauss points and compute their displacements.
60  for ( int i=0; i<3; ++i) {
61  // Obtain the positions of the Gauss point
62  Vector_2 nc; e.get_gp_nat_coor( i, nc, 2);
63  Point_3 p; e.interpolate( ps, nc, &p);
64 
65  // Obtain the displacement at the Gauss point using 4th order RK
66  disps[ i] = time_integrate( p, s, t, dt, 4);
67  }
68 }
69 
70 // Propagate the Gauss points of all faces of a given mesh
72 propagate_faces( const std::string &wname, const Speed &s,
73  double t, double dt, const std::string &vname) {
74  COM::Window *win = COM_get_roccom()->get_window_object(wname);
75  COM::Attribute *velos = win->attribute( vname);
76 
77  COM_assertion_msg( velos->is_elemental() && velos->size_of_components()==9,
78  "Velos must be elemental data associated with quadrature points");
79 
80  // Loop through all the panes and then all the faces
81  std::vector<COM::Pane*> panes; win->panes( panes);
82 
83  // Loop through the panes and its real faces
84  std::vector< COM::Pane*>::iterator it = panes.begin();
85  for ( int i=0, local_npanes = panes.size(); i<local_npanes; ++i, ++it) {
86  COM::Pane *pane = *it;
87  const Point_3 *pnts = reinterpret_cast<Point_3*>(pane->coordinates());
88  Vector_3 *velos_ptr = reinterpret_cast<Vector_3*>
89  (pane->attribute( velos->id())->pointer());
90 
91  // Loop through real elements of the current pane
92  COM::Element_node_enumerator ene( pane, 1);
93  for ( int j=0, nj=pane->size_of_real_elements(); j<nj; ++j, ene.next()) {
94  // First compute the displacements at Gauss points using high-order
95  // time integration
96  propagate_gp_of_element( pnts, ene, s, t, dt, &velos_ptr[3*j]);
97 
98  // Convert displacements into velocities by dividing by time step.
99  velos_ptr[3*j] /= dt; velos_ptr[3*j+1] /= dt; velos_ptr[3*j+2] /= dt;
100  }
101  }
102 }
103 
104 // Propagate the nodes of a given mesh
105 void PointPropagate::
106 propagate_nodes( const std::string &wname, const Speed &s,
107  double t, double dt, const std::string &vname) {
108  COM::Window *win = COM_get_roccom()->get_window_object(wname);
109  COM::Attribute *velos = win->attribute( vname);
110 
111  COM_assertion_msg( velos->is_nodal() && velos->size_of_components()==3,
112  "Velos must be nodal data associated");
113 
114  double a = 1./dt;
115 
116  // Loop through all the panes and then all the vertices
117  std::vector<COM::Pane*> panes; win->panes( panes);
118 
119  std::vector< COM::Pane*>::iterator it = panes.begin();
120  for ( int i=0, local_npanes = panes.size(); i<local_npanes; ++i, ++it) {
121  COM::Pane *pane = *it;
122  const Point_3 *pnts = reinterpret_cast<Point_3*>(pane->coordinates());
123  Vector_3 *velos_ptr = reinterpret_cast<Vector_3*>
124  (pane->attribute( velos->id())->pointer());
125 
126  // Loop through real vertices of the current pane
127  for ( int j=0, nj=pane->size_of_real_nodes(); j<nj; ++j) {
128  velos_ptr[j] = a*time_integrate( pnts[j], s, t, dt, 4);
129  }
130  }
131 }
132 
134 
135 
136 
137 
138 
139 
#define COM_assertion(EX)
Error checking utility similar to the assert macro of the C language.
#define PROP_END_NAMESPACE
Definition: propbasic.h:29
static void propagate_faces(const std::string &wname, const Speed &s, double t, double dt, const std::string &vname)
#define PROP_BEGIN_NAMESPACE
Definition: propbasic.h:28
#define COM_assertion_msg(EX, msg)
double s
Definition: blastest.C:80
Definition: speeds.h:32
static void propagate_gp_of_element(const Point_3 *pnts, COM::Element_node_enumerator &ene, const Speed &s, double t, double dt, Vector_3 *qp_vels)
blockLoc i
Definition: read.cpp:79
virtual Vector_3 get_velocity(const Point_3 &p, double t) const
Definition: speeds.h:40
static void propagate_nodes(const std::string &wname, const Speed &s, double t, double dt, const std::string &vname)
j indices j
Definition: Indexing.h:6
void int * nj
Definition: read.cpp:74
Some basic geometric data types.
Definition: mapbasic.h:54
COM_END_NAME_SPACE COM::Roccom_base * COM_get_roccom()
Definition: Roccom_base.h:537
static Vector_3 time_integrate(const Point_3 &p, const Speed &s, double t, double dt, int order)