@@ -20,6 +20,12 @@ logical function logical_func(component, i, j, k, problemInfo)
2020 end function logical_func
2121 end interface
2222
23+ interface registerNode
24+ module procedure &
25+ registerNodeByIndex, &
26+ registerNodeByCoordinate
27+ end interface
28+
2329contains
2430
2531 subroutine find_and_store_important_coords (lowerBound , upperBound , component , problemInfo , nPoints , coords )
@@ -83,9 +89,11 @@ subroutine store_required_coords(lowerBound, upperBound, requestComponent, probl
8389 end do
8490 end subroutine store_required_coords
8591
86- subroutine createUnstructuredDataForVTU (counter , coords , currentType , Nodes , Edges , Quads , numNodes , numEdges , numQuads )
92+ subroutine createUnstructuredDataForVTU (counter , coords , currentType , Nodes , Edges , Quads , numNodes , numEdges , numQuads , usevtkindex , realXGrid , realYGrid , realZGrid )
8793 integer , intent (in ) :: counter
8894 integer (kind= SINGLE), intent (in ) :: coords(:, :), currentType(:)
95+ logical , intent (in ) :: usevtkindex
96+ real (KIND= RKIND), pointer , dimension (:), intent (in ) :: realXGrid, realYGrid, realZGrid
8997
9098 integer (kind= 4 ), intent (out ):: numNodes, numQuads, numEdges
9199 real (kind= RKIND), allocatable , dimension (:, :), intent (out ) :: Nodes
@@ -99,17 +107,27 @@ subroutine createUnstructuredDataForVTU(counter, coords, currentType, Nodes, Edg
99107 allocate (Quads(4 , numQuads))
100108 allocate (Nodes(3 , 2 * numEdges + 4 * numQuads))
101109
102- call registerElements(counter, coords, currentType, Nodes, Edges, Quads)
110+ call registerElements(counter, coords, currentType, Nodes, Edges, Quads, usevtkindex, realXGrid, realYGrid, realZGrid )
103111 return
104112 end subroutine
105113
106- subroutine registerNode (nodes , nodeIx , x , y , z )
114+ subroutine registerNodeByIndex (nodes , nodeIdx , x , y , z )
115+ real (kind= RKIND), dimension (:, :), intent (inout ) :: nodes
116+ integer (kind= SINGLE), intent (in ) :: nodeIdx, x, y, z
117+ ! We need to avoid using idx 0
118+ nodes(1 , nodeIdx + 1 ) = x* 1.0_RKIND
119+ nodes(2 , nodeIdx + 1 ) = y* 1.0_RKIND
120+ nodes(3 , nodeIdx + 1 ) = z* 1.0_RKIND
121+ end subroutine
122+
123+ subroutine registerNodeByCoordinate (nodes , nodeIdx , x , y , z )
107124 real (kind= RKIND), dimension (:, :), intent (inout ) :: nodes
108- integer (kind= SINGLE), intent (in ) :: nodeIx, x, y, z
125+ integer (kind= SINGLE), intent (in ) :: nodeIdx
126+ real (kind= RKIND), intent (in ) :: x, y, z
109127 ! We need to avoid using idx 0
110- nodes(1 , nodeIx + 1 ) = x* 1.0_RKIND
111- nodes(2 , nodeIx + 1 ) = y* 1.0_RKIND
112- nodes(3 , nodeIx + 1 ) = z* 1.0_RKIND
128+ nodes(1 , nodeIdx + 1 ) = x
129+ nodes(2 , nodeIdx + 1 ) = y
130+ nodes(3 , nodeIdx + 1 ) = z
113131 end subroutine
114132
115133 subroutine registerEdge (edges , edgeIdx , startNodeIdx , endNodeIdx )
@@ -145,66 +163,109 @@ subroutine countElements(counter, currentType, numEdges, numQuads)
145163 end do
146164 end subroutine
147165
148- subroutine registerElements (counter , coords , currentType , Nodes , Edges , Quads )
166+ subroutine registerElements (counter , coords , currentType , Nodes , Edges , Quads , usevtkindex , realXGrid , realYGrid , realZGrid )
149167 integer , intent (in ) :: counter
150168 integer (kind= SINGLE), intent (in ) :: coords(:, :), currentType(:)
151169 real (kind= RKIND), intent (inout ) :: Nodes(:, :)
152170 integer (kind= 4 ), intent (inout ) :: Edges(:, :), Quads(:, :)
171+ logical :: usevtkindex
172+ real (KIND= RKIND), pointer , dimension (:), intent (in ) :: realXGrid, realYGrid, realZGrid
153173
154174 integer :: nodeIdx, quadIdx, edgeIdx
175+ integer :: xCoord, yCoord, zCoord
155176 integer :: i
156177
157178 nodeIdx = - 1
158179 quadIdx = - 1
159180 edgeIdx = - 1
160-
181+
161182 do i = 1 , counter
183+ xCoord = coords(1 , i)
184+ yCoord = coords(2 , i)
185+ zCoord = coords(3 , i)
186+
162187 select case (currentType(i))
163188 case (iJx)
164189 nodeIdx = nodeIdx + 2
165- call registerNode(Nodes, nodeIdx - 1 , coords(1 , i) , coords(2 , i), coords(3 , i) )
166- call registerNode(Nodes, nodeIdx , coords(1 , i) + 1 , coords(2 , i), coords(3 , i) )
190+ if (usevtkindex) then
191+ call registerNode(Nodes, nodeIdx - 1 , xCoord , yCoord, zCoord )
192+ call registerNode(Nodes, nodeIdx , xCoord + 1 , yCoord, zCoord )
193+ else
194+ call registerNode(Nodes, nodeIdx - 1 , realXGrid(xCoord) , realYGrid(yCoord), realZGrid(zCoord) )
195+ call registerNode(Nodes, nodeIdx , realXGrid(xCoord + 1 ), realYGrid(yCoord), realZGrid(zCoord) )
196+ endif
167197 edgeIdx = edgeIdx + 1
168198 call registerEdge(Edges, edgeIdx, nodeIdx - 1 , nodeIdx)
169199
170200 case (iJy)
171201 nodeIdx = nodeIdx + 2
172- call registerNode(Nodes, nodeIdx - 1 , coords(1 , i), coords(2 , i) , coords(3 , i) )
173- call registerNode(Nodes, nodeIdx , coords(1 , i), coords(2 , i) + 1 , coords(3 , i) )
202+ if (usevtkindex) then
203+ call registerNode(Nodes, nodeIdx - 1 , xCoord , yCoord , zCoord )
204+ call registerNode(Nodes, nodeIdx , xCoord , yCoord + 1 , zCoord )
205+ else
206+ call registerNode(Nodes, nodeIdx - 1 , realXGrid(xCoord) , realYGrid(yCoord) , realZGrid(zCoord) )
207+ call registerNode(Nodes, nodeIdx , realXGrid(xCoord) , realYGrid(yCoord + 1 ), realZGrid(zCoord) )
208+ endif
174209 edgeIdx = edgeIdx + 1
175210 call registerEdge(Edges, edgeIdx, nodeIdx - 1 , nodeIdx)
176211
177212 case (iJz)
178213 nodeIdx = nodeIdx + 2
179- call registerNode(Nodes, nodeIdx - 1 , coords(1 , i), coords(2 , i) , coords(3 , i) )
180- call registerNode(Nodes, nodeIdx , coords(1 , i), coords(2 , i) , coords(3 , i) + 1 )
214+ if (usevtkindex) then
215+ call registerNode(Nodes, nodeIdx - 1 , xCoord, yCoord , zCoord )
216+ call registerNode(Nodes, nodeIdx , xCoord, yCoord , zCoord + 1 )
217+ else
218+ call registerNode(Nodes, nodeIdx - 1 , realXGrid(xCoord) , realYGrid(yCoord) , realZGrid(zCoord) )
219+ call registerNode(Nodes, nodeIdx , realXGrid(xCoord) , realYGrid(yCoord) , realZGrid(zCoord + 1 ))
220+ endif
181221 edgeIdx = edgeIdx + 1
182222 call registerEdge(Edges, edgeIdx, nodeIdx - 1 , nodeIdx)
183223
184224 case (iBloqueJx)
185225 nodeIdx = nodeIdx + 4
186- call registerNode(Nodes, nodeIdx - 3 , coords(1 , i), coords(2 , i) , coords(3 , i) )
187- call registerNode(Nodes, nodeIdx - 2 , coords(1 , i), coords(2 , i) + 1 , coords(3 , i) )
188- call registerNode(Nodes, nodeIdx - 1 , coords(1 , i), coords(2 , i) + 1 , coords(3 , i) + 1 )
189- call registerNode(Nodes, nodeIdx , coords(1 , i), coords(2 , i) , coords(3 , i) + 1 )
226+ if (usevtkindex) then
227+ call registerNode(Nodes, nodeIdx - 3 , xCoord, yCoord , zCoord )
228+ call registerNode(Nodes, nodeIdx - 2 , xCoord, yCoord + 1 , zCoord )
229+ call registerNode(Nodes, nodeIdx - 1 , xCoord, yCoord + 1 , zCoord + 1 )
230+ call registerNode(Nodes, nodeIdx , xCoord, yCoord , zCoord + 1 )
231+ else
232+ call registerNode(Nodes, nodeIdx - 3 , realXGrid(xCoord), realYGrid(yCoord) , realZGrid(zCoord) )
233+ call registerNode(Nodes, nodeIdx - 2 , realXGrid(xCoord), realYGrid(yCoord + 1 ), realZGrid(zCoord) )
234+ call registerNode(Nodes, nodeIdx - 1 , realXGrid(xCoord), realYGrid(yCoord + 1 ), realZGrid(zCoord + 1 ))
235+ call registerNode(Nodes, nodeIdx , realXGrid(xCoord), realYGrid(yCoord) , realZGrid(zCoord + 1 ))
236+ endif
190237 quadIdx = quadIdx + 1
191238 call registerQuad(Quads, quadIdx, nodeIdx - 3 , nodeIdx - 2 , nodeIdx - 1 , nodeIdx)
192239
193240 case (iBloqueJy)
194241 nodeIdx = nodeIdx + 4
195- call registerNode(Nodes, nodeIdx - 3 , coords(1 , i) , coords(2 , i), coords(3 , i) )
196- call registerNode(Nodes, nodeIdx - 2 , coords(1 , i) + 1 , coords(2 , i), coords(3 , i) )
197- call registerNode(Nodes, nodeIdx - 1 , coords(1 , i) + 1 , coords(2 , i), coords(3 , i) + 1 )
198- call registerNode(Nodes, nodeIdx , coords(1 , i) , coords(2 , i), coords(3 , i) + 1 )
242+ if (usevtkindex) then
243+ call registerNode(Nodes, nodeIdx - 3 , xCoord , yCoord, zCoord )
244+ call registerNode(Nodes, nodeIdx - 2 , xCoord + 1 , yCoord, zCoord )
245+ call registerNode(Nodes, nodeIdx - 1 , xCoord + 1 , yCoord, zCoord + 1 )
246+ call registerNode(Nodes, nodeIdx , xCoord , yCoord, zCoord + 1 )
247+ else
248+ call registerNode(Nodes, nodeIdx - 3 , realXGrid(xCoord) , realYGrid(yCoord), realZGrid(zCoord) )
249+ call registerNode(Nodes, nodeIdx - 2 , realXGrid(xCoord + 1 ), realYGrid(yCoord), realZGrid(zCoord) )
250+ call registerNode(Nodes, nodeIdx - 1 , realXGrid(xCoord + 1 ), realYGrid(yCoord), realZGrid(zCoord + 1 ))
251+ call registerNode(Nodes, nodeIdx , realXGrid(xCoord) , realYGrid(yCoord), realZGrid(zCoord + 1 ))
252+ endif
199253 quadIdx = quadIdx + 1
200254 call registerQuad(Quads, quadIdx, nodeIdx - 3 , nodeIdx - 2 , nodeIdx - 1 , nodeIdx)
201255
202256 case (iBloqueJz)
203257 nodeIdx = nodeIdx + 4
204- call registerNode(Nodes, nodeIdx - 3 , coords(1 , i) , coords(2 , i) , coords(3 , i))
205- call registerNode(Nodes, nodeIdx - 2 , coords(1 , i) + 1 , coords(2 , i) , coords(3 , i))
206- call registerNode(Nodes, nodeIdx - 1 , coords(1 , i) + 1 , coords(2 , i) + 1 , coords(3 , i))
207- call registerNode(Nodes, nodeIdx , coords(1 , i) , coords(2 , i) + 1 , coords(3 , i))
258+ if (usevtkindex) then
259+ call registerNode(Nodes, nodeIdx - 3 , xCoord , yCoord , zCoord)
260+ call registerNode(Nodes, nodeIdx - 2 , xCoord + 1 , yCoord , zCoord)
261+ call registerNode(Nodes, nodeIdx - 1 , xCoord + 1 , yCoord + 1 , zCoord)
262+ call registerNode(Nodes, nodeIdx , xCoord , yCoord + 1 , zCoord)
263+ else
264+ call registerNode(Nodes, nodeIdx - 3 , realXGrid(xCoord) , realYGrid(yCoord) , realZGrid(zCoord))
265+ call registerNode(Nodes, nodeIdx - 2 , realXGrid(xCoord + 1 ), realYGrid(yCoord) , realZGrid(zCoord))
266+ call registerNode(Nodes, nodeIdx - 1 , realXGrid(xCoord + 1 ), realYGrid(yCoord + 1 ), realZGrid(zCoord))
267+ call registerNode(Nodes, nodeIdx , realXGrid(xCoord) , realYGrid(yCoord + 1 ), realZGrid(zCoord))
268+ endif
208269 quadIdx = quadIdx + 1
209270 call registerQuad(Quads, quadIdx, nodeIdx - 3 , nodeIdx - 2 , nodeIdx - 1 , nodeIdx)
210271 end select
0 commit comments