Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
cons_diff.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: cons_diff.C,v 1.4 2008/12/06 08:45:28 mtcampbe Exp $
24 
25 #include "FaceOffset_3.h"
26 #include "../Rocblas/include/Rocblas.h"
27 #include "../Rocsurf/include/Generic_element_2.h"
28 #include "../Rocsurf/include/Rocsurf.h"
29 
31 
32 void FaceOffset_3::
34  COM::Attribute *disps =
35  _buf->new_attribute( "disps_buf_bm", 'n', COM_DOUBLE, 3, "");
36  _buf->resize_array( disps, 0);
37  COM::Attribute *pos =
38  _buf->new_attribute( "pos_buf_bm", 'n', COM_DOUBLE, 3, "");
39  _buf->resize_array( pos, 0);
40  COM::Attribute *fvol_buf =
41  _buf->new_attribute( "vfol_buf_bm", 'e', COM_DOUBLE, 1, "");
42  _buf->resize_array( fvol_buf, 0);
43  _buf->init_done( false);
44 
45  // Use face-area as buffer for facial-volume
46  COM::Attribute *fvol = _faceareas;
47 
48  // Compute volume change at each vertex.
49  const COM::Attribute *coors = _buf->attribute( COM::COM_NC);
50  Rocblas::add( coors, _vcenters, pos);
51 
52  // Obtain density-vector for vertices.
53  int normalize=false;
54  SURF::Rocsurf::compute_element_normals( _facenormals, &normalize, pos);
55  _surf->elements_to_nodes( _facenormals, disps, SURF::E2N_ONE, NULL, NULL, 1);
56 
57  // Use _scales for vortex area and _weights for vertex-volume.
58  Rocblas::dot( disps, _vnormals, _scales);
59  double zero=0;
60  Rocblas::copy_scalar( &zero, disps);
61 
62  for ( int k=0;k<2;++k) {
63  if ( k) {
64  SURF::Rocsurf::compute_swept_volumes( pos, disps, fvol);
65 
66  Rocblas::sub( fvol_buf, fvol, fvol);
67  }
68  else {
69  SURF::Rocsurf::compute_bounded_volumes( pos, coors, fvol);
70  Rocblas::copy( fvol, fvol_buf);
71  }
73 
74 
75  std::vector< COM::Pane*>::iterator it = _panes.begin();
76  // Loop through the panes and its real vertices
77  for (int i=0, local_npanes = _panes.size(); i<local_npanes; ++i, ++it) {
78  COM::Pane *pane = *it;
79 
80  const double *vs = reinterpret_cast<const double*>
81  ( pane->attribute(_weights->id())->pointer());
82  const double *as = reinterpret_cast<const double*>
83  ( pane->attribute(_scales->id())->pointer());
84  const Vector_3 *ds_m = reinterpret_cast<const Vector_3*>
85  ( pane->attribute(_vnormals->id())->pointer());
86  Vector_3 *ds = reinterpret_cast<Vector_3*>
87  ( pane->attribute(disps->id())->pointer());
88 
89  // Loop through all real nodes of the pane
90  for ( int j=0, jn=pane->size_of_real_nodes(); j<jn; ++j) {
91  ds[j] += vs[j]/as[j]*ds_m[j]; // Omit the factor 3 here
92  }
93  }
94  }
95 
97 
98  _buf->delete_attribute( fvol_buf->name());
99  _buf->delete_attribute( pos->name());
100  _buf->delete_attribute( disps->name());
101  _buf->init_done( false);
102 }
103 
104 void FaceOffset_3::
105 distribute_volume_e2n( const COM::Attribute *fvol,
106  const COM::Attribute *tranks,
107  COM::Attribute *vvol) {
108 
109  double zero=0;
110  Rocblas::copy_scalar( &zero, vvol);
111 
112  // Loop through the panes and its real faces
113  std::vector< COM::Pane*>::iterator it = _panes.begin();
114  Manifold::PM_iterator pm_it=_surf->pm_begin();
115  for ( int i=0, local_npanes = _panes.size();
116  i<local_npanes; ++i, ++it, ++pm_it) {
117  COM::Pane *pane = *it;
118 
119  const double *fv = reinterpret_cast<const double*>
120  ( pane->attribute(fvol->id())->pointer());
121  double *vv = reinterpret_cast<double*>
122  ( pane->attribute(vvol->id())->pointer());
123 
124  // Loop through real elements of the current pane
125  Element_node_enumerator ene( pane, 1);
126  for ( int j=0, nj=pane->size_of_real_elements(); j<nj; ++j, ene.next()) {
127  int ne = ene.size_of_edges();
128 
129  for (int k=0; k<ne; ++k) {
130  int index = ene[k]-1;
131  vv[index] += fv[j]; // Omit the factor 1/3 here
132  }
133  }
134  }
135 
136  // Reduce on shared nodes
137  _surf->reduce_on_shared_nodes( vvol, Manifold::OP_SUM);
138 
139 }
140 
142 
143 
144 
145 
146 
147 
COM::Attribute * _scales
Definition: FaceOffset_3.h:424
static void sub(const Attribute *x, const Attribute *y, Attribute *z)
Operation wrapper for subtraction.
Definition: op3args.C:237
COM::Window * _buf
An adaptor for enumerating node IDs of an element.
#define PROP_END_NAMESPACE
Definition: propbasic.h:29
j indices k indices k
Definition: Indexing.h:6
#define PROP_BEGIN_NAMESPACE
Definition: propbasic.h:28
COM::Attribute * _vcenters
Definition: FaceOffset_3.h:415
COM::Attribute * _faceareas
Definition: FaceOffset_3.h:414
COM::Attribute * _tangranks
Definition: FaceOffset_3.h:417
std::vector< COM::Pane * > _panes
static void add(const Attribute *x, const Attribute *y, Attribute *z)
Operation wrapper for addition.
Definition: op3args.C:221
void distribute_volume_e2n(const COM::Attribute *fvol, const COM::Attribute *tranks, COM::Attribute *vvol)
Definition: cons_diff.C:105
int size_of_edges() const
Number of edges per element.
blockLoc i
Definition: read.cpp:79
Manifold * _surf
COM::Attribute * _weights
Definition: FaceOffset_3.h:425
static void copy_scalar(const void *x, Attribute *y)
Operation wrapper for copy (x is a scalar pointer).
Definition: op2args.C:583
j indices j
Definition: Indexing.h:6
static void copy(const Attribute *x, Attribute *y)
Wrapper for copy.
Definition: op2args.C:333
COM::Attribute * _vnormals
Definition: FaceOffset_3.h:410
void next()
Go to the next element within the connectivity tables of a pane.
void int * nj
Definition: read.cpp:74
Some basic geometric data types.
Definition: mapbasic.h:54
void balance_mass()
Definition: cons_diff.C:33
static void dot(const Attribute *x, const Attribute *y, Attribute *z, const Attribute *mults=NULL)
Wrapper for dot product.
Definition: dots.C:279
COM::Attribute * _facenormals
Definition: FaceOffset_3.h:412