/[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 3259 - (show annotations)
Mon Oct 11 01:48:14 2010 UTC (8 years, 11 months ago) by jfenwick
File MIME type: text/x-python
File size: 28677 byte(s)
Merging dudley and scons updates from branches

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26