Changeset 12644


Ignore:
Timestamp:
07/17/12 14:48:07 (13 years ago)
Author:
seroussi
Message:

added transient spc for enthalpy (need to be improved to use iomodelcreateconstraints)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/modules/ModelProcessorx/Enthalpy/CreateConstraintsEnthalpy.cpp

    r12529 r12644  
    99#include "../../../objects/objects.h"
    1010#include "../../../shared/shared.h"
     11#include "../../../include/include.h"
    1112#include "../ModelProcessorx.h"
    1213
     
    1415
    1516        /*Intermediary*/
    16         int i;
    17         int count;
     17        int    i,j;
     18        int    count;
    1819        int    dim;
     20        int    M,N;
    1921        int    numberofvertices;
     22        bool   spcpresent=false;
    2023        double heatcapacity;
    2124        double referencetemperature;
    2225       
    2326        /*Output*/
     27        IssmDouble *spcvector  = NULL;
     28        IssmDouble* times=NULL;
     29        IssmDouble* values=NULL;
    2430        Constraints* constraints = NULL;
    25         SpcStatic*    spcstatic  = NULL;
    2631
    2732        /*Fetch parameters: */
     
    4449
    4550        /*Fetch data: */
    46         double *spctemperature=NULL;
    47         iomodel->FetchData(&spctemperature,NULL,NULL,ThermalSpctemperatureEnum);
     51        iomodel->FetchData(&spcvector,&M,&N,ThermalSpctemperatureEnum);
    4852
    49         /*Initialize counter*/
    50         count=0;
     53        //FIX ME: SHOULD USE IOMODELCREATECONSTRAINTS
     54        /*Transient or static?:*/
     55        if(M==numberofvertices){
     56                /*static: just create Constraints objects*/
     57                count=0;
    5158
    52         /*Create constraints from x,y,z: */
    53         for (i=0;i<numberofvertices;i++){
    54                 /*keep only this partition's nodes:*/
    55                 if((iomodel->my_vertices[i])){
     59                for (i=0;i<numberofvertices;i++){
     60                        /*keep only this partition's nodes:*/
     61                        if((iomodel->my_vertices[i])){
    5662
    57                         if (!xIsNan<IssmDouble>(spctemperature[i])){
     63                                if (!xIsNan<IssmDouble>(spcvector[i])){
    5864
    59                                 constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,heatcapacity*(spctemperature[i]-referencetemperature),EnthalpyAnalysisEnum));
    60                                 count++;
     65                                        constraints->AddObject(new SpcStatic(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,heatcapacity*(spcvector[i]-referencetemperature),EnthalpyAnalysisEnum));
     66                                        count++;
    6167
     68                                }
    6269                        }
    6370                }
    6471        }
     72        else if (M==(numberofvertices+1)){
     73                /*transient: create transient SpcTransient objects. Same logic, except we need to retrieve
     74                 * various times and values to initialize an SpcTransient object: */
     75                count=0;
    6576
    66         /*Free data: */
    67         xDelete<double>(spctemperature);
    68        
     77                /*figure out times: */
     78                times=xNew<IssmDouble>(N);
     79                for(j=0;j<N;j++){
     80                        times[j]=spcvector[(M-1)*N+j];
     81                }
     82                /*unit conversion: */
     83                UnitConversion(times,N,ExtToIuEnum,TimeEnum);
     84
     85                /*Create constraints from x,y,z: */
     86                for (i=0;i<numberofvertices;i++){
     87                       
     88                        /*keep only this partition's nodes:*/
     89                        if((iomodel->my_vertices[i])){
     90
     91                                /*figure out times and values: */
     92                                values=xNew<IssmDouble>(N);
     93                                spcpresent=false;
     94                                for(j=0;j<N;j++){
     95                                        values[j]=heatcapacity*(spcvector[i*N+j]-referencetemperature);
     96                                        if(!xIsNan<IssmDouble>(values[j]))spcpresent=true; //NaN means no spc by default
     97                                }
     98
     99                                if(spcpresent){
     100                                        constraints->AddObject(new SpcTransient(iomodel->constraintcounter+count+1,iomodel->nodecounter+i+1,1,N,times,values,EnthalpyAnalysisEnum));
     101                                        count++;
     102                                }
     103                                xDelete<IssmDouble>(values);
     104                        }
     105                }
     106        }
     107        else{
     108                _error2_("Size of field " << EnumToStringx(ThermalSpctemperatureEnum) << " not supported");
     109        }
     110
     111        /*Free ressources:*/
     112        xDelete<IssmDouble>(spcvector);
     113        xDelete<IssmDouble>(times);
     114        xDelete<IssmDouble>(values);
     115
    69116        /*Assign output pointer: */
    70117        *pconstraints=constraints;
Note: See TracChangeset for help on using the changeset viewer.