Rocstar  1.0
Rocstar multiphysics simulation application
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FIND_NODES.f90
Go to the documentation of this file.
1 !*********************************************************************
2 !* Illinois Open Source License *
3 !* *
4 !* University of Illinois/NCSA *
5 !* Open Source License *
6 !* *
7 !* Copyright@2008, University of Illinois. All rights reserved. *
8 !* *
9 !* Developed by: *
10 !* *
11 !* Center for Simulation of Advanced Rockets *
12 !* *
13 !* University of Illinois *
14 !* *
15 !* www.csar.uiuc.edu *
16 !* *
17 !* Permission is hereby granted, free of charge, to any person *
18 !* obtaining a copy of this software and associated documentation *
19 !* files (the "Software"), to deal with the Software without *
20 !* restriction, including without limitation the rights to use, *
21 !* copy, modify, merge, publish, distribute, sublicense, and/or *
22 !* sell copies of the Software, and to permit persons to whom the *
23 !* Software is furnished to do so, subject to the following *
24 !* conditions: *
25 !* *
26 !* *
27 !* @ Redistributions of source code must retain the above copyright *
28 !* notice, this list of conditions and the following disclaimers. *
29 !* *
30 !* @ Redistributions in binary form must reproduce the above *
31 !* copyright notice, this list of conditions and the following *
32 !* disclaimers in the documentation and/or other materials *
33 !* provided with the distribution. *
34 !* *
35 !* @ Neither the names of the Center for Simulation of Advanced *
36 !* Rockets, the University of Illinois, nor the names of its *
37 !* contributors may be used to endorse or promote products derived *
38 !* from this Software without specific prior written permission. *
39 !* *
40 !* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, *
41 !* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES *
42 !* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND *
43 !* NONINFRINGEMENT. IN NO EVENT SHALL THE CONTRIBUTORS OR *
44 !* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER *
45 !* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, *
46 !* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE *
47 !* USE OR OTHER DEALINGS WITH THE SOFTWARE. *
48 !*********************************************************************
49 !* Please acknowledge The University of Illinois Center for *
50 !* Simulation of Advanced Rockets in works and publications *
51 !* resulting from this software or its derivatives. *
52 !*********************************************************************
53  SUBROUTINE find_nodes
55 
56  IMPLICIT NONE
57 
58  INTEGER :: num_matches ! The number of nodes with matching XY coord values
59  ! This should equal numscale_np and is used for verification
60  INTEGER :: iteration ! The number of iteration the subroutine has gone through
61  INTEGER :: max_iterations ! The maximum number of iterations for the search algorithm
62  INTEGER :: step ! The step value for redifining the tolerances
63 
64  REAL*8 :: low_tol ! The lower tolerance by which 'FIND_NODES' determines a match
65  REAL*8 :: hi_tol ! The upper tolerance by which 'FIND_NODES' determines a match
66 
67  ! Variable initializations
68  low_tol = 99999.00000
69  hi_tol = 100001.00000
70  max_iterations = 5
71  iteration = 1
72  step = 5
73 
74  IF (numscale_ft .NE. numscale_bk) THEN
75  WRITE(6,*) "ERROR: The number of nodes on the front and back surfaces do not equal."
76  WRITE(6,*) "Please check your mesh and try again."
77  stop
78  ENDIF
79 
80  WRITE(6,'(//A)') "Beginning search on sister nodes... This could take a while"
81 
82 100 frontnode => first_front_node
83  backnode => first_back_node
84  num_matches = 0
85  iteration = iteration + 1
86 
87  DO WHILE(associated(backnode%next))
88  DO WHILE(associated(frontnode%next))
89 
90 ! WRITE(6,*) "COORDS"
91 ! WRITE(6,*) "backnode", backnode%ID, backnode%coord(1:3)
92 ! WRITE(6,*) "frontnode", frontnode%ID, frontnode%coord(1:3)
93 
94 ! WRITE(6,*) "DIVISION"
95 ! WRITE(6,*) backnode%coord(1)/frontnode%coord(1)
96 ! WRITE(6,*) backnode%coord(2)/frontnode%coord(2)
97 
98  ! If the 'X' coord is almost identical for both nodes THEN
99  ! check the 'Y' coord value
100  IF ((backnode%coord(1) .EQ. frontnode%coord(1)) .OR. &
101  ((backnode%coord(1)/frontnode%coord(1) .GT. low_tol/100000) .AND. &
102  (backnode%coord(1)/frontnode%coord(1) .LT. hi_tol/100000))) THEN
103  ! IF the 'Y' coord is almost identical for both nodes THEN
104  ! these nodes are sister nodes (a match is found)
105  IF((backnode%coord(2) .EQ. frontnode%coord(2)) .OR. &
106  ((backnode%coord(2)/frontnode%coord(2) .GT. low_tol/100000) .AND. &
107  (backnode%coord(2)/frontnode%coord(2) .LT. hi_tol/100000))) THEN
108  backnode%sister => frontnode
109  frontnode%sister => backnode
110  num_matches = num_matches + 1
111  ENDIF
112  ENDIF
113  ! proceed to the next node
114  frontnode => frontnode%next
115  ENDDO
116  ! Once all the front nodes are cycled through, proceed to the next backnode
117  ! and begin the search again
118  backnode => backnode%next
119  frontnode => first_front_node
120  ENDDO
121 
122 
123 
124 !!$ WRITE(6,*) "Writing node match information to '3Dnodematch.dat' file..."
125 !!$
126 !!$ OPEN(UNIT = 400, FILE = '3Dnodematch.dat', STATUS = 'UNKNOWN')
127 !!$
128 !!$ frontnode => first_front_node
129 !!$ backnode => first_back_node
130 !!$
131 !!$ WRITE(400,'(A8,3(6X,A1,5X),5X,A9,3(6X,A1,5X))') &
132 !!$ "BACKNODE", "X", "Y", "Z", "FRONTNODE", "X", "Y", "Z"
133 !!$
134 !!$ DO WHILE(associated(frontnode%next) .AND. associated(backnode%next))
135 !!$ WRITE(400,'(I8,3F12.8,6X,I8,3F12.8)') backnode%ID, backnode%coord(1:3), &
136 !!$ backnode%sister%ID, backnode%sister%coord(1:3)
137 !!$ frontnode => frontnode%next
138 !!$ backnode => backnode%next
139 !!$ END DO
140 !!$
141 !!$ CLOSE(400)
142 
143 
144 
145  WRITE(6,*) "Number of verified matches: ", num_matches
146  WRITE(6,*) "Number of intended matches: ", numscale_np/2
147 
148  IF (iteration .LE. max_iterations) THEN
149  IF (numscale_np/2 .NE. num_matches) THEN
150  WRITE(6,*) "There was a failure in matching up the desired number of nodes."
151  WRITE(6,*) "Redefining tolerances and starting iteration number ", iteration
152  low_tol = low_tol - step
153  hi_tol = hi_tol + step
154  goto 100
155  ELSE IF (numscale_np/2 .EQ. num_matches) THEN
156  WRITE(6,*) "Number of matches confirmed. Proceeding to next step."
157  ENDIF
158  ENDIF
159 
160  END SUBROUTINE find_nodes
161 
162 
163 
164 
165 
166 
167 
168 
169 
subroutine find_nodes
Definition: FIND_NODES.f90:53