Skip to content

Commit 63407f7

Browse files
committed
Update ScanPath implementation
1 parent 51404d6 commit 63407f7

File tree

4 files changed

+25
-18
lines changed

4 files changed

+25
-18
lines changed

source/HeatSources.hh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,7 @@ template <typename MemorySpace, int dim>
217217
double HeatSources<MemorySpace, dim>::get_current_height(double time) const
218218
{
219219
// Right now this is just the maximum heat source height, which can lead to
220-
// unexpected behavior for
221-
// different sources with different heights.
220+
// unexpected behavior for different sources with different heights.
222221
double temp_height = std::numeric_limits<double>::lowest();
223222
for (unsigned int i = 0; i < _electron_beam_heat_sources.size(); ++i)
224223
temp_height = std::max(

source/ScanPath.cc

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ void ScanPath::load_segment_scan_path(std::string scan_path_file)
6060
{
6161
// Check to make sure the segment isn't the first, if it is, throw an
6262
// exception (the first segment must be a point in the spec).
63-
ASSERT_THROW(_segment_list.size() > 0,
63+
ASSERT_THROW(_segment_list_length > 0,
6464
"Error: Scan paths must begin with a 'point' segment.");
6565
}
6666
else if (split_line[0] == "1")
@@ -85,10 +85,10 @@ void ScanPath::load_segment_scan_path(std::string scan_path_file)
8585
// Set the velocity and end time
8686
if (segment_type == ScanPathSegmentType::point)
8787
{
88-
if (_segment_list.size() > 0)
88+
if (_segment_list_length > 0)
8989
{
90-
segment.end_time =
91-
_segment_list.back().end_time + std::stod(split_line[5]);
90+
segment.end_time = _segment_list[_segment_list_length - 1].end_time +
91+
std::stod(split_line[5]);
9292
}
9393
else
9494
{
@@ -98,12 +98,14 @@ void ScanPath::load_segment_scan_path(std::string scan_path_file)
9898
else
9999
{
100100
double velocity = std::stod(split_line[5]);
101-
double line_length =
102-
segment.end_point.distance(_segment_list.back().end_point);
103-
segment.end_time =
104-
_segment_list.back().end_time + std::abs(line_length / velocity);
101+
double line_length = segment.end_point.distance(
102+
_segment_list[_segment_list_length - 1].end_point);
103+
segment.end_time = _segment_list[_segment_list_length - 1].end_time +
104+
std::abs(line_length / velocity);
105105
}
106-
_segment_list.push_back(segment);
106+
if (_segment_list_length == MAX_NUMBER_OF_SEGMENTS)
107+
Kokkos::abort("too many segmnets");
108+
_segment_list[_segment_list_length++] = segment;
107109
data_index++;
108110
}
109111
file.close();
@@ -138,7 +140,9 @@ void ScanPath::load_event_series_scan_path(std::string scan_path_file)
138140
segment.power_modifier = last_power;
139141
last_power = std::stod(split_line[4]);
140142

141-
_segment_list.push_back(segment);
143+
if (_segment_list_length == MAX_NUMBER_OF_SEGMENTS)
144+
Kokkos::abort("too many segmnets");
145+
_segment_list[_segment_list_length++] = segment;
142146
}
143147
}
144148

@@ -169,7 +173,7 @@ dealii::Point<3> ScanPath::value(double const &time) const
169173
{
170174
// If the current time is after the scan path data is over, return a point
171175
// that is (presumably) out of the domain.
172-
if (time > _segment_list.back().end_time)
176+
if (time > _segment_list[_segment_list_length - 1].end_time)
173177
{
174178
dealii::Point<3> out_of_domain_point(std::numeric_limits<double>::lowest(),
175179
std::numeric_limits<double>::lowest(),
@@ -196,7 +200,7 @@ double ScanPath::get_power_modifier(double const &time) const
196200
{
197201
// If the current time is after the scan path data is over, set the power to
198202
// zero.
199-
if (time > _segment_list.back().end_time)
203+
if (time > _segment_list[_segment_list_length - 1].end_time)
200204
return 0.0;
201205

202206
// Get to the correct segment
@@ -209,7 +213,7 @@ double ScanPath::get_power_modifier(double const &time) const
209213

210214
std::vector<ScanPathSegment> ScanPath::get_segment_list() const
211215
{
212-
return _segment_list;
216+
return {&_segment_list[0], &_segment_list[0] + _segment_list_length};
213217
}
214218

215219
} // namespace adamantine

source/ScanPath.hh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#include <istream>
2020
#include <vector>
2121

22+
#define MAX_NUMBER_OF_SEGMENTS 100
23+
2224
namespace adamantine
2325
{
2426
/**
@@ -94,7 +96,9 @@ private:
9496
/**
9597
* The list of information about each segment in the scan path.
9698
*/
97-
std::vector<ScanPathSegment> _segment_list;
99+
ScanPathSegment _segment_list[MAX_NUMBER_OF_SEGMENTS];
100+
101+
int _segment_list_length = 0;
98102

99103
/**
100104
* The index of the current segment in the scan path.

tests/test_scan_path.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ class ScanPathTester
2222
std::vector<ScanPathSegment> get_segment_format_list()
2323
{
2424
ScanPath scan_path("scan_path.txt", "segment");
25-
return scan_path._segment_list;
25+
return scan_path.get_segment_list();
2626
};
2727
std::vector<ScanPathSegment> get_event_series_format_list()
2828
{
2929
ScanPath scan_path("scan_path_event_series.inp", "event_series");
30-
return scan_path._segment_list;
30+
return scan_path.get_segment_list();
3131
};
3232
};
3333

0 commit comments

Comments
 (0)