1 | /*!\file ElementResponsex
|
---|
2 | * \brief: compute element input on one element only
|
---|
3 | */
|
---|
4 |
|
---|
5 | #include "./ElementResponsex.h"
|
---|
6 |
|
---|
7 | #include "../../shared/shared.h"
|
---|
8 | #include "../../include/include.h"
|
---|
9 | #include "../../toolkits/toolkits.h"
|
---|
10 | #include "../../EnumDefinitions/EnumDefinitions.h"
|
---|
11 |
|
---|
12 | void ElementResponsex( IssmDouble* presponse, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials,Parameters* parameters,int response_enum,bool process_units){
|
---|
13 |
|
---|
14 |
|
---|
15 | extern int my_rank;
|
---|
16 | int i;
|
---|
17 |
|
---|
18 | int found=0;
|
---|
19 | int sumfound=0;
|
---|
20 | int cpu_found=-1;
|
---|
21 | int index;
|
---|
22 | IssmDouble response;
|
---|
23 | Element* element=NULL;
|
---|
24 |
|
---|
25 | /*retrieve element we are interested in: */
|
---|
26 | parameters->FindParam(&index,IndexEnum);
|
---|
27 |
|
---|
28 | /*now, go through our elements, and retrieve the one with this id: index: */
|
---|
29 | for(i=0;i<elements->Size();i++){
|
---|
30 | element=(Element*)elements->GetObjectByOffset(i);
|
---|
31 | if (element->Id()==index){
|
---|
32 | found=1;
|
---|
33 | cpu_found=my_rank;
|
---|
34 | break;
|
---|
35 | }
|
---|
36 | }
|
---|
37 |
|
---|
38 | /*Broadcast whether we found the element: */
|
---|
39 | #ifdef _HAVE_MPI_
|
---|
40 | MPI_Allreduce ( &found,&sumfound,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
|
---|
41 | if(!sumfound)_error_("could not find material with id" << index << " to compute ElementResponse");
|
---|
42 | #endif
|
---|
43 |
|
---|
44 | /*Ok, we found the element, compute responseocity: */
|
---|
45 | if(my_rank==cpu_found){
|
---|
46 | element->ElementResponse(&response,response_enum,IuToExtEnum);
|
---|
47 | }
|
---|
48 |
|
---|
49 | /*Broadcast and plug into response: */
|
---|
50 | #ifdef _HAVE_MPI_
|
---|
51 | MPI_Allreduce ( &cpu_found,&cpu_found,1,MPI_INT,MPI_MAX,MPI_COMM_WORLD);
|
---|
52 | MPI_Bcast(&response,1,MPI_DOUBLE,cpu_found,MPI_COMM_WORLD);
|
---|
53 | #endif
|
---|
54 |
|
---|
55 | *presponse=response;
|
---|
56 | }
|
---|