source: issm/trunk/src/c/modules/ConstraintsStatex/ConstraintsStatex.cpp@ 25836

Last change on this file since 25836 was 25836, checked in by Mathieu Morlighem, 4 years ago

merged trunk-jpl and trunk for revision 25834

File size: 1.9 KB
Line 
1/*!\file ConstraintsStatex
2 * \brief: set up penalty constraints on loads
3 */
4
5#include "./ConstraintsStatex.h"
6#include "./ConstraintsStateLocal.h"
7#include "../../shared/shared.h"
8#include "../../toolkits/toolkits.h"
9
10void ConstraintsStatex(int* pconverged, int* pnum_unstable_constraints,FemModel* femmodel){
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
19 /*output: */
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;
25 int analysis_type;
26
27 /*Display message*/
28 if(VerboseModule()) _printf0_(" Constraining penalties\n");
29
30 /*recover parameters: */
31 femmodel->parameters->FindParam(&min_mechanical_constraints,StressbalanceRiftPenaltyThresholdEnum);
32 femmodel->parameters->FindParam(&analysis_type,AnalysisTypeEnum);
33
34 /*Rift penalties first*/
35 if(femmodel->loads->numrifts){
36 RiftConstraintsState(&converged,&num_unstable_constraints,femmodel->loads,min_mechanical_constraints,analysis_type);
37 }
38
39 /*Deal with pengrid*/
40 if(femmodel->loads->numpenalties){
41 for(Object* & object : femmodel->loads->objects){
42 Load* load=(Load*)object;
43 if(load->ObjectEnum()==PengridEnum){
44 Pengrid* pengrid=(Pengrid*)load;
45 pengrid->ConstraintActivate(&unstable);
46 num_unstable_constraints += unstable;
47 }
48 }
49 }
50
51 ISSM_MPI_Reduce(&num_unstable_constraints,&sum_num_unstable_constraints,1,ISSM_MPI_INT,ISSM_MPI_SUM,0,IssmComm::GetComm() );
52 ISSM_MPI_Bcast(&sum_num_unstable_constraints,1,ISSM_MPI_INT,0,IssmComm::GetComm());
53 num_unstable_constraints=sum_num_unstable_constraints;
54
55 /*Have we converged? : */
56 if(num_unstable_constraints) converged=0;
57
58 /*Assign output pointers: */
59 *pconverged = converged;
60 *pnum_unstable_constraints = num_unstable_constraints;
61}
Note: See TracBrowser for help on using the repository browser.