ITM Grid Service Library: Fortran 90

src/service/itm_grid_transform.f90

Go to the documentation of this file.
00001 module itm_grid_transform
00002 
00003   use itm_types , ITM_R8 => R8, ITM_R4 => R4
00004   use itm_assert
00005   use euITM_schemas ! IGNORE
00006   use itm_grid_object
00007   use itm_grid_subgrid
00008   use itm_combinations
00009 
00010   implicit none
00011 
00012 contains
00013 
00014   !> Transform a grid with possibly multiple spaces into an equivalent grid
00015   !> with only one space
00016   subroutine transformGridToSingleSpace( gIn, gOut  )
00017     type(type_complexgrid), intent(in) :: gin
00018     type(type_complexgrid), intent(out) :: gout
00019 
00020     ! internal
00021     integer :: i, iDim, iSp, nNodes, nObj, iObj, maxCompObjs, iCompObj
00022     type(type_complexgrid_space) :: s
00023 
00024     integer, dimension(gridNSpace(gIn)) :: cls, maxCls
00025     type(type_complexgrid_subgrid), dimension(:), allocatable :: subgrids
00026     integer, allocatable :: classes(:,:)
00027     type(GridObject) :: obj, node
00028     type(GridObject), allocatable :: compObjs(:)
00029 
00030     ! Some basic checks
00031     do iSp = 1, gridNSpace(gIn)
00032         ! Can only do simple geometry representations
00033         call assert(size(gIn%spaces(iSp)%objects(1)%geo,3) == 1)
00034     end do
00035 
00036     ! Set up new grid with one space
00037     allocate(gOut%spaces(1))
00038     
00039     ! Basic space information
00040     allocate(s%coordtype(gridNDim(gIn), 1))
00041     s%coordtype(:,1) = gridCoordTypes(gIn)
00042 
00043     ! Fill in object descriptions in new space s
00044     maxCls = gridGetMaxDimClass( gIn )
00045     allocate(s%objects(classDim(maxCls)+1))
00046 
00047     ! Nodes (object class (0,...,0))
00048     cls = (/ (0, i = 1, gridNSpace(gIn) ) /)
00049     nNodes = gridNObject( gin, cls )
00050     allocate(s%objects(1)%geo(nNodes, gridNDim(gIn), 1, 1))
00051     
00052     do i = 1, nNodes
00053         node = getObjectByGlobalIndex(gIn, cls, i)
00054         s%objects(1)%geo(i,:,1,1) = gridNodeCoord(gIn, node%ind)
00055     end do
00056     ! TODO for nodes: altgeo, xpoints, alias
00057 
00058     ! Higher-dimensional objects
00059     
00060     ! Build subgrids containing all objects of every dimension present grid
00061     allocate(subgrids(0:classDim(maxCls)))
00062     do iDim = 0, classDim(maxCls)
00063         call allocate_combinations(maxCls, iDim, classes)
00064         call createSubGridForClasses( gIn, subgrids(iDim), classes )
00065         deallocate(classes)
00066     end do
00067 
00068     ! Fill in the object descriptions
00069 
00070     do iDim = 1, classDim(maxCls)
00071         nObj = gridSubGridSize( subgrids(iDim) )
00072 
00073         ! Figure out maximum number of boundaries for objects
00074         maxCompObjs = 0
00075         do iObj = 1, nObj
00076             obj = subGridGetObject( subgrids(iDim), iObj )
00077             call getComposingObjects( gIn, obj, compObjs )
00078             maxCompObjs = max( maxCompObjs, size(compObjs) )
00079         end do
00080 
00081         ! Fill in boundary
00082         allocate(s%objects(iDim)%boundary(nObj, maxCompObjs))
00083         s%objects(iDim)%boundary = GRID_UNDEFINED
00084 
00085         do iObj = 1, nObj
00086             obj = subGridGetObject( subgrids(iDim), iObj )
00087             call getComposingObjects( gIn, obj, compObjs )
00088             do iCompObj = 1, size(compObjs)
00089                 s%objects(iDim)%boundary(iObj, iCompObj) = &
00090                     & subGridGetIndexForObject(subgrids(iDim-1), compObjs(iCompObj) )
00091             end do            
00092         end do
00093 
00094         ! TODO: fill in connectivity
00095     end do
00096    
00097     gOut%spaces(1) = s
00098 
00099   end subroutine transformGridToSingleSpace
00100 
00101 
00102 end module itm_grid_transform
 All Classes Namespaces Files Functions Variables