/[escript]/trunk/modellib/py_src/geometry.py
ViewVC logotype

Diff of /trunk/modellib/py_src/geometry.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 147 by jgs, Fri Aug 12 01:45:47 2005 UTC revision 149 by jgs, Thu Sep 1 03:31:39 2005 UTC
# Line 1  Line 1 
1  # $Id$  # $Id$
2    
3    
4  from escript.escript import *  from esys.escript import *
5  from escript.modelframe import Model  from esys.escript.modelframe import Model,ParameterSet
6  from finley import finley  from esys import finley
7    
8  class RectangularDomain(Model):  class RectangularDomain(Model):
9         """generates a mesh over a rectangular domain finley         """
10           Generates a mesh over a rectangular domain finley.
              dim  
              l  
              n  
              order  
              periodic  
              intergration order  
   
              domain (callable)  
11    
12           @ivar dim:
13           @ivar l:
14           @ivar n:
15           @ivar order:
16           @ivar periodic:
17           @ivar intergration order:
18           @ivar domain (callable):
19         """         """
20         def __init__(self,debug=False):         def __init__(self,debug=False):
21             Model.__init__(self,debug=debug)             Model.__init__(self,debug=debug)
# Line 54  class RectangularDomain(Model): Line 53  class RectangularDomain(Model):
53    
54            return self._domain            return self._domain
55    
56  class ScalarConstrainer(Model):  class ScalarConstrainer(ParameterSet):
57       """@brief creates a characteristic function for the location of constraints for a scalar value       """
58         Creates a characteristic function for the location of constraints
59                @param domain (in) - rectangular domain       for a scalar value.
               @param left (in)  - True to set a constraint at the left face of the domain (x[0]=min x[0]), default is False  
               @param right (in) - True to set a constraint at the left face of the domain (x[0]=max x[0]), default is False  
               @param top (in)  - True to set a constraint at the left face of the domain (x[1]=min x[1]), default is False  
               @param bottom (in) - True to set a constraint at the left face of the domain (x[1]=max x[1]), default is False  
               @param front (in)  - True to set a constraint at the left face of the domain (x[2]=min x[2]), default is False  
               @param back (in) - True to set a constraint at the left face of the domain (x[2]=max x[2]), default is False  
               @param location_of_constraint (out) - object that defines the location of the constraints.  
60    
61         In the case that the spatial dimension is two, teh arguments front and back are ignored       In the case that the spatial dimension is two, the arguments front
62         and back are ignored.
63    
64         @ivar domain (in): rectangular domain
65         @ivar left (in): True to set a constraint at the left face of the
66                   domain (x[0]=min x[0]), default is False
67         @ivar right (in): True to set a constraint at the left face of the
68                   domain (x[0]=max x[0]), default is False
69         @ivar top (in): True to set a constraint at the left face of the
70                   domain (x[1]=min x[1]), default is False
71         @ivar bottom (in): True to set a constraint at the left face of the
72                   domain (x[1]=max x[1]), default is False
73         @ivar front (in): True to set a constraint at the left face of the
74                   domain (x[2]=min x[2]), default is False
75         @ivar back (in): True to set a constraint at the left face of the
76                   domain (x[2]=max x[2]), default is False
77         @ivar location_of_constraint (out): object that defines the location
78                   of the constraints.
79       """       """
80       def __init__(self,debug=False):       def __init__(self,debug=False):
81             Model.__init__(self,debug=debug)             ParameterSet.__init__(self,debug=debug)
82             self.declareParameter(domain=None, \             self.declareParameter(domain=None, \
83                                   left=False, \                                   left=False, \
84                                   right=False, \                                   right=False, \
# Line 81  class ScalarConstrainer(Model): Line 89  class ScalarConstrainer(Model):
89             self._location_of_constraint=None             self._location_of_constraint=None
90    
91       def location_of_constraint(self):       def location_of_constraint(self):
92            """returns the mask of the location of constraint"""            """
93              Returns the mask of the location of constraint.
94              """
95            if self._location_of_constraint==None:            if self._location_of_constraint==None:
96               x=self.domain.getX()               x=self.domain.getX()
97               self._location_of_constraint=Scalar(0,x.getFunctionSpace())               self._location_of_constraint=Scalar(0,x.getFunctionSpace())
# Line 99  class ScalarConstrainer(Model): Line 109  class ScalarConstrainer(Model):
109                  if self.top: self._location_of_constraint+=(x[1]-sup(x[1])).whereZero()                  if self.top: self._location_of_constraint+=(x[1]-sup(x[1])).whereZero()
110            return self._location_of_constraint            return self._location_of_constraint
111    
112  class VectorConstrainer(Model):  class VectorConstrainer(ParameterSet):
113        """@brief creates a characteristic function for the location of constraints for a scalar value        """
114          Creates a characteristic function for the location of constraints
115                @param domain (in) - rectangular domain        for a scalar value.
               @param left (in)  - list of three boolean. left[i]==True sets a constraint for the i-th component at the left  
                                   face of the domain (x[0]=min x[0]), default is [False,False,False]  
               @param right (in) - list of three boolean. left[i]==True sets a constraint for the i-th component at the right  
                                   face of the domain (x[0]=max x[0]), default is [False,False,False]  
               @param top (in)  - list of three boolean. left[i]==True sets a constraint for the i-th component at the top  
                                   face of the domain (x[1]=min x[1]), default is [False,False,False]  
               @param bottom (in) - list of three boolean. left[i]==True sets a constraint for the i-th component at the bottom  
                                   face of the domain (x[1]=min x[1]), default is [False,False,False]  
               @param front (in)  - list of three boolean. left[i]==True sets a constraint for the i-th component at the front  
                                   face of the domain (x[2]=min x[2]), default is [False,False,False]  
               @param back (in) - list of three boolean. left[i]==True sets a constraint for the i-th component at the back  
                                   face of the domain (x[2]=max x[2]), default is [False,False,False]  
               @param location_of_constraint (callable) - object that defines the location of the constraints for each vector component.  
116    
117         In the case that the spatial dimension is two, thh arguments front and back as well as the third component of each argument is ignored.        @ivar domain (in): rectangular domain
118          @ivar left (in): list of three boolean. left[i]==True sets a
119                    constraint for the i-th component at the left
120                    face of the domain (x[0]=min x[0]),
121                    default is [False,False,False]
122          @ivar right (in): list of three boolean. left[i]==True sets a
123                    constraint for the i-th component at the right
124                    face of the domain (x[0]=max x[0]),
125                    default is [False,False,False]
126          @ivar top (in): list of three boolean. left[i]==True sets a
127                    constraint for the i-th component at the top
128                    face of the domain (x[1]=min x[1]),
129                    default is [False,False,False]
130          @ivar bottom (in): list of three boolean. left[i]==True sets a
131                    constraint for the i-th component at the bottom
132                    face of the domain (x[1]=min x[1]),
133                    default is [False,False,False]
134          @ivar front (in): list of three boolean. left[i]==True sets a
135                    constraint for the i-th component at the front
136                    face of the domain (x[2]=min x[2]),
137                    default is [False,False,False]
138          @ivar back (in): list of three boolean. left[i]==True sets a
139                    constraint for the i-th component at the back
140                    face of the domain (x[2]=max x[2]),
141                    default is [False,False,False]
142          @ivar location_of_constraint (callable): object that defines the location of the constraints for each vector component.
143    
144          In the case that the spatial dimension is two, thh arguments front and
145          back as well as the third component of each argument is ignored.
146        """        """
147        def __init__(self,debug=False):        def __init__(self,debug=False):
148             Model.__init__(self,debug=debug)             ParameterSet.__init__(self,debug=debug)
149             self.declareParameter(domain=None, \             self.declareParameter(domain=None, \
150                                   left=[0,0,0],  \                                   left=[0,0,0],  \
151                                   right=[0,0,0],  \                                   right=[0,0,0],  \
# Line 131  class VectorConstrainer(Model): Line 155  class VectorConstrainer(Model):
155                                   back=[0,0,0])                                   back=[0,0,0])
156             self._location_of_constraint=None             self._location_of_constraint=None
157        def location_of_constraint(self):        def location_of_constraint(self):
158            """returns the mask of the location of constraint"""            """
159              Returns the mask of the location of constraint.
160              """
161            if self._location_of_constraint==None:            if self._location_of_constraint==None:
162               x=self.domain.getX()               x=self.domain.getX()
163               self._location_of_constraint=Vector(0,x.getFunctionSpace())               self._location_of_constraint=Vector(0,x.getFunctionSpace())
# Line 174  class VectorConstrainer(Model): Line 200  class VectorConstrainer(Model):
200                  if self.top[0]: self._location_of_constraint+=top_mask*[1.,0.]                  if self.top[0]: self._location_of_constraint+=top_mask*[1.,0.]
201                  if self.top[1]: self._location_of_constraint+=top_mask*[0.,1.]                  if self.top[1]: self._location_of_constraint+=top_mask*[0.,1.]
202            return self._location_of_constraint            return self._location_of_constraint
203    
204    # vim: expandtab shiftwidth=4:

Legend:
Removed from v.147  
changed lines
  Added in v.149

  ViewVC Help
Powered by ViewVC 1.1.26