1 #pragma once
2 
3 /// \file Materials.h
4 /// \brief SPH-specific implementation of particle materials
5 /// \author Pavel Sevecek (sevecek at sirrah.troja.mff.cuni.cz)
6 /// \date 2016-2021
7 
8 #include "quantities/IMaterial.h"
9 
10 NAMESPACE_SPH_BEGIN
11 
12 class IEos;
13 class IRheology;
14 
15 /// \brief Material holding equation of state
16 ///
17 /// Pressure and sound speed are computed in \ref initialize function, so the EoS does not have to be
18 /// evaluated manually. If this is necessary for some reason (when setting pressure-dependent initial
19 /// conditions or checking if we selected correct EoS, for example), functions \ref evaluate and \ref getEos
20 /// can be used. This is not part of the IMaterial interface, so dynamic_cast have to be used to access it.
21 class EosMaterial : public IMaterial {
22 private:
23     AutoPtr<IEos> eos;
24 
25 public:
26     /// \brief Creates the material by specifying an equation of state.
27     ///
28     /// Equation of state must not be nullptr.
29     EosMaterial(const BodySettings& body, AutoPtr<IEos>&& eos);
30 
31     /// \brief Creates the material.
32     ///
33     /// Equation of state is constructed from parameters in settings.
34     explicit EosMaterial(const BodySettings& body);
35 
36     /// Returns the equation of state.
37     const IEos& getEos() const;
38 
39     virtual void create(Storage& storage, const MaterialInitialContext& context) override;
40 
41     virtual void initialize(IScheduler& scheduler, Storage& storage, const IndexSequence sequence) override;
42 
finalize(IScheduler & UNUSED (scheduler),Storage & UNUSED (storage),const IndexSequence UNUSED (sequence))43     virtual void finalize(IScheduler& UNUSED(scheduler),
44         Storage& UNUSED(storage),
45         const IndexSequence UNUSED(sequence)) override {
46         // nothing
47     }
48 };
49 
50 /// \brief Generalization of material with equation of state.
51 ///
52 /// It holds a rheology implementation that modifies pressure and stress tensor. This is done in \ref
53 /// initialize function, function \ref finalize then integrates the fragmentation model (if used, of course).
54 class SolidMaterial : public EosMaterial {
55 private:
56     AutoPtr<IRheology> rheology;
57 
58 public:
59     SolidMaterial(const BodySettings& body, AutoPtr<IEos>&& eos, AutoPtr<IRheology>&& rheology);
60 
61     explicit SolidMaterial(const BodySettings& body);
62 
63     virtual void create(Storage& storage, const MaterialInitialContext& context) override;
64 
65     virtual void initialize(IScheduler& scheduler, Storage& storage, const IndexSequence sequence) override;
66 
67     virtual void finalize(IScheduler& scheduler, Storage& storage, const IndexSequence sequence) override;
68 };
69 
70 /// \brief Basic materials available in the code.
71 ///
72 /// Parameters were taken from Reinhardt and Stadel (2016).
73 enum class MaterialEnum {
74     BASALT,
75     IRON,
76     ICE,
77     OLIVINE,
78 };
79 
80 AutoPtr<IMaterial> getMaterial(const MaterialEnum type);
81 
82 NAMESPACE_SPH_END
83