~fluidity-core/fluidity/tidal-velocity-bcs-doodson

« back to all changes in this revision

Viewing changes to femtools/Parallel_fields.F90

Merging in moving mesh checkpoint fix, so we can checkpoint our tidal runs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
 
47
47
  private
48
48
 
49
 
  public :: halo_communicator, element_owned, element_owner, node_owned, assemble_ele, &
50
 
    & surface_element_owned, nowned_nodes
 
49
  public :: halo_communicator, element_owned, element_neighbour_owned, &
 
50
       & element_owner, node_owned, assemble_ele, &
 
51
       & surface_element_owned, nowned_nodes
51
52
  ! Apparently ifort has a problem with the generic name node_owned
52
53
  public :: node_owned_mesh, zero_non_owned
53
54
  
61
62
      & element_owned_vector, element_owned_tensor
62
63
  end interface element_owned
63
64
 
 
65
  interface element_neighbour_owned
 
66
     module procedure element_neighbour_owned_mesh, &
 
67
          & element_neighbour_owned_scalar, element_neighbour_owned_vector, &
 
68
          & element_neighbour_owned_tensor
 
69
  end interface element_neighbour_owned
 
70
 
64
71
  interface element_owner
65
72
    module procedure element_owner_mesh, element_owner_scalar, &
66
73
      & element_owner_vector, element_owner_tensor
273
280
 
274
281
  end function element_owned_tensor
275
282
 
 
283
  function element_neighbour_owned_mesh(mesh, element_number) result(owned)
 
284
    !!< Return .true. if ELEMENT_NUMBER has a neighbour in MESH that
 
285
    !!< is owned by this process otherwise .false.
 
286
 
 
287
    !! Effectively, this computes whether ELEMENT_NUMBER is in the L1
 
288
    !! halo.
 
289
    type(mesh_type), intent(in) :: mesh
 
290
    integer, intent(in) :: element_number
 
291
    logical :: owned
 
292
    integer, dimension(:), pointer :: neighbours
 
293
    integer :: i, n_neigh
 
294
 
 
295
    neighbours => ele_neigh(mesh, element_number)
 
296
    n_neigh = size(neighbours)
 
297
    owned = .false.
 
298
    do i = 1, n_neigh
 
299
       ! If element_number is in the halo, then some of the neighbour
 
300
       ! data might not be available, in which case neighbours(i) can
 
301
       ! be invalid (missing data are marked by negative values).
 
302
       if ( neighbours(i) <= 0 ) cycle
 
303
       if ( element_owned(mesh, neighbours(i)) ) then
 
304
          owned = .true.
 
305
          return
 
306
       end if
 
307
    end do
 
308
  end function element_neighbour_owned_mesh
 
309
 
 
310
  function element_neighbour_owned_scalar(field, element_number) result(owned)
 
311
    !!< Return .true. if ELEMENT_NUMBER has a neighbour in FIELD that
 
312
    !!< is owned by this process otherwise .false.
 
313
 
 
314
    !! Effectively, this computes whether ELEMENT_NUMBER is in the L1
 
315
    !! halo.
 
316
    type(scalar_field), intent(in) :: field
 
317
    integer, intent(in) :: element_number
 
318
    logical :: owned
 
319
 
 
320
    owned = element_neighbour_owned(field%mesh, element_number)
 
321
  end function element_neighbour_owned_scalar
 
322
 
 
323
  function element_neighbour_owned_vector(field, element_number) result(owned)
 
324
    !!< Return .true. if ELEMENT_NUMBER has a neighbour in FIELD that
 
325
    !!< is owned by this process otherwise .false.
 
326
 
 
327
    !! Effectively, this computes whether ELEMENT_NUMBER is in the L1
 
328
    !! halo.
 
329
    type(vector_field), intent(in) :: field
 
330
    integer, intent(in) :: element_number
 
331
    logical :: owned
 
332
 
 
333
    owned = element_neighbour_owned(field%mesh, element_number)
 
334
  end function element_neighbour_owned_vector
 
335
 
 
336
  function element_neighbour_owned_tensor(field, element_number) result(owned)
 
337
    !!< Return .true. if ELEMENT_NUMBER has a neighbour in FIELD that
 
338
    !!< is owned by this process otherwise .false.
 
339
 
 
340
    !! Effectively, this computes whether ELEMENT_NUMBER is in the L1
 
341
    !! halo.
 
342
    type(tensor_field), intent(in) :: field
 
343
    integer, intent(in) :: element_number
 
344
    logical :: owned
 
345
 
 
346
    owned = element_neighbour_owned(field%mesh, element_number)
 
347
  end function element_neighbour_owned_tensor
 
348
 
276
349
  function element_owner_mesh(mesh, element_number) result(owner)
277
350
  !!< Return number of processor that owns the supplied element in the
278
351
  !given mesh