~reducedmodelling/fluidity/ROM_Non-intrusive-ann

« back to all changes in this revision

Viewing changes to assemble/Advection_Diffusion_CG.F90

  • Committer: skramer
  • Date: 2010-11-16 15:37:38 UTC
  • Revision ID: svn-v4:5bf5533e-7014-46e3-b1bb-cce4b9d03719:trunk:2477
Changing the storage of vector_field from vfield%val(dim)%ptr(node) to vfield%val(dim,node).

This was a long desired and discussed change that should improve cache performance and will allow vector fields of more than 3 dimension (internally no vtk support). Just realised it could be done with a few simple seds.

Most important changes need:
- removal of wrap_field() for vector_fields.
- this required some surgery in vtk_write_fields, a horrible piece of code in any case
- traffic and mesh_movement were using wrap_field and now have to do a few more copies.
- halo_update() requires a contiguous buffer in memory, so a copy is now done for halo_update(vfield)
- the wrapped python vector fields available in python_state diagnostics had to be rewired to account for the new storage. This actually simplifies the wrapping a lot.

I realise this is a big commit which might give some trouble when merging in big changes (from for example a branch). The following little script I used might be handy for this. You might only want to apply it to files you have modified. Make sure you back up your entire local checkout before applying any of these:

#/bin/sh
FILES=*/*.F90 */tests/*.F90
# replace any %val(1)%ptr(2) where 2 contains a pair of ()
sed -i 's!%val(\([A-Za-z0-9%_\+\* -]*\))%ptr(\([^)]*([^)]*)[^)]*\))!%val(\1,\2)!g' ${FILES}
# replace any %val(1)%ptr(2) where 2 contains no closing )
sed -i 's!%val(\([A-Za-z0-9%_\+\* -]*\))%ptr(\([^)]*\))!%val(\1,\2)!g' ${FILES}
# replace any %val(1)%ptr not followed by (
sed -i 's!%val(\([A-Za-z0-9%_\+\* -]*\))%ptr!%val(\1,:)!g' ${FILES}
# now svn revert femtools/Sparse_Tools.F90
# as it gives false positives for dcsr_matrices
# luckily it doesn't use vector_fields, so we can just revert


Show diffs side-by-side

added added

removed removed

Lines of Context:
238
238
    ! Coordinate
239
239
    positions => extract_vector_field(state, "Coordinate")
240
240
    do i = 1, positions%dim
241
 
      ewrite_minmax(positions%val(i)%ptr)
 
241
      ewrite_minmax(positions%val(i,:))
242
242
    end do
243
243
    assert(positions%dim == mesh_dim(t))
244
244
    assert(ele_count(positions) == ele_count(t))
251
251
      
252
252
      ewrite(2, *) "Velocity:"
253
253
      do i = 1, velocity_ptr%dim
254
 
        ewrite_minmax(velocity_ptr%val(i)%ptr)
 
254
        ewrite_minmax(velocity_ptr%val(i,:))
255
255
      end do
256
256
 
257
257
      if (have_option(trim(t%option_path) // &
302
302
      ! this may perform a "remap" internally from CoordinateMesh to VelocitMesh
303
303
      call addto(velocity, gravity_direction, scale = sinking_velocity)
304
304
      do i = 1, velocity_ptr%dim
305
 
        ewrite_minmax(velocity%val(i)%ptr)
 
305
        ewrite_minmax(velocity%val(i,:))
306
306
      end do
307
307
    else
308
308
      ewrite(2, *) "No sinking velocity"
378
378
      ewrite(2,*) "Moving the mesh"
379
379
      old_positions => extract_vector_field(state, "OldCoordinate")
380
380
      do i = 1, old_positions%dim
381
 
        ewrite_minmax(old_positions%val(i)%ptr)
 
381
        ewrite_minmax(old_positions%val(i,:))
382
382
      end do
383
383
      new_positions => extract_vector_field(state, "IteratedCoordinate")
384
384
      do i = 1, new_positions%dim
385
 
        ewrite_minmax(new_positions%val(i)%ptr)
 
385
        ewrite_minmax(new_positions%val(i,:))
386
386
      end do
387
387
      
388
388
      ! Grid velocity
392
392
      
393
393
      ewrite(2, *) "Grid velocity:"    
394
394
      do i = 1, grid_velocity%dim
395
 
        ewrite_minmax(grid_velocity%val(i)%ptr)
 
395
        ewrite_minmax(grid_velocity%val(i,:))
396
396
      end do
397
397
    else
398
398
      ewrite(2,*) "Not moving the mesh"