1 |
jgs |
117 |
# $Id$ |
2 |
|
|
|
3 |
|
|
""" |
4 |
|
|
@brief A simple projector for rank 0 and rank 1 Data to a continuous |
5 |
|
|
function space. |
6 |
|
|
""" |
7 |
|
|
|
8 |
|
|
from esys.escript import * |
9 |
|
|
from esys.linearPDEs import LinearPDE |
10 |
|
|
import numarray |
11 |
|
|
|
12 |
|
|
class Projector: |
13 |
|
|
|
14 |
|
|
def __init__(self, domain, rank = 0, reduce = False): |
15 |
|
|
""" |
16 |
|
|
@brief Create a continuous function space projector for a domain. |
17 |
|
|
|
18 |
|
|
@param domain Domain of the projection. |
19 |
|
|
@param rank Rank of data to project. |
20 |
|
|
@param reduce Flag to reduce projection order. |
21 |
|
|
""" |
22 |
|
|
dim = rank * domain.getDim() + (1 - rank) |
23 |
|
|
self.pde = LinearPDE(domain, numEquations = dim, numSolutions = dim) |
24 |
|
|
self.pde.setLumping(True) |
25 |
|
|
self.pde.setReducedOrderTo(reduce) |
26 |
|
|
if rank == 0: |
27 |
|
|
D = 1 |
28 |
|
|
elif rank == 1: |
29 |
|
|
D = numarray.identity(domain.getDim()) |
30 |
|
|
else: |
31 |
|
|
raise Exception("Projection restricted to rank 0 or rank 1 Data.") |
32 |
|
|
self.pde._setValue(D = D) |
33 |
|
|
return |
34 |
|
|
|
35 |
|
|
def __del__(self): |
36 |
|
|
return |
37 |
|
|
|
38 |
|
|
def __call__(self, value): |
39 |
|
|
""" |
40 |
|
|
@brief Execute a projection to a continous function space on value. |
41 |
|
|
|
42 |
|
|
@param value The value to be projected. |
43 |
|
|
""" |
44 |
|
|
self.pde._setValue(Y = value) |
45 |
|
|
return self.pde.getSolution() |