[10703] | 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( double* 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 | double 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: */
|
---|
[12330] | 39 | #ifdef _HAVE_MPI_
|
---|
[10703] | 40 | MPI_Allreduce ( &found,&sumfound,1,MPI_INT,MPI_SUM,MPI_COMM_WORLD);
|
---|
| 41 | if(!sumfound)_error_("%s%i%s","could not find material with id",index," to compute ElementResponse");
|
---|
[12330] | 42 | #endif
|
---|
[10703] | 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: */
|
---|
[12330] | 50 | #ifdef _HAVE_MPI_
|
---|
[10703] | 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);
|
---|
[12330] | 53 | #endif
|
---|
[10703] | 54 |
|
---|
| 55 | *presponse=response;
|
---|
| 56 | }
|
---|