/* SPDX-FileCopyrightText: Copyright (c) 2020 - 2026, the adamantine authors. * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception */ #ifndef HEAT_SOURCE_HH #define HEAT_SOURCE_HH #include #include #include #include #include #include namespace adamantine { /** * This is the base class for describing the functional form of a heat * source. It has a pure virtual "value" method that needs to be implemented in * a derived class. * NOTE: The coordinate system in this class is different than * for the finite element mesh. In this class, the first two components of a * dealii::Point<3> describe the position along the surface of the part. The * last component is the height through the thickness of the part from the base * plate. This is in opposition to the finite element mesh where the first and * last components of a dealii::Point<3> describe the position along the surface * of the part, and the second component is the thickness. That is, the last two * components are swapped between the two coordinate systems. */ template class HeatSource { public: /** * Default constructor. This constructor should only be used for non-beam heat * source. */ HeatSource() = default; /** * Constructor. * \param[in] beam_database requires the following entries: * - absorption_efficiency: double in \f$[0,1]\f$ * - depth: double in \f$[0,\infty)\f$ * - diameter: double in \f$[0,\infty)\f$ * - max_power: double in \f$[0, \infty)\f$ * - input_file: name of the file that contains the scan path * segments * \param[in] units_optional_database may contain the following entries: * - heat_source.dimension * - heat_source.power */ HeatSource(boost::property_tree::ptree const &beam_database, boost::optional const &units_optional_database) : _beam(beam_database, units_optional_database), // PropertyTreeInput sources.beam_X.scan_path_file // PropertyTreeInput sources.beam_X.scan_path_file_format _scan_path(beam_database.get("scan_path_file"), beam_database.get("scan_path_file_format"), units_optional_database) { } /** * Destructor. */ virtual ~HeatSource() = default; /** * Set the time variable. */ virtual void update_time(double time) = 0; /** * Return true if the heat source is on. */ virtual bool is_source_on() const; /** * Compute the heat source at a given point at a given time */ virtual double value(dealii::Point const &points) const = 0; /** * Same function as above but it uses vectorized data. */ virtual dealii::VectorizedArray value(dealii::Point> const &points) const = 0; /** * Return the scan path for the heat source. */ virtual ScanPath &get_scan_path(); /** * (Re)sets the BeamHeatSourceProperties member variable, necessary if the * beam parameters vary in time (e.g. due to data assimilation). */ virtual void set_beam_properties(boost::property_tree::ptree const &database); /** * Return a scaled bounding box of the heat source at the given time. */ virtual dealii::BoundingBox get_bounding_box(double const time, double const scaling_factor) const = 0; protected: /** * Flag is true if the power is on. It is false otherwise. */ bool _source_on = false; /** * Structure of the physical properties of the beam heat source. */ BeamHeatSourceProperties _beam; /** * The scan path for the heat source. */ ScanPath _scan_path; }; template inline bool HeatSource::is_source_on() const { return _source_on; } template inline ScanPath &HeatSource::get_scan_path() { return _scan_path; } template inline void HeatSource::set_beam_properties( boost::property_tree::ptree const &database) { _beam.set_from_database(database); } } // namespace adamantine #endif