~reducedmodelling/fluidity/ROM_Non-intrusive-ann

« back to all changes in this revision

Viewing changes to assemble/Sam_integration.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:
944
944
       allocate(senlist(stotel * snloc))
945
945
       ewrite(1, *) "Calling sam_export_mesh from sam_drive"
946
946
       call sam_export_mesh(nonods, totele, stotel, nloc, snloc, &
947
 
                          & new_positions%val(1)%ptr, new_positions%val(2)%ptr, new_positions%val(3)%ptr, &
 
947
                          & new_positions%val(1,:), new_positions%val(2,:), new_positions%val(3,:), &
948
948
                          & linear_mesh%ndglno, senlist, surface_ids)
949
949
       ewrite(1, *) "Exited sam_export_mesh"
950
950
       linear_mesh%option_path = linear_mesh_option_path
1088
1088
 
1089
1089
         do field=vcount(state),1,-1
1090
1090
           do component=dim,1,-1
1091
 
             call sam_pop_field(linear_v%val(component)%ptr, node_count(linear_mesh))
 
1091
             call sam_pop_field(linear_v%val(component,:), node_count(linear_mesh))
1092
1092
           end do
1093
1093
 
1094
1094
           field_v => extract_vector_field(states(state), trim(namelist_v(state, field)))
1095
 
           do component=dim,1,-1
1096
 
             deallocate(field_v%val(component)%ptr)
1097
 
             allocate(field_v%val(component)%ptr(node_count(field_v%mesh)))
1098
 
           end do
 
1095
           deallocate(field_v%val)
 
1096
           allocate(field_v%val(dim,node_count(field_v%mesh)))
1099
1097
#ifdef HAVE_MEMORY_STATS
1100
1098
           call register_allocation("vector_field", "real", node_count(field_v%mesh)*mesh_dim(field_v%mesh), name=trim(field_v%name))
1101
1099
#endif
1187
1185
         do j = 1, vector_field_count(states(i))
1188
1186
           v_field => extract_vector_field(states(i), j)
1189
1187
           if(v_field%field_type == FIELD_TYPE_DEFERRED) then
1190
 
             do k = 1, mesh_dim(v_field%mesh)
1191
 
               deallocate(v_field%val(k)%ptr)
1192
 
               allocate(v_field%val(k)%ptr(node_count(v_field%mesh)))
1193
 
             end do
 
1188
             deallocate(v_field%val)
 
1189
             allocate(v_field%val(mesh_dim(v_field%mesh),node_count(v_field%mesh)))
1194
1190
#ifdef HAVE_MEMORY_STATS
1195
1191
             call register_allocation("vector_field", "real", node_count(v_field%mesh)*mesh_dim(v_field%mesh), name=trim(v_field%name))
1196
1192
#endif
1260
1256
       call interleave_surface_ids(mesh, surfid, max_coplanar_id)
1261
1257
       select case(dim)
1262
1258
         case(3)
1263
 
           x => positions%val(1)%ptr
1264
 
           y => positions%val(2)%ptr
1265
 
           z => positions%val(3)%ptr
 
1259
           x => positions%val(1,:)
 
1260
           y => positions%val(2,:)
 
1261
           z => positions%val(3,:)
1266
1262
         case(2)
1267
 
           x => positions%val(1)%ptr
1268
 
           y => positions%val(2)%ptr
 
1263
           x => positions%val(1,:)
 
1264
           y => positions%val(2,:)
1269
1265
           z => dummy
1270
1266
         case(1)
1271
 
           x => positions%val(1)%ptr
 
1267
           x => positions%val(1,:)
1272
1268
           y => dummy
1273
1269
           z => dummy
1274
1270
         case default
1360
1356
       integer :: i
1361
1357
       
1362
1358
       do i=1,field%dim
1363
 
         call sam_add_field(field%val(i)%ptr, node_count(field))
 
1359
         call sam_add_field(field%val(i,:), node_count(field))
1364
1360
       end do
1365
1361
       
1366
1362
     end subroutine sam_add_field_vector