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 | /*FUNCTION Elements::Elements(){{{*/
|
---|
26 | Elements::Elements(){
|
---|
27 | enum_type=MeshElementsEnum;
|
---|
28 | return;
|
---|
29 | }
|
---|
30 | /*}}}*/
|
---|
31 | /*FUNCTION Elements::~Elements(){{{*/
|
---|
32 | Elements::~Elements(){
|
---|
33 | return;
|
---|
34 | }
|
---|
35 | /*}}}*/
|
---|
36 |
|
---|
37 | /*Object management*/
|
---|
38 | /*FUNCTION Elements::Configure{{{*/
|
---|
39 | void Elements::Configure(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters){
|
---|
40 |
|
---|
41 | vector<Object*>::iterator object;
|
---|
42 | Element* element=NULL;
|
---|
43 |
|
---|
44 | for ( object=objects.begin() ; object < objects.end(); object++ ){
|
---|
45 |
|
---|
46 | element=dynamic_cast<Element*>((*object));
|
---|
47 | element->Configure(elements,loads,nodes,vertices,materials,parameters);
|
---|
48 |
|
---|
49 | }
|
---|
50 |
|
---|
51 | }
|
---|
52 | /*}}}*/
|
---|
53 | /*FUNCTION Elements::SetCurrentConfiguration{{{*/
|
---|
54 | void Elements::SetCurrentConfiguration(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters){
|
---|
55 |
|
---|
56 | vector<Object*>::iterator object;
|
---|
57 | Element* element=NULL;
|
---|
58 |
|
---|
59 | for ( object=objects.begin() ; object < objects.end(); object++ ){
|
---|
60 |
|
---|
61 | element=dynamic_cast<Element*>((*object));
|
---|
62 | element->SetCurrentConfiguration(elements,loads,nodes,materials,parameters);
|
---|
63 |
|
---|
64 | }
|
---|
65 |
|
---|
66 | }
|
---|
67 | /*}}}*/
|
---|
68 | /*FUNCTION Elements::MaxNumNodes{{{*/
|
---|
69 | int Elements::MaxNumNodes(void){
|
---|
70 |
|
---|
71 | int max=0;
|
---|
72 | int allmax;
|
---|
73 | int numnodes=0;
|
---|
74 |
|
---|
75 | /*Now go through all elements, and get how many nodes they own, unless they are clone nodes: */
|
---|
76 | for(int i=0;i<this->Size();i++){
|
---|
77 |
|
---|
78 | Element* element=dynamic_cast<Element*>(this->GetObjectByOffset(i));
|
---|
79 | numnodes=element->GetNumberOfNodes();
|
---|
80 | if(numnodes>max)max=numnodes;
|
---|
81 | }
|
---|
82 |
|
---|
83 | /*Grab max of all cpus: */
|
---|
84 | ISSM_MPI_Allreduce((void*)&max,(void*)&allmax,1,ISSM_MPI_INT,ISSM_MPI_MAX,IssmComm::GetComm());
|
---|
85 | max=allmax;
|
---|
86 |
|
---|
87 | return max;
|
---|
88 | }
|
---|
89 | /*}}}*/
|
---|
90 | /*FUNCTION Elements::NumberOfElements{{{*/
|
---|
91 | int Elements::NumberOfElements(void){
|
---|
92 |
|
---|
93 | int local_nelem;
|
---|
94 | int numberofelements;
|
---|
95 |
|
---|
96 | local_nelem=this->Size();
|
---|
97 | ISSM_MPI_Allreduce((void*)&local_nelem,(void*)&numberofelements,1,ISSM_MPI_INT,ISSM_MPI_SUM,IssmComm::GetComm());
|
---|
98 |
|
---|
99 | return numberofelements;
|
---|
100 | }
|
---|
101 | /*}}}*/
|
---|
102 | /*FUNCTION Elements::InputDuplicate{{{*/
|
---|
103 | void Elements::InputDuplicate(int input_enum,int output_enum){
|
---|
104 |
|
---|
105 | for(int i=0;i<this->Size();i++){
|
---|
106 | Element* element=dynamic_cast<Element*>(this->GetObjectByOffset(i));
|
---|
107 | element->InputDuplicate(input_enum,output_enum);
|
---|
108 | }
|
---|
109 | }
|
---|
110 | /*}}}*/
|
---|