Doubly-periodic BC syntax
I am trying to solve a problem on a doubly-periodic domain. However, the answer is clearly wrong, as it has differing values at "equivalent" nodes at the corners. This strongly suggests that the 4 corners are not being contracted to a single degree of freedom. I have no idea whether my program is wrong, or whether this is a bug, so I'm asking whether my code below is correct.
from dolfin import *
set_log_
mesh = UnitSquare(1, 1)
E = FunctionSpace(mesh, 'CG', 2)
S = FunctionSpace(mesh, 'BDM', 1)
class PeriodicBoundar
def inside(self, x, on_boundary):
return on_boundary and ( (x[0]<DOLFIN_EPS and x[1]<(1-
def map(self, x, y):
if (x[0] > (1 - DOLFIN_EPS)) and (x[1] > (1 - DOLFIN_EPS)):
y[0] = x[0] - 1
y[1] = x[1] - 1
elif x[0] > (1 - DOLFIN_EPS):
y[0] = x[0] - 1
y[1] = x[1]
else:
y[0] = x[0]
y[1] = x[1] - 1
bcEp = PeriodicBC(E, PeriodicBoundary())
u2_expr = Expression(("1 + x[0]*(1-
u2 = Function(
v = TrialFunction(E)
w = TestFunction(E)
om2 = Function(E)
solve(inner(
print om2.vector(
As of the current dev version, the node numbering for P2 elements in UnitSquare(1,1) appears to be:
8 7 4
6 3 1
5 0 2
The difference between the values at 1 and 6 is 0, but the difference between the 0-7 pair is O(10^-16). None of the corner pairs match. The 5-8 pair has a difference of O(10^-16), while all the other pairs have O(1) differences.
In the UnitSquare(2,2) case, the numbering seems to be
24 23 19 12 11
22 21 18 10 08
20 17 16 06 03
15 13 07 05 01
14 09 04 00 02
The 0-12 and 4-19 pairs weren't numerically identical, with errors at the 10^-16 / 10^-17 scale. Again, none of the corner pairs match, while the horizontal pairs 8-22, 3-20, 1-15 have differences that are numerically 0.
Question information
- Language:
- English Edit question
- Status:
- Answered
- For:
- DOLFIN Edit question
- Assignee:
- No assignee Edit question
- Last query:
- Last reply:
This question was reopened
- by Andrew McRae
Can you help with this problem?
Provide an answer of your own, or ask Andrew McRae for more information if necessary.