-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrenormalisation_handler.cc
41 lines (32 loc) · 1.19 KB
/
renormalisation_handler.cc
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
#include "renormalisation_handler.h"
#include "llg_problem.h"
#include "vector_helpers.h"
namespace oomph {
void AlwaysRenormalise::renormalise(LLGProblem* problem_pt)
{
oomph_info << "Renormalising nodal magnetisations." << std::endl;
// Loop over meshes and renormalise m at each node
for(unsigned nd=0; nd<problem_pt->mesh_pt()->nnode(); nd++)
{
Node* nd_pt = problem_pt->mesh_pt()->node_pt(nd);
// Get m vector
Vector<double> m_values(3,0.0);
for(unsigned j=0; j<3; j++) m_values[j] = nd_pt->value(problem_pt->m_index(j));
// Normalise
VectorOps::normalise(m_values);
// Write m vector
for(unsigned j=0; j<3; j++) nd_pt->set_value(problem_pt->m_index(j),
m_values[j]);
}
}
void RenormaliseAfterTolerance::renormalise(LLGProblem* problem_pt)
{
Vector<Vector<double> > ms = MManipulation::nodal_magnetisations(0, *problem_pt);
Vector<double> ml_errors = MManipulation::nodal_m_length_errors(ms);
double worst_error = VectorOps::max(ml_errors);
if(std::abs(worst_error) > tol)
{
handler_pt->renormalise(problem_pt);
}
}
}