Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MarkerParticles_3.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: MarkerParticles_3.C,v 1.8 2008/12/06 08:45:27 mtcampbe Exp $
24 
25 #include "MarkerParticles_3.h"
26 #include "../Rocblas/include/Rocblas.h"
27 
29 
30 double
31 MarkerParticles_3::time_stepping( const COM::Attribute *spd, double dt,
32  COM::Attribute *disp, int *smoothed) {
33  COM_assertion( spd->size_of_components()==1);
34  COM_assertion( disp->size_of_components()==3 && disp->is_nodal());
35 
36  multiply_nodal_normals( spd, disp);
37  Rocblas::mul_scalar( disp, &dt, disp);
38 
39  if ( smoothed) *smoothed = false;
40  return dt;
41 }
42 
43 // Multiply attribute speed by nodal normals and save into attribute disp
44 void
45 MarkerParticles_3::multiply_nodal_normals( const COM::Attribute *spd,
46  COM::Attribute *disp) {
47  assert( spd->size_of_components()==1);
48 
49  if ( spd->is_nodal()) {
50  // compute normals
51  _surf->compute_normals( disp);
52 
53  // If spd is not elemental, simply need call Rocblas
54  Rocblas::mul( disp, spd, disp);
55  }
56  else {
57  // Create a buffer window to store the element normals
58  COM::Window *win = disp->window();
59  COM::Window buf( win->name()+"-marker", win->get_communicator());
60  buf.inherit( win->attribute( COM::COM_MESH), "", false, true, NULL, 0);
61  Attribute *node_disps = buf.inherit( disp, "disps", false, true, NULL, 0);
62  buf.inherit(const_cast<COM::Attribute*>(spd), "spd", false, true, NULL, 0);
63  Attribute *elem_normals =
64  buf.new_attribute( "elem_normals", 'e', COM_DOUBLE, 3, "");
65  buf.resize_array( "elem_normals", 0, NULL);
66  buf.init_done();
67 
68  // First, compute elemental normals
69  _surf->compute_normals( elem_normals);
70 
71  // Multiply elemental normals by speed
72  Rocblas::mul( elem_normals, spd, elem_normals);
73 
74  // Convert elemental motion to nodal motion
75  _surf->elements_to_nodes( elem_normals, node_disps, SURF::E2N_ANGLE);
76  }
77 }
78 
79 
81 
82 
83 
84 
85 
86 
void inherit(Attribute *a, bool clone, bool withghost, int depth=0)
Inherit from parent. If depth&gt;0, then the procedure is for the subcomponents.
Definition: Attribute.C:426
#define COM_assertion(EX)
Error checking utility similar to the assert macro of the C language.
#define PROP_END_NAMESPACE
Definition: propbasic.h:29
An Attribute object is a data member of a window.
Definition: Attribute.h:51
#define PROP_BEGIN_NAMESPACE
Definition: propbasic.h:28
static void mul_scalar(const Attribute *x, const void *y, Attribute *z, int swap=0)
Operation wrapper for multiplication with y as a scalar pointer.
Definition: op3args.C:347
Manifold * _surf
void multiply_nodal_normals(const COM::Attribute *a, COM::Attribute *b)
virtual double time_stepping(const COM::Attribute *spd, double dt, COM::Attribute *disp, int *smoothed=NULL)
Main entry of the algorithm.
static void mul(const Attribute *x, const Attribute *y, Attribute *z)
Operation wrapper for multiplication.
Definition: op3args.C:253