| 1 | /*
|
|---|
| 2 | * \file Elements.cpp
|
|---|
| 3 | * \brief: Implementation of Elements class, derived from DataSet class
|
|---|
| 4 | */
|
|---|
| 5 |
|
|---|
| 6 | /*Headers: {{{*/
|
|---|
| 7 | #ifdef HAVE_CONFIG_H
|
|---|
| 8 | #include <config.h>
|
|---|
| 9 | #else
|
|---|
| 10 | #error "Cannot compile with HAVE_CONFIG_H symbol! run configure first!"
|
|---|
| 11 | #endif
|
|---|
| 12 |
|
|---|
| 13 | #include "./Element.h"
|
|---|
| 14 | #include "./Elements.h"
|
|---|
| 15 | #include "../Params/Parameters.h"
|
|---|
| 16 | #include "../ExternalResults/Results.h"
|
|---|
| 17 | #include "../ExternalResults/GenericExternalResult.h"
|
|---|
| 18 | #include "../../toolkits/toolkits.h"
|
|---|
| 19 | #include "../../shared/shared.h"
|
|---|
| 20 |
|
|---|
| 21 | using namespace std;
|
|---|
| 22 | /*}}}*/
|
|---|
| 23 |
|
|---|
| 24 | /*Object constructors and destructor*/
|
|---|
| 25 | Elements::Elements(){/*{{{*/
|
|---|
| 26 | enum_type=MeshElementsEnum;
|
|---|
| 27 | return;
|
|---|
| 28 | }
|
|---|
| 29 | /*}}}*/
|
|---|
| 30 | Elements::~Elements(){/*{{{*/
|
|---|
| 31 | return;
|
|---|
| 32 | }
|
|---|
| 33 | /*}}}*/
|
|---|
| 34 |
|
|---|
| 35 | /*Object management*/
|
|---|
| 36 | void Elements::Configure(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters){/*{{{*/
|
|---|
| 37 |
|
|---|
| 38 | vector<Object*>::iterator object;
|
|---|
| 39 | Element* element=NULL;
|
|---|
| 40 |
|
|---|
| 41 | for ( object=objects.begin() ; object < objects.end(); object++ ){
|
|---|
| 42 |
|
|---|
| 43 | element=dynamic_cast<Element*>((*object));
|
|---|
| 44 | element->Configure(elements,loads,nodes,vertices,materials,parameters);
|
|---|
| 45 |
|
|---|
| 46 | }
|
|---|
| 47 |
|
|---|
| 48 | }
|
|---|
| 49 | /*}}}*/
|
|---|
| 50 | void Elements::SetCurrentConfiguration(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters){/*{{{*/
|
|---|
| 51 |
|
|---|
| 52 | vector<Object*>::iterator object;
|
|---|
| 53 | Element* element=NULL;
|
|---|
| 54 |
|
|---|
| 55 | for ( object=objects.begin() ; object < objects.end(); object++ ){
|
|---|
| 56 |
|
|---|
| 57 | element=dynamic_cast<Element*>((*object));
|
|---|
| 58 | element->SetCurrentConfiguration(elements,loads,nodes,materials,parameters);
|
|---|
| 59 |
|
|---|
| 60 | }
|
|---|
| 61 |
|
|---|
| 62 | }
|
|---|
| 63 | /*}}}*/
|
|---|
| 64 | void Elements::ResetHooks(){/*{{{*/
|
|---|
| 65 |
|
|---|
| 66 | vector<Object*>::iterator object;
|
|---|
| 67 | Element* element=NULL;
|
|---|
| 68 |
|
|---|
| 69 | for ( object=objects.begin() ; object < objects.end(); object++ ){
|
|---|
| 70 |
|
|---|
| 71 | element=dynamic_cast<Element*>((*object));
|
|---|
| 72 | element->ResetHooks();
|
|---|
| 73 |
|
|---|
| 74 | }
|
|---|
| 75 |
|
|---|
| 76 | }
|
|---|
| 77 | /*}}}*/
|
|---|
| 78 | int Elements::MaxNumNodes(void){/*{{{*/
|
|---|
| 79 |
|
|---|
| 80 | int max=0;
|
|---|
| 81 | int allmax;
|
|---|
| 82 | int numnodes=0;
|
|---|
| 83 |
|
|---|
| 84 | /*Now go through all elements, and get how many nodes they own, unless they are clone nodes: */
|
|---|
| 85 | for(int i=0;i<this->Size();i++){
|
|---|
| 86 |
|
|---|
| 87 | Element* element=dynamic_cast<Element*>(this->GetObjectByOffset(i));
|
|---|
| 88 | numnodes=element->GetNumberOfNodes();
|
|---|
| 89 | if(numnodes>max)max=numnodes;
|
|---|
| 90 | }
|
|---|
| 91 |
|
|---|
| 92 | /*Grab max of all cpus: */
|
|---|
| 93 | ISSM_MPI_Allreduce((void*)&max,(void*)&allmax,1,ISSM_MPI_INT,ISSM_MPI_MAX,IssmComm::GetComm());
|
|---|
| 94 | max=allmax;
|
|---|
| 95 |
|
|---|
| 96 | return max;
|
|---|
| 97 | }
|
|---|
| 98 | /*}}}*/
|
|---|
| 99 | int Elements::NumberOfElements(void){/*{{{*/
|
|---|
| 100 |
|
|---|
| 101 | int local_nelem;
|
|---|
| 102 | int numberofelements;
|
|---|
| 103 |
|
|---|
| 104 | local_nelem=this->Size();
|
|---|
| 105 | ISSM_MPI_Allreduce((void*)&local_nelem,(void*)&numberofelements,1,ISSM_MPI_INT,ISSM_MPI_SUM,IssmComm::GetComm());
|
|---|
| 106 |
|
|---|
| 107 | return numberofelements;
|
|---|
| 108 | }
|
|---|
| 109 | /*}}}*/
|
|---|
| 110 | void Elements::InputDuplicate(int input_enum,int output_enum){/*{{{*/
|
|---|
| 111 |
|
|---|
| 112 | for(int i=0;i<this->Size();i++){
|
|---|
| 113 | Element* element=dynamic_cast<Element*>(this->GetObjectByOffset(i));
|
|---|
| 114 | element->InputDuplicate(input_enum,output_enum);
|
|---|
| 115 | }
|
|---|
| 116 | }
|
|---|
| 117 | /*}}}*/
|
|---|