00001 module model
00002
00003
00004
00005 use global
00006
00007 use myFunctions
00008
00009 implicit none
00010
00011
00012 contains
00013
00014
00015 function discrete(a)
00016
00017
00018 real(8) discrete(globalCurrentSetLength)
00019
00020 integer i,j,t
00021
00022 integer a
00023
00024 integer myI,myJ,myT,myBC,myUnk
00025
00026 integer myP,myD
00027
00028 integer,pointer :: IM(:,:,:,:)
00029
00030 integer,pointer :: IM2(:,:,:,:)
00031
00032 integer,pointer :: maxI,maxJ,maxT
00033
00034 integer,pointer :: iVec(:),jVec(:),bcVec(:),tVec(:)
00035
00036 integer,pointer :: endIndex(:)
00037
00038 integer modelPhysics
00039 integer modelDomain
00040
00041 real(8), allocatable :: RHS(:)
00042
00043 integer,pointer :: dof
00044
00045 integer,pointer :: nx,ny
00046
00047
00048
00049
00050
00051
00052 real(8) Tc,Tw,Te,Ts,Tn
00053
00054 real(8) T1,T2,T3,T4
00055
00056 real(8) d2TdX2,d2TdY2
00057
00058
00059
00060 real(8) dtau
00061
00062 real(8) upu,upv
00063
00064 real(8) myU,myV
00065
00066
00067
00068 real(8) sourceT
00069 real(8) sourceU
00070
00071 real(8) dx,dy
00072
00073
00074
00075
00076
00077
00078 do i=1,a
00079 discreteY=>tempy
00080 end do
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092 discrete=-1.d0
00093
00094
00095 x=>discreteY
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135
00136
00137
00138
00139
00140
00141
00142 modelPhysics=1
00143 modelDomain=1
00144
00145
00146 sourceT=1.d0
00147
00148
00149
00150
00151
00152
00153 dx=1.d0/(myModel%physics(modelPhysics)%domain(modelDomain)%maxI-myModel%physics(modelPhysics)%domain(modelDomain)%minI)
00154 dy=1.d0/(myModel%physics(modelPhysics)%domain(modelDomain)%maxJ-myModel%physics(modelPhysics)%domain(modelDomain)%minJ)
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172 dof=>myModel%physics(modelPhysics)%dof
00173
00174 IM=>myModel%physics(modelPhysics)%domain(modelDomain)%dofMatrix
00175
00176 IM2=>myModel%physics(2)%domain(1)%dofMatrix
00177
00178
00179 allocate(RHS(dof))
00180 RHS=0.d0
00181
00182
00183
00184
00185
00186
00187 do myP=1,myModel%endIndex(modelPhysics)
00188
00189
00190 do myD=1,myModel%physics(modelPhysics)%endIndex(modelDomain)
00191
00192
00193
00194
00195
00196
00197
00198 myBC=2
00199
00200 maxJ=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%maxJ
00201 jVec=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%jVec
00202
00203
00204 do myJ=1,maxJ
00205
00206 j=jVec(myJ)
00207 maxI=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%j(myJ)%maxI
00208 iVec=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%j(myJ)%iVec
00209
00210 RHS=0
00211 do myI=1,maxI
00212
00213 i=iVec(myI)
00214
00215 maxT=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%j(myJ)%i(myI)%maxT
00216 tVec=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%j(myJ)%i(myI)%tVec
00217 endIndex=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%j(myJ)%i(myI)%endIndex
00218
00219
00220 t=1
00221 do myT=1,endIndex(t)
00222
00223
00224 TC=x(IM(i,j,1,absolute))
00225
00226
00227
00228 RHS(t)=TC-0.d0
00229
00230 end do
00231
00232
00233
00234 do myT=1,maxT
00235
00236 t=tVec(myT)
00237
00238
00239
00240 discrete(IM(i,j,t,relative))=rhs(t)
00241
00242 end do
00243
00244 end do
00245
00246
00247
00248 end do
00249
00250
00251
00252
00253
00254 myBC=3
00255
00256 maxJ=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%maxJ
00257 jVec=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%jVec
00258
00259
00260 do myJ=1,maxJ
00261
00262 j=jVec(myJ)
00263 maxI=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%j(myJ)%maxI
00264 iVec=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%j(myJ)%iVec
00265
00266 RHS=0
00267 do myI=1,maxI
00268
00269 i=iVec(myI)
00270
00271 maxT=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%j(myJ)%i(myI)%maxT
00272 tVec=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%j(myJ)%i(myI)%tVec
00273 endIndex=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%j(myJ)%i(myI)%endIndex
00274
00275
00276 t=1
00277 do myT=1,endIndex(t)
00278
00279
00280 TC=x(IM(i,j,1,absolute))
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292 T1=x(IM2(1,j,1,absolute))
00293 T2=x(IM2(1+1,j,1,absolute))
00294 T3=x(IM2(1+1,j+1,1,absolute))
00295 T4=x(IM2(1,j+1,1,absolute))
00296
00297
00298 RHS(t)=TC-(T1+T2+T3+T4)/4.d0
00299
00300 end do
00301
00302
00303 do myT=1,maxT
00304
00305 t=tVec(myT)
00306
00307
00308
00309 discrete(IM(i,j,t,relative))=rhs(t)
00310
00311
00312 end do
00313
00314 end do
00315
00316
00317 end do
00318
00319
00320
00321
00322
00323 myBC=1
00324
00325 maxJ=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%maxJ
00326 jVec=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%jVec
00327
00328 do myJ=1,maxJ
00329
00330 j=jVec(myJ)
00331 maxI=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%j(myJ)%maxI
00332 iVec=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%j(myJ)%iVec
00333
00334 RHS=0
00335 do myI=1,maxI
00336
00337 i=iVec(myI)
00338
00339 maxT=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%j(myJ)%i(myI)%maxT
00340 tVec=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%j(myJ)%i(myI)%tVec
00341 endIndex=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%j(myJ)%i(myI)%endIndex
00342
00343
00344 t=1
00345 do myT=1,endIndex(t)
00346
00347
00348 TC=x(IM(i,j,1,absolute))
00349 TW=x(IM(i-1,j,1,absolute))
00350 TE=x(IM(i+1,j,1,absolute))
00351 TS=x(IM(i,j-1,1,absolute))
00352 TN=x(IM(i,j+1,1,absolute))
00353
00354 d2TdX2=(TE+TW-2.d0*TC)/(dx**2.d0)
00355
00356 d2TdY2=(TN+TS-2.d0*TC)/(dy**2.d0)
00357
00358 RHS(t)=d2TdX2+d2TdY2+sourceT
00359
00360
00361
00362
00363
00364 end do
00365
00366
00367
00368 do myT=1,maxT
00369
00370 t=tVec(myT)
00371
00372
00373
00374 discrete(IM(i,j,t,relative))=rhs(t)
00375
00376 end do
00377
00378 end do
00379
00380
00381 end do
00382
00383
00384
00385 end do
00386
00387 end do
00388
00389
00390
00391
00392
00393
00394
00395
00396 deallocate(RHS)
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430 modelPhysics=2
00431
00432
00433 modelDomain=1
00434
00435
00436
00437 dof=>myModel%physics(modelPhysics)%dof
00438
00439 IM=>myModel%physics(modelPhysics)%domain(modelDomain)%dofMatrix
00440
00441 IM2=>myModel%physics(1)%domain(1)%dofMatrix
00442
00443 allocate(RHS(dof))
00444 RHS=0.d0
00445
00446
00447
00448
00449
00450 nx=>myModel%physics(1)%domain(1)%nx
00451 ny=>myModel%physics(1)%domain(1)%ny
00452
00453
00454
00455
00456
00457
00458 do myP=1,myModel%endIndex(modelPhysics)
00459
00460
00461 do myD=1,myModel%physics(modelPhysics)%endIndex(modelDomain)
00462
00463
00464
00465
00466
00467
00468 myBC=2
00469
00470 maxJ=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%maxJ
00471 jVec=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%jVec
00472
00473
00474 do myJ=1,maxJ
00475
00476 j=jVec(myJ)
00477 maxI=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%j(myJ)%maxI
00478 iVec=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%j(myJ)%iVec
00479
00480 RHS=0
00481 do myI=1,maxI
00482
00483 i=iVec(myI)
00484
00485 maxT=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%j(myJ)%i(myI)%maxT
00486 tVec=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%j(myJ)%i(myI)%tVec
00487 endIndex=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%j(myJ)%i(myI)%endIndex
00488
00489
00490 t=1
00491 do myT=1,endIndex(t)
00492
00493
00494 TC=x(IM(i,j,1,absolute))
00495
00496 RHS(t)=TC-0.d0
00497
00498 end do
00499
00500
00501 do myT=1,maxT
00502
00503 t=tVec(myT)
00504
00505 discrete(IM(i,j,t,relative))=rhs(t)
00506
00507
00508
00509 end do
00510
00511 end do
00512
00513
00514 end do
00515
00516
00517
00518
00519 myBC=3
00520
00521 maxJ=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%maxJ
00522 jVec=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%jVec
00523
00524
00525 do myJ=1,maxJ
00526
00527 j=jVec(myJ)
00528 maxI=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%j(myJ)%maxI
00529 iVec=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%j(myJ)%iVec
00530
00531 RHS=0
00532 do myI=1,maxI
00533
00534 i=iVec(myI)
00535
00536 maxT=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%j(myJ)%i(myI)%maxT
00537 tVec=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%j(myJ)%i(myI)%tVec
00538 endIndex=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%j(myJ)%i(myI)%endIndex
00539
00540
00541 t=1
00542 do myT=1,endIndex(t)
00543
00544
00545 TC=x(IM(i,j,1,absolute))
00546
00547
00548
00549
00550
00551
00552
00553
00554
00555 T1=x(IM2(nx-1,j-1,1,absolute))
00556 T2=x(IM2(nx-1+1,j-1,1,absolute))
00557 T3=x(IM2(nx-1+1,j,1,absolute))
00558 T4=x(IM2(nx-1,j,1,absolute))
00559
00560
00561 RHS(t)=TC-(T1+T2+T3+T4)/4.d0
00562
00563 end do
00564
00565
00566 do myT=1,maxT
00567
00568 t=tVec(myT)
00569
00570 discrete(IM(i,j,t,relative))=rhs(t)
00571
00572
00573
00574 end do
00575
00576 end do
00577
00578
00579 end do
00580
00581
00582
00583
00584
00585 myBC=1
00586
00587 maxJ=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%maxJ
00588 jVec=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%jVec
00589
00590 do myJ=1,maxJ
00591
00592 j=jVec(myJ)
00593 maxI=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%j(myJ)%maxI
00594 iVec=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%j(myJ)%iVec
00595
00596 RHS=0
00597 do myI=1,maxI
00598
00599 i=iVec(myI)
00600
00601 maxT=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%j(myJ)%i(myI)%maxT
00602 tVec=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%j(myJ)%i(myI)%tVec
00603 endIndex=>myModel%physics(modelPhysics)%domain(modelDomain)%set%bc(myBC)%j(myJ)%i(myI)%endIndex
00604
00605
00606 t=1
00607 do myT=1,endIndex(t)
00608
00609 TC=x(IM(i,j,1,absolute))
00610 TW=x(IM(i-1,j,1,absolute))
00611 TE=x(IM(i+1,j,1,absolute))
00612 TS=x(IM(i,j-1,1,absolute))
00613 TN=x(IM(i,j+1,1,absolute))
00614
00615 d2TdX2=(TE+TW-2.d0*TC)/(dx**2.d0)
00616
00617 d2TdY2=(TN+TS-2.d0*TC)/(dy**2.d0)
00618
00619 RHS(t)=d2TdX2+d2TdY2+sourceT
00620
00621
00622
00623
00624 end do
00625
00626
00627
00628 do myT=1,maxT
00629
00630 t=tVec(myT)
00631
00632 discrete(IM(i,j,t,relative))=rhs(t)
00633
00634
00635 end do
00636
00637 end do
00638
00639
00640 end do
00641
00642
00643 end do
00644
00645
00646 end do
00647
00648
00649
00650
00651
00652
00653
00654
00655
00656
00657
00658
00659
00660
00661
00662
00663 deallocate(RHS)
00664
00665
00666
00667 discreteY=>y
00668
00669 end function discrete
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680
00681
00682 end module model