97 integer ,
parameter :: verb = 2
108 integer ,
parameter :: fe_v =
fe_p2_2d 109 integer ,
parameter :: fe_s =
fe_p2_1d 112 character(LEN=1),
parameter :: mesh_idx =
"2" 122 type(quadmesh) :: qdm
125 character(len=100),
parameter :: mesh_file= &
126 & trim(GMSH_DIR)//
"square/square_"//mesh_idx//
".msh" 138 real(RP),
dimension(:),
allocatable :: rhs, u_h, aux
139 real(RP),
dimension(:),
allocatable :: u_h_1, u_h_2
144 real(RP) :: err_L2, err_H1
146 character(LEN=300) :: shell_com
159 write(*,*)
'elasticity_Neumann_2D: start' 161 write(*,*)
" EXAMPLE OF A LINEAR ELASTICITY PROBLEM" 163 write(*,*)
" -div(A(x) e(u)) = f on \Omega" 165 write(*,*)
" WITH A NEUMANN BOUNDARY CONDITION " 167 write(*,*)
" A(x)e(u)) n = g on \partial\Omega" 169 write(*,*)
" AND WITH NON CONSTANT LAME COEFFICIENTS:" 171 write(*,*)
" A(x) \xi = lambda(x) Tr(\xi) Id + 2 mu(x) \si" 173 write(*,*)
" The problem data 'lambda', 'mu', 'u', 'f' and 'g'" 174 write(*,*)
" have been derived in " 175 write(*,*)
" choral/maple/example_elasticity_Neumann.mw" 181 write(*,*)
"================================== MESH ASSEMBLING" 182 msh = mesh(mesh_file,
'gmsh')
187 write(*,*)
"================================== FINITE ELEMENT& 194 y = fespacexk(x_h, 2)
198 write(*,*)
"================================== INTEGRATION METHOD& 199 & ON \Omega ASSEMBLING" 206 write(*,*)
"================================== STIFFNESS& 208 call elasticity_stiffmat(stiff,
lambda,
mu, &
213 write(*,*)
"================================== RIGHT HAND SIDE" 214 write(*,*)
" 1- COMPUTATION OF F" 217 call l2_product(rhs, y, qdm,
f_1,
f_2)
221 write(*,*)
"================================== RIGHT HAND SIDE" 222 write(*,*)
" 2- COMPUTATION OF G" 225 call elasticity_neumann_rhs(aux, y, qd_s, &
230 call elasticity_neumann_rhs(aux, y, qd_s, &
235 call elasticity_neumann_rhs(aux, y, qd_s, &
240 call elasticity_neumann_rhs(aux, y, qd_s, &
245 write(*,*)
"================================== SOLVE LINEAR SYSTEM& 249 kry = krylov(
kry_gmres, tol=1
e-6_rp, itmax=1000, restart=25, verb=2)
253 call interp_vect_func(u_h, y,
u_1,
u_2)
256 call solve(u_h, kry, rhs, stiff)
263 write(*,*)
"================================== POST-TREATMENT" 267 call extract_component(u_h_2, u_h, y, 2)
268 call extract_component(u_h_1, u_h, y, 1)
274 shell_com =
'elasticity_Neumann_u.msh' 277 call write(x_h, trim(shell_com),
'gmsh')
281 call gmsh_addview(x_h, u_h_1, &
283 &
'Elasticity problem : numerical solution', 0.0_rp, 1)
284 call gmsh_addview(x_h, u_h_2, &
286 &
'Elasticity problem : numerical solution', 1.0_rp, 2)
289 shell_com =
'gmsh -option '//trim(gmsh_dir)//
'gmsh-options-view'&
290 & //
' '//trim(shell_com)
291 call system(shell_com)
296 write(*,*)
"Numerical errors" 297 err_l2 = l2_dist(u_h, y, qdm,
u_1,
u_2)
299 write(*,*)
" Error | u - u_h|_L2 =", err_l2
300 write(*,*)
" Error |\nabla (u - u_h)|_L2 =", err_h1
311 function lambda(x)
result(r)
313 real(RP),
dimension(3),
intent(in) :: x
321 function mu(x)
result(r)
323 real(RP),
dimension(3),
intent(in) :: x
331 function u_1(x)
result(r)
333 real(RP),
dimension(3),
intent(in) :: x
335 r = cos(pi*x(1) ) * sin(pi*x(2))
338 function u_2(x)
result(r)
340 real(RP),
dimension(3),
intent(in) :: x
342 r = sin(pi*x(1) ) * cos(pi*x(2))
350 function grad_u1(x)
result(grad)
351 real(RP),
dimension(3) :: grad
352 real(RP),
dimension(3),
intent(in) :: x
354 grad(1) = -pi * sin(pi*x(1)) * sin(pi*x(2))
355 grad(2) = pi * cos(pi*x(1)) * cos(pi*x(2))
359 function grad_u2(x)
result(grad)
360 real(RP),
dimension(3) :: grad
361 real(RP),
dimension(3),
intent(in) :: x
363 grad(1) = pi * cos(pi*x(1)) * cos(pi*x(2))
364 grad(2) = -pi * sin(pi*x(1)) * sin(pi*x(2))
372 function f_1(x)
result(r)
374 real(RP),
dimension(3),
intent(in) :: x
376 r = 6.0_rp * pi**2 *
u_1(x)
379 function f_2(x)
result(r)
381 real(RP),
dimension(3),
intent(in) :: x
383 r = 6.0_rp * pi**2 *
u_2(x)
390 function x_le_0(x)
result(r)
392 real(RP),
dimension(3),
intent(in) :: x
401 function x_ge_1(x)
result(r)
403 real(RP),
dimension(3),
intent(in) :: x
411 function y_le_0(x)
result(r)
413 real(RP),
dimension(3),
intent(in) :: x
422 function y_ge_1(x)
result(r)
424 real(RP),
dimension(3),
intent(in) :: x
435 real(RP),
dimension(3),
intent(in) :: x
445 real(RP),
dimension(3),
intent(in) :: x
447 r = -2.0_rp * cos(pi*x(2)) * pi
455 real(RP),
dimension(3),
intent(in) :: x
465 real(RP),
dimension(3),
intent(in) :: x
467 r = -2.0_rp * cos(pi*x(2)) * pi
475 real(RP),
dimension(3),
intent(in) :: x
477 r = -2.0_rp * cos(pi*x(1)) * pi
485 real(RP),
dimension(3),
intent(in) :: x
495 real(RP),
dimension(3),
intent(in) :: x
497 r = -2.0_rp * cos(pi*x(1)) * pi
505 real(RP),
dimension(3),
intent(in) :: x
real(rp) function x_ge_1(x)
To characterise {x=1}.
real(rp) function g_1_y_0(x)
g(x) on {y=0}, first component
real(rp) function g_2_y_1(x)
g(x) on {y=1}, second component
real(rp) function, dimension(3) grad_u1(x)
gradient of the exact solution
subroutine, public choral_init(verb)
Initialisation for the CHORAL library
real(rp) function g_1_y_1(x)
g(x) on {y=1}, first component
TOP-LEVEL MODULE FOR THE LIBRARY CHORAL
integer, parameter fe_p2_2d
integer, parameter quad_gauss_edg_4
integer, parameter kry_gmres
GmRes linear solver.
program elasticity_neumann_2d
SOLVES THE LINEAR ELASTICITY PROBLEM with Neumann boundary conditions
real(rp) function g_2_x_0(x)
g(x) on {x=0}, second component
real(rp) function g_2_y_0(x)
g(x) on {y=0}, second component
real(rp) function, dimension(3) grad_u2(x)
real(rp) function x_le_0(x)
To characterise {x=0}.
real(rp) function e(x, v1, v2)
real(rp) function y_le_0(x)
To characterise {x=0}.
real(rp) function mu(x)
Lame coefficient 'mu'.
real(rp) function f(x)
right hand side 'f'
real(rp) function y_ge_1(x)
To characterise {x=1}.
real(rp) function g_1_x_1(x)
g(x) on {x=1}, first component
real(rp) function lambda(x)
Lame coefficient 'lambda'.
integer, parameter quad_gauss_trg_12
real(rp) function f_1(x)
right hand side 'f'= =(f_1, f_2)
integer, parameter fe_p2_1d
real(rp) function g_1_x_0(x)
g(x) on {x=0}, first component
real(rp) function g_2_x_1(x)
g(x) on {x=1}, second component
real(rp) function u_1(x)
exact solution u=(u_1, u_2)