Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
compute_element_areas.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_areas.C,v 1.6 2008/12/06 08:43:23 mtcampbe Exp $
24 
29 /* Author: Phillip Alexander
30  * Dates: Dec. 13, 2002
31  */
32 
33 #include "Rocsurf.h"
34 #include "roccom_devel.h"
35 #include "Element_accessors.h"
36 #include "Generic_element_2.h"
37 #include <vector>
38 
40 
41 void Rocsurf::compute_element_areas( COM::Attribute *element_areas,
42  const COM::Attribute *pnts) {
43  COM_assertion_msg( element_areas && element_areas->is_elemental(),
44  "Argument must be elemental attribute");
45  COM_assertion_msg( element_areas->size_of_components()== 1 &&
46  COM_compatible_types(element_areas->data_type(), COM_DOUBLE),
47  "Argument must be double-precision scalars");
48 
49  std::vector< COM:: Pane*> panes;
50  element_areas->window() -> panes( panes);
52  Vector_2<Real> nc(0,0);
53 
54  std::vector< COM::Pane*>::const_iterator it = panes.begin();
55 
56  for (int i=0, local_npanes = panes.size(); i<local_npanes; ++i, ++it){
57  COM::Pane &pane = **it;
58 
59  const COM::Attribute *nc_pane = (pnts==NULL)?pane.attribute( COM::COM_NC):
60  pane.attribute( pnts->id());
61  COM::Attribute *a_pane = pane.attribute( element_areas->id());
62  COM_assertion( pane.size_of_elements()==0 ||
63  nc_pane->stride()==3 && a_pane->stride()==1);
64 
65  const Point_3<Real> *pnts = (const Point_3<Real>*)(nc_pane->pointer());
66  Real *ptr = (Real *)(a_pane->pointer());
67 
68  // Loop through elements of the pane
69  Element_node_enumerator ene( &pane, 1);
70  for ( int j=pane.size_of_elements(); j>0; --j, ene.next(),++ptr) {
72  ps.set( pnts, ene, 1);
73  int size = e.get_num_gp();
74  Real this_area = 0;
75 
76  for (int k = 0; k<size; k++){
77  Real weight = e.get_gp_weight( k);
78  e.get_gp_nat_coor(k, nc);
79  Real jacobi_det = e.Jacobian_det(ps,nc);
80  this_area += weight * jacobi_det;
81  }
82  *ptr = this_area;
83  }
84  }
85 }
86 
87 // Integrate a function given by an elemental attribute over surface
88 void Rocsurf::integrate( const COM::Attribute *x, double *z) {
89 
90  COM_assertion_msg( x && x->is_elemental(),
91  "Argument must be elemental attribute");
93  "Argument must be double precision");
94 
95  const int ncomp = x->size_of_components();
96  // Initialize output to 0.
97  for ( int kk=0; kk<ncomp; ++kk) z[kk]=0.;
98 
99  std::vector< const COM:: Pane*> panes;
100  x->window()-> panes( panes);
102  Vector_2<Real> nc(0,0);
103 
104  std::vector< const COM::Pane*>::const_iterator it = panes.begin();
105 
106  for (int i=0, local_npanes = panes.size(); i<local_npanes; ++i, ++it){
107  const COM::Pane &pane = **it;
108  // Assuming contiguous layout
109  const COM::Attribute *nc_pane = pane.attribute( COM::COM_NC);
110  const COM::Attribute *x_pane = pane.attribute( x->id());
111  COM_assertion( pane.size_of_elements()==0 ||
112  nc_pane->stride()==3 && x_pane->stride()==ncomp);
113 
114  const Point_3<Real> *pnts = (const Point_3<Real>*)(nc_pane->pointer());
115  const Real *xptr = (Real *)(x_pane->pointer());
116 
117  // Loop through elements of the pane
118  Element_node_enumerator ene( &pane, 1);
119  for ( int j=pane.size_of_elements(); j>0; --j, ene.next(), xptr+=ncomp) {
121  ps.set( pnts, ene, 1);
122  int size = e.get_num_gp();
123 
124  for (int k = 0; k<size; k++){
125  Real weight = e.get_gp_weight( k);
126  e.get_gp_nat_coor(k, nc);
127  Real jacobi_det = e.Jacobian_det(ps,nc);
128 
129  for ( int kk=0; kk<ncomp; ++kk)
130  z[kk] += weight * jacobi_det * xptr[kk];
131  }
132  }
133  }
134 
135  if ( COMMPI_Initialized()) {
136  // Perform reduction on all processros within the communicator.
137  std::vector<double> lval(ncomp);
138  std::copy( z, z+ncomp, lval.begin());
139  MPI_Allreduce( &lval[0], z, ncomp, MPI_DOUBLE, MPI_SUM,
140  x->window()->get_communicator());
141  }
142 }
143 
145 
146 
147 
148 
149 
150 
#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.
j indices k indices k
Definition: Indexing.h:6
#define COM_assertion_msg(EX, msg)
#define SURF_END_NAMESPACE
Definition: surfbasic.h:29
Encapsulation of the element-wise computations for two-dimensional elements.
double Real
Definition: mapbasic.h:322
#define SURF_BEGIN_NAMESPACE
Definition: surfbasic.h:28
This is a helper class for accessing nodal data.
*********************************************************************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 ** copy
Definition: roccomf90.h:20
void int int int REAL REAL REAL * z
Definition: write.cpp:76
int size_of_edges() const
Number of edges per element.
int COM_compatible_types(COM_Type type1, COM_Type type2)
Definition: roccom_c++.h:563
blockLoc i
Definition: read.cpp:79
void int int REAL * x
Definition: read.cpp:74
static void integrate(const COM::Attribute *x, double *z)
Integrate a function given by an elemental attribute over surface z is an array of size equal to numb...
int size_of_nodes() const
Number of nodes per element.
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.
static void compute_element_areas(COM::Attribute *areas, const COM::Attribute *pnts=NULL)
Computes the area of each face of the surface mesh of window areas-&gt;window and saves the results in a...
int COMMPI_Initialized()
Definition: commpi.h:168
here we put it at the!beginning of the common block The point to point and collective!routines know about but MPI_TYPE_STRUCT as yet does not!MPI_STATUS_IGNORE and MPI_STATUSES_IGNORE are similar objects!Until the underlying MPI library implements the C version of these are declared as arrays of MPI_STATUS_SIZE!The types and are OPTIONAL!Their values are zero if they are not available Note that!using these reduces the portability of MPI_IO INTEGER MPI_BOTTOM INTEGER MPI_DOUBLE_PRECISION INTEGER MPI_LOGICAL INTEGER MPI_2REAL INTEGER MPI_2DOUBLE_COMPLEX INTEGER MPI_LB INTEGER MPI_WTIME_IS_GLOBAL INTEGER MPI_GROUP_EMPTY INTEGER MPI_SUM