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

« back to all changes in this revision

Viewing changes to femtools/Transform_elements.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:
32
32
  use quadrature
33
33
  use elements
34
34
  use vector_tools
 
35
  use parallel_tools, only: abort_if_in_parallel_region
35
36
  use fields_base
36
37
  use cv_faces, only: cv_faces_type
37
38
  use eventcounter
62
63
            transform_cvsurf_to_physical, transform_cvsurf_facet_to_physical, &
63
64
            transform_superconvergent_to_physical, transform_horizontal_to_physical, &
64
65
            compute_jacobian, compute_inverse_jacobian, element_volume,&
65
 
            cache_transform_elements, deallocate_transform_cache
 
66
            cache_transform_elements, deallocate_transform_cache, &
 
67
            prepopulate_transform_cache
66
68
  
67
69
  integer, parameter :: cyc3(1:5)=(/ 1, 2, 3, 1, 2 /)  
68
70
 
167
169
    
168
170
  end function retrieve_cached_transform_det
169
171
 
 
172
  function prepopulate_transform_cache(X) result(cache_valid)
 
173
    !!< Prepopulate the caches for transform_to_physical and
 
174
    !!< transform_face_to_physical
 
175
    !!
 
176
    !!< If you're going to call transform_to_physical on a coordinate
 
177
    !!< field inside a threaded region, you need to call this on the
 
178
    !!< same field before entering the region.
 
179
    type(vector_field), intent(in) :: X
 
180
    logical :: cache_valid
 
181
    logical :: face_cache_valid
 
182
    cache_valid=.true.
 
183
    face_cache_valid=.true.
 
184
    ! Although the caches are thread safe, the code that assembles the
 
185
    ! caches is not so we want a simple way to construct them if
 
186
    ! appropriate before entering a threaded region.
 
187
    if (X%refcount%id /= position_id) then
 
188
       cache_valid=.false.
 
189
       if (X%name/="Coordinate") then
 
190
          !!< If Someone is not calling this on the main Coordinate field
 
191
          !!< then we're screwed anyway.
 
192
          return
 
193
       end if
 
194
    else if (eventcount(EVENT_MESH_MOVEMENT) /= last_mesh_movement) then
 
195
       cache_valid=.false.
 
196
    end if
 
197
 
 
198
    if (X%refcount%id /= face_position_id) then
 
199
       face_cache_valid=.false.
 
200
    else if (eventcount(EVENT_MESH_MOVEMENT) /= face_last_mesh_movement) then
 
201
       face_cache_valid = .false.
 
202
    end if
 
203
 
 
204
    if (.not.cache_valid) then
 
205
       call construct_cache(X)
 
206
       cache_valid=.true.
 
207
    end if
 
208
 
 
209
    if (.not.face_cache_valid) then
 
210
       call construct_face_cache(X)
 
211
       face_cache_valid=.true.
 
212
    end if
 
213
 
 
214
    cache_valid = cache_valid .and. face_cache_valid
 
215
 
 
216
  end function prepopulate_transform_cache
170
217
 
171
218
  subroutine construct_cache(X)
172
219
    !!< The cache is invalid so make a new one.
179
226
 
180
227
!    ewrite(1,*) "Reconstructing element geometry cache."
181
228
 
 
229
    call abort_if_in_parallel_region
 
230
 
182
231
    position_id=X%refcount%id
183
232
    last_mesh_movement=eventcount(EVENT_MESH_MOVEMENT)
184
233
 
305
354
    
306
355
!    ewrite(1,*) "Reconstructing element geometry cache."
307
356
 
 
357
    call abort_if_in_parallel_region
 
358
 
308
359
    face_position_id=X%refcount%id
309
360
    face_last_mesh_movement=eventcount(EVENT_MESH_MOVEMENT)
310
361