/[escript]/trunk/doc/examples/usersguide/dirac.py
ViewVC logotype

Contents of /trunk/doc/examples/usersguide/dirac.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 5707 - (show annotations)
Mon Jun 29 03:59:06 2015 UTC (3 years, 8 months ago) by sshaw
File MIME type: text/x-python
File size: 1996 byte(s)
adding copyright headers to files without copyright info, moved header to top of file in some cases where it wasn't
1
2 ##############################################################################
3 #
4 # Copyright (c) 2012-2015 by The 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 example to demonstrate the use of Dirac Delta functions
18 """
19 from __future__ import division, print_function
20
21 __copyright__="""Copyright (c) 2012-2015 by The University of Queensland
22 http://www.uq.edu.au
23 Primary Business: Queensland, Australia"""
24 __license__="""Licensed under the Open Software License version 3.0
25 http://www.opensource.org/licenses/osl-3.0.php"""
26 __url__="https://launchpad.net/escript-finley"
27
28
29 from esys.escript import *
30 from esys.escript.linearPDEs import LinearSinglePDE
31 from esys.weipa import saveVTK
32
33 try:
34 from esys.finley import Rectangle
35 HAVE_FINLEY = True
36 except ImportError:
37 HAVE_FINLEY = False
38 # generate domain:
39 if not HAVE_FINLEY:
40 print("Finley module not available")
41 else:
42 mydomain=Rectangle(30,30, l0=3, l1=2,
43 diracPoints=[(1.,1.), (2.,1.)], diracTags=['in', 'out'])
44 # fix the solution on the boundary
45 x = mydomain.getX()
46 gammaD = whereZero(x[0])+whereZero(x[1])+whereZero(x[0]-3.)+whereZero(x[1]-2.)
47 # fix the solution on the boundary
48 s=Scalar(0., DiracDeltaFunctions(mydomain))
49 s.setTaggedValue('in', +1.)
50 s.setTaggedValue('out', -1.)
51 # define PDE and get its solution u
52 mypde = LinearSinglePDE(domain=mydomain)
53 mypde.setValue(q=gammaD, A=kronecker(2), y_dirac=s)
54 u = mypde.getSolution()
55 print("Solution = ",str(u))
56 # write u to an external file
57 saveVTK("u.vtu",sol=u)

  ViewVC Help
Powered by ViewVC 1.1.26