SEVN
Loading...
Searching...
No Matches
pairinstability.h
Go to the documentation of this file.
1/*
2 Created by iorio on 7/25/22.
3Module for Pair instability models, it includes:
4- Struct PISNreturn: a simple struct containing a double and a Lookup::SNExplosionType (enum) to handle some function returns
5- Class PairInstability: Base class for PairInstability models
6- Class PIDisabled: Simple PairInstability model, just disable the pair instability correction
7*/
8
9#ifndef SEVN_PAIRINSTABILITY_H
10#define SEVN_PAIRINSTABILITY_H
11
108#include <map>
109#include <utilities.h>
110#include <vector>
111#include <sevnlog.h>
112#include <lookup_and_phases.h>
113
114class Star;
116
121 const double Mremnant_after_pisn; //Mass of the remnant after the correction
122 const Lookup::SNExplosionType SNType; //Type of SNexplosion considering pairinstability
123};
124
125
130/***** For Developers that want to add new PairInstability models: ******/
134public:
136 virtual inline std::string name() const {return "PairInstability";}
137
142 virtual PairInstability *instance() = 0; //Pure virtual
143
148public:
163
164
179 virtual PISNreturn apply_afterSN(_UNUSED Star* s, _UNUSED double mremnant) const;
180
181
182
183 /*********************************************************************************************************/
184 /***** STOP: DO NOT CHANGE THE REST OF THE CODE IF YOU ARE NOT FULLY AWARE OF WHAT YOU ARE DOING ******/
185 /*********************************************************************************************************/
186
187public:
188
189 //Constructor - Destructor
190 explicit PairInstability(_UNUSED bool reg=true){};
191 virtual ~PairInstability() = default;
192
193 //Create instance
199 static PairInstability *Instance(std::string const &name);
200
201 //Remove cp and mv, we don't need to copy or mv, therefore to avoid unexpected behaviour we just delete them
202 PairInstability (const PairInstability&) = delete; //copy constructor
203 PairInstability& operator= (const PairInstability&) = delete; //copy assignment
204 PairInstability (PairInstability&& other) = delete; //mv constructor
205 PairInstability& operator= (PairInstability&& other) = delete; //mv assignement
206
207
208protected:
212 static void Register(PairInstability *ptr);
214
215private:
216
218 //TODO We are using this Register-StaticMap formalism a lot, maybe we have to create a base template class containing
219 //all these methods (GetStaticMap,Register,GetUsed) to have only one definition of these functions
220 static std::map<std::string, PairInstability *> &GetStaticMap() {
221 //First time call the function create the map, since c++11 this is thread safe
222 static std::map<std::string, PairInstability *> _locmap;
223 return _locmap;
224 }
226 static std::vector<int> &GetUsed() {
227 static std::vector<int> _used;
228 return _used;
229 }
230};
231
237public:
238 //Ctor
239 explicit PIDisabled(bool reg=true);
240
241 //Static instance
243
244 //name
245 inline std::string name() const override { return "disabled";}
246
247 //return an heap allocated instance
248 PIDisabled* instance() override {
249 return (new PIDisabled(false));
250 }
251
252};
253
254
255
256
257#endif //SEVN_PAIRINSTABILITY_H
#define _UNUSED
Definition: BinaryProperty.h:20
Definition: pairinstability.h:236
static PIDisabled _pidisabled
Definition: pairinstability.h:242
std::string name() const override
Definition: pairinstability.h:245
PIDisabled * instance() override
Definition: pairinstability.h:248
Definition: pairinstability.h:129
PairInstability(PairInstability &&other)=delete
PairInstability(const PairInstability &)=delete
virtual PISNreturn apply_afterSN(_UNUSED Star *s, _UNUSED double mremnant) const
Definition: pairinstability.cpp:46
virtual ~PairInstability()=default
static PairInstability * Instance(std::string const &name)
Base class.
Definition: pairinstability.cpp:9
static std::vector< int > & GetUsed()
TODO we are never using this method, we should remove it.
Definition: pairinstability.h:226
PairInstability & operator=(const PairInstability &)=delete
PairInstability(_UNUSED bool reg=true)
Definition: pairinstability.h:190
virtual std::string name() const
Definition: pairinstability.h:136
virtual utilities::MassContainer apply_beforeSN(_UNUSED Star *s) const
Definition: pairinstability.cpp:41
static void Register(PairInstability *ptr)
Definition: pairinstability.cpp:29
SevnLogging svlog
Definition: pairinstability.h:213
static std::map< std::string, PairInstability * > & GetStaticMap()
Option handling.
Definition: pairinstability.h:220
virtual PairInstability * instance()=0
Definition: star.h:39
Definition: sevnlog.h:43
SNExplosionType
Definition: lookup_and_phases.h:54
Definition: pairinstability.h:120
const Lookup::SNExplosionType SNType
Definition: pairinstability.h:122
const double Mremnant_after_pisn
Definition: pairinstability.h:121
Definition: utilities.h:163