SEVN
Loading...
Searching...
No Matches
neutrinomassloss.h
Go to the documentation of this file.
1/*
2 Created by iorio on 7/25/22.
3Module for Neutrino mass loss models, it includes:
4- Class NeutrinoMassLoss: Base class for NeutrinoMassLoss models
5- Class NMLDisabled: Simple NeutrinoMassLoss model, just disable the neutrino mass loss correction
6*/
7
8#ifndef SEVN_NEUTRINOMASSLOSS_H
9#define SEVN_NEUTRINOMASSLOSS_H
10
68#include <sevnlog.h>
69#include <map>
70#include <vector>
71#define _UNUSED __attribute__ ((unused))
72
73class Star;
74
76
81/***** For Developers that want to add new NeutrinoMassLoss models: ******/
85public:
87 virtual inline std::string name() const {return "NeutrinoMassLoss";}
88
93 virtual NeutrinoMassLoss *instance() = 0; //Pure virtual
94
101 virtual double apply(_UNUSED const double mremnant, _UNUSED Star *s) const = 0; //Pure virtual
102
103
104 /*********************************************************************************************************/
105 /***** STOP: DO NOT CHANGE THE REST OF THE CODE IF YOU ARE NOT FULLY AWARE OF WHAT YOU ARE DOING ******/
106 /*********************************************************************************************************/
107
108public:
109 //Constructor - Destructor
110 explicit NeutrinoMassLoss(_UNUSED bool reg=true){};
111 virtual ~NeutrinoMassLoss() = default;
112
113 //Create instance
119 static NeutrinoMassLoss *Instance(std::string const &name);
120
121 //Remove cp and mv, we don't need to copy or mv, therefore to avoid unexpected behaviour we just delete them
122 NeutrinoMassLoss (const NeutrinoMassLoss&) = delete; //copy constructor
123 NeutrinoMassLoss& operator= (const NeutrinoMassLoss&) = delete; //copy assignment
124 NeutrinoMassLoss (NeutrinoMassLoss&& other) = delete; //mv constructor
125 NeutrinoMassLoss& operator= (NeutrinoMassLoss&& other) = delete; //mv assignement
126
127protected:
131 static void Register(NeutrinoMassLoss *ptr);
133
134private:
135
137 //TODO We are using this Register-StaticMap formalism a lot, maybe we have to create a base template class containing
138 //all these methods (GetStaticMap,Register,GetUsed) to have only one definition of these functions
139 static std::map<std::string, NeutrinoMassLoss *> &GetStaticMap() {
140 //First time call the function create the map, since c++11 this is thread safe
141 static std::map<std::string, NeutrinoMassLoss *> _locmap;
142 return _locmap;
143 }
145 static std::vector<int> &GetUsed() {
146 static std::vector<int> _used;
147 return _used;
148 }
149};
150
157public:
158 //Ctor
159 NMLDisabled(bool reg=true);
160
161 //name
162 inline std::string name() const override { return "disabled";}
163
164 //Static instance
166
167 //return an heap allocated instance
168 NMLDisabled* instance() override {
169 return (new NMLDisabled(false));
170 }
171
178 double apply(const double mremnant, _UNUSED Star *s) const override {return mremnant;}
179};
180
181
182
183#endif //SEVN_NEUTRINOMASSLOSS_H
Definition: neutrinomassloss.h:156
NMLDisabled * instance() override
Definition: neutrinomassloss.h:168
double apply(const double mremnant, _UNUSED Star *s) const override
Definition: neutrinomassloss.h:178
std::string name() const override
Definition: neutrinomassloss.h:162
static NMLDisabled _nmldisabled
Definition: neutrinomassloss.h:165
Definition: neutrinomassloss.h:80
virtual std::string name() const
Definition: neutrinomassloss.h:87
virtual ~NeutrinoMassLoss()=default
SevnLogging svlog
Definition: neutrinomassloss.h:132
static std::vector< int > & GetUsed()
TODO we are never using this method, we should remove it.
Definition: neutrinomassloss.h:145
static void Register(NeutrinoMassLoss *ptr)
Definition: neutrinomassloss.cpp:7
NeutrinoMassLoss(NeutrinoMassLoss &&other)=delete
static NeutrinoMassLoss * Instance(std::string const &name)
Definition: neutrinomassloss.cpp:18
virtual NeutrinoMassLoss * instance()=0
NeutrinoMassLoss(_UNUSED bool reg=true)
Definition: neutrinomassloss.h:110
NeutrinoMassLoss & operator=(const NeutrinoMassLoss &)=delete
NeutrinoMassLoss(const NeutrinoMassLoss &)=delete
static std::map< std::string, NeutrinoMassLoss * > & GetStaticMap()
Option handling.
Definition: neutrinomassloss.h:139
virtual double apply(_UNUSED const double mremnant, _UNUSED Star *s) const =0
Definition: star.h:39
Definition: sevnlog.h:43
#define _UNUSED
Definition: neutrinomassloss.h:71