@@ -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 ));
@@ -101,46 +99,36 @@ TriSubChannelMesh::channelIndex(const Point & p) const
10199 // looping over all channels
102100 for (unsigned int i = 0 ; i < _n_channels ; i ++ )
103101 {
102+ // Distance from the point to subchannel
103+ distance1 = std ::sqrt (std ::pow ((p (0 ) - _subchannel_position [i ][0 ]), 2.0 ) +
104+ std ::pow ((p (1 ) - _subchannel_position [i ][1 ]), 2.0 ));
104105
105- if (_n_rings == 1 )
106+ // If subchannel belongs to center ring
107+ if (channel_distance < distance_outer_ring )
106108 {
107- Real angle = std ::atan (p (1 ) / p (0 ));
108- if ((i * libMesh ::pi / 6.0 < angle ) && (angle <= (i + 1 ) * libMesh ::pi / 6.0 ))
109- return i ;
110- }
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
111116 else
112117 {
113- // Distance from the point to subchannel
114- distance1 = std ::sqrt (std ::pow ((p (0 ) - _subchannel_position [i ][0 ]), 2.0 ) +
115- std ::pow ((p (1 ) - _subchannel_position [i ][1 ]), 2.0 ));
116-
117- // If subchannel belongs to center ring
118- if (channel_distance < distance_outer_ring )
118+ if ((distance1 < distance0 ) &&
119+ (_subch_type [i ] == EChannelType ::EDGE || _subch_type [i ] == EChannelType ::CORNER ))
119120 {
120- if ((distance1 < distance0 ) && (_subch_type [i ] == EChannelType ::CENTER ))
121+ if (((x_coord_new > x_lim ) || (x_coord_new < - x_lim )) &&
122+ _subch_type [i ] == EChannelType ::CORNER )
121123 {
122124 j = i ;
123125 distance0 = distance1 ;
124126 } // if
125- } // if
126- // If subchannel belongs to outer ring
127- else
128- {
129- if ((distance1 < distance0 ) &&
130- (_subch_type [i ] == EChannelType ::EDGE || _subch_type [i ] == EChannelType ::CORNER ))
127+ else if ((x_coord_new <= x_lim && x_coord_new >= - x_lim ) &&
128+ _subch_type [i ] == EChannelType ::EDGE )
131129 {
132- if (((x_coord_new > x_lim ) || (x_coord_new < - x_lim )) &&
133- _subch_type [i ] == EChannelType ::CORNER )
134- {
135- j = i ;
136- distance0 = distance1 ;
137- } // if
138- else if (((x_coord_new > x_lim ) || (x_coord_new > - x_lim )) &&
139- _subch_type [i ] == EChannelType ::EDGE )
140- {
141- j = i ;
142- distance0 = distance1 ;
143- }
130+ j = i ;
131+ distance0 = distance1 ;
144132 }
145133 }
146134 }
@@ -205,7 +193,7 @@ TriSubChannelMesh::pinPositions(std::vector<Point> & positions,
205193 Real theta_corrected = 0.0 ;
206194 Real pi = libMesh ::pi ;
207195 unsigned int k = 0 ;
208- positions .emplace_back (0.0 , 0.0 );
196+ positions .emplace_back (center ( 0 ), center ( 1 ) );
209197 for (unsigned int i = 1 ; i < nrings ; i ++ )
210198 {
211199 dtheta = 2.0 * pi / (i * 6 );
0 commit comments