コード例 #1
0
        public double[] FindDisplacementsAt(double x, double y)
        {
            Element element = FindElementThatContains(x, y);
            Quad4   quad4   = (Quad4)element.ElementType;

            Node[] nodes = element.Nodes.ToArray();

            // Calculate shape functions
            var inverseInterpolation = new InverseInterpolationQuad4(nodes);

            double[] naturalCoords = inverseInterpolation.TransformPointCartesianToNatural(new double[] { x, y });
            //double[] naturalCoords = quad4.GetNaturalCoordinates(element, new Node() { X = x, Y = y });
            double[] shapeFunctions = quad4.CalcQ4Shape(naturalCoords[0], naturalCoords[1]);

            // Interpolate nodal displacements
            double ux = 0.0, uy = 0.0;

            for (int i = 0; i < nodes.Length; i++)
            {
                int    nodeID = nodes[i].ID;
                double N      = shapeFunctions[i];
                ux += N * nodalDisplacements[nodeID][0];
                uy += N * nodalDisplacements[nodeID][1];
            }

            return(new double[] { ux, uy });
        }
コード例 #2
0
        private Bilinear(double[,] result, Quad4 srcQuad, Quad4 dstQuad)
        {
            rc00   = result[0, 0];
            rc10   = result[1, 0];
            rc20   = result[2, 0];
            rc30   = result[3, 0];
            rc01   = result[0, 1];
            rc11   = result[1, 1];
            rc21   = result[2, 1];
            rc31   = result[3, 1];
            _valid = true;

            _srcQuad = srcQuad;
            _dstQuad = dstQuad;
        }
コード例 #3
0
        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);
            }
        }