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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3411 - (show annotations)
Thu Dec 9 22:42:02 2010 UTC (8 years, 8 months ago) by gross
File MIME type: text/x-python
File size: 2222 byte(s)
some cleaning
1
2 ########################################################
3 #
4 # Copyright (c) 2003-2010 by University of Queensland
5 # Earth Systems Science Computational Center (ESSCC)
6 # http://www.uq.edu.au/esscc
7 #
8 # Primary Business: Queensland, Australia
9 # Licensed under the Open Software License version 3.0
10 # http://www.opensource.org/licenses/osl-3.0.php
11 #
12 ########################################################
13
14 __copyright__="""Copyright (c) 2003-2010 by University of Queensland
15 Earth Systems Science Computational Center (ESSCC)
16 http://www.uq.edu.au/esscc
17 Primary Business: Queensland, Australia"""
18 __license__="""Licensed under the Open Software License version 3.0
19 http://www.opensource.org/licenses/osl-3.0.php"""
20 __url__="https://launchpad.net/escript-finley"
21
22 from esys.escript import *
23 from esys.escript.linearPDEs import LinearPDE
24 from esys import finley
25 from esys.weipa import saveVTK
26
27 pres0=-100.
28 lame=1.
29 mu=0.3
30 rho=1.
31 g=9.81
32
33 # generate mesh: here 20x20 mesh of order 1
34 domain=finley.Rectangle(20,20,1,l0=1.0,l1=1.0)
35 #
36 # set a mask msk of type vector which is one for nodes and components set be a constraint:
37 #
38 msk=whereZero(domain.getX()[0])*[1.,1.]
39 #
40 # set the normal stress components on face elements.
41 # faces tagged with 21 get the normal stress [0,-press0].
42 #
43 # now the pressure is set to zero for x0 coordinates equal 1. (= right face)
44 press=whereZero(FunctionOnBoundary(domain).getX()[0]-1.)*pres0*[1.,0.]
45 # assemble the linear system:
46 mypde=LinearPDE(domain)
47 k3=kronecker(domain)
48 k3Xk3=outer(k3,k3)
49
50 mypde.setValue(A=mu * ( swap_axes(k3Xk3,0,3)+swap_axes(k3Xk3,1,3) ) + lame*k3Xk3,
51 Y=[0,-g*rho],
52 y=press,
53 q=msk,r=[0,0])
54 mypde.setSymmetryOn()
55 mypde.getSolverOptions().setVerbosityOn()
56 # use direct solver (default is iterative)
57 mypde.getSolverOptions().setSolverMethod(mypde.getSolverOptions().DIRECT)
58 # mypde.getSolverOptions().setPreconditioner(mypde.getSolverOptions().AMG)
59 # solve for the displacements:
60 u_d=mypde.getSolution()
61 # get the gradient and calculate the stress:
62 g=grad(u_d)
63 stress=lame*trace(g)*kronecker(domain)+mu*(g+transpose(g))
64 # write the hydrostatic pressure:
65 saveVTK("result.vtu",displacement=u_d,pressure=trace(stress)/domain.getDim())

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26