Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
compute_element_normals.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: compute_element_normals.C,v 1.4 2008/12/06 08:43:23 mtcampbe Exp $
24 
25 #include "Rocsurf.h"
26 #include "roccom_devel.h"
27 #include "Generic_element_2.h"
28 #include <vector>
29 
31 
32 void Rocsurf::compute_element_normals( COM::Attribute *elem_nrmls,
33  const int *to_normalize,
34  const COM::Attribute *pnts) {
35 
36  assert( elem_nrmls != NULL && elem_nrmls ->size_of_components() == 3);
37 
38  std::vector< COM:: Pane*> panes;
39  elem_nrmls->window() -> panes( panes);
41 
42  Vector_2<Real> nc(0.5,0.5);
43  Vector_3<Real> J[2];
44 
45  std::vector< COM::Pane*>::const_iterator it = panes.begin();
46 
47  for (int i=0, local_npanes = panes.size(); i<local_npanes; ++i, ++it){
48  const COM::Pane &pane = **it;
49 
50  const COM::Attribute *nc_pane = (pnts==NULL)?pane.attribute( COM::COM_NC):
51  pane.attribute( pnts->id());
52  COM_assertion( pane.size_of_elements()==0 || nc_pane->stride()==3);
53 
54  const Point_3<Real> *pnts = (const Point_3<Real>*)(nc_pane->pointer());
56  (pane.attribute( elem_nrmls->id())->pointer());
57 
58  // Loop through elements of the pane
59  Element_node_enumerator ene( &pane, 1);
60 
61  for ( int j=pane.size_of_elements(); j>0; --j, ene.next(),++ptr) {
63  ps.set( pnts, ene, 1);
64 
65  e.Jacobian( ps, nc, J);
66  *ptr = Vector_3<Real>::cross_product( J[0], J[1]);
67  if ( to_normalize==NULL || *to_normalize)
68  ptr->normalize();
69  else if ( e.size_of_edges()==3) // If triangle, reduce by half.
70  (*ptr) *= 0.5;
71  }
72  }
73 }
74 
76 
77 
78 
79 
80 
81 
#define COM_assertion(EX)
Error checking utility similar to the assert macro of the C language.
An adaptor for enumerating node IDs of an element.
#define SURF_END_NAMESPACE
Definition: surfbasic.h:29
Encapsulation of the element-wise computations for two-dimensional elements.
Vector_3 & normalize()
Definition: mapbasic.h:114
#define SURF_BEGIN_NAMESPACE
Definition: surfbasic.h:28
This is a helper class for accessing nodal data.
int size_of_edges() const
Number of edges per element.
blockLoc i
Definition: read.cpp:79
int size_of_nodes() const
Number of nodes per element.
static Vector_3 cross_product(const Vector_3 &v, const Vector_3 &w)
Definition: mapbasic.h:104
static void compute_element_normals(COM::Attribute *nrm, const int *to_normalize=NULL, const COM::Attribute *pnts=NULL)
Computes elemental normals of a given window.
j indices j
Definition: Indexing.h:6
void set(const Value *p, Element_node_enumerator &ene, int strd)
initialize the accessor with a pointer and a specific stride.
void next()
Go to the next element within the connectivity tables of a pane.