KTH framework for Nek5000 toolboxes; testing version  0.0.1

Tool for 3D to 2D grid mapping. More...

+ Collaboration diagram for Grid mapping:

Files

file  map2D.f
 3D to 2D element mapping routines
 

Functions

subroutine map2d_register ()
 Register 2D mapping routines. More...
 
subroutine map2d_init ()
 Initilise map2d module. More...
 
subroutine map2d_get ()
 Get 3D to 2D element mapping. More...
 
subroutine map2d_get_local (ctrs, cell, ninseg, ind, ifseg, lctrs1, lctrs2, nseg, nelsort, tol)
 Get local 3D=>2D mapping. More...
 
subroutine map2d_get_global (ctrs, owner, cell, ninseg, ind, ifseg, lctrs1, lctrs2, nseg, tol)
 Get global 3D=>2D mapping. More...
 
subroutine map2d_init_coord
 Generate 2D mesh out of 3D one. More...
 

Detailed Description

Tool for 3D to 2D grid mapping.

3D to 2D mesh mappinfg for 2D-extruded meshes.

Todo:
This description has to be extended.
Module interface:
Global interface list:
Interface provided:
  1. map2d_register
  2. map2d_init
  3. map2d_get
Global interface dependency:
Interface required:
  1. multiple interfaces from Frame module, Runtime parameters and Monitoring module modules
  2. io_file_freeid from Input/output module module (debugging only)
  3. user_map2d_get; user defined
Module interface usage:
!======================================================================
subroutine userchk
include 'TSTEP'
if (istep.eq.0) then
! start framework
endif
! monitor simulation
! finalise framework
if (istep.eq.nsteps.or.lastep.eq.1) then
call frame_end
endif
return
end
!======================================================================
subroutine frame_usr_register
implicit none
include 'SIZE'
include 'FRAMELP'
!-----------------------------------------------------------------------
! register modules
return
end subroutine
!======================================================================
> @brief initialise user specified modules
subroutine frame_usr_init
implicit none
include 'SIZE'
include 'FRAMELP'
!-----------------------------------------------------------------------
! initialise modules
return
end subroutine
!======================================================================
subroutine frame_usr_end
implicit none
include 'SIZE'
include 'FRAMELP'
!-----------------------------------------------------------------------
! finlise modules
return
end subroutine
!======================================================================
subroutine frame_monitor
Simulataion monitoring.
Definition: frame.f:59
subroutine frame_start
Start framework.
Definition: frame.f:12
subroutine frame_end
Finalise framework.
Definition: frame.f:76
subroutine map2d_register()
Register 2D mapping routines.
Definition: map2D.f:13
subroutine map2d_init()
Initilise map2d module.
Definition: map2D.f:70
!======================================================================
subroutine user_map2d_get(idir,ctrs,cell,lctrs1,lctrs2,nelsort,
$ map_xm1,map_ym1,ierr)
implicit none
include 'SIZE'
include 'INPUT' ! [XYZ]C
include 'GEOM' ! [XYZ]M1
! argument list
integer idir
integer lctrs1,lctrs2
real ctrs(lctrs1,lctrs2) ! 2D element centres and diagonals
integer cell(lctrs2) ! local element numberring
integer nelsort ! number of local 3D elements to sort
real map_xm1(lx1,lz1,lelt), map_ym1(lx1,lz1,lelt)
integer ierr ! error flag
! local variables
integer ntot ! tmp array size for copying
integer el ,il ,jl ! loop indexes
integer nvert ! vertex number
real rnvert ! 1/nvert
real xmid,ymid ! 2D element centre
real xmin,xmax,ymin,ymax ! to get approximate element diagonal
integer ifc ! face number
! dummy arrays
real xcoord(8,LELT), ycoord(8,LELT) ! tmp vertex coordinates
#ifdef DEBUG
! for testing
character*3 str1, str2
integer iunit, ierrl
! call number
integer icalldl
save icalldl
data icalldl /0/
#endif
!-----------------------------------------------------------------------
! initial error flag
ierr = 0
! set important parameters
! uniform direction; should be taken as input parameter
! x-> 1, y-> 2, z-> 3
idir = 3
! get element midpoints
! vertex number
nvert = 2**ndim
rnvert= 1.0/real(nvert)
! eliminate uniform direction
ntot = 8*nelv
if (idir.EQ.1) then ! uniform X
call copy(xcoord,yc,ntot) ! copy y
call copy(ycoord,zc,ntot) ! copy z
elseif (idir.EQ.2) then ! uniform Y
call copy(xcoord,xc,ntot) ! copy x
call copy(ycoord,zc,ntot) ! copy z
elseif (idir.EQ.3) then ! uniform Z
call copy(xcoord,xc,ntot) ! copy x
call copy(ycoord,yc,ntot) ! copy y
endif
! set initial number of elements to sort
nelsort = 0
call izero(cell,nelt)
! for every element
do el=1,nelv
! element centre
xmid = xcoord(1,el)
ymid = ycoord(1,el)
! element diagonal
xmin = xmid
xmax = xmid
ymin = ymid
ymax = ymid
do il=2,nvert
xmid=xmid+xcoord(il,el)
ymid=ymid+ycoord(il,el)
xmin = min(xmin,xcoord(il,el))
xmax = max(xmax,xcoord(il,el))
ymin = min(ymin,ycoord(il,el))
ymax = max(ymax,ycoord(il,el))
enddo
xmid = xmid*rnvert
ymid = ymid*rnvert
! count elements to sort
nelsort = nelsort + 1
! 2D position
! in general this coud involve some curvilinear transform
ctrs(1,nelsort)=xmid
ctrs(2,nelsort)=ymid
! reference distance
ctrs(3,nelsort)=sqrt((xmax-xmin)**2 + (ymax-ymin)**2)
if (ctrs(3,nelsort).eq.0.0) then
ierr = 1
return
endif
! element index
cell(nelsort) = el
enddo
! provide 2D mesh
! in general this coud involve some curvilinear transform
if (idir.EQ.1) then ! uniform X
ifc = 4
do el=1,nelv
call ftovec(map_xm1(1,1,el),ym1,el,ifc,nx1,ny1,nz1)
call ftovec(map_ym1(1,1,el),zm1,el,ifc,nx1,ny1,nz1)
enddo
elseif (idir.eq.2) then ! uniform y
ifc = 1
do el=1,nelv
call ftovec(map_xm1(1,1,el),xm1,el,ifc,nx1,ny1,nz1)
call ftovec(map_ym1(1,1,el),zm1,el,ifc,nx1,ny1,nz1)
enddo
elseif (idir.eq.3) then ! uniform z
ifc = 5
do el=1,nelv
call ftovec(map_xm1(1,1,el),xm1,el,ifc,nx1,ny1,nz1)
call ftovec(map_ym1(1,1,el),ym1,el,ifc,nx1,ny1,nz1)
enddo
endif
#ifdef DEBUG
! testing
! to output refinement
icalldl = icalldl+1
call io_file_freeid(iunit, ierrl)
write(str1,'(i3.3)') nid
write(str2,'(i3.3)') icalldl
open(unit=iunit,file='map2d_usr.txt'//str1//'i'//str2)
write(iunit,*) idir, nelv, nelsort
write(iunit,*) 'Centre coordinates and cells'
do el=1,nelsort
write(iunit,*) el, ctrs(:,el), cell(el)
enddo
write(iunit,*) 'GLL coordinates'
do el=1,nelsort
write(iunit,*) 'Element ', el
write(iunit,*) 'XM1'
do il=1,nz1
write(iunit,*) (map_xm1(jl,il,el),jl=1,nx1)
enddo
write(iunit,*) 'YM1'
do il=1,nz1
write(iunit,*) (map_ym1(jl,il,el),jl=1,nx1)
enddo
enddo
close(iunit)
#endif
return
end subroutine
!=======================================================================
subroutine ftovec(a, b, ie, iface, nx, ny, nz)
Definition: dssum.f:417
subroutine io_file_freeid(iunit, ierr)
Get free file unit number and store max unit value.
Definition: io_tools.f:47
subroutine copy(a, b, n)
Definition: math.f:260
subroutine izero(a, n)
Definition: math.f:215

Function Documentation

◆ map2d_get()

subroutine map2d_get

Get 3D to 2D element mapping.

Remarks
This routine uses global scratch space SCRNS , SCRVH and SCRUZ

Definition at line 119 of file map2D.f.

References ifill(), io_file_freeid(), map2d_get_global(), map2d_get_local(), mntr_abort(), mntr_check_abort(), mntr_log(), mntr_logi(), and mntr_tmr_add().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ map2d_get_global()

subroutine map2d_get_global ( real, dimension(lctrs1,lctrs2)  ctrs,
integer, dimension(lctrs2)  owner,
integer, dimension(lctrs2)  cell,
integer, dimension(lctrs2)  ninseg,
integer, dimension(lctrs2)  ind,
logical, dimension(lctrs2)  ifseg,
integer  lctrs1,
integer  lctrs2,
integer  nseg,
real  tol 
)

Get global 3D=>2D mapping.

Parameters
[in,out]ctrs2D element centres
[in,out]ownerglobal element ownership (work array)
[in,out]celllocal element numberring (work array)
[in,out]ninsegelements in segmen (work array)
[in,out]indsorting index (work array)
[in,out]ifsegsegment borders (work array)
[in]lctrs1,lctrs2array sizes
[in,out]nsegsegments number
[in]toltolerance to find segment borders

Definition at line 406 of file map2D.f.

References copy(), csend(), iswap_ip(), mntr_abort(), mntr_check_abort(), mntr_logi(), msgwait(), and tuple_sort().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ map2d_get_local()

subroutine map2d_get_local ( real, dimension(lctrs1,lctrs2)  ctrs,
integer, dimension(lctrs2)  cell,
integer, dimension(lctrs2)  ninseg,
integer, dimension(lctrs2)  ind,
logical, dimension(lctrs2)  ifseg,
integer  lctrs1,
integer  lctrs2,
integer  nseg,
integer  nelsort,
real  tol 
)

Get local 3D=>2D mapping.

Parameters
[out]ctrs2D element centres
[out]celllocal element numberring
[out]ninsegelements in segmen (work array)
[out]indsorting index (work array)
[out]ifsegsegment borders (work array)
[in]lctrs1,lctrs2array sizes
[out]nsegsegments number
[in]nelsortnumber of local 3D elements to sort
[in]toltolerance to find segment borders

Definition at line 309 of file map2D.f.

References iswap_ip(), and tuple_sort().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ map2d_init()

subroutine map2d_init

Initilise map2d module.

Note
This routine should be called in frame_usr_init

Definition at line 69 of file map2D.f.

References map2d_get(), map2d_init_coord(), mntr_log(), mntr_tmr_add(), and mntr_warn().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ map2d_init_coord()

subroutine map2d_init_coord

Generate 2D mesh out of 3D one.

Definition at line 701 of file map2D.f.

References copy(), ifill(), and io_file_freeid().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ map2d_register()

subroutine map2d_register

Register 2D mapping routines.

Note
This routine should be called in frame_usr_register

Definition at line 12 of file map2D.f.

References mntr_abort(), mntr_mod_is_name_reg(), mntr_mod_reg(), mntr_tmr_add(), mntr_tmr_is_name_reg(), mntr_tmr_reg(), and mntr_warn().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: