~fluidity-core/fluidity/shallow-water-dev

« back to all changes in this revision

Viewing changes to error_measures/Metric_advection.F90

  • Committer: colin.cotter at ac
  • Date: 2012-02-16 17:35:27 UTC
  • mfrom: (3565.1.365 fluidity)
  • Revision ID: colin.cotter@imperial.ac.uk-20120216173527-wpnlu4v9v1kmf4xz
MergeĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
  use field_options, only: get_coordinate_field
63
63
  use sparsity_patterns_meshes
64
64
  use futils, only: int2str
 
65
  use fefields, only: compute_cv_mass
65
66
 
66
67
  implicit none
67
68
 
111
112
    type(tensor_field) :: l_tfield, tmp_tfield
112
113
    type(scalar_field), pointer :: t_cvmass
113
114
    type(scalar_field) :: cvmass
 
115
      
 
116
    ! Porosity fields, field name, theta value and include flag
 
117
    type(scalar_field), pointer :: porosity_old, porosity_new
 
118
    type(scalar_field) :: porosity_theta 
 
119
    character(len=OPTION_PATH_LEN) :: porosity_name
 
120
    real :: porosity_theta_value
 
121
    logical :: include_porosity
114
122
 
115
123
    ! local copy of option_path for solution field
116
124
    character(len=OPTION_PATH_LEN) :: option_path
270
278
    end if
271
279
    
272
280
    sub_dt=adapt_dt/real(no_subcycles)
 
281
 
 
282
    ! find the cv mass that is used for the time term derivative
 
283
 
 
284
    ! are we including a porosity coefficient on the time term?
 
285
    if (have_option(trim(option_path)//'/porosity')) then
 
286
       include_porosity = .true.
 
287
     
 
288
       ! get the name of the field to use as porosity
 
289
       call get_option(trim(option_path)//'/porosity/porosity_field_name', &
 
290
                       porosity_name, &
 
291
                       default = 'Porosity')
 
292
         
 
293
       ! get the porosity theta value
 
294
       call get_option(trim(option_path)//'/porosity/temporal_discretisation/theta', &
 
295
                       porosity_theta_value, &
 
296
                       default = 0.0)
 
297
         
 
298
       porosity_new => extract_scalar_field(state, trim(porosity_name), stat = stat)                  
 
299
 
 
300
       if (stat /=0) then
 
301
         FLExit('Including porosity in Metric_Advection but failed to extract Porosity from state')
 
302
       end if
 
303
 
 
304
       porosity_old => extract_scalar_field(state, "Old"//trim(porosity_name), stat = stat)
 
305
 
 
306
       if (stat /=0) then
 
307
         FLExit('Including porosity in Metric_Advection but failed to extract OldPorosity from state')
 
308
       end if
 
309
         
 
310
       call allocate(porosity_theta, porosity_new%mesh)
 
311
         
 
312
       call set(porosity_theta, porosity_new, porosity_old, porosity_theta_value)
 
313
         
 
314
       ewrite_minmax(porosity_theta)
 
315
       
 
316
       allocate(t_cvmass)  
 
317
       call allocate(t_cvmass, tfield%mesh, name="LocalCVMassWithPorosity")
 
318
       call compute_cv_mass(x, t_cvmass, porosity_theta)
 
319
       
 
320
       call deallocate(porosity_theta)
 
321
    else
 
322
       include_porosity = .false.
 
323
       t_cvmass => get_cv_mass(state, tfield%mesh)
 
324
    end if
 
325
    ewrite_minmax(t_cvmass)    
273
326
    
274
 
    ! find the cv mass
275
 
    t_cvmass => get_cv_mass(state, tfield%mesh)
276
327
    call allocate(cvmass, tfield%mesh, "LocalCVMass")
277
328
    call set(cvmass, t_cvmass)
 
329
    ewrite_minmax(cvmass)    
278
330
 
279
331
    ewrite(2,*) 'no_subcycles = ', no_subcycles
280
332
    ewrite(2,*) 'rk_iterations = ', rk_iterations
393
445
    call deallocate(relu)
394
446
    call deallocate(x_tfield)
395
447
    call deallocate(cvmass)
 
448
    if (include_porosity) then
 
449
       call deallocate(t_cvmass)
 
450
       deallocate(t_cvmass)
 
451
    end if
396
452
 
397
453
  end subroutine form_advection_metric
398
454
  ! end of solution wrapping subroutines