Periodic boundary conditions multiplied by a constant

Hi, I’m trying to implement periodic boundary conditions on a 2D square mesh. I implement the example in the doc, like this:

# Sub domain for Periodic boundary condition
class PeriodicBoundary(SubDomain):

    # Left boundary is "target domain" G
    def inside(self, x, on_boundary):
        return bool(x[0] < DOLFIN_EPS and x[0] > -DOLFIN_EPS and on_boundary)

    # Map right boundary (H) to left boundary (G)
    def map(self, x, y):
        y[0] = x[0] - 1.0
        y[1] = x[1]

But, I need to multiply a boundary by a constant (m):

w(0,y) = -m*(w(1,y))

I’m trying the next code, but m multiplies the coordinate but not the value of the node:

# Sub domain for Periodic boundary condition
class PeriodicBoundary(SubDomain):

    # Left boundary is "target domain" G
    def inside(self, x, on_boundary):
        return bool(x[0] < DOLFIN_EPS and x[0] > -DOLFIN_EPS and on_boundary)

    # Map right boundary (H) to left boundary (G)
    def map(self, x, y):
        y[0] = -m*(x[0] - 1.0)
        y[1] = x[1]

How do I apply the periodic boundary conditions multiplied by a constant?

Thank you.

You can use my extension to dolfinx called dolfinx_mpc. A demo using periodic conditions is found here: dolfinx_mpc/demo_periodic_geometrical.py at master · jorgensd/dolfinx_mpc · GitHub
and as you can see from the documentation, you can send in a scale parameter: dolfinx_mpc/multipointconstraint.py at master · jorgensd/dolfinx_mpc · GitHub

1 Like

def map is the mapping of the coordinate, and thus your code is just multiplying the coordinate as you said.

So, you need to modify the value itself somewhere else. If you could provide your code, maybe people can help you detecting how to modify the value of the node.