This is a read only copy of the old FEniCS QA forum. Please visit the new QA forum to ask questions

repeat function periodically over mesh

+1 vote

Hi all,
I started to use fenics recently for homogenization/multiscale experiments.

I have periodic function $f$, defined on CG1 elements in a small domain $Y$, for example on

eps = 0.1
domain = mshr.Rectangle(Point(0., 0.), Point(eps, eps))
mesh = mshr.generate_mesh(domain, 32)
V = FunctionSpace(mesh, "CG", 1)

$f$ really is the solution of a PDE with periodic constraints on V, but let's take

ex = Expression("sin(x[0]*2*pi/L)*sin(x[1]*2*pi/L)", L=eps)
f = interpolate(ex, V)

Now there is a second domain, $\Omega$, e.g. the square $(0,1)\times(0,1)$, which (in theory) consists of copies of the small periodic domain.
I need to repeat the function $f$ over the whole domain $\Omega$, so that in the example I get one function $f_\Omega$ that contains $10\times10$ $f$-sines over the unit square.

Is there some way to do this efficiently with dolfin? Like interpolate only to a portion of a domain, or stack the $Y$ meshs together somehow to build up $\Omega$..

Thanks, any help is much appreciated :)
Best, David

asked Nov 19, 2015 by dajuno FEniCS User (4,140 points)
edited Nov 24, 2015 by dajuno

Hi, just to clarify your question. Say you have computed the solution $u$ on UnitSquareMesh(1, 1) and this domain would be your 'cell' that needs to be periodically repeated. You then have other function $f$ setup on `RectangleMesh(Point(0, 0), Point(4, 4), 2, 2)'. Are you asking for how to assign to $f$ the values of $u$ such that you get the 'tiling'?

Sorry for the confusing and unnecessary details... I guess it can be reduced to what you said!

Okay, you should also specify the finite element type you had in mind for the spaces of $u$ and $f$. I assume they are the same.

Okay. It's just linear Lagrange (V = FunctionSpace(mesh, "CG", 1, constrained_domain=PeriodicBoundary()))

I edited the question to make it more understandable.

...