Using a mesh function to move a boundary.

Asked by Douglas Brinkerhoff

I'm attempting to implement a free surface problem, and I need to move a subdomain of a mesh boundary. The mesh boundary is complicated, so a logical expression defining the boundary will not suffice. Instead, I have the relevant subdomain marked with a mesh function. Is there a way to move boundary mesh coordinates based on a mesh function? For example, say my surface is marked with a 1 in a meshfunction, is there a way to say:

for x in boundary_mesh.coordinates() where mesh_function == 1
    x[0] += f(x[0],x[1])
    x[1] += g(x[0],x[1])

Question information

Language:
English Edit question
Status:
Answered
For:
DOLFIN Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
Anders Logg (logg) said :
#1

On Thu, Sep 29, 2011 at 08:30:52PM -0000, Douglas Brinkerhoff wrote:
> New question #172754 on DOLFIN:
> https://answers.launchpad.net/dolfin/+question/172754
>
> I'm attempting to implement a free surface problem, and I need to move a subdomain of a mesh boundary. The mesh boundary is complicated, so a logical expression defining the boundary will not suffice. Instead, I have the relevant subdomain marked with a mesh function. Is there a way to move boundary mesh coordinates based on a mesh function? For example, say my surface is marked with a 1 in a meshfunction, is there a way to say:
>
> for x in boundary_mesh.coordinates() where mesh_function == 1
> x[0] += f(x[0],x[1])
> x[1] += g(x[0],x[1])

Yes. Iterate over the facets of the mesh, check if they have the
correct marker using your mesh function and in that case get the
vertices of the facet in question and move them. Some vertices will
then be moved twice so you need to keep track for that, for example by
putting those vertex indices into a set.

Here's some quick untested code:

vertex_indices = set()
for facet in facets(mesh):
    if mesh_function[facet] != 1:
        continue
    for vertex in vertices(facet):
        vertex_indices.add(vertex.index())

x = mesh.coordinates()
for vertex_index in vertex_indices:
    x[i] += <something>

--
Anders

Can you help with this problem?

Provide an answer of your own, or ask Douglas Brinkerhoff for more information if necessary.

To post a message you must log in.