@@ -82,17 +82,15 @@ TriSubChannelMesh::channelIndex(const Point & p) const
8282 // subchannel
8383 Real distance_outer_ring = _flat_to_flat / 2 - _duct_to_pin_gap - _pin_diameter / 2 ;
8484 Real channel_distance = std ::sqrt (std ::pow (p (0 ), 2 ) + std ::pow (p (1 ), 2 ));
85- Real angle = std ::abs (std ::atan (p (1 ) / p (0 )));
85+ Real angle = std ::abs (std ::atan2 (p (1 ), p (0 )));
8686 Real projection_angle =
8787 angle - libMesh ::pi / 6 - std ::trunc (angle / (libMesh ::pi / 3 )) * (libMesh ::pi / 3 );
8888 channel_distance = channel_distance * std ::cos (projection_angle );
8989
9090 // Projecting point on top edge to determine if the point is a corner or edge subchannel by x
9191 // coordinate
92- Real loc_angle = std ::atan (p (1 ) / p (0 ));
93- if (p (0 ) <= 0 )
94- loc_angle += libMesh ::pi ;
95- else if (p (0 ) >= 0 && p (1 ) <= 0 )
92+ Real loc_angle = std ::atan2 (p (1 ), p (0 ));
93+ if (loc_angle < 0.0 )
9694 loc_angle += 2 * libMesh ::pi ;
9795 Real rem_ang = std ::trunc (loc_angle / (libMesh ::pi / 3 )) * (libMesh ::pi / 3 ) - libMesh ::pi / 3 ;
9896 Real x_coord_new = (std ::cos (- rem_ang ) * p (0 ) - std ::sin (- rem_ang ) * p (1 ));
@@ -104,7 +102,9 @@ TriSubChannelMesh::channelIndex(const Point & p) const
104102
105103 if (_n_rings == 1 )
106104 {
107- Real angle = std ::atan (p (1 ) / p (0 ));
105+ Real angle = std ::atan2 (p (1 ), p (0 ));
106+ if (angle < 0.0 )
107+ angle += 2.0 * libMesh ::pi ;
108108 if ((i * libMesh ::pi / 6.0 < angle ) && (angle <= (i + 1 ) * libMesh ::pi / 6.0 ))
109109 return i ;
110110 }
@@ -129,13 +129,13 @@ TriSubChannelMesh::channelIndex(const Point & p) const
129129 if ((distance1 < distance0 ) &&
130130 (_subch_type [i ] == EChannelType ::EDGE || _subch_type [i ] == EChannelType ::CORNER ))
131131 {
132- if ((( x_coord_new > x_lim ) || ( x_coord_new < - x_lim ) ) &&
132+ if ((x_coord_new > x_lim || x_coord_new < - x_lim ) &&
133133 _subch_type [i ] == EChannelType ::CORNER )
134134 {
135135 j = i ;
136136 distance0 = distance1 ;
137137 } // if
138- else if ((( x_coord_new > x_lim ) || ( x_coord_new > - x_lim ) ) &&
138+ else if ((x_coord_new <= x_lim && x_coord_new >= - x_lim ) &&
139139 _subch_type [i ] == EChannelType ::EDGE )
140140 {
141141 j = i ;
0 commit comments