Changeset 16897


Ignore:
Timestamp:
11/22/13 15:24:52 (11 years ago)
Author:
Mathieu Morlighem
Message:

CHG: fixing thermal but still not there yet

File:
1 edited

Legend:

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

    r16842 r16897  
    231231                                for(int j=0;j<numnodes;j++){
    232232                                        Ke->values[i*numnodes+j]+=tau_parameter*D_scalar*
    233                                           ((u-um)*dbasis[0*3+i]+(v-vm)*dbasis[1*3+i]+(w-wm)*dbasis[2*3+i])*((u-um)*dbasis[0*3+j]+(v-vm)*dbasis[1*3+j]+(w-wm)*dbasis[2*3+j]);
     233                                          ((u-um)*dbasis[0*numnodes+i]+(v-vm)*dbasis[1*numnodes+i]+(w-wm)*dbasis[2*numnodes+i])*((u-um)*dbasis[0*numnodes+j]+(v-vm)*dbasis[1*numnodes+j]+(w-wm)*dbasis[2*numnodes+j]);
    234234                                }
    235235                        }
     
    237237                                for(int i=0;i<numnodes;i++){
    238238                                        for(int j=0;j<numnodes;j++){
    239                                                 Ke->values[i*numnodes+j]+=tau_parameter*D_scalar*basis[j]*((u-um)*dbasis[0*3+i]+(v-vm)*dbasis[1*3+i]+(w-wm)*dbasis[2*3+i]);
     239                                                Ke->values[i*numnodes+j]+=tau_parameter*D_scalar*basis[j]*((u-um)*dbasis[0*numnodes+i]+(v-vm)*dbasis[1*numnodes+i]+(w-wm)*dbasis[2*numnodes+i]);
    240240                                        }
    241241                                }
     
    377377                        tau_parameter=element->StabilizationParameter(u,v,w,diameter,kappa);
    378378
    379                         for(int i=0;i<numnodes;i++) pe->values[i]+=tau_parameter*scalar_def*(u*dbasis[0*3+i]+v*dbasis[1*3+i]+w*dbasis[2*3+i]);
     379                        for(int i=0;i<numnodes;i++) pe->values[i]+=tau_parameter*scalar_def*(u*dbasis[0*numnodes+i]+v*dbasis[1*numnodes+i]+w*dbasis[2*numnodes+i]);
    380380                        if(reCast<bool,IssmDouble>(dt)){
    381                                 for(int i=0;i<numnodes;i++) pe->values[i]+=tau_parameter*scalar_transient*(u*dbasis[0*3+i]+v*dbasis[1*3+i]+w*dbasis[2*3+i]);
     381                                for(int i=0;i<numnodes;i++) pe->values[i]+=tau_parameter*scalar_transient*(u*dbasis[0*numnodes+i]+v*dbasis[1*numnodes+i]+w*dbasis[2*numnodes+i]);
    382382                        }
    383383                }
     
    393393}/*}}}*/
    394394ElementVector* ThermalAnalysis::CreatePVectorSheet(Element* element){/*{{{*/
    395         return NULL;
     395
     396        /* Geothermal flux on ice sheet base and basal friction */
     397        if(!element->IsOnBed() || element->IsFloating()) return NULL;
     398
     399        IssmDouble  dt,Jdet,geothermalflux,vx,vy,vz;
     400        IssmDouble  alpha2,scalar,basalfriction,heatflux;
     401        IssmDouble *xyz_list_base = NULL;
     402
     403        /*Fetch number of nodes for this finite element*/
     404        int numnodes = element->GetNumberOfNodes();
     405
     406        /*Initialize vectors*/
     407        ElementVector* pe    = element->NewElementVector();
     408        IssmDouble*    basis = xNew<IssmDouble>(numnodes);
     409
     410        /*Retrieve all inputs and parameters*/
     411        element->GetVerticesCoordinatesBase(&xyz_list_base);
     412        element->FindParam(&dt,TimesteppingTimeStepEnum);
     413        Input* vx_input             = element->GetInput(VxEnum);                          _assert_(vx_input);
     414        Input* vy_input             = element->GetInput(VyEnum);                          _assert_(vy_input);
     415        Input* vz_input             = element->GetInput(VzEnum);                          _assert_(vz_input);
     416        Input* geothermalflux_input = element->GetInput(BasalforcingsGeothermalfluxEnum); _assert_(geothermalflux_input);
     417        IssmDouble  rho_ice             = element->GetMaterialParameter(MaterialsRhoIceEnum);
     418        IssmDouble  heatcapacity        = element->GetMaterialParameter(MaterialsHeatcapacityEnum);
     419
     420        /*Build friction element, needed later: */
     421        Friction* friction=new Friction(element,3);
     422
     423        /* Start  looping on the number of gaussian points: */
     424        Gauss* gauss   = element->NewGaussBase(2);
     425        for(int ig=gauss->begin();ig<gauss->end();ig++){
     426                gauss->GaussPoint(ig);
     427
     428                element->JacobianDeterminantBase(&Jdet,xyz_list_base,gauss);
     429                element->NodalFunctions(basis,gauss);
     430
     431                geothermalflux_input->GetInputValue(&geothermalflux,gauss);
     432                friction->GetAlpha2(&alpha2,gauss,vx_input,vy_input,vz_input);
     433                vx_input->GetInputValue(&vx,gauss);
     434                vy_input->GetInputValue(&vy,gauss);
     435                vz_input->GetInputValue(&vz,gauss);
     436                vz = 0.;//FIXME
     437                basalfriction = alpha2*(vx*vx + vy*vy + vz*vz);
     438                heatflux      = (basalfriction+geothermalflux)/(rho_ice*heatcapacity);
     439
     440                scalar = gauss->weight*Jdet*heatflux;
     441                if(dt!=0.) scalar=dt*scalar;
     442
     443                for(int i=0;i<numnodes;i++) pe->values[i]+=scalar*basis[i];
     444        }
     445
     446        /*Clean up and return*/
     447        delete gauss;
     448        delete friction;
     449        xDelete<IssmDouble>(basis);
     450        xDelete<IssmDouble>(xyz_list_base);
     451        return pe;
    396452}/*}}}*/
    397453ElementVector* ThermalAnalysis::CreatePVectorShelf(Element* element){/*{{{*/
Note: See TracChangeset for help on using the changeset viewer.