Changeset 12644
- Timestamp:
- 07/17/12 14:48:07 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/modules/ModelProcessorx/Enthalpy/CreateConstraintsEnthalpy.cpp
r12529 r12644 9 9 #include "../../../objects/objects.h" 10 10 #include "../../../shared/shared.h" 11 #include "../../../include/include.h" 11 12 #include "../ModelProcessorx.h" 12 13 … … 14 15 15 16 /*Intermediary*/ 16 int i;17 int count;17 int i,j; 18 int count; 18 19 int dim; 20 int M,N; 19 21 int numberofvertices; 22 bool spcpresent=false; 20 23 double heatcapacity; 21 24 double referencetemperature; 22 25 23 26 /*Output*/ 27 IssmDouble *spcvector = NULL; 28 IssmDouble* times=NULL; 29 IssmDouble* values=NULL; 24 30 Constraints* constraints = NULL; 25 SpcStatic* spcstatic = NULL;26 31 27 32 /*Fetch parameters: */ … … 44 49 45 50 /*Fetch data: */ 46 double *spctemperature=NULL; 47 iomodel->FetchData(&spctemperature,NULL,NULL,ThermalSpctemperatureEnum); 51 iomodel->FetchData(&spcvector,&M,&N,ThermalSpctemperatureEnum); 48 52 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; 51 58 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])){ 56 62 57 if (!xIsNan<IssmDouble>(spctemperature[i])){63 if (!xIsNan<IssmDouble>(spcvector[i])){ 58 64 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++; 61 67 68 } 62 69 } 63 70 } 64 71 } 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; 65 76 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 69 116 /*Assign output pointer: */ 70 117 *pconstraints=constraints;
Note:
See TracChangeset
for help on using the changeset viewer.