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

Diff of /trunk/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 525 by gross, Tue Feb 14 06:56:13 2006 UTC
# Line 122  class Projector: Line 122  class Projector:
122    
123      @param input_data: The input_data to be projected.      @param input_data: The input_data to be projected.
124      """      """
125      out=escript.Data(0.,input_data.getShape(),what=escript.ContinuousFunction(self.__pde.getDomain()))      out=escript.Data(0.,input_data.getShape(),self.__pde.getFunctionSpaceForSolution())
126      if input_data.getRank()==0:      if input_data.getRank()==0:
127          self.__pde.setValue(Y = input_data)          self.__pde.setValue(Y = input_data)
128          out=self.__pde.getSolution()          out=self.__pde.getSolution()
# Line 150  class Projector: Line 150  class Projector:
150                      out[i0,i1,i2,i3]=self.__pde.getSolution()                      out[i0,i1,i2,i3]=self.__pde.getSolution()
151      return out      return out
152    
153    class NoPDE:
154         """
155         solves the following problem for u:
156    
157         M{kronecker[i,j]*D[j]*u[j]=Y[i]}
158    
159         with constraint
160    
161         M{u[j]=r[j]}  where M{q[j]>0}
162    
163         where D, Y, r and q are given functions of rank 1.
164    
165         In the case of scalars this takes the form
166    
167         M{D*u=Y}
168    
169         with constraint
170    
171         M{u=r}  where M{q>0}
172    
173         where D, Y, r and q are given scalar functions.
174    
175         The constraint is overwriting any other condition.
176    
177         @remark: This class is similar to the L{LinearPDE} class with A=B=C=X=0 but has the intention
178                  that all input parameter are given in L{Solution} or L{ReducedSolution}. The whole
179                  thing is a bit strange and I blame Robert.Woodcock@csiro.au for this.
180         """
181         def __init__(self,domain,D=None,Y=None,q=None,r=None):
182             """
183             initialize the problem
184    
185             @param domain: domain of the PDE.
186             @type domain: L{Domain}
187             @param D: coefficient of the solution.
188             @type D: C{float}, C{int}, L{NumArray}, L{Data}
189             @param Y: right hand side
190             @type Y: C{float}, C{int}, L{NumArray}, L{Data}
191             @param q: location of constraints
192             @type q: C{float}, C{int}, L{NumArray}, L{Data}
193             @param r: value of solution at locations of constraints
194             @type r: C{float}, C{int}, L{NumArray}, L{Data}
195             """
196             self.__domain=domain
197             self.__D=D
198             self.__Y=Y
199             self.__q=q
200             self.__r=r
201             self.__u=None
202             self.__function_space=escript.Solution(self.__domain)
203         def setReducedOn(self):
204             """
205             sets the L{FunctionSpace} of the solution to L{ReducedSolution}
206             """
207             self.__function_space=escript.ReducedSolution(self.__domain)
208             self.__u=None
209    
210         def setReducedOff(self):
211             """
212             sets the L{FunctionSpace} of the solution to L{Solution}
213             """
214             self.__function_space=escript.Solution(self.__domain)
215             self.__u=None
216            
217         def setValue(self,D=None,Y=None,q=None,r=None):
218             """
219             assigns values to the parameters.
220    
221             @param D: coefficient of the solution.
222             @type D: C{float}, C{int}, L{NumArray}, L{Data}
223             @param Y: right hand side
224             @type Y: C{float}, C{int}, L{NumArray}, L{Data}
225             @param q: location of constraints
226             @type q: C{float}, C{int}, L{NumArray}, L{Data}
227             @param r: value of solution at locations of constraints
228             @type r: C{float}, C{int}, L{NumArray}, L{Data}
229             """
230             if not D==None:
231                self.__D=D
232                self.__u=None
233             if not Y==None:
234                self.__Y=Y
235                self.__u=None
236             if not q==None:
237                self.__q=q
238                self.__u=None
239             if not r==None:
240                self.__r=r
241                self.__u=None
242    
243         def getSolution(self):
244             """
245             returns the solution
246            
247             @return: the solution of the problem
248             @rtype: L{Data} object in the L{FunctionSpace} L{Solution} or L{ReducedSolution}.
249             """
250             if self.__u==None:
251                if self.__D==None:
252                   raise ValueError,"coefficient D is undefined"
253                D=escript.Data(self.__D,self.__function_space)
254                if D.getRank()>1:
255                   raise ValueError,"coefficient D must have rank 0 or 1"
256                if self.__Y==None:
257                   self.__u=escript.Data(0.,D.getShape(),self.__function_space)
258                else:
259                   self.__u=util.quotient(self.__Y,D)
260                if not self.__q==None:
261                    q=util.wherePositive(escript.Data(self.__q,self.__function_space))
262                    self.__u*=(1.-q)
263                    if not self.__r==None: self.__u+=q*self.__r
264             return self.__u
265                
266  class Locator:  class Locator:
267       """       """
268       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 283  class Locator:
283            self.__function_space=where            self.__function_space=where
284         else:         else:
285            self.__function_space=escript.ContinuousFunction(where)            self.__function_space=escript.ContinuousFunction(where)
286         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()
287    
288       def __str__(self):       def __str__(self):
289         """         """

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

  ViewVC Help
Powered by ViewVC 1.1.26