DCS
a Driven-Cavity Open source Simulator code
 All Classes Files Functions Variables Groups Pages
Data_Type_Mesh.f90
Go to the documentation of this file.
1 
6 
12 
18 
24 
26 module data_type_mesh
27 !-----------------------------------------------------------------------------------------------------------------------------------
28 USE ir_precision ! Integers and reals precision definition.
29 USE data_type_cell_quad ! Definition of Type_Cell_Quad.
30 USE data_type_node ! Definition of Type_Node.
31 USE data_type_face ! Definition of Type_Face.
32 !-----------------------------------------------------------------------------------------------------------------------------------
33 
34 !-----------------------------------------------------------------------------------------------------------------------------------
35 private
36 !-----------------------------------------------------------------------------------------------------------------------------------
37 
38 !-----------------------------------------------------------------------------------------------------------------------------------
41 type, public:: type_mesh
42  integer(I4P):: n = 0_i4p
43  real(R8P):: dh = 0._r8p
44  real(R8P), allocatable:: x(:)
45  real(R8P), allocatable:: y(:)
46 
47  integer(I4P):: nnode = 0_i4p
48  integer(I4P):: nface = 0_i4p
49  integer(I4P):: ncell = 0_i4p
50  type(type_node), allocatable:: node(:)
51  type(type_face), allocatable:: face(:)
52  type(type_cell_quad), allocatable:: cell(:)
53  contains
54  procedure, non_overridable:: initialize ! Procedure for initializing Type_Mesh.
55  procedure, non_overridable:: finalize ! Procedure for finalizing Type_Mesh.
56  procedure, non_overridable:: pprint ! Procedure for printing Type_Mesh components with a "pretty" format.
57 endtype type_mesh
58 !-----------------------------------------------------------------------------------------------------------------------------------
59 contains
63 
67  elemental subroutine initialize(self,N)
68  !---------------------------------------------------------------------------------------------------------------------------------
69  implicit none
70  class(type_mesh), intent(INOUT):: self
71  integer(I4P), intent(IN):: n
72  integer(I4P):: nnode
73  integer(I4P):: nface
74  integer(I4P):: ncell
75  integer(I4P):: ij
76  !---------------------------------------------------------------------------------------------------------------------------------
77 
78  !---------------------------------------------------------------------------------------------------------------------------------
79  self%N = n
80  self%dh = 1._r8p/real(n,r8p)
81  if (allocated(self%x)) deallocate(self%x) ; allocate(self%x(0:n))
82  if (allocated(self%y)) deallocate(self%y) ; allocate(self%y(0:n))
83  do ij=0,n
84  self%x(ij) = real(ij,r8p)/real(n,r8p)
85  enddo
86  self%y = self%x
87 
88  nnode = (n+1)*(n+1)
89  nface = 2*n*(n+1)
90  ncell = n*n
91  if (allocated(self%node)) deallocate(self%node) ; allocate(self%node(1:nnode))
92  if (allocated(self%face)) deallocate(self%face) ; allocate(self%face(1:nface))
93  if (allocated(self%cell)) deallocate(self%cell) ; allocate(self%cell(1:ncell))
94 ! ij = 0
95  !do j=0,N
96  !do i=0,N
97  !ij = ij + 1 ; call xyz%set(x=real(i,R8P)/real(N,R8P),y=real(j,R8P)/real(N,R8P),z=0._R8P) ; call self%node(ig)%initialize(xyz)
98  !enddo
99  !enddo
100  !ij = 0
101  !do j=1,N
102  !do i=1,N
103  !ij = ij + 1 ; call self%face(ij)%initialize(node=[self%node(ij)],N=null(),S=null())
104  !enddo
105 ! enddo
106  return
107  !---------------------------------------------------------------------------------------------------------------------------------
108  endsubroutine initialize
111  elemental subroutine finalize(self)
112  !---------------------------------------------------------------------------------------------------------------------------------
113  implicit none
114  class(type_mesh), intent(INOUT):: self
115  !---------------------------------------------------------------------------------------------------------------------------------
116 
117  !---------------------------------------------------------------------------------------------------------------------------------
118  self%N = 0_i4p
119  self%dh = 0._r8p
120  if (allocated(self%x)) deallocate(self%x)
121  if (allocated(self%y)) deallocate(self%y)
122  return
123  !---------------------------------------------------------------------------------------------------------------------------------
124  endsubroutine finalize
125 
128  function pprint(self,unit) result(err)
129  !---------------------------------------------------------------------------------------------------------------------------------
130  implicit none
131  class(type_mesh), intent(IN):: self
132  integer(I4P), intent(IN):: unit
133  integer(I4P):: err
134  integer(I4P):: ij
135  !---------------------------------------------------------------------------------------------------------------------------------
136 
137  !---------------------------------------------------------------------------------------------------------------------------------
138  write(unit,'(A)',iostat=err)' N='//str(n=self%N)
139  if (allocated(self%x).AND.allocated(self%y)) then
140  do ij=lbound(self%x,dim=1),ubound(self%x,dim=1)
141  write(unit,'(A)',iostat=err)' ij='//str(n=ij)//' x='//str(n=self%x(ij))//' y='//str(n=self%y(ij))
142  enddo
143  endif
144  write(unit,'(A)',iostat=err)' dh='//str(n=self%dh)
145  return
146  !---------------------------------------------------------------------------------------------------------------------------------
147  endfunction pprint
149 endmodule data_type_mesh
Derived type containing conservative variables.
procedure, non_overridable finalize
This module contains the definition of Type_Node and its procedures.
This module contains the definition of Type_Face and its procedures.
Derived type containing conservative variables.
Procedure for converting number, real and integer, to string (number to string type casting); logical...
integer, parameter, public r8p
15 digits, range ; 64 bits.
Derived type containing conservative variables.
procedure, non_overridable initialize
This module contains the definition of Type_Mesh and its procedures.
Derived type containing conservative variables.
procedure, non_overridable pprint
This module contains the definition of Type_Cell_Quad and its procedures.
Module IR_Precision makes available some portable kind-parameters and some useful procedures to deal ...