Changeset 14975


Ignore:
Timestamp:
05/09/13 01:46:02 (12 years ago)
Author:
Eric.Larour
Message:

CHG: cleanup the shared/Numerics directory. Took out the IsInputConverged, ToolkitsOptionsFromAnalysis and OptionsFromAnalysis
and put them into the Container/ Inputs and Parameters files. This uncovered a bunch of cyclical dependencies that needed fixing.

Location:
issm/trunk-jpl/src/c
Files:
3 deleted
40 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/Container/Constraints.h

    r14960 r14975  
    44/*forward declarations */
    55#include "./DataSet.h"
    6 class Materials;
    7 class Parameters;
    8 class Elements;
    9 class Vertices;
    10 class Loads;
    11 class Nodes;
    12 class Inputs;
    136
    147#include "../shared/Enum/Enum.h"
  • issm/trunk-jpl/src/c/Container/DataSet.h

    r14965 r14975  
    99/*forward declarations */
    1010class Object;
    11 class Elements;
    12 class Loads;
    13 class Nodes;
    14 class Vertices;
    15 class Materials;
    16 class Parameters;
    17 class Patch;
    1811class Results;
    19 class Patch;
    2012
    2113/*! \brief Declaration of DataSet class
  • issm/trunk-jpl/src/c/Container/Elements.cpp

    r14960 r14975  
    1212
    1313#include "./Elements.h"
     14#include "./Results.h"
    1415#include "./Parameters.h"
    1516#include "../classes/classes.h"
  • issm/trunk-jpl/src/c/Container/Elements.h

    r14953 r14975  
    66class Materials;
    77class Parameters;
    8 class Elements;
    98class Vertices;
    109class Loads;
    1110class Nodes;
    12 class Inputs;
     11class Patch;
    1312
    1413/*! \brief Declaration of Elements class
  • issm/trunk-jpl/src/c/Container/Inputs.cpp

    r14960 r14975  
    426426}
    427427/*}}}*/
     428
     429/*Methods relating to inputs: */
     430void IsInputConverged(IssmDouble* peps, Input** new_inputs,Input** old_inputs,int num_inputs,int criterion_enum){ /*{{{*/
     431 
     432        /*figure out convergence at the input level.
     433          We are given a list of inputs, new and old, and a criterion, and using the
     434          inputs, we return the value of the criterion test, which will be used at the
     435          solution level to determine convergence.
     436          */
     437
     438        int i,j;
     439
     440        /*output: */
     441        IssmDouble eps;
     442
     443        /*intermediary: */
     444        IssmDouble *newvalues     = NULL;
     445        IssmDouble *oldvalues     = NULL;
     446        int     num_values;
     447        IssmDouble  ndu        = 0;
     448        IssmDouble  nu         = 0;
     449
     450        if(criterion_enum==RelativeEnum){
     451
     452                /*conpute ndu/du (where u could be velocity, pressure, temperature, etc ...): */
     453                for(i=0;i<num_inputs;i++){
     454
     455                        /*in debugging mode, check that the inputs are of the same type*/
     456                        _assert_(new_inputs[i]->ObjectEnum()==old_inputs[i]->ObjectEnum());
     457
     458                        /*Get pointers*/
     459                        new_inputs[i]->GetValuesPtr(&newvalues,&num_values);
     460                        old_inputs[i]->GetValuesPtr(&oldvalues,&num_values);
     461                        for(j=0;j<num_values;j++){
     462                                ndu+=pow(newvalues[j]-oldvalues[j],2);
     463                                nu+=pow(oldvalues[j],2);
     464                        }
     465                }
     466
     467                /*take square root: */
     468                ndu=sqrt(ndu);
     469                nu=sqrt(nu);
     470
     471                /*now, compute eps: */
     472                if(reCast<bool>(nu))eps=ndu/nu;
     473                else eps=0;
     474        }
     475        else _error_("convergence criterion " << EnumToStringx(criterion_enum) << " not supported yet!");
     476
     477        /*Assign output pointers:*/
     478        *peps=eps;
     479}
     480/*}}}*/
  • issm/trunk-jpl/src/c/Container/Inputs.h

    r14953 r14975  
    55class Parameters;
    66class Input;
     7
    78#include "./DataSet.h"
    89#include "../shared/Numerics/types.h"
     
    4243};
    4344
     45/*Methods relating to inputs: */
     46void IsInputConverged(IssmDouble* peps, Input** new_inputs,Input** old_inputs,int num_inputs,int criterion_enum);
     47
    4448#endif //ifndef _INPUTS_H_
  • issm/trunk-jpl/src/c/Container/Loads.cpp

    r14960 r14975  
    1616#include <iostream>
    1717
    18 #include "./DataSet.h"
     18#include "./Loads.h"
    1919#include "../shared/shared.h"
    2020#include "../shared/Enum/Enum.h"
  • issm/trunk-jpl/src/c/Container/Loads.h

    r14476 r14975  
    33
    44/*forward declarations */
     5#include "./DataSet.h"
    56class Materials;
    67class Parameters;
    78class Elements;
    89class Vertices;
    9 class Loads;
    1010class Nodes;
    11 class DataSet;
    12 class Inputs;
    1311
    1412/*!\brief Declaration of Loads class.
  • issm/trunk-jpl/src/c/Container/Materials.h

    r14953 r14975  
    99class Loads;
    1010class Nodes;
    11 class Inputs;
    1211
    1312/*! \brief Declaration of Materials class.
  • issm/trunk-jpl/src/c/Container/Nodes.h

    r14953 r14975  
    33
    44#include "./DataSet.h"
     5class Parameters;
     6class Elements;
     7class Vertices;
     8class Loads;
     9class Nodes;
     10class Materials;
     11
    512
    613/*!\brief Declaration of Nodes class.
  • issm/trunk-jpl/src/c/Container/Options.cpp

    r14960 r14975  
    1616
    1717#include "./DataSet.h"
     18#include "./Options.h"
    1819#include "../shared/shared.h"
    1920#include "../shared/io/io.h"
  • issm/trunk-jpl/src/c/Container/Parameters.cpp

    r14960 r14975  
    1616#include <iostream>
    1717
    18 #include "./DataSet.h"
     18#include "./Parameters.h"
    1919#include "../shared/shared.h"
    2020#include "../shared/Enum/Enum.h"
     
    490490}
    491491/*}}}*/
     492
     493/*Methods relating to parameters: */
     494char* OptionsFromAnalysis(Parameters* parameters,int analysis_type){ /*{{{*/
     495
     496        /* figure out ISSM options for current analysis, return a string. */
     497
     498        /*output: */
     499        char*   outstring=NULL;
     500
     501        /*intermediary: */
     502        int          dummy;
     503        IssmDouble  *analyses    = NULL;
     504        char       **strings     = NULL;
     505        char        *string      = NULL;
     506        int          numanalyses;
     507        int          found       = -1;
     508        int          i;
     509
     510        numanalyses=0;
     511        parameters->FindParam(&strings,&numanalyses,ToolkitsOptionsStringsEnum);
     512
     513        parameters->FindParam(&analyses,&dummy,ToolkitsOptionsAnalysesEnum);
     514
     515        if(numanalyses==0)return NULL; //we did not find petsc options, don't bother.
     516
     517        /*ok, go through analyses and figure out if it corresponds to our analysis_type: */
     518        for(i=0;i<numanalyses;i++){
     519                if(analyses[i]==analysis_type){
     520                        found=i;
     521                        break;
     522                }
     523        }
     524        if(found==-1){
     525                /*still haven't found a list of petsc options, go find the default one, for analysis type NoneAnalysisEnum: */
     526                for(i=0;i<numanalyses;i++){
     527                        if(analyses[i]==DefaultAnalysisEnum){
     528                                found=i;
     529                                break;
     530                        }
     531                }
     532        }
     533        if (found==-1){
     534                _error_("could find neither a default analysis nor analysis " << EnumToStringx(analysis_type));
     535        }
     536
     537        /*ok, grab the option string: */
     538        outstring=xNew<char>(strlen(strings[found])+1);
     539        strcpy(outstring,strings[found]);
     540
     541        /*Free ressources*/
     542        xDelete<IssmDouble>(analyses);
     543        for(i=0;i<numanalyses;i++){
     544                string=strings[i];
     545                xDelete<char>(string);
     546        }
     547        xDelete<char*>(strings);
     548        return outstring;
     549}
     550/*}}}*/
     551void ToolkitsOptionsFromAnalysis(Parameters* parameters,int analysis_type){ /*{{{*/
     552
     553        /*!\file:  ToolkitsOptionsFromAnalysis.cpp
     554         * \brief: for each analysis, setup the issmoptions string.
     555         * This is mainly for the case where we run our toolkits using petsc. In this case, we need to
     556         * plug our toolkits options directly into the petsc options database. This is the case for each analysis type
     557         * and parameters
     558         */
     559
     560
     561        char* options=NULL;
     562
     563        /*Recover first the options string for this analysis: */
     564        options=OptionsFromAnalysis(parameters,analysis_type);
     565
     566        /*Initialize our Toolkit Options: */
     567        ToolkitOptions::Init(options);
     568
     569        #ifdef _HAVE_PETSC_
     570                /*In case we are using PETSC, we do not rely on issmoptions. Instead, we dump issmoptions into the Petsc
     571                 * options database: */
     572
     573                #if _PETSC_MAJOR_ == 2
     574                PetscOptionsDestroy();
     575                PetscOptionsCreate();
     576                //PetscOptionsCheckInitial_Private();
     577                //PetscOptionsCheckInitial_Components();
     578                PetscOptionsSetFromOptions();
     579                PetscOptionsInsertMultipleString(options); //our patch
     580                #else
     581                PetscOptionsSetFromOptions();
     582                PetscOptionsClear();
     583                //PetscOptionsSetFromOptions();
     584                PetscOptionsInsertMultipleString(options); //our patch
     585                #endif
     586
     587        #endif
     588
     589        xDelete<char>(options);
     590}
     591/*}}}*/
  • issm/trunk-jpl/src/c/Container/Parameters.h

    r14957 r14975  
    66template <class doublematrix> class Matrix;
    77template <class doubletype> class Vector;
    8 class Materials;
    9 class Parameters;
    10 class Elements;
    11 class Vertices;
    12 class Loads;
    13 class Nodes;
    14 class Inputs;
    158#include "./DataSet.h"
    169#include "../shared/Numerics/types.h"
     
    6558};
    6659
     60/*Methods relating to parameters: */
     61char       *OptionsFromAnalysis(Parameters *parameters,int analysis_type);
     62void        ToolkitsOptionsFromAnalysis(Parameters* parameters,int analysis_type);
     63
     64
    6765#endif //ifndef _PARAMETERS_H_
  • issm/trunk-jpl/src/c/Container/Results.h

    r14953 r14975  
    55
    66/*forward declarations */
    7 class Materials;
    87class Parameters;
    9 class Elements;
    10 class Vertices;
    11 class Loads;
    12 class Nodes;
    13 class Inputs;
    148
    159/*!\brief Declaration of Results class.
  • issm/trunk-jpl/src/c/Container/Vertices.cpp

    r14960 r14975  
    1616#include <iostream>
    1717
    18 #include "./DataSet.h"
     18#include "./Vertices.h"
    1919#include "../shared/shared.h"
    2020#include "../shared/Enum/Enum.h"
  • issm/trunk-jpl/src/c/Container/Vertices.h

    r14476 r14975  
    33
    44/*forward declarations */
    5 class Materials;
    6 class Elements;
    7 class Vertices;
    8 class Loads;
    9 class Nodes;
    10 class DataSet;
    11 class Inputs;
     5#include "./DataSet.h"
     6#include "../shared/Numerics/types.h"
    127
    138/*!\brief Declaration of Vertices class.
  • issm/trunk-jpl/src/c/Makefile.am

    r14960 r14975  
    200200                                        ./shared/Numerics/Verbosity.h\
    201201                                        ./shared/Numerics/Verbosity.cpp\
    202                                         ./shared/Numerics/IsInputConverged.cpp\
    203202                                        ./shared/Numerics/GaussPoints.h\
    204203                                        ./shared/Numerics/GaussPoints.cpp\
     
    210209                                        ./shared/Numerics/XZvectorsToCoordinateSystem.cpp\
    211210                                        ./shared/Numerics/UnitConversion.cpp\
    212                                         ./shared/Numerics/OptionsFromAnalysis.cpp\
    213                                         ./shared/Numerics/ToolkitsOptionsFromAnalysis.cpp\
    214211                                        ./shared/Exceptions/exceptions.h\
    215212                                        ./shared/Exceptions/Exceptions.cpp\
  • issm/trunk-jpl/src/c/classes/IoModel.cpp

    r14950 r14975  
    1818#include "../shared/io/io.h"
    1919#include "../Container/Parameters.h"
     20#include "../Container/Elements.h"
    2021#include "../shared/shared.h"
    2122
  • issm/trunk-jpl/src/c/classes/kriging/ExponentialVariogram.cpp

    r14960 r14975  
    1212#include <string.h>
    1313#include "../objects/objects.h"
    14 #include "../../shared/Enum/Enum.h"
    1514#include "../../shared/shared.h"
     15#include "../../Container/Container.h"
    1616
    1717/*ExponentialVariogram constructors and destructor*/
  • issm/trunk-jpl/src/c/classes/kriging/GaussianVariogram.cpp

    r14960 r14975  
    1212#include <string.h>
    1313#include "../objects/objects.h"
    14 #include "../../shared/Enum/Enum.h"
    1514#include "../../shared/shared.h"
     15#include "../../Container/Container.h"
    1616
    1717/*GaussianVariogram constructors and destructor*/
  • issm/trunk-jpl/src/c/classes/kriging/PowerVariogram.cpp

    r14960 r14975  
    1212#include <string.h>
    1313#include "../objects/objects.h"
    14 #include "../../shared/Enum/Enum.h"
    1514#include "../../shared/shared.h"
     15#include "../../Container/Container.h"
    1616
    1717/*PowerVariogram constructors and destructor*/
  • issm/trunk-jpl/src/c/classes/kriging/SphericalVariogram.cpp

    r14960 r14975  
    1212#include <string.h>
    1313#include "../objects/objects.h"
    14 #include "../../shared/Enum/Enum.h"
    1514#include "../../shared/shared.h"
     15#include "../../Container/Container.h"
    1616
    1717/*SphericalVariogram constructors and destructor*/
  • issm/trunk-jpl/src/c/classes/objects/DependentObject.h

    r13699 r14975  
    1111/*}}}*/
    1212
    13 class Elements;
    14 class Nodes;
    15 class Vertices;
    16 class Loads;
    17 class Materials;
    18 class Parameters;
    1913class FemModel;
    2014
  • issm/trunk-jpl/src/c/classes/objects/ElementResults/ElementResult.h

    r13623 r14975  
    99/*{{{*/
    1010#include "../Object.h"
     11class Patch;
    1112/*}}}*/
    1213
  • issm/trunk-jpl/src/c/classes/objects/Loads/Icefront.cpp

    r14960 r14975  
    1616#include "../../../shared/Enum/Enum.h"
    1717#include "../../../shared/shared.h"
     18#include "../../../Container/Inputs.h"
     19#include "../../../Container/Parameters.h"
    1820/*}}}*/
    1921
     
    218220        /*Take care of hooking up all objects for this element, ie links the objects in the hooks to their respective
    219221         * datasets, using internal ids and offsets hidden in hooks: */
    220         hnodes->configure(nodesin);
    221         hvertices->configure(verticesin);
    222         helement->configure(elementsin);
    223         hmatpar->configure(materialsin);
     222        hnodes->configure((DataSet*)nodesin);
     223        hvertices->configure((DataSet*)verticesin);
     224        helement->configure((DataSet*)elementsin);
     225        hmatpar->configure((DataSet*)materialsin);
    224226
    225227        /*Initialize hooked fields*/
  • issm/trunk-jpl/src/c/classes/objects/Loads/Icefront.h

    r14761 r14975  
    1717class IoModel;
    1818class ElementVector;
     19class Vertex;
    1920/*}}}*/
    2021
  • issm/trunk-jpl/src/c/classes/objects/Loads/Load.h

    r14951 r14975  
    1010/*Headers:*/
    1111/*{{{*/
    12 class Object;
     12class Node;
    1313template <class doublematrix> class Matrix;
    1414template <class doubletype> class Vector;
     15class Elements;
     16class Loads;
     17class Nodes;
     18class Vertices;
     19class Materials;
     20class Parameters;
    1521
    1622#include "../Object.h"
    1723#include "../../Update.h"
    18 #include "../../../toolkits/toolkits.h"
    19 #include "../../../Container/Container.h"
     24
    2025/*}}}*/
    2126
  • issm/trunk-jpl/src/c/classes/objects/Loads/Numericalflux.cpp

    r14960 r14975  
    1616#include "../../../shared/shared.h"
    1717#include "../../classes.h"
     18#include "../../../Container/Inputs.h"
     19#include "../../../Container/Parameters.h"
    1820/*}}}*/
    1921
     
    238240        /*Take care of hooking up all objects for this element, ie links the objects in the hooks to their respective
    239241         * datasets, using internal ids and offsets hidden in hooks: */
    240         hnodes->configure(nodesin);
    241         hvertices->configure(verticesin);
    242         helement->configure(elementsin);
     242        hnodes->configure((DataSet*)nodesin);
     243        hvertices->configure((DataSet*)verticesin);
     244        helement->configure((DataSet*)elementsin);
    243245
    244246        /*Initialize hooked fields*/
  • issm/trunk-jpl/src/c/classes/objects/Loads/Penpair.cpp

    r14960 r14975  
    1616#include "../../../shared/Enum/Enum.h"
    1717#include "../../../shared/shared.h"
     18#include "../../../Container/Parameters.h"
    1819/*}}}*/
    1920
     
    111112        /*Take care of hooking up all objects for this element, ie links the objects in the hooks to their respective
    112113         * datasets, using internal ids and offsets hidden in hooks: */
    113         hnodes->configure(nodesin);
     114        hnodes->configure((DataSet*)nodesin);
    114115
    115116        /*Initialize hooked fields*/
  • issm/trunk-jpl/src/c/classes/objects/Materials/Matdamageice.cpp

    r14960 r14975  
    1414#include "../../../shared/Enum/Enum.h"
    1515#include "../../../shared/shared.h"
     16#include "../../../Container/Inputs.h"
     17#include "../../../Container/Parameters.h"
    1618
    1719/*Matdamageice constructors and destructor*/
     
    112114        /*Take care of hooking up all objects for this element, ie links the objects in the hooks to their respective
    113115         * datasets, using internal ids and offsets hidden in hooks: */
    114         helement->configure(elementsin);
     116        helement->configure((DataSet*)elementsin);
    115117}
    116118/*}}}*/
  • issm/trunk-jpl/src/c/classes/objects/Materials/Matice.cpp

    r14960 r14975  
    1414#include "../../../shared/Enum/Enum.h"
    1515#include "../../../shared/shared.h"
     16#include "../../../Container/Inputs.h"
     17#include "../../../Container/Parameters.h"
    1618
    1719/*Matice constructors and destructor*/
     
    112114        /*Take care of hooking up all objects for this element, ie links the objects in the hooks to their respective
    113115         * datasets, using internal ids and offsets hidden in hooks: */
    114         helement->configure(elementsin);
     116        helement->configure((DataSet*)elementsin);
    115117}
    116118/*}}}*/
  • issm/trunk-jpl/src/c/classes/objects/Options/GenericOption.h

    r14960 r14975  
    1717#include "../../../shared/Exceptions/exceptions.h"
    1818#include "../../../shared/MemOps/MemOps.h"
    19 #include "../../../shared/io/io.h"
    20 #include "../../../shared/Enum/Enum.h"
     19#include "../../../shared/shared.h"
    2120#include "./OptionUtilities.h"
    2221
  • issm/trunk-jpl/src/c/classes/objects/Vertex.cpp

    r14960 r14975  
    1212#include <string.h>
    1313#include "../classes.h"
    14 #include "../../shared/Enum/Enum.h"
    1514#include "../../shared/shared.h"
     15#include "../../Container/Parameters.h"
    1616/*}}}*/
    1717
  • issm/trunk-jpl/src/c/modules/InterpFromMeshToMesh2dx/InterpFromMeshToMesh2dx.cpp

    r14917 r14975  
    77#include "../../toolkits/toolkits.h"
    88#include "../../classes/objects/objects.h"
     9#include "../../Container/Container.h"
    910
    1011using namespace bamg;
  • issm/trunk-jpl/src/c/modules/Reducevectorgtofx/Reducevectorgtofx.h

    r13623 r14975  
    88
    99#include "../../classes/objects/objects.h"
     10#include "../../Container/Parameters.h"
     11#include "../../Container/Nodes.h"
    1012
    1113/* local prototypes: */
  • issm/trunk-jpl/src/c/modules/Reducevectorgtosx/Reducevectorgtosx.h

    r13623 r14975  
    88
    99#include "../../classes/objects/objects.h"
     10#include "../../Container/Container.h"
    1011
    1112/* local prototypes: */
  • issm/trunk-jpl/src/c/shared/Elements/Arrhenius.cpp

    r14951 r14975  
    44
    55#include <math.h>
    6 #include "./elements.h"
     6#include "../Numerics/types.h"
    77#include "../Exceptions/exceptions.h"
    88
  • issm/trunk-jpl/src/c/shared/Elements/elements.h

    r14951 r14975  
    77
    88#include "../Numerics/types.h"
    9 class ElementMatrix;
    10 class ElementVector;
    11 class Vertex;
    12 class Node;
    139
    1410IssmDouble Paterson(IssmDouble temperature);
  • issm/trunk-jpl/src/c/shared/Numerics/numerics.h

    r14915 r14975  
    1111#include "./recast.h"
    1212#include "./types.h"
     13#include "./constants.h"
    1314
    1415class Input;
     
    2627void        OptimalSearch(IssmDouble *psearch_scalar,IssmDouble*pJ,OptPars*optpars,IssmDouble (*f)(IssmDouble,OptArgs*), OptArgs*optargs);
    2728void        cross(IssmDouble *result,IssmDouble*vector1,IssmDouble*vector2);
    28 void        IsInputConverged(IssmDouble *peps, Input**new_inputs,Input**old_inputs,int num_inputs,int criterion_enum);
    2929void        UnitConversion(IssmDouble *values, int numvalues,int direction_enum, int type_enum);
    3030IssmDouble  UnitConversion(IssmDouble value, int direction_enum, int type_enum);
    31 char       *OptionsFromAnalysis(Parameters *parameters,int analysis_type);
    3231void        XZvectorsToCoordinateSystem(IssmDouble *T,IssmDouble*xzvectors);
    3332int         cubic(IssmDouble a, IssmDouble b, IssmDouble c, IssmDouble d, double X[3], int *num);
    34 void        ToolkitsOptionsFromAnalysis(Parameters* parameters,int analysis_type);
    3533
    3634#endif //ifndef _NUMERICS_H_
  • issm/trunk-jpl/src/c/shared/Numerics/recast.h

    r14927 r14975  
    1717#if !defined(_HAVE_ADOLC_) || defined(_WRAPPERS_)
    1818
    19 template<class To, class From>
    20 To reCast(const From& from) {
     19template<class To, class From> To reCast(const From& from) {
    2120    return (To)from;
    2221}
     
    2524#include "./types.h"
    2625
    27 template<class To, class From>
    28 struct ForPartialSpecialization {
     26template<class To, class From> struct ForPartialSpecialization {
    2927    static  To reCast(const From& from ) { return (To) from;}
    3028};
    3129
    32 template<class To, class From>
    33 To reCast(const From& from) {
     30template<class To, class From> To reCast(const From& from) {
    3431    return ForPartialSpecialization<To,From>::reCast(from);
    3532}
     
    3734 * partial specialization
    3835 */
    39 template<class To>
    40 struct ForPartialSpecialization<To,adouble> {
     36template<class To> struct ForPartialSpecialization<To,adouble> {
    4137    static  To reCast(const adouble& from ) { return (To) (from.getValue());}
    4238};
Note: See TracChangeset for help on using the changeset viewer.