28 #ifndef TETRA_ELEMENT_LINEAR_H_INCLUDED 29 #define TETRA_ELEMENT_LINEAR_H_INCLUDED 45 #define NUM_NODES_LINEAR_TET 4 46 #define NUM_NODES_QUADRATIC_TET 10 55 #define BULK_VISCOUS_SUBMATRIX_DIAG(V,I) \ 56 V[I + 0][I + 0] = dpsi[I + 0] * dpsi[I + 0] * (A + B); \ 57 V[I + 1][I + 1] = dpsi[I + 1] * dpsi[I + 1] * (A + B); \ 58 V[I + 2][I + 2] = dpsi[I + 2] * dpsi[I + 2] * (A + B); \ 59 V[I + 3][I + 3] = dpsi[I + 3] * dpsi[I + 3] * (A + B); \ 60 V[I + 0][I + 1] = dpsi[I + 1] * dpsi[I + 0] * (A + B); \ 61 V[I + 0][I + 2] = dpsi[I + 2] * dpsi[I + 0] * (A + B); \ 62 V[I + 0][I + 3] = dpsi[I + 3] * dpsi[I + 0] * (A + B); \ 63 V[I + 1][I + 2] = dpsi[I + 1] * dpsi[I + 2] * (A + B); \ 64 V[I + 1][I + 3] = dpsi[I + 1] * dpsi[I + 3] * (A + B); \ 65 V[I + 2][I + 3] = dpsi[I + 2] * dpsi[I + 3] * (A + B); 77 #define BULK_VISCOUS_SUBMATRIX_OFFDIAG(V, I, J) \ 78 K[0][0] = dpsi[I] * dpsi[J]; \ 79 K[0][1] = dpsi[J + 1] * dpsi[I]; \ 80 K[0][2] = dpsi[J + 2] * dpsi[I]; \ 81 K[0][3] = dpsi[J + 3] * dpsi[I]; \ 83 K[1][0] = dpsi[I + 1] * dpsi[J]; \ 84 K[1][1] = dpsi[I + 1] * dpsi[J + 1]; \ 85 K[1][2] = dpsi[I + 1] * dpsi[J + 2]; \ 86 K[1][3] = dpsi[I + 1] * dpsi[J + 3]; \ 88 K[2][0] = dpsi[I + 2] * dpsi[J]; \ 89 K[2][1] = dpsi[I + 2] * dpsi[J + 1]; \ 90 K[2][2] = dpsi[I + 2] * dpsi[J + 2]; \ 91 K[2][3] = dpsi[I + 2] * dpsi[J + 3]; \ 93 K[3][0] = dpsi[I + 3] * dpsi[J]; \ 94 K[3][1] = dpsi[I + 3] * dpsi[J + 1]; \ 95 K[3][2] = dpsi[I + 3] * dpsi[J + 2]; \ 96 K[3][3] = dpsi[I + 3] * dpsi[J + 3]; \ 98 V[I + 0][J + 0] = (B + A) * K[0][0]; \ 99 V[I + 0][J + 1] = B * K[0][1] + A * K[1][0]; \ 100 V[I + 0][J + 2] = B * K[0][2] + A * K[2][0]; \ 101 V[I + 0][J + 3] = B * K[0][3] + A * K[3][0]; \ 103 V[I + 1][J + 0] = B * K[1][0] + A * K[0][1]; \ 104 V[I + 1][J + 1] = (B + A) * K[1][1]; \ 105 V[I + 1][J + 2] = B * K[1][2] + A * K[2][1]; \ 106 V[I + 1][J + 3] = B * K[1][3] + A * K[3][1]; \ 108 V[I + 2][J + 0] = B * K[2][0] + A * K[0][2]; \ 109 V[I + 2][J + 1] = B * K[2][1] + A * K[1][2]; \ 110 V[I + 2][J + 2] = (B + A) * K[2][2]; \ 111 V[I + 2][J + 3] = B * K[2][3] + A * K[3][2]; \ 113 V[I + 3][J + 0] = B * K[3][0] + A * K[0][3]; \ 114 V[I + 3][J + 1] = B * K[3][1] + A * K[1][3]; \ 115 V[I + 3][J + 2] = B * K[3][2] + A * K[2][3]; \ 116 V[I + 3][J + 3] = (B + A) * K[3][3]; \ 118 #define RAND(A, B) ((A) + ((B)-(A))*(rng[thread_id].RandU01())) void add_element_force_vector(vector12 force)
Add this element's nodal forces to those given in the force 12-vector.
Definition: tetra_element_linear.cpp:474
void volume_coord_to_xyz(scalar eta0, scalar eta1, scalar eta2, scalar eta3, vector3 *r)
Definition: tetra_element_linear.cpp:555
int what_node_is_this(int index)
A roundabout and inefficient way of working out what node (from 0 to 9) this index corresponds to...
Definition: tetra_element_linear.cpp:499
scalar vol
The current volume of this element.
Definition: tetra_element_linear.h:171
Definition: tetra_element_linear.h:136
vector3 node_force[NUM_NODES_QUADRATIC_TET]
Store the contribution from this element to the force on each of its four nodes.
Definition: tetra_element_linear.h:165
scalar vol_0
The rest volume of this element.
Definition: tetra_element_linear.h:168
void add_bulk_elastic_stress_OLD(matrix3 stress)
scalar matrix3[3][3]
Definition: mat_vec_types.h:132
void calc_centroid()
Definition: tetra_element_linear.cpp:593
scalar * get_K_alpha_element_mem_loc(int ni, int nj)
Get the memory location of the specified element of K_alpha.
Definition: tetra_element_linear.cpp:56
Blob * daddy_blob
Definition: tetra_element_linear.h:186
void calculate_jacobian(matrix3 J)
Calculates the Jacobian matrix for this element.
Definition: tetra_element_linear.cpp:193
void get_element_velocity_vector(vector12 v)
Sets the given 12-vector to the velocities of this element's four nodes,.
Definition: tetra_element_linear.cpp:454
scalar W
Definition: tetra_element_linear.h:332
matrix12 viscosity_matrix
Viscosity Matrix for the internal forces of this element.
Definition: tetra_element_linear.h:183
void get_grad_phi_at_stu(vector3 &grad_phi, scalar s, scalar t, scalar u)
Returns the gradient of the potential at the given (s,t,u) position in the element.
Definition: tetra_element_linear.cpp:85
scalar calc_volume()
Uses above functions to get volume. Easy.
Definition: tetra_element_linear.cpp:343
PoissonMatrixQuadratic K_alpha
Definition: tetra_element_linear.h:162
void zero_force()
Definition: tetra_element_linear.cpp:561
scalar internal_stress_mag
The double contraction of the internal stress tensor, including elastic and thermal stresses...
Definition: tetra_element_linear.h:177
scalar vector12[12]
Definition: mat_vec_types.h:122
matrix3 F_ij
The gradient deformation tensor for this element (needed for potential energy calculation) ...
Definition: tetra_element_linear.h:174
Definition: MassMatrixLinear.h:33
scalar A
shear viscosity
Definition: tetra_element_linear.h:143
void calculate_K_alpha()
Calc the diffusion matrix for this element.
Definition: tetra_element_linear.cpp:61
scalar B
second coefficient of viscosity
Definition: tetra_element_linear.h:144
tetra_element_linear()
Definition: tetra_element_linear.cpp:30
scalar eta[4]
Definition: tetra_element_linear.h:333
void calc_elastic_force_vector(vector12 F)
Calculate the elastic contribution to the force.
Definition: tetra_element_linear.cpp:354
upper_triangular_matrix4 del2
The del2 matrix for this element (in upper triangular form, since it's symmetric). Used in constructing the diffusion matrix and the poisson matrix.
Definition: tetra_element_linear.h:160
void print()
Definition: tetra_element_linear.cpp:509
scalar length_of_longest_edge()
Definition: tetra_element_linear.cpp:692
void construct_element_mass_matrix(MassMatrixQuadratic *M_alpha)
Definition: tetra_element_linear.cpp:66
int index
Index of this element in the parent Blob.
Definition: tetra_element_linear.h:189
const scalar force
force = E/l
Definition: dimensions.h:37
void print_structural_details()
Prints a variety of structural details about the element to analyse it's configuration.
Definition: tetra_element_linear.cpp:333
int get_opposite_node(int n1, int n2, int n3)
Definition: tetra_element_linear.cpp:645
void add_shear_elastic_stress(matrix3 J, matrix3 stress)
Definition: tetra_element_linear.cpp:378
void add_fluctuating_stress(SimulationParams *params, RngStream rng[], matrix3 stress, int thread_id)
Given the shape function derivatives, the element volume and a random number generator, this function calculates the fluctuating stress tensor, generating a stochastic change in the nodal velocities for the element under consideration. This function will add its contribution to the given 12-vector du.
Definition: tetra_element_linear.cpp:417
scalar last_det
The last determinant of this element's transformation (used to work out whether it has inverted itsel...
Definition: tetra_element_linear.h:322
scalar matrix12[12][12]
Definition: mat_vec_types.h:127
matrix3 J_inv_0
The inverse jacobian of this element at rest.
Definition: tetra_element_linear.h:180
scalar mass
Definition: tetra_element_linear.h:148
Definition: mat_vec_types.h:142
void apply_stress_tensor(matrix3 stress, vector12 du)
Applies the given stress tensor to the shape function derivatives to get the contribution to du...
Definition: tetra_element_linear.cpp:441
Definition: RngStream.h:43
vector12 dpsi
The 12-vector containing the shape function derivatives for this element.
Definition: tetra_element_linear.h:154
scalar E
bulk modulus
Definition: tetra_element_linear.h:146
void calc_del2_matrix()
Creates del2 matrix from the shape function derivatives.
Definition: tetra_element_linear.cpp:599
int calc_shape_function_derivatives_and_volume(matrix3 J)
Inverts the given jacobian matrix J, using this to calculate the derivatives of the shape functions w...
Definition: tetra_element_linear.cpp:223
scalar rho
density
Definition: tetra_element_linear.h:142
mesh_node * n[NUM_NODES_QUADRATIC_TET]
A quadratic tetrahedron has 10 nodes. Keep pointers to the actual memory location of the nodes...
Definition: tetra_element_linear.h:151
void print_viscosity_matrix()
Definition: tetra_element_linear.cpp:520
Definition: mesh_node.h:39
Definition: MassMatrixQuadratic.h:35
Definition: SimulationParams.h:75
scalar dielectric
Definition: tetra_element_linear.h:147
void calculate_electrostatic_forces()
Calculates the force on each node of the element due to the electrostatic potential gradient there...
Definition: tetra_element_linear.cpp:109
scalar G
shear modulus
Definition: tetra_element_linear.h:145
void add_bulk_elastic_stress(matrix3 stress)
Definition: tetra_element_linear.cpp:401
void apply_element_mass_matrix(vector12 du)
Applies the mass matrix (for a linear tetrahedral element of density rho and equilibrium volume vol_0...
Definition: tetra_element_linear.cpp:534
Definition: tetra_element_linear.h:331
static const int i
index of ith thing
Definition: rod_math_v9.h:63
vector3 centroid
Definition: tetra_element_linear.h:191
#define NUM_NODES_QUADRATIC_TET
Definition: tetra_element_linear.h:46
void calc_deformation(matrix3 J)
Calculates Deformation Gradient.
Definition: tetra_element_linear.cpp:370
void create_viscosity_matrix()
Builds the viscosity matrix from the shape function derivatives, the shear and bulk viscosity constan...
Definition: tetra_element_linear.cpp:299
Definition: PoissonMatrixQuadratic.h:44
void linearise_element()
Definition: tetra_element_linear.cpp:567
Definition: mat_vec_types.h:90
void add_K_alpha(scalar *K, int num_nodes)
Definition: tetra_element_linear.cpp:76
double scalar
Definition: mat_vec_types.h:36
void add_force_to_node(int i, vector3 *f)
Add given force to the specified node of this element.
Definition: tetra_element_linear.cpp:492
void add_diffusion_matrix(matrix12 V)
Definition: tetra_element_linear.cpp:621