1 | include(dom.inc)
2 |
3 | PROGRAM initbc
4 |
5 | ! ================================================================!
6 | ! !
7 | ! initbc.F : Creates boundary conditions for PRISSMA !
8 | ! !
9 | ! author : J. AMAYA (february 2008) !
10 | ! !
11 | ! ================================================================!
12 |
13 | IMPLICIT NONE
14 |
15 | include 'dom_constants.h'
16 |
17 | DOM_INT :: ntcells, ntnodes, ntfaces, ntfacesmax
18 | DOM_INT :: i, j, k, icell, patch, cellnfaces, nbfaces
19 |
20 | DOM_REAL :: r, d
21 | DOM_REAL :: emissivity, T
22 |
23 | CHARACTER*80 :: clpropfile, cefacefile, emisfile
24 | CHARACTER*80 :: gdatafile, path, cldatfile, clfacfile
25 |
26 | DOM_REAL :: x, y, z
27 | DOM_REAL :: L_ref, R_ref, x_ref, y_ref, z_ref
28 |
29 | DOM_REAL, ALLOCATABLE, DIMENSION(:,:) :: xfc, yfc, zfc
30 | DOM_REAL, ALLOCATABLE, DIMENSION(:,:) :: Tw, newepsil
31 | DOM_INT , ALLOCATABLE, DIMENSION(:,:) :: facepatch
32 |
33 | ! ------------------!
34 | ! Read choices file !
35 | ! ------------------!
36 |
37 | OPEN (FILE_CHCS , FILE='initbc.choices', FORM='FORMATTED')
38 | READ (FILE_CHCS,*) path
39 | CLOSE(FILE_CHCS)
40 |
41 | ! -----------!
42 | ! Open files !
43 | ! -----------!
44 |
45 | clpropfile = path(1:len_trim(path))//'/CLProperties.in'
46 | emisfile = path(1:len_trim(path))//'/Emissivities.in'
47 | cefacefile = path(1:len_trim(path))//'/Centerfaces.in'
48 | gdatafile = path(1:len_trim(path))//'/Global.in'
49 | cldatfile = path(1:len_trim(path))//'/CLdata.in'
50 | clfacfile = path(1:len_trim(path))//'/CLFaces.in'
51 |
52 | OPEN(FILE_CLPRO, FILE=clpropfile, FORM='UNFORMATTED')
53 | OPEN(FILE_CFACE, FILE=cefacefile, FORM='UNFORMATTED')
54 | OPEN(FILE_GDATA, FILE=gdatafile , FORM='UNFORMATTED')
55 | OPEN(FILE_CLFAC, FILE=clfacfile , FORM='UNFORMATTED')
56 | ! OPEN(FILE_EMIS , FILE=emisfile , FORM='UNFORMATTED')
57 |
58 | ! ----------------------!
59 | ! Read Global mesh data !
60 | ! ----------------------!
61 |
62 | WRITE(*,*) " Reading Global data."
63 |
64 | READ(FILE_GDATA) ntcells, ntnodes, ntfaces, ntfacesmax
65 | CLOSE(FILE_GDATA)
66 |
67 | ! -----------------!
68 | ! Allocate vectors !
69 | ! -----------------!
70 |
71 | ALLOCATE(xfc (ntfacesmax,ntcells))
72 | ALLOCATE(yfc (ntfacesmax,ntcells))
73 | ALLOCATE(zfc (ntfacesmax,ntcells))
74 | ALLOCATE(Tw (ntfacesmax,ntcells))
75 | ALLOCATE(newepsil (ntfacesmax,ntcells))
76 | ALLOCATE(facepatch(ntfacesmax,ntcells))
77 |
78 | ! ---------------------------!
79 | ! Read properties from files !
80 | ! ---------------------------!
81 |
82 | WRITE(*,*) " Reading Boundary data"
83 |
84 | DO j=1, ntcells
85 |
86 | READ(FILE_CFACE) icell, cellnfaces, &
87 | & (xfc(i,j), yfc(i,j), zfc(i,j),i=1,cellnfaces)
88 | READ(FILE_CLPRO) icell, cellnfaces, &
89 | & (Tw(i,j), facepatch(i,j), i=1, cellnfaces)
90 | ! READ(FILE_EMIS) icell, cellnfaces,(epsil(i,j),i=1,cellnfaces)
91 | ! print*, " cell: ",j,"/",ntcells,":",epsil(:,j)
92 |
93 | ENDDO
94 |
95 | ! --------------------!
96 | ! Set boundary values !
97 | ! --------------------!
98 |
99 | WRITE(*,*) " Writing the new boundary conditions"
100 |
101 | CLOSE(FILE_CLPRO)
102 | ! CLOSE(FILE_EMIS )
103 | CLOSE(FILE_CFACE)
104 |
105 | newepsil = -1.
106 | Tw = 0.
107 |
108 | OPEN(FILE_CLPRO, FILE=clpropfile, FORM='UNFORMATTED')
109 | OPEN(FILE_CFACE, FILE=cefacefile, FORM='UNFORMATTED')
110 | OPEN(FILE_EMIS , FILE=emisfile , FORM='UNFORMATTED')
111 | OPEN(FILE_CLDAT, FILE=cldatfile , FORM='UNFORMATTED')
112 |
113 | nbfaces = 0
114 | DO j=1, ntcells
115 |
116 | READ(FILE_CFACE) icell, cellnfaces
117 |
118 | DO i=1, cellnfaces
119 |
120 | patch = facepatch(i,j)
121 |
122 | IF (patch.ne.0) THEN
123 |
124 | ! --------------------------!
125 | ! by default emessivity = 1 !
126 | ! --------------------------!
127 | newepsil(i,j) = 1.
128 |
129 | x = xfc(i,j)
130 | y = yfc(i,j)
131 | z = zfc(i,j)
132 |
133 | include 'clperso.inc'
134 |
135 | newepsil(i,j) = emissivity
136 | Tw(i,j) = T
137 |
138 | WRITE(FILE_CLDAT) j, i, emissivity, T
139 | nbfaces = nbfaces + 1
140 | ENDIF
141 |
142 | ENDDO
143 |
144 | ! -------------------------!
145 | ! Write new values to file !
146 | ! -------------------------!
147 |
148 | WRITE(FILE_CLPRO) icell, cellnfaces, &
149 | & (Tw(i,j), facepatch(i,j), i=1, cellnfaces)
150 | ! print*, " cell: ",j,"/",ntcells,":",newepsil(:,j)
151 | WRITE(FILE_EMIS) icell, cellnfaces, &
152 | & (newepsil(i,j),i=1,cellnfaces)
153 |
154 | ENDDO
155 |
156 | OPEN(FILE_CLFAC, FILE=clfacfile , FORM='UNFORMATTED')
157 | WRITE(FILE_CLFAC) nbfaces
158 |
159 | CLOSE(FILE_CLPRO)
160 | CLOSE(FILE_CFACE)
161 | CLOSE(FILE_CLDAT)
162 | CLOSE(FILE_CLFAC)
163 |
164 | WRITE(*,*) " initbc: Succesful run!"
165 |
166 | END PROGRAM initbc