Ice Sheet System Model  4.18
Code documentation
NodalValuex.cpp
Go to the documentation of this file.
1 
5 #include "./NodalValuex.h"
6 
7 #include "../../shared/shared.h"
8 #include "../../toolkits/toolkits.h"
9 
10 void NodalValuex( IssmDouble* pnodalvalue, int natureofdataenum,Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials, Parameters* parameters){
11 
12  IssmDouble value;
13  int index;
14  int found,sumfound,cpu_found,cpu;
15 
16  /*retrieve element we are interested in: */
17  parameters->FindParam(&index,IndexEnum);
18 
19  /*This is the vertex id for which we want to collect the data. Go through elements, and for each
20  *element, figure out if they hold the vertex, and the data. If so, return it: */
21  cpu_found=-1;
22  found=0;
23 
24  for(int i=0;i<elements->Size();i++){
25  Element* element=xDynamicCast<Element*>(elements->GetObjectByOffset(i));
26  found=element->NodalValue(&value,index,natureofdataenum);
27  if(found){
28  cpu_found=IssmComm::GetRank();
29  break;
30  }
31  }
32 
33  /*Broadcast whether we found the element: */
35  if(!sumfound)_error_("could not find element with vertex with id " << index << " to compute nodal value " << EnumToStringx(natureofdataenum));
36 
37  /*Broadcast and plug into response: */
40 
41  *pnodalvalue=value;
42 }
DataSet::Size
int Size()
Definition: DataSet.cpp:399
Vertices
Declaration of Vertices class.
Definition: Vertices.h:15
IndexEnum
@ IndexEnum
Definition: EnumDefinitions.h:201
IssmDouble
double IssmDouble
Definition: types.h:37
Nodes
Declaration of Nodes class.
Definition: Nodes.h:19
ISSM_MPI_Allreduce
int ISSM_MPI_Allreduce(void *sendbuf, void *recvbuf, int count, ISSM_MPI_Datatype datatype, ISSM_MPI_Op op, ISSM_MPI_Comm comm)
Definition: issmmpi.cpp:116
Parameters
Declaration of Parameters class.
Definition: Parameters.h:18
ISSM_MPI_SUM
#define ISSM_MPI_SUM
Definition: issmmpi.h:134
IssmComm::GetComm
static ISSM_MPI_Comm GetComm(void)
Definition: IssmComm.cpp:30
Elements
Declaration of Elements class.
Definition: Elements.h:17
ISSM_MPI_MAX
#define ISSM_MPI_MAX
Definition: issmmpi.h:131
NodalValuex
void NodalValuex(IssmDouble *pnodalvalue, int natureofdataenum, Elements *elements, Nodes *nodes, Vertices *vertices, Loads *loads, Materials *materials, Parameters *parameters)
Definition: NodalValuex.cpp:10
NodalValuex.h
header file for NodalValuex
Element::NodalValue
virtual int NodalValue(IssmDouble *pvalue, int index, int natureofdataenum)=0
Element
Definition: Element.h:41
ISSM_MPI_DOUBLE
#define ISSM_MPI_DOUBLE
Definition: issmmpi.h:125
ISSM_MPI_INT
#define ISSM_MPI_INT
Definition: issmmpi.h:127
Materials
Declaration of Materials class.
Definition: Materials.h:16
EnumToStringx
const char * EnumToStringx(int enum_in)
Definition: EnumToStringx.cpp:15
ISSM_MPI_Bcast
int ISSM_MPI_Bcast(void *buffer, int count, ISSM_MPI_Datatype datatype, int root, ISSM_MPI_Comm comm)
Definition: issmmpi.cpp:162
IssmComm::GetRank
static int GetRank(void)
Definition: IssmComm.cpp:34
Loads
Declaration of Loads class.
Definition: Loads.h:16
_error_
#define _error_(StreamArgs)
Definition: exceptions.h:49
DataSet::GetObjectByOffset
Object * GetObjectByOffset(int offset)
Definition: DataSet.cpp:334
Parameters::FindParam
void FindParam(bool *pinteger, int enum_type)
Definition: Parameters.cpp:262