1 |
jgs |
150 |
# $Id$ |
2 |
|
|
|
3 |
jgs |
154 |
## @file symbols.py |
4 |
|
|
|
5 |
jgs |
150 |
""" |
6 |
gross |
345 |
some tools supporting the usage of symbols. |
7 |
|
|
|
8 |
|
|
@var __author__: name of author |
9 |
gross |
637 |
@var __copyright__: copyrights |
10 |
elspeth |
614 |
@var __license__: licence agreement |
11 |
gross |
345 |
@var __url__: url entry point on documentation |
12 |
|
|
@var __version__: version |
13 |
|
|
@var __date__: date of the version |
14 |
jgs |
150 |
""" |
15 |
gross |
345 |
|
16 |
|
|
__author__="Lutz Gross, l.gross@uq.edu.au" |
17 |
elspeth |
609 |
__copyright__=""" Copyright (c) 2006 by ACcESS MNRF |
18 |
|
|
http://www.access.edu.au |
19 |
|
|
Primary Business: Queensland, Australia""" |
20 |
elspeth |
614 |
__license__="""Licensed under the Open Software License version 3.0 |
21 |
|
|
http://www.opensource.org/licenses/osl-3.0.php""" |
22 |
gross |
345 |
__url__="http://www.iservo.edu.au/esys/escript" |
23 |
|
|
__version__="$Revision$" |
24 |
|
|
__date__="$Date$" |
25 |
jgs |
150 |
|
26 |
gross |
345 |
from util import Symbol |
27 |
jgs |
150 |
|
28 |
gross |
345 |
def ScalarSymbol(dim=None): |
29 |
|
|
""" |
30 |
|
|
returns a rank 0 L{Symbol}. |
31 |
|
|
|
32 |
|
|
@param dim: spatial dimension or an object that has the C{getDim} method defining the spatial dimension. If dim=C{None}, the spatial diminsion of the returned L{Symbol} is undefined. |
33 |
|
|
@type dim: C{None}, C{int} or any object with a C{getDim} method |
34 |
|
|
@return: a L{Symbol} of rank 0. |
35 |
|
|
@rtype: L{Symbol} |
36 |
|
|
""" |
37 |
|
|
if hasattr(dim,"getDim"): |
38 |
|
|
d=dim.getDim() |
39 |
|
|
else: |
40 |
|
|
d=dim |
41 |
|
|
return Symbol(shape=(),dim=d,args=[]) |
42 |
|
|
|
43 |
|
|
|
44 |
|
|
def VectorSymbol(dim=3): |
45 |
|
|
""" |
46 |
|
|
returns a vector L{Symbol} of rank 1 and spatial dimension C{dim} |
47 |
|
|
|
48 |
|
|
@param dim: spatial dimension or an object that has the C{getDim} method defining the spatial dimension. |
49 |
|
|
@type dim: C{int} or any object with a C{getDim} method |
50 |
|
|
@return: a L{Symbol} of shape (C{dim},) |
51 |
|
|
@rtype: L{Symbol} |
52 |
|
|
""" |
53 |
|
|
if hasattr(dim,"getDim"): |
54 |
|
|
d=dim.getDim() |
55 |
|
|
else: |
56 |
|
|
d=dim |
57 |
|
|
return Symbol(shape=(d,),dim=d,args=[]) |
58 |
|
|
|
59 |
|
|
def TensorSymbol(dim=3): |
60 |
|
|
""" |
61 |
|
|
returns a tensor L{Symbol} of rank 2 and spatial dimension C{dim} |
62 |
|
|
|
63 |
|
|
@param dim: spatial dimension or an object that has the C{getDim} method defining the spatial dimension. |
64 |
|
|
@type dim: C{int} or any object with a C{getDim} method |
65 |
|
|
@return: a L{Symbol} of shape (C{dim},C{dim}) |
66 |
|
|
@rtype: L{Symbol} |
67 |
|
|
""" |
68 |
|
|
if hasattr(dim,"getDim"): |
69 |
|
|
d=dim.getDim() |
70 |
|
|
else: |
71 |
|
|
d=dim |
72 |
|
|
return Symbol(shape=(d,d),dim=d,args=[]) |
73 |
|
|
|
74 |
|
|
def Tensor3Symbol(dim=3): |
75 |
|
|
""" |
76 |
|
|
returns a tensor L{Symbol} of rank 3 and spatial dimension C{dim} |
77 |
|
|
|
78 |
|
|
@param dim: spatial dimension or an object that has the C{getDim} method defining the spatial dimension. |
79 |
|
|
@type dim: C{int} or any object with a C{getDim} method |
80 |
|
|
@return: a L{Symbol} of shape (C{dim},C{dim},C{dim}) |
81 |
|
|
@rtype: L{Symbol} |
82 |
|
|
""" |
83 |
|
|
if hasattr(dim,"getDim"): |
84 |
|
|
d=dim.getDim() |
85 |
|
|
else: |
86 |
|
|
d=dim |
87 |
|
|
return Symbol(shape=(d,d,d),dim=d,args=[]) |
88 |
|
|
|
89 |
|
|
def Tensor4Symbol(dim=3): |
90 |
|
|
""" |
91 |
|
|
returns a tensor L{Symbol} of rank 4 and spatial dimension C{dim} |
92 |
|
|
|
93 |
|
|
@param dim: spatial dimension or an object that has the C{getDim} method defining the spatial dimension. |
94 |
|
|
@type dim: C{int} or any object with a C{getDim} method |
95 |
|
|
@param name: name of the symbol |
96 |
|
|
@type name: C{str} |
97 |
|
|
@return: a L{Symbol} of shape (C{dim},C{dim},C{dim},C{dim}) |
98 |
|
|
@rtype: L{Symbol} |
99 |
|
|
""" |
100 |
|
|
if hasattr(dim,"getDim"): |
101 |
|
|
d=dim.getDim() |
102 |
|
|
else: |
103 |
|
|
d=dim |
104 |
|
|
return Symbol(shape=(d,d,d,d),dim=d,args=[]) |
105 |
|
|
# |
106 |
|
|
# $Log:$ |
107 |
|
|
# |
108 |
|
|
# vim: expandtab shiftwidth=4: |