5 #ifndef manufactured_HPP 6 #define manufactured_HPP 18 manufactured(Epetra_Comm & comm, Teuchos::ParameterList & Parameters, std::string & mesh_file){
20 Krylov = &Parameters.sublist(
"Krylov");
22 Mesh =
new mesh(comm, mesh_file, 1.0);
38 Epetra_SerialDenseVector
u(3);
39 double c1 = 2.0e-5;
double c2 = 1.0e-5;
double c3 = 2.0e-5;
double topcoord = 25.0;
40 u(0) = -c1*x2*(topcoord-x1)*(topcoord - x2);
41 u(1) = c2*x2*(topcoord/2.0-x2);
42 u(2) = std::sin(c1*x3);
47 Epetra_SerialDenseMatrix epsilon(3,3);
48 double c1 = 2.0e-5;
double c2 = 1.0e-5;
double c3 = 2.0e-5;
double topcoord = 25.0;
49 epsilon(0,0) = c1*x2*(topcoord - x2);
50 epsilon(1,1) = c2*(topcoord/2 - x2) - c2*x2;
51 epsilon(2,2) = c1*std::cos(c1*x3);
52 epsilon(1,2) = 0.0; epsilon(2,1) = 0.0;
53 epsilon(0,2) = 0.0; epsilon(2,0) = 0.0;
54 epsilon(0,1) = (c1*x2*(topcoord-x1))/2.0 - (c1*(topcoord-x1)*(topcoord-x2))/2.0; epsilon(1,0) = epsilon(0,1);
59 Epetra_SerialDenseMatrix sigma(3,3), epsilon(3,3), elasticity(6,6);
60 Epetra_SerialDenseVector sigma_voigt(6), epsilon_voigt(6);
62 epsilon_voigt(0) = epsilon(0,0); epsilon_voigt(1) = epsilon(1,1); epsilon_voigt(2) = epsilon(2,2);
63 epsilon_voigt(3) = std::sqrt(2.0)*epsilon(1,2); epsilon_voigt(4) = std::sqrt(2.0)*epsilon(0,2); epsilon_voigt(5) = std::sqrt(2.0)*epsilon(0,1);
64 unsigned int e_lid = 0;
67 sigma_voigt.Multiply(
'N',
'N',1.0,elasticity,epsilon_voigt,0.0);
68 sigma(0,0) = sigma_voigt(0); sigma(0,1) = sigma_voigt(5)/std::sqrt(2.0); sigma(0,2) = sigma_voigt(4)/std::sqrt(2.0);
69 sigma(1,0) = sigma_voigt(5)/std::sqrt(2.0); sigma(1,1) = sigma_voigt(1); sigma(1,2) = sigma_voigt(3)/std::sqrt(2.0);
70 sigma(2,0) = sigma_voigt(4)/std::sqrt(2.0); sigma(2,1) = sigma_voigt(3)/std::sqrt(2.0); sigma(2,2) = sigma_voigt(2);
74 Epetra_SerialDenseVector
get_neumannBc(Epetra_SerialDenseMatrix & matrix_X, Epetra_SerialDenseMatrix & xg,
unsigned int & gp){
75 Epetra_SerialDenseVector
t(3), normal(3);
83 normal(0) = dxi_matrix_x(1,0)*dxi_matrix_x(2,1) - dxi_matrix_x(2,0)*dxi_matrix_x(1,1);
84 normal(1) = dxi_matrix_x(2,0)*dxi_matrix_x(0,1) - dxi_matrix_x(0,0)*dxi_matrix_x(2,1);
85 normal(2) = dxi_matrix_x(0,0)*dxi_matrix_x(1,1) - dxi_matrix_x(1,0)*dxi_matrix_x(0,1);
89 t.Multiply(
'N',
'N',1.0,sigma,normal,0.0);
92 Epetra_SerialDenseVector
get_forcing(
double & x1,
double & x2,
double & x3,
unsigned int & e_lid,
unsigned int & gp){
93 Epetra_SerialDenseVector f(3);
94 Epetra_SerialDenseMatrix C(6,6);
96 double k = std::sqrt(2.0);
97 double C11 = C(0,0);
double C12 = C(0,1);
double C13 = C(0,2);
double C14 = C(0,3);
double C15 = C(0,4);
double C16 = C(0,5);
98 double C22 = C(1,1);
double C23 = C(1,2);
double C24 = C(1,3);
double C25 = C(1,4);
double C26 = C(1,5);
99 double C33 = C(2,2);
double C34 = C(2,3);
double C35 = C(2,4);
double C36 = C(2,5);
100 double C44 = C(3,3);
double C45 = C(3,4);
double C46 = C(3,5);
101 double C55 = C(4,4);
double C56 = C(4,5);
103 double c1 = 2.0e-5;
double c2 = 1.0e-5;
double c3 = 2.0e-5;
double topcoord = 25.0;
104 f(0) = C66*c1*topcoord - k*C26*c2 - C66*c1*x1 - (k*C35*c1*c1*std::sin(c1*x3))/2 + k*C16*c1*topcoord - 2*k*C16*c1*x2;
105 f(1) = C12*c1*(topcoord - x2) - C66*((c1*x2)/2 - (c1*(topcoord - x2))/2) - C12*c1*x2 - 2*C22*c2 + k*C26*c1*(topcoord - x1) - (k*C34*c1*c1*std::sin(c1*x3))/2;
106 f(2) = - (k*(2*C24*c2 + C14*c1*x2 - C14*c1*(topcoord - x2) - k*C46*c1*(topcoord - x1)))/2 - C56*((c1*x2)/2 - (c1*(topcoord - x2))/2) - C33*c1*c1*std::sin(c1*x3);
111 double solve(std::string & outPath){
112 Epetra_FECrsMatrix linearOperator(Copy,*
FEGraph);
121 double totalError =
errorL2(*uh);
138 Epetra_SerialDenseVector uExact(3), vH(3);
140 Epetra_SerialDenseMatrix u_G(3,n_gauss_points), x_G(3,n_gauss_points);
144 for (
unsigned int inode=0; inode<
Mesh->
el_type; ++inode){
155 for (
unsigned int gp=0; gp<n_gauss_points; ++gp){
158 vH(0) = uExact(0) - u_G(0,gp);
159 vH(1) = uExact(1) - u_G(1,gp);
160 vH(2) = uExact(2) - u_G(2,gp);
172 Comm->SumAll(&error,&totalError,1);
173 totalError = std::sqrt(totalError);
184 if(x==0.0 || x==25.0){
194 if(x==0.0 || x==25.0){
209 Epetra_SerialDenseVector
u(3);
215 if(y==0.0 || y==25.0){
225 F.Update(-1.0,rhs_dir,1.0);
232 if(y==0.0 || y==25.0){
244 double c1 = 144.8969e3;
245 double c2 = 14.2500e3;
246 double c3 = 5.8442e3;
247 double c4 = 7.5462e3;
248 double c5 = 12.5580e3;
253 C(0,0) = c1/16.0 + (9.0*c2)/32.0 + (9.0*c4)/32.0 + (3.0*c5)/8.0 + (3.0*std::sqrt(2.0)*c3)/16.0;
254 C(0,1) = (3.0*c1)/16.0 + (3.0*c2)/32.0 + (3.0*c4)/32.0 - (3.0*c5)/8.0 + (5.0*std::sqrt(2.0)*c3)/16.0;
255 C(0,2) = (3.0*c2)/8.0 - (3.0*c4)/8.0 + (std::sqrt(2.0)*c3)/8.0;
258 C(0,5) = std::sqrt(6)*(c1/16.0 - (3.0*c2)/32.0 - (3.0*c4)/32.0 + c5/8.0 + (std::sqrt(2.0)*c3)/16.0);
260 C(1,0) = (3.0*c1)/16.0 + (3.0*c2)/32.0 + (3.0*c4)/32.0 - (3.0*c5)/8.0 + (5*std::sqrt(2.0)*c3)/16.0;
261 C(1,1) = (9.0*c1)/16.0 + c2/32.0 + c4/32.0 + (3.0*c5)/8.0 + (3.0*std::sqrt(2.0)*c3)/16.0;
262 C(1,2) = c2/8.0 - c4/8.0 + (3.0*std::sqrt(2.0)*c3)/8.0;
265 C(1,5) = -std::sqrt(6.0)*(c2/32.0 - (3.0*c1)/16.0 + c4/32.0 + c5/8.0 + (std::sqrt(2.0)*c3)/16.0);
267 C(2,0) = (3.0*c2)/8.0 - (3.0*c4)/8.0 + std::sqrt(2.0)*c3/8.0;
268 C(2,1) = c2/8.0 - c4/8.0 + (3.0*std::sqrt(2.0)*c3)/8.0;
269 C(2,2) = c2/2.0 + c4/2.0;
272 C(2,5) = (std::sqrt(3.0)*(2.0*c3 - std::sqrt(2.0)*c2 + std::sqrt(2.0)*c4))/8.0;
277 C(3,3) = c4/4.0 + (3.0*c5)/4.0;
278 C(3,4) = -(std::sqrt(3.0)*(c4 - c5))/4.0;
284 C(4,3) = -(std::sqrt(3.0)*(c4 - c5))/4.0;
285 C(4,4) = (3.0*c4)/4.0 + c5/4.0;
288 C(5,0) = std::sqrt(6.0)*(c1/16.0 - (3.0*c2)/32.0 - (3.0*c4)/32.0 + c5/8.0 + std::sqrt(2.0)*c3/16.0);
289 C(5,1) = -std::sqrt(6.0)*(c2/32.0 - (3.0*c1)/16.0 + c4/32.0 + c5/8.0 + (std::sqrt(2.0)*c3)/16.0);
290 C(5,2) = (std::sqrt(3.0)*(2.0*c3 - std::sqrt(2.0)*c2 + std::sqrt(2.0)*c4))/8.0;
293 C(5,5) = (3.0*c1)/8.0 + (3.0*c2)/16.0 + (3.0*c4)/16.0 + c5/4.0 - (3.0*std::sqrt(2.0)*c3)/8.0;
int print_solution(Epetra_Vector &solution, std::string fileName)
void assembleMixedDirichletNeumann_inhomogeneousForcing(Epetra_FECrsMatrix &K, Epetra_FEVector &F)
std::vector< int > local_nodes
double solve(std::string &outPath)
std::vector< double > nodes_coord
std::vector< int > local_dof
Epetra_SerialDenseMatrix D2_N_faces
Epetra_SerialDenseVector N_cells
Epetra_SerialDenseMatrix manufacturedStress(double &x1, double &x2, double &x3)
Epetra_SerialDenseVector get_neumannBc(Epetra_SerialDenseMatrix &matrix_X, Epetra_SerialDenseMatrix &xg, unsigned int &gp)
Epetra_SerialDenseVector detJac_cells
Epetra_FECrsGraph * FEGraph
void get_elasticity_tensor_for_recovery(unsigned int &e_lid, Epetra_SerialDenseMatrix &tangent_matrix)
std::vector< int > local_cells
clc clear all close all mesh
Epetra_SerialDenseVector get_forcing(double &x1, double &x2, double &x3, unsigned int &e_lid, unsigned int &gp)
Teuchos::ParameterList * Krylov
int n_local_nodes_without_ghosts
std::vector< int > cells_nodes
Epetra_Import * ImportToOverlapMap
Epetra_SerialDenseMatrix D1_N_faces
unsigned int n_gauss_cells
manufactured(Epetra_Comm &comm, Teuchos::ParameterList &Parameters, std::string &mesh_file)
Epetra_SerialDenseMatrix manufacturedDeformation(double &x1, double &x2, double &x3)
std::vector< int > local_dof_without_ghosts
void d_shape_functions(Epetra_SerialDenseMatrix &D, double &xi, double &eta)
Epetra_SerialDenseVector manufacturedSolution(double &x1, double &x2, double &x3)
void get_elasticity_tensor(unsigned int &e_lid, unsigned int &gp, Epetra_SerialDenseMatrix &tangent_matrix)
void aztecSolver(Epetra_FECrsMatrix &A, Epetra_FEVector &b, Epetra_Vector &u, Teuchos::ParameterList ¶mList)
double errorL2(Epetra_Vector &uStandardMap)
void transverse_isotropic_matrix(Epetra_SerialDenseMatrix &C, double &c1, double &c2, double &c3, double &c4, double &c5)
Epetra_SerialDenseVector gauss_weight_cells
void apply_dirichlet_conditions(Epetra_FECrsMatrix &K, Epetra_FEVector &F, double &displacement)
void setup_dirichlet_conditions()