Changeset 3479 for issm/trunk


Ignore:
Timestamp:
04/08/10 16:49:03 (15 years ago)
Author:
Mathieu Morlighem
Message:

bug fix

Location:
issm/trunk/src
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk/src/c/objects/ElementProperties.cpp

    r3446 r3479  
    3434        this->geothermalflux=NULL;
    3535       
    36         this->friction_type=0;
    37         this->p=0;
    38         this->q=0;
    39         this->shelf=0;
    40         this->onbed=0;
    41         this->onwater=0;
    42         this->onsurface=0;
    43         this->collapse=0;
    44         this->thermal_steadystate=0;
     36        this->friction_type=UNDEF;
     37        this->p=UNDEF;
     38        this->q=UNDEF;
     39        this->shelf=UNDEF;
     40        this->onbed=UNDEF;
     41        this->onwater=UNDEF;
     42        this->onsurface=UNDEF;
     43        this->collapse=UNDEF;
     44        this->thermal_steadystate=UNDEF;
    4545        return;
    4646}
     
    145145        this->numnodes=elementproperties_numnodes;
    146146
    147         if(elementproperties_h)this->h=(double*)xmalloc(this->numnodes*sizeof(double));
    148         else this->h=NULL;
    149         if(elementproperties_s)this->s=(double*)xmalloc(this->numnodes*sizeof(double));
    150         else this->s=NULL;
    151         if(elementproperties_b)this->b=(double*)xmalloc(this->numnodes*sizeof(double));
    152         else this->b=NULL;
    153         if(elementproperties_k)this->k=(double*)xmalloc(this->numnodes*sizeof(double));
    154         else this->k=NULL;
    155         if(elementproperties_melting)this->melting=(double*)xmalloc(this->numnodes*sizeof(double));
    156         else this->melting=NULL;
    157         if(elementproperties_accumulation)this->accumulation=(double*)xmalloc(this->numnodes*sizeof(double));
    158         else this->accumulation=NULL;
    159         if(elementproperties_geothermalflux)this->geothermalflux=(double*)xmalloc(this->numnodes*sizeof(double));
    160         else this->geothermalflux=NULL;
     147        this->h=(double*)xmalloc(this->numnodes*sizeof(double));
     148        this->s=(double*)xmalloc(this->numnodes*sizeof(double));
     149        this->b=(double*)xmalloc(this->numnodes*sizeof(double));
     150        this->k=(double*)xmalloc(this->numnodes*sizeof(double));
     151        this->melting=(double*)xmalloc(this->numnodes*sizeof(double));
     152        this->accumulation=(double*)xmalloc(this->numnodes*sizeof(double));
     153        this->geothermalflux=(double*)xmalloc(this->numnodes*sizeof(double));
    161154
    162155        for(i=0;i<this->numnodes;i++){
    163                 if(elementproperties_h)this->h[i]=elementproperties_h[i];
    164                 if(elementproperties_s)this->s[i]=elementproperties_s[i];
    165                 if(elementproperties_b)this->b[i]=elementproperties_b[i];
    166                 if(elementproperties_k)this->k[i]=elementproperties_k[i];
    167                 if(elementproperties_melting)this->melting[i]=elementproperties_melting[i];
    168                 if(elementproperties_accumulation)this->accumulation[i]=elementproperties_accumulation[i];
     156                if(elementproperties_h)             this->h[i]=elementproperties_h[i];
     157                else                                this->h[i]=UNDEF;
     158                if(elementproperties_s)             this->s[i]=elementproperties_s[i];
     159                else                                this->s[i]=UNDEF;
     160                if(elementproperties_b)             this->b[i]=elementproperties_b[i];
     161                else                                this->b[i]=UNDEF;
     162                if(elementproperties_k)             this->k[i]=elementproperties_k[i];
     163                else                                this->k[i]=UNDEF;
     164                if(elementproperties_melting)       this->melting[i]=elementproperties_melting[i];
     165                else                                this->melting[i]=UNDEF;
     166                if(elementproperties_accumulation)  this->accumulation[i]=elementproperties_accumulation[i];
     167                else                                this->accumulation[i]=UNDEF;
    169168                if(elementproperties_geothermalflux)this->geothermalflux[i]=elementproperties_geothermalflux[i];
     169                else                                this->geothermalflux[i]=UNDEF;
    170170        }
    171171       
     
    179179        this->collapse=elementproperties_collapse;
    180180        this->thermal_steadystate=elementproperties_thermal_steadystate;
     181
     182        return;
     183}
     184/*}}}*/
     185/*FUNCTION ElementProperties Init propreties from iomodel{{{1*/
     186void ElementProperties::Init(int numberofnodes, int* vertex_ids, int element_id, IoModel* iomodel){ //i is the node index
     187
     188        int i,k;
     189
     190        /*Initialize number of nodes*/
     191        this->numnodes=numberofnodes;
     192
     193        /*Allocate node properties*/
     194        if (iomodel->thickness)     this->h=(double*)xmalloc(this->numnodes*sizeof(double));
     195        if (iomodel->surface)       this->s=(double*)xmalloc(this->numnodes*sizeof(double));
     196        if (iomodel->bed)           this->b=(double*)xmalloc(this->numnodes*sizeof(double));
     197        if (iomodel->drag)          this->k=(double*)xmalloc(this->numnodes*sizeof(double));
     198        if (iomodel->melting)       this->melting=(double*)xmalloc(this->numnodes*sizeof(double));
     199        if (iomodel->accumulation)  this->accumulation=(double*)xmalloc(this->numnodes*sizeof(double));
     200        if (iomodel->geothermalflux)this->geothermalflux=(double*)xmalloc(this->numnodes*sizeof(double));
     201
     202        /*Get node properties*/
     203        for(i=0;i<this->numnodes;i++){
     204
     205                //get index of the vertex in C indexing
     206                k=vertex_ids[i]-1;
     207
     208                //Get properties from iomodel
     209                if(iomodel->thickness)     this->h[i]=iomodel->thickness[k];
     210                if(iomodel->surface)       this->s[i]=iomodel->surface[k];
     211                if(iomodel->bed)           this->b[i]=iomodel->bed[k];
     212                if(iomodel->drag)          this->k[i]=iomodel->drag[k];
     213                if(iomodel->melting)       this->melting[i]=iomodel->melting[k];
     214                if(iomodel->accumulation)  this->accumulation[i]=iomodel->accumulation[k];
     215                if(iomodel->geothermalflux)this->geothermalflux[i]=iomodel->geothermalflux[k];
     216        }
     217
     218        /*Get element properties from iomodel*/
     219        if (iomodel->p)                this->p=iomodel->p[element_id-1];
     220        if (iomodel->q)                this->q=iomodel->q[element_id-1];
     221        if (iomodel->elementoniceshelf)this->shelf=(int)iomodel->elementoniceshelf[element_id-1];
     222        if (iomodel->elementonbed)     this->onbed=(int)iomodel->elementonbed[element_id-1];
     223        if (iomodel->elementonwater)   this->onwater=(bool)iomodel->elementonwater[element_id-1];
     224        if (iomodel->elementonsurface) this->onsurface=(int)iomodel->elementonsurface[element_id-1];
     225
     226        /*Get other properties from iomodel*/
     227        this->friction_type=iomodel->drag_type;
     228
     229        /*WARNING: collapse and thermal_steadystate are left undefined*/
    181230
    182231        return;
  • issm/trunk/src/c/objects/ElementProperties.h

    r3420 r3479  
    55#ifndef _ELEMENTPROPERTIES_H_
    66#define  _ELEMENTPROPERTIES_H_
     7
     8/*indefinitions: */
     9struct IoModel;
    710
    811class ElementProperties{
     
    3336                ElementProperties();
    3437                ElementProperties(int numnodes, double* h, double* s, double* b, double* k, double* melting, double* accumulation, double* geothermalflux, int friction_type, double p, double q, int shelf, int onbed, bool onwater, int onsurface, int collapse, int thermal_steadystate);
    35                 void Init(int numnodes, double* h, double* s, double* b, double* k, double* melting, double* accumulation, double* geothermalflux, int friction_type, double p, double q, int shelf, int onbed, bool onwater, int onsurface, int collapse, int thermal_steadystate);
    3638                ElementProperties(ElementProperties* properties);
    3739                ~ElementProperties();
     40
     41                void Init(int numnodes, int* vertex_ids, int element_id, IoModel* iomodel);
     42                void Init(int numnodes, double* h, double* s, double* b, double* k, double* melting, double* accumulation, double* geothermalflux, int friction_type, double p, double q, int shelf, int onbed, bool onwater, int onsurface, int collapse, int thermal_steadystate);
    3843               
    3944                void  Marshall(char** pmarshalled_dataset);
  • issm/trunk/src/c/objects/Matice.cpp

    r3463 r3479  
    1212#include "./Matice.h"
    1313#include <string.h>
     14#include "../EnumDefinitions/EnumDefinitions.h"
    1415#include "../shared/shared.h"
    1516#include "../include/macros.h"
    16 #include "../EnumDefinitions/EnumDefinitions.h"
    17 
     17#include "../include/typedefs.h"
    1818               
    1919/*Object constructors and destructor*/
     
    5151        matice_mid=i+1;  //same as element it is created for
    5252 
    53         /*B and n: */
    54         B_avg=0;
    55         for(j=0;j<num_vertices;j++){
    56                 B_avg+=*(iomodel->B+((int)*(iomodel->elements+num_vertices*i+j)-1));
    57         }
    58         B_avg=B_avg/num_vertices;
    59        
    60         matice_B=B_avg;
    61         matice_n=(double)*(iomodel->n+i);
     53        /*Compute B on the element if provided*/
     54        if (iomodel->B){
     55                B_avg=0;
     56                for(j=0;j<num_vertices;j++){
     57                        B_avg+=*(iomodel->B+((int)*(iomodel->elements+num_vertices*i+j)-1));
     58                }
     59                B_avg=B_avg/num_vertices;
     60        }
     61       
     62        if (iomodel->B) matice_B=B_avg;
     63        else            matice_B=UNDEF;
     64        if (iomodel->n) matice_n=(double)*(iomodel->n+i);
     65        else            matice_n=UNDEF;
    6266
    6367        this->Init(matice_mid,matice_B,matice_n);
  • issm/trunk/src/c/objects/Node.cpp

    r3470 r3479  
    803803/*FUNCTION Node::UpdateFromInputs {{{2*/
    804804void  Node::UpdateFromInputs(void* vinputs){
    805 
    806         ISSMERROR("not used yet!");
    807        
     805       
     806        /*nothing updated for now*/
     807
    808808}
    809809/*}}}*/
  • issm/trunk/src/c/objects/Tria.cpp

    r3470 r3479  
    6767
    6868        int j;
    69         int offset;
    7069        int tria_node_ids[3];
    7170        int tria_matice_id;
    7271        int tria_matpar_id;
    7372        int tria_numpar_id;
    74         double tria_h[3];
    75         double tria_s[3];
    76         double tria_b[3];
    77         double tria_k[3];
    78         double tria_melting[3];
    79         double tria_accumulation[3];
    80         int    tria_friction_type;
    81         double tria_p,tria_q;
    82         int tria_shelf;
    83         int tria_onwater;
    84        
    8573
    8674        /*id: */
     
    9987        this->hmatpar.Init(&tria_matpar_id,1);
    10088        this->hnumpar.Init(&tria_numpar_id,1);
    101 
    102         /*properties: */
    103         for(j=0;j<3;j++){
    104 
    105                 offset=(int)*(iomodel->elements+3*i+j)-1; //get index of this vertex, in C numbering.
    106                 tria_h[j]= *(iomodel->thickness+offset);
    107                 tria_s[j]= *(iomodel->surface+offset);
    108                 tria_b[j]=*(iomodel->bed+offset);
    109                 tria_k[j]=*(iomodel->drag+offset);
    110                 tria_melting[j]=*(iomodel->melting+offset);
    111                 tria_accumulation[j]=*(iomodel->accumulation+offset);
    112         }
    113         tria_friction_type=(int)iomodel->drag_type;
    114         tria_p=iomodel->p[i];
    115         tria_q=iomodel->q[i];
    116         tria_shelf=(int)*(iomodel->elementoniceshelf+i);
    117         tria_onwater=(bool)*(iomodel->elementonwater+i);
    118        
    119         this->properties.Init(3,tria_h, tria_s, tria_b, tria_k, tria_melting, tria_accumulation, NULL,
    120                         tria_friction_type, tria_p, tria_q, tria_shelf, UNDEF,tria_onwater, UNDEF,UNDEF,UNDEF);
    121 
     89        this->properties.Init(3,tria_node_ids,this->id,iomodel);
    12290
    12391}
  • issm/trunk/src/c/objects/Vertex.cpp

    r3469 r3479  
    188188        Vertex* vertex=NULL;
    189189        int dof[1]={0};
    190         double coord[3];
    191190
    192191        vertex=this;
    193 
    194         coord[0]=this->x; coord[1]=this->y; coord[2]=this->z;
    195192
    196193        /*Recover parameter inputs: */
     
    198195
    199196        /*Update internal data if inputs holds new values: */
    200         inputs->Recover("x",&coord[0],1,dof,1,(void**)&vertex);
    201         inputs->Recover("y",&coord[1],1,dof,1,(void**)&vertex);
    202         inputs->Recover("z",&coord[2],1,dof,1,(void**)&vertex);
    203        
    204         ISSMERROR("not supported yet!");
     197        inputs->Recover("x",&x,1,dof,1,(void**)&vertex);
     198        inputs->Recover("y",&y,1,dof,1,(void**)&vertex);
     199        inputs->Recover("z",&z,1,dof,1,(void**)&vertex);
    205200       
    206201}
  • issm/trunk/src/m/solutions/jpl/control_core.m

    r2761 r3479  
    4545
    4646        %Update inputs in datasets
    47         [model.elements,model.nodes,model.loads,model.materials,model.parameters]=UpdateFromInputs(model.elements,model.nodes,model.loads,model.materials,model.parameters,inputs);
     47        [model.elements,model.nodes,model.vertices,model.loads,model.materials,model.parameters]=UpdateFromInputs(model.elements,model.nodes,model.vertices,model.loads,model.materials,model.parameters,inputs);
    4848
    4949        displaystring(verbose,'\n%s',['      computing gradJ...']);
  • issm/trunk/src/m/solutions/jpl/diagnostic_core_linear.m

    r2333 r3479  
    99
    1010        %Update inputs in datasets
    11         [m.elements,m.nodes, m.loads,m.materials,m.parameters]=UpdateFromInputs(m.elements,m.nodes, m.loads,m.materials,m.parameters,inputs);
     11        [m.elements,m.nodes,m.vertices,m.loads,m.materials,m.parameters]=UpdateFromInputs(m.elements,m.nodes,m.vertices,m.loads,m.materials,m.parameters,inputs);
    1212       
    1313        %system matrices
    14         [K_gg, p_g]=SystemMatrices(m.elements,m.nodes,m.loads,m.materials,m.parameters,inputs,analysis_type,sub_analysis_type);
    15         [K_gg, p_g,kmax]=PenaltySystemMatrices(K_gg,p_g,m.elements,m.nodes,m.loads,m.materials,m.parameters,inputs,analysis_type,sub_analysis_type);
     14        [K_gg, p_g]=SystemMatrices(m.elements,m.nodes,m.vertices,m.loads,m.materials,m.parameters,inputs,analysis_type,sub_analysis_type);
     15        [K_gg, p_g,kmax]=PenaltySystemMatrices(K_gg,p_g,m.elements,m.nodes,m.vertices,m.loads,m.materials,m.parameters,inputs,analysis_type,sub_analysis_type);
    1616       
    1717        %Reduce tangent matrix from g size to f size
  • issm/trunk/src/m/solutions/jpl/diagnostic_core_nonlinear.m

    r2547 r3479  
    3131               
    3232                %Update inputs in datasets
    33                 [m.elements,m.nodes, loads,m.materials,m.parameters]=UpdateFromInputs(m.elements,m.nodes, loads,m.materials,m.parameters,inputs);
     33                [m.elements,m.nodes,m.vertices, loads,m.materials,m.parameters]=UpdateFromInputs(m.elements,m.nodes,m.vertices, loads,m.materials,m.parameters,inputs);
    3434               
    3535                %system matrices
    36                 [K_gg_nopenalty , p_g_nopenalty]=SystemMatrices(m.elements,m.nodes,loads,m.materials,m.parameters,inputs,analysis_type,sub_analysis_type);
     36                [K_gg_nopenalty , p_g_nopenalty]=SystemMatrices(m.elements,m.nodes,m.vertices,loads,m.materials,m.parameters,inputs,analysis_type,sub_analysis_type);
    3737       
    3838                %penalties
    39                 [K_gg , p_g, kmax]=PenaltySystemMatrices(K_gg_nopenalty,p_g_nopenalty,m.elements,m.nodes,loads,m.materials,m.parameters,inputs,analysis_type,sub_analysis_type);
     39                [K_gg , p_g, kmax]=PenaltySystemMatrices(K_gg_nopenalty,p_g_nopenalty,m.elements,m.nodes,m.vertices,loads,m.materials,m.parameters,inputs,analysis_type,sub_analysis_type);
    4040
    4141                %Reduce tangent matrix from g size to f size
     
    8484                inputs=add(inputs,'velocity',u_g,'doublevec',m.parameters.numberofdofspernode,m.parameters.numberofnodes);
    8585                m.parameters.kflag=1; m.parameters.pflag=0;
    86                 [K_gg, p_g]=SystemMatrices(m.elements,m.nodes,loads,m.materials,m.parameters,inputs,analysis_type,sub_analysis_type);
     86                [K_gg, p_g]=SystemMatrices(m.elements,m.nodes,m.vertices,loads,m.materials,m.parameters,inputs,analysis_type,sub_analysis_type);
    8787                [K_ff, K_fs] = Reducematrixfromgtof( K_gg, m.Gmn, m.nodesets);
    8888                varargout(1)={K_ff};
  • issm/trunk/src/m/solutions/jpl/thermal_core_nonlinear.m

    r2333 r3479  
    2323
    2424                %Update inputs in datasets
    25                 [m.elements,m.nodes, loads,m.materials,m.parameters]=UpdateFromInputs(m.elements,m.nodes, loads,m.materials,m.parameters,inputs);
     25                [m.elements,m.nodes,m.vertices,loads,m.materials,m.parameters]=UpdateFromInputs(m.elements,m.nodes,m.vertices, loads,m.materials,m.parameters,inputs);
    2626
    2727                %system matrices
     
    2929                        if count==1
    3030                                displaystring(m.parameters.verbose,'%s',['   system matrices']);
    31                                 [K_gg_nopenalty, p_g_nopenalty]=SystemMatrices(m.elements,m.nodes,loads,m.materials,m.parameters,inputs,analysis_type,sub_analysis_type);
     31                                [K_gg_nopenalty, p_g_nopenalty]=SystemMatrices(m.elements,m.nodes,m.vertices,loads,m.materials,m.parameters,inputs,analysis_type,sub_analysis_type);
    3232                        end
    3333                        displaystring(m.parameters.verbose,'%s',['   penalty system matrices']);
    34                         [K_gg , p_g, melting_offset]=PenaltySystemMatrices(K_gg_nopenalty,p_g_nopenalty,m.elements,m.nodes,loads,m.materials,m.parameters,inputs,analysis_type,sub_analysis_type);
     34                        [K_gg , p_g, melting_offset]=PenaltySystemMatrices(K_gg_nopenalty,p_g_nopenalty,m.elements,m.nodes,m.verticesloads,m.materials,m.parameters,inputs,analysis_type,sub_analysis_type);
    3535                else
    3636                        displaystring(m.parameters.verbose,'%s',['   system matrices']);
    37                         [K_gg , p_g]=SystemMatrices(m.elements,m.nodes,loads,m.materials,m.parameters,inputs,analysis_type,sub_analysis_type);
     37                        [K_gg , p_g]=SystemMatrices(m.elements,m.nodes,m.vertices,loads,m.materials,m.parameters,inputs,analysis_type,sub_analysis_type);
    3838                        displaystring(m.parameters.verbose,'%s',['   penalty system matrices']);
    39                         [K_gg , p_g, melting_offset]=PenaltySystemMatrices(K_gg,p_g,m.elements,m.nodes,loads,m.materials,m.parameters,inputs,analysis_type,sub_analysis_type);
     39                        [K_gg , p_g, melting_offset]=PenaltySystemMatrices(K_gg,p_g,m.elements,m.nodes,m.vertices,loads,m.materials,m.parameters,inputs,analysis_type,sub_analysis_type);
    4040                end
    4141
     
    5757                inputs=add(inputs,'temperature',t_g,'doublevec',m.parameters.numberofdofspernode,m.parameters.numberofnodes);
    5858                displaystring(m.parameters.verbose,'%s',['   update inputs']);
    59                 [m.elements,m.nodes, loads,m.materials,m.parameters]=UpdateFromInputs(m.elements,m.nodes, loads,m.materials,m.parameters,inputs);
     59                [m.elements,m.nodes,m.vertices, loads,m.materials,m.parameters]=UpdateFromInputs(m.elements,m.nodes,m.vertices, loads,m.materials,m.parameters,inputs);
    6060       
    6161                %penalty constraints
  • issm/trunk/src/mex/PenaltySystemMatrices/PenaltySystemMatrices.cpp

    r3445 r3479  
    7979{
    8080        _printf_("\n");
    81         _printf_("   usage: [Kgg,pg] = %s(Kggin,pgin,eleemnts,nodes,loads,materials,params,inputs,analysis_type,sub_analysis_type);\n",__FUNCT__);
     81        _printf_("   usage: [Kgg,pg] = %s(Kggin,pgin,elements,nodes,vertices,loads,materials,params,inputs,analysis_type,sub_analysis_type);\n",__FUNCT__);
    8282        _printf_("\n");
    8383}
  • issm/trunk/src/mex/SystemMatrices/SystemMatrices.cpp

    r3445 r3479  
    8181{
    8282        _printf_("\n");
    83         _printf_("   usage: [Kgg,pg] = %s(eleemnts,nodes,loads,materials,params,inputs,analysis_type);\n",__FUNCT__);
     83        _printf_("   usage: [Kgg,pg] = %s(elements,nodes,vertices,loads,materials,params,inputs,analysis_type);\n",__FUNCT__);
    8484        _printf_("\n");
    8585}
  • issm/trunk/src/mex/UpdateFromInputs/UpdateFromInputs.cpp

    r3445 r3479  
    6464{
    6565        _printf_("\n");
    66         _printf_("   usage: [elements,nodes,loads, materials, parameters] = %s(elements,nodes,loads, materials,parameters,inputs);\n",__FUNCT__);
     66        _printf_("   usage: [elements,nodes,vertices,loads,materials,parameters] = %s(elements,nodes,vertices,loads,materials,parameters,inputs);\n",__FUNCT__);
    6767        _printf_("\n");
    6868}
Note: See TracChangeset for help on using the changeset viewer.