project(): boundary oszillations, subdomain restrictions
I discovered two ways in which Dolfin's project() behaves that I wouldn't have expected. Both are highlighted by the following setup.
Suppose you have a domain Omega=[0,3]x[-1,1] that divides into a couple of subdomains. We would like to create the function
( 1/x[0] for the subdomains 1,2,3,
f(x) = (
( 0 everywhere else.
(The subdomains 1,2,3 don't contain points with x[0]==0.)
The definition of f() can happen via an expression. When plotting the function, it has to be projected onto a meaningful space, e.g., FunctionSpace(mesh, 'CG', 1). When using CG1, oszillations around the boundary of the subdomains 1,2,3 occur.
What is the reason for those?
(Using DG0 avoids avoids such oszillations.)
Now we would like to restrict f to subdomain 4 (which does contain points x[0]==0). We would expect it to be 0 throughout.
Overever, when projecting onto
submesh = SubMesh(mesh, subdomains, 4)
Vsub = FunctionSpace(
tmp = project(oneOverX, Vsub)
the expression 1/x[0] is evaluated with x[0]==0.
Why is that?
The complete failing code is
=======
from dolfin import *
# -------
def _main():
# Read the mesh and its subdomains.
mesh = Mesh('coils2d.xml')
subdomains = MeshFunction(
coil_indices = [1,2,3]
class OneOverX(
def eval_cell(self, values, x, cell):
k = subdomains.
try:
except ValueError:
oneOverX = OneOverX()
# Plot it.
V = FunctionSpace(mesh, 'CG', 1)
File(
# Project onto subdomain.
submesh = SubMesh(mesh, subdomains, 4)
Vsub = FunctionSpace(
tmp = project(oneOverX, Vsub)
File(
return
# -------
if __name__ == '__main__':
_main()
# -------
=======
and the domain data can be retrieved from http://
Question information
- Language:
- English Edit question
- Status:
- Expired
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply: