Changeset 5160
- Timestamp:
- 08/11/10 15:19:35 (15 years ago)
- Location:
- issm/trunk/src/c/modules/PenaltyConstraintsx
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk/src/c/modules/PenaltyConstraintsx/PenaltyConstraintsLocal.h
r4458 r5160 13 13 int MeltingIsPresent(Loads* loads,int analysis_type); 14 14 15 /*rifts: */ 16 int RiftConstraints(int* pconverged, int* pnum_unstable_constraints,Loads* loads,int min_mechanical_constraints,int analysis_type); 17 int RiftIsPresent(Loads* loads,int analysis_type); 18 int IsPreStable(Loads* loads); 19 int SetPreStable(Loads* loads); 20 int PreConstrain(int* pnum_unstable_constraints,Loads* loads); 21 int Constrain(int* pnum_unstable_constraints,Loads* loads); 22 void FreezeConstraints(Loads* loads); 23 int MaxPenetrationInInputs(Loads* loads); 24 int PotentialUnstableConstraints(Loads* loads); 25 int IsMaterialStable(Loads* loads); 26 int IsFrozen(Loads* loads); 15 /*rifts module: */ 16 int RiftIsPresent(Loads* loads,int analysis_type); 17 void RiftConstraints(int* pconverged, int* pnum_unstable_constraints,Loads* loads,int min_mechanical_constraints,int analysis_type); 18 void RiftConstrain(int* pnum_unstable_constraints,Loads* loads,int analysis_type); 19 int RiftIsFrozen(Loads* loads,int analysis_type); 20 void RiftFreezeConstraints(Loads* loads,int analysis_type); 21 22 /*rifts, trial and errors: */ 23 int RiftIsPreStable(Loads* loads); 24 void RiftSetPreStable(Loads* loads); 25 void RiftPreConstrain(int* pnum_unstable_constraints,Loads* loads); 26 void RiftMaxPenetrationInInputs(Loads* loads); 27 int RiftPotentialUnstableConstraints(Loads* loads); 28 int RiftIsMaterialStable(Loads* loads); 27 29 28 30 #endif /* _PENALTYCONSTRAINTSX_H */ -
issm/trunk/src/c/modules/PenaltyConstraintsx/RiftConstraints.cpp
r4699 r5160 10 10 #define _ZIGZAGCOUNTER_ 11 11 12 int RiftConstraints(int* pconverged, int* pnum_unstable_constraints,Loads* loads,int min_mechanical_constraints,int analysis_type){ 13 14 int num_unstable_constraints=0; 15 int converged=0; 16 int potential; 17 ISSMERROR(" check analysis_type across all routine!"); 18 19 Constrain(&num_unstable_constraints,loads); 20 if(num_unstable_constraints==0)converged=1; 21 22 23 if(IsFrozen(loads)){ 24 converged=1; 25 num_unstable_constraints=0; 26 } 27 else if(num_unstable_constraints<=min_mechanical_constraints){ 28 _printf_(" freezing constraints\n"); 29 FreezeConstraints(loads); 30 } 31 32 /*Assign output pointers: */ 33 *pconverged=converged; 34 *pnum_unstable_constraints=num_unstable_constraints; 35 } 36 37 int IsMaterialStable(Loads* loads){ 38 39 int i; 40 41 Riftfront* riftfront=NULL; 42 int found=0; 43 int mpi_found=0; 44 45 /*go though loads, and if non-linearity of the material has converged, let all penalties know: */ 46 for (i=0;i<loads->Size();i++){ 47 48 if(RiftfrontEnum==loads->GetEnum(i)){ 49 50 riftfront=(Riftfront*)loads->GetObjectByOffset(i); 51 52 if (riftfront->IsMaterialStable()){ 53 found=1; 54 /*do not break! all penalties should get informed the non-linearity converged!*/ 55 } 56 } 57 } 58 59 #ifdef _PARALLEL_ 60 MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD ); 61 MPI_Bcast(&mpi_found,1,MPI_INT,0,MPI_COMM_WORLD); 62 found=mpi_found; 63 #endif 64 65 return found; 66 } 67 12 /*current module: */ 13 /*RiftIsPresent(Loads* loads,int analysis_type){{{1*/ 68 14 int RiftIsPresent(Loads* loads,int analysis_type){ 69 15 … … 93 39 return found; 94 40 } 95 96 int IsPreStable(Loads* loads){ 97 98 99 int i; 100 101 Riftfront* riftfront=NULL; 102 int found=0; 103 int mpi_found=0; 104 105 /*go though loads, and figure out if one of the penpair loads is still not stable: */ 106 for (i=0;i<loads->Size();i++){ 107 108 if(RiftfrontEnum==loads->GetEnum(i)){ 109 110 riftfront=(Riftfront*)loads->GetObjectByOffset(i); 111 112 if (riftfront->PreStable()==0){ 113 found=1; 114 break; 115 } 116 } 117 } 118 119 #ifdef _PARALLEL_ 120 MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD ); 121 MPI_Bcast(&mpi_found,1,MPI_INT,0,MPI_COMM_WORLD); 122 found=mpi_found; 123 #endif 124 125 if (found){ 126 /*We found an unstable constraint. : */ 127 return 0; 128 } 129 else{ 130 return 1; 131 } 132 } 133 134 int SetPreStable(Loads* loads){ 135 136 137 int i; 138 139 Riftfront* riftfront=NULL; 140 int found=0; 141 int mpi_found=0; 142 143 /*go though loads, and set loads to pre stable.:*/ 144 for (i=0;i<loads->Size();i++){ 145 146 if(RiftfrontEnum==loads->GetEnum(i)){ 147 148 riftfront=(Riftfront*)loads->GetObjectByOffset(i); 149 riftfront->SetPreStable(); 150 } 151 } 152 } 153 154 int PreConstrain(int* pnum_unstable_constraints,Loads* loads){ 155 156 int i; 157 158 /* generic object pointer: */ 159 Riftfront* riftfront=NULL; 41 /*}}}*/ 42 /*RiftConstraints(int* pconverged, int* pnum_unstable_constraints,Loads* loads,int min_mechanical_constraints,int analysis_type){{{1*/ 43 void RiftConstraints(int* pconverged, int* pnum_unstable_constraints,Loads* loads,int min_mechanical_constraints,int analysis_type){ 44 45 int num_unstable_constraints=0; 46 int converged=0; 47 int potential; 48 49 RiftConstrain(&num_unstable_constraints,loads,analysis_type); 50 if(num_unstable_constraints==0)converged=1; 51 52 if(RiftIsFrozen(loads,analysis_type)){ 53 converged=1; 54 num_unstable_constraints=0; 55 } 56 else if(num_unstable_constraints<=min_mechanical_constraints){ 57 _printf_(" freezing constraints\n"); 58 RiftFreezeConstraints(loads,analysis_type); 59 } 60 61 /*Assign output pointers: */ 62 *pconverged=converged; 63 *pnum_unstable_constraints=num_unstable_constraints; 64 } 65 /*}}}*/ 66 /*RiftConstrain(int* pnum_unstable_constraints,Loads* loads,int analysis_type){{{1*/ 67 void RiftConstrain(int* pnum_unstable_constraints,Loads* loads,int analysis_type){ 68 69 int i; 70 71 /* generic object pointer: */ 72 Riftfront* riftfront=NULL; 73 Load* load=NULL; 160 74 161 75 int unstable; … … 168 82 if (RiftfrontEnum==loads->GetEnum(i)){ 169 83 170 riftfront=(Riftfront*)loads->GetObjectByOffset(i); 171 172 riftfront->PreConstrain(&unstable); 173 174 num_unstable_constraints+=unstable; 84 load=(Load*)loads->GetObjectByOffset(i); 85 if(load->InAnalysis(analysis_type)){ 86 87 riftfront=(Riftfront*)load; 88 89 riftfront->Constrain(&unstable); 90 91 num_unstable_constraints+=unstable; 92 } 175 93 } 176 94 } … … 186 104 187 105 } 188 189 int Constrain(int* pnum_unstable_constraints,Loads* loads){ 106 /*}}}*/ 107 /*RiftIsFrozen(Loads* loads,int analysis_type){{{1*/ 108 int RiftIsFrozen(Loads* loads,int analysis_type){ 109 110 int i; 111 112 /* generic object pointer: */ 113 Load* load=NULL; 114 Riftfront* riftfront=NULL; 115 int found=0; 116 int mpi_found=0; 117 118 /*Enforce constraints: */ 119 for (i=0;i<loads->Size();i++){ 120 121 if (RiftfrontEnum==loads->GetEnum(i)){ 122 123 load=(Load*)loads->GetObjectByOffset(i); 124 if(load->InAnalysis(analysis_type)){ 125 126 riftfront=(Riftfront*)load; 127 if (riftfront->IsFrozen()){ 128 found=1; 129 break; 130 } 131 } 132 } 133 } 134 135 /*Is there just one found? that would mean we have frozen! : */ 136 #ifdef _PARALLEL_ 137 MPI_Reduce (&found,&mpi_found,1,MPI_DOUBLE,MPI_MAX,0,MPI_COMM_WORLD ); 138 MPI_Bcast(&mpi_found,1,MPI_DOUBLE,0,MPI_COMM_WORLD); 139 found=mpi_found; 140 #endif 141 142 return found; 143 } 144 /*}}}*/ 145 /*RiftFreezeConstraints(Loads* loads,int analysis_type){{{1*/ 146 void RiftFreezeConstraints(Loads* loads,int analysis_type){ 147 148 int i; 149 150 /* generic object pointer: */ 151 Load* load=NULL; 152 Riftfront* riftfront=NULL; 153 154 /*Enforce constraints: */ 155 for (i=0;i<loads->Size();i++){ 156 157 if (RiftfrontEnum==loads->GetEnum(i)){ 158 159 load=(Load*)loads->GetObjectByOffset(i); 160 if(load->InAnalysis(analysis_type)){ 161 162 riftfront=(Riftfront*)load; 163 riftfront->FreezeConstraints(); 164 } 165 166 } 167 } 168 169 } 170 /*}}}*/ 171 172 /*diverse trials and errors: */ 173 /*RiftIsMaterialStable(Loads* loads){{{1*/ 174 int RiftIsMaterialStable(Loads* loads){ 175 176 int i; 177 178 Riftfront* riftfront=NULL; 179 int found=0; 180 int mpi_found=0; 181 182 /*go though loads, and if non-linearity of the material has converged, let all penalties know: */ 183 for (i=0;i<loads->Size();i++){ 184 185 if(RiftfrontEnum==loads->GetEnum(i)){ 186 187 riftfront=(Riftfront*)loads->GetObjectByOffset(i); 188 189 if (riftfront->IsMaterialStable()){ 190 found=1; 191 /*do not break! all penalties should get informed the non-linearity converged!*/ 192 } 193 } 194 } 195 196 #ifdef _PARALLEL_ 197 MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD ); 198 MPI_Bcast(&mpi_found,1,MPI_INT,0,MPI_COMM_WORLD); 199 found=mpi_found; 200 #endif 201 202 return found; 203 } 204 /*}}}*/ 205 /*RiftIsPreStable(Loads* loads){{{1*/ 206 int RiftIsPreStable(Loads* loads){ 207 208 209 int i; 210 211 Riftfront* riftfront=NULL; 212 int found=0; 213 int mpi_found=0; 214 215 /*go though loads, and figure out if one of the penpair loads is still not stable: */ 216 for (i=0;i<loads->Size();i++){ 217 218 if(RiftfrontEnum==loads->GetEnum(i)){ 219 220 riftfront=(Riftfront*)loads->GetObjectByOffset(i); 221 222 if (riftfront->PreStable()==0){ 223 found=1; 224 break; 225 } 226 } 227 } 228 229 #ifdef _PARALLEL_ 230 MPI_Reduce (&found,&mpi_found,1,MPI_INT,MPI_SUM,0,MPI_COMM_WORLD ); 231 MPI_Bcast(&mpi_found,1,MPI_INT,0,MPI_COMM_WORLD); 232 found=mpi_found; 233 #endif 234 235 if (found){ 236 /*We found an unstable constraint. : */ 237 return 0; 238 } 239 else{ 240 return 1; 241 } 242 } 243 /*}}}*/ 244 /*RiftSetPreStable(Loads* loads){{{1*/ 245 void RiftSetPreStable(Loads* loads){ 246 247 248 int i; 249 250 Riftfront* riftfront=NULL; 251 int found=0; 252 int mpi_found=0; 253 254 /*go though loads, and set loads to pre stable.:*/ 255 for (i=0;i<loads->Size();i++){ 256 257 if(RiftfrontEnum==loads->GetEnum(i)){ 258 259 riftfront=(Riftfront*)loads->GetObjectByOffset(i); 260 riftfront->SetPreStable(); 261 } 262 } 263 } 264 /*}}}*/ 265 /*RiftPreConstrain(int* pnum_unstable_constraints,Loads* loads){{{1*/ 266 void RiftPreConstrain(int* pnum_unstable_constraints,Loads* loads){ 190 267 191 268 int i; … … 205 282 riftfront=(Riftfront*)loads->GetObjectByOffset(i); 206 283 207 riftfront-> Constrain(&unstable);284 riftfront->PreConstrain(&unstable); 208 285 209 286 num_unstable_constraints+=unstable; … … 221 298 222 299 } 223 224 void FreezeConstraints(Loads* loads){ 225 226 int i; 227 228 /* generic object pointer: */ 229 Riftfront* riftfront=NULL; 230 231 /*Enforce constraints: */ 232 for (i=0;i<loads->Size();i++){ 233 234 if (RiftfrontEnum==loads->GetEnum(i)){ 235 236 riftfront=(Riftfront*)loads->GetObjectByOffset(i); 237 238 riftfront->FreezeConstraints(); 239 240 } 241 } 242 243 } 244 245 int IsFrozen(Loads* loads){ 246 247 int i; 248 249 /* generic object pointer: */ 250 Riftfront* riftfront=NULL; 251 int found=0; 252 int mpi_found=0; 253 254 /*Enforce constraints: */ 255 for (i=0;i<loads->Size();i++){ 256 257 if (RiftfrontEnum==loads->GetEnum(i)){ 258 259 riftfront=(Riftfront*)loads->GetObjectByOffset(i); 260 if (riftfront->IsFrozen()){ 261 found=1; 262 break; 263 } 264 } 265 } 266 267 /*Is there just one found? that would mean we have frozen! : */ 268 #ifdef _PARALLEL_ 269 MPI_Reduce (&found,&mpi_found,1,MPI_DOUBLE,MPI_MAX,0,MPI_COMM_WORLD ); 270 MPI_Bcast(&mpi_found,1,MPI_DOUBLE,0,MPI_COMM_WORLD); 271 found=mpi_found; 272 #endif 273 274 return found; 275 } 276 277 int MaxPenetrationInInputs(Loads* loads){ 300 /*}}}*/ 301 /*RiftMaxPenetrationInInputs(Loads* loads){{{1*/ 302 void RiftMaxPenetrationInInputs(Loads* loads){ 278 303 279 304 int i; … … 315 340 } 316 341 } 317 318 int PotentialUnstableConstraints(Loads* loads){ 342 /*}}}*/ 343 /*RiftPotentialUnstableConstraints(Loads* loads){{{1*/ 344 int RiftPotentialUnstableConstraints(Loads* loads){ 319 345 320 346 int i; … … 349 375 return num_unstable_constraints; 350 376 } 377 /*}}}*/
Note:
See TracChangeset
for help on using the changeset viewer.