/[escript]/temp/escript/py_src/pdetools.py
ViewVC logotype

Diff of /temp/escript/py_src/pdetools.py

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

revision 409 by gross, Fri Dec 23 01:13:41 2005 UTC revision 637 by gross, Thu Mar 23 10:55:31 2006 UTC
# Line 7  Currently includes: Line 7  Currently includes:
7      - Projector - to project a discontinuous      - Projector - to project a discontinuous
8      - Locator - to trace values in data objects at a certain location      - Locator - to trace values in data objects at a certain location
9      - TimeIntegrationManager - to handel extraplotion in time      - TimeIntegrationManager - to handel extraplotion in time
10    
11    @var __author__: name of author
12    @var __copyright__: copyrights
13    @var __license__: licence agreement
14    @var __url__: url entry point on documentation
15    @var __version__: version
16    @var __date__: date of the version
17  """  """
18    
19    __author__="Lutz Gross, l.gross@uq.edu.au"
20    __copyright__="""  Copyright (c) 2006 by ACcESS MNRF
21                        http://www.access.edu.au
22                    Primary Business: Queensland, Australia"""
23    __license__="""Licensed under the Open Software License version 3.0
24                 http://www.opensource.org/licenses/osl-3.0.php"""
25    __url__="http://www.iservo.edu.au/esys"
26    __version__="$Revision$"
27    __date__="$Date$"
28    
29    
30  import escript  import escript
31  import linearPDEs  import linearPDEs
32  import numarray  import numarray
# Line 122  class Projector: Line 140  class Projector:
140    
141      @param input_data: The input_data to be projected.      @param input_data: The input_data to be projected.
142      """      """
143      out=escript.Data(0.,input_data.getShape(),what=escript.ContinuousFunction(self.__pde.getDomain()))      out=escript.Data(0.,input_data.getShape(),self.__pde.getFunctionSpaceForSolution())
144      if input_data.getRank()==0:      if input_data.getRank()==0:
145          self.__pde.setValue(Y = input_data)          self.__pde.setValue(Y = input_data)
146          out=self.__pde.getSolution()          out=self.__pde.getSolution()
# Line 150  class Projector: Line 168  class Projector:
168                      out[i0,i1,i2,i3]=self.__pde.getSolution()                      out[i0,i1,i2,i3]=self.__pde.getSolution()
169      return out      return out
170    
171    class NoPDE:
172         """
173         solves the following problem for u:
174    
175         M{kronecker[i,j]*D[j]*u[j]=Y[i]}
176    
177         with constraint
178    
179         M{u[j]=r[j]}  where M{q[j]>0}
180    
181         where D, Y, r and q are given functions of rank 1.
182    
183         In the case of scalars this takes the form
184    
185         M{D*u=Y}
186    
187         with constraint
188    
189         M{u=r}  where M{q>0}
190    
191         where D, Y, r and q are given scalar functions.
192    
193         The constraint is overwriting any other condition.
194    
195         @remark: This class is similar to the L{LinearPDE} class with A=B=C=X=0 but has the intention
196                  that all input parameter are given in L{Solution} or L{ReducedSolution}. The whole
197                  thing is a bit strange and I blame Robert.Woodcock@csiro.au for this.
198         """
199         def __init__(self,domain,D=None,Y=None,q=None,r=None):
200             """
201             initialize the problem
202    
203             @param domain: domain of the PDE.
204             @type domain: L{Domain}
205             @param D: coefficient of the solution.
206             @type D: C{float}, C{int}, L{NumArray}, L{Data}
207             @param Y: right hand side
208             @type Y: C{float}, C{int}, L{NumArray}, L{Data}
209             @param q: location of constraints
210             @type q: C{float}, C{int}, L{NumArray}, L{Data}
211             @param r: value of solution at locations of constraints
212             @type r: C{float}, C{int}, L{NumArray}, L{Data}
213             """
214             self.__domain=domain
215             self.__D=D
216             self.__Y=Y
217             self.__q=q
218             self.__r=r
219             self.__u=None
220             self.__function_space=escript.Solution(self.__domain)
221         def setReducedOn(self):
222             """
223             sets the L{FunctionSpace} of the solution to L{ReducedSolution}
224             """
225             self.__function_space=escript.ReducedSolution(self.__domain)
226             self.__u=None
227    
228         def setReducedOff(self):
229             """
230             sets the L{FunctionSpace} of the solution to L{Solution}
231             """
232             self.__function_space=escript.Solution(self.__domain)
233             self.__u=None
234            
235         def setValue(self,D=None,Y=None,q=None,r=None):
236             """
237             assigns values to the parameters.
238    
239             @param D: coefficient of the solution.
240             @type D: C{float}, C{int}, L{NumArray}, L{Data}
241             @param Y: right hand side
242             @type Y: C{float}, C{int}, L{NumArray}, L{Data}
243             @param q: location of constraints
244             @type q: C{float}, C{int}, L{NumArray}, L{Data}
245             @param r: value of solution at locations of constraints
246             @type r: C{float}, C{int}, L{NumArray}, L{Data}
247             """
248             if not D==None:
249                self.__D=D
250                self.__u=None
251             if not Y==None:
252                self.__Y=Y
253                self.__u=None
254             if not q==None:
255                self.__q=q
256                self.__u=None
257             if not r==None:
258                self.__r=r
259                self.__u=None
260    
261         def getSolution(self):
262             """
263             returns the solution
264            
265             @return: the solution of the problem
266             @rtype: L{Data} object in the L{FunctionSpace} L{Solution} or L{ReducedSolution}.
267             """
268             if self.__u==None:
269                if self.__D==None:
270                   raise ValueError,"coefficient D is undefined"
271                D=escript.Data(self.__D,self.__function_space)
272                if D.getRank()>1:
273                   raise ValueError,"coefficient D must have rank 0 or 1"
274                if self.__Y==None:
275                   self.__u=escript.Data(0.,D.getShape(),self.__function_space)
276                else:
277                   self.__u=util.quotient(self.__Y,D)
278                if not self.__q==None:
279                    q=util.wherePositive(escript.Data(self.__q,self.__function_space))
280                    self.__u*=(1.-q)
281                    if not self.__r==None: self.__u+=q*self.__r
282             return self.__u
283                
284  class Locator:  class Locator:
285       """       """
286       Locator provides access to the values of data objects at a given       Locator provides access to the values of data objects at a given
# Line 171  class Locator: Line 301  class Locator:
301            self.__function_space=where            self.__function_space=where
302         else:         else:
303            self.__function_space=escript.ContinuousFunction(where)            self.__function_space=escript.ContinuousFunction(where)
304         self.__id=util.length(x[:self.__function_space.getDim()]-self.__function_space.getX()).mindp()         self.__id=util.length(self.__function_space.getX()-x[:self.__function_space.getDim()]).mindp()
305    
306       def __str__(self):       def __str__(self):
307         """         """

Legend:
Removed from v.409  
changed lines
  Added in v.637

  ViewVC Help
Powered by ViewVC 1.1.26