43 Float omega = 2._f *
PI / (60._f * 60._f * 2._f);
94 const Float incidentFlux = (1._f - A) * Phi *
max(
cos(omega * t), 0._f);
96 T[0] = T[1] + dz * (incidentFlux - emissionFlux) / K;
97 }
else if (i == n - 1) {
106 dT[i] = K / (rho * C) * (T[i + 1] + T[i - 1] - 2._f * T[i]) /
sqr(dz);
126 , file(
Path(
"temperature.txt")) {}
130 stdout.
write(
"Progress: ",
int(progress * 100._f),
"%");
134 file.
write(time,
" ", T[0]);
149 material->temperature = 250._f;
150 material->conductivity = 1._f;
151 material->density = 2500._f;
152 material->heatCapacity = 680._f;
153 material->albedo = 0.1_f;
156 *storage =
Storage(std::move(material));
159 solver = makeAuto<HdeSolver>();
169 triggers.pushBack(makeAuto<ProgressLogger>());
172 logWriter = makeAuto<NullLogWriter>();
182 simulation.
run(storage);
184 std::cout <<
"Error during simulation: " << e.
what() << std::endl;
const EmptyFlags EMPTY_FLAGS
uint32_t Size
Integral type used to index arrays (by default).
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
constexpr INLINE T max(const T &f1, const T &f2)
constexpr INLINE T sqr(const T &f) noexcept
Return a squared value.
constexpr INLINE Float pow< 4 >(const Float v)
constexpr Float PI
Mathematical constants.
@ TEMPERATURE
Temperature, always a scalar quantity.
@ FIRST
Quantity with 1st derivative.
@ RUN_TIME
Current time of the simulation in code units. Does not necessarily have to be 0 when run starts.
void fill(const T &t)
Sets all elements of the array to given value.
Wrapper of pointer that deletes the resource from destructor.
virtual const char * what() const noexcept
virtual void create(Storage &storage, IMaterial &material) const override
Initializes all quantities needed by the solver in the storage.
virtual void integrate(Storage &storage, Statistics &stats) override
Computes derivatives of all time-dependent quantities.
virtual void setUp(SharedPtr< Storage > storage) override
Prepares the run, creates logger, output, ...
virtual void tearDown(const Storage &UNUSED(storage), const Statistics &UNUSED(stats)) override
void write(TArgs &&... args)
Creates and logs a message by concatenating arguments.
Material settings and functions specific for one material.
Defines the interface for a run.
Statistics run(Storage &storage)
Runs the simulation.
Base class for all solvers.
Non-owning wrapper of a material and particles with this material.
INLINE IMaterial & material()
Returns the reference to the material of the particles.
INLINE IndexSequence sequence()
Returns iterable index sequence.
Material that does not require any initialization or finalization.
Object representing a path on a filesystem.
Trigger executing given action every period.
virtual AutoPtr< ITrigger > action(Storage &storage, Statistics &stats) override
Action executed when the condition is fulfilled.
Object holding various statistics about current run.
TValue get(const StatisticsId idx) const
Returns value of a statistic.
Container storing all quantities used within the simulations.
Size getMaterialCnt() const
Return the number of materials in the storage.
Quantity & insert(const QuantityId key, const OrderEnum order, const TValue &defaultValue)
Creates a quantity in the storage, given its key, value type and order.
Array< TValue > & getDt(const QuantityId key)
Retrieves a quantity derivative from the storage, given its key and value type.
MaterialView getMaterial(const Size matIdx) const
Returns an object containing a reference to given material.
Array< TValue > & getValue(const QuantityId key)
Retrieves a quantity values from the storage, given its key and value type.
@ EULER_EXPLICIT
Explicit (forward) 1st-order integration.
@ TIMESTEPPING_INITIAL_TIMESTEP
@ RUN_OUTPUT_TYPE
Selected format of the output file, see IoEnum.
@ TIMESTEPPING_INTEGRATOR
Selected timestepping integrator.
@ RUN_NAME
User-specified name of the run, used in some output files.
constexpr Float stefanBoltzmann
Stefan-Boltzmann constant.