Hey there,
my domain is [0, length] x [0, length] x [0,length] cube created with mshr. I want that the opposite xz and yz planes of the domain are periodic and did the following:
class PeriodicBoundary(SubDomain):
def inside(self, y, on_boundary):
#left and front boundary are target domain
return bool((near(y[0],0) and on_boundary) \
or (near(y[1],0) and on_boundary)) \
and (not(near(y[0],length) or near(y[1],length)))
def map(self,x,y):
#map right and back boundary to target domain
if near(x[0], length):
y[0] = x[0] - length
y[1] = x[1]
y[2] = x[2]
elif near(x[1], length):
y[0] = x[0]
y[1] = x[1] - length
y[2] = x[2]
else:
y[0] = -1000
y[1] = -1000
y[2] = -1000
I included the else condition because I get otherwise the following error:
*** -------------------------------------------------------------------------
*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at
***
*** fenics-support@googlegroups.com
***
*** Remember to include the error message listed below and, if possible,
*** include a *minimal* running example to reproduce the error.
***
*** -------------------------------------------------------------------------
*** Error: Unable to periodic boundary mapping.
*** Reason: Need to set coordinate 0 in sub_domain.map.
*** Where: This error was encountered inside PeriodicBoundaryComputation.cpp.
*** Process: 0
***
*** DOLFIN version: 2018.1.0
*** Git changeset: 948dc42cc4e06ed9227d0201ad50f94ac94cbf9f
*** -------------------------------------------------------------------------
I found this, which was my guidance: https://fenicsproject.org/qa/262/possible-specify-more-than-one-periodic-boundary-condition/
Why do I have to include the else condition? Even with the else condition the code doesn’t work as I want to. I tried to set one of each periodic pair to 0, but the dofs are not mapped to each other and therefore only one wall is 0. What am I missing?
I copied this from the allanswered.
Thanks in advance
Kind regards
Max