Skip to content

Commit cdb7692

Browse files
committed
Harden triangular subchannel point classification Refs idaholab#32847
1 parent 21e0bb2 commit cdb7692

2 files changed

Lines changed: 29 additions & 46 deletions

File tree

modules/subchannel/src/mesh/TriSubChannelMesh.C

Lines changed: 26 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -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

139132
void

modules/subchannel/src/meshgenerators/SCMDetailedTriAssemblyMeshGenerator.C

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -395,19 +395,9 @@ SCMDetailedTriAssemblyMeshGenerator::generate()
395395
}
396396

397397
// specify number and type of sub-channel
398-
unsigned int n_center, n_side, n_corner;
399-
if (_n_rings == 1)
400-
{
401-
n_corner = 6;
402-
n_side = 0;
403-
n_center = _n_channels - n_side - n_corner;
404-
}
405-
else
406-
{
407-
n_corner = 6;
408-
n_side = (_n_rings - 1) * 6;
409-
n_center = _n_channels - n_side - n_corner;
410-
}
398+
unsigned int n_corner = 6;
399+
unsigned int n_side = (_n_rings - 1) * 6;
400+
unsigned int n_center = _n_channels - n_side - n_corner;
411401
if (_verbose)
412402
{
413403
_console << "Centers: " << n_center << std::endl;

0 commit comments

Comments
 (0)