### Error: Sorry this triangulation does not deal with intersecting constraints

62

views

0

I'm trying to create a mesh like the filled-in Koch-curve by adding triangles and then generating a mesh. Please see below. There is no boundary supposed to be in-between.

from dolfin import *

from mshr import *

import math

def dist(p1, p2):

return sqrt(pow(p2.x() - p1.x(), 2) + pow(p2.y() - p1.y(), 2))

def findLowerMiddlePoint(p1, p2):

return Point(p1.x() + (p2.x() - p1.x()) * 1/3, p1.y() + (p2.y() - p1.y()) * 1/3)

def findUpperMiddlePoint(p1, p2):

return Point(p1.x() + (p2.x() - p1.x()) * 2/3, p1.y() + (p2.y() - p1.y()) * 2/3)

def findThirdPoint(p1, p2):

dx = p2.x() - p1.x()

dy = p2.y() - p1.y()

alpha = 60./180 * pi

x3 = p1.x() + math.cos(alpha) * dx + math.sin(alpha) * dy

y3 = p1.y() + math.sin(-alpha) * dx + math.cos(alpha) * dy

return Point(x3, y3)

def orderCCW(p1, p2, p3):

val = (p2.y() - p1.y()) * (p3.x() - p2.x()) - (p2.x() - p1.x()) * (p3.y() - p2.y())

if val > 0: return [p1, p3, p2]

else: return [p1, p2, p3]

# Create geometry

polygons = Polygon([Point(10,10), Point(10,10.01), Point(9.99,10)])

def createKochCurve(p1, p2, d):

if d == 0: return 0

lmp = findLowerMiddlePoint(p1, p2)

ump = findUpperMiddlePoint(p1, p2)

thp = findThirdPoint(lmp, ump)

newpoly = Polygon(orderCCW(lmp, ump, thp))

print(lmp.x(), lmp.y())

global polygons

polygons += newpoly

createKochCurve(lmp, thp, d-1)

createKochCurve(ump, thp, d-1)

pstart = Point(0, 0)

pend = Point(1, 0)

depth = 2

createKochCurve(pstart, pend, depth)

mesh = generate_mesh(polygons,100)

Message:

sorry, this triangulation does not deal with

intersecting constraints

[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.

--------------------------------------------------------------------------

from dolfin import *

from mshr import *

import math

def dist(p1, p2):

return sqrt(pow(p2.x() - p1.x(), 2) + pow(p2.y() - p1.y(), 2))

def findLowerMiddlePoint(p1, p2):

return Point(p1.x() + (p2.x() - p1.x()) * 1/3, p1.y() + (p2.y() - p1.y()) * 1/3)

def findUpperMiddlePoint(p1, p2):

return Point(p1.x() + (p2.x() - p1.x()) * 2/3, p1.y() + (p2.y() - p1.y()) * 2/3)

def findThirdPoint(p1, p2):

dx = p2.x() - p1.x()

dy = p2.y() - p1.y()

alpha = 60./180 * pi

x3 = p1.x() + math.cos(alpha) * dx + math.sin(alpha) * dy

y3 = p1.y() + math.sin(-alpha) * dx + math.cos(alpha) * dy

return Point(x3, y3)

def orderCCW(p1, p2, p3):

val = (p2.y() - p1.y()) * (p3.x() - p2.x()) - (p2.x() - p1.x()) * (p3.y() - p2.y())

if val > 0: return [p1, p3, p2]

else: return [p1, p2, p3]

# Create geometry

polygons = Polygon([Point(10,10), Point(10,10.01), Point(9.99,10)])

def createKochCurve(p1, p2, d):

if d == 0: return 0

lmp = findLowerMiddlePoint(p1, p2)

ump = findUpperMiddlePoint(p1, p2)

thp = findThirdPoint(lmp, ump)

newpoly = Polygon(orderCCW(lmp, ump, thp))

print(lmp.x(), lmp.y())

global polygons

polygons += newpoly

createKochCurve(lmp, thp, d-1)

createKochCurve(ump, thp, d-1)

pstart = Point(0, 0)

pend = Point(1, 0)

depth = 2

createKochCurve(pstart, pend, depth)

mesh = generate_mesh(polygons,100)

Message:

sorry, this triangulation does not deal with

intersecting constraints

[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.

--------------------------------------------------------------------------

Community: FEniCS Project

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