Changeset 16699


Ignore:
Timestamp:
11/11/13 09:07:42 (11 years ago)
Author:
Mathieu Morlighem
Message:

NEW: added case in thermalanalysis

Location:
issm/trunk-jpl/src/c
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/analyses/ThermalAnalysis.cpp

    r16684 r16699  
    116116}/*}}}*/
    117117void ThermalAnalysis::InputUpdateFromSolution(IssmDouble* solution,Element* element){/*{{{*/
    118         _error_("not implemented yet");
     118
     119        bool        converged;
     120        int         i,rheology_law;
     121        IssmDouble  B_average,s_average,T_average=0.;
     122        int        *doflist   = NULL;
     123        IssmDouble *xyz_list  = NULL;
     124        bool        hack      = false;
     125
     126        /*Fetch number of nodes and dof for this finite element*/
     127        int numnodes = element->GetNumberOfNodes();
     128
     129        /*Fetch dof list and allocate solution vector*/
     130        element->GetDofList(&doflist,NoneApproximationEnum,GsetEnum);
     131        IssmDouble* values    = xNew<IssmDouble>(numnodes);
     132
     133        /*Use the dof list to index into the solution vector: */
     134        for(i=0;i<numnodes;i++){
     135                values[i]=solution[doflist[i]];
     136
     137                /*Check solution*/
     138                if(xIsNan<IssmDouble>(values[i])) _error_("NaN found in solution vector");
     139                //if(values[i]<0)      _printf_("temperature < 0°K found in solution vector\n");
     140                //if(values[i]>275)    _printf_("temperature > 275°K found in solution vector (Paterson's rheology associated is negative)\n");
     141        }
     142
     143        /*Force temperature between [Tpmp-50 Tpmp] to disable penalties*/
     144        if(hack){
     145                IssmDouble* pressure = xNew<IssmDouble>(numnodes);
     146                element->GetInputListOnVertices(pressure,PressureEnum);
     147                for(i=0;i<numnodes;i++){
     148                        if(values[i]>element->TMeltingPoint(pressure[i]))     values[i]=element->TMeltingPoint(pressure[i]);
     149                        if(values[i]<element->TMeltingPoint(pressure[i])-50.) values[i]=element->TMeltingPoint(pressure[i])-50.;
     150                }
     151                xDelete<IssmDouble>(pressure);
     152        }
     153
     154        /*Get all inputs and parameters*/
     155
     156        element->GetInputValue(&converged,ConvergedEnum);
     157        if(converged){
     158                element->AddInput(TemperatureEnum,values,P1Enum);
     159
     160                /*Update Rheology only if converged (we must make sure that the temperature is below melting point
     161                 * otherwise the rheology could be negative*/
     162                element->FindParam(&rheology_law,MaterialsRheologyLawEnum);
     163                switch(rheology_law){
     164                        case NoneEnum:
     165                                /*Do nothing: B is not temperature dependent*/
     166                                break;
     167                        case PatersonEnum:
     168                                for(i=0;i<numnodes;i++) T_average+=values[i]/reCast<IssmDouble>(numnodes);
     169                                B_average=Paterson(T_average);
     170                                element->AddMaterialInput(MaterialsRheologyBEnum,&B_average,P0Enum);
     171                                break;
     172                        case ArrheniusEnum:{
     173                                Input* surface_input=element->GetInput(SurfaceEnum); _assert_(surface_input);
     174                                surface_input->GetInputAverage(&s_average);
     175                                element->GetVerticesCoordinates(&xyz_list);
     176                                for(i=0;i<numnodes;i++) T_average+=values[i]/reCast<IssmDouble>(numnodes);
     177                                //B_average=Arrhenius(T_average,
     178                                                        //s_average-((xyz_list[0][2]+xyz_list[1][2]+xyz_list[2][2]+xyz_list[3][2]+xyz_list[4][2]+xyz_list[5][2])/6.0),
     179                                                        //element->GetMaticeParameter(MaterialsRheologyNEnum));
     180                                element->AddMaterialInput(MaterialsRheologyBEnum,&B_average,P0Enum);
     181                                break;
     182                                }
     183                        default:
     184                                _error_("Rheology law " << EnumToStringx(rheology_law) << " not supported yet");
     185
     186                }
     187        }
     188        else{
     189                element->AddInput(TemperaturePicardEnum,values,P1Enum);
     190        }
     191
     192        /*Free ressources:*/
     193        xDelete<IssmDouble>(values);
     194        xDelete<IssmDouble>(xyz_list);
     195        xDelete<int>(doflist);
    119196}/*}}}*/
  • issm/trunk-jpl/src/c/classes/Elements/Element.h

    r16698 r16699  
    4040                virtual void   SetwiseNodeConnectivity(int* d_nz,int* o_nz,Node* node,bool* flags,int* flagsindices,int set1_enum,int set2_enum)=0;
    4141                virtual void   AddInput(int input_enum, IssmDouble* values, int interpolation_enum)=0;
     42                virtual void   AddMaterialInput(int input_enum, IssmDouble* values, int interpolation_enum)=0;
    4243                virtual void   CreateKMatrix(Matrix<IssmDouble>* Kff, Matrix<IssmDouble>*  Kfs)=0;
    4344                virtual void   CreateDVector(Vector<IssmDouble>* df)=0;
     
    9596                virtual void   Delta18oParameterization(void)=0;
    9697                virtual void   SmbGradients()=0;
     98                virtual IssmDouble TMeltingPoint(IssmDouble pressure)=0;
    9799                virtual void   ResetCoordinateSystem()=0;
    98100                virtual int    VelocityInterpolation()=0;
  • issm/trunk-jpl/src/c/classes/Elements/Penta.cpp

    r16698 r16699  
    124124void  Penta::AddInput(int input_enum,IssmDouble* values, int interpolation_enum){
    125125
    126         /*Call inputs method*/
     126        _assert_(this->inputs);
    127127        this->inputs->AddInput(new PentaInput(input_enum,values,interpolation_enum));
    128128}
    129129/*}}}*/
     130/*FUNCTION Penta::AddMaterialInput{{{*/
     131void  Penta::AddMaterialInput(int input_enum,IssmDouble* values, int interpolation_enum){
     132
     133        _assert_(this->material);
     134        this->material->inputs->AddInput(new TriaInput(input_enum,values,interpolation_enum));
     135}
     136/*}}}*/
     137
    130138/*FUNCTION Penta::BedNormal {{{*/
    131139void Penta::BedNormal(IssmDouble* bed_normal, IssmDouble xyz_list[3][3]){
     
    31513159          /*Update inputs*/
    31523160          this->inputs->AddInput(new PentaInput(SurfaceforcingsMassBalanceEnum,&smb[0],P1Enum));
     3161}
     3162/*}}}*/
     3163/*FUNCTION Penta::TMeltingPoint{{{*/
     3164IssmDouble Penta::TMeltingPoint(IssmDouble pressure){
     3165
     3166        _assert_(matpar);
     3167        return this->matpar->TMeltingPoint(pressure);
     3168
    31533169}
    31543170/*}}}*/
  • issm/trunk-jpl/src/c/classes/Elements/Penta.h

    r16698 r16699  
    112112                void   ResetCoordinateSystem(void);
    113113                void   SmbGradients();
     114                IssmDouble  TMeltingPoint(IssmDouble pressure);
    114115                IssmDouble SurfaceArea(void);
    115116                void   Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type,int finitelement);
     
    182183                /*Penta specific routines:{{{*/
    183184                void           AddInput(int input_enum, IssmDouble* values, int interpolation_enum);
     185                void           AddMaterialInput(int input_enum, IssmDouble* values, int interpolation_enum);
    184186                void             BedNormal(IssmDouble* bed_normal, IssmDouble xyz_list[3][3]);
    185187                ElementMatrix* CreateBasalMassMatrix(void);
  • issm/trunk-jpl/src/c/classes/Elements/Seg.h

    r16698 r16699  
    6767                /*Element virtual functions definitions: {{{*/
    6868                void        AddInput(int input_enum, IssmDouble* values, int interpolation_enum){_error_("not implemented yet");};
     69                void        AddMaterialInput(int input_enum, IssmDouble* values, int interpolation_enum){_error_("not implemented yet");};
    6970                void        ComputeBasalStress(Vector<IssmDouble>* sigma_b){_error_("not implemented yet");};
    7071                void        ComputeStrainRate(Vector<IssmDouble>* eps){_error_("not implemented yet");};
     
    137138                void        ResetCoordinateSystem(void){_error_("not implemented yet");};
    138139                void          SmbGradients(){_error_("not implemented yet");};
     140                IssmDouble  TMeltingPoint(IssmDouble pressure){_error_("not implemented yet");};
    139141                IssmDouble  SurfaceArea(void){_error_("not implemented yet");};
    140142                void        Update(int index, IoModel* iomodel,int analysis_counter,int analysis_type,int finitelement){_error_("not implemented yet");};
  • issm/trunk-jpl/src/c/classes/Elements/Tria.cpp

    r16698 r16699  
    170170
    171171        /*Call inputs method*/
     172        _assert_(this->inputs);
    172173        this->inputs->AddInput(new TriaInput(input_enum,values,interpolation_enum));
     174}
     175/*}}}*/
     176/*FUNCTION Tria::AddMaterialInput{{{*/
     177void  Tria::AddMaterialInput(int input_enum,IssmDouble* values, int interpolation_enum){
     178
     179        _assert_(this->material);
     180        this->material->inputs->AddInput(new TriaInput(input_enum,values,interpolation_enum));
    173181}
    174182/*}}}*/
     
    26412649          /*Update inputs*/
    26422650          this->inputs->AddInput(new TriaInput(SurfaceforcingsMassBalanceEnum,&smb[0],P1Enum));
     2651}
     2652/*}}}*/
     2653/*FUNCTION Tria::TMeltingPoint{{{*/
     2654IssmDouble Tria::TMeltingPoint(IssmDouble pressure){
     2655
     2656        _assert_(matpar);
     2657        return this->matpar->TMeltingPoint(pressure);
     2658
    26432659}
    26442660/*}}}*/
  • issm/trunk-jpl/src/c/classes/Elements/Tria.h

    r16698 r16699  
    118118                void        ResetCoordinateSystem(void);
    119119                void          SmbGradients();
     120                IssmDouble  TMeltingPoint(IssmDouble pressure);
    120121                int         VelocityInterpolation();
    121122                int         PressureInterpolation();
     
    193194                /*Tria specific routines:{{{*/
    194195                void           AddInput(int input_enum, IssmDouble* values, int interpolation_enum);
     196                void           AddMaterialInput(int input_enum, IssmDouble* values, int interpolation_enum);
    195197                ElementMatrix* CreateKMatrix(void);
    196198                ElementMatrix* CreateKMatrixBalancethickness(void);
Note: See TracChangeset for help on using the changeset viewer.