~reducedmodelling/fluidity/ROM_Non-intrusive-ann

« back to all changes in this revision

Viewing changes to femtools/Petsc_Tools.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:
486
486
#ifdef DOUBLEP
487
487
         call VecSetValues(vec, insert_rows, &
488
488
            petsc_numbering%gnn2unn( 1:insert_rows, b ), &
489
 
            fields(i)%val(j)%ptr( 1:insert_rows ), insert_action, ierr)
 
489
            fields(i)%val(j, 1:insert_rows ), insert_action, ierr)
490
490
#else
491
491
         call VecSetValues(vec, insert_rows, &
492
492
            petsc_numbering%gnn2unn( 1:insert_rows, b ), &
493
 
            real(fields(i)%val(j)%ptr( 1:insert_rows ), kind = PetscScalar_kind), insert_action, ierr)
 
493
            real(fields(i)%val(j, 1:insert_rows ), kind = PetscScalar_kind), insert_action, ierr)
494
494
#endif
495
495
        b=b+1
496
496
        
808
808
      do j=1, fields(i)%dim
809
809
         call VecGetValues(vec, nnodp, &
810
810
           petsc_numbering%gnn2unn( 1:nnodp, b ), &
811
 
           fields(i)%val(j)%ptr( 1:nnodp ), ierr)
 
811
           fields(i)%val(j, 1:nnodp ), ierr)
812
812
         b=b+1
813
813
      end do
814
814
      call profiler_toc(fields(i), "petsc2field")
824
824
         call VecGetValues(vec, nnodp, &
825
825
           petsc_numbering%gnn2unn( 1:nnodp, b ), &
826
826
           vals, ierr)
827
 
         fields(i)%val(j)%ptr( 1:nnodp ) = vals
 
827
         fields(i)%val(j, 1:nnodp ) = vals
828
828
         b=b+1
829
829
      end do
830
830
      call profiler_toc(fields(i), "petsc2field")