Changeset 24630
- Timestamp:
- 03/03/20 12:19:15 (5 years ago)
- Location:
- issm/trunk-jpl/src/c
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified issm/trunk-jpl/src/c/classes/Loads/Loads.cpp ¶
r23587 r24630 19 19 #include "../../shared/Enum/EnumDefinitions.h" 20 20 #include "../../shared/Exceptions/exceptions.h" 21 #include "../../shared/MemOps/MemOps.h" 22 #include "../../shared/io/Marshalling/Marshalling.h" 21 23 #include "./Loads.h" 22 24 #include "./Load.h" … … 27 29 /*Object constructors and destructor*/ 28 30 Loads::Loads(){/*{{{*/ 29 enum_type=LoadsEnum; 31 this->enum_type=LoadsEnum; 32 this->numrifts = 0; 33 this->numpenalties = 0; 30 34 return; 31 35 } … … 36 40 /*}}}*/ 37 41 42 Loads* Loads::Copy() {/*{{{*/ 43 44 int num_proc = IssmComm::GetSize(); 45 46 /*Copy dataset*/ 47 Loads* output=new Loads(); 48 output->sorted=this->sorted; 49 output->numsorted=this->numsorted; 50 output->presorted=this->presorted; 51 for(vector<Object*>::iterator obj=this->objects.begin() ; obj < this->objects.end(); obj++ ){ 52 output->AddObject((*obj)->copy()); 53 } 54 55 /*Build id_offsets and sorted_ids*/ 56 int objsize = this->numsorted; 57 output->id_offsets=NULL; 58 output->sorted_ids=NULL; 59 if(this->sorted && objsize>0 && this->id_offsets){ 60 output->id_offsets=xNew<int>(objsize); 61 xMemCpy<int>(output->id_offsets,this->id_offsets,objsize); 62 } 63 if(this->sorted && objsize>0 && this->sorted_ids){ 64 output->sorted_ids=xNew<int>(objsize); 65 xMemCpy<int>(output->sorted_ids,this->sorted_ids,objsize); 66 } 67 68 /*Copy other fields*/ 69 output->numrifts = this->numrifts; 70 output->numpenalties = this->numpenalties; 71 72 return output; 73 } 74 /*}}}*/ 75 void Loads::Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction){ /*{{{*/ 76 77 int num_procs=IssmComm::GetSize(); 78 int test = num_procs; 79 MARSHALLING_ENUM(LoadsEnum); 80 MARSHALLING(numrifts); 81 MARSHALLING(numpenalties); 82 83 DataSet::Marshall(pmarshalled_data,pmarshalled_data_size,marshall_direction); 84 } 85 /*}}}*/ 86 38 87 /*Numerics:*/ 39 88 void Loads::Configure(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters){/*{{{*/ 40 89 41 90 vector<Object*>::iterator object; 42 Load* load=NULL; 91 for(object=objects.begin() ; object < objects.end(); object++){ 92 Load* load=xDynamicCast<Load*>(*object); 93 load->Configure(elements,loads,nodes,vertices,materials,parameters); 94 } 95 } 96 /*}}}*/ 97 void Loads::Finalize(){/*{{{*/ 43 98 44 for ( object=objects.begin() ; object < objects.end(); object++ ){ 99 /*Count Rifts and penalties*/ 100 int ispenalty=0; 101 int isrift=0; 102 int allcount; 45 103 46 load=xDynamicCast<Load*>(*object); 47 load->Configure(elements,loads,nodes,vertices,materials,parameters); 104 /*Now go through all loads, and get how many nodes they own, unless they are clone nodes: */ 105 for(int i=0;i<this->Size();i++){ 106 Load* load=xDynamicCast<Load*>(this->GetObjectByOffset(i)); 107 if(load->IsPenalty()){ 108 ispenalty++; 109 } 110 if(load->ObjectEnum()==RiftfrontEnum){ 111 isrift++; 112 } 113 } 48 114 49 } 115 /*Grab sum of all cpus: */ 116 ISSM_MPI_Allreduce((void*)&ispenalty,(void*)&allcount,1,ISSM_MPI_INT,ISSM_MPI_SUM,IssmComm::GetComm()); 117 this->numpenalties = allcount; 118 119 ISSM_MPI_Allreduce((void*)&isrift,(void*)&allcount,1,ISSM_MPI_INT,ISSM_MPI_SUM,IssmComm::GetComm()); 120 this->numrifts= allcount; 50 121 51 122 } … … 53 124 bool Loads::IsPenalty(){/*{{{*/ 54 125 55 int ispenalty=0; 56 int allispenalty=0; 57 58 /*Now go through all loads, and get how many nodes they own, unless they are clone nodes: */ 59 for(int i=0;i<this->Size();i++){ 60 Load* load=xDynamicCast<Load*>(this->GetObjectByOffset(i)); 61 if(load->IsPenalty()) ispenalty++; 62 } 63 64 /*Grab sum of all cpus: */ 65 ISSM_MPI_Allreduce((void*)&ispenalty,(void*)&allispenalty,1,ISSM_MPI_INT,ISSM_MPI_SUM,IssmComm::GetComm()); 66 ispenalty=allispenalty; 67 68 if(ispenalty) 126 if(this->numpenalties>0) 69 127 return true; 70 128 else -
TabularUnified issm/trunk-jpl/src/c/classes/Loads/Loads.h ¶
r23587 r24630 18 18 public: 19 19 20 int numrifts; 21 int numpenalties; 22 20 23 /*constructors, destructors*/ 21 24 Loads(); 22 25 ~Loads(); 23 26 27 /*Objects virtual functions*/ 28 Loads* Copy(); 29 void Marshall(char** pmarshalled_data,int* pmarshalled_data_size, int marshall_direction); 30 24 31 /*numerics*/ 25 32 void Configure(Elements* elements,Loads* loads, Nodes* nodes, Vertices* vertices, Materials* materials,Parameters* parameters); 26 33 bool IsPenalty(); 34 void Finalize(); 27 35 int MaxNumNodes(); 28 36 int NumberOfLoads(); -
TabularUnified issm/trunk-jpl/src/c/modules/ConstraintsStatex/ConstraintsStatex.cpp ¶
r23588 r24630 10 10 void ConstraintsStatex(int* pconverged, int* pnum_unstable_constraints,FemModel* femmodel){ 11 11 12 /*Early return if no rift and no penalties*/ 13 if(femmodel->loads->numrifts == 0 && femmodel->loads->numpenalties == 0){ 14 *pconverged = 0; 15 *pnum_unstable_constraints = 0; 16 return; 17 } 18 12 19 /*output: */ 13 int converged 14 int num_unstable_constraints 15 int min_mechanical_constraints 16 int 17 int 20 int converged = 1; 21 int num_unstable_constraints = 0; 22 int min_mechanical_constraints = 0; 23 int unstable = 0; 24 int sum_num_unstable_constraints = 0; 18 25 int analysis_type; 19 26 … … 26 33 27 34 /*Rift penalties first*/ 28 if( RiftIsPresent(femmodel->loads,analysis_type)){35 if(femmodel->loads->numrifts){ 29 36 RiftConstraintsState(&converged,&num_unstable_constraints,femmodel->loads,min_mechanical_constraints,analysis_type); 30 37 } 31 38 32 39 /*Deal with pengrid*/ 33 for(int i=0;i<femmodel->loads->Size();i++){ 34 Load* load=(Load*)femmodel->loads->GetObjectByOffset(i); 35 if(load->ObjectEnum()==PengridEnum){ 36 Pengrid* pengrid=(Pengrid*)load; 37 pengrid->ConstraintActivate(&unstable); 38 num_unstable_constraints += unstable; 40 if(femmodel->loads->numpenalties){ 41 for(int i=0;i<femmodel->loads->Size();i++){ 42 Load* load=(Load*)femmodel->loads->GetObjectByOffset(i); 43 if(load->ObjectEnum()==PengridEnum){ 44 Pengrid* pengrid=(Pengrid*)load; 45 pengrid->ConstraintActivate(&unstable); 46 num_unstable_constraints += unstable; 47 } 39 48 } 40 49 } 50 41 51 ISSM_MPI_Reduce(&num_unstable_constraints,&sum_num_unstable_constraints,1,ISSM_MPI_INT,ISSM_MPI_SUM,0,IssmComm::GetComm() ); 42 52 ISSM_MPI_Bcast(&sum_num_unstable_constraints,1,ISSM_MPI_INT,0,IssmComm::GetComm()); -
TabularUnified issm/trunk-jpl/src/c/modules/ConstraintsStatex/ConstraintsStatex.h ¶
r16206 r24630 9 9 10 10 /* local prototypes: */ 11 int RiftIsPresent(Loads* loads,int analysis_type);12 11 void ConstraintsStatex(int* pconverged, int* pnum_unstable_constraints,FemModel* femmodel); 13 12 -
TabularUnified issm/trunk-jpl/src/c/modules/ConstraintsStatex/RiftConstraintsState.cpp ¶
r24623 r24630 6 6 7 7 /*current module: */ 8 /*RiftIsPresent(Loads* loads,int configuration_type){{{*/9 int RiftIsPresent(Loads* loads,int configuration_type){10 11 int i;12 13 int found=0;14 int mpi_found=0;15 16 /*go though loads, and figure out if one of the loads is a Riftfront: */17 for (i=0;i<loads->Size();i++){18 Load* load=(Load*)loads->GetObjectByOffset(i);19 if(RiftfrontEnum==loads->GetEnum(i)){20 found=1;21 break;22 }23 }24 25 ISSM_MPI_Reduce (&found,&mpi_found,1,ISSM_MPI_INT,ISSM_MPI_SUM,0,IssmComm::GetComm() );26 ISSM_MPI_Bcast(&mpi_found,1,ISSM_MPI_INT,0,IssmComm::GetComm());27 found=mpi_found;28 29 return found;30 }31 /*}}}*/32 8 /*RiftConstraintsState(int* pconverged, int* pnum_unstable_constraints,Loads* loads,int min_mechanical_constraints,int configuration_type){{{*/ 33 9 void RiftConstraintsState(int* pconverged, int* pnum_unstable_constraints,Loads* loads,int min_mechanical_constraints,int configuration_type){ -
TabularUnified issm/trunk-jpl/src/c/modules/ModelProcessorx/ModelProcessorx.cpp ¶
r24335 r24630 69 69 loads[i]->Presort(); 70 70 nodes[i]->Presort(); 71 72 /*Finalize loads (count pengrids,penpairs,rifts,etc)*/ 73 loads[i]->Finalize(); 71 74 } 72 75 -
TabularUnified issm/trunk-jpl/src/c/modules/ResetConstraintsx/ResetConstraintsx.cpp ¶
r23588 r24630 24 24 25 25 /*Deal with rift first*/ 26 if( RiftIsPresent(femmodel->loads,analysis_type)){26 if(femmodel->loads->numrifts){ 27 27 _error_("rift constraints reset not supported yet!"); 28 28 } … … 43 43 44 44 /*Deal with rift first*/ 45 if( RiftIsPresent(femmodel->loads,femmodel->analysis_type_list[femmodel->analysis_counter])){45 if(femmodel->loads->numrifts){ 46 46 _error_("rift constraints reset not supported yet!"); 47 47 }
Note:
See TracChangeset
for help on using the changeset viewer.