/// <summary> /// Creates an instance that uses a specific problem type and an appropriate child analyzer for the construction of the system of equations arising from the actual physical problem /// </summary> /// <param name="provider">Instance of the problem type to be solver</param> /// <param name="childAnalyzer">Instance of the child analyzer that will handle the solution of the system of equations</param> /// <param name="linearSystem">Instance of the linear system that will be initialized</param> public StaticAnalyzer(ProblemStructural provider, LinearAnalyzer childAnalyzer, SkylineLinearSystem linearSystem) { this.provider = provider; this.ChildAnalyzer = childAnalyzer; this.ChildAnalyzer.ParentAnalyzer = this; this.linearSystem = linearSystem; }
public void TestEulerBeam2DLinearBendingExample() { // Model and node creation var model = new Model(); model.NodesDictionary.Add(1, new Node { ID = 1, X = 0.0, Y = 0.0, Z = 0.0 }); model.NodesDictionary.Add(2, new Node { ID = 2, X = 100.0, Y = 0.0, Z = 0.0 }); model.NodesDictionary.Add(3, new Node { ID = 3, X = 200.0, Y = 0.0, Z = 0.0 }); // Constrain bottom node and add nodal load value model.NodesDictionary[1].Constraints.AddRange(new[] { DOFType.X, DOFType.Y, DOFType.Z, DOFType.RotZ }); model.Loads.Add(new Load() { Amount = 2000, Node = model.NodesDictionary[3], DOF = DOFType.Y }); // Generate elements of the structure for (int iElem = 0; iElem < 2; iElem++) { // Create new Beam2D section and element var element = new EulerBeam2D(2.1e4) { ID = iElem + 1, Density = 7.85, SectionArea = 91.04, MomentOfInertia = 8091.00 }; element.ElementType = element; // Add nodes to the created element element.AddNode(model.NodesDictionary[iElem + 1]); element.AddNode(model.NodesDictionary[iElem + 2]); // Add Hexa element to the element and subdomains dictionary of the model model.ElementsDictionary.Add(element.ID, element); } // Needed in order to make all the required data structures model.ConnectDataStructures(); // Setup var linearSystem = new SkylineLinearSystem(model.Forces); var solver = new SolverSkyline(linearSystem); var provider = new ProblemStructural(model); var childAnalyzer = new LinearAnalyzer(solver); var parentAnalyzer = new StaticAnalyzer(provider, childAnalyzer, linearSystem); parentAnalyzer.BuildMatrices(); parentAnalyzer.Initialize(); parentAnalyzer.Solve(); // Tests if calculated solution meets expected var expectedSolution = new double[] { 0, 9.80905689841542, 0.17656302417147754, 0, 31.388982074929341, 0.23541736556197002 }; for (int i = 0; i < expectedSolution.Length; i++) { Assert.Equal(expectedSolution[i], linearSystem.Solution[i], 12); } }
private static Vector RunAnalysis(Model model) { // Setup analysis var linearSystem = new SkylineLinearSystem(model.Forces); var solver = new SolverSkyline(linearSystem); var provider = new ProblemStructural(model); var childAnalyzer = new LinearAnalyzer(solver); var parentAnalyzer = new StaticAnalyzer(provider, childAnalyzer, linearSystem); parentAnalyzer.BuildMatrices(); parentAnalyzer.Initialize(); parentAnalyzer.Solve(); return(linearSystem.Solution); }
public void TestQuad4LinearCantileverExample() { // Model and node creation var model = new Model(); model.NodesDictionary.Add(1, new Node { ID = 1, X = 0.0, Y = 0.0, Z = 0.0 }); model.NodesDictionary.Add(2, new Node { ID = 2, X = 10.0, Y = 0.0, Z = 0.0 }); model.NodesDictionary.Add(3, new Node { ID = 3, X = 10.0, Y = 10.0, Z = 0.0 }); model.NodesDictionary.Add(4, new Node { ID = 4, X = 0.0, Y = 10.0, Z = 0.0 }); // Constrain bottom nodes of the model and add loads model.NodesDictionary[1].Constraints.AddRange(new[] { DOFType.X, DOFType.Y }); model.NodesDictionary[4].Constraints.AddRange(new[] { DOFType.X, DOFType.Y }); model.Loads.Add(new Load() { Amount = 500, Node = model.NodesDictionary[2], DOF = DOFType.X }); model.Loads.Add(new Load() { Amount = 500, Node = model.NodesDictionary[3], DOF = DOFType.X }); // Create Quad4 element and its material var material = new ElasticMaterial2D(StressState2D.PlaneStress) { YoungModulus = 3.76, PoissonRatio = 0.3779 }; var quad = new Quad4(material) { Thickness = 1 }; // Create the element connectivity var element = new Element() { ID = 1, ElementType = quad }; element.AddNode(model.NodesDictionary[1]); element.AddNode(model.NodesDictionary[2]); element.AddNode(model.NodesDictionary[3]); element.AddNode(model.NodesDictionary[4]); // Add quad element to the element and subdomains dictionary of the model model.ElementsDictionary.Add(element.ID, element); model.ConnectDataStructures(); // Setup var linearSystem = new SkylineLinearSystem(model.Forces); var solver = new SolverSkyline(linearSystem); var provider = new ProblemStructural(model); var childAnalyzer = new LinearAnalyzer(solver); var parentAnalyzer = new StaticAnalyzer(provider, childAnalyzer, linearSystem); parentAnalyzer.BuildMatrices(); parentAnalyzer.Initialize(); parentAnalyzer.Solve(); var expectedSolution = new double[] { 253.13237596153559, 66.567582057178811, 253.13237596153553, -66.567582057178811 }; for (int i = 0; i < expectedSolution.Length; i++) { Assert.Equal(expectedSolution[i], linearSystem.Solution[i], 12); } }
private static void TestLinearTrussExample() { // Model and node creation Model model = new Model(); model.NodesDictionary.Add(1, new Node { ID = 1, X = 0, Y = 0 }); model.NodesDictionary.Add(2, new Node { ID = 2, X = 0, Y = 40 }); model.NodesDictionary.Add(3, new Node { ID = 3, X = 40, Y = 40 }); // Constrain bottom nodes of the model and add loads model.NodesDictionary[1].Constraints.AddRange(new[] { DOFType.X, DOFType.Y }); model.NodesDictionary[2].Constraints.AddRange(new[] { DOFType.X, DOFType.Y }); model.Loads.Add(new Load() { Amount = 500, Node = model.NodesDictionary[3], DOF = DOFType.X }); model.Loads.Add(new Load() { Amount = 300, Node = model.NodesDictionary[3], DOF = DOFType.Y }); var element1 = new Truss2D(1e7) { ID = 1, Density = 1, SectionArea = 1.5 }; element1.ElementType = element1; var element2 = new Truss2D(1e7) { ID = 2, Density = 1, SectionArea = 1.5 }; element2.ElementType = element2; element1.AddNode(model.NodesDictionary[1]); element1.AddNode(model.NodesDictionary[3]); element2.AddNode(model.NodesDictionary[2]); element2.AddNode(model.NodesDictionary[3]); model.ElementsDictionary.Add(element1.ID, element1); model.ElementsDictionary.Add(element2.ID, element2); model.ConnectDataStructures(); // Setup var linearSystem = new SkylineLinearSystem(model.Forces); var solver = new SolverSkyline(linearSystem); var provider = new ProblemStructural(model); var childAnalyzer = new LinearAnalyzer(solver); var parentAnalyzer = new StaticAnalyzer(provider, childAnalyzer, linearSystem); parentAnalyzer.BuildMatrices(); parentAnalyzer.Initialize(); parentAnalyzer.Solve(); Assert.Equal(0.00053333333333333336, linearSystem.Solution[0], 10); Assert.Equal(0.0017294083664636196, linearSystem.Solution[1], 10); }
/// <summary> /// Initializes a new instance of the <see cref="TxtWriter"/> class. /// </summary> /// <param name="model">The model.</param> /// <param name="filepath">The filepath.</param> /// <param name="linearSystem">The linear system.</param> public TxtWriter(Model model, string filepath, SkylineLinearSystem linearSystem) { _model = model; _filepath = filepath; _linearSystem = linearSystem; }