Exemplo n.º 1
0
        private static void PrintDisplacementsAlongBottomFiber(Model model, Quad4DisplacementOutput displacementOutput)
        {
            // Define the points where the displacements will be calculated
            double offset = 1E-3; // avoid searching at exactly the edge of the domain, since accuracy loss may cause problems

            double[,] points =
            {
                {      0 + offset, 0 + offset },
                {   0.25 * length, 0 + offset },
                {    0.5 * length, 0 + offset },
                {   0.75 * length, 0 + offset },
                { length - offset, 0 + offset }
            };

            // Calculate the displacements at these points
            int numPoints = points.GetLength(0);
            var displacementsYBottomFiber = new double[numPoints];

            for (int i = 0; i < numPoints; ++i)
            {
                double[] u = displacementOutput.FindDisplacementsAt(points[i, 0], points[i, 1]);
                displacementsYBottomFiber[i] = u[1];
            }

            // Print the displacements
            Console.WriteLine("Displacements y of fiber at y = 0:");
            for (int i = 0; i < numPoints; ++i)
            {
                Console.Write(" " + displacementsYBottomFiber[i]);
            }
            Console.WriteLine();
        }
Exemplo n.º 2
0
        public static void RunExample()
        {
            int numElementsX = 15, numElementsY = 3;

            // Create model
            Model model = CreateModel(numElementsX, numElementsY);

            // Run linear static analysis
            Vector freeDisplacements = RunAnalysis(model);

            // Output
            // First of all prepare the object that will calculate the displacements at arbitrary points
            var displacementOutput = new Quad4DisplacementOutput(model, freeDisplacements);

            // Plot displacements
            displacementOutput.PlotDisplacementField(@"C:\Users\Serafeim\Desktop\temp\displacements.vtk");

            // *******************************************************************************************
            // *******************************************************************************************
            // Excercise: Refine the mesh until the solutions converge
            // *******************************************************************************************
            // *******************************************************************************************
            Console.WriteLine("Max uy = " + displacementOutput.FindMaxDisplacementY());


            // *******************************************************************************************
            // *******************************************************************************************
            // Excercise: Print the displacements ux & uy along other fibers
            // *******************************************************************************************
            // *******************************************************************************************
            PrintDisplacementsAlongBottomFiber(model, displacementOutput);
        }
Exemplo n.º 3
0
        public static void TestDisplacementsAtCantileverFibers()
        {
            // Create model
            int   numElementsX = 20, numElementsY = 5; // the middle fiber will intersect some elements
            Model model = CreateModel(numElementsX, numElementsY);

            // Run linear static analysis
            Vector freeDisplacements = RunAnalysis(model);

            // Find displacements at various points along the bottom, middle and top fiber
            var    displacementOutput = new Quad4DisplacementOutput(model, freeDisplacements);
            double offset             = 1E-3; // avoid searching at exactly the edge of elements, since accuracy loss may vause problems.

            double[] samplesX = { 0 + offset, 0.25 * length, 0.5 * length, 0.75 * length, length - offset };

            // Bottom fiber
            double bottomY = 0.0 + offset;
            var    displacementsBottomFiber = new double[samplesX.Length];

            for (int i = 0; i < samplesX.Length; ++i)
            {
                double[] u = displacementOutput.FindDisplacementsAt(samplesX[i], bottomY);
                displacementsBottomFiber[i] = u[1];
            }

            // Middle fiber
            double middleY = 0.5 * height;
            var    displacementsMiddleFiber = new double[samplesX.Length];

            for (int i = 0; i < samplesX.Length; ++i)
            {
                double[] u = displacementOutput.FindDisplacementsAt(samplesX[i], middleY);
                displacementsMiddleFiber[i] = u[1];
            }

            // Top fiber
            double topY = height - offset;
            var    displacementsTopFiber = new double[samplesX.Length];

            for (int i = 0; i < samplesX.Length; ++i)
            {
                double[] u = displacementOutput.FindDisplacementsAt(samplesX[i], topY);
                displacementsTopFiber[i] = u[1];
            }

            //Test solution
            for (int i = 0; i < samplesX.Length - 1; ++i)
            {
                Assert.True(Math.Abs(displacementsBottomFiber[i]) < Math.Abs(displacementsBottomFiber[i + 1]));
                Assert.True(Math.Abs(displacementsMiddleFiber[i]) < Math.Abs(displacementsMiddleFiber[i + 1]));
                Assert.True(Math.Abs(displacementsTopFiber[i]) < Math.Abs(displacementsTopFiber[i + 1]));
            }
        }