-
Notifications
You must be signed in to change notification settings - Fork 52
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FE - Finite Elements #68
base: master
Are you sure you want to change the base?
Conversation
So- if I understand this, the idea is to generate a set of tetrahedra who collectively make up the volume of the model. If you want to use it tor FEA I assume the tetraheda should be small and roughly the same size. There's a terminology issue that needs to be addressed: Marching cubes generates surface triangles. That is: the "cubes" is a reference to the sampling of the field - not to the result. So: sample the field with "marching X" and generate tetrahedra instead of surface triangles. Works for 2D as well. ie: generate 2D triangle instead of lines. |
@deadsy Yes, that's right 👍
I believe it depends on the desired accuracy and the complexity of the shape. To achieve the same accuracy throughout a 3D model, simple regions may need fewer finite elements. Complex regions may need more. As the initial implementation, the same size for all finite elements might be a good start ✔️
Right. Great point. I'm still not sure which sampling is more suitable. It is mentioned that:
Maybe the above sentence means marching tetrahedra is the preferred sampling. I'm not sure 🙄 |
You need to take a punt at saddle points and you may get it wrong. In practice it doesn't seem to be too much of an issue. At least I haven't had to deal with it. See case 10.... If you want to keep things simple you could just adapt marching cubes/squares to generate tetrahedra/triangles. I haven't looked at your code yet... |
To be able to easily debug the code, I guess I'm going to implement the output API first, then work on the sampling algorithm. To develop the output API, some constant hard-coded tetrahedra vertices may be used. |
4-node tetrahedral elementCalculiX solver documentation mentions:
10-nodeFrom the same document:
Pick 4-nodeLet's keep it simple. Let's consider 4-node tetrahedral element (C3D4) for the initial implementation. Later, it can be expanded to 10-node. |
TIL... about FEA nodes. I still don't understand why adding edge nodes to the TET that appear to be linear combinations of the corner nodes makes them better. |
CalculiX solver documentation mentions: As far as I know, stress and strain are distributed linear for one and quadratic for the other 🙂 |
Trying to figure out how to adapt the marching cubes algorithm: https://math.stackexchange.com/q/4648068/197913 UPDATE: About the tools to do so: https://softwarerecs.stackexchange.com/q/86486/12269 |
Conceptually it seems simple enough. For each of those 256 cases work, break up the defined volume into tetrahedra. But yes- you don't want to do it by hand. fwiw- doing the 2d form of the same thing can lead to insights. |
MC tablesTables of marching cubes algorithm are better understood now. Edge tableTo determine which edges are involved with triangle creation: // 8 vertices -> 256 possible inside/outside combinations
// A 1 bit in the value indicates an edge with a line end point.
// 12 edges -> 12 bit values, note the fwd/rev symmetry
var mcEdgeTable = [256]int{ /* ... */ }
// Example: mcEdgeTable[3] is:
//
// 0x030a
//
// It means:
// 0b 0000 0011 0000 1010
// It means edges are:
// 9, 8, 3, 1
// Min possible:
// 0b 0000 0000 0000 0000 i.e. 0x0000
// Max possible:
// 0b 0000 1111 1111 1111 i.e. 0x0fff Pair tableTo define how // These are the vertex pairs for the edges
var mcPairTable = [12][2]int{
{0, 1}, // Edge 0
{1, 2}, // Edge 1
{2, 3}, // Edge 2
{3, 0}, // Edge 3
{4, 5}, // Edge 4
{5, 6}, // Edge 5
{6, 7}, // Edge 6
{7, 4}, // Edge 7
{0, 4}, // Edge 8
{1, 5}, // Edge 9
{2, 6}, // Edge 10
{3, 7}, // Edge 11
} Triangle tableTo determine the edge order for each triangle being created. Each triangle is created by connecting // specify the edges used to create the triangle(s)
var mcTriangleTable = [256][]int{ /* ... */ }
// Example: mcTriangleTable[3] is:
//
// {1, 8, 3, 9, 8, 1},
//
// It means:
// 1 of 2 triangles connecting edge 1 to edge 8 to edge 3
// 1 of 2 triangles connecting edge 9 to edge 8 to edge 1 NotesRepeated edgeAn edge can be repeated multiple times by one of the However, each edge can have only a single point on it. An edge cannot have multiple points on it. Because each edge can only have a single point with a |
btw- the rest of the code has been written to follow the strictures of golint. I realise this is deprecated, but it is a standard. |
Possible optimization
|
|
AMRAmong the optimizations here: #68 (comment) Adaptive mesh refinement AMR may have the highest priority. It would be helpful regardless of the FEA engine. Octree space subdivisionFile |
Those 256 cases from |
TetrahedronThe tetrahedron element is implemented using this repository: https://github.com/Megidd/tetrahedron-table Now both hexahedron and tetrahedron can be used to represent a 3D mode. TestAn STL file of WELSIM software i.e.
|
Good STL, good FEAThe last comment tested a good STL file of WELSIM software: This STL had no faults, so the FEA had no problem too. Faulty STL, faulty FEAWhen input STL model has faults, the output FEA model can be difficult for math solvers. Throwing an error like this:
Or this error:
RepairA repair stage may be required. I mean we may need a repair stage after finite elements are generated. The repair main objectives might be:
|
VoxelWe are currently storing the finite elements by their containing voxel. Every voxel is corresponding to a cube of the marching cubes algorithm. Voxel & repairA repair logic requires knowing the neighborhood of elements. Our voxel data structure may help with repair logic. |
ArtifactInside the 3D model some artifacts are observed. The artifact starts at some layers and it grows layer by layer. I ran out if ideas. Is the artifact a result of the marching cubes algorithm's famous ambiguity? 🙄 Artifact: hex + tetArtifact when a combination of hex an tet elements are generated. Artifacat: only hexArtifact when only hex elements are generated. Artifact: only tetArtifact when only tet elements are generated. ReproduceTo reproduce the artifact, commit b7973b8 sets the layer where the artifact begins. Then, just like this commit, layer can be incremented to see how artifact grows. FreeCADThe FreeCAD software can be used to open the ouput |
The marching cubes issue shows up when you have saddle points. These look like plain surfaces. Therefore: A bug? |
Is this code good for a commit to master? |
If you ask me, I'd say let's do a code review and merge, if it's fine. Of course, renaming, formatting, cleaning up, and more could be done with
Right, it looks like a bug 🐞 I try to pinpoint the bug by stepping through the code with the debugger. Maybe I can fix it by submitting other PRs. |
4 FEA benchmarksI have picked four benchmark 3D models from here to verify the FEA results. The square, circular, and I-shaped 3D beams are OK, but the pipe one is a bit strange. As expectedNot expectedWhy are some elements missing from the pipe? 🙄 Is it due to the same bug that was mentioned by the last comment? 🐞 |
This reverts commit 24f9529.
80/20 rule.
Objective
Render an SDF3 to finite elements in the shape of tetrahedra.
Philosohpy / why
There are some commercial software to convert STL surface mesh to FEA volume mesh. Like WELSIM. But as far as I tested, they are unreliable, limited, slow, ...
Problem
I have been only able to do STL mesh to FEA mesh conversion for WELSIM's own sample STL files like the following
hinge.stl
sample. For any other STL file, the conversion is throwing errors. Looks like even the commercial apps only work for perfect STL meshes without any fault. Not sure, maybe?STL surface mesh
FEA volume mesh
Methodology
This looks like a feasible approach:
STL triangles
->
SDF3->
MT (marching tetrahedra)->
FE (finite elements)->
ABAQUS or CalculiX input fileMarching cubes algorithm and marching tetrahedra are closely related.
It's needed to develop a code like below. But for marching tetrahedra rather than marching cubes:
sdfx/render/march3.go
Line 4 in 5bd4805
0
values.<=0
values.Output API
Feeding the finite elements in the shape of tetrahedra - or any other shape - into the FEA engines could be done in various ways. But looks like the ABAQUS way makes sense. Popular opensource FEA engines like CalculiX are using it too.
Question
Does the whole thing make sense? It looks like a solution to me 🙄