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 |
|
---|
10 | void ConstraintsStatex(int* pconverged, int* pnum_unstable_constraints,FemModel* femmodel){
|
---|
11 |
|
---|
12 | /*output: */
|
---|
13 | int converged = 1;
|
---|
14 | int num_unstable_constraints = 0;
|
---|
15 | int min_mechanical_constraints = 0;
|
---|
16 | int unstable = 0;
|
---|
17 | int sum_num_unstable_constraints = 0;
|
---|
18 | int analysis_type;
|
---|
19 |
|
---|
20 | /*Display message*/
|
---|
21 | if(VerboseModule()) _printf0_(" Constraining penalties\n");
|
---|
22 |
|
---|
23 | /*recover parameters: */
|
---|
24 | femmodel->parameters->FindParam(&min_mechanical_constraints,StressbalanceRiftPenaltyThresholdEnum);
|
---|
25 | femmodel->parameters->FindParam(&analysis_type,AnalysisTypeEnum);
|
---|
26 |
|
---|
27 | /*Rift penalties first*/
|
---|
28 | if(RiftIsPresent(femmodel->loads,analysis_type)){
|
---|
29 | RiftConstraintsState(&converged,&num_unstable_constraints,femmodel->loads,min_mechanical_constraints,analysis_type);
|
---|
30 | }
|
---|
31 |
|
---|
32 | /*Deal with pengrid*/
|
---|
33 | for(int i=0;i<femmodel->loads->Size();i++){
|
---|
34 | Load* load=(Load*)femmodel->loads->GetObjectByOffset(i);
|
---|
35 | if(load->InAnalysis(analysis_type)){
|
---|
36 | if(load->ObjectEnum()==PengridEnum){
|
---|
37 | Pengrid* pengrid=(Pengrid*)load;
|
---|
38 | pengrid->ConstraintActivate(&unstable);
|
---|
39 | num_unstable_constraints += unstable;
|
---|
40 | }
|
---|
41 | }
|
---|
42 | }
|
---|
43 | ISSM_MPI_Reduce(&num_unstable_constraints,&sum_num_unstable_constraints,1,ISSM_MPI_INT,ISSM_MPI_SUM,0,IssmComm::GetComm() );
|
---|
44 | ISSM_MPI_Bcast(&sum_num_unstable_constraints,1,ISSM_MPI_INT,0,IssmComm::GetComm());
|
---|
45 | num_unstable_constraints=sum_num_unstable_constraints;
|
---|
46 |
|
---|
47 | /*Have we converged? : */
|
---|
48 | if(num_unstable_constraints) converged=0;
|
---|
49 |
|
---|
50 | /*Assign output pointers: */
|
---|
51 | *pconverged = converged;
|
---|
52 | *pnum_unstable_constraints = num_unstable_constraints;
|
---|
53 | }
|
---|