# Periodic Boundary Conditions with OCC and a Rotational Transformation

Hello NGSolve folks,

I have following code:

``````from netgen.occ import *
from ngsolve import *
from netgen.meshing import IdentificationType
b = Box((-1.0, -0.5, 0), (0.0, 0.5, 1.0))
a = Box((0.0, -0.5, 0), (1.0, 0.5, 1.0))
a.faces.Max(Z).col = (1, 0, 0)
b.faces.Max(Z).col = (0, 0, 1)
trafo = Rotation(Axis((0, 0, 0), Y), 180)
a.faces.Max(Z).Identify(b.faces.Max(Z), "periodic", IdentificationType.PERIODIC, trafo)
geo_objects = Glue([a, b])
geo = OCCGeometry(geo_objects)
mesh = Mesh(geo.GenerateMesh(maxh=0.4))
Draw(mesh)
``````

where I would like to specify rotational periodicity between the red and blue face.
Unfortunately it seems that the identifcation is not successful
(no Map face 1 → 2 output; no identified points).

I have tried different configurations, e.g., a block between so that there is no shared
edge - but this did not help.

Any suggestions ? Thank you.

(likely related with OpenCascade geometry Periodic Boundary Conditions - Kunena ?)

Hi Phil,

I don’t know if you check the forum regularly so I am writing to you in case you get a notification.

Professor Schöberl answered to the other post with the solution to this problem:

We were not giving the correct transformation.

Best,
Alessio

Thanks @acesarano for sharing your solution.

I think this might be a different issue. For example, while following code works:

``````from netgen.occ import *
from ngsolve import *
from netgen.meshing import IdentificationType

half_gap_distance = 0.1

b = Box((-1.0, -0.5, 0), (-half_gap_distance, 0.5, 1.0))
a = Box((half_gap_distance, -0.5, 0), (1.0, 0.5, 1.0))

a.faces.Max(Z).col = (1, 0, 0)
b.faces.Max(Z).col = (0, 0, 1)

trafo = Rotation(Axis((0, 0.5, 1), Y), 180)

a.faces.Max(Z).Identify(b.faces.Max(Z), "periodic", IdentificationType.PERIODIC, trafo)

geo_objects = Glue([a, b])

geo = OCCGeometry(geo_objects)
mesh = Mesh(geo.GenerateMesh(maxh=0.4))
``````

Reducing the gap distance to 0 (so that the cubes touch each other), the identification fails:

``````half_gap_distance = 0.0
``````

Shows no identified points.

Many thanks,

Paul