/[escript]/trunk/finley/test/python/linearElastic.py
ViewVC logotype

Annotation of /trunk/finley/test/python/linearElastic.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 6651 - (hide annotations)
Wed Feb 7 02:12:08 2018 UTC (3 years, 2 months ago) by jfenwick
File MIME type: text/x-python
File size: 2409 byte(s)
Make everyone sad by touching all the files

Copyright dates update

1 ksteube 1809
2 jfenwick 3981 ##############################################################################
3 ksteube 1312 #
4 jfenwick 6651 # Copyright (c) 2003-2018 by The University of Queensland
5 jfenwick 3981 # http://www.uq.edu.au
6 ksteube 1312 #
7 ksteube 1809 # Primary Business: Queensland, Australia
8 jfenwick 6112 # Licensed under the Apache License, version 2.0
9     # http://www.apache.org/licenses/LICENSE-2.0
10 ksteube 1312 #
11 jfenwick 3981 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 jfenwick 4657 # Development 2012-2013 by School of Earth Sciences
13     # Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 jfenwick 3981 #
15     ##############################################################################
16 ksteube 1312
17 sshaw 5706 from __future__ import print_function, division
18    
19 jfenwick 6651 __copyright__="""Copyright (c) 2003-2018 by The University of Queensland
20 jfenwick 3981 http://www.uq.edu.au
21 ksteube 1809 Primary Business: Queensland, Australia"""
22 jfenwick 6112 __license__="""Licensed under the Apache License, version 2.0
23     http://www.apache.org/licenses/LICENSE-2.0"""
24 jfenwick 2344 __url__="https://launchpad.net/escript-finley"
25 ksteube 1809
26 gross 447 from esys.escript import *
27 sshaw 4821 from esys.escript.linearPDEs import LinearPDE, SolverOptions
28 caltinay 3346 from esys import finley
29     from esys.weipa import saveVTK
30 gross 447
31 gross 3411 pres0=-100.
32     lame=1.
33     mu=0.3
34     rho=1.
35     g=9.81
36 gross 447
37 gross 3411 # generate mesh: here 20x20 mesh of order 1
38     domain=finley.Rectangle(20,20,1,l0=1.0,l1=1.0)
39 gross 447 #
40     # set a mask msk of type vector which is one for nodes and components set be a constraint:
41     #
42 gross 3411 msk=whereZero(domain.getX()[0])*[1.,1.]
43 gross 447 #
44     # set the normal stress components on face elements.
45     # faces tagged with 21 get the normal stress [0,-press0].
46     #
47 gross 3411 # now the pressure is set to zero for x0 coordinates equal 1. (= right face)
48     press=whereZero(FunctionOnBoundary(domain).getX()[0]-1.)*pres0*[1.,0.]
49 gross 447 # assemble the linear system:
50     mypde=LinearPDE(domain)
51 gross 3411 k3=kronecker(domain)
52     k3Xk3=outer(k3,k3)
53    
54     mypde.setValue(A=mu * ( swap_axes(k3Xk3,0,3)+swap_axes(k3Xk3,1,3) ) + lame*k3Xk3,
55     Y=[0,-g*rho],
56     y=press,
57     q=msk,r=[0,0])
58 gross 447 mypde.setSymmetryOn()
59 gross 3027 mypde.getSolverOptions().setVerbosityOn()
60 gross 3411 # use direct solver (default is iterative)
61 sshaw 4821 #mypde.getSolverOptions().setSolverMethod(SolverOptions.DIRECT)
62     # mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
63 gross 447 # solve for the displacements:
64 gross 3027 u_d=mypde.getSolution()
65 gross 4037
66     mypde.applyOperator(u_d)
67 gross 447 # get the gradient and calculate the stress:
68     g=grad(u_d)
69 gross 3411 stress=lame*trace(g)*kronecker(domain)+mu*(g+transpose(g))
70 gross 447 # write the hydrostatic pressure:
71 caltinay 2534 saveVTK("result.vtu",displacement=u_d,pressure=trace(stress)/domain.getDim())

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26