private void GenerateMeshNodes(int LElements) { Nodes.Clear(); boundaryNodes.Clear(); MiddleNodes.Clear(); int indexCur = 0; double xCur = _plate.Points[0].X; int LNodes = LElements + 1; double xStep = _plate.Width / Convert.ToDouble(LElements); for (int j = 0; j < LNodes; j++) { FiniteElementNode node = new FiniteElementNode(); node.Index = indexCur; node.Point.X = Math.Round(xCur, 4); node.Point.Y = 0; Nodes.Add(node); MiddleNodes.Add(node); if (j == 0) AddBoundaryNode(node, _plate.Edges[0]); if (j == (LNodes - 1)) AddBoundaryNode(node, _plate.Edges[2]); indexCur++; xCur += xStep; } }
public void NodesCanBeCreated() { FiniteElementNode result = SUT.Create(3); Assert.IsNotNull(result); Assert.AreEqual(3, result.X); }
private void GenerateMeshNodes(int LElements) { Nodes.Clear(); boundaryNodes.Clear(); MiddleNodes.Clear(); int indexCur = 0; double xCur = _plate.Points[0].X; int LNodes = LElements + 1; double xStep = _plate.Width / Convert.ToDouble(LElements); for (int j = 0; j < LNodes; j++) { FiniteElementNode node = new FiniteElementNode(); node.Index = indexCur; node.Point.X = Math.Round(xCur, 4); node.Point.Y = 0; Nodes.Add(node); MiddleNodes.Add(node); if (j == 0) { AddBoundaryNode(node, _plate.Edges[0]); } if (j == (LNodes - 1)) { AddBoundaryNode(node, _plate.Edges[2]); } indexCur++; xCur += xStep; } }
public void WillCheckForInsufficientNumberOfNodes() { model = new FiniteElementModel(ModelType.Truss1D); node1 = model.NodeFactory.Create(0); SUT = new MatrixInversionLinearSolver(model); SUT.Solve(); }
public void NodesAreEqualIfTheirCoordinatesAreEqual() { factory = new NodeFactory(ModelType.Truss3D); FiniteElementNode SUT = factory.Create(0, 0, 0); FiniteElementNode equalToSUT = factory.Create(0, 0, 0); Assert.IsTrue(SUT.Equals(equalToSUT)); Assert.IsTrue(SUT == equalToSUT); Assert.IsFalse(SUT != equalToSUT); FiniteElementNode notEqualToSUTByX = factory.Create(1, 0, 0); Assert.IsFalse(SUT.Equals(notEqualToSUTByX)); Assert.IsFalse(SUT == notEqualToSUTByX); Assert.IsTrue(SUT != notEqualToSUTByX); FiniteElementNode notEqualToSUTByY = factory.Create(0, 1, 0); Assert.IsFalse(SUT.Equals(notEqualToSUTByY)); Assert.IsFalse(SUT == notEqualToSUTByY); Assert.IsTrue(SUT != notEqualToSUTByY); FiniteElementNode notEqualToSUTByZ = factory.Create(0, 0, 1); Assert.IsFalse(SUT.Equals(notEqualToSUTByZ)); Assert.IsFalse(SUT == notEqualToSUTByZ); Assert.IsTrue(SUT != notEqualToSUTByZ); }
public void CanAddMultipleDisplacements() { FiniteElementNode node1 = model.NodeFactory.Create(1); NodalDegreeOfFreedom ndof1 = new NodalDegreeOfFreedom(node, DegreeOfFreedom.X); NodalDegreeOfFreedom ndof2 = new NodalDegreeOfFreedom(node, DegreeOfFreedom.Y); NodalDegreeOfFreedom ndof3 = new NodalDegreeOfFreedom(node1, DegreeOfFreedom.Y); IList <NodalDegreeOfFreedom> identifiers = new List <NodalDegreeOfFreedom>(3); identifiers.Add(ndof1); identifiers.Add(ndof2); identifiers.Add(ndof3); KeyedVector <NodalDegreeOfFreedom> displacements = new KeyedVector <NodalDegreeOfFreedom>(identifiers); displacements[ndof1] = 10; displacements[ndof2] = 12; displacements[ndof3] = 13; SUT.AddMultipleDisplacements(displacements); Assert.AreEqual(10, SUT.GetDisplacement(node).X); Assert.AreEqual(12, SUT.GetDisplacement(node).Y); Assert.AreEqual(13, SUT.GetDisplacement(node1).Y); }
public void AllElementsConnectedToANodeCanBeFound() { IList <IFiniteElement> results = SUT.GetAllElementsConnectedTo(node1); Assert.IsNotNull(results); Assert.AreEqual(1, results.Count); Assert.IsTrue(results.Contains(spring1)); results = SUT.GetAllElementsConnectedTo(node2); Assert.IsNotNull(results); Assert.AreEqual(2, results.Count); Assert.IsTrue(results.Contains(spring1)); Assert.IsTrue(results.Contains(spring2)); results = SUT.GetAllElementsConnectedTo(node3); Assert.IsNotNull(results); Assert.AreEqual(1, results.Count); Assert.IsTrue(results.Contains(spring2)); FiniteElementNode unconnectedNode = nodeFactory.CreateFor2DTruss(0, 3); results = SUT.GetAllElementsConnectedTo(unconnectedNode); Assert.IsNotNull(results); Assert.AreEqual(0, results.Count); }
public void SetUp() { model = new FiniteElementModel(ModelType.Truss1D); node = model.NodeFactory.Create(0); SUT = new FiniteElementResults(ModelType.Truss1D); }
public void ReversedCantilever() { FiniteElementModel model = new FiniteElementModel(ModelType.Beam1D); FiniteElementNode node1 = model.NodeFactory.Create(0); model.ConstrainNode(node1, DegreeOfFreedom.Z); model.ConstrainNode(node1, DegreeOfFreedom.YY); FiniteElementNode node2 = model.NodeFactory.Create(3.0); IMaterial material = new GenericElasticMaterial(0, 210000000000, 0, 0); ICrossSection section = new GenericCrossSection(0.0001, 0.0002); model.ElementFactory.CreateLinear1DBeam(node2, node1, material, section); //connecting the nodes in reverse order to the Cantilever() example ForceVector force = model.ForceFactory.CreateFor1DBeam(-10000, 0); model.ApplyForceToNode(force, node2); IFiniteElementSolver solver = new MatrixInversionLinearSolver(model); FiniteElementResults results = solver.Solve(); ReactionVector reaction = results.GetReaction(node1); Assert.AreEqual(10000, reaction.Z, 0.001); Assert.AreEqual(-30000, reaction.YY, 0.001); DisplacementVector displacement = results.GetDisplacement(node2); Assert.AreEqual(-0.00214, displacement.Z, 0.0005); Assert.AreEqual(0.00107, displacement.YY, 0.0001); }
public void AreEqualIfPropertiesAreEqual() { NodeFactory factory = new NodeFactory(ModelType.Truss1D); FiniteElementNode node1 = factory.Create(0); NodalDegreeOfFreedom SUT = new NodalDegreeOfFreedom(node1, DegreeOfFreedom.X); NodalDegreeOfFreedom equalNodalDegreeOfFreedom = new NodalDegreeOfFreedom(node1, DegreeOfFreedom.X); Assert.IsTrue(SUT.Equals(equalNodalDegreeOfFreedom)); Assert.IsTrue(SUT == equalNodalDegreeOfFreedom); Assert.IsFalse(SUT != equalNodalDegreeOfFreedom); Assert.AreEqual(SUT.GetHashCode(), equalNodalDegreeOfFreedom.GetHashCode()); NodalDegreeOfFreedom notEqualDegreeOfFreedom = new NodalDegreeOfFreedom(node1, DegreeOfFreedom.Y); Assert.IsFalse(SUT.Equals(notEqualDegreeOfFreedom)); Assert.IsFalse(SUT == notEqualDegreeOfFreedom); Assert.IsTrue(SUT != notEqualDegreeOfFreedom); Assert.AreNotEqual(SUT.GetHashCode(), notEqualDegreeOfFreedom.GetHashCode()); FiniteElementNode node2 = factory.Create(1); NodalDegreeOfFreedom notEqualNode = new NodalDegreeOfFreedom(node2, DegreeOfFreedom.X); Assert.IsFalse(SUT.Equals(notEqualNode)); Assert.IsFalse(SUT == notEqualNode); Assert.IsTrue(SUT != notEqualNode); Assert.AreNotEqual(SUT.GetHashCode(), notEqualNode.GetHashCode()); }
public void SpringAt60DegreesInXYPlane() { FiniteElementModel model = new FiniteElementModel(ModelType.Truss2D); // we will create and analyze a 2D truss system FiniteElementNode node1 = model.NodeFactory.CreateFor2DTruss(0, 0); // create a node at the origin model.ConstrainNode(node1, DegreeOfFreedom.X); // constrain this node from moving in the X axis model.ConstrainNode(node1, DegreeOfFreedom.Z); // also constrain it from moving in the Y axis FiniteElementNode node2 = model.NodeFactory.CreateFor2DTruss(1, 1.73205); // create a second node at a distance 1 metre along the X axis and 1.73 metres along the Y axis (giving an angle of 60 degrees from x-axis). model.ConstrainNode(node2, DegreeOfFreedom.X); LinearConstantSpring spring = model.ElementFactory.CreateLinearConstantSpring(node1, node2, 1000); // create a spring between the first two nodes of a stiffness of 1000 Newtons per metre ForceVector force = model.ForceFactory.CreateForTruss(0, 10); // Create a force of with components of 10 Newtons along the y-axis. model.ApplyForceToNode(force, node2); // Apply that force to the second node IFiniteElementSolver solver = new MatrixInversionLinearSolver(model); // Create a new instance of the solver class and pass it the model to solve FiniteElementResults results = solver.Solve(); // ask the solver to solve the model and return results DisplacementVector displacementAtNode2 = results.GetDisplacement(node2); // get the displacement at the second node Assert.AreEqual(0, displacementAtNode2.X); // Check that there is no displacement in the x-axis Assert.AreEqual(0.013333, displacementAtNode2.Z, 0.001); // and 0.01333 metres (13 millimetres) along the Y axis. ReactionVector reactionAtNode1 = results.GetReaction(node1); //get the reaction at the first node Assert.AreEqual(-5.774, reactionAtNode1.X, 0.001); // Check that we have calculated a reaction of 10/SQRT(3) Newtons in the X axis. Assert.AreEqual(-10, reactionAtNode1.Z, 0.001); // and a reaction of -10 Newtons in the Y axis. }
public void Cantilever() { FiniteElementModel model = new FiniteElementModel(ModelType.Beam1D); // we will create and analyze a 1D beam system FiniteElementNode node1 = model.NodeFactory.Create(0); // create a node at the origin model.ConstrainNode(node1, DegreeOfFreedom.Z); // constrain the node from moving in the Z-axis model.ConstrainNode(node1, DegreeOfFreedom.YY); // constrain this node from rotating around the Y-axis FiniteElementNode node2 = model.NodeFactory.Create(3.0); // create a second node at a distance 1 metre along the X axis IMaterial material = new GenericElasticMaterial(0, 210000000000, 0, 0); ICrossSection section = new GenericCrossSection(0.0001, 0.0002); model.ElementFactory.CreateLinear1DBeam(node1, node2, material, section); ForceVector force = model.ForceFactory.CreateFor1DBeam(-10000, 0); // Create a force of 10 KiloNewtons in the z direction model.ApplyForceToNode(force, node2); // Apply that force to the second node IFiniteElementSolver solver = new MatrixInversionLinearSolver(model); // Create a new instance of the solver class and pass it the model to solve FiniteElementResults results = solver.Solve(); // ask the solver to solve the model and return results ReactionVector reaction = results.GetReaction(node1); //get the reaction at the first node Assert.AreEqual(10000, reaction.Z, 0.001); // Check that we have calculated a reaction of 10 KiloNewtons in the Z-axis Assert.AreEqual(-30000, reaction.YY, 0.001); // Check that we have calculated a reaction of -30 KiloNewtonMetres around the YY axis. DisplacementVector displacement = results.GetDisplacement(node2); // get the displacement at the second node Assert.AreEqual(-0.00214, displacement.Z, 0.0005); Assert.AreEqual(0.00107, displacement.YY, 0.0001); }
public override void ToSharpLoad(GH_Model model) { ForceVector forceVector = null; switch (model.ModelType) { case SharpFE.ModelType.Truss2D: forceVector = model.Model.ForceFactory.CreateForTruss(Force.X, Force.Z); break; case SharpFE.ModelType.Full3D: forceVector = model.Model.ForceFactory.Create(Force.X, Force.Y, Force.Z, Moment.X, Moment.Y, Moment.Z); break; default: throw new Exception("No such model type implemented: " + model.ModelType); } foreach (GH_Node node in Nodes) { node.ToSharpElement(model); FiniteElementNode FEnode = model.Nodes[node.Index]; model.Model.ApplyForceToNode(forceVector, FEnode); } }
public void CalculateModelOfOneSpringWith2DegreesOfFreedom() { FiniteElementModel model = new FiniteElementModel(ModelType.Truss1D); // we will create and analyze a 1D truss system FiniteElementNode node1 = model.NodeFactory.Create(0); // create a node at the origin model.ConstrainNode(node1, DegreeOfFreedom.X); // constrain this node from moving in the X axis FiniteElementNode node2 = model.NodeFactory.Create(1.0); // create a second node at a distance 1 metre along the X axis model.ElementFactory.CreateLinearConstantSpring(node1, node2, 2000.0); // create a spring between the two nodes of a stiffness of 2000 Newtons per metre ForceVector force = model.ForceFactory.Create(10.0); // Create a force of 10 Newtons in the x direction model.ApplyForceToNode(force, node2); // Apply that force to the second node IFiniteElementSolver solver = new MatrixInversionLinearSolver(model); // Create a new instance of the solver class and pass it the model to solve FiniteElementResults results = solver.Solve(); // ask the solver to solve the model and return results DisplacementVector displacement = results.GetDisplacement(node2); // get the displacement at the second node Assert.AreEqual(0.005, displacement.X); // Check that we have calculated a displacement of 0.005 metres (5 millimetres) along the X axis. ReactionVector reaction = results.GetReaction(node1); //get the reaction at the first node Assert.AreEqual(-10, reaction.X); // Check that we have calculated a reaction of -10 Newtons in the X axis. }
public void SetUp() { nodeFactory = new NodeFactory(ModelType.Truss2D); node1 = nodeFactory.CreateFor2DTruss(0, 0); node2 = nodeFactory.CreateFor2DTruss(0, 1); SUT = new ElementFactory(ModelType.Truss2D); }
public void SpringInXAxis() { FiniteElementModel model = new FiniteElementModel(ModelType.Truss2D); // we will create and analyze a 1D spring in the vertical FiniteElementNode node1 = model.NodeFactory.CreateFor2DTruss(0, 0); // create a node at the origin model.ConstrainNode(node1, DegreeOfFreedom.X); // constrain this node from moving in the X axis model.ConstrainNode(node1, DegreeOfFreedom.Z); // also constrain it from moving in the Y axis FiniteElementNode node2 = model.NodeFactory.CreateFor2DTruss(1, 0); // create a second node at a distance 1 metre along the X axis. model.ConstrainNode(node2, DegreeOfFreedom.Z); // fix this node from moving along the Y-axis. It is still free to move along the X-axis however. LinearConstantSpring spring = model.ElementFactory.CreateLinearConstantSpring(node1, node2, 1000); // create a spring between the two nodes of a stiffness of 1000 Newtons per metre ForceVector force = model.ForceFactory.CreateForTruss(10, 0); // Create a force of 10 Newtons along the x-axis. model.ApplyForceToNode(force, node2); // Apply that force to the second node IFiniteElementSolver solver = new MatrixInversionLinearSolver(model); // Create a new instance of the solver class and pass it the model to solve FiniteElementResults results = solver.Solve(); // ask the solver to solve the model and return results DisplacementVector displacementAtNode2 = results.GetDisplacement(node2); // get the displacement at the second node Assert.AreEqual(0.01, displacementAtNode2.X); // check that we calculated 0.010 metres (10 millimetres) along the Y axis. ReactionVector reactionAtNode1 = results.GetReaction(node1); //get the reaction at the first node Assert.AreEqual(-10, reactionAtNode1.X); // Check that we have calculated a reaction of -10 Newtons in the X axis. Assert.AreEqual(0, reactionAtNode1.Z); // and a reaction of 0 Newtons in the Y axis. }
public void NodesCanHaveAConstraint() { SUT = new NodeRepository(ModelType.Full3D); nodeFactory = new NodeFactory(ModelType.Full3D, SUT); node1 = nodeFactory.Create(0, 0, 0); Assert.IsFalse(SUT.IsConstrained(node1, DegreeOfFreedom.X)); Assert.IsFalse(SUT.IsConstrained(node1, DegreeOfFreedom.Y)); Assert.IsFalse(SUT.IsConstrained(node1, DegreeOfFreedom.Z)); Assert.IsFalse(SUT.IsConstrained(node1, DegreeOfFreedom.XX)); Assert.IsFalse(SUT.IsConstrained(node1, DegreeOfFreedom.YY)); Assert.IsFalse(SUT.IsConstrained(node1, DegreeOfFreedom.ZZ)); SUT.ConstrainNode(node1, DegreeOfFreedom.X); Assert.IsTrue(SUT.IsConstrained(node1, DegreeOfFreedom.X)); Assert.IsFalse(SUT.IsConstrained(node1, DegreeOfFreedom.Y)); SUT.ConstrainNode(node1, DegreeOfFreedom.Y); Assert.IsTrue(SUT.IsConstrained(node1, DegreeOfFreedom.X)); Assert.IsTrue(SUT.IsConstrained(node1, DegreeOfFreedom.Y)); SUT.ConstrainNode(node1, DegreeOfFreedom.Z); Assert.IsTrue(SUT.IsConstrained(node1, DegreeOfFreedom.Z)); SUT.ConstrainNode(node1, DegreeOfFreedom.XX); Assert.IsTrue(SUT.IsConstrained(node1, DegreeOfFreedom.XX)); SUT.ConstrainNode(node1, DegreeOfFreedom.YY); Assert.IsTrue(SUT.IsConstrained(node1, DegreeOfFreedom.YY)); SUT.ConstrainNode(node1, DegreeOfFreedom.ZZ); Assert.IsTrue(SUT.IsConstrained(node1, DegreeOfFreedom.ZZ)); }
public void CalculateGridOf3BeamsAnd24Dof() { FiniteElementModel model = new FiniteElementModel(ModelType.Slab2D); FiniteElementNode node1 = model.NodeFactory.Create(4, 4); FiniteElementNode node2 = model.NodeFactory.Create(4, 0); model.ConstrainNode(node2, DegreeOfFreedom.Z); model.ConstrainNode(node2, DegreeOfFreedom.XX); model.ConstrainNode(node2, DegreeOfFreedom.YY); FiniteElementNode node3 = model.NodeFactory.Create(0, 0); model.ConstrainNode(node3, DegreeOfFreedom.Z); model.ConstrainNode(node3, DegreeOfFreedom.XX); model.ConstrainNode(node3, DegreeOfFreedom.YY); FiniteElementNode node4 = model.NodeFactory.Create(0, 4); model.ConstrainNode(node4, DegreeOfFreedom.Z); model.ConstrainNode(node4, DegreeOfFreedom.XX); model.ConstrainNode(node4, DegreeOfFreedom.YY); IMaterial material = new GenericElasticMaterial(0, 210000000000, 0, 84000000000); ICrossSection section = new GenericCrossSection(0.02, 0.0002, 0.0002, 0.00005); model.ElementFactory.CreateLinear3DBeam(node1, node2, material, section); model.ElementFactory.CreateLinear3DBeam(node1, node3, material, section); model.ElementFactory.CreateLinear3DBeam(node1, node4, material, section); ForceVector force = model.ForceFactory.Create(0, 0, -20000, 0, 0, 0); model.ApplyForceToNode(force, node1); IFiniteElementSolver solver = new LinearSolverSVD(model); FiniteElementResults results = solver.Solve(); DisplacementVector node1Displacement = results.GetDisplacement(node1); ReactionVector node2Reaction = results.GetReaction(node2); ReactionVector node3Reaction = results.GetReaction(node3); ReactionVector node4Reaction = results.GetReaction(node4); Assert.AreEqual(-0.0033, node1Displacement.Z, 0.0001); Assert.AreEqual(-0.0010, node1Displacement.XX, 0.0001); Assert.AreEqual(0.0010, node1Displacement.YY, 0.0001); Assert.AreEqual(10794, node2Reaction.Z, 1); Assert.AreEqual(31776, node2Reaction.XX, 1); Assert.AreEqual(-1019, node2Reaction.YY, 1); Assert.AreEqual(-1587, node3Reaction.Z, 1); Assert.AreEqual(4030, node3Reaction.XX, 1); Assert.AreEqual(-4030, node3Reaction.YY, 1); Assert.AreEqual(10794, node4Reaction.Z, 1); Assert.AreEqual(1019, node4Reaction.XX, 1); Assert.AreEqual(-31776, node4Reaction.YY, 1); }
public void OneVerticalQuadFixed3PointsMembrane() { FiniteElementModel model = new FiniteElementModel(ModelType.Membrane3D); FiniteElementNode node1 = model.NodeFactory.Create(0.0, 0.0, 0.0); model.ConstrainNode(node1, DegreeOfFreedom.X); model.ConstrainNode(node1, DegreeOfFreedom.Y); model.ConstrainNode(node1, DegreeOfFreedom.Z); FiniteElementNode node2 = model.NodeFactory.Create(1.0, 0.0, 0.0); model.ConstrainNode(node2, DegreeOfFreedom.X); model.ConstrainNode(node2, DegreeOfFreedom.Y); model.ConstrainNode(node2, DegreeOfFreedom.Z); FiniteElementNode node3 = model.NodeFactory.Create(1.0, 0.0, 1.0); model.ConstrainNode(node3, DegreeOfFreedom.X); model.ConstrainNode(node3, DegreeOfFreedom.Y); model.ConstrainNode(node3, DegreeOfFreedom.Z); FiniteElementNode node4 = model.NodeFactory.Create(0.0, 0.0, 1.0); model.ConstrainNode(node4, DegreeOfFreedom.Y); IMaterial material = new GenericElasticMaterial(0, 210000000000, 0.3, 0); model.ElementFactory.CreateLinearConstantStressQuadrilateral(node1, node2, node3, node4, material, 0.1); ForceVector force = model.ForceFactory.Create(10000, 0, 0, 0, 0, 0); model.ApplyForceToNode(force, node4); IFiniteElementSolver solver = new MatrixInversionLinearSolver(model); FiniteElementResults results = solver.Solve(); ReactionVector reaction1 = results.GetReaction(node1); Console.WriteLine("\nReaction1 : \n" + reaction1); ReactionVector reaction2 = results.GetReaction(node2); Console.WriteLine("\nReaction2 : \n" + reaction2); ReactionVector reaction3 = results.GetReaction(node3); Console.WriteLine("\nReaction3 : \n" + reaction3); DisplacementVector displacement4 = results.GetDisplacement(node4); Console.WriteLine("\nDisplacement4 : \n" + displacement4); Assert.AreEqual(2621, reaction1.X, 1); Assert.AreEqual(-3039, reaction1.Z, 1); Assert.AreEqual(-5660, reaction2.X, 1); Assert.AreEqual(1706, reaction2.Z, 1); Assert.AreEqual(-6961, reaction3.X, 1); Assert.AreEqual(1333, reaction3.Z, 1); Assert.AreEqual(0.0000012400, displacement4.X, 0.0000000001); Assert.AreEqual(0.0000004875, displacement4.Z, 0.0000000001); }
public void Setup() { SUT = new NodeRepository(ModelType.Truss1D); nodeFactory = new NodeFactory(ModelType.Truss1D, SUT); node1 = nodeFactory.Create(0); node2 = nodeFactory.Create(1); node3 = nodeFactory.Create(2); }
private void CreateFiniteElement1D(double startX, double startY, double startZ, double endX, double endY, double endZ) { nodeFactory = new NodeFactory(ModelType.Truss3D); start = nodeFactory.Create(startX, startY, startZ); end = nodeFactory.Create(endX, endY, endZ); elementFactory = new ElementFactory(ModelType.Truss3D); SUT = elementFactory.CreateLinearConstantSpring(start, end, 0); }
public void SetUp() { nodeFactory = new NodeFactory(ModelType.Truss1D); start = nodeFactory.Create(0); end = nodeFactory.Create(1); elementFactory = new ElementFactory(ModelType.Truss1D); SUT = elementFactory.CreateLinearConstantSpring(start, end, 2); }
public void TwoTriangleWall() { FiniteElementModel model = new FiniteElementModel(ModelType.Membrane3D); // we will create and analyze a 2D slab system FiniteElementNode node1 = model.NodeFactory.Create(0.0, 0.0, 0.0); // create a node at the origin model.ConstrainNode(node1, DegreeOfFreedom.X); // constrain the node from moving in the x-axis model.ConstrainNode(node1, DegreeOfFreedom.Y); // constrain the node from moving in the y-axis model.ConstrainNode(node1, DegreeOfFreedom.Z); // constrain the node from moving in the z-axis FiniteElementNode node2 = model.NodeFactory.Create(1.0, 0.0, 0.0); // create a second node at a distance 1 metre along the X axis model.ConstrainNode(node2, DegreeOfFreedom.X); // constrain the node from moving in the x-axis model.ConstrainNode(node2, DegreeOfFreedom.Y); // constrain the node from moving in the y-axis model.ConstrainNode(node2, DegreeOfFreedom.Z); // constrain the node from moving in the z-axis FiniteElementNode node3 = model.NodeFactory.Create(0.0, 1.0, 0.0); model.ConstrainNode(node3, DegreeOfFreedom.Z); // constrain the node from moving in the z-axis FiniteElementNode node4 = model.NodeFactory.Create(1.0, 1.0, 0.0); model.ConstrainNode(node4, DegreeOfFreedom.Z); // constrain the node from moving in the z-axis IMaterial material = new GenericElasticMaterial(0, 200000, 0.2, 84000); model.ElementFactory.CreateLinearConstantStrainTriangle(node1, node2, node3, material, 0.1); // create a triangle of thickness of 0.1 metres model.ElementFactory.CreateLinearConstantStrainTriangle(node2, node4, node3, material, 0.1); ForceVector force = model.ForceFactory.Create(0, -10); // Create a force of 10 Newtons in the y direction model.ApplyForceToNode(force, node3); // Apply that force to the third node model.ApplyForceToNode(force, node4); IFiniteElementSolver solver = new MatrixInversionLinearSolver(model); FiniteElementResults results = solver.Solve(); ReactionVector reaction1 = results.GetReaction(node1); //get the reaction at the first node Console.WriteLine("\nReaction1 : \n" + reaction1); ReactionVector reaction2 = results.GetReaction(node2); Console.WriteLine("\nReaction2 : \n" + reaction2); Assert.AreEqual(20, reaction1.Y + reaction2.Y, 0.001); DisplacementVector displacement3 = results.GetDisplacement(node3); // get the displacement at the second node Console.WriteLine("\nDisplacement3 : \n" + displacement3); Assert.AreNotEqual(0.0, displacement3.X); // TODO calculate the actual value, rather than just checking we have any value Assert.AreNotEqual(0.0, displacement3.Y); // TODO calculate the actual value, rather than just checking we have any value Assert.AreEqual(0.0, displacement3.Z); // TODO calculate the actual value, rather than just checking we have any value DisplacementVector displacement4 = results.GetDisplacement(node4); // get the displacement at the second node Console.WriteLine("\nDisplacement4 : \n" + displacement4); Assert.AreNotEqual(0.0, displacement4.X); // TODO calculate the actual value, rather than just checking we have any value Assert.AreNotEqual(0.0, displacement4.Y); // TODO calculate the actual value, rather than just checking we have any value Assert.AreEqual(0.0, displacement4.Z); // TODO calculate the actual value, rather than just checking we have any value }
public void Calculate2DPortalFrameOf3BeamsAnd12Dof() { FiniteElementModel model = new FiniteElementModel(ModelType.Full3D); FiniteElementNode node1 = model.NodeFactory.Create(-3, 0, 0); model.ConstrainNode(node1, DegreeOfFreedom.X); model.ConstrainNode(node1, DegreeOfFreedom.Y); model.ConstrainNode(node1, DegreeOfFreedom.Z); model.ConstrainNode(node1, DegreeOfFreedom.XX); model.ConstrainNode(node1, DegreeOfFreedom.YY); FiniteElementNode node2 = model.NodeFactory.Create(-3, 0, 6); FiniteElementNode node3 = model.NodeFactory.Create(3, 0, 6); FiniteElementNode node4 = model.NodeFactory.Create(3, 0, 0); model.ConstrainNode(node4, DegreeOfFreedom.X); model.ConstrainNode(node4, DegreeOfFreedom.Y); model.ConstrainNode(node4, DegreeOfFreedom.Z); model.ConstrainNode(node4, DegreeOfFreedom.XX); model.ConstrainNode(node4, DegreeOfFreedom.YY); IMaterial material = new GenericElasticMaterial(0, 210000000000, 0, 84000000); ICrossSection section = new GenericCrossSection(0.0002, 0.0002, 0.0002, 0.00005); model.ElementFactory.CreateLinear3DBeam(node1, node2, material, section); model.ElementFactory.CreateLinear3DBeam(node2, node3, material, section); model.ElementFactory.CreateLinear3DBeam(node3, node4, material, section); ForceVector force2 = model.ForceFactory.Create(15000, 0, 0, 0, -10000, 0); model.ApplyForceToNode(force2, node2); IFiniteElementSolver solver = new LinearSolverSVD(model); FiniteElementResults results = solver.Solve(); DisplacementVector node2Displacement = results.GetDisplacement(node2); DisplacementVector node3Displacement = results.GetDisplacement(node3); ReactionVector node1Reaction = results.GetReaction(node1); ReactionVector node4Reaction = results.GetReaction(node4); Assert.AreEqual(0.0052843, node2Displacement.X, 0.0001); Assert.AreEqual(0.0006522, node2Displacement.Z, 0.0001); Assert.AreEqual(0.0005, node2Displacement.YY, 0.0001); Assert.AreEqual(0.0044052, node3Displacement.X, 0.0001); Assert.AreEqual(-0.0006522, node3Displacement.Z, 0.0001); Assert.AreEqual(0.0006, node3Displacement.YY, 0.0001); Assert.AreEqual(-9000, node1Reaction.X, 500); Assert.AreEqual(-5000, node1Reaction.Z, 500); Assert.AreEqual(-30022, node1Reaction.YY, 500); Assert.AreEqual(-6000, node4Reaction.X, 500); Assert.AreEqual(5000, node4Reaction.Z, 500); Assert.AreEqual(-22586, node4Reaction.YY, 500); }
public void ThreeNodeSimplySupportedBeam() //TODO verify results using independent check { FiniteElementModel model = new FiniteElementModel(ModelType.Frame2D); FiniteElementNode node1 = model.NodeFactory.CreateFor2DTruss(0, 0); model.ConstrainNode(node1, DegreeOfFreedom.X); model.ConstrainNode(node1, DegreeOfFreedom.Z); FiniteElementNode node2 = model.NodeFactory.CreateFor2DTruss(1, 0); FiniteElementNode node3 = model.NodeFactory.CreateFor2DTruss(2, 0); model.ConstrainNode(node3, DegreeOfFreedom.Z); IMaterial material = new GenericElasticMaterial(0, 10000000000, 0, 0); ICrossSection section = new GenericCrossSection(0.0001, 0.0002); model.ElementFactory.CreateLinear1DBeam(node1, node2, material, section); model.ElementFactory.CreateLinear1DBeam(node2, node3, material, section); ForceVector force = model.ForceFactory.Create(0, 0, -10000, 0, 0, 0); model.ApplyForceToNode(force, node2); IFiniteElementSolver solver = new MatrixInversionLinearSolver(model); Stiffness.GlobalModelStiffnessMatrixBuilder gmsmb = new SharpFE.Stiffness.GlobalModelStiffnessMatrixBuilder(model); Console.WriteLine(gmsmb.BuildKnownForcesUnknownDisplacementStiffnessMatrix()); FiniteElementResults results = solver.Solve(); DisplacementVector node1Displacement = results.GetDisplacement(node1); Console.WriteLine("node1Displacement : " + node1Displacement); DisplacementVector node2Displacement = results.GetDisplacement(node2); Console.WriteLine("node2Displacement : " + node2Displacement); DisplacementVector node3Displacement = results.GetDisplacement(node3); Console.WriteLine("node3Displacement : " + node3Displacement); ReactionVector node1Reaction = results.GetReaction(node1); Console.WriteLine("node1Reaction : " + node1Reaction); ReactionVector node3Reaction = results.GetReaction(node3); Console.WriteLine("node5Reaction : " + node3Reaction); Assert.AreEqual(-0.000833333, node2Displacement.Z, 0.0000001); Assert.AreEqual(5000, node1Reaction.Z, 0.001); Assert.AreEqual(5000, node3Reaction.Z, 0.001); Assert.AreEqual(0, node2Displacement.YY, 0.0001); Assert.AreEqual(0.00125, node1Displacement.YY, 0.0000001); Assert.AreEqual(-0.00125, node3Displacement.YY, 0.0000001); }
public override void ToSharpElement(GH_Model model) { FiniteElementNode n0 = null; FiniteElementNode n1 = null; FiniteElementNode n2 = null; int n0Index = model.Points.IndexOf(this.Points[0]); int n1Index = model.Points.IndexOf(this.Points[1]); int n2Index = model.Points.IndexOf(this.Points[2]); switch (model.ModelType) { case ModelType.Full3D: if (n0Index == -1) //Node does not exist { n0 = model.Model.NodeFactory.Create(this.Points[0].X, this.Points[0].Y, this.Points[0].Z); model.Nodes.Add(n0); model.Points.Add(this.Points[0]); } else { n0 = model.Nodes[n0Index]; } if (n1Index == -1) //Node does not exist { n1 = model.Model.NodeFactory.Create(this.Points[1].X, this.Points[1].Y, this.Points[1].Z); model.Nodes.Add(n1); model.Points.Add(this.Points[1]); } else { n1 = model.Nodes[n1Index]; } if (n2Index == -1) //Node does not exist { n2 = model.Model.NodeFactory.Create(this.Points[2].X, this.Points[2].Y, this.Points[2].Z); model.Nodes.Add(n2); model.Points.Add(this.Points[2]); } else { n2 = model.Nodes[n2Index]; } if (n0 != null && n1 != null && n2 != null) { model.Model.ElementFactory.CreateLinearConstantStrainTriangle(n0, n1, n2, this.Material.ToSharpMaterial(), this.Thickness); } break; default: throw new Exception("Model type not valid: " + model.ModelType); } }
protected void CreateAndStore2DSpringFromOriginTo(double x, double z) { this.nodeFactory = new NodeFactory(ModelType.Truss2D); this.start = nodeFactory.CreateFor2DTruss(0, 0); this.end = nodeFactory.CreateFor2DTruss(x, z); this.elementFactory = new ElementFactory(ModelType.Truss2D); this.SUT = elementFactory.CreateLinearConstantSpring(this.start, this.end, 1); }
public void SetUp() { this.nodeFactory = new NodeFactory(ModelType.Truss1D); this.start = nodeFactory.Create(0); this.end = nodeFactory.Create(1); this.elementFactory = new ElementFactory(ModelType.Truss1D); this.spring = elementFactory.CreateLinearConstantSpring(start, end, 2); this.SUT = new LinearTrussStiffnessMatrixBuilder(spring); }
protected void CreateAndStore2DSpringBetween(double startX, double startZ, double endX, double endZ) { this.nodeFactory = new NodeFactory(ModelType.Truss2D); this.start = nodeFactory.CreateFor2DTruss(startX, startZ); this.end = nodeFactory.CreateFor2DTruss(endX, endZ); this.elementFactory = new ElementFactory(ModelType.Truss2D); this.SUT = elementFactory.CreateLinearConstantSpring(this.start, this.end, 1); }
protected void CreateAndStore3DSpringFromOriginTo(double x, double y, double z) { nodeFactory = new NodeFactory(ModelType.Truss3D); start = nodeFactory.Create(0, 0, 0); end = nodeFactory.Create(x, y, z); elementFactory = new ElementFactory(ModelType.Truss3D); this.SUT = elementFactory.CreateLinearConstantSpring(start, end, 1); }
public override void ToSharpElement(GH_Model model) { Start.ToSharpElement(model); End.ToSharpElement(model); FiniteElementNode startNode = model.Nodes[Start.Index]; FiniteElementNode endNode = model.Nodes[End.Index]; model.Model.ElementFactory.CreateLinear1DBeam(startNode, endNode, Material.ToSharpMaterial(), CrossSection.ToSharpCrossSection()); }
protected void CreateAndStore2DSpringFromOriginTo(double x, double z) { this.nodeFactory = new NodeFactory(ModelType.Truss2D); this.start = nodeFactory.CreateFor2DTruss(0, 0); this.end = nodeFactory.CreateFor2DTruss(x, z); this.elementFactory = new ElementFactory(ModelType.Truss2D); this.spring = elementFactory.CreateLinearConstantSpring(this.start, this.end, 1); this.SUT = new LinearTrussStiffnessMatrixBuilder(this.spring); }
protected void CreateAndStore3DSpringFromOriginTo(double x, double y, double z) { nodeFactory = new NodeFactory(ModelType.Truss3D); start = nodeFactory.Create(0, 0, 0); end = nodeFactory.Create(x, y, z); elementFactory = new ElementFactory(ModelType.Truss3D); this.spring = elementFactory.CreateLinearConstantSpring(start, end, 1); this.SUT = new LinearTrussStiffnessMatrixBuilder(this.spring); }
public void SetUp() { nodeFactory = new NodeFactory(ModelType.Frame2D); start = nodeFactory.CreateFor2DTruss(0, 0); end = nodeFactory.CreateFor2DTruss(1, 0); elementFactory = new ElementFactory(ModelType.Frame2D); material = new GenericElasticMaterial(0, 1, 0, 1); section = new GenericCrossSection(1, 1, 1, 1); beam = elementFactory.CreateLinear3DBeam(start, end, material, section); SUT = new Linear3DBernoulliBeamStiffnessMatrixBuilder(beam); }
public void SetUp() { nodeFactory = new NodeFactory(ModelType.Truss1D); start = nodeFactory.Create(0); end = nodeFactory.Create(1); elementFactory = new ElementFactory(ModelType.Truss1D); SUT = elementFactory.CreateLinearConstantSpring(start, end, 0); }
public static double Length(FiniteElementNode a, FiniteElementNode b) { return Point.Length(a.Point, b.Point); }
protected void AddBoundaryNode(FiniteElementNode node, Edge edge) { boundaryNodes.Add(new KeyValuePair<FiniteElementNode, Edge>(node, edge)); }
private void GenerateMeshNodes(int LElements, int HElements) { Nodes.Clear(); boundaryNodes.Clear(); int indexCur = 0; double xCur = _rectangle.Points[0].X; double yCur = _rectangle.Points[0].Y; if (HElements % 2 == 1) HElements++; int HNodes = HElements + 1; int LNodes = LElements + 1; double xStep = _rectangle.Width / Convert.ToDouble(LElements); double yStep = _rectangle.Height / Convert.ToDouble(HElements); int HNodesdiv2 = HNodes / 2; for (int i = 0; i < HNodesdiv2; i++) { for (int j = 0; j < LNodes; j++) { FiniteElementNode node = new FiniteElementNode(); node.Index = indexCur; node.Point.X = Math.Round(xCur, 4); node.Point.Y = Math.Round(yCur, 4); Nodes.Add(node); if (j == 0) AddBoundaryNode(node, _rectangle.Edges[0]); if (j == (LNodes - 1)) AddBoundaryNode(node, _rectangle.Edges[2]); indexCur++; xCur += xStep; if (i == 0) { AddBoundaryNode(node, _rectangle.Edges[1]); } } yCur -= yStep; xCur = _rectangle.Points[0].X; } //xCur = _rectangle.Points[0].X; //yCur = (_rectangle.Points[0].Y + _rectangle.Points[1].Y) / 2; MiddleNodes.Clear(); for (int j = 0; j < LNodes; j++) { FiniteElementNode node = new FiniteElementNode(); node.Index = indexCur; node.Point.X = Math.Round(xCur, 4); node.Point.Y = Math.Round(yCur, 4); Nodes.Add(node); MiddleNodes.Add(node); if (j == 0) AddBoundaryNode(node, _rectangle.Edges[0]); if (j == (LNodes - 1)) AddBoundaryNode(node, _rectangle.Edges[2]); indexCur++; xCur += xStep; } yCur -= yStep; xCur = _rectangle.Points[0].X; for (int i = 0; i < HNodesdiv2; i++) { for (int j = 0; j < LNodes; j++) { FiniteElementNode node = new FiniteElementNode(); node.Index = indexCur; node.Point.X = Math.Round(xCur, 4); node.Point.Y = Math.Round(yCur, 4); Nodes.Add(node); if (j == 0) AddBoundaryNode(node, _rectangle.Edges[0]); if (j == (LNodes - 1)) AddBoundaryNode(node, _rectangle.Edges[2]); if (i == (HNodesdiv2 - 1)) { AddBoundaryNode(node, _rectangle.Edges[3]); } indexCur++; xCur += xStep; } yCur -= yStep; xCur = _rectangle.Points[0].X; } }