Hi all,
I am loading a mesh from gmsh and marking the boundaries (mesh can be found here. I wish to mark the first quadrant as ‘2’, the fourth quadrant as ‘10’ and the second and third quadrant as ‘20’. Those boundaries are not getting marked properly (as seen in the paraview from loading pvd file). Please can anyone tell me the reason for not getting marked properly and how to fix it?
Thanks in advance.
from dolfin import *
from fenics import *
import numpy as np
import math
import mshr
import dolfin
from mshr import *
import os
parameters["allow_extrapolation"]=True
dir_path = os.path.dirname(os.path.realpath(__file__))
R = 10.00 # Radius of the circular part
mesh = Mesh("mesh.xml")
class centre(SubDomain):
def inside(self,x, on_boundary):
tol = 3e-1
return (near(x[0],0.00,tol) and near(x[1],0.00,tol))
class circle_boundary(SubDomain):
def inside(self,x, on_boundary):
tol = 1.0
r=(x[0]**2+x[1]**2)**0.5
return ( R-r < tol) and on_boundary
class circle_load(SubDomain):
def inside(self,x, on_boundary):
tol = 5e-1
return ((R+tol > x[0] > 0-tol and R+tol > x[1] > 0-tol) and on_boundary)
class circle_bound1(SubDomain):
def inside(self,x, on_boundary):
tol = 5e-1
return (( x[0] > 0 and x[1] < 0) and on_boundary)
class circle_bound2(SubDomain):
def inside(self,x, on_boundary):
tol = 5e-1
return ((0> x[0] > -R and R > x[1] > -R) and on_boundary)
boundaries = MeshFunction("size_t",mesh,mesh.topology().dim()-1)
boundaries.set_all(0)
centre= centre()
circle_boundary = circle_boundary()
circle_load = circle_load()
circle_bound1 = circle_bound1()
circle_bound2 = circle_bound2()
#circle_conc = circle_boundary - circle_load
centre.mark(boundaries,5)
circle_boundary.mark(boundaries,1)
circle_load.mark(boundaries,2)
circle_bound1.mark(boundaries,10)
circle_bound2.mark(boundaries,20)
meshfile=File(dir_path+'/mesh.pvd')
meshfile<<mesh
#plot(boundaries, interactive=True)
boundary_file = File(dir_path+'/boundaries1.pvd')
boundary_file <<boundaries
raise SystemExit()