Changeset 15055


Ignore:
Timestamp:
05/21/13 10:09:52 (12 years ago)
Author:
Mathieu Morlighem
Message:

CHG: moved convergence stuff to solutionsequences (solutionsequences should not include analyses.h)

Location:
issm/trunk-jpl/src/c
Files:
3 deleted
9 edited
1 moved

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/Makefile.am

    r15053 r15055  
    321321                                        ./modules/InputConvergencex/InputConvergencex.cpp\
    322322                                        ./modules/InputConvergencex/InputConvergencex.h\
    323                                         ./analyses/convergence.cpp\
    324323                                        ./analyses/ProcessArguments.cpp\
    325324                                        ./analyses/ResetBoundaryConditions.cpp\
     
    333332                                        ./solutionsequences/solutionsequence_nonlinear.cpp\
    334333                                        ./solutionsequences/solutionsequence_newton.cpp\
     334                                        ./solutionsequences/convergence.cpp\
    335335                                        ./classes/Options/Options.h\
    336336                                        ./classes/Options/Options.cpp\
     
    361361#}}}
    362362#Steadystate sources  {{{
    363 steadystate_sources = ./analyses/steadystate_core.cpp\
    364                                                          ./analyses/steadystateconvergence.cpp
     363steadystate_sources = ./analyses/steadystate_core.cpp
    365364#}}}
    366365#Prognostic sources  {{{
     
    436435                                          ./analyses/control_core.cpp\
    437436                                          ./analyses/controltao_core.cpp\
    438                                           ./analyses/controlrestart.cpp\
    439                                           ./analyses/controlconvergence.cpp\
    440437                                          ./analyses/objectivefunction.cpp\
    441438                                          ./analyses/gradient_core.cpp\
  • issm/trunk-jpl/src/c/analyses/CMakeLists.txt

    r14985 r15055  
    2323# }}}
    2424# STEADYSTATE_SOURCES {{{
    25 set(STEADYSTATE_SOURCES $ENV{ISSM_DIR}/src/c/solutions/steadystate_core.cpp
    26                   $ENV{ISSM_DIR}/src/c/solutions/steadystateconvergence.cpp PARENT_SCOPE)
     25set(STEADYSTATE_SOURCES $ENV{ISSM_DIR}/src/c/solutions/steadystate_core.cpp PARENT_SCOPE)
    2726# }}}
    2827# PROGNOSTIC_SOURCES {{{
  • issm/trunk-jpl/src/c/analyses/analyses.h

    r14985 r15055  
    3939IssmDouble objectivefunction(IssmDouble search_scalar,OptArgs* optargs);
    4040
    41 //convergence:
    42 void convergence(bool* pconverged, Matrix<IssmDouble>* K_ff,Vector<IssmDouble>* p_f,Vector<IssmDouble>* u_f,Vector<IssmDouble>* u_f_old,Parameters* parameters);
    43 bool controlconvergence(IssmDouble J,IssmDouble tol_cm);
    44 bool steadystateconvergence(FemModel* femmodel);
    45 
    4641//optimization
    4742int GradJSearch(IssmDouble* search_vector,FemModel* femmodel,int step);
     
    5045void ProcessArguments(int* solution,char** pbinname,char** poutbinname,char** ptoolkitsname,char** plockname,char** prootpath,int argc,char **argv);
    5146void WriteLockFile(char* filename);
    52 void controlrestart(FemModel* femmodel,IssmDouble* J);
    5347void ResetBoundaryConditions(FemModel* femmodel, int analysis_type);
    5448COMM EnvironmentInit(int argc,char** argv);
  • issm/trunk-jpl/src/c/analyses/control_core.cpp

    r15001 r15055  
    1010#include "../solutionsequences/solutionsequences.h"
    1111
     12/*Local prototypes*/
     13bool controlconvergence(IssmDouble J, IssmDouble tol_cm);
     14
    1215void control_core(FemModel* femmodel){
    1316
    14         int     i,n;
     17        int     i;
    1518
    1619        /*parameters: */
    17         int     num_controls,num_responses;
    18         int     nsteps;
    19         IssmDouble  tol_cm;
    20         bool    cm_gradient;
    21         int     dim;
    22         int     solution_type;
    23         bool    isstokes;
    24         bool    dakota_analysis=false;
     20        int        num_controls,num_responses;
     21        int        nsteps;
     22        IssmDouble tol_cm;
     23        bool       cm_gradient;
     24        int        dim;
     25        int        solution_type;
     26        bool       isstokes;
     27        bool       dakota_analysis = false;
    2528
    26         int*    control_type = NULL;
    27         IssmDouble* responses=NULL;
    28         int*    step_responses=NULL;
    29         IssmDouble* maxiter=NULL;
    30         IssmDouble* cm_jump=NULL;
     29        int        *control_type  = NULL;
     30        IssmDouble *responses      = NULL;
     31        int        *step_responses = NULL;
     32        IssmDouble *maxiter        = NULL;
     33        IssmDouble *cm_jump        = NULL;
    3134
    3235        /*intermediary: */
    33         IssmDouble  search_scalar=1;
    34         OptArgs optargs;
    35         OptPars optpars;
     36        IssmDouble search_scalar = 1;
     37        OptArgs    optargs;
     38        OptPars    optpars;
    3639
    3740        /*Solution and Adjoint core pointer*/
    38         void (*solutioncore)(FemModel*)=NULL;
    39         void (*adjointcore)(FemModel*)=NULL;
     41        void (*solutioncore)(FemModel*) = NULL;
     42        void (*adjointcore)(FemModel*)  = NULL;
    4043
    4144        /*output: */
     
    7578
    7679        /*Start looping: */
    77         for(n=0;n<nsteps;n++){
     80        for(int n=0;n<nsteps;n++){
    7881
    7982                /*Display info*/
     
    115118                #ifdef _HAVE_ADOLC_
    116119                IssmPDouble* J_passive=xNew<IssmPDouble>(nsteps);
    117                 for(int i=0;i<nsteps;i++)J_passive[i]=reCast<IssmPDouble>(J[i]);
     120                for(i=0;i<nsteps;i++) J_passive[i]=reCast<IssmPDouble>(J[i]);
    118121                femmodel->results->AddObject(new GenericExternalResult<IssmPDouble*>(femmodel->results->Size()+1,JEnum,J_passive,nsteps,1,1,0));
    119122                xDelete<IssmPDouble>(J_passive);
     
    132135        xDelete<IssmDouble>(J);
    133136}
     137bool controlconvergence(IssmDouble J, IssmDouble tol_cm){
     138
     139        bool converged=false;
     140
     141        /*Has convergence been reached?*/
     142        if (!xIsNan<IssmDouble>(tol_cm) && J<tol_cm){
     143                converged=true;
     144                if(VerboseConvergence()) _pprintString_("      Convergence criterion reached: J = " << J << " < " << tol_cm);
     145        }
     146
     147        return converged;
     148}
  • issm/trunk-jpl/src/c/analyses/steadystate_core.cpp

    r15001 r15055  
    1414#include "../modules/modules.h"
    1515#include "../solutionsequences/solutionsequences.h"
     16
     17/*Local prototypes*/
     18bool steadystateconvergence(FemModel* femmodel);
    1619
    1720void steadystate_core(FemModel* femmodel){
     
    9194        xDelete<int>(requested_outputs);
    9295}
     96bool steadystateconvergence(FemModel* femmodel){
     97
     98        /*output: */
     99        bool converged=false;
     100        bool velocity_converged=false;
     101        bool temperature_converged=false;
     102
     103        /*intermediary: */
     104        int velocityenums[8]={VxEnum,VxPicardEnum,VyEnum,VyPicardEnum,VzEnum,VzPicardEnum,PressureEnum,PressurePicardEnum}; //pairs of enums (new and old) on which to carry out the converence tests
     105        int temperatureenums[2]={TemperatureEnum,TemperatureOldEnum};
     106        int convergencecriterion[1]={RelativeEnum}; //criterions for convergence, RelativeEnum or AbsoluteEnum
     107        IssmDouble convergencecriterionvalue[1]; //value of criterion to be respected
     108
     109        /*retrieve parameters: */
     110        femmodel->parameters->FindParam(&convergencecriterionvalue[0],SteadystateReltolEnum);
     111
     112        /*figure out convergence at the input level, because we don't have the solution vectors!: */
     113        velocity_converged=InputConvergencex(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,&velocityenums[0],8,&convergencecriterion[0],&convergencecriterionvalue[0],1);
     114        temperature_converged=InputConvergencex(femmodel->elements,femmodel->nodes,femmodel->vertices,femmodel->loads,femmodel->materials,femmodel->parameters,&temperatureenums[0],2,&convergencecriterion[0],&convergencecriterionvalue[0],1);
     115
     116        if(velocity_converged && temperature_converged) converged=true;
     117
     118        /*return: */
     119        return converged;
     120}
  • issm/trunk-jpl/src/c/solutionsequences/solutionsequence_newton.cpp

    r15002 r15055  
    33 */
    44
     5#include "./solutionsequences.h"
    56#include "../toolkits/toolkits.h"
    67#include "../classes/classes.h"
    78#include "../shared/shared.h"
    89#include "../modules/modules.h"
    9 #include "../analyses/analyses.h"
    1010
    1111void solutionsequence_newton(FemModel* femmodel){
  • issm/trunk-jpl/src/c/solutionsequences/solutionsequence_nonlinear.cpp

    r15002 r15055  
    33 */
    44
     5#include "./solutionsequences.h"
    56#include "../toolkits/toolkits.h"
    67#include "../classes/classes.h"
    78#include "../shared/shared.h"
    89#include "../modules/modules.h"
    9 #include "../analyses/analyses.h"
    1010
    1111void solutionsequence_nonlinear(FemModel* femmodel,bool conserve_loads){
  • issm/trunk-jpl/src/c/solutionsequences/solutionsequence_stokescoupling_nonlinear.cpp

    r15002 r15055  
    33 */
    44
     5#include "./solutionsequences.h"
    56#include "../toolkits/toolkits.h"
    67#include "../classes/classes.h"
    78#include "../shared/shared.h"
    89#include "../modules/modules.h"
    9 #include "../analyses/analyses.h"
    1010
    1111void solutionsequence_stokescoupling_nonlinear(FemModel* femmodel,bool conserve_loads){
  • issm/trunk-jpl/src/c/solutionsequences/solutionsequences.h

    r14992 r15055  
    66#define _SOLUTION_SEQUENCES_H_
    77
    8 struct OptArgs;
    98class FemModel;
     9class Parameters;
     10template <class doubletype> class Matrix;
     11template <class doubletype> class Vector;
     12#include "../shared/Numerics/types.h"
    1013
    1114void solutionsequence_thermal_nonlinear(FemModel* femmodel);
     
    1720void solutionsequence_adjoint_linear(FemModel* femmodel);
    1821
     22/*convergence*/
     23void convergence(bool* pconverged, Matrix<IssmDouble>* K_ff,Vector<IssmDouble>* p_f,Vector<IssmDouble>* u_f,Vector<IssmDouble>* u_f_old,Parameters* parameters);
     24
    1925#endif
Note: See TracChangeset for help on using the changeset viewer.