PRISMS-PF Manual v3.0-pre
Loading...
Searching...
No Matches
nucleationParameters.h
1#ifndef INCLUDE_NUCLEATIONPARAMETERS_H_
2#define INCLUDE_NUCLEATIONPARAMETERS_H_
3
4#include <deal.II/base/tensor.h>
5
6#include <utility>
7#include <vector>
8
9template <int dim>
11{
12public:
13 unsigned int var_index;
14 std::vector<double> semiaxes;
15 std::vector<double> ellipsoid_rotation;
16 std::vector<double> freeze_semiaxes;
17 double no_nucleation_border_thickness;
18 double hold_time;
19 dealii::Tensor<2, dim, double> rotation_matrix;
20
21 nucleationParameters(unsigned int _var_index,
22 std::vector<double> _semiaxes,
23 std::vector<double> _freeze_semiaxes,
24 std::vector<double> _ellipsoid_rotation,
25 double _hold_time,
26 double _no_nucleation_border_thickness)
27 : var_index(_var_index)
28 , semiaxes(std::move(_semiaxes))
29 , ellipsoid_rotation(std::move(_ellipsoid_rotation))
30 , freeze_semiaxes(std::move(_freeze_semiaxes))
31 , no_nucleation_border_thickness(_no_nucleation_border_thickness)
32 , hold_time(_hold_time)
33 {
34 set_rotation_matrix();
35 };
36
37 void
38 set_rotation_matrix()
39 {
40 // Rotation conventions:
41 // Rx refers to rotations about the x axis, Ry refers to rotations about the
42 // y axis, and Rz refers to rotations about the z axis. A positive rotation
43 // angle about the z axis corresponds to a clockwise rotation of the
44 // particle in a 2D calculation.
45
46 double degrees_to_rad = std::acos(0.0) / 90.0;
47
48 dealii::Tensor<2, dim, double> Rx;
49 dealii::Tensor<2, dim, double> Ry;
50 dealii::Tensor<2, dim, double> Rz;
51
52 Rx[0][0] = 1.0;
53 Rx[1][1] = std::cos(ellipsoid_rotation.at(0) * degrees_to_rad);
54
55 Ry[0][0] = std::cos(ellipsoid_rotation.at(1) * degrees_to_rad);
56 Ry[1][1] = 1.0;
57
58 Rz[0][0] = std::cos(ellipsoid_rotation.at(2) * degrees_to_rad);
59 Rz[1][0] = std::sin(ellipsoid_rotation.at(2) * degrees_to_rad);
60 Rz[0][1] = -std::sin(ellipsoid_rotation.at(2) * degrees_to_rad);
61 Rz[1][1] = std::cos(ellipsoid_rotation.at(2) * degrees_to_rad);
62
63 if (dim == 3)
64 {
65 Rx[1][2] = -std::sin(ellipsoid_rotation.at(0) * degrees_to_rad);
66 Rx[2][1] = std::sin(ellipsoid_rotation.at(0) * degrees_to_rad);
67 Rx[2][2] = std::cos(ellipsoid_rotation.at(0) * degrees_to_rad);
68
69 Ry[0][2] = std::sin(ellipsoid_rotation.at(1) * degrees_to_rad);
70 Ry[2][0] = -std::sin(ellipsoid_rotation.at(1) * degrees_to_rad);
71 Ry[2][2] = std::cos(ellipsoid_rotation.at(1) * degrees_to_rad);
72
73 Rz[2][2] = 1.0;
74 }
75
76 rotation_matrix = Rx * Ry * Rz; // Note: these are tensor multiplications
77 };
78};
79
80#endif
Definition nucleationParameters.h:11