-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrenormalisation_handler.h
97 lines (76 loc) · 1.96 KB
/
renormalisation_handler.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
#ifndef OOMPH_RENORMALISATION_HANDLERS_H
#define OOMPH_RENORMALISATION_HANDLERS_H
#include "../../src/generic/oomph_utilities.h"
namespace oomph
{
class LLGProblem;
/// Pure virtual base
class RenormalisationHandler
{
public:
virtual void renormalise(LLGProblem* problem_pt) = 0;
};
class AlwaysRenormalise : public RenormalisationHandler
{
public:
void renormalise(LLGProblem* problem_pt);
};
class NeverRenormalise : public RenormalisationHandler
{
public:
void renormalise(LLGProblem* problem_pt)
{
// no-op
}
};
class RenormaliseAfterTolerance : public RenormalisationHandler
{
public:
RenormaliseAfterTolerance()
{
// ??ds hard code it for now
handler_pt = new AlwaysRenormalise();
tol = 1e-2; // This is the default value from magpar (see
// magpar-0.9/src/llg/checkiterationllg.c line 179).
}
RenormalisationHandler* handler_pt;
double tol;
void renormalise(LLGProblem* problem_pt);
};
class RenomaliseOntoSphere : public RenormalisationHandler
{
public:
void renormalise(LLGProblem* problem_pt)
{
throw OomphLibError("Not implemented (yet?).", OOMPH_CURRENT_FUNCTION,
OOMPH_EXCEPTION_LOCATION);
}
};
inline RenormalisationHandler*
renormalisation_handler_factory(std::string name)
{
if(name == "always")
{
return new AlwaysRenormalise();
}
else if(name == "never")
{
return new NeverRenormalise();
}
else if(name == "after-tol")
{
return new RenormaliseAfterTolerance();
}
else if(name == "onto-sphere")
{
return new RenomaliseOntoSphere();
}
else
{
std::string err = "Unrecognised renormaliation setting \"" + name +"\".";
throw OomphLibError(err, OOMPH_CURRENT_FUNCTION,
OOMPH_EXCEPTION_LOCATION);
}
}
} // End of oomph namespace
#endif