### Remesh from boundary

195

views

0

Hi,

I am trying to remesh the interior of a mesh keeping the boundary. I extracted the boundary from the initial mesh and then I passed the coordinates of the points to mshr. Finally I tried to generate a new mesh as a Polygon where the vertices are the points of the boundary of the old mesh.

Here there is a code that reproduce the problem:

The error message that I get is:

Probably the problem is that the function

The version of dolfin is 2017.1, installed through the Ubuntu PPA.

Thanks,

Davide

I am trying to remesh the interior of a mesh keeping the boundary. I extracted the boundary from the initial mesh and then I passed the coordinates of the points to mshr. Finally I tried to generate a new mesh as a Polygon where the vertices are the points of the boundary of the old mesh.

Here there is a code that reproduce the problem:

```
from dolfin import *
import mshr
mesh = UnitSquareMesh(5,5)
bmesh = BoundaryMesh(mesh, "exterior")
bmesh_coord = bmesh.coordinates()[:]
points=[]
for i in xrange(len(bmesh_coord)):
points.append(Point(bmesh_coord[i][0],bmesh_coord[i][1]))
new_pol = mshr.Polygon(points)
new_mesh = mshr.generate_mesh(new_pol, 20)
```

The error message that I get is:

```
[0]PETSC ERROR: ------------------------------------------------------------------------
[0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range
[0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger
[0]PETSC ERROR: or see http://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind
[0]PETSC ERROR: or try http://valgrind.org on GNU/linux and Apple Mac OS X to find memory corruption errors
[0]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and run
[0]PETSC ERROR: to get more information on the crash.
--------------------------------------------------------------------------
MPI_ABORT was invoked on rank 0 in communicator MPI_COMM_WORLD
with errorcode 59.
NOTE: invoking MPI_ABORT causes Open MPI to kill all MPI processes.
You may or may not see output from other processes, depending on
exactly when Open MPI kills them.
--------------------------------------------------------------------------
```

Probably the problem is that the function

`bmesh.coordinates()`

returns the coordinates of the boundary vertices but they are not ordered whilst `mshr.Polygon(points)`

requires that the points are ordered in a counter-clockwise order.The version of dolfin is 2017.1, installed through the Ubuntu PPA.

Thanks,

Davide

Community: FEniCS Project

### 2 Answers

0

I can't comment on whether using mshr is the right approach, but the perhaps you can do something using connectivity information available in 'bmesh.cells()' to get your ordering correct. If you manage to get it working please post a MWE with the solution.

0

Hi, I have done exactly you code working for an unstructured mesh. The problem is that mshr assumes that your points are ordered counterclockwise, and I guess this is not the case for your points. An easy way to solve this is to take your first point and then for every point, append the closest one. This could be clockwise instead of counterclockwise... but you can always do list[::-1]. You can also just calculate the angle and look for the point which gives the smallest angle (always measure with respect to a point inside your domain... which I am assuming to be a star-shaped domain), but I am too lazy so I didn't do that. Let me know if it works.

Best regards!

Best regards!

Please login to add an answer/comment or follow this question.