- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi.
I have a quastion about storage of pointers. i am working on data structure of a CFD program. There are some user defined types where need to point to other user defined types. in my old version, i used integers (or user defined types) to point array index of desierd user defined types. For example:
TYPE FACEFAM
INTEGER :: FACENUM
INTEGER :: FACTYPE
INTEGER :: PARNUM
TYPE (PARENT),ALLOCATABLE :: PARENTS(:)
INTEGER ,ALLOCATABLE :: NODES(:)
REAL(8) :: AREA
REAL(8), DIMENSION(3) :: NORMAL
REAL(8), DIMENSION(3) :: R
END TYPE FACEFAM
! FACE
TYPE FACE
INTEGER :: FACENUM
INTEGER :: FACTYPE
INTEGER ,ALLOCATABLE :: NODES(:)
REAL(8) :: NORSGN=0.D0
LOGICAL :: BND=.FALSE.
INTEGER :: BNDSET
INTEGER :: BNDNUM
END TYPE FACE
TYPE ELEMENT
INTEGER :: ELMNUM
INTEGER :: ELMTYP
INTEGER :: NUMNOD
INTEGER,ALLOCATABLE :: ELMNOD(:)
INTEGER :: NUMEDG
INTEGER :: NUMFAC
INTEGER :: NUMBND=0
INTEGER :: NUMNEIGH
TYPE(EDGE),ALLOCATABLE :: EDGES(:)
TYPE(FACE),ALLOCATABLE :: FACES(:) !!!!!!!!!!!! note to thistype.+++++++++++++++++++++++++++++++++++++++++++++++++
INTEGER,ALLOCATABLE :: ELMNIG(:)
REAL(8) :: CENTROID(3)
REAL(8) :: VOLUME
LOGICAL :: LOGFLG=.FALSE. ! LOGICAL FLAG
INTEGER,ALLOCATABLE :: STENCIL(:)
REAL(8),ALLOCATABLE :: AP(:,:)
REAL(8),ALLOCATABLE :: D(:)
REAL(8),ALLOCATABLE :: INTG(:)
END TYPE ELEMENT
! CALCULATING ELEMENTS VOLUME
I=0.D0
V=0.D0
DO I=1,MESHDATA.SPEC.NUMELM
W=0.D0
C(1:3)=0.D0
DO J=1,MESHDATA.ELEMENTS(I).NUMFAC
M=MESHDATA.ELEMENTS(I).FACES(J).FACENUM
S=(MESHDATA.ELEMENTS(I).FACES(J).NORSGN)*(MESHDATA.FACES(M).AREA)*(MESHDATA.FACES(M).NORMAL)
R=MESHDATA.FACES(M).R
W=(S(1)*R(1)+S(2)*R(2)+S(3)*R(3))+W
C=(S(1)*R(1)+S(2)*R(2)+S(3)*R(3))*R+C
CONTINUE
END DO
MESHDATA.ELEMENTS(I).VOLUME=W/3.D0
MESHDATA.ELEMENTS(I).CENTROID=C/W*3.D0/4.D0
V=W+V
END DO
MESHDATA.SPEC.VOLUME=V
Now, i want to use pointers to simplifiy the redirections (and also other advantages of pointers). for exapmle (types are not complete yet) :
type,abstract :: type_face_base
integer :: surface_number
integer :: surface_type
integer :: parent_number
real(wp) :: area
logical :: flag=.false.
class(type_node_2d),pointer :: nodes(:)
class(type_vector_2d),allocatable :: normal
class(type_vector_2d),allocatable :: centroid
end type type_face_base
type :: type_face_container
class(type_face_base),pointer :: face
end type type_face_container
type,extends(type_face_base) :: type_face_triangle
end type type_face_triangle
type,abstract :: type_element_base
integer :: element_number
integer :: number_of_boundaries=0
integer :: number_of_neighbors
integer,allocatable :: neighbors(:)
real(wp) :: volume
class(type_node_2d),pointer :: nodes(:)=>null()
class(type_face_container),allocatable :: faces(:) !!!!!! note to thistype.+++++++++++++++++++++++++++++++++++++++++++++++++
class(type_vector_2d),allocatable :: centroid
logical :: flag=.false. ! logical flag
integer,allocatable :: stencil(:)
real(wp),allocatable :: aplus(:,:)
real(wp),allocatable :: d(:)
real(wp),allocatable :: geometric_moments(:)
contains
procedure(interface_initiate),deferred :: initiate
end type type_element_base
I want to know about memory usage of pointers. Does their memory usage is in order of default integers or they use more memory due to their declared type?
Sorry for bad english.
Thanks.
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page