rod_blob_interface.h
Go to the documentation of this file.
1 //
2 // This file is part of the FFEA simulation package
3 //
4 // Copyright (c) by the Theory and Development FFEA teams,
5 // as they appear in the README.md file.
6 //
7 // FFEA is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU General Public License as published by
9 // the Free Software Foundation, either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // FFEA is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with FFEA. If not, see <http://www.gnu.org/licenses/>.
19 //
20 // To help us fund FFEA development, we humbly ask that you cite
21 // the research papers on the package.
22 //
23 
24 /*
25  * rod_blob_interface.cpp
26  * Author: Rob Welch, University of Leeds
27  * Email: py12rw@leeds.ac.uk
28  */
29 
30 #ifndef ROD_BLOB_INTERFACE
31 #define ROD_BLOB_INTERFACE
32 
33 #include "rod_structure.h"
34 
35 // this bit
36 //#include "SimulationParams.h"
37 #include "tetra_element_linear.h"
38 #include "Face.h"
39 #include "Blob.h"
40 
41 namespace rod {
42 
43 // functions go here
44 
45 void get_tri_norm(float node0[3], float node1[3], float node2[3], OUT float tri_norm[3]);
46 void get_jacobian(mesh_node **tet_nodes, OUT float J[9]);
47 void float_3x3_invert(float m[9], OUT float m_inv[9]);
48 void get_gradient_deformation(float J_inv_0[0], mesh_node**nodes_curr, OUT float gradient_deformation_3x3[9]);
49 void QR_decompose_gram_schmidt(float matrix_3x3[9], OUT float Q[9], float R[9]);
50 void construct_euler_rotation_matrix(float a, float b, float g, float rotmat[9]);
51 void rotate_tet(float rotmat[9], mesh_node **nodes, OUT mesh_node **rotated_nodes);
52 void get_euler_angles(float rm[9], OUT float euler_angles[3]);
53 void get_rotation_matrix_from_euler(float euler_angles[3], OUT float rm[9]);
54 bool array_equal(float arr1[3], float arr2[3]);
55 bool array_contains(float large_arr[4][3], float small_arr[3][3]);
56 void mesh_node_null_check(mesh_node* node, std::string location);
57 void rescale_attachment_node(float attachment_node[3], float end_node[3], float attachment_node_equil[3], float end_node_equil[3], OUT float scaled_attachment_node[3], float scaled_attachment_node_equil[3]);
58 void matrix_invert_3x3(float m[9], OUT float inverted_matrix[9]);
59 void equil_attachment_node_from_J(float J_inv_0[9], int face_node_indices[3], bool ends_at_rod, float node_weighting[3], float tet_origin[3], float edge_vecs[3][3], float rotation[3], OUT float equil_attachment_node[3]);
60 bool points_out_of_tet(float node1[3], float node2[3], float node3[3], float node4[3], float attachment_element[3], float attachment_node[3]);
61 void get_attachment_node_pos(float face_node_1[3], float face_node_2[3], float face_node_3[3], float edge_vecs[3][3], float node_weighting[3], float tet_origin[3], OUT float face_node_pos[3]);
62 
63 // objects go here
64 
66 {
67  // member variables
72  bool ends_at_rod = true; // if this is false, it goes rod->blob, otherwise it goes blob->rod
73  int to_index;
76  int order;
77  int face_nodes[3];
78  float node_weighting[3] = {0.333333333333333, 0.333333333333333, 0.333333333333333};
79  float euler_angles[3] = {0, 0, 0};
80  float tet_origin[3];
81  //float tet_origin_equil[3];
82  float edge_vecs[3][3];
83  //float edge_vecs_equil[3][3];
84  mesh_node* deformed_tet_nodes[4]; // used for calculating the jacobian
86  float J_inv_0[9]; // equilibrium jacobian of the attachment node
87 
89  //float attachment_node_pos_equil[3]; // note: remove attachment_node_pos_equil, it is useless
91 
92  float attachment_node[3];
94  float attachment_m[3];
95 
96  //methods
97  Rod_blob_interface (Rod* set_connected_rod, Blob* set_connected_blob, bool set_ends_at_rod, int set_to_index, int set_from_index, int face_nodes[3], float rotation[3], float node_weighting[3], int order);
98  void set_initial_values();
99  void update_internal_state(bool update_edge_vecs, bool update_tet);
100  void update_J_0();
101  void set_edge_vecs();
102  void get_attachment_node(OUT float attachment_node[3], float attachment_node_pos[3], bool equil);
103  void get_attachment_node_pos(float attachment_node_pos[3], bool equil);
104  void get_initial_material_axis(); // parallel transport nearest mataxis
105  void get_attachment_material_axis(float attachment_node[3], OUT float attachment_material_axis[3]);
106  void get_tet_rotation_matrix(float tet_points_before[12], float tet_points_after[12]); // calls to get_gradient_deformation and qr_decompose
107 
108  void make_tet(); // turn nodes into tet elements
109  void set_tet(tetra_element_linear *tet);
110  void reorientate_connection(float attachment_element_orig[3], float attachment_material_axis_orig[3], OUT float new_attachment_element[3], float new_attachment_material_axis[3]);
111  void position_rod_from_blob(bool use_equil);
112  void position_blob_from_rod();
113  void get_face(OUT float face_node_1[3], float face_node_2[3], float face_node_3[3]);
114  void select_face_nodes(OUT int face_node_indices[3]);
115  int get_element_id(int nodes[3]);
116  void get_node_energy(int node_index, float attachment_node_equil[3], float attachment_material_axis_equil[3], float attachment_node[3], float attachment_material_axis[3], float displacement, float energy[6]);
117  //void get_rod_energy(float attachment_node_equil[3], float attachment_material_axis_equil[3], float displacement, float energy[2][6]);
118  void position_rod_ends(float attachment_node_pos[3]);
119  void do_connection_timestep();
120 
121 
122  // note: maybe a wrapper function for doubles that converts them to floats? see if it works
123 
124  // note: use vector12 class for internal nodes or something similar
125 
126 };
127 
128 bool point_inside_tetrahedron(float point[3], float tet[12]); // work out what direction the attachment node should face (it should point inside the tet, i think?)
129 
130 } //end namespace
131 
132 
133 #endif
void position_rod_from_blob(bool use_equil)
Definition: rod_blob_interface.cpp:1090
float J_inv_0[9]
Definition: rod_blob_interface.h:86
void get_attachment_node_pos(float attachment_node_pos[3], bool equil)
Definition: rod_blob_interface.cpp:973
Definition: tetra_element_linear.h:136
float node_weighting[3]
Definition: rod_blob_interface.h:78
Definition: Blob.h:94
void get_attachment_node(OUT float attachment_node[3], float attachment_node_pos[3], bool equil)
Definition: rod_blob_interface.cpp:756
void select_face_nodes(OUT int face_node_indices[3])
Definition: rod_blob_interface.cpp:1248
bool points_out_of_tet(float node1[3], float node2[3], float node3[3], float node4[3], float attachment_element[3], float attachment_node[3])
Definition: rod_blob_interface.cpp:562
bool array_equal(float arr1[3], float arr2[3])
Definition: rod_blob_interface.cpp:390
void matrix_invert_3x3(float m[9], OUT float inverted_matrix[9])
Definition: rod_blob_interface.cpp:471
Definition: rod_structure.h:46
void mesh_node_null_check(mesh_node *node, std::string location)
Definition: rod_blob_interface.cpp:425
void update_internal_state(bool update_edge_vecs, bool update_tet)
Definition: rod_blob_interface.cpp:710
void get_node_energy(int node_index, float attachment_node_equil[3], float attachment_material_axis_equil[3], float attachment_node[3], float attachment_material_axis[3], float displacement, float energy[6])
Definition: rod_blob_interface.cpp:1334
mesh_node * deformed_tet_nodes[4]
Definition: rod_blob_interface.h:84
Definition: rod_blob_interface.h:65
float attachment_node_pos[3]
Definition: rod_blob_interface.h:93
bool point_inside_tetrahedron(float point[3], float tet[12])
void rescale_attachment_node(float attachment_node[3], float end_node[3], float attachment_node_equil[3], float end_node_equil[3], OUT float scaled_attachment_node[3], float scaled_attachment_node_equil[3])
Definition: rod_blob_interface.cpp:447
int face_node_indices[3]
Definition: rod_blob_interface.h:85
float attachment_node_equil[3]
Definition: rod_blob_interface.h:88
bool ends_at_rod
Definition: rod_blob_interface.h:72
bool array_contains(float large_arr[4][3], float small_arr[3][3])
Definition: rod_blob_interface.cpp:406
void reorientate_connection(float attachment_element_orig[3], float attachment_material_axis_orig[3], OUT float new_attachment_element[3], float new_attachment_material_axis[3])
Definition: rod_blob_interface.cpp:1069
void set_tet(tetra_element_linear *tet)
Definition: rod_blob_interface.cpp:1047
void do_connection_timestep()
Definition: rod_blob_interface.cpp:1591
int get_element_id(int nodes[3])
Definition: rod_blob_interface.cpp:1284
void rotate_tet(float rotmat[9], mesh_node **nodes, OUT mesh_node **rotated_nodes)
Definition: rod_blob_interface.cpp:286
void get_attachment_material_axis(float attachment_node[3], OUT float attachment_material_axis[3])
Definition: rod_blob_interface.cpp:1016
void get_face(OUT float face_node_1[3], float face_node_2[3], float face_node_3[3])
int face_nodes[3]
Definition: rod_blob_interface.h:77
float edge_vecs[3][3]
Definition: rod_blob_interface.h:82
Definition: rod_blob_interface.cpp:38
int to_index
Definition: rod_blob_interface.h:73
Rod * connected_rod
Definition: rod_blob_interface.h:68
void get_tri_norm(float node0[3], float node1[3], float node2[3], OUT float tri_norm[3])
Definition: rod_blob_interface.cpp:45
void get_jacobian(mesh_node **tet_nodes, OUT float J[0])
Definition: rod_blob_interface.cpp:60
void set_initial_values()
Definition: rod_blob_interface.cpp:675
int face_index
Definition: rod_blob_interface.h:75
Face * connected_face
Definition: rod_blob_interface.h:70
void get_rotation_matrix_from_euler(float euler_angles[3], OUT float rm[9])
Definition: rod_blob_interface.cpp:368
void position_blob_from_rod()
Definition: rod_blob_interface.cpp:1193
Blob * connected_blob
Definition: rod_blob_interface.h:69
float tet_origin[3]
Definition: rod_blob_interface.h:80
void update_J_0()
Definition: rod_blob_interface.cpp:723
Definition: mesh_node.h:39
void float_3x3_invert(float m[9], OUT float m_inv[9])
Definition: rod_blob_interface.cpp:91
void construct_euler_rotation_matrix(float a, float b, float g, float rotmat[9])
Definition: rod_blob_interface.cpp:265
float attachment_node[3]
Definition: rod_blob_interface.h:92
void get_gradient_deformation(float J_inv_0[0], mesh_node **nodes_curr, OUT float transposed_gradient_deformation_3x3[9])
Definition: rod_blob_interface.cpp:178
void get_attachment_node_pos(float face_node_1[3], float face_node_2[3], float face_node_3[3], float edge_vecs[3][3], float node_weighting[3], float tet_origin[3], OUT float attachment_node_pos[3])
Definition: rod_blob_interface.cpp:582
float euler_angles[3]
Definition: rod_blob_interface.h:79
int order
Definition: rod_blob_interface.h:76
Rod_blob_interface(Rod *set_connected_rod, Blob *set_connected_blob, bool set_ends_at_rod, int set_to_index, int set_from_index, int face_nodes[3], float rotation[3], float node_weighting[3], int order)
Definition: rod_blob_interface.cpp:609
void get_euler_angles(float rm[9], OUT float euler_angles[3])
Definition: rod_blob_interface.cpp:332
void QR_decompose_gram_schmidt(float matrix_3x3[9], OUT float Q[9], float R[9])
Definition: rod_blob_interface.cpp:224
void equil_attachment_node_from_J(float J_inv_0[9], int face_node_indices[3], bool ends_at_rod, float node_weighting[3], float tet_origin[3], float edge_vecs[3][3], float rotation[3], OUT float equil_attachment_node[3])
Definition: rod_blob_interface.cpp:501
void set_edge_vecs()
Definition: rod_blob_interface.cpp:736
void position_rod_ends(float attachment_node_pos[3])
Definition: rod_blob_interface.cpp:1555
float attachment_m_equil[3]
Definition: rod_blob_interface.h:90
void get_tet_rotation_matrix(float tet_points_before[12], float tet_points_after[12])
tetra_element_linear * connected_tet
Definition: rod_blob_interface.h:71
#define OUT
This is used to denote when a function modifies one of its parameters.
Definition: rod_math_v9.h:32
float attachment_m[3]
Definition: rod_blob_interface.h:94
Definition: Face.h:38
int from_index
Definition: rod_blob_interface.h:74