[4055] | 1 | /*!\file InputConvergencex
|
---|
| 2 | */
|
---|
| 3 |
|
---|
| 4 | #include "./InputConvergencex.h"
|
---|
| 5 | #include "../../shared/shared.h"
|
---|
| 6 | #include "../../include/include.h"
|
---|
[9761] | 7 | #include "../../io/io.h"
|
---|
[4055] | 8 | #include "../../toolkits/toolkits.h"
|
---|
| 9 | #include "../../EnumDefinitions/EnumDefinitions.h"
|
---|
| 10 |
|
---|
[12706] | 11 | bool InputConvergencex(Elements* elements,Nodes* nodes,Vertices* vertices,Loads* loads,Materials* materials,Parameters* parameters,int* enums, int num_enums, int* criterionenums, IssmDouble* criterionvalues,int num_criterionenums){
|
---|
[4055] | 12 |
|
---|
| 13 | /*intermediary:*/
|
---|
[12706] | 14 | int i;
|
---|
| 15 | bool converged;
|
---|
| 16 | int num_notconverged = 0;
|
---|
| 17 | int total_notconverged;
|
---|
| 18 | IssmDouble *eps = NULL;
|
---|
| 19 | Element *element = NULL;
|
---|
[4055] | 20 |
|
---|
| 21 | /*allocate dynamic memory: */
|
---|
[12706] | 22 | eps=xNew<IssmDouble>(num_criterionenums);
|
---|
[4055] | 23 |
|
---|
| 24 | /*Go through elements, and ask them to do the job: */
|
---|
| 25 | for(i=0;i<elements->Size();i++){
|
---|
[13975] | 26 | element=dynamic_cast<Element*>(elements->GetObjectByOffset(i));
|
---|
[4879] | 27 | converged=element->InputConvergence(eps,enums,num_enums,criterionenums,criterionvalues,num_criterionenums);
|
---|
| 28 | if(!converged) num_notconverged++;
|
---|
[4055] | 29 | }
|
---|
| 30 |
|
---|
| 31 | /*In parallel, we need to gather the converged status: */
|
---|
[12330] | 32 | #ifdef _HAVE_MPI_
|
---|
[13975] | 33 | MPI_Allreduce ( (void*)&num_notconverged,(void*)&total_notconverged,1,MPI_INT,MPI_SUM,IssmComm::GetComm());
|
---|
[4890] | 34 | num_notconverged=total_notconverged;
|
---|
[4055] | 35 | #endif
|
---|
[12706] | 36 | if(VerboseConvergence()) _pprintLine_(" #elements above convergence criterion = " << num_notconverged);
|
---|
[4055] | 37 |
|
---|
| 38 | /*Free ressources:*/
|
---|
[12706] | 39 | xDelete<IssmDouble>(eps);
|
---|
[4055] | 40 |
|
---|
| 41 | /*return: */
|
---|
[4890] | 42 | if (num_notconverged){
|
---|
[4879] | 43 | return false;}
|
---|
| 44 | else{
|
---|
[4780] | 45 | return true;}
|
---|
[4055] | 46 | }
|
---|