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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2548 - (show annotations)
Mon Jul 20 06:20:06 2009 UTC (10 years, 2 months ago) by jfenwick
File MIME type: text/x-python
File size: 28752 byte(s)
Updating copyright notices
1
2 ########################################################
3 #
4 # Copyright (c) 2003-2009 by University of Queensland
5 # Earth Systems Science Computational Center (ESSCC)
6 # http://www.uq.edu.au/esscc
7 #
8 # Primary Business: Queensland, Australia
9 # Licensed under the Open Software License version 3.0
10 # http://www.opensource.org/licenses/osl-3.0.php
11 #
12 ########################################################
13
14 __copyright__="""Copyright (c) 2003-2008 by University of Queensland
15 Earth Systems Science Computational Center (ESSCC)
16 http://www.uq.edu.au/esscc
17 Primary Business: Queensland, Australia"""
18 __license__="""Licensed under the Open Software License version 3.0
19 http://www.opensource.org/licenses/osl-3.0.php"""
20 __url__="https://launchpad.net/escript-finley"
21
22 from esys.escript import *
23 from esys.escript.modelframe import Model,ParameterSet
24 from esys import finley
25
26 class FinleyReader(ParameterSet):
27 """
28 reads finley mesh file.
29
30 @ivar source: mesh file in finley or gmsh format
31 @type source: C{DataSource}
32 @ivar intergrationOrder: integration order, default -1 (in).
33 @type intergrationOrder: C{int}
34 @ivar reducedIntegrationOrder: reduced integration order, default -1 (in).
35 @type reducedIntegrationOrder: C{int}
36 @ivar optimizeLabeling: switches on optimization of the labeling of the nodes
37 @type optimizeLabeling: C{bool}
38 """
39 def __init__(self,**kwargs):
40 """
41 initializes the object
42 """
43 super(FinleyReader,self).__init__(**kwargs)
44 self.declareParameter(source="none",
45 dim=None,
46 optimizeLabeling=True,
47 reducedIntegrationOrder=-1,
48 integrationOrder=-1)
49 self.__domain=None
50
51
52 def domain(self):
53 """
54 returns the domain
55
56 @return: the domain
57 @rtype: L{Domain}
58 """
59 if self.__domain == None:
60 if self.source.fileformat == "fly":
61 self.__domain=finley.ReadMesh(self.source.getLocalFileName(),self.integrationOrder)
62 elif self.source.fileformat == "gmsh":
63 if self.dim==None:
64 dim=3
65 else:
66 dim=self.dim
67 self.__domain=finley.ReadGmsh(self.source.getLocalFileName(),dim,self.integrationOrder,self.reducedIntegrationOrder, self.optimizeLabeling)
68 else:
69 raise TypeError("unknown mesh file format %s."%self.source.fileformat)
70 self.trace("mesh read from %s in %s format."%(self.source.getLocalFileName(), self.source.fileformat))
71 return self.__domain
72 class RectangularDomain(ParameterSet):
73 """
74 Generates a mesh over a rectangular domain finley.
75
76 @ivar dim: spatial dimension, default =2 (in).
77 @type dim: spatial dimension
78 @ivar l: spatial lengths, default [1.,1.,1.] (in).
79 @type l: C{list} of C{floats}s
80 @ivar n: number of elements, default [10,10,10] (in).
81 @type n: C{list} of C{int}s
82 @ivar order: element order, default 1 (in).
83 @type order: C{int}
84 @ivar periodic: flags for periodicity, default [False,False,False] (in).
85 @type periodic: C{list} of C{bool}s
86 @ivar intergrationOrder: integration order, default -1 (in).
87 @type intergrationOrder: C{int}
88 """
89 def __init__(self,**kwargs):
90 """
91 initializes the object
92 """
93 super(RectangularDomain,self).__init__(**kwargs)
94 self.declareParameter(dim=2,\
95 l=[1.,1.,1.],\
96 n=[10,10,10], \
97 order=1,\
98 periodic=[False,False,False],
99 integrationOrder=-1)
100 self.__domain=None
101
102 def domain(self):
103 """
104 returns the domain
105
106 @return: the domain
107 @rtype: L{Domain}
108 """
109 if self.__domain==None:
110 if self.dim==2:
111 self.__domain=finley.Rectangle(n0=self.n[0],\
112 n1=self.n[2],\
113 l0=self.l[0],\
114 l1=self.l[2],\
115 order=self.order, \
116 periodic0=self.periodic[0], \
117 periodic1=self.periodic[2], \
118 integrationOrder=self.integrationOrder)
119 else:
120 self.__domain=finley.Brick(n0=self.n[0],\
121 n1=self.n[1],\
122 n2=self.n[2],\
123 l0=self.l[0],\
124 l1=self.l[1],\
125 l2=self.l[2],\
126 order=self.order, \
127 periodic0=self.periodic[0], \
128 periodic1=self.periodic[1], \
129 periodic2=self.periodic[2], \
130 integrationOrder=self.integrationOrder)
131 return self.__domain
132
133 class UpdateGeometry(Model):
134 """
135 applies a displacement field to a domain
136
137 @ivar displacement: displacements applied to the original mesh coordinates (in).
138 @type displacement: L{escript.Vector}
139 @ivar domain: domain
140 @type domain: L{escript.Domain}
141 """
142 def __init__(self,**kwargs):
143 """
144 set-up the object
145 """
146 super(UpdateGeometry, self).__init__(**kwargs)
147 self.declareParameter(domain=None,\
148 displacement=None)
149
150
151 def doInitialization(self):
152 """
153 initialize model
154 """
155 self.__x=self.domain.getX()
156 self.__reset=True
157
158 def doStepPreprocessing(self,dt):
159 """
160 applies the current L{displacement} to mesh nodes if required.
161 """
162 if self.__reset:
163 self.trace("mesh nodes updated.")
164 self.domain.setX(self.__x+self.displacement)
165 self.__reset=False
166
167 def doStep(self,dt):
168 """
169 applies the current L{displacement} to mesh nodes.
170 """
171 self.trace("mesh nodes updated.")
172 self.domain.setX(self.__x+self.displacement)
173 self.__reset=True
174
175 def doStepPostprocessing(self,dt):
176 """
177 marks nodes as beeing updated.
178 """
179 self.__reset=False
180
181 class ConstrainerOverBox(Model):
182 """
183 Creates a characteristic function for the location of constraints
184 for all components of a value and selects the value from an initial value
185 ate these locations.
186
187 In the case that the spatial dimension is two, the arguments front and back are ignored.
188
189 @ivar domain: domain (in).
190 @ivar left: True to set a constraint at the left face of the domain (x[0]=min x[0]), default False (in).
191 @ivar right: True to set a constraint at the left face of the domain (x[0]=max x[0]), default False (in).
192 @ivar top: True to set a constraint at the left face of the domain (x[1]=min x[1]), default False (in).
193 @ivar bottom: True to set a constraint at the left face of the domain (x[1]=max x[1]), default False (in).
194 @ivar front: True to set a constraint at the left face of the domain (x[2]=min x[2]), default False (in).
195 @ivar back: True to set a constraint at the left face of the domain (x[2]=max x[2]), default False (in).
196 @ivar tol: absolute tolerance for "x=max x" condition, default 1.e-8 (in).
197 """
198 def __init__(self,**kwargs):
199 super(ConstrainerOverBox, self).__init__(**kwargs)
200 self.declareParameter(domain=None, \
201 value=None, \
202 left=False, \
203 right=False, \
204 top=False, \
205 bottom=False, \
206 front=False, \
207 back=False, \
208 tol=1.e-8)
209 self.__value_of_constraint = None
210 self.__location_of_constraint=None
211 def location_of_constraint(self):
212 """
213 return the values used to constrain a solution
214
215 @return: the mask marking the locations of the constraints
216 @rtype: L{escript.Scalar}
217 """
218 if self.__location_of_constraint == None: self.__setOutput()
219 return self.__location_of_constraint
220
221 def value_of_constraint(self):
222 """
223 return the values used to constrain a solution
224
225 @return: values to be used at the locations of the constraints. If
226 C{value} is not given C{None} is rerturned.
227 @rtype: L{escript.Scalar}
228 """
229 if self.__location_of_constraint == None: self.__setOutput()
230 return self.__value_of_constraint
231
232 def __setOutput(self):
233 if self.__location_of_constraint == None:
234 x=self.domain.getX()
235 val=self.value
236 if isinstance(val, int) or isinstance(val, float):
237 shape=()
238 elif isinstance(val, list) or isinstance(val, tuple) :
239 shape=(len(val),)
240 elif isinstance(val, numpy.ndarray):
241 shape=val.shape
242 elif val == None:
243 shape=()
244 else:
245 shape=val.getShape()
246 self.__location_of_constraint=Data(0,shape,x.getFunctionSpace())
247 if self.domain.getDim()==3:
248 x0,x1,x2=x[0],x[1],x[2]
249 if self.left: self.__location_of_constraint+=whereZero(x0-inf(x0),self.tol)
250 if self.right: self.__location_of_constraint+=whereZero(x0-sup(x0),self.tol)
251 if self.front: self.__location_of_constraint+=whereZero(x1-inf(x1),self.tol)
252 if self.back: self.__location_of_constraint+=whereZero(x1-sup(x1),self.tol)
253 if self.bottom: self.__location_of_constraint+=whereZero(x2-inf(x2),self.tol)
254 if self.top: self.__location_of_constraint+=whereZero(x2-sup(x2),self.tol)
255 else:
256 x0,x1=x[0],x[1]
257 if self.left: self.__location_of_constraint+=whereZero(x0-inf(x0),self.tol)
258 if self.right: self.__location_of_constraint+=whereZero(x0-sup(x0),self.tol)
259 if self.bottom: self.__location_of_constraint+=whereZero(x1-inf(x1),self.tol)
260 if self.top: self.__location_of_constraint+=whereZero(x1-sup(x1),self.tol)
261 if not self.value == None:
262 self.__value_of_constraint=self.__location_of_constraint*self.value
263 class ScalarConstrainerOverBox(Model):
264 """
265 Creates a characteristic function for the location of constraints
266 for a scalar value and selects the value from an initial value
267 ate these locations.
268
269 In the case that the spatial dimension is two, the arguments front and back are ignored.
270
271 @ivar domain: domain (in).
272 @ivar left: True to set a constraint at the left face of the domain (x[0]=min x[0]), default False (in).
273 @ivar right: True to set a constraint at the left face of the domain (x[0]=max x[0]), default False (in).
274 @ivar top: True to set a constraint at the left face of the domain (x[1]=min x[1]), default False (in).
275 @ivar bottom: True to set a constraint at the left face of the domain (x[1]=max x[1]), default False (in).
276 @ivar front: True to set a constraint at the left face of the domain (x[2]=min x[2]), default False (in).
277 @ivar back: True to set a constraint at the left face of the domain (x[2]=max x[2]), default False (in).
278 @ivar tol: absolute tolerance for "x=max x" condition, default 1.e-8 (in).
279 """
280 def __init__(self,**kwargs):
281 super(ScalarConstrainerOverBox, self).__init__(**kwargs)
282 self.declareParameter(domain=None, \
283 value=None, \
284 left=False, \
285 right=False, \
286 top=False, \
287 bottom=False, \
288 front=False, \
289 back=False, \
290 tol=1.e-8)
291 self.__value_of_constraint = None
292 self.__location_of_constraint=None
293 def location_of_constraint(self):
294 """
295 return the values used to constrain a solution
296
297 @return: the mask marking the locations of the constraints
298 @rtype: L{escript.Scalar}
299 """
300 if self.__location_of_constraint == None: self.__setOutput()
301 return self.__location_of_constraint
302
303 def value_of_constraint(self):
304 """
305 return the values used to constrain a solution
306
307 @return: values to be used at the locations of the constraints. If
308 C{value} is not given C{None} is rerturned.
309 @rtype: L{escript.Scalar}
310 """
311 if self.__location_of_constraint == None: self.__setOutput()
312 return self.__value_of_constraint
313
314 def __setOutput(self):
315 x=self.domain.getX()
316 self.__location_of_constraint=Scalar(0,x.getFunctionSpace())
317 if self.domain.getDim()==3:
318 x0,x1,x2=x[0],x[1],x[2]
319 d=max(sup(x0)-inf(x0), sup(x1)-inf(x1), sup(x2)-inf(x2))
320 if self.left: self.__location_of_constraint+=whereZero(x0-inf(x0),self.tol*d)
321 if self.right: self.__location_of_constraint+=whereZero(x0-sup(x0),self.tol*d)
322 if self.front: self.__location_of_constraint+=whereZero(x1-inf(x1),self.tol*d)
323 if self.back: self.__location_of_constraint+=whereZero(x1-sup(x1),self.tol*d)
324 if self.bottom: self.__location_of_constraint+=whereZero(x2-inf(x2),self.tol*d)
325 if self.top: self.__location_of_constraint+=whereZero(x2-sup(x2),self.tol*d)
326 else:
327 x0,x1=x[0],x[1]
328 d=max(sup(x0)-inf(x0), sup(x1)-inf(x1))
329 if self.left: self.__location_of_constraint+=whereZero(x0-inf(x0),self.tol*d)
330 if self.right: self.__location_of_constraint+=whereZero(x0-sup(x0),self.tol*d)
331 if self.bottom: self.__location_of_constraint+=whereZero(x1-inf(x1),self.tol*d)
332 if self.top: self.__location_of_constraint+=whereZero(x1-sup(x1),self.tol*d)
333 if not self.value == None:
334 self.__value_of_constraint=self.__location_of_constraint*self.value
335
336 class VectorConstrainerOverBox(Model):
337 """
338 Creates a characteristic function for the location of constraints vector value.
339 In the case that the spatial dimension is two, the arguments front and
340 back as well as the third component of each argument is ignored.
341
342 @ivar domain: domain
343 @ivar left: 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]),
344 default [False,False,False] (in).
345 @ivar right: 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]),
346 default [False,False,False] (in).
347 @ivar top: 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]),
348 default [False,False,False] (in).
349 @ivar bottom: 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]),
350 default [False,False,False] (in).
351 @ivar front: 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]),
352 default [False,False,False] (in).
353 @ivar back: 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]),
354 default [False,False,False] (in).
355 @ivar tol: absolute tolerance for "x=max x" condition, default 1.e-8 (in).
356 """
357 def __init__(self, **kwargs):
358 super(VectorConstrainerOverBox, self).__init__(**kwargs)
359 self.declareParameter(domain=None, \
360 value=None, \
361 left=[False ,False ,False ], \
362 right=[False ,False ,False ], \
363 top=[False ,False ,False ], \
364 bottom=[False ,False ,False ], \
365 front=[False ,False ,False ], \
366 back=[False ,False ,False ], \
367 tol=1.e-8)
368 self.__value_of_constraint = None
369 self.__location_of_constraint=None
370
371 def location_of_constraint(self):
372 """
373 return the values used to constrain a solution
374
375 @return: the mask marking the locations of the constraints
376 @rtype: L{escript.Vector}
377 """
378 if self.__location_of_constraint == None: self.__setOutput()
379 return self.__location_of_constraint
380
381 def value_of_constraint(self):
382 """
383 return the values used to constrain a solution
384
385 @return: values to be used at the locations of the constraints. If
386 C{value} is not given C{None} is rerturned.
387 @rtype: L{escript.Vector}
388 """
389 if self.__location_of_constraint == None: self.__setOutput()
390 return self.__value_of_constraint
391
392 def __setOutput(self):
393 x=self.domain.getX()
394 self.__location_of_constraint=Vector(0,x.getFunctionSpace())
395 if self.domain.getDim()==3:
396 x0,x1,x2=x[0],x[1],x[2]
397 d=max(sup(x0)-inf(x0), sup(x1)-inf(x1), sup(x2)-inf(x2))
398 left_mask=whereZero(x0-inf(x0),self.tol*d)
399 if self.left[0]: self.__location_of_constraint+=left_mask*[1.,0.,0.]
400 if self.left[1]: self.__location_of_constraint+=left_mask*[0.,1.,0.]
401 if self.left[2]: self.__location_of_constraint+=left_mask*[0.,0.,1.]
402 right_mask=whereZero(x0-sup(x0),self.tol*d)
403 if self.right[0]: self.__location_of_constraint+=right_mask*[1.,0.,0.]
404 if self.right[1]: self.__location_of_constraint+=right_mask*[0.,1.,0.]
405 if self.right[2]: self.__location_of_constraint+=right_mask*[0.,0.,1.]
406 front_mask=whereZero(x1-inf(x1),self.tol*d)
407 if self.front[0]: self.__location_of_constraint+=front_mask*[1.,0.,0.]
408 if self.front[1]: self.__location_of_constraint+=front_mask*[0.,1.,0.]
409 if self.front[2]: self.__location_of_constraint+=front_mask*[0.,0.,1.]
410 back_mask=whereZero(x1-sup(x1),self.tol*d)
411 if self.back[0]: self.__location_of_constraint+=back_mask*[1.,0.,0.]
412 if self.back[1]: self.__location_of_constraint+=back_mask*[0.,1.,0.]
413 if self.back[2]: self.__location_of_constraint+=back_mask*[0.,0.,1.]
414 bottom_mask=whereZero(x2-inf(x2),self.tol*d)
415 if self.bottom[0]: self.__location_of_constraint+=bottom_mask*[1.,0.,0.]
416 if self.bottom[1]: self.__location_of_constraint+=bottom_mask*[0.,1.,0.]
417 if self.bottom[2]: self.__location_of_constraint+=bottom_mask*[0.,0.,1.]
418 top_mask=whereZero(x2-sup(x2),self.tol*d)
419 if self.top[0]: self.__location_of_constraint+=top_mask*[1.,0.,0.]
420 if self.top[1]: self.__location_of_constraint+=top_mask*[0.,1.,0.]
421 if self.top[2]: self.__location_of_constraint+=top_mask*[0.,0.,1.]
422 if not self.value == None:
423 self.__value_of_constraint=self.__location_of_constraint*self.value
424 else:
425 x0,x1=x[0],x[1]
426 d=max(sup(x0)-inf(x0), sup(x1)-inf(x1))
427 left_mask=whereZero(x0-inf(x0),self.tol*d)
428 if self.left[0]: self.__location_of_constraint+=left_mask*[1.,0.]
429 if self.left[1]: self.__location_of_constraint+=left_mask*[0.,1.]
430 right_mask=whereZero(x0-sup(x0),self.tol*d)
431 if self.right[0]: self.__location_of_constraint+=right_mask*[1.,0.]
432 if self.right[1]: self.__location_of_constraint+=right_mask*[0.,1.]
433 bottom_mask=whereZero(x1-inf(x1),self.tol*d)
434 if self.bottom[0]: self.__location_of_constraint+=bottom_mask*[1.,0.]
435 if self.bottom[1]: self.__location_of_constraint+=bottom_mask*[0.,1.]
436 top_mask=whereZero(x1-sup(x1),self.tol*d)
437 if self.top[0]: self.__location_of_constraint+=top_mask*[1.,0.]
438 if self.top[1]: self.__location_of_constraint+=top_mask*[0.,1.]
439 if not self.value == None:
440 self.__value_of_constraint=self.__location_of_constraint*self.value[:2]
441
442 class ConstrainerAtBoxVertex(Model):
443 """
444 Creates a characteristic function for the location of constraints
445 for all components of a value and selects the value from an initial value
446 ate these locations.
447
448 In the case that the spatial dimension is two, the arguments front and back are ignored.
449
450 @ivar domain: domain (in).
451 @ivar tol: absolute tolerance for "x=left, front, bottom vertex" condition, default 1.e-8 (in).
452 """
453 def __init__(self,**kwargs):
454 super(ConstrainerAtBoxVertex, self).__init__(**kwargs)
455 self.declareParameter(domain=None, \
456 value=None, \
457 tol=1.e-8)
458 self.__value_of_constraint = None
459 self.__location_of_constraint=None
460 def location_of_constraint(self):
461 """
462 return the values used to constrain a solution
463
464 @return: the mask marking the locations of the constraints
465 @rtype: L{escript.Scalar}
466 """
467 if self.__location_of_constraint == None: self.__setOutput()
468 return self.__location_of_constraint
469
470 def value_of_constraint(self):
471 """
472 return the values used to constrain a solution
473
474 @return: values to be used at the locations of the constraints. If
475 C{value} is not given C{None} is rerturned.
476 @rtype: L{escript.Scalar}
477 """
478 if self.__location_of_constraint == None: self.__setOutput()
479 return self.__value_of_constraint
480
481 def __setOutput(self):
482 if self.__location_of_constraint == None:
483 x=self.domain.getX()
484 val=self.value
485 if isinstance(val, int) or isinstance(val, float):
486 shape=()
487 elif isinstance(val, list) or isinstance(val, tuple) :
488 shape=(len(val),)
489 elif isinstance(val, numpy.ndarray):
490 shape=val.shape
491 elif val == None:
492 shape=()
493 else:
494 shape=val.getShape()
495 if self.domain.getDim()==3:
496 vertex=[inf(x[0]),inf(x[1]),inf(x[2])]
497 else:
498 vertex=[inf(x[0]),inf(x[1])]
499 self.__location_of_constraint=whereZero(length(x-vertex),self.tol)*numpy.ones(shape)
500 if not self.value == None:
501 self.__value_of_constraint=self.__location_of_constraint*self.value
502 class ScalarConstrainerAtBoxVertex(Model):
503 """
504 Creates a characteristic function for the location of constraints
505 for a scalar value and selects the value from an initial value
506 ate these locations.
507
508 In the case that the spatial dimension is two, the arguments front and back are ignored.
509
510 @ivar domain: domain (in).
511 @ivar tol: absolute tolerance for "x=left, front, bottom vertex" condition, default 1.e-8 (in).
512 """
513 def __init__(self,**kwargs):
514 super(ScalarConstrainerAtBoxVertex, self).__init__(**kwargs)
515 self.declareParameter(domain=None, \
516 value=None, \
517 tol=1.e-8)
518 self.__value_of_constraint = None
519 self.__location_of_constraint=None
520 def location_of_constraint(self):
521 """
522 return the values used to constrain a solution
523
524 @return: the mask marking the locations of the constraints
525 @rtype: L{escript.Scalar}
526 """
527 if self.__location_of_constraint == None: self.__setOutput()
528 return self.__location_of_constraint
529
530 def value_of_constraint(self):
531 """
532 return the values used to constrain a solution
533
534 @return: values to be used at the locations of the constraints. If
535 C{value} is not given C{None} is rerturned.
536 @rtype: L{escript.Scalar}
537 """
538 if self.__location_of_constraint == None: self.__setOutput()
539 return self.__value_of_constraint
540
541 def __setOutput(self):
542 x=self.domain.getX()
543 self.__location_of_constraint=Scalar(0,x.getFunctionSpace())
544 if self.domain.getDim()==3:
545 vertex=[inf(x[0]),inf(x[1]),inf(x[2])]
546 else:
547 vertex=[inf(x[0]),inf(x[1])]
548 self.__location_of_constraint=whereZero(length(x-vertex),self.tol)
549 if not self.value == None:
550 self.__value_of_constraint=self.__location_of_constraint*self.value
551
552 class VectorConstrainerAtBoxVertex(Model):
553 """
554 Creates a characteristic function for the location of constraints vector value.
555 In the case that the spatial dimension is two, the arguments front and
556 back as well as the third component of each argument is ignored.
557
558 @ivar domain: domain
559 @ivar comp_mask: list of three boolean. comp_mask[i]==True sets a constraint for the i-th component at the left, front, bottom vertex, default [False,False,False] (in).
560 @ivar tol: absolute tolerance for "x=left, front, bottom vertex" condition, default 1.e-8 (in).
561 """
562 def __init__(self, **kwargs):
563 super(VectorConstrainerAtBoxVertex, self).__init__(**kwargs)
564 self.declareParameter(domain=None, \
565 value=None, \
566 comp_mask=[False, False, False],
567 tol=1.e-8)
568 self.__value_of_constraint = None
569 self.__location_of_constraint=None
570
571 def location_of_constraint(self):
572 """
573 return the values used to constrain a solution
574
575 @return: the mask marking the locations of the constraints
576 @rtype: L{escript.Vector}
577 """
578 if self.__location_of_constraint == None: self.__setOutput()
579 return self.__location_of_constraint
580
581 def value_of_constraint(self):
582 """
583 return the values used to constrain a solution
584
585 @return: values to be used at the locations of the constraints. If
586 C{value} is not given C{None} is rerturned.
587 @rtype: L{escript.Vector}
588 """
589 if self.__location_of_constraint == None: self.__setOutput()
590 return self.__value_of_constraint
591
592 def __setOutput(self):
593 x=self.domain.getX()
594 self.__location_of_constraint=Vector(0,x.getFunctionSpace())
595 if self.domain.getDim()==3:
596 vertex=[inf(x[0]),inf(x[1]),inf(x[2])]
597 msk=numpy.zeros((3,))
598 if self.comp_mask[0]: msk[0]=1
599 if self.comp_mask[1]: msk[1]=1
600 if self.comp_mask[2]: msk[2]=1
601 else:
602 vertex=[inf(x[0]),inf(x[1])]
603 msk=numpy.zeros((2,))
604 if self.comp_mask[0]: msk[0]=1
605 if self.comp_mask[1]: msk[1]=1
606 self.__location_of_constraint=whereZero(length(x-vertex),self.tol)*numpy.ones(shape)
607 if not self.value == None:
608 self.__value_of_constraint=self.__location_of_constraint*self.value
609

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.26