- Thank you received: 0
Multiple Cylinder issue
4 years 3 months ago - 4 years 3 months ago #3031
by Simulator
Hello NGSolve Users,
I am trying to model a flat coil to simulate the magnetic field of it. As a first step, I am creating the geometry by adding up Cylinder objects to the desired shape.
FGeometry issue (picture attached):
When adding up the Cylinders by the "+" operator, it draws holes in the tubes, which are on the same axis like the inner tubes. As far as I understood from the docs, "+" should only "glue" overlapping points. Here it seems like it is also removing points on the same axis.
Second issue (code attached):
When trying to create the mesh, it stays at "Find points" forever. Am I doing something wrong with the GenerateMesh() command?
I would appreciate any help.
Thanks a lot and best regards!
Multiple Cylinder issue was created by Simulator
Attachment not found
I am trying to model a flat coil to simulate the magnetic field of it. As a first step, I am creating the geometry by adding up Cylinder objects to the desired shape.
FGeometry issue (picture attached):
When adding up the Cylinders by the "+" operator, it draws holes in the tubes, which are on the same axis like the inner tubes. As far as I understood from the docs, "+" should only "glue" overlapping points. Here it seems like it is also removing points on the same axis.
Second issue (code attached):
When trying to create the mesh, it stays at "Find points" forever. Am I doing something wrong with the GenerateMesh() command?
I would appreciate any help.
Thanks a lot and best regards!
Last edit: 4 years 3 months ago by Simulator. Reason: Creating Attachments
4 years 3 months ago - 4 years 3 months ago #3032
by Simulator
Replied by Simulator on topic Multiple Cylinder issue
Seems like the attachments did not work, here is the code:
from ngsolve import *
from ngsolve.solve import Draw, Redraw
from netgen.csg import *
# Creating the coil geometry
# Format of endpoints: end_point = [xi1, yi1, zi1, xi2, yi2, zi2, r]
end_points = []
radius = 6
end_points.append([0, 0, 0, 198.179, 0, 0, radius])
end_points.append([198.179, 0, 0, 198.179 , 280, 0, radius])
end_points.append([198.179, 280, 0, -182.184, 280, 0, radius])
end_points.append([-182.184, 280, 0, -182.184, 20, 0, radius])
end_points.append([-182.184, 20, 0, 168.162, 20, 0, radius])
end_points.append([168.162, 20, 0, 168.162, 260, 0, radius])
end_points.append([168.162, 260, 0, -152.166, 260, 0, radius])
# Create tubes from end_points vecotr
tubes = []
for end_point in end_points:
tubes.append(Cylinder(Pnt(end_point[0],end_point[1],end_point[2]), Pnt(end_point[3],end_point[4],end_point[5]), end_point[6]))
# Join tubes to coil geometry
coil = tubes[0]
for i in range (1,len(tubes)):
coil = coil + tubes
# Create geometry
geo = CSGeometry()
geo.Add(coil)
# Draw Geometry
geo.Draw()
# Generate Mesh
mesh = geo.GenerateMesh()
from ngsolve import *
from ngsolve.solve import Draw, Redraw
from netgen.csg import *
# Creating the coil geometry
# Format of endpoints: end_point = [xi1, yi1, zi1, xi2, yi2, zi2, r]
end_points = []
radius = 6
end_points.append([0, 0, 0, 198.179, 0, 0, radius])
end_points.append([198.179, 0, 0, 198.179 , 280, 0, radius])
end_points.append([198.179, 280, 0, -182.184, 280, 0, radius])
end_points.append([-182.184, 280, 0, -182.184, 20, 0, radius])
end_points.append([-182.184, 20, 0, 168.162, 20, 0, radius])
end_points.append([168.162, 20, 0, 168.162, 260, 0, radius])
end_points.append([168.162, 260, 0, -152.166, 260, 0, radius])
# Create tubes from end_points vecotr
tubes = []
for end_point in end_points:
tubes.append(Cylinder(Pnt(end_point[0],end_point[1],end_point[2]), Pnt(end_point[3],end_point[4],end_point[5]), end_point[6]))
# Join tubes to coil geometry
coil = tubes[0]
for i in range (1,len(tubes)):
coil = coil + tubes
# Create geometry
geo = CSGeometry()
geo.Add(coil)
# Draw Geometry
geo.Draw()
# Generate Mesh
mesh = geo.GenerateMesh()
Last edit: 4 years 3 months ago by Simulator. Reason: Attachment did not work, now giving code as text
4 years 3 months ago #3046
by cwinters
Replied by cwinters on topic Multiple Cylinder issue
Hello,
the command
defines an infinite cylinder, where the two points p1, p2 just define the axis. Thus you have to cut the cylinder with another object.
The visualization of the geometry might help to see what you defined, but it is not always accurate. Looks like it got confused by the intersection of the infinite cylinders.
The "+" operator leads to the union of objects.
Attached is a running version of you python file. Important is to cut the cylinders
where the vectors of the planes have to point outward.
When two objects have a common plane, it is advisable to use the same plane to cut them. You can use the following syntax:
where the cylinder is cut with the plane at p2, but using the "-" operator turns the vector vec2 performing the intersection. See also
CSGeometry
.
Best,
Christoph
the command
Code:
Cylinder(p1,p2,radius)
The visualization of the geometry might help to see what you defined, but it is not always accurate. Looks like it got confused by the intersection of the infinite cylinders.
The "+" operator leads to the union of objects.
Attached is a running version of you python file. Important is to cut the cylinders
Code:
Cylinder(p1,p2,radius)*Plane(p1,vec1)*Plane(p2,vec2)
When two objects have a common plane, it is advisable to use the same plane to cut them. You can use the following syntax:
Code:
Cylinder(p1,p2,radius)*Plane(p1,vec1)-Plane(p2,vec2)
Best,
Christoph
Attachments:
4 years 3 months ago #3048
by Simulator
Replied by Simulator on topic Multiple Cylinder issue
Dear Christoph,
thanks a lot for your detailed answer and the example code. Indeed I did not realize the necessity to cut the cylinders by the planes, which is clear now.
Thanks again and best regards!
thanks a lot for your detailed answer and the example code. Indeed I did not realize the necessity to cut the cylinders by the planes, which is clear now.
Thanks again and best regards!
Time to create page: 0.097 seconds