/[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 4821 - (hide annotations)
Tue Apr 1 04:58:33 2014 UTC (5 years, 5 months ago) by sshaw
File MIME type: text/x-python
File size: 2372 byte(s)
moved SolverOptions to c++, split into SolverOptions for the options and SolverBuddy as the state as a precursor to per-pde solving... does break some use cases (e.g. pde.getSolverOptions().DIRECT will now fail, new value access is with SolverOptions.DIRECT), examples and documentation updated to match
1 ksteube 1809
2 jfenwick 3981 ##############################################################################
3 ksteube 1312 #
4 jfenwick 4657 # Copyright (c) 2003-2014 by University of Queensland
5 jfenwick 3981 # http://www.uq.edu.au
6 ksteube 1312 #
7 ksteube 1809 # Primary Business: Queensland, Australia
8     # Licensed under the Open Software License version 3.0
9     # http://www.opensource.org/licenses/osl-3.0.php
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 jfenwick 4657 __copyright__="""Copyright (c) 2003-2014 by University of Queensland
18 jfenwick 3981 http://www.uq.edu.au
19 ksteube 1809 Primary Business: Queensland, Australia"""
20 elspeth 617 __license__="""Licensed under the Open Software License version 3.0
21 ksteube 1809 http://www.opensource.org/licenses/osl-3.0.php"""
22 jfenwick 2344 __url__="https://launchpad.net/escript-finley"
23 ksteube 1809
24 gross 447 from esys.escript import *
25 sshaw 4821 from esys.escript.linearPDEs import LinearPDE, SolverOptions
26 caltinay 3346 from esys import finley
27     from esys.weipa import saveVTK
28 gross 447
29 gross 3411 pres0=-100.
30     lame=1.
31     mu=0.3
32     rho=1.
33     g=9.81
34 gross 447
35 gross 3411 # generate mesh: here 20x20 mesh of order 1
36     domain=finley.Rectangle(20,20,1,l0=1.0,l1=1.0)
37 gross 447 #
38     # set a mask msk of type vector which is one for nodes and components set be a constraint:
39     #
40 gross 3411 msk=whereZero(domain.getX()[0])*[1.,1.]
41 gross 447 #
42     # set the normal stress components on face elements.
43     # faces tagged with 21 get the normal stress [0,-press0].
44     #
45 gross 3411 # now the pressure is set to zero for x0 coordinates equal 1. (= right face)
46     press=whereZero(FunctionOnBoundary(domain).getX()[0]-1.)*pres0*[1.,0.]
47 gross 447 # assemble the linear system:
48     mypde=LinearPDE(domain)
49 gross 3411 k3=kronecker(domain)
50     k3Xk3=outer(k3,k3)
51    
52     mypde.setValue(A=mu * ( swap_axes(k3Xk3,0,3)+swap_axes(k3Xk3,1,3) ) + lame*k3Xk3,
53     Y=[0,-g*rho],
54     y=press,
55     q=msk,r=[0,0])
56 gross 447 mypde.setSymmetryOn()
57 gross 3027 mypde.getSolverOptions().setVerbosityOn()
58 gross 3411 # use direct solver (default is iterative)
59 sshaw 4821 #mypde.getSolverOptions().setSolverMethod(SolverOptions.DIRECT)
60     # mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
61 gross 447 # solve for the displacements:
62 gross 3027 u_d=mypde.getSolution()
63 gross 4037
64     mypde.applyOperator(u_d)
65 gross 447 # get the gradient and calculate the stress:
66     g=grad(u_d)
67 gross 3411 stress=lame*trace(g)*kronecker(domain)+mu*(g+transpose(g))
68 gross 447 # write the hydrostatic pressure:
69 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