@@ -73,10 +73,13 @@ TriSubChannelMesh::channelIndex(const Point & p) const
7373 /// Looping over all subchannels to determine the closest one to the point
7474 /// Special treatment for edge and corner subchannels since deformed elements may lead to wrong transfers
7575
76- // Distances to determine the closest subchannel
77- Real distance0 = 1.0e+8 ; // Dummy distance to keep updating the closes distance found
78- Real distance1 ; // Distance to be updated with the current subchannel distance
79- unsigned int j = 0 ; // Index to keep track of the closest point to subchannel
76+ Real distance1 ;
77+ Real distance_center = 1.0e+8 ;
78+ Real distance_edge = 1.0e+8 ;
79+ Real distance_corner = 1.0e+8 ;
80+ unsigned int center_idx = 0 ;
81+ unsigned int edge_idx = 0 ;
82+ unsigned int corner_idx = 0 ;
8083
8184 // Projecting point into hexahedral coordinated to determine if the point belongs to a center
8285 // subchannel
@@ -96,44 +99,34 @@ TriSubChannelMesh::channelIndex(const Point & p) const
9699 Real x_coord_new = (std ::cos (- rem_ang ) * p (0 ) - std ::sin (- rem_ang ) * p (1 ));
97100 Real x_lim = (_n_rings - 1 ) * _pitch / 2.0 ;
98101
99- // looping over all channels
100102 for (unsigned int i = 0 ; i < _n_channels ; i ++ )
101103 {
102- // Distance from the point to subchannel
103104 distance1 = std ::sqrt (std ::pow ((p (0 ) - _subchannel_position [i ][0 ]), 2.0 ) +
104105 std ::pow ((p (1 ) - _subchannel_position [i ][1 ]), 2.0 ));
105106
106- // If subchannel belongs to center ring
107- if (channel_distance < distance_outer_ring )
107+ if (_subch_type [i ] == EChannelType ::CENTER && distance1 < distance_center )
108108 {
109- if ((distance1 < distance0 ) && (_subch_type [i ] == EChannelType ::CENTER ))
110- {
111- j = i ;
112- distance0 = distance1 ;
113- } // if
114- } // if
115- // If subchannel belongs to outer ring
116- else
109+ center_idx = i ;
110+ distance_center = distance1 ;
111+ }
112+ else if (_subch_type [i ] == EChannelType ::EDGE && distance1 < distance_edge )
117113 {
118- if ((distance1 < distance0 ) &&
119- (_subch_type [i ] == EChannelType ::EDGE || _subch_type [i ] == EChannelType ::CORNER ))
120- {
121- if ((x_coord_new > x_lim || x_coord_new < - x_lim ) &&
122- _subch_type [i ] == EChannelType ::CORNER )
123- {
124- j = i ;
125- distance0 = distance1 ;
126- } // if
127- else if ((x_coord_new <= x_lim && x_coord_new >= - x_lim ) &&
128- _subch_type [i ] == EChannelType ::EDGE )
129- {
130- j = i ;
131- distance0 = distance1 ;
132- }
133- }
114+ edge_idx = i ;
115+ distance_edge = distance1 ;
116+ }
117+ else if (_subch_type [i ] == EChannelType ::CORNER && distance1 < distance_corner )
118+ {
119+ corner_idx = i ;
120+ distance_corner = distance1 ;
134121 }
135122 }
136- return j ;
123+
124+ if (channel_distance < distance_outer_ring )
125+ return center_idx ;
126+ else if ((x_coord_new > x_lim ) || (x_coord_new < - x_lim ))
127+ return corner_idx ;
128+ else
129+ return edge_idx ;
137130}
138131
139132void
0 commit comments