File: lagran.f90

package info (click to toggle)
code-saturne 4.3.3%2Brepack-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 77,992 kB
  • sloc: ansic: 281,257; f90: 122,305; python: 56,490; makefile: 3,915; xml: 3,285; cpp: 3,183; sh: 1,139; lex: 176; yacc: 101; sed: 16
file content (471 lines) | stat: -rw-r--r-- 17,608 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
!-------------------------------------------------------------------------------

! This file is part of Code_Saturne, a general-purpose CFD tool.
!
! Copyright (C) 1998-2016 EDF S.A.
!
! This program is free software; you can redistribute it and/or modify it under
! the terms of the GNU General Public License as published by the Free Software
! Foundation; either version 2 of the License, or (at your option) any later
! version.
!
! This program is distributed in the hope that it will be useful, but WITHOUT
! ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
! FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
! details.
!
! You should have received a copy of the GNU General Public License along with
! this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
! Street, Fifth Floor, Boston, MA 02110-1301, USA.

!-------------------------------------------------------------------------------

!> \file lagran.f90
!> \brief Module for Lagrangian model.

module lagran

  !===========================================================================

  use, intrinsic :: iso_c_binding

  implicit none

  !> \defgroup lagran Module for Lagrangian model

  !> \addtogroup lagran
  !> \{

  !=============================================================================

  !> \defgroup base Base

  !> \addtogroup base
  !> \{

  !> \anchor iilagr
  !> activates (>0) or deactivates (=0) the Lagrangian module
  !> the different values correspond to the following modellings:
  !> - = 1 Lagrangian two-phase flow in one-way coupling (no influence of
  !> the particles on the continuous phase)
  !> - = 2 Lagrangian two-phase flow with two-way coupling (influence of
  !> the particles on the dynamics of the continuous phase).
  !> Dynamics, temperature and mass may be coupled independently.
  !> - = 3 Lagrangian two-phase flow on frozen continuous phase. This option can
  !> only be used in case of a calculation restart. All the
  !> Eulerian fields are frozen (including the scalar fields). This option
  !> automatically implies \ref iccvfg = 1
  integer(c_int), pointer, save :: iilagr

  !> \}

  !=============================================================================

  !> \defgroup lag_st_pointers Lagrangian source term pointers

  !> \addtogroup lag_st_pointers
  !> \{

  !> \anchor ntersl
  integer(c_int), pointer, save :: ntersl

  !> \anchor ptsvar
  double precision, dimension(:,:), pointer, save :: ptsvar

  !> \}

  !> \}

  !=============================================================================

  !> \defgroup specific_physic Specific physics

  !> \addtogroup specific_physic
  !> \{

  !> - 0: no deposition submodel activated,
  !> - 1: deposition submodel used
  integer(c_int), pointer, save :: idepst

  !> - 0: no head losses calculation for influence of the deposit on the flow
  !> - 1: head losses calculation for influence of the deposit on the flow
  integer, save :: iflow

  !> - 0: no precipitation/dissolution model
  !> - 1: precipitation/dissolution model
  integer(c_int), pointer, save :: ipreci

  !> \}

  !=============================================================================

  !> \defgroup source_terms Source terms

  !> \addtogroup source_terms
  !> \{

  !> activation (=1) or not (=0) of the two-way coupling on the dynamics
  !> of the continuous phase.
  !> Useful if \ref iilagr = 2 and \ref iccvfg = 0
  integer(c_int), pointer, save ::  ltsdyn

  !> activation (=1) or not (=0) of the two-way coupling on the mass.
  !> Useful if \ref iilagr = 2, \ref physical_model = 1 and \ref impvar = 1
  integer(c_int), pointer, save ::  ltsmas

  !> if \ref physical_model = 1 and \ref itpvar = 1, \ref ltsthe
  !> activates (=1) or not (=0) the two-way coupling on temperature.
  !> if \ref physical_model = 2, \ref ltsthe activates (=1) or not (=0) the
  !> two-way coupling on the eulerian variables related to pulverised
  !> coal combustion.
  !> Useful if \ref iilagr = 2
  integer(c_int), pointer, save ::  ltsthe

  !> explicit source term for the continuous phase X velocity
  integer(c_int), pointer, save ::  itsvx

  !> explicit source term for the continuous phase Y velocity
  integer(c_int), pointer, save ::  itsvy

  !> explicit source term for the continuous phase Z velocity
  integer(c_int), pointer, save ::  itsvz

  !> implicit source term for the continuous phase velocity and
  !> for the turbulent energy if the \f$k-\varepsilon\f$ model is used
  integer(c_int), pointer, save ::  itsli

  !> explicit source term for the turbulent dissipation and the
  !> turbulent energy if the \f$k-\varepsilon\f$ turbulence model is used
  !> for the continuous phase
  integer(c_int), pointer, save ::  itske

  !> source term for the Reynolds stress
  !> and the turbulent dissipation if the \f$R_{ij}-\varepsilon\f$
  !> turbulence model is used for the continuous phase
  integer(c_int), pointer, save ::  itsr11

  !> source term for the Reynolds stress
  !> and the turbulent dissipation if the \f$R_{ij}-\varepsilon\f$
  !> turbulence model is used for the continuous phase
  integer(c_int), pointer, save ::  itsr12
  !> source term for the Reynolds stress
  !> and the turbulent dissipation if the \f$R_{ij}-\varepsilon\f$
  !> turbulence model is used for the continuous phase
  integer(c_int), pointer, save ::  itsr13
  !> source term for the Reynolds stress
  !> and the turbulent dissipation if the \f$R_{ij}-\varepsilon\f$
  !> turbulence model is used for the continuous phase
  integer(c_int), pointer, save ::  itsr22
  !> source term for the Reynolds stress
  !> and the turbulent dissipation if the \f$R_{ij}-\varepsilon\f$
  !> turbulence model is used for the continuous phase
  integer(c_int), pointer, save ::  itsr23
  !> source term for the Reynolds stress
  !> and the turbulent dissipation if the \f$R_{ij}-\varepsilon\f$
  !> turbulence model is used for the continuous phase
  integer(c_int), pointer, save ::  itsr33

  !> explicit thermal source term for the thermal scalar of the continuous phase
  integer(c_int), pointer, save ::  itste

  !> implicit thermal source term for the thermal scalar of the continuous phase
  integer(c_int), pointer, save ::  itsti

  !> mass source term
  integer(c_int), pointer, save ::  itsmas

  !> source term for the light volatile matters
  integer(c_int), dimension(:), pointer, save ::  itsmv1

  !> source term for the heavy volatile matters
  integer(c_int),  dimension(:), pointer, save ::  itsmv2

  !> source term for the carbon released during heterogeneous combustion
  integer(c_int), pointer, save ::  itsco

  !> \}

  !=============================================================================

  interface

    !---------------------------------------------------------------------------

    ! Interface to C function returning particle attribute pointers
    subroutine cs_f_lagr_dim_pointers(p_ntersl) &
      bind(C, name='cs_f_lagr_dim_pointers')
      use, intrinsic :: iso_c_binding
      implicit none
      type(c_ptr), intent(out)     :: p_ntersl
    end subroutine cs_f_lagr_dim_pointers

    !---------------------------------------------------------------------------

    ! Interface to C function returning particle attribute pointers

    subroutine cs_f_lagr_params_pointers(p_iilagr, p_idepst, p_ipreci)         &
      bind(C, name='cs_f_lagr_params_pointers')
      use, intrinsic :: iso_c_binding
      implicit none
      type(c_ptr), intent(out) :: p_iilagr, p_idepst, p_ipreci
    end subroutine cs_f_lagr_params_pointers

    subroutine cs_f_lagr_source_terms_pointers(p_ltsdyn, p_ltsmas,   &
                                               p_ltsthe, p_itsvx,              &
                                               p_itsvy, p_itsvz, p_itsli,      &
                                               p_itske, p_itsr11, p_itsr12,    &
                                               p_itsr13, p_itsr22, p_itsr23,   &
                                               p_itsr33, p_itste, p_itsti,     &
                                               p_itsmas, p_itsco,              &
                                               p_itsmv1, p_itsmv2, dim_itsmv1, &
                                               dim_itsmv2) &
      bind(C, name='cs_f_lagr_source_terms_pointers')
      use, intrinsic :: iso_c_binding
      implicit none
      integer(c_int) :: dim_itsmv1, dim_itsmv2
      type(c_ptr), intent(out) :: p_ltsdyn, p_ltsmas, p_ltsthe,      &
                                  p_itsvx, p_itsvy, p_itsvz, p_itsli,          &
                                  p_itske, p_itsr11, p_itsr12, p_itsr13,       &
                                  p_itsr22, p_itsr23, p_itsr33, p_itste,       &
                                  p_itsti, p_itsmas, p_itsmv1, p_itsmv2,       &
                                  p_itsco
    end subroutine cs_f_lagr_source_terms_pointers

    !---------------------------------------------------------------------------

    ! Interface to C function passing specific physics options

    subroutine  cs_f_lagr_specific_physics(nozppm, iirayo, ncharb, ncharm,     &
                                           diftl0)                             &
      bind(C, name='cs_f_lagr_specific_physics')
      use, intrinsic :: iso_c_binding
      implicit none
      integer(c_int) :: nozppm, iirayo, ncharb, ncharm
      real(c_double) :: diftl0
    end subroutine cs_f_lagr_specific_physics

    !---------------------------------------------------------------------------

    ! Interface to C function passing coal combustion parameters

    subroutine  cs_f_lagr_coal_comb(ih2o, io2, ico, iatc, prefth, trefth,      &
                                    natom, wmolat, ngazem, wmole, iym1,        &
                                    ncharm, a1ch, h02ch, e1ch, a2ch, e2ch,     &
                                    y1ch, y2ch, cp2ch, ahetch, ehetch,         &
                                    rho0ch, xwatch, xashch, thcdch)            &
      bind(C, name='cs_f_lagr_coal_comb')
      use, intrinsic :: iso_c_binding
      implicit none
      integer(c_int) :: ih2o, io2, ico, iatc, natom, ngazem, ncharm
      real(c_double) :: prefth, trefth
      integer(c_int), dimension(ngazem) :: iym1
      real(c_double), dimension(natom) :: wmole, wmolat
      real(c_double), dimension(ncharm) :: a1ch, h02ch, e1ch, a2ch, e2ch,      &
                                           y1ch, y2ch, cp2ch, ahetch, ehetch,  &
                                           rho0ch, xwatch, xashch, thcdch
    end subroutine cs_f_lagr_coal_comb

    !---------------------------------------------------------------------------

    !> Execute one time step of the Lagrangian model.

    subroutine cs_lagr_solve_time_step(itypfb, dt)  &
      bind(C, name='cs_lagr_solve_time_step')
      use, intrinsic :: iso_c_binding
      implicit none
      integer(c_int), dimension(*), intent(in) :: itypfb
      real(kind=c_double), dimension(*), intent(in) :: dt
    end subroutine cs_lagr_solve_time_step

    !---------------------------------------------------------------------------

    !> \brief Allocate bound_stat and return fortran compatible pointer

    subroutine cs_lagr_init_c_arrays(dim_tslagr, p_tslagr)         &
      bind(C, name='cs_lagr_init_c_arrays')
      use, intrinsic ::  iso_c_binding

      implicit none
      integer(c_int), dimension(2) :: dim_tslagr
      type(c_ptr), intent(out)     :: p_tslagr
    end subroutine cs_lagr_init_c_arrays

    !---------------------------------------------------------------------------

    subroutine cs_lagr_init_par ()&
      bind(C, name='cs_lagr_init_par')

      use, intrinsic :: iso_c_binding

    end subroutine cs_lagr_init_par

    !---------------------------------------------------------------------------

    !> \brief Write particle data to checkpoint.

    !> \param[in, out]  r  pointer to restart structure

    function lagr_restart_write_particle_data(r) result(n) &
      bind(C, name='cs_lagr_restart_write_particle_data')
      use, intrinsic :: iso_c_binding
      implicit none
      type(c_ptr), value :: r
      integer(c_int) :: n
    end function lagr_restart_write_particle_data

  !=============================================================================

  end interface

contains

  !=============================================================================

  subroutine lagran_pointers()

    implicit none

    ! lagr_option_base
    type(c_ptr) :: p_iilagr

    ! lagr_params
    type(c_ptr) :: p_idepst, p_ipreci

    ! lagr_option_source_terms
    type(c_ptr) :: p_ltsdyn, p_ltsmas, p_ltsthe, p_itsvx,                     &
                   p_itsvy, p_itsvz, p_itsli, p_itske, p_itsr11, p_itsr12,    &
                   p_itsr13, p_itsr22, p_itsr23,  p_itsr33, p_itste, p_itsti, &
                   p_itsmas, p_itsmv1, p_itsmv2, p_itsco
    integer(c_int) :: dim_itsmv1, dim_itsmv2

    call cs_f_lagr_params_pointers(p_iilagr, p_idepst, p_ipreci)
    call c_f_pointer(p_iilagr, iilagr)
    call c_f_pointer(p_idepst, idepst)
    call c_f_pointer(p_ipreci , ipreci)

    call cs_f_lagr_source_terms_pointers(p_ltsdyn, p_ltsmas,           &
                                         p_ltsthe, p_itsvx,            &
                                         p_itsvy, p_itsvz, p_itsli,    &
                                         p_itske, p_itsr11, p_itsr12,  &
                                         p_itsr13, p_itsr22, p_itsr23, &
                                         p_itsr33, p_itste, p_itsti,   &
                                         p_itsmas, p_itsco,            &
                                         p_itsmv1, p_itsmv2,           &
                                         dim_itsmv1, dim_itsmv2)
    call c_f_pointer(p_ltsdyn, ltsdyn)
    call c_f_pointer(p_ltsmas, ltsmas)
    call c_f_pointer(p_ltsthe, ltsthe)
    call c_f_pointer(p_itsvx , itsvx )
    call c_f_pointer(p_itsvy , itsvy )
    call c_f_pointer(p_itsvz , itsvz )
    call c_f_pointer(p_itsli , itsli )
    call c_f_pointer(p_itske , itske )
    call c_f_pointer(p_itsr11, itsr11)
    call c_f_pointer(p_itsr12, itsr12)
    call c_f_pointer(p_itsr13, itsr13)
    call c_f_pointer(p_itsr22, itsr22)
    call c_f_pointer(p_itsr23, itsr23)
    call c_f_pointer(p_itsr33, itsr33)
    call c_f_pointer(p_itste , itste )
    call c_f_pointer(p_itsti , itsti )
    call c_f_pointer(p_itsmas, itsmas)
    call c_f_pointer(p_itsco , itsco )
    call c_f_pointer(p_itsmv1, itsmv1, [dim_itsmv1])
    call c_f_pointer(p_itsmv2, itsmv2, [dim_itsmv2])

    return

  end subroutine lagran_pointers

  !=============================================================================

  subroutine init_lagr_dim_pointers()

    implicit none

    type(c_ptr) :: p_ntersl

    call cs_f_lagr_dim_pointers(p_ntersl)

    call c_f_pointer(p_ntersl, ntersl)

    return

  end subroutine init_lagr_dim_pointers

  !=============================================================================

  ! Initialize auxiliary arrays

  subroutine init_lagr_arrays(tslagr)

    implicit none

    double precision, dimension(:,:), pointer  :: tslagr
    integer(c_int),   dimension(2)             :: dim_tslagr
    type(c_ptr)                                :: p_tslagr

    call cs_lagr_init_c_arrays(dim_tslagr, p_tslagr)

    call c_f_pointer(p_tslagr, tslagr, [dim_tslagr])

    return

  end subroutine init_lagr_arrays

  !=============================================================================

  subroutine lagran_init_map

    use ppincl, only: iccoal, icfuel, ieljou, ielarc, icoebu, icod3p,          &
                      ippmod, icpl3c, iym1, icompf
    use cpincl, only: ncharb, xashch, cp2ch, xwatch, rho0ch, a1ch,             &
                      a2ch, e1ch, e2ch, io2, ih2o, ico,                        &
                      ahetch, ehetch, thcdch, y1ch, y2ch, h02ch
    use ppppar, only: nozppm, ncharm
    use ppthch, only: diftl0, ngazem, wmole, wmolat, trefth, prefth, iatc,     &
                      natom, wmolat
    use radiat, only: iirayo

    call init_lagr_dim_pointers

    call lagran_pointers

    call cs_f_lagr_specific_physics(nozppm,         &
                                    iirayo,         &
                                    ncharb,         &
                                    ncharm,         &
                                    diftl0)

    call cs_f_lagr_coal_comb(ih2o,   &
                             io2,    &
                             ico,    &
                             iatc,   &
                             prefth, &
                             trefth, &
                             natom,  &
                             wmolat, &
                             ngazem, &
                             wmole,  &
                             iym1,   &
                             ncharm, &
                             a1ch,   &
                             h02ch,  &
                             e1ch,   &
                             a2ch,   &
                             e2ch,   &
                             y1ch,   &
                             y2ch,   &
                             cp2ch,  &
                             ahetch, &
                             ehetch, &
                             rho0ch, &
                             xwatch, &
                             xashch, &
                             thcdch)

  end subroutine lagran_init_map

  !=============================================================================

end module lagran