Skip to content

Commit 456fa4e

Browse files
committed
Store ScanPathSegments outside of ScanPath
1 parent 63407f7 commit 456fa4e

23 files changed

+328
-203
lines changed

source/CubeHeatSource.cc

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,14 @@
99
#include <instantiation.hh>
1010
#include <types.hh>
1111

12+
#include <deal.II/base/memory_space.h>
13+
1214
namespace adamantine
1315
{
14-
template <int dim>
15-
CubeHeatSource<dim>::CubeHeatSource(boost::property_tree::ptree const &database)
16-
: HeatSource<dim>()
16+
template <int dim, typename MemorySpaceType>
17+
CubeHeatSource<dim, MemorySpaceType>::CubeHeatSource(
18+
boost::property_tree::ptree const &database)
19+
: HeatSource<dim, MemorySpaceType>()
1720
{
1821
_start_time = database.get<double>("start_time");
1922
_end_time = database.get<double>("end_time");
@@ -29,15 +32,16 @@ CubeHeatSource<dim>::CubeHeatSource(boost::property_tree::ptree const &database)
2932
}
3033
}
3134

32-
template <int dim>
33-
void CubeHeatSource<dim>::update_time(double time)
35+
template <int dim, typename MemorySpaceType>
36+
void CubeHeatSource<dim, MemorySpaceType>::update_time(double time)
3437
{
3538
_source_on = ((time > _start_time) && (time < _end_time));
3639
}
3740

38-
template <int dim>
39-
double CubeHeatSource<dim>::value(dealii::Point<dim> const &point,
40-
double const /*height*/) const
41+
template <int dim, typename MemorySpaceType>
42+
double
43+
CubeHeatSource<dim, MemorySpaceType>::value(dealii::Point<dim> const &point,
44+
double const /*height*/) const
4145
{
4246
if (_source_on)
4347
{
@@ -58,12 +62,14 @@ double CubeHeatSource<dim>::value(dealii::Point<dim> const &point,
5862
return 0.;
5963
}
6064

61-
template <int dim>
62-
double CubeHeatSource<dim>::get_current_height(double const /*time*/) const
65+
template <int dim, typename MemorySpaceType>
66+
double CubeHeatSource<dim, MemorySpaceType>::get_current_height(
67+
double const /*time*/) const
6368
{
6469
return _max_point[axis<dim>::z];
6570
}
6671

6772
} // namespace adamantine
6873

69-
INSTANTIATE_DIM(CubeHeatSource)
74+
INSTANTIATE_DIM_DEVICE(CubeHeatSource)
75+
INSTANTIATE_DIM_HOST(CubeHeatSource)

source/CubeHeatSource.hh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ namespace adamantine
1616
* Cube heat source. This source does not represent a physical source, it is
1717
* used for verification purpose.
1818
*/
19-
template <int dim>
20-
class CubeHeatSource final : public HeatSource<dim>
19+
template <int dim, typename MemorySpaceType>
20+
class CubeHeatSource final : public HeatSource<dim, MemorySpaceType>
2121
{
2222
public:
2323
/**

source/DataAssimilator.hh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
#include <deal.II/fe/mapping_q1_eulerian.h>
1515
#include <deal.II/lac/full_matrix.h>
1616
#include <deal.II/lac/la_parallel_block_vector.h>
17-
#include <deal.II/lac/la_vector.h>
17+
// #include <deal.II/lac/la_vector.h>
1818
#include <deal.II/lac/solver_gmres.h>
1919
#include <deal.II/lac/sparse_matrix.h>
2020
#include <deal.II/lac/trilinos_sparse_matrix.h>

source/ElectronBeamHeatSource.cc

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,21 @@
99
#include <instantiation.hh>
1010
#include <types.hh>
1111

12+
#include <deal.II/base/memory_space.h>
13+
1214
namespace adamantine
1315
{
1416

15-
template <int dim>
16-
ElectronBeamHeatSource<dim>::ElectronBeamHeatSource(
17-
boost::property_tree::ptree const &database)
18-
: HeatSource<dim>(database)
17+
template <int dim, typename MemorySpaceType>
18+
ElectronBeamHeatSource<dim, MemorySpaceType>::ElectronBeamHeatSource(
19+
BeamHeatSourceProperties const &beam,
20+
ScanPath<MemorySpaceType> const &scan_path)
21+
: HeatSource<dim, MemorySpaceType>(beam, scan_path)
1922
{
2023
}
2124

22-
template <int dim>
23-
void ElectronBeamHeatSource<dim>::update_time(double time)
25+
template <int dim, typename MemorySpaceType>
26+
void ElectronBeamHeatSource<dim, MemorySpaceType>::update_time(double time)
2427
{
2528
static const double log_01 = std::log(0.1);
2629
_beam_center = this->_scan_path.value(time);
@@ -31,9 +34,9 @@ void ElectronBeamHeatSource<dim>::update_time(double time)
3134
(dealii::numbers::PI * this->_beam.radius_squared * this->_beam.depth);
3235
}
3336

34-
template <int dim>
35-
double ElectronBeamHeatSource<dim>::value(dealii::Point<dim> const &point,
36-
double const height) const
37+
template <int dim, typename MemorySpaceType>
38+
double ElectronBeamHeatSource<dim, MemorySpaceType>::value(
39+
dealii::Point<dim> const &point, double const height) const
3740
{
3841
double const z = point[axis<dim>::z] - height;
3942
if ((z + this->_beam.depth) < 0.)
@@ -65,4 +68,5 @@ double ElectronBeamHeatSource<dim>::value(dealii::Point<dim> const &point,
6568
}
6669
} // namespace adamantine
6770

68-
INSTANTIATE_DIM(ElectronBeamHeatSource)
71+
INSTANTIATE_DIM_DEVICE(ElectronBeamHeatSource)
72+
INSTANTIATE_DIM_HOST(ElectronBeamHeatSource)

source/ElectronBeamHeatSource.hh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ namespace adamantine
1717
* The form of the heat source model is taken from the following reference:
1818
* Raghavan et al, Acta Materilia, 112, 2016, pp 303-314.
1919
*/
20-
template <int dim>
21-
class ElectronBeamHeatSource final : public HeatSource<dim>
20+
template <int dim, typename MemorySpaceType>
21+
class ElectronBeamHeatSource final : public HeatSource<dim, MemorySpaceType>
2222
{
2323
public:
2424
/**
@@ -31,7 +31,8 @@ public:
3131
* - <B>input_file</B>: name of the file that contains the scan path
3232
* segments
3333
*/
34-
ElectronBeamHeatSource(boost::property_tree::ptree const &database);
34+
ElectronBeamHeatSource(BeamHeatSourceProperties const &beam,
35+
ScanPath<MemorySpaceType> const &scan_path);
3536

3637
/**
3738
* Set the time variable.

source/GoldakHeatSource.cc

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,21 @@
99
#include <instantiation.hh>
1010
#include <types.hh>
1111

12+
#include <deal.II/base/memory_space.h>
13+
1214
namespace adamantine
1315
{
1416

15-
template <int dim>
16-
GoldakHeatSource<dim>::GoldakHeatSource(
17-
boost::property_tree::ptree const &database)
18-
: HeatSource<dim>(database)
17+
template <int dim, typename MemorySpaceType>
18+
GoldakHeatSource<dim, MemorySpaceType>::GoldakHeatSource(
19+
BeamHeatSourceProperties const &beam,
20+
ScanPath<MemorySpaceType> const &scan_path)
21+
: HeatSource<dim, MemorySpaceType>(beam, scan_path)
1922
{
2023
}
2124

22-
template <int dim>
23-
void GoldakHeatSource<dim>::update_time(double time)
25+
template <int dim, typename MemorySpaceType>
26+
void GoldakHeatSource<dim, MemorySpaceType>::update_time(double time)
2427
{
2528
static const double _pi_over_3_to_1p5 =
2629
std::pow(dealii::numbers::PI / 3.0, 1.5);
@@ -32,9 +35,10 @@ void GoldakHeatSource<dim>::update_time(double time)
3235
(this->_beam.radius_squared * this->_beam.depth * _pi_over_3_to_1p5);
3336
}
3437

35-
template <int dim>
36-
double GoldakHeatSource<dim>::value(dealii::Point<dim> const &point,
37-
double const height) const
38+
template <int dim, typename MemorySpaceType>
39+
double
40+
GoldakHeatSource<dim, MemorySpaceType>::value(dealii::Point<dim> const &point,
41+
double const height) const
3842
{
3943
double const z = point[axis<dim>::z] - height;
4044
if ((z + this->_beam.depth) < 0.)
@@ -61,4 +65,5 @@ double GoldakHeatSource<dim>::value(dealii::Point<dim> const &point,
6165
}
6266
} // namespace adamantine
6367

64-
INSTANTIATE_DIM(GoldakHeatSource)
68+
INSTANTIATE_DIM_DEVICE(GoldakHeatSource)
69+
INSTANTIATE_DIM_HOST(GoldakHeatSource)

source/GoldakHeatSource.hh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ namespace adamantine
1717
* The form of the heat source model is taken from the following reference:
1818
* Coleman et al, Journal of Heat Transfer, (in press, 2020).
1919
*/
20-
template <int dim>
21-
class GoldakHeatSource final : public HeatSource<dim>
20+
template <int dim, typename MemorySpaceType>
21+
class GoldakHeatSource final : public HeatSource<dim, MemorySpaceType>
2222
{
2323
public:
2424
/**
@@ -31,7 +31,8 @@ public:
3131
* - <B>input_file</B>: name of the file that contains the scan path
3232
* segments
3333
*/
34-
GoldakHeatSource(boost::property_tree::ptree const &database);
34+
GoldakHeatSource(BeamHeatSourceProperties const &beam,
35+
ScanPath<MemorySpaceType> const &scan_path);
3536

3637
/**
3738
* Set the time variable.

source/HeatSource.hh

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace adamantine
2929
* of the part, and the second component is the thickness. That is, the last two
3030
* components are swapped between the two coordinate systems.
3131
*/
32-
template <int dim>
32+
template <int dim, typename MemorySpaceType>
3333
class HeatSource
3434
{
3535
public:
@@ -49,12 +49,9 @@ public:
4949
* - <B>input_file</B>: name of the file that contains the scan path
5050
* segments
5151
*/
52-
HeatSource(boost::property_tree::ptree const &database)
53-
: _beam(database),
54-
// PropertyTreeInput sources.beam_X.scan_path_file
55-
// PropertyTreeInput sources.beam_X.scan_path_format
56-
_scan_path(database.get<std::string>("scan_path_file"),
57-
database.get<std::string>("scan_path_file_format"))
52+
HeatSource(BeamHeatSourceProperties const &beam,
53+
ScanPath<MemorySpaceType> const &scan_path)
54+
: _beam(beam), _scan_path(scan_path)
5855
{
5956
}
6057

@@ -77,7 +74,7 @@ public:
7774
/**
7875
* Return the scan path for the heat source.
7976
*/
80-
virtual ScanPath const &get_scan_path() const;
77+
virtual ScanPath<MemorySpaceType> const &get_scan_path() const;
8178

8279
/**
8380
* Compute the current height of the where the heat source meets the material
@@ -100,23 +97,25 @@ protected:
10097
/**
10198
* The scan path for the heat source.
10299
*/
103-
ScanPath _scan_path;
100+
ScanPath<MemorySpaceType> _scan_path;
104101
};
105102

106-
template <int dim>
107-
inline ScanPath const &HeatSource<dim>::get_scan_path() const
103+
template <int dim, typename MemorySpaceType>
104+
inline ScanPath<MemorySpaceType> const &
105+
HeatSource<dim, MemorySpaceType>::get_scan_path() const
108106
{
109107
return _scan_path;
110108
}
111109

112-
template <int dim>
113-
inline double HeatSource<dim>::get_current_height(double const time) const
110+
template <int dim, typename MemorySpaceType>
111+
inline double
112+
HeatSource<dim, MemorySpaceType>::get_current_height(double const time) const
114113
{
115114
return _scan_path.value(time)[2];
116115
}
117116

118-
template <int dim>
119-
inline void HeatSource<dim>::set_beam_properties(
117+
template <int dim, typename MemorySpaceType>
118+
inline void HeatSource<dim, MemorySpaceType>::set_beam_properties(
120119
boost::property_tree::ptree const &database)
121120
{
122121
_beam.set_from_database(database);

0 commit comments

Comments
 (0)