Ice Sheet System Model  4.18
Code documentation
AverageOntoPartitionx.cpp
Go to the documentation of this file.
1 
6 #ifdef HAVE_CONFIG_H
7  #include <config.h>
8 #else
9 #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
10 #endif
11 
13 #include "../../shared/shared.h"
14 #include "../../toolkits/toolkits.h"
15 
16 void AverageOntoPartitionx(double** paverage, Elements* elements, Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters,double* vertex_response,double* qmu_part,int npart){
17 
18  /*output: */
19  Vector<IssmDouble>* partition_contributions=NULL;
20  Vector<IssmDouble>* partition_areas=NULL;
21  Vector<IssmDouble>* vec_average=NULL;
22  double* average=NULL;
23 
24  /*average onto the separate areas. The result will be a npart sized vector. */
25 
26  /*allocate: */
27  partition_contributions=new Vector<IssmDouble>(npart);
28  partition_areas=new Vector<IssmDouble>(npart);
29  vec_average=new Vector<IssmDouble>(npart);
30 
31  /*loop on each element, and add contribution of the element to the partition (surface weighted average): */
32  for(int i=0;i<elements->Size();i++){
33  Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
34  element->AverageOntoPartition(partition_contributions,partition_areas,vertex_response,qmu_part);
35  }
36 
37  /*Assemble: */
38  partition_contributions->Assemble();
39  partition_areas->Assemble();
40 
41  /*We have the partition_areas and the partition_contributions for each partition -> compute the surfae weighted average: */
42  vec_average->PointwiseDivide(partition_contributions,partition_areas);
43 
44  /*serialize:*/
45  average=vec_average->ToMPISerial();
46 
47  /*Free ressources:*/
48  delete partition_contributions;
49  delete partition_areas;
50  delete vec_average;
51 
52  /*Assign output pointers:*/
53  *paverage=average;
54 }
DataSet::Size
int Size()
Definition: DataSet.cpp:399
Vertices
Declaration of Vertices class.
Definition: Vertices.h:15
Nodes
Declaration of Nodes class.
Definition: Nodes.h:19
Parameters
Declaration of Parameters class.
Definition: Parameters.h:18
Elements
Declaration of Elements class.
Definition: Elements.h:17
Element
Definition: Element.h:41
Materials
Declaration of Materials class.
Definition: Materials.h:16
AverageOntoPartitionx
void AverageOntoPartitionx(double **paverage, Elements *elements, Nodes *nodes, Vertices *vertices, Loads *loads, Materials *materials, Parameters *parameters, double *vertex_response, double *qmu_part, int npart)
Definition: AverageOntoPartitionx.cpp:16
Vector::Assemble
void Assemble(void)
Definition: Vector.h:142
Loads
Declaration of Loads class.
Definition: Loads.h:16
DataSet::GetObjectByOffset
Object * GetObjectByOffset(int offset)
Definition: DataSet.cpp:334
AverageOntoPartitionx.h
header file for averaging dakota responses onto a vertices partition
Vector::PointwiseDivide
void PointwiseDivide(Vector *x, Vector *y)
Definition: Vector.h:378
Vector::ToMPISerial
doubletype * ToMPISerial(void)
Definition: Vector.h:277
Vector< IssmDouble >
Element::AverageOntoPartition
virtual void AverageOntoPartition(Vector< IssmDouble > *partition_contributions, Vector< IssmDouble > *partition_areas, IssmDouble *vertex_response, IssmDouble *qmu_part)=0