24 integer(kind=kint) :: eid
25 integer(kind=kint) :: etype
26 integer(kind=kint),
pointer :: nodes(:)=>null()
27 integer(kind=kint) :: n_neighbor
28 integer(kind=kint) :: n_neighbor_max
29 integer(kind=kint),
pointer :: neighbor(:)=>null()
30 real(kind=kreal) :: reflen
31 real(kind=kreal) :: xavg(3)
32 real(kind=kreal) :: dmax
33 integer(kind=kint) :: bktid
34 real(kind=kreal),
pointer :: vertex_normals(:,:)=>null()
35 real(kind=kreal),
pointer :: intermediate_points(:,:)=>null()
38 integer(kind=kint),
parameter,
private :: debug = 0
44 integer(kind=kint),
intent(in) :: eid
45 integer(kind=kint),
intent(in) :: etype
46 integer(kind=kint),
intent(in) :: nsurf
48 integer(kind=kint) :: i, n, outtype, nodes(100)
52 call getsubface( etype, nsurf, outtype, nodes )
62 allocate( surf%nodes(n) )
63 surf%nodes(1:n)=nodes(1:n)
65 surf%n_neighbor_max = 0
70 allocate( surf%vertex_normals(3,n) )
71 surf%vertex_normals(:,:) = 0.d0
77 if(
associated(surf%nodes) )
deallocate( surf%nodes )
78 if(
associated(surf%neighbor) )
deallocate( surf%neighbor )
79 if(
associated(surf%vertex_normals) )
deallocate( surf%vertex_normals )
80 if(
associated(surf%intermediate_points) )
deallocate( surf%intermediate_points )
86 type(bucketdb),
intent(in) :: bktDB
87 integer(kind=kint) :: i, j, ii,jj, nd1, nd2, nsurf
88 integer(kind=kint) :: k, oldsize, newsize
89 integer(kind=kint),
pointer :: dumarray(:) => null()
90 integer(kind=kint) :: bktID, ncand, js
91 integer(kind=kint),
allocatable :: indexSurf(:)
92 if (debug >= 1)
write(0,*)
'DEBUG: find_surface_neighbor: start'
102 if (ncand == 0) cycle
103 allocate(indexsurf(ncand))
108 if(
associated(surf(i)%neighbor) )
then
109 if ( any( surf(i)%neighbor(1:surf(i)%n_neighbor)==j ) ) cycle
111 do ii=1,
size(surf(i)%nodes)
112 nd1 = surf(i)%nodes(ii)
113 do jj=1,
size(surf(j)%nodes)
114 nd2 = surf(j)%nodes(jj)
116 surf(i)%n_neighbor = surf(i)%n_neighbor+1
118 if( .not.
associated(surf(i)%neighbor) )
then
121 surf(i)%neighbor(1) = j
122 else if( surf(i)%n_neighbor > surf(i)%n_neighbor_max )
then
123 oldsize = surf(i)%n_neighbor_max
124 newsize = oldsize * 2
125 dumarray => surf(i)%neighbor
126 allocate( surf(i)%neighbor(newsize) )
127 surf(i)%n_neighbor_max = newsize
129 surf(i)%neighbor(k) = dumarray(k)
131 surf(i)%neighbor(oldsize+1) = j
132 deallocate( dumarray )
134 surf(i)%neighbor(surf(i)%n_neighbor) = j
142 deallocate(indexsurf)
146 if (debug >= 1)
write(0,*)
'DEBUG: find_surface_neighbor: end'
152 real(kind=kreal),
intent(in) :: coord(:)
154 integer(kind=kint) :: nn, i, j, iss
157 nn =
size(surf(j)%nodes)
159 iss = surf(j)%nodes(i)
160 elem(1:3,i) = coord(3*iss-2:3*iss)
171 real(kind=kreal),
intent(in) :: currpos(:)
172 integer(kind=kint) :: nn, i, j, iss
176 nn =
size(surf(j)%nodes)
178 iss = surf(j)%nodes(i)
179 elem(1:3,i) = currpos(3*iss-2:3*iss)
182 xmin(i) = minval(elem(i,1:nn))
183 xmax(i) = maxval(elem(i,1:nn))
184 xsum(i) = sum(elem(i,1:nn))
186 surf(j)%xavg(:) = xsum(:) / nn
187 lx(:) = xmax(:) - xmin(:)
188 surf(j)%dmax = maxval(lx) * 0.5d0
196 type(bucketdb),
intent(inout) :: bktDB
197 real(kind=kreal) :: x_min(3), x_max(3), d_max
198 integer(kind=kint) :: nsurf, i, j
199 if (debug >= 1)
write(0,*)
'DEBUG: update_surface_bucket_info: start'
201 if (nsurf == 0)
return
202 x_min(:) = surf(1)%xavg(:)
203 x_max(:) = surf(1)%xavg(:)
204 d_max = surf(1)%dmax*2.d0
207 if (surf(i)%xavg(j) < x_min(j)) x_min(j) = surf(i)%xavg(j)
208 if (surf(i)%xavg(j) > x_max(j)) x_max(j) = surf(i)%xavg(j)
209 if (surf(i)%dmax > d_max) d_max = surf(i)%dmax
213 x_min(j) = x_min(j) - d_max
214 x_max(j) = x_max(j) + d_max
227 if (debug >= 1)
write(0,*)
'DEBUG: update_surface_bucket_info: end'
234 real(kind=
kreal),
intent(in) :: elem(3,*)
236 integer(kind=kint) :: j, nn, etype
237 real(kind=
kreal) :: cnpos(2), normal(3)
240 nn =
size(surf%nodes)
245 normal = normal / dsqrt(dot_product(normal, normal))
246 surf%vertex_normals(:, j) = normal
254 real(kind=kreal),
intent(in) :: currpos(:)
256 integer(kind=kint) :: i, j, nn, iss
261 nn =
size(surf(i)%nodes)
263 iss = surf(i)%nodes(j)
264 elem(1:3, j) = currpos(3*iss-2:3*iss)
This module provides bucket-search functionality It provides definition of bucket info and its access...
subroutine, public bucketdb_allocate(bktdb)
Allocate memory before actually registering members Before allocating memory, bucketDB_registerPre ha...
subroutine, public bucketdb_registerpre(bktdb, bid)
Pre-register for just counting members to be actually registered Bucket ID has to be obtained with bu...
integer(kind=kint) function, public bucketdb_getbucketid(bktdb, x)
Get bucket ID that includes given point.
subroutine, public bucketdb_register(bktdb, bid, sid)
Register member Before actually register, bucketDB_allocate has to be called.
integer(kind=kint) function, public bucketdb_getnumcand(bktdb, bid)
Get number of candidates within neighboring buckets of a given bucket Bucket ID has to be obtained wi...
subroutine, public bucketdb_getcand(bktdb, bid, ncand, cand)
Get candidates within neighboring buckets of a given bucket Number of candidates has to be obtained w...
subroutine, public bucketdb_setup(bktdb, x_min, x_max, dmin, n_tot)
Setup basic info of buckets.
This module encapsulate the basic functions of all elements provide by this software.
integer(kind=kind(2)) function getnumberofnodes(etype)
Obtain number of nodes of the element.
subroutine getelementcenter(fetype, localcoord)
Return natural coordinate of the center of element.
subroutine getsubface(intype, innumber, outtype, nodes)
Find the definition of surface of the element.
subroutine getvertexcoord(fetype, cnode, localcoord)
Get the natural coord of a vertex node.
real(kind=kreal) function, dimension(3) surfacenormal(fetype, nn, localcoord, elecoord)
Calculate normal of 3d-surface.
real(kind=kreal) function getreferencelength(fetype, nn, localcoord, elecoord)
This function calculates reference length at a point in surface.
integer(kind=4), parameter kreal
This module provides aux functions.
This module manages surface elements in 3D It provides basic definition of surface elements (triangla...
subroutine initialize_surf(eid, etype, nsurf, surf)
Initializer.
integer(kind=kint), parameter l_max_elem_node
subroutine calc_surf_vertex_normals(surf, elem)
Compute vertex normals for a single surface element (geometric calculation only)
subroutine update_surface_reflen(surf, coord)
Compute reference length of surface elements.
subroutine update_surface_box_info(surf, currpos)
Update info of cubic box including surface elements.
integer(kind=kint), parameter l_max_elem_surf
subroutine find_surface_neighbor(surf, bktDB)
Find neighboring surface elements.
integer(kind=kint), parameter n_neighbor_max_init
subroutine update_surface_bucket_info(surf, bktDB)
Update bucket info for searching surface elements.
integer(kind=kint), parameter l_max_surface_node
subroutine finalize_surf(surf)
Memory management subroutine.
subroutine calc_all_surf_vertex_normals(surf, currpos)
Calculate vertex normals for all surface elements (geometric calculation only)
Structure to define surface group.