-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresidual_calculator.h
82 lines (62 loc) · 2.09 KB
/
residual_calculator.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
#ifndef OOMPH_RESIDUAL_CALCULATOR_H
#define OOMPH_RESIDUAL_CALCULATOR_H
/*
A class holding a single function which calculates the residual.
This allows us to dynamically choose which residual function to use :)
*/
#include "../../src/generic/elements.h"
#include "../../src/generic/matrices.h"
#include "../../src/generic/Vector.h"
using namespace oomph;
namespace oomph
{
// for micromag ones:
class MicromagEquations;
class ResidualCalculator
{
public:
virtual ~ResidualCalculator(){};
/// The residual function
virtual void fill_in_generic_residual_contribution
(const MicromagEquations* const ele_pt,
Vector<double> &residuals, DenseMatrix<double> &jacobian,
const unsigned& flag) const = 0;
};
class LLGResidualCalculator : public ResidualCalculator
{
public:
LLGResidualCalculator(bool _use_gilbert_form)
{
Use_gilbert_form = _use_gilbert_form;
}
/// The residual function. Pick which form to use based on the flag.
void fill_in_generic_residual_contribution
(const MicromagEquations* const ele_pt,
Vector<double> &residuals, DenseMatrix<double> &jacobian,
const unsigned& flag) const
{
if(use_gilbert_form())
{
llg_residual(ele_pt, residuals, jacobian, flag);
}
else
{
ll_residual(ele_pt, residuals, jacobian, flag);
}
}
bool use_gilbert_form() const {return Use_gilbert_form;}
void set_use_gilbert_form() {Use_gilbert_form = true;}
void set_use_ll_form() {Use_gilbert_form = false;}
private:
/// Calculate residual using gilbert form
void llg_residual(const MicromagEquations* const e_pt,
Vector<double> &residuals, DenseMatrix<double> &jacobian,
const unsigned& flag) const;
/// Calculate residual using ll form
void ll_residual(const MicromagEquations* const e_pt,
Vector<double> &residuals, DenseMatrix<double> &jacobian,
const unsigned& flag) const;
bool Use_gilbert_form;
};
} // End of oomph namespace
#endif