/[escript]/branches/3.4.1/modellib/py_src/geometry.py
ViewVC logotype

Contents of /branches/3.4.1/modellib/py_src/geometry.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4587 - (show annotations)
Wed Dec 11 06:17:09 2013 UTC (5 years, 3 months ago) by jfenwick
File MIME type: text/x-python
File size: 28911 byte(s)
Preparation begins

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

Properties

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

  ViewVC Help
Powered by ViewVC 1.1.26