BriefFiniteElementNet / BriefFiniteElement.Net

BriefFiniteElementDotNET (BFE.NET) is a library for linear-static Finite Element Method (FEM) analysis of solids and structures in .NET
GNU Lesser General Public License v3.0
148 stars 57 forks source link

Adding RigidElement to model causes NaN in displacement #100

Closed epsi1on closed 2 years ago

epsi1on commented 3 years ago

Describe the bug When a rigid element is added to the model, then after solve displacements are NaN

To Reproduce This is the code We've used and caused wrong result/ runtime error

var model = StructureGenerator.Generate3DTetrahedralElementGrid(3, 3, 70);

                var e = 210e9;

                foreach (var elm in model.Elements)
                {
                    if(elm is TetrahedronElement)
                    {
                        var tet = elm as TetrahedronElement;

                        tet.Material = new Materials.UniformIsotropicMaterial(e, 0.25);
                    }
                }

                var dx = model.Nodes.Max(i => i.Location.X) - model.Nodes.Min(i => i.Location.X);
                var dy = model.Nodes.Max(i => i.Location.Y) - model.Nodes.Min(i => i.Location.Y);
                var dz = model.Nodes.Max(i => i.Location.Z) - model.Nodes.Min(i => i.Location.Z);

                var l = dz;// model.Nodes.Max(i => i.Location.Z);

                var cnt = model.Nodes.Where(i => i.Location.Z == l);

                var f = 1e7;
                var I = dy * dx * dx * dx / 12;
                var rigid = new MpcElements.RigidElement_MPC() { UseForAllLoads = true };

                foreach (var node in cnt)
                {
                    node.Loads.Add(new NodalLoad(new Force(f / cnt.Count(), 0, 0, 0, 0, 0)));
                    rigid.Nodes.Add(node);
                }

                model.MpcElements.Add(rigid);
                model.Trace.Listeners.Add(new ConsoleTraceListener()); 
                model.Solve_MPC();

                var delta = f * l * l * l / (3 * e * I);

                var t = cnt.FirstOrDefault().GetNodalDisplacement();

                var ratio = delta / t.DX;

Expected behavior The displacements should not be Na