~fluidity-core/fluidity/sea-ice-branch

« back to all changes in this revision

Viewing changes to femtools/Dgtools.F90

  • Committer: Simon Mouradian
  • Date: 2012-03-30 11:11:47 UTC
  • mfrom: (3520.32.239 fluidity)
  • Revision ID: simon.mouradian06@imperial.ac.uk-20120330111147-y4n4y4th52x2dqcf
mergeĀ fromĀ lp:fluidity

Show diffs side-by-side

added added

removed removed

Lines of Context:
11
11
use FETools
12
12
use transform_elements
13
13
use boundary_conditions, only: get_boundary_condition_nodes
 
14
use halos_base
14
15
 
15
16
implicit none
16
17
 
433
434
 
434
435
  end subroutine dcsr_assemble_local_lumped_mass
435
436
 
436
 
  subroutine csr_dg_inverse_mass_from_mass(inv_mass, mass)
 
437
  subroutine csr_dg_inverse_mass_from_mass(inv_mass, mass, only_owned_elements)
437
438
    !!< Put the inverse of mass into inv_mass. This is short-circuited by
438
439
    !!< knowing that mass is DG.
439
440
    type(csr_matrix), intent(inout) :: inv_mass
440
441
    type(csr_matrix), intent(in) :: mass
441
 
 
442
 
    integer :: row, colm_pos, nloc
443
 
 
444
 
    row=0
 
442
    !! if present and true, only computed inverse mass for owned elements, the rest of inv_mass is zeroed
 
443
    !! this means that after multiplication with this matrix, you need to halo_update:
 
444
    logical, intent(in), optional :: only_owned_elements
 
445
 
 
446
    integer :: row, colm_pos, nloc, last_row
 
447
 
 
448
    row=1
445
449
    colm_pos=0
 
450
 
 
451
    if (present_and_true(only_owned_elements) .and. associated(mass%sparsity%row_halo)) then
 
452
      last_row = halo_nowned_nodes(mass%sparsity%row_halo)
 
453
    else
 
454
      last_row = size(mass,1)
 
455
    end if
446
456
    
447
457
    do 
448
 
       if(row>=size(mass,1)) exit
449
 
       nloc=row_length(mass, row+1)
 
458
       if(row>last_row) exit
 
459
       nloc=row_length(mass, row)
450
460
       inv_mass%val(colm_pos+1:colm_pos+nloc**2) &
451
461
            = reshape(&
452
462
            &  inverse(&
458
468
       row=row+nloc
459
469
       colm_pos=colm_pos+nloc**2
460
470
    end do
 
471
 
 
472
    if (present_and_true(only_owned_elements) .and. associated(mass%sparsity%row_halo)) then
 
473
      ! rest is zeroed
 
474
      inv_mass%val(colm_pos+1:)=0.0
 
475
    end if
461
476
 
462
477
  end subroutine csr_dg_inverse_mass_from_mass
463
478