/[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 4821 - (show annotations)
Tue Apr 1 04:58:33 2014 UTC (5 years, 4 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
2 ##############################################################################
3 #
4 # Copyright (c) 2003-2014 by University of Queensland
5 # http://www.uq.edu.au
6 #
7 # 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 #
11 # Development until 2012 by Earth Systems Science Computational Center (ESSCC)
12 # Development 2012-2013 by School of Earth Sciences
13 # Development from 2014 by Centre for Geoscience Computing (GeoComp)
14 #
15 ##############################################################################
16
17 __copyright__="""Copyright (c) 2003-2014 by University of Queensland
18 http://www.uq.edu.au
19 Primary Business: Queensland, Australia"""
20 __license__="""Licensed under the Open Software License version 3.0
21 http://www.opensource.org/licenses/osl-3.0.php"""
22 __url__="https://launchpad.net/escript-finley"
23
24 from esys.escript import *
25 from esys.escript.linearPDEs import LinearPDE, SolverOptions
26 from esys import finley
27 from esys.weipa import saveVTK
28
29 pres0=-100.
30 lame=1.
31 mu=0.3
32 rho=1.
33 g=9.81
34
35 # generate mesh: here 20x20 mesh of order 1
36 domain=finley.Rectangle(20,20,1,l0=1.0,l1=1.0)
37 #
38 # set a mask msk of type vector which is one for nodes and components set be a constraint:
39 #
40 msk=whereZero(domain.getX()[0])*[1.,1.]
41 #
42 # set the normal stress components on face elements.
43 # faces tagged with 21 get the normal stress [0,-press0].
44 #
45 # 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 # assemble the linear system:
48 mypde=LinearPDE(domain)
49 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 mypde.setSymmetryOn()
57 mypde.getSolverOptions().setVerbosityOn()
58 # use direct solver (default is iterative)
59 #mypde.getSolverOptions().setSolverMethod(SolverOptions.DIRECT)
60 # mypde.getSolverOptions().setPreconditioner(SolverOptions.AMG)
61 # solve for the displacements:
62 u_d=mypde.getSolution()
63
64 mypde.applyOperator(u_d)
65 # get the gradient and calculate the stress:
66 g=grad(u_d)
67 stress=lame*trace(g)*kronecker(domain)+mu*(g+transpose(g))
68 # write the hydrostatic pressure:
69 saveVTK("result.vtu",displacement=u_d,pressure=trace(stress)/domain.getDim())

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26