source: issm/trunk/src/c/modules/ElementResponsex/ElementResponsex.cpp@ 13395

Last change on this file since 13395 was 13395, checked in by Mathieu Morlighem, 12 years ago

merged trunk-jpl and trunk for revision 13393

File size: 1.5 KB
RevLine 
[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
[13395]12void ElementResponsex( IssmDouble* presponse, Elements* elements,Nodes* nodes, Vertices* vertices, Loads* loads, Materials* materials,Parameters* parameters,int response_enum,bool process_units){
[10703]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;
[13395]22 IssmDouble response;
[10703]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);
[13395]41 if(!sumfound)_error_("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}
Note: See TracBrowser for help on using the repository browser.