00001
00002
00003
00004
00005
00006
00007 #include "homogmat.h"
00008 #include "globalt.h"
00009 #include "math.h"
00010
00011 homogmat::homogmat (void)
00012 {
00013 allocm (6,6,dd);
00014 allocm (3,3,cc);
00015 }
00016 homogmat::~homogmat (void)
00017 {
00018 destrm(dd);
00019 destrm(cc);
00020 }
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 void homogmat::matcond (matrix &d,long ri,long ci,long ipp)
00037 {
00038 long n;
00039 n = d.n;
00040
00041 switch (n){
00042 case 1:{
00043 matcond1d (d,ri,ci,ipp);
00044 break;
00045 }
00046 case 2:{
00047 matcond2d (d,ri,ci,ipp);
00048 break;
00049 }
00050 case 3:{
00051 matcond3d (d,ri,ci,ipp);
00052 break;
00053 }
00054 default:{
00055 print_err("unknown number of components of conductivity tensor is required",__FILE__,__LINE__,__func__);
00056 }
00057 }
00058 }
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071 void homogmat::matcond1d (matrix &d,long ri,long ci,long ipp)
00072 {
00073 d[0][0] = dd[ri][ci];
00074 }
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086 void homogmat::matcond2d (matrix &d,long ri,long ci,long ipp)
00087 {
00088 d[0][0] = dd[2*ri+0][2*ci+0]; d[0][1] = dd[2*ri+0][2*ci+1];
00089 d[1][0] = dd[2*ri+1][2*ci+0]; d[1][1] = dd[2*ri+1][2*ci+1];
00090 }
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102 void homogmat::matcond3d (matrix &d,long ri,long ci,long ipp)
00103 {
00104 d[0][0] = dd[3*ri+0][3*ci+0]; d[0][1] = dd[3*ri+0][3*ci+1]; d[0][2] = dd[3*ri+0][3*ci+2];
00105 d[1][0] = dd[3*ri+1][3*ci+0]; d[1][1] = dd[3*ri+1][3*ci+1]; d[1][2] = dd[3*ri+1][3*ci+2];
00106 d[2][0] = dd[3*ri+2][3*ci+0]; d[2][1] = dd[3*ri+2][3*ci+1]; d[2][2] = dd[3*ri+2][3*ci+2];
00107 }
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120 void homogmat::matcap (double &c,long ri,long ci,long ipp)
00121 {
00122 c = cc[ri][ci];
00123 }
00124
00125
00126
00127
00128
00129
00130
00131
00132 void homogmat::assemble_matrices (double *d,long ntm,long dim)
00133 {
00134 if (dim==2 && ntm==2){
00135 dd[0][0]=d[0]; dd[0][1]=d[1]; dd[0][2]=d[2]; dd[0][3]=d[3];
00136 dd[1][0]=d[4]; dd[1][1]=d[5]; dd[1][2]=d[6]; dd[1][3]=d[7];
00137 dd[2][0]=d[8]; dd[2][1]=d[9]; dd[2][2]=d[10]; dd[2][3]=d[11];
00138 dd[3][0]=d[12]; dd[3][1]=d[13]; dd[3][2]=d[14]; dd[3][3]=d[15];
00139
00140 cc[0][0]=d[16]; cc[0][1]=d[17];
00141 cc[1][0]=d[18]; cc[1][1]=d[19];
00142 }
00143 if (dim==3 && ntm==2){
00144 dd[0][0]=d[0]; dd[0][1]=d[1]; dd[0][2]=d[2]; dd[0][3]=d[3]; dd[0][4]=d[4]; dd[0][5]=d[5];
00145 dd[1][0]=d[6]; dd[1][1]=d[7]; dd[1][2]=d[8]; dd[1][3]=d[9]; dd[1][4]=d[10]; dd[1][5]=d[11];
00146 dd[2][0]=d[12]; dd[2][1]=d[13]; dd[2][2]=d[14]; dd[2][3]=d[15]; dd[2][4]=d[16]; dd[2][5]=d[17];
00147 dd[3][0]=d[18]; dd[3][1]=d[19]; dd[3][2]=d[20]; dd[3][3]=d[21]; dd[3][4]=d[22]; dd[3][5]=d[23];
00148 dd[4][0]=d[24]; dd[4][1]=d[25]; dd[4][2]=d[26]; dd[4][3]=d[27]; dd[4][4]=d[28]; dd[4][5]=d[29];
00149 dd[5][0]=d[30]; dd[5][1]=d[31]; dd[5][2]=d[32]; dd[5][3]=d[33]; dd[5][4]=d[34]; dd[5][5]=d[35];
00150
00151 cc[0][0]=d[36]; cc[0][1]=d[37];
00152 cc[1][0]=d[38]; cc[1][1]=d[39];
00153 }
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164 }
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177
00178
00179
00180 double homogmat::transmission_transcoeff(double trc,long ri,long ci,long nn,long bc,long ipp)
00181 {
00182 long k;
00183 double new_trc,w,t;
00184 new_trc = 0.0;
00185
00186 k=Gtt->give_dof(nn,0);
00187 if (k>0) {w = Lsrst->lhs[k-1]+Lsrst->lhsi[k-1];}
00188 if (k==0) {w = 0.0;}
00189 if (k<0) {w = Tb->lc[0].pv[0-k-1].getval();}
00190 k=Gtt->give_dof(nn,1);
00191 if (k>0) {t = Lsrst->lhs[k-1]+Lsrst->lhsi[k-1];}
00192 if (k==0) {t = 0.0;}
00193 if (k<0) {t = Tb->lc[0].pv[0-k-1].getval();}
00194
00195 if((ri == 0) && (ci == 0))
00196 new_trc = get_transmission_transcoeff_ww(w,t,bc,ipp);
00197 if((ri == 0) && (ci == 1))
00198 new_trc = 0.0;
00199
00200 if((ri == 1) && (ci == 0))
00201 new_trc = 0.0;
00202 if((ri == 1) && (ci == 1))
00203 new_trc = get_transmission_transcoeff_tt(w,t,bc,ipp);
00204
00205 new_trc = new_trc*trc;
00206
00207 return (new_trc);
00208 }
00209
00210
00211
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225 double homogmat::transmission_nodval(double nodval,double trc2,long ri,long ci,long nn,long bc,long ipp)
00226 {
00227 long k;
00228 double new_nodval,w,t;
00229 new_nodval = 0.0;
00230
00231 k=Gtt->give_dof(nn,0);
00232 if (k>0) {w = Lsrst->lhs[k-1]+Lsrst->lhsi[k-1];}
00233 if (k==0) {w = 0.0;}
00234 if (k<0) {w = Tb->lc[0].pv[0-k-1].getval();}
00235 k=Gtt->give_dof(nn,1);
00236 if (k>0) {t = Lsrst->lhs[k-1]+Lsrst->lhsi[k-1];}
00237 if (k==0) {t = 0.0;}
00238 if (k<0) {t = Tb->lc[0].pv[0-k-1].getval();}
00239
00240 if((ri == 0) && (ci == 0))
00241 new_nodval = get_transmission_nodval_ww(nodval,w,t,bc,ipp);
00242 if((ri == 0) && (ci == 1))
00243 new_nodval = 0.0;
00244
00245 if((ri == 1) && (ci == 0))
00246 new_nodval = 0.0;
00247 if((ri == 1) && (ci == 1))
00248 new_nodval = get_transmission_nodval_tt(nodval,w,t,bc,ipp);
00249
00250 return (new_nodval);
00251 }
00252
00253
00254
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269 double homogmat::transmission_flux(double nodval,double trc2,long ri,long ci,long nn,long bc,long ipp)
00270 {
00271 long k;
00272 double flux,w,t;
00273 flux = 0.0;
00274
00275 k=Gtt->give_dof(nn,0);
00276 if (k>0) {w = Lsrst->lhs[k-1]+Lsrst->lhsi[k-1];}
00277 if (k==0) {w = 0.0;}
00278 if (k<0) {w = Tb->lc[0].pv[0-k-1].getval();}
00279 k=Gtt->give_dof(nn,1);
00280 if (k>0) {t = Lsrst->lhs[k-1]+Lsrst->lhsi[k-1];}
00281 if (k==0) {t = 0.0;}
00282 if (k<0) {t = Tb->lc[0].pv[0-k-1].getval();}
00283
00284 if((ri == 0) && (ci == 0))
00285 flux = get_transmission_flux_ww(nodval,w,t,bc,ipp);
00286 if((ri == 0) && (ci == 1))
00287 flux = 0.0;
00288
00289 if((ri == 1) && (ci == 0))
00290 flux = 0.0;
00291 if((ri == 1) && (ci == 1))
00292 flux = get_transmission_flux_tt(nodval,w,t,bc,ipp);
00293
00294 return (flux);
00295 }
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307 double homogmat::get_transmission_transcoeff_ww(double w,double t,long bc,long ipp)
00308 {
00309 double trc;
00310
00311 switch (bc){
00312 case 30:{
00313 trc = 1.0;
00314 break;
00315 }
00316 default:{
00317 print_err("\n\n No real boundary condition is prescribed (%s, line %d).\n",__FILE__,__LINE__,__func__);
00318 exit(0);
00319 }
00320 }
00321
00322 return(trc);
00323 }
00324
00325
00326
00327
00328
00329
00330
00331
00332
00333
00334
00335 double homogmat::get_transmission_nodval_ww(double bv,double w,double t,long bc,long ipp)
00336 {
00337 double nodval;
00338
00339 switch (bc){
00340 case 30:{
00341 nodval = bv;
00342 break;
00343 }
00344 default:{
00345 print_err("\n\n No real boundary condition is prescribed (%s, line %d).\n",__FILE__,__LINE__,__func__);
00346 exit(0);
00347 }
00348 }
00349 return(nodval);
00350 }
00351
00352
00353
00354
00355
00356
00357
00358
00359
00360
00361
00362
00363 double homogmat::get_transmission_flux_ww(double bv,double w,double t,long bc,long ipp)
00364 {
00365 double flux;
00366
00367 switch (bc){
00368 case 30:{
00369 flux = (bv - t);
00370 break;
00371 }
00372 default:{
00373 print_err("\n\n No real boundary condition is prescribed (%s, line %d).\n",__FILE__,__LINE__,__func__);
00374 exit(0);
00375 }
00376 }
00377 return(flux);
00378 }
00379
00380
00381
00382
00383
00384
00385
00386
00387
00388
00389
00390 double homogmat::get_transmission_transcoeff_tt(double w,double t,long bc,long ipp)
00391 {
00392 double trc;
00393
00394 switch (bc){
00395 case 30:{
00396 trc = 1.0;
00397 break;
00398 }
00399 case 31:{
00400 trc = 0.0;
00401 break;
00402 }
00403 default:{
00404 print_err("\n\n No real boundary condition is prescribed (%s, line %d).\n",__FILE__,__LINE__,__func__);
00405 exit(0);
00406 }
00407 }
00408
00409 return(trc);
00410 }
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422 double homogmat::get_transmission_nodval_tt(double bv,double w,double t,long bc,long ipp)
00423 {
00424 double nodval;
00425
00426 switch (bc){
00427 case 30:{
00428 nodval = bv;
00429 break;
00430 }
00431 case 31:{
00432 nodval = (bv - t);
00433 break;
00434 }
00435 default:{
00436 print_err("\n\n No real boundary condition is prescribed (%s, line %d).\n",__FILE__,__LINE__,__func__);
00437 exit(0);
00438 }
00439 }
00440 return(nodval);
00441 }
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454 double homogmat::get_transmission_flux_tt(double bv,double w,double t,long bc,long ipp)
00455 {
00456 double flux;
00457
00458 switch (bc){
00459 case 30:{
00460 flux = (bv - t);
00461 break;
00462 }
00463 case 31:{
00464 flux = (bv - t);
00465 break;
00466 }
00467 default:{
00468 print_err("\n\n No real boundary condition is prescribed (%s, line %d).\n",__FILE__,__LINE__,__func__);
00469 exit(0);
00470 }
00471 }
00472 return(flux);
00473 }
00474
00475
00476
00477
00478
00479
00480
00481
00482
00483
00484
00485 double homogmat::get_othervalue(long compother,double rh,double t,long ipp)
00486 {
00487 double other;
00488
00489 switch (compother){
00490 case 0:{
00491 other = rh;
00492 break;
00493 }
00494 case 1:{
00495 other = t;
00496 break;
00497 }
00498 default:{
00499 print_err("\n\n This component type is not implemented\n",__FILE__,__LINE__,__func__);
00500 }
00501 }
00502 return (other);
00503 }
00504
00505
00506
00507
00508
00509
00510
00511
00512 void homogmat::print_othervalue_name(FILE *out,long compother)
00513 {
00514 switch (compother){
00515 case 0:{
00516 fprintf (out,"Relative humidity () ");
00517 break;
00518 }
00519 case 1:{
00520 fprintf (out,"Temperature (K) ");
00521 break;
00522 }
00523 default:{
00524 print_err("\n\n This component type is not implemented\n",__FILE__,__LINE__,__func__);
00525 }
00526 }
00527 }
00528
00529
00530
00531
00532
00533
00534
00535
00536
00537
00538
00539 void homogmat::give_dof_names(namevart *dofname, long ntm)
00540 {
00541 if (ntm < 1)
00542 {
00543 print_err("the model defines %ld unknowns but number of transported media is %ld",
00544 __FILE__, __LINE__, __func__, 1, ntm);
00545 abort();
00546 }
00547
00548 dofname[0] = trf_rel_humidity;
00549 dofname[1] = trf_temperature;
00550 }