Forum Message

 

 

We have moved the forum to https://forum.ngsolve.org . This is an archived version of the topics until 05/05/23. All the topics were moved to the new forum and conversations can be continued there. This forum is just kept as legacy to not invalidate old links. If you want to continue a conversation just look for the topic in the new forum.

Notice

The forum is in read only mode.

Multiple Cylinder issue

More
3 years 8 months ago - 3 years 8 months ago #3031 by Simulator

Attachment not found

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!
Last edit: 3 years 8 months ago by Simulator. Reason: Creating Attachments
More
3 years 8 months ago - 3 years 8 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()
Last edit: 3 years 8 months ago by Simulator. Reason: Attachment did not work, now giving code as text
More
3 years 8 months ago #3046 by cwinters
Replied by cwinters on topic Multiple Cylinder issue
Hello,

the command
Code:
Cylinder(p1,p2,radius)
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
Code:
Cylinder(p1,p2,radius)*Plane(p1,vec1)*Plane(p2,vec2)
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:
Code:
Cylinder(p1,p2,radius)*Plane(p1,vec1)-Plane(p2,vec2)
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
More
3 years 8 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!
Time to create page: 0.121 seconds