Model Size limit

Need help, or want to share a macro? Post here!
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
mjrich79
Posts: 14
Joined: Wed Dec 28, 2016 8:24 pm

Model Size limit

Post by mjrich79 »

Hi

I am trying to make a porous structure using a macro script. With the help of the forum I have an approach, now my issue the size of my model. I can do about 100 holes a pass in a loop but i run into problems as I approach 10,000 pores. Am I at just a hard limit for the program. I know there are a lot of surfaces to handle but I am planning on just converting to an STL file for a CFD run.

What is the most intensive step of a binary cut? Should I go to a 1 sphere per pass after a certain point? Ideally I need to get about 1 million pores. The CFD is going on a cluster but I have to do geometry on a desktop, (i5 wtih 32GB of memory). Is this just not feasible?

My code

Code: Select all

import Part,numpy

doc = App.newDocument() 
mu, sigma = 0, 0.1 # mean and standard deviation
solid = Part.makeBox(500,500,200)
message = "#Entering Loop"
spheres = []
file = open('myfile1.dat', 'w+')

s1 = solid 
for y in range(0,100):
	spheres = []
	s2 = None
	for x in range(0,10 ):
		radius = numpy.random.normal(loc=20.0, scale=1.0, size=None)
		pos_x = numpy.random.randint(1,500)
		pos_y = numpy.random.randint(1,500)
		pos_z  = numpy.random.randint(1,500)
		pos_vec = FreeCAD.Vector(pos_x,pos_y,pos_z)
		spheres.append(Part.makeSphere(radius, pos_vec))
	s2 = spheres.pop()
	fused = s2.multiFuse(spheres)
	result = s1.cut(fused)
	s1 = result 

Part.show(result)
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Model Size limit

Post by microelly2 »

The time eater will be the rendering call Part.show.
viewtopic.php?f=8&t=19003

If you need only the model for production you can calculate more detailed data.
I have found some limits for presentation in my tasks: 100 000 faces per mesh
so I split the visualization into 100 000 face pieces

If you want to convert your model to stl maybe the fast way is to calculate your mesh structure completly by a script.

maybe the use of a nurbs surface is a way.
viewtopic.php?f=8&t=6973&start=110#p135536
my largest dataset was 4 million poles.
mjrich79
Posts: 14
Joined: Wed Dec 28, 2016 8:24 pm

Re: Model Size limit

Post by mjrich79 »

Can you clarify a bit more? I seem to be crashing out before the display step so I am not sure the Part.show is the issue. I think it is the cut procedure. I was wondering if there is a way to make my part dumber so it becomes easier to handle. I am not sure if there is a way for me to cleanly generate an stl file purely from python given the uncontrolled geometry that can result.

I want to know more about how nurbs could make a less cumbersome representation of a spongelike looking shape.

Thanks for your help!
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: Model Size limit

Post by sgrogan »

mjrich79 wrote:I think it is the cut procedure
Hi mjrich79,
Have you seen this thread? viewtopic.php?f=10&t=18179
multifuse has been in master for a while now. Multicut was merged today.
"fight the good fight"
mjrich79
Posts: 14
Joined: Wed Dec 28, 2016 8:24 pm

Re: Model Size limit

Post by mjrich79 »

hmm, I did not know I was stuck on a core. I will try and see if I can get a build. I am stuck on a windows box though :(
User avatar
sgrogan
Veteran
Posts: 6499
Joined: Wed Oct 22, 2014 5:02 pm

Re: Model Size limit

Post by sgrogan »

mjrich79 wrote:hmm, I did not know I was stuck on a core. I will try and see if I can get a build. I am stuck on a windows box though :(
Win developer builds are here: https://github.com/FreeCAD/FreeCAD/rele ... g/0.17_pre
They are built with OCCT 7.0
"fight the good fight"
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Model Size limit

Post by triplus »

Hi @mjrich79.

Yes i guess you are the first user asking for help and we can respond in a way to suggest for you to try out the new multi-threaded BOA cut operation which has just landed in FreeCAD! Quickly looking at the script you can do some tests and get some data for separate phases:

Geometry creation:

Code: Select all

import Part,numpy

base = Part.makeBox(500,500,200)

spheres = []
for x in range(0,1000):
      radius = numpy.random.normal(loc=20.0, scale=1.0, size=None)
      pos_x = numpy.random.randint(1,500)
      pos_y = numpy.random.randint(1,500)
      pos_z  = numpy.random.randint(1,200)
      pos_vec = FreeCAD.Vector(pos_x,pos_y,pos_z)
      spheres.append(Part.makeSphere(radius, pos_vec))
Cut operation:

Code: Select all

result = base.cut(spheres) # multiple arguments
Show the produced result:

Code: Select all

Part.show(result)
Ideally I need to get about 1 million pores.
If you will establish geometry creation and showing the result of such complexity is manageable what i feel will give you troubles is the Cut operation. I didn't test this with data but i do imagine what happens. In the cut phase each cut makes the base shape more complex. Therefore likely the time needed to complete each new cut increases exponentially. You would therefore likely need a lot of threads to complete 1 million cuts successfully in reasonable time. ;) And i do imagine geometric kernel could be a bit overwhelmed by all the (random) Cut variations you are asking for. And it would take just 1 operation it can't handle to produce invalid shape.

P.S. But the thing is we don't know yet as nobody has tested this yet.
mjrich79
Posts: 14
Joined: Wed Dec 28, 2016 8:24 pm

Re: Model Size limit

Post by mjrich79 »

Sure NP, I will be glad to help. I am going to focus on some runs this weekend.

I suspect I am running into the issue of a cut creating an invalid shape. The code will hang at random times sometimes on cut 634 other times on cut 26,325. I will need to find a way of producing a random cut but not be position so close to another cut that it would produce a jaggy.

Fortunately i only need to do this once. So as long as I get there. Hopefully i do not need the full million i threw that out there as a ballpark upper bound.

Look forward to working you guys and helping the team. I love Freecad and open development projects in general, I just wish i were a better coder to help out more directly.
triplus
Veteran
Posts: 9471
Joined: Mon Dec 12, 2011 4:45 pm

Re: Model Size limit

Post by triplus »

mjrich79 wrote:The code will hang at random times sometimes on cut 634 other times on cut 26,325.
Yes that likely indicates a condition was made geometric kernel can't handle in the cut operation.
User avatar
microelly2
Veteran
Posts: 4688
Joined: Tue Nov 12, 2013 4:06 pm
Contact:

Re: Model Size limit

Post by microelly2 »

I made a calculation of a nurbs with 1000 x 1000 poles and 500 000 random modifications
I cannot display the object surface completly but we can render areas.
but here is a 200 x 200 grid picture

creation time 78 s
memory required 4.8 GB
bp_314.png
bp_314.png (135.79 KiB) Viewed 3635 times
what exactly do you need?

here the 500 x 500 grid picture (84 s)
bp_315.png
bp_315.png (37.4 KiB) Viewed 3635 times
and the 1000 x 1000 grid (102s 5.9 GB RAM)
bp_316.png
bp_316.png (119.19 KiB) Viewed 3635 times
here the "simple testcase" full rendered
Image
Post Reply