예제 #1
0
        public void SolveNewmark()
        {
            List <double> aConstants = CalculateIntegrationConstantsNewmark();

            double[,] hatStiffnessMatrixNewmark = CalculateHatKMatrixNewmark(aConstants);
            explicitSolution.Add(0, InitialValues.InitialDisplacementVector);
            explicitVelocity.Add(0, InitialValues.InitialVelocityVector);
            explicitAcceleration.Add(0, CalculateInitialAccelerationsNewmark());
            TimeAtEachStep.Add(0, 0.0);
            double[] nextSolution;
            for (int i = 1; i < timeStepsNumber; i++)
            {
                double time = i * timeStep + InitialValues.InitialTime;

                if (ActivateNonLinearSolution == false)
                {
                    double[] hatRVectorNewmark = CalculateHatRVectorNewmark(i, aConstants);
                    nextSolution = LinearSolver.Solve(hatStiffnessMatrixNewmark, hatRVectorNewmark);
                    Console.WriteLine("Solution for Load Step {0} is:", i);
                    VectorOperations.PrintVector(nextSolution);
                }
                else
                {
                    nextSolution = NewtonIterationsNewmark(ExternalForcesVector, i, aConstants);
                    Console.WriteLine("Solution for Load Step {0} is:", i);
                    VectorOperations.PrintVector(nextSolution);
                }
                explicitSolution.Add(i, nextSolution);
                explicitAcceleration.Add(i, CalculateAccelerationNewmark(i, aConstants));
                explicitVelocity.Add(i, CalculateVelocityNewmark(i, aConstants));
                TimeAtEachStep.Add(i, time);
            }
            ExportToFile.ExportExplicitResults(explicitSolution, TimeAtEachStep, 1, 1);
            //ShowToGUI.ShowResults(explicitSolution, TimeAtEachStep, 1, 1);
        }
예제 #2
0
        public void SolveExplicit()
        {
            double[,] hatMassMatrix = CalculateHatMMatrix();
            explicitSolution.Add(-1, CalculatePreviousDisplacementVector());
            explicitSolution.Add(0, InitialValues.InitialDisplacementVector);
            explicitAcceleration.Add(0, CalculateInitialAccelerations());
            TimeAtEachStep.Add(-1, -1 * timeStep + InitialValues.InitialTime);
            TimeAtEachStep.Add(0, 0.0);
            double[] nextSolution;
            for (int i = 1; i < timeStepsNumber; i++)
            {
                double time = i * timeStep + InitialValues.InitialTime;

                if (ActivateNonLinearSolution == false)
                {
                    double[] hatRVector = CalculateHatRVector(i);
                    nextSolution = LinearSolver.Solve(hatMassMatrix, hatRVector);
                    Console.WriteLine("Solution for Load Step {0} is:", i);
                    VectorOperations.PrintVector(nextSolution);
                }
                else
                {
                    double[] hatRVector = CalculateHatRVectorNL(i);
                    nextSolution = LinearSolver.Solve(hatMassMatrix, hatRVector);
                    //nextSolution = NewtonIterations(hatRVector);
                    Console.WriteLine("Solution for Load Step {0} is:", i);
                    VectorOperations.PrintVector(nextSolution);
                }
                explicitSolution.Add(i, nextSolution);
                explicitAcceleration.Add(i, CalculateAccelerations());
                TimeAtEachStep.Add(i, time);
            }
            ExportToFile.ExportExplicitResults(explicitSolution, TimeAtEachStep, 1, 1);
        }
예제 #3
0
        private void Button_Test(object sender, RoutedEventArgs e)
        {
            double[] testVector = new double[75];
            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 15; j++)
                {
                    testVector[i * 15 + j] = i;
                }
            }
            string path = @"C:\Users\Public\Documents\ContourDataY.dat";

            ExportToFile.CreateContourDataForMatlab(testVector, testVector, testVector, 5, 15, path);
        }
예제 #4
0
        public static Results RunStaticExample()
        {
            #region Structural
            IAssembly elementsAssembly = CreateAssembly();
            elementsAssembly.CreateElementsAssembly();
            elementsAssembly.ActivateBoundaryConditions = true;
            double[,] globalStiffnessMatrix             = elementsAssembly.CreateTotalStiffnessMatrix();

            //Gnuplot graphs
            ShowToGUI.PlotInitialGeometry(elementsAssembly);

            Dictionary <int, INode> initialNodes = elementsAssembly.Nodes;
            double[] initialXCoord = Assembly.NodalCoordinatesToVectors(initialNodes).Item1;
            double[] initialYCoord = Assembly.NodalCoordinatesToVectors(initialNodes).Item2;

            double[] Xvec1Initial = new double[totalNodes / 2];
            double[] Yvec1Initial = new double[totalNodes / 2];
            double[] Xvec2Initial = new double[totalNodes / 2];
            double[] Yvec2Initial = new double[totalNodes / 2];
            double[] Ζvec1Initial = Enumerable.Repeat(1.0, totalNodes / 2).ToArray();
            double[] Ζvec2Initial = Enumerable.Repeat(1.0, totalNodes / 2).ToArray();

            Array.Copy(initialXCoord, 0, Xvec1Initial, 0, totalNodes / 2);
            Array.Copy(initialYCoord, 0, Yvec1Initial, 0, totalNodes / 2);

            Array.Copy(initialXCoord, totalNodes / 2, Xvec2Initial, 0, totalNodes / 2);
            Array.Copy(initialYCoord, totalNodes / 2, Yvec2Initial, 0, totalNodes / 2);
            string pathForContour1 = @"C:\Users\Public\Documents\Total\1";
            string pathForContour2 = @"C:\Users\Public\Documents\Total\2";
            ExportToFile.CreateContourDataForMatlab(Xvec1Initial, Yvec1Initial, Ζvec1Initial, nodesInYCoor, nodesInXCoor, pathForContour1);
            ExportToFile.CreateContourDataForMatlab(Xvec2Initial, Yvec2Initial, Ζvec2Initial, nodesInYCoor, nodesInXCoor, pathForContour2);



            ///structuralSolution = new StaticSolver();
            structuralSolution.LinearScheme = new PCGSolver();
            //structuralSolution.NonLinearScheme = new LoadControlledNewtonRaphson();
            structuralSolution.NonLinearScheme.Tolerance         = 1e-6;
            structuralSolution.ActivateNonLinearSolver           = true;
            structuralSolution.NonLinearScheme.numberOfLoadSteps = 40;

            double[] externalForces3 = externalForcesStructuralVector;
            foreach (var dof in loadedStructuralDOFs)
            {
                externalForces3[dof - 1] = externalStructuralLoad;
            }



            double[] reducedExternalForces3 = BoundaryConditionsImposition.ReducedVector(externalForces3, elementsAssembly.BoundedDOFsVector);
            structuralSolution.AssemblyData = elementsAssembly;
            structuralSolution.Solve(reducedExternalForces3);
            double[] solvector3 = structuralSolution.GetSolution();
            elementsAssembly.UpdateDisplacements(solvector3);
            ShowToGUI.PlotFinalGeometry(elementsAssembly);
            double[] fullSolVector3                      = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(solvector3, elementsAssembly.BoundedDOFsVector);
            Dictionary <int, INode> finalNodes           = Assembly.CalculateFinalNodalCoordinates(elementsAssembly.Nodes, fullSolVector3);
            double[] xFinalNodalCoor                     = Assembly.NodalCoordinatesToVectors(finalNodes).Item1;
            double[] yFinalNodalCoor                     = Assembly.NodalCoordinatesToVectors(finalNodes).Item2;
            Dictionary <int, double[]> allStepsSolutions = structuralSolution.GetAllStepsSolutions();

            Dictionary <int, Dictionary <int, double[]> > allStepsContactForces    = new Dictionary <int, Dictionary <int, double[]> >();
            Dictionary <int, Dictionary <int, double> >   allStepsProjectionPoints = new Dictionary <int, Dictionary <int, double> >();
            Dictionary <int, double[]> elementsInternalContactForcesVector;
            Dictionary <int, double>   projectionPointForEachElement;
            for (int i = 1; i <= allStepsSolutions.Count; i++)
            {
                elementsInternalContactForcesVector = new Dictionary <int, double[]>();
                projectionPointForEachElement       = new Dictionary <int, double>();
                elementsAssembly.UpdateDisplacements(allStepsSolutions[i]);
                for (int j = totalElements + 1; j <= totalElements + totalContactElements - 1; j++)
                {
                    elementsInternalContactForcesVector[j] = elementsAssembly.ElementsAssembly[j].CreateInternalGlobalForcesVector();
                    projectionPointForEachElement[j]       = elementsAssembly.ElementsAssembly[j].ClosestPointProjection();
                }
                allStepsContactForces[i]    = elementsInternalContactForcesVector;
                allStepsProjectionPoints[i] = projectionPointForEachElement;
            }



            List <double[]> structuralSolutions = new List <double[]>();

            ExportToFile.ExportMatlabInitialGeometry(elementsAssembly);
            #endregion


            #region Thermal
            List <double[]> thermalSolutions = new List <double[]>();
            List <Dictionary <int, double> > contactContactivityForEachStep = new List <Dictionary <int, double> >();
            for (int k = 1; k <= allStepsSolutions.Count; k++)
            {
                IAssembly elementsAssembly2 = CreateThermalAssembly();

                for (int j = totalElements + 1; j <= totalElements + totalContactElements - 1; j++)
                {
                    double[] contactForce = allStepsContactForces[k][j];
                    elementsAssembly2.ElementsProperties[j].ContactForceValue = -contactForce[5];
                    double projectionPoint = allStepsProjectionPoints[k][j];
                    elementsAssembly2.ElementsProperties[j].Dx1 = projectionPoint;
                }

                elementsAssembly2.CreateElementsAssembly();
                elementsAssembly2.ActivateBoundaryConditions = true;
                double[,] globalStiffnessMatrix2             = elementsAssembly2.CreateTotalStiffnessMatrix();

                ISolver thermalSolution = new StaticSolver();
                thermalSolution.LinearScheme                      = new LUFactorization();
                thermalSolution.NonLinearScheme                   = new LoadControlledNewtonRaphson();
                thermalSolution.NonLinearScheme.Tolerance         = 1e-9;
                thermalSolution.ActivateNonLinearSolver           = true;
                thermalSolution.NonLinearScheme.numberOfLoadSteps = 40;

                thermalSolution.AssemblyData = elementsAssembly2;
                double[] externalHeatFlux = externalHeatLoafVector;
                //externalHeatFlux[0] =  externalHeatLoad;
                //externalHeatFlux[15] = externalHeatLoad;
                //externalHeatFlux[30] = externalHeatLoad;
                //externalHeatFlux[45] = externalHeatLoad;
                //externalHeatFlux[60] = externalHeatLoad;
                foreach (var dof in loadedThermalDOFs)
                {
                    if ((dof == ThermalDof1 | dof == ThermalDof2))
                    {
                        externalHeatFlux[dof - 1] = externalHeatLoad / 2;
                    }
                    else
                    {
                        externalHeatFlux[dof - 1] = externalHeatLoad;
                    }
                }
                //foreach (var dof in loadedThermalDOFs)
                //{
                //    externalHeatFlux[dof - 1] = externalHeatLoad;
                //}
                //for (int i = 61; i <= 75; i++)
                //{
                //    externalHeatFlux[61] = externalHeatLoad;
                //}
                double[] reducedExternalHeatFlux = BoundaryConditionsImposition.ReducedVector(externalHeatFlux, thermalSolution.AssemblyData.BoundedDOFsVector);
                thermalSolution.Solve(reducedExternalHeatFlux);
                double[] tempSol = thermalSolution.GetSolution();
                thermalSolutions.Add(tempSol);

                Dictionary <int, double> contactContactivity = AssemblyHelpMethods.RetrieveContactContactivity(thermalSolution.AssemblyData);
                contactContactivityForEachStep.Add(contactContactivity);
            }

            int[]    thermalBoundCond     = thermalBoundaryConditions;
            double[] fullStructuralSol1   = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[8], elementsAssembly.BoundedDOFsVector);
            double[] fullStructuralSol2   = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[16], elementsAssembly.BoundedDOFsVector);
            double[] fullStructuralSol3   = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[24], elementsAssembly.BoundedDOFsVector);
            double[] fullStructuralSol4   = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[32], elementsAssembly.BoundedDOFsVector);
            double[] fullStructuralSol5   = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[40], elementsAssembly.BoundedDOFsVector);
            double[] fullThermalSol1      = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(thermalSolutions[7], thermalBoundCond);
            double[] fullThermalSol2      = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(thermalSolutions[15], thermalBoundCond);
            double[] fullThermalSol3      = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(thermalSolutions[23], thermalBoundCond);
            double[] fullThermalSol4      = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(thermalSolutions[31], thermalBoundCond);
            double[] fullThermalSol5      = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(thermalSolutions[39], thermalBoundCond);
            double[] fullThermalSolfinal1 = new double[fullThermalSol1.Length + 1];
            double[] fullThermalSolfinal2 = new double[fullThermalSol1.Length + 1];
            double[] fullThermalSolfinal3 = new double[fullThermalSol1.Length + 1];
            double[] fullThermalSolfinal4 = new double[fullThermalSol1.Length + 1];
            double[] fullThermalSolfinal5 = new double[fullThermalSol1.Length + 1];

            for (int runs = 0; runs < fullThermalSol1.Length; runs++)
            {
                fullThermalSolfinal1[runs] = fullThermalSol1[runs];
                fullThermalSolfinal2[runs] = fullThermalSol2[runs];
                fullThermalSolfinal3[runs] = fullThermalSol3[runs];
                fullThermalSolfinal4[runs] = fullThermalSol4[runs];
                fullThermalSolfinal5[runs] = fullThermalSol5[runs];
            }
            double[] contactContactivityForLoadStep1 = contactContactivityForEachStep[3].Values.ToArray();
            double[] contactContactivityForLoadStep2 = contactContactivityForEachStep[7].Values.ToArray();
            double[] contactContactivityForLoadStep3 = contactContactivityForEachStep[11].Values.ToArray();
            double[] contactContactivityForLoadStep4 = contactContactivityForEachStep[15].Values.ToArray();
            double[] contactContactivityForLoadStep5 = contactContactivityForEachStep[19].Values.ToArray();
            ExportToFile.ExportGeometryDataWithTemperatures(Assembly.CalculateFinalNodalCoordinates(elementsAssembly.Nodes, fullStructuralSol1), fullThermalSolfinal1, @"C:\Users\Public\Documents\Results1.dat");
            ExportToFile.ExportGeometryDataWithTemperatures(Assembly.CalculateFinalNodalCoordinates(elementsAssembly.Nodes, fullStructuralSol2), fullThermalSolfinal2, @"C:\Users\Public\Documents\Results2.dat");
            ExportToFile.ExportGeometryDataWithTemperatures(Assembly.CalculateFinalNodalCoordinates(elementsAssembly.Nodes, fullStructuralSol3), fullThermalSolfinal3, @"C:\Users\Public\Documents\Results3.dat");
            ExportToFile.ExportGeometryDataWithTemperatures(Assembly.CalculateFinalNodalCoordinates(elementsAssembly.Nodes, fullStructuralSol4), fullThermalSolfinal4, @"C:\Users\Public\Documents\Results4.dat");
            ExportToFile.ExportGeometryDataWithTemperatures(Assembly.CalculateFinalNodalCoordinates(elementsAssembly.Nodes, fullStructuralSol5), fullThermalSolfinal5, @"C:\Users\Public\Documents\Results5.dat");
            VectorOperations.PrintVectorToFile(contactContactivityForLoadStep1, @"C:\Users\Public\Documents\contactivity1.dat");
            VectorOperations.PrintVectorToFile(contactContactivityForLoadStep2, @"C:\Users\Public\Documents\contactivity2.dat");
            VectorOperations.PrintVectorToFile(contactContactivityForLoadStep3, @"C:\Users\Public\Documents\contactivity3.dat");
            VectorOperations.PrintVectorToFile(contactContactivityForLoadStep4, @"C:\Users\Public\Documents\contactivity4.dat");
            VectorOperations.PrintVectorToFile(contactContactivityForLoadStep5, @"C:\Users\Public\Documents\contactivity5.dat");

            structuralSolutions.Add(fullStructuralSol1);
            structuralSolutions.Add(fullStructuralSol2);
            structuralSolutions.Add(fullStructuralSol3);
            structuralSolutions.Add(fullStructuralSol4);
            structuralSolutions.Add(fullStructuralSol5);



            double[] Xvec1Final = new double[totalNodes / 2];
            double[] Yvec1Final = new double[totalNodes / 2];
            double[] Xvec2Final = new double[totalNodes / 2];
            double[] Yvec2Final = new double[totalNodes / 2];
            double[] Ζvec1Final = new double[totalNodes / 2];
            double[] Ζvec2Final = new double[totalNodes / 2];

            Array.Copy(xFinalNodalCoor, 0, Xvec1Final, 0, totalNodes / 2);
            Array.Copy(yFinalNodalCoor, 0, Yvec1Final, 0, totalNodes / 2);
            Array.Copy(fullThermalSol4, 0, Ζvec1Final, 0, totalNodes / 2);
            Array.Copy(xFinalNodalCoor, totalNodes / 2, Xvec2Final, 0, totalNodes / 2);
            Array.Copy(yFinalNodalCoor, totalNodes / 2, Yvec2Final, 0, totalNodes / 2);
            Array.Copy(fullThermalSol4, totalNodes / 2, Ζvec2Final, 0, totalNodes / 2);

            List <HeatMapData> plots2 = new List <HeatMapData>();
            plots2.Add(new HeatMapData()
            {
                Xcoordinates = Xvec1Final, Ycoordinates = Yvec1Final, Temperatures = Ζvec1Final
            });
            plots2.Add(new HeatMapData()
            {
                Xcoordinates = Xvec2Final, Ycoordinates = Yvec2Final, Temperatures = Ζvec2Final
            });

            ShowToGUI.PlotHeatMap(plots2);

            string path  = @"C:\Users\Public\Documents\Total\1final";
            string path2 = @"C:\Users\Public\Documents\Total\2final";
            ExportToFile.CreateContourDataForMatlab(Xvec1Final, Yvec1Final, Ζvec1Final, nodesInYCoor, nodesInXCoor, path);
            ExportToFile.CreateContourDataForMatlab(Xvec2Final, Yvec2Final, Ζvec2Final, nodesInYCoor, nodesInXCoor, path2);

            //ExportToFile.ExportGeometryDataWithTemperatures(finalNodes, fullTempSol);

            GnuPlot.Close();

            while (true)
            {
                if (File.Exists(AppContext.BaseDirectory + "gnuplot.png") && new FileInfo(AppContext.BaseDirectory + "gnuplot.png").Length > 0)
                {
                    break;
                }
                Thread.Sleep(100);
            }
            GnuPlot.KillProcess();
            #endregion



            return(new Results()
            {
                NonlinearSolution = structuralSolutions, SelectedDOF = 2, SolutionType = "Nonlinear"
            });
        }
예제 #5
0
        public static Results RunStaticExample()
        {
            #region Structural
            IAssembly elementsAssembly = CreateAssembly();
            elementsAssembly.CreateElementsAssembly();
            elementsAssembly.ActivateBoundaryConditions = true;
            double[,] globalStiffnessMatrix             = elementsAssembly.CreateTotalStiffnessMatrix();

            //Gnuplot graphs
            ShowToGUI.PlotInitialGeometry(elementsAssembly);

            ExportToFile.ExportMatlabInitialGeometry(elementsAssembly);


            //ISolver structuralSolution = new StaticSolver();
            structuralSolution.LinearScheme = new LUFactorization();
            //structuralSolution.NonLinearScheme = new LoadControlledNewtonRaphson();
            structuralSolution.ActivateNonLinearSolver           = true;
            structuralSolution.NonLinearScheme.numberOfLoadSteps = 10;
            //int[] BoundedDOFsVector2 = new int[] { 1, 2, 31, 32, 61, 62, 91, 92, 121, 122, 179, 180, 209, 210, 239, 240, 269, 270, 299, 300 };

            double[] externalForces3 = externalForcesStructuralVector;
            foreach (var dof in loadedStructuralDOFs)
            {
                externalForces3[dof] = externalStructuralLoad;
            }
            //externalForces3[135] = externalStructuralLoad;
            //externalForces3[137] = externalStructuralLoad;
            //externalForces3[139] = externalStructuralLoad;
            //externalForces3[141] = externalStructuralLoad;
            //externalForces3[143] = externalStructuralLoad;
            //externalForces3[145] = externalStructuralLoad;
            //externalForces3[147] = externalStructuralLoad;
            //externalForces3[149] = externalStructuralLoad;


            double[] reducedExternalForces3 = BoundaryConditionsImposition.ReducedVector(externalForces3, elementsAssembly.BoundedDOFsVector);
            structuralSolution.AssemblyData = elementsAssembly;
            structuralSolution.Solve(reducedExternalForces3);
            double[] solvector3 = structuralSolution.GetSolution();
            elementsAssembly.UpdateDisplacements(solvector3);
            //ShowToGUI.PlotFinalGeometry(elementsAssembly);

            double[] fullSolVector3 = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(solvector3, elementsAssembly.BoundedDOFsVector);

            ExportToFile.ExportMatlabFinalGeometry(elementsAssembly, fullSolVector3);
            Dictionary <int, INode> finalNodes           = Assembly.CalculateFinalNodalCoordinates(elementsAssembly.Nodes, fullSolVector3);
            double[] xFinalNodalCoor                     = Assembly.NodalCoordinatesToVectors(finalNodes).Item1;
            double[] yFinalNodalCoor                     = Assembly.NodalCoordinatesToVectors(finalNodes).Item2;
            Dictionary <int, double[]> allStepsSolutions = structuralSolution.GetAllStepsSolutions();

            Dictionary <int, Dictionary <int, double[]> > allStepsContactForces = new Dictionary <int, Dictionary <int, double[]> >();
            Dictionary <int, double[]> elementsInternalContactForcesVector;
            for (int i = 1; i <= allStepsSolutions.Count; i++)
            {
                elementsInternalContactForcesVector = new Dictionary <int, double[]>();
                elementsAssembly.UpdateDisplacements(allStepsSolutions[i]);
                for (int j = 113; j <= 120; j++)
                {
                    elementsInternalContactForcesVector[j] = elementsAssembly.ElementsAssembly[j].CreateInternalGlobalForcesVector();
                }
                allStepsContactForces[i] = elementsInternalContactForcesVector;
            }



            //    double[] solVector2 = new double[280];
            List <double[]> structuralSolutions = new List <double[]>();
            //    int[] BoundedDOFsVector = new int[] { 1, 2, 31, 32, 61, 62, 91, 92, 121, 122, 179, 180, 209, 210, 239, 240, 269, 270, 299, 300 };
            //    double[] externalForces2 = new double[300];
            //    for (int i = 1; i <= 5; i++)
            //    {
            //        structuralSolution.NonLinearScheme = new LoadControlledNewtonRaphson(solVector2);
            //        externalForces2[135] = -10000.0 * i;
            //        externalForces2[137] = -10000.0 * i;
            //        externalForces2[139] = -10000.0 * i;
            //        externalForces2[141] = -10000.0 * i;
            //        externalForces2[143] = -10000.0 * i;
            //        externalForces2[145] = -10000.0 * i;
            //        externalForces2[147] = -10000.0 * i;
            //        externalForces2[149] = -10000.0 * i;
            //        double[] reducedExternalForces2 = BoundaryConditionsImposition.ReducedVector(externalForces2, BoundedDOFsVector);
            //        structuralSolution.AssemblyData = elementsAssembly;
            //        structuralSolution.Solve(reducedExternalForces2);
            //        solVector2 = structuralSolution.GetSolution();
            //        structuralSolutions.Add(solVector2);
            //    }
            //    Dictionary<int, double[]> intForces = structuralSolution.GetInternalForces();
            //    Dictionary<int, double[]> elementInternalForces = elementsAssembly.GetElementsInternalForces(structuralSolutions[0]);
            //    List<string> elementTypes = elementsAssembly.GetElementsType();
            //    double[] completeFinalSolutionVector = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(solVector2, BoundedDOFsVector);
            //    Dictionary<int, INode> finalNodesList = new Dictionary<int, INode>();
            //    finalNodesList = Assembly.CalculateFinalNodalCoordinates(elementsAssembly.Nodes, completeFinalSolutionVector);
            #endregion


            #region Thermal
            List <double[]> thermalSolutions = new List <double[]>();
            for (int k = 1; k <= allStepsSolutions.Count; k++)
            {
                IAssembly elementsAssembly2 = CreateThermalAssembly();

                for (int j = 113; j < 120; j++)
                {
                    double[] contactForce = allStepsContactForces[k][j];
                    elementsAssembly2.ElementsProperties[j].ContactForceValue = VectorOperations.VectorNorm2(new double[] { contactForce[2], contactForce[3] });
                }

                elementsAssembly2.CreateElementsAssembly();
                elementsAssembly2.ActivateBoundaryConditions = true;
                double[,] globalStiffnessMatrix2             = elementsAssembly2.CreateTotalStiffnessMatrix();

                ISolver thermalSolution = new StaticSolver();
                thermalSolution.LinearScheme                      = new LUFactorization();
                thermalSolution.NonLinearScheme                   = new LoadControlledNewtonRaphson();
                thermalSolution.ActivateNonLinearSolver           = true;
                thermalSolution.NonLinearScheme.numberOfLoadSteps = 10;

                thermalSolution.AssemblyData = elementsAssembly2;
                double[] externalHeatFlux = externalHeatLoafVector;
                //externalHeatFlux[0] =  externalHeatLoad;
                //externalHeatFlux[15] = externalHeatLoad;
                //externalHeatFlux[30] = externalHeatLoad;
                //externalHeatFlux[45] = externalHeatLoad;
                //externalHeatFlux[60] = externalHeatLoad;

                foreach (var dof in loadedThermalDOFs)
                {
                    externalHeatFlux[dof] = externalHeatLoad;
                }
                //for (int i = 61; i <= 75; i++)
                //{
                //    externalHeatFlux[61] = externalHeatLoad;
                //}
                double[] reducedExternalHeatFlux = BoundaryConditionsImposition.ReducedVector(externalHeatFlux, thermalSolution.AssemblyData.BoundedDOFsVector);
                thermalSolution.Solve(reducedExternalHeatFlux);
                double[] tempSol = thermalSolution.GetSolution();
                thermalSolutions.Add(tempSol);
            }

            int[]    thermalBoundCond   = thermalBoundaryConditions;
            double[] fullStructuralSol1 = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[2], elementsAssembly.BoundedDOFsVector);
            double[] fullStructuralSol2 = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[4], elementsAssembly.BoundedDOFsVector);
            double[] fullStructuralSol3 = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[6], elementsAssembly.BoundedDOFsVector);
            double[] fullStructuralSol4 = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[8], elementsAssembly.BoundedDOFsVector);
            double[] fullStructuralSol5 = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[10], elementsAssembly.BoundedDOFsVector);
            double[] fullThermalSol1    = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(thermalSolutions[1], thermalBoundCond);
            double[] fullThermalSol2    = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(thermalSolutions[3], thermalBoundCond);
            double[] fullThermalSol3    = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(thermalSolutions[5], thermalBoundCond);
            double[] fullThermalSol4    = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(thermalSolutions[7], thermalBoundCond);
            double[] fullThermalSol5    = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(thermalSolutions[9], thermalBoundCond);
            ExportToFile.ExportGeometryDataWithTemperatures(Assembly.CalculateFinalNodalCoordinates(elementsAssembly.Nodes, fullStructuralSol1), fullThermalSol1, @"C:\Users\Public\Documents\Results1.dat");
            ExportToFile.ExportGeometryDataWithTemperatures(Assembly.CalculateFinalNodalCoordinates(elementsAssembly.Nodes, fullStructuralSol2), fullThermalSol2, @"C:\Users\Public\Documents\Results2.dat");
            ExportToFile.ExportGeometryDataWithTemperatures(Assembly.CalculateFinalNodalCoordinates(elementsAssembly.Nodes, fullStructuralSol3), fullThermalSol3, @"C:\Users\Public\Documents\Results3.dat");
            ExportToFile.ExportGeometryDataWithTemperatures(Assembly.CalculateFinalNodalCoordinates(elementsAssembly.Nodes, fullStructuralSol4), fullThermalSol4, @"C:\Users\Public\Documents\Results4.dat");
            ExportToFile.ExportGeometryDataWithTemperatures(Assembly.CalculateFinalNodalCoordinates(elementsAssembly.Nodes, fullStructuralSol5), fullThermalSol5, @"C:\Users\Public\Documents\Results5.dat");



            //double[] temperatures = new double[135];

            //int[] BoundedDOFsVectorForHeat = new int[] { 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165 };
            //for (int i = 1; i <= 5; i++)
            //{
            //    thermalSolution.NonLinearScheme = new LoadControlledNewtonRaphson(temperatures);
            //    double[] externalHeatFlux = new double[150];
            //    double[] reducedExternalHeatFlux = BoundaryConditionsImposition.ReducedVector(externalHeatFlux, BoundedDOFsVectorForHeat);
            //    thermalSolution.AssemblyData = elementsAssembly2;
            //    thermalSolution.Solve(reducedExternalHeatFlux);
            //    temperatures = thermalSolution.GetSolution();
            //    thermalSolutions.Add(temperatures);
            //}
            //List<double> X = new List<double>();
            //List<double> Y = new List<double>();
            //double[] fullTempSol = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(tempSol, thermalSolution.AssemblyData.BoundedDOFsVector);
            //double[] Z = fullTempSol;//thermalSolutions[4];
            //foreach (var node in elementsAssembly2.Nodes)
            //{
            //    X.Add(node.Value.XCoordinate);
            //    Y.Add(node.Value.YCoordinate);

            //}
            //double[] Xvec = X.ToArray();
            //double[] Yvec = Y.ToArray();


            //double[] Xvec1 = new double[75];
            //double[] Yvec1 = new double[75];
            //double[] Zvec1 = new double[75];
            //double[] Xvec2 = new double[75];
            //double[] Yvec2 = new double[75];
            //double[] Zvec2 = new double[75];
            //Array.Copy(Xvec, 75, Xvec2, 0, 75);
            //Array.Copy(Yvec, 75, Yvec2, 0, 75);
            //Array.Copy(Z, 75, Zvec2, 0, 75);
            //Array.Copy(Xvec, 0, Xvec1, 0, 75);
            //Array.Copy(Yvec, 0, Yvec1, 0, 75);
            //Array.Copy(Z, 0, Zvec1, 0, 75);
            //GnuPlot.Set("terminal png size 500, 300");
            //GnuPlot.Set("output 'gnuplot.png'");

            //GnuPlot.HoldOn();
            //GnuPlot.Set("cbrange[0:20.0]");
            //GnuPlot.Set("palette defined(0 \"blue\", 1 \"red\")");
            //GnuPlot.Set("pm3d");
            //GnuPlot.Set("dgrid3d");
            //GnuPlot.Set("view map");
            //GnuPlot.SPlot(Xvec1, Yvec1, Zvec1);
            //GnuPlot.SPlot(Xvec2, Yvec2, Zvec2);
            //GnuPlot.Set("output");
            //List<HeatMapData> plots = new List<HeatMapData>();
            //plots.Add(new HeatMapData() { Xcoordinates = Xvec1, Ycoordinates = Yvec1, Temperatures = Zvec1 });
            //plots.Add(new HeatMapData() { Xcoordinates = Xvec2, Ycoordinates = Yvec2, Temperatures = Zvec2 });
            ////ShowToGUI.PlotHeatMap(plots);

            double[] Xvec1Final = new double[75];
            double[] Yvec1Final = new double[75];
            double[] Xvec2Final = new double[75];
            double[] Yvec2Final = new double[75];
            double[] Ζvec1Final = new double[75];
            double[] Ζvec2Final = new double[75];

            Array.Copy(xFinalNodalCoor, 0, Xvec1Final, 0, 75);
            Array.Copy(yFinalNodalCoor, 0, Yvec1Final, 0, 75);
            Array.Copy(fullThermalSol4, 0, Ζvec1Final, 0, 75);
            Array.Copy(xFinalNodalCoor, 75, Xvec2Final, 0, 75);
            Array.Copy(yFinalNodalCoor, 75, Yvec2Final, 0, 75);
            Array.Copy(fullThermalSol4, 75, Ζvec2Final, 0, 75);

            List <HeatMapData> plots2 = new List <HeatMapData>();
            plots2.Add(new HeatMapData()
            {
                Xcoordinates = Xvec1Final, Ycoordinates = Yvec1Final, Temperatures = Ζvec1Final
            });
            plots2.Add(new HeatMapData()
            {
                Xcoordinates = Xvec2Final, Ycoordinates = Yvec2Final, Temperatures = Ζvec2Final
            });
            //GnuPlot.HoldOn();
            //GnuPlot.Set("pm3d");
            //GnuPlot.Set("dgrid3d");
            //GnuPlot.Set("view map");
            //GnuPlot.SPlot(new double[] { -1.0, 2.0, 1.0, -1.0}, new double[] { 1.0, 2.0, -1.0, 1.0 }, new double[] { 2, 1, 3, 2 });
            ////GnuPlot.SPlot(new double[] { -1.0, 1.0, 3.0 }, new double[] { 2.0, 2.0, -1.0 }, new double[] { 5, 4, 9 });
            ////GnuPlot.Plot(Xvec2Final, Yvec2Final);
            ShowToGUI.PlotHeatMap(plots2);

            string path  = @"C:\Users\Public\Documents\Total\1final";
            string path2 = @"C:\Users\Public\Documents\Total\2final";
            ExportToFile.CreateContourDataForMatlab(Xvec1Final, Yvec1Final, Ζvec1Final, 5, 15, path);
            ExportToFile.CreateContourDataForMatlab(Xvec2Final, Yvec2Final, Ζvec2Final, 5, 15, path2);

            //ExportToFile.ExportGeometryDataWithTemperatures(finalNodes, fullTempSol);

            GnuPlot.Close();

            while (true)
            {
                if (File.Exists(AppContext.BaseDirectory + "gnuplot.png") && new FileInfo(AppContext.BaseDirectory + "gnuplot.png").Length > 0)
                {
                    break;
                }
                Thread.Sleep(100);
            }
            GnuPlot.KillProcess();
            #endregion



            structuralSolutions.Add(fullStructuralSol1);
            structuralSolutions.Add(fullStructuralSol2);
            structuralSolutions.Add(fullStructuralSol3);
            structuralSolutions.Add(fullStructuralSol4);
            structuralSolutions.Add(fullStructuralSol5);
            diagramData.ShowResults(new Results()
            {
                NonlinearSolution = structuralSolutions, SelectedDOF = 2, SolutionType = "Nonlinear"
            });



            return(new Results()
            {
                NonlinearSolution = structuralSolutions, SelectedDOF = 2, SolutionType = "Nonlinear"
            });
        }
예제 #6
0
        public static Results RunStaticExample()
        {
            #region Structural
            IAssembly elementsAssembly = CreateAssembly();
            elementsAssembly.CreateElementsAssembly();
            elementsAssembly.ActivateBoundaryConditions = true;
            double[,] globalStiffnessMatrix             = elementsAssembly.CreateTotalStiffnessMatrix();
            int countContactElements = elementsAssembly.CountElementsOfSameType(typeof(ContactStS2D));
            ShowToGUI.PlotInitialGeometry(elementsAssembly);
            structuralSolution.LinearScheme = new LUFactorization();
            structuralSolution.NonLinearScheme.Tolerance         = 1e-5;
            structuralSolution.ActivateNonLinearSolver           = true;
            structuralSolution.NonLinearScheme.numberOfLoadSteps = 30;

            double[] externalForces3 = externalForcesStructuralVector;
            foreach (var dof in loadedStructuralDOFs)
            {
                externalForces3[dof - 1] = externalStructuralLoad;
            }
            double[] reducedExternalForces3 = BoundaryConditionsImposition.ReducedVector(externalForces3, elementsAssembly.BoundedDOFsVector);
            structuralSolution.AssemblyData = elementsAssembly;
            structuralSolution.Solve(reducedExternalForces3);
            double[] solvector3 = structuralSolution.GetSolution();
            Dictionary <int, double[]>         allStepsSolutions = structuralSolution.GetAllStepsSolutions();
            Dictionary <int, List <double[]> > gPointsStress     = new Dictionary <int, List <double[]> >();
            Dictionary <int, List <double[]> > gPointsStrain     = new Dictionary <int, List <double[]> >();
            Dictionary <int, List <double[]> > gPoints           = new Dictionary <int, List <double[]> >();
            Dictionary <int, List <double[]> > nodalStress       = new Dictionary <int, List <double[]> >();
            Dictionary <int, List <double[]> > nodalStrain       = new Dictionary <int, List <double[]> >();
            for (int i = 1; i <= allStepsSolutions.Count; i++)
            {
                string name = "NodalCoordinates" + i.ToString() + ".dat";
                ExportToFile.ExportUpdatedNodalCoordinates(elementsAssembly, BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions.Single(m => m.Key == i).Value, elementsAssembly.BoundedDOFsVector), name);
                gPointsStress = elementsAssembly.GetElementsStresses(allStepsSolutions[i]);
                gPointsStrain = elementsAssembly.GetElementsStains(allStepsSolutions[i]);
                gPoints       = elementsAssembly.GetElementsGaussPoints(allStepsSolutions[i]);
                nodalStress   = elementsAssembly.GetElementsNodesStresses(allStepsSolutions[i]);
                nodalStrain   = elementsAssembly.GetElementsNodesStains(allStepsSolutions[i]);
                string name1 = "GPointsStress" + i.ToString() + ".dat";
                string name2 = "GPointsStrain" + i.ToString() + ".dat";
                string name3 = "GPointsCoordinates" + i.ToString() + ".dat";
                string name4 = "NodalStress" + i.ToString() + ".dat";
                string name5 = "NodalStrain" + i.ToString() + ".dat";

                VectorOperations.PrintDictionaryofListsofVectorsToFile(gPointsStress, @"C:\Users\Public\Documents\" + name1);
                VectorOperations.PrintDictionaryofListsofVectorsToFile(gPointsStrain, @"C:\Users\Public\Documents\" + name2);
                VectorOperations.PrintDictionaryofListsofVectorsToFile(gPoints, @"C:\Users\Public\Documents\" + name3);
                VectorOperations.PrintDictionaryofListsofVectorsToFile(nodalStress, @"C:\Users\Public\Documents\" + name4);
                VectorOperations.PrintDictionaryofListsofVectorsToFile(nodalStrain, @"C:\Users\Public\Documents\" + name5);
            }
            elementsAssembly.UpdateDisplacements(solvector3);
            ShowToGUI.PlotFinalGeometry(elementsAssembly);
            double[] fullSolVector3            = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(solvector3, elementsAssembly.BoundedDOFsVector);
            Dictionary <int, INode> finalNodes = Assembly.CalculateFinalNodalCoordinates(elementsAssembly.Nodes, fullSolVector3);
            double[] xFinalNodalCoor           = Assembly.NodalCoordinatesToVectors(finalNodes).Item1;
            double[] yFinalNodalCoor           = Assembly.NodalCoordinatesToVectors(finalNodes).Item2;
            Dictionary <int, double[]> allStepsFullSolutions = new Dictionary <int, double[]>();
            Dictionary <int, Dictionary <int, double[]> > allStepsContactForces = new Dictionary <int, Dictionary <int, double[]> >();
            Dictionary <int, double[]> elementsInternalContactForcesVector;
            for (int i = 1; i <= allStepsSolutions.Count; i++)
            {
                elementsInternalContactForcesVector = new Dictionary <int, double[]>();
                elementsAssembly.UpdateDisplacements(allStepsSolutions[i]);
                for (int j = 1; j <= contactElements; j++)
                {
                    elementsInternalContactForcesVector[elementsNumber + j] = elementsAssembly.ElementsAssembly[elementsNumber + j].CreateInternalGlobalForcesVector();
                }
                allStepsContactForces[i] = elementsInternalContactForcesVector;
                string   name   = "ContactForces" + i.ToString() + ".dat";
                double[] Vector = new double[contactElements * 12];
                int      count  = 0;
                for (int j = 1; j <= contactElements; j++)
                {
                    Vector[count] = allStepsContactForces.Single(m => m.Key == i).Value.Single(n => n.Key == elementsNumber + j).Value[0];
                    count        += 1;
                    Vector[count] = allStepsContactForces.Single(m => m.Key == i).Value.Single(n => n.Key == elementsNumber + j).Value[1];
                    count        += 1;
                    Vector[count] = allStepsContactForces.Single(m => m.Key == i).Value.Single(n => n.Key == elementsNumber + j).Value[2];
                    count        += 1;
                    Vector[count] = allStepsContactForces.Single(m => m.Key == i).Value.Single(n => n.Key == elementsNumber + j).Value[3];
                    count        += 1;
                    Vector[count] = allStepsContactForces.Single(m => m.Key == i).Value.Single(n => n.Key == elementsNumber + j).Value[4];
                    count        += 1;
                    Vector[count] = allStepsContactForces.Single(m => m.Key == i).Value.Single(n => n.Key == elementsNumber + j).Value[5];
                    count        += 1;
                    Vector[count] = allStepsContactForces.Single(m => m.Key == i).Value.Single(n => n.Key == elementsNumber + j).Value[6];
                    count        += 1;
                    Vector[count] = allStepsContactForces.Single(m => m.Key == i).Value.Single(n => n.Key == elementsNumber + j).Value[7];
                    count        += 1;
                    Vector[count] = allStepsContactForces.Single(m => m.Key == i).Value.Single(n => n.Key == elementsNumber + j).Value[8];
                    count        += 1;
                    Vector[count] = allStepsContactForces.Single(m => m.Key == i).Value.Single(n => n.Key == elementsNumber + j).Value[9];
                    count        += 1;
                    Vector[count] = allStepsContactForces.Single(m => m.Key == i).Value.Single(n => n.Key == elementsNumber + j).Value[10];
                    count        += 1;
                    Vector[count] = allStepsContactForces.Single(m => m.Key == i).Value.Single(n => n.Key == elementsNumber + j).Value[11];
                    count        += 1;
                }
                VectorOperations.PrintVectorToFile(Vector, @"C:\Users\Public\Documents\" + name);
            }

            for (int i = 0; i < allStepsSolutions.Count; i++)
            {
                allStepsFullSolutions.Add(i + 1, BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions.Single(m => m.Key == i + 1).Value, elementsAssembly.BoundedDOFsVector));
                int    j    = i + 1;
                string name = "solution" + j.ToString() + ".dat";
                VectorOperations.PrintVectorToFile(allStepsFullSolutions.Single(m => m.Key == i + 1).Value, @"C:\Users\Public\Documents\" + name);
            }
            List <double[]> structuralSolutions = new List <double[]>();

            #endregion
            return(new Results()
            {
                NonlinearSolution = structuralSolutions, SelectedDOF = 2, SolutionType = "Nonlinear"
            });
        }
예제 #7
0
        public static Results RunStaticExample()
        {
            #region Structural
            IAssembly elementsAssembly = CreateAssembly();
            elementsAssembly.CreateElementsAssembly();
            elementsAssembly.ActivateBoundaryConditions = true;
            double[,] globalStiffnessMatrix             = elementsAssembly.CreateTotalStiffnessMatrix();

            //Gnuplot graphs
            ShowToGUI.PlotInitialGeometry(elementsAssembly);

            Dictionary <int, INode> initialNodes = elementsAssembly.Nodes;
            double[] initialXCoord = Assembly.NodalCoordinatesToVectors(initialNodes).Item1;
            double[] initialYCoord = Assembly.NodalCoordinatesToVectors(initialNodes).Item2;

            double[] Xvec1Initial = new double[totalNodes / 2];
            double[] Yvec1Initial = new double[totalNodes / 2];
            double[] Xvec2Initial = new double[totalNodes / 2];
            double[] Yvec2Initial = new double[totalNodes / 2];
            double[] Ζvec1Initial = Enumerable.Repeat(1.0, totalNodes / 2).ToArray();
            double[] Ζvec2Initial = Enumerable.Repeat(1.0, totalNodes / 2).ToArray();

            Array.Copy(initialXCoord, 0, Xvec1Initial, 0, totalNodes / 2);
            Array.Copy(initialYCoord, 0, Yvec1Initial, 0, totalNodes / 2);

            Array.Copy(initialXCoord, totalNodes / 2, Xvec2Initial, 0, totalNodes / 2);
            Array.Copy(initialYCoord, totalNodes / 2, Yvec2Initial, 0, totalNodes / 2);
            //string pathForContour1 = @"C:\Users\Public\Documents\Total\1";
            //string pathForContour2 = @"C:\Users\Public\Documents\Total\2";
            //ExportToFile.CreateContourDataForMatlab(Xvec1Initial, Yvec1Initial, Ζvec1Initial, nodesInYCoor, nodesInXCoor, pathForContour1);
            //ExportToFile.CreateContourDataForMatlab(Xvec2Initial, Yvec2Initial, Ζvec2Initial, nodesInYCoor, nodesInXCoor, pathForContour2);
            //ISolver structuralSolution = new StaticSolver();
            structuralSolution.LinearScheme = new PCGSolver();
            //structuralSolution.NonLinearScheme = new LoadControlledNewtonRaphson();
            //structuralSolution.NonLinearScheme.Tolerance = 1e-5;
            structuralSolution.NonLinearScheme.Tolerance = 0.00001;
            //structuralSolution.NonLinearScheme.MaxIterations = 100;
            structuralSolution.ActivateNonLinearSolver           = true;
            structuralSolution.NonLinearScheme.numberOfLoadSteps = 20;

            double[] externalForces3 = externalForcesStructuralVector;
            foreach (var dof in loadedStructuralDOFs)
            {
                if (dof == loadDof1 | dof == LoadDof2)
                {
                    externalForces3[dof - 1] = externalStructuralLoad / 2;
                }
                else
                {
                    externalForces3[dof - 1] = externalStructuralLoad;
                }
            }
            double[] reducedExternalForces3 = BoundaryConditionsImposition.ReducedVector(externalForces3, elementsAssembly.BoundedDOFsVector);
            structuralSolution.AssemblyData = elementsAssembly;
            structuralSolution.Solve(reducedExternalForces3);
            double[] solvector3 = structuralSolution.GetSolution();
            elementsAssembly.UpdateDisplacements(solvector3);
            ShowToGUI.PlotFinalGeometry(elementsAssembly);
            double[] fullSolVector3                      = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(solvector3, elementsAssembly.BoundedDOFsVector);
            Dictionary <int, INode> finalNodes           = Assembly.CalculateFinalNodalCoordinates(elementsAssembly.Nodes, fullSolVector3);
            double[] xFinalNodalCoor                     = Assembly.NodalCoordinatesToVectors(finalNodes).Item1;
            double[] yFinalNodalCoor                     = Assembly.NodalCoordinatesToVectors(finalNodes).Item2;
            Dictionary <int, double[]> allStepsSolutions = structuralSolution.GetAllStepsSolutions();

            Dictionary <int, Dictionary <int, double[]> > allStepsContactForces = new Dictionary <int, Dictionary <int, double[]> >();
            Dictionary <int, Dictionary <int, double> >   allStepsContactDXs    = new Dictionary <int, Dictionary <int, double> >();
            Dictionary <int, Dictionary <int, double> >   allStepsContactDXs1   = new Dictionary <int, Dictionary <int, double> >();
            Dictionary <int, Dictionary <int, double> >   allStepsContactDXs2   = new Dictionary <int, Dictionary <int, double> >();
            Dictionary <int, Dictionary <int, INode> >    allstepsfinalNodes    = new Dictionary <int, Dictionary <int, INode> >();
            //Dictionary<int, Dictionary<int, INode>> PreviusStatefinalNodes = new Dictionary<int, Dictionary<int, INode>>();
            Dictionary <int, double[]> elementsInternalContactForcesVector;
            Dictionary <int, double>   Deltax;
            Dictionary <int, double>   Deltax1;
            Dictionary <int, double>   Deltax2;
            //double[] SolutionSum = new double[2 * totalNodes];
            double[] NodalX         = new double[totalNodes];
            double[] NodalY         = new double[totalNodes];
            int      upperNode      = new int();
            int      lowerLeftNode  = new int();
            int      lowerRightNode = new int();
            for (int i = 1; i <= allStepsSolutions.Count; i++)
            {
                elementsInternalContactForcesVector = new Dictionary <int, double[]>();
                Deltax  = new Dictionary <int, double>();
                Deltax1 = new Dictionary <int, double>();
                Deltax2 = new Dictionary <int, double>();
                //allstepsfinalNodes = new Dictionary<int, Dictionary<int, INode>>();
                double[] fullSolVectorSteps = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[i], elementsAssembly.BoundedDOFsVector);
                //SolutionSum = VectorOperations.VectorVectorAddition(SolutionSum, fullSolVectorSteps);
                allstepsfinalNodes[i] = Assembly.CalculateFinalNodalCoordinates(elementsAssembly.Nodes, fullSolVectorSteps);
                elementsAssembly.UpdateDisplacements(allStepsSolutions[i]);
                NodalX = Assembly.NodalCoordinatesToVectors(allstepsfinalNodes[i]).Item1;
                NodalY = Assembly.NodalCoordinatesToVectors(allstepsfinalNodes[i]).Item2;
                for (int j = totalElements + 1; j <= totalElements + totalContactElements; j++)
                {
                    elementsInternalContactForcesVector[j] = elementsAssembly.ElementsAssembly[j].CreateInternalGlobalForcesVector();
                }
                upperNode      = nodesInXCoor - totalContactElements + 1;
                lowerLeftNode  = (nodesInXCoor + nodesInXCoor2) * nodesInYCoor - nodesInXCoor2 + 1;
                lowerRightNode = lowerLeftNode + 1;
                for (int j = totalElements + 1; j <= totalElements + totalContactElements; j += 2)
                {
                    Deltax[j]      = Math.Pow(Math.Pow(NodalX[lowerRightNode - 1] - NodalX[lowerLeftNode - 1], 2) + Math.Pow(NodalY[lowerRightNode - 1] - NodalY[lowerLeftNode - 1], 2), 0.5);
                    Deltax2[j]     = Math.Pow(Math.Pow(NodalX[lowerRightNode - 1] - NodalX[upperNode - 1], 2) + Math.Pow(NodalY[lowerRightNode - 1] - NodalY[upperNode - 1], 2), 0.5);
                    Deltax1[j]     = Math.Pow(Math.Pow(NodalX[upperNode - 1] - NodalX[lowerLeftNode - 1], 2) + Math.Pow(NodalY[upperNode - 1] - NodalY[lowerLeftNode - 1], 2), 0.5);
                    upperNode      = upperNode + 1;
                    Deltax[j + 1]  = Math.Pow(Math.Pow(NodalX[lowerRightNode - 1] - NodalX[lowerLeftNode - 1], 2) + Math.Pow(NodalY[lowerRightNode - 1] - NodalY[lowerLeftNode - 1], 2), 0.5);
                    Deltax2[j + 1] = Math.Pow(Math.Pow(NodalX[lowerRightNode - 1] - NodalX[upperNode - 1], 2) + Math.Pow(NodalY[lowerRightNode - 1] - NodalY[upperNode - 1], 2), 0.5);
                    Deltax1[j + 1] = Math.Pow(Math.Pow(NodalX[upperNode - 1] - NodalX[lowerLeftNode - 1], 2) + Math.Pow(NodalY[upperNode - 1] - NodalY[lowerLeftNode - 1], 2), 0.5);
                    lowerLeftNode  = lowerRightNode;
                    lowerRightNode = lowerRightNode + 1;
                    upperNode      = upperNode + 1;
                }
                allStepsContactForces[i] = elementsInternalContactForcesVector;
                allStepsContactDXs[i]    = Deltax;
                allStepsContactDXs1[i]   = Deltax1;
                allStepsContactDXs2[i]   = Deltax2;
            }
            List <double[]> structuralSolutions = new List <double[]>();

            #endregion
            #region Thermal
            List <double[]> thermalSolutions = new List <double[]>();
            //List<double[]> thermalSolutions2 = new List<double[]>();
            List <Dictionary <int, double> > contactContactivityForEachStep = new List <Dictionary <int, double> >();
            List <double[]> contactContactivityForEachStep2 = new List <double[]>();
            for (int k = 1; k <= allStepsSolutions.Count; k++)
            {
                IAssembly elementsAssembly2 = CreateThermalAssembly();

                for (int j = totalElements + 1; j <= totalElements + totalContactElements; j++)
                {
                    double[] contactForce = allStepsContactForces[k][j];
                    double   DX           = allStepsContactDXs[k][j];
                    double   DX1          = allStepsContactDXs1[k][j];
                    double   DX2          = allStepsContactDXs2[k][j];
                    //double ContactForceVar = Math.Pow(Math.Pow(VectorOperations.VectorNorm2(new double[] { contactForce[4], contactForce[5] }),2),0.5);
                    elementsAssembly2.ElementsProperties[j].ContactForceValue = VectorOperations.VectorNorm2(new double[] { contactForce[4], contactForce[5] });
                    elementsAssembly2.ElementsProperties[j].Dx  = DX;
                    elementsAssembly2.ElementsProperties[j].Dx1 = DX1;
                    elementsAssembly2.ElementsProperties[j].Dx2 = DX2;
                }

                elementsAssembly2.CreateElementsAssembly();
                elementsAssembly2.ActivateBoundaryConditions = true;
                double[,] globalStiffnessMatrix2             = elementsAssembly2.CreateTotalStiffnessMatrix();

                ISolver thermalSolution = new StaticSolver();
                thermalSolution.LinearScheme                      = new LUFactorization();
                thermalSolution.NonLinearScheme                   = new LoadControlledNewtonRaphson();
                thermalSolution.NonLinearScheme.Tolerance         = 1e-7;
                thermalSolution.NonLinearScheme.MaxIterations     = 100;
                thermalSolution.ActivateNonLinearSolver           = true;
                thermalSolution.NonLinearScheme.numberOfLoadSteps = 10;

                thermalSolution.AssemblyData = elementsAssembly2;
                double[] externalHeatFlux = externalHeatLoafVector;
                //externalHeatFlux[0] =  externalHeatLoad;
                //externalHeatFlux[15] = externalHeatLoad;
                //externalHeatFlux[30] = externalHeatLoad;
                //externalHeatFlux[45] = externalHeatLoad;
                //externalHeatFlux[60] = externalHeatLoad;

                foreach (var dof in loadedThermalDOFs)
                {
                    if ((dof == ThermalDof1 | dof == ThermalDof2))
                    {
                        externalHeatFlux[dof - 1] = -T0 * (cond / (6 * xIntervals * yIntervals)) * ((Math.Pow(xIntervals, 2) - 2 * Math.Pow(yIntervals, 2)) - (Math.Pow(xIntervals, 2) + Math.Pow(yIntervals, 2)));
                    }
                    else
                    {
                        externalHeatFlux[dof - 1] = -2 * T0 * (cond / (6 * xIntervals * yIntervals)) * ((Math.Pow(xIntervals, 2) - 2 * Math.Pow(yIntervals, 2)) - (Math.Pow(xIntervals, 2) + Math.Pow(yIntervals, 2)));
                    }
                }
                //for (int i = 61; i <= 75; i++)
                //{
                //    externalHeatFlux[61] = externalHeatLoad;
                //}
                double[] reducedExternalHeatFlux = BoundaryConditionsImposition.ReducedVector(externalHeatFlux, thermalSolution.AssemblyData.BoundedDOFsVector);
                thermalSolution.Solve(reducedExternalHeatFlux);
                Dictionary <int, double[]> IntHeatFlux = thermalSolution.GetInternalForces();
                //double [] HeatSolve= new double[totalNodes];
                //double[] value;
                ////double[] Values = new double[totalNodes];
                //for (int i = 1; i <= 10; i++)
                //{
                //    value = IntHeatFlux[i];
                //    thermalSolutions2.Add(value);
                //    //Values[i - 1] = Convert.ToDouble(value);
                //}
                //HeatSolve = VectorOperations.VectorVectorAddition(Values , externalHeatFlux);
                double[] tempSol = thermalSolution.GetSolution();
                elementsAssembly2.UpdateDisplacements(tempSol);
                //double[] contactContactivityVector = new double[totalContactElements];
                //Dictionary<int, double[]> allStepsSolutions2 = thermalSolution.GetAllStepsSolutions();
                thermalSolutions.Add(tempSol);
                //thermalSolutions2.Add(HeatSolve);
                Dictionary <int, double> contactContactivity = AssemblyHelpMethods.RetrieveContactContactivity(thermalSolution.AssemblyData);
                //    contactContactivityForEachStep.Add(contactContactivity);
                //    for (int i = 0; i <= totalContactElements - 1; i++)
                //    {
                //        contactContactivityVector[i] = contactContactivity[i + totalElements + 1];
                //    }
                //    contactContactivityForEachStep2.Add(contactContactivityVector);
            }
            int[] thermalBoundCond = thermalBoundaryConditions;
            //int[] thermalBoundCond2 = thermalBoundaryConditions2;
            double[] fullStructuralSol1 = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[4], elementsAssembly.BoundedDOFsVector);
            double[] fullStructuralSol2 = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[8], elementsAssembly.BoundedDOFsVector);
            double[] fullStructuralSol3 = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[12], elementsAssembly.BoundedDOFsVector);
            double[] fullStructuralSol4 = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[16], elementsAssembly.BoundedDOFsVector);
            double[] fullStructuralSol5 = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[20], elementsAssembly.BoundedDOFsVector);
            double[] fullThermalSol1    = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(thermalSolutions[3], thermalBoundCond);
            double[] fullThermalSol2    = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(thermalSolutions[7], thermalBoundCond);
            double[] fullThermalSol3    = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(thermalSolutions[11], thermalBoundCond);
            double[] fullThermalSol4    = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(thermalSolutions[15], thermalBoundCond);
            double[] fullThermalSol5    = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(thermalSolutions[19], thermalBoundCond);
            //double[] fullThermalSol6 = thermalSolutions2[19];
            //double[] fullThermalSol7 = thermalSolutions2[39];
            //double[] fullThermalSol8 = thermalSolutions2[59];
            //double[] fullThermalSol9 = thermalSolutions2[79];
            //double[] fullThermalSol10 = thermalSolutions2[99];
            //double[] FullcontactContactivity1 = contactContactivityForEachStep2[1];
            //double[] FullcontactContactivity2 = contactContactivityForEachStep2[3];
            //double[] FullcontactContactivity3 = contactContactivityForEachStep2[5];
            //double[] FullcontactContactivity4 = contactContactivityForEachStep2[7];
            //double[] FullcontactContactivity5 = contactContactivityForEachStep2[9];
            double[] FullStructuralSolution_1_Χ = new double[totalNodes];
            double[] FullStructuralSolution_1_Υ = new double[totalNodes];
            double[] FullStructuralSolution_2_Χ = new double[totalNodes];
            double[] FullStructuralSolution_2_Υ = new double[totalNodes];
            double[] FullStructuralSolution_3_Χ = new double[totalNodes];
            double[] FullStructuralSolution_3_Υ = new double[totalNodes];
            double[] FullStructuralSolution_4_Χ = new double[totalNodes];
            double[] FullStructuralSolution_4_Υ = new double[totalNodes];
            double[] FullStructuralSolution_5_Χ = new double[totalNodes];
            double[] FullStructuralSolution_5_Υ = new double[totalNodes];
            int      count = 1;
            for (int i = 1; i <= 2 * totalNodes - 1; i += 2)
            {
                FullStructuralSolution_1_Χ[count - 1] = fullStructuralSol1[i - 1];
                FullStructuralSolution_1_Υ[count - 1] = fullStructuralSol1[i];
                count += 1;
            }
            count = 1;
            for (int i = 1; i <= 2 * totalNodes - 1; i += 2)
            {
                FullStructuralSolution_2_Χ[count - 1] = fullStructuralSol2[i - 1];
                FullStructuralSolution_2_Υ[count - 1] = fullStructuralSol2[i];
                count += 1;
            }
            count = 1;
            for (int i = 1; i <= 2 * totalNodes - 1; i += 2)
            {
                FullStructuralSolution_3_Χ[count - 1] = fullStructuralSol3[i - 1];
                FullStructuralSolution_3_Υ[count - 1] = fullStructuralSol3[i];
                count += 1;
            }
            count = 1;
            for (int i = 1; i <= 2 * totalNodes - 1; i += 2)
            {
                FullStructuralSolution_4_Χ[count - 1] = fullStructuralSol4[i - 1];
                FullStructuralSolution_4_Υ[count - 1] = fullStructuralSol4[i];
                count += 1;
            }
            count = 1;
            for (int i = 1; i <= 2 * totalNodes - 1; i += 2)
            {
                FullStructuralSolution_5_Χ[count - 1] = fullStructuralSol5[i - 1];
                FullStructuralSolution_5_Υ[count - 1] = fullStructuralSol5[i];
                count += 1;
            }
            ExportToFile.ExportGeometryDataWithTemperatures(Assembly.CalculateFinalNodalCoordinates(elementsAssembly.Nodes, fullStructuralSol1), FullStructuralSolution_1_Χ, @"C:\Users\Public\Documents\ThermalStructuralCNTsInAngle3_0.12L_20.00Mpa_Res1_ux.dat");
            ExportToFile.ExportGeometryDataWithTemperatures(Assembly.CalculateFinalNodalCoordinates(elementsAssembly.Nodes, fullStructuralSol2), FullStructuralSolution_2_Χ, @"C:\Users\Public\Documents\ThermalStructuralCNTsInAngle3_0.12L_20.00Mpa_Res2_ux.dat");
            ExportToFile.ExportGeometryDataWithTemperatures(Assembly.CalculateFinalNodalCoordinates(elementsAssembly.Nodes, fullStructuralSol3), FullStructuralSolution_3_Χ, @"C:\Users\Public\Documents\ThermalStructuralCNTsInAngle3_0.12L_20.00Mpa_Res3_ux.dat");
            ExportToFile.ExportGeometryDataWithTemperatures(Assembly.CalculateFinalNodalCoordinates(elementsAssembly.Nodes, fullStructuralSol4), FullStructuralSolution_4_Χ, @"C:\Users\Public\Documents\ThermalStructuralCNTsInAngle3_0.12L_20.00Mpa_Res4_ux.dat");
            ExportToFile.ExportGeometryDataWithTemperatures(Assembly.CalculateFinalNodalCoordinates(elementsAssembly.Nodes, fullStructuralSol5), FullStructuralSolution_5_Χ, @"C:\Users\Public\Documents\ThermalStructuralCNTsInAngle3_0.12L_20.00Mpa_Res5_ux.dat");
            ExportToFile.ExportGeometryDataWithTemperatures(Assembly.CalculateFinalNodalCoordinates(elementsAssembly.Nodes, fullStructuralSol1), FullStructuralSolution_1_Υ, @"C:\Users\Public\Documents\ThermalStructuralCNTsInAngle3_0.12L_20.00Mpa_Res1_uy.dat");
            ExportToFile.ExportGeometryDataWithTemperatures(Assembly.CalculateFinalNodalCoordinates(elementsAssembly.Nodes, fullStructuralSol2), FullStructuralSolution_2_Υ, @"C:\Users\Public\Documents\ThermalStructuralCNTsInAngle3_0.12L_20.00Mpa_Res2_uy.dat");
            ExportToFile.ExportGeometryDataWithTemperatures(Assembly.CalculateFinalNodalCoordinates(elementsAssembly.Nodes, fullStructuralSol3), FullStructuralSolution_3_Υ, @"C:\Users\Public\Documents\ThermalStructuralCNTsInAngle3_0.12L_20.00Mpa_Res3_uy.dat");
            ExportToFile.ExportGeometryDataWithTemperatures(Assembly.CalculateFinalNodalCoordinates(elementsAssembly.Nodes, fullStructuralSol4), FullStructuralSolution_4_Υ, @"C:\Users\Public\Documents\ThermalStructuralCNTsInAngle3_0.12L_20.00Mpa_Res4_uy.dat");
            ExportToFile.ExportGeometryDataWithTemperatures(Assembly.CalculateFinalNodalCoordinates(elementsAssembly.Nodes, fullStructuralSol5), FullStructuralSolution_5_Υ, @"C:\Users\Public\Documents\ThermalStructuralCNTsInAngle3_0.12L_20.00Mpa_Res5_uy.dat");
            ExportToFile.ExportGeometryDataWithTemperatures(Assembly.CalculateFinalNodalCoordinates(elementsAssembly.Nodes, fullStructuralSol1), fullThermalSol1, @"C:\Users\Public\Documents\ThermalStructuralCNTsInAngle3_0.12L_20.000Mpa_Res1_temp.dat");
            ExportToFile.ExportGeometryDataWithTemperatures(Assembly.CalculateFinalNodalCoordinates(elementsAssembly.Nodes, fullStructuralSol2), fullThermalSol2, @"C:\Users\Public\Documents\ThermalStructuralCNTsInAngle3_0.12L_20.000Mpa_Res2_temp.dat");
            ExportToFile.ExportGeometryDataWithTemperatures(Assembly.CalculateFinalNodalCoordinates(elementsAssembly.Nodes, fullStructuralSol3), fullThermalSol3, @"C:\Users\Public\Documents\ThermalStructuralCNTsInAngle3_0.12L_20.000Mpa_Res3_temp.dat");
            ExportToFile.ExportGeometryDataWithTemperatures(Assembly.CalculateFinalNodalCoordinates(elementsAssembly.Nodes, fullStructuralSol4), fullThermalSol4, @"C:\Users\Public\Documents\ThermalStructuralCNTsInAngle3_0.12L_20.000Mpa_Res4_temp.dat");
            ExportToFile.ExportGeometryDataWithTemperatures(Assembly.CalculateFinalNodalCoordinates(elementsAssembly.Nodes, fullStructuralSol5), fullThermalSol5, @"C:\Users\Public\Documents\ThermalStructuralCNTsInAngle3_0.12L_20.000Mpa_Res5_temp.dat");
            //ExportToFile.ExportGeometryDataWithTemperatures(Assembly.CalculateFinalNodalCoordinates(elementsAssembly.Nodes, fullStructuralSol1), fullThermalSol6, @"C:\Users\Public\Documents\CouplThermStructCNTs_0.90L_0.100Mpa_Res6.dat");
            //ExportToFile.ExportGeometryDataWithTemperatures(Assembly.CalculateFinalNodalCoordinates(elementsAssembly.Nodes, fullStructuralSol2), fullThermalSol7, @"C:\Users\Public\Documents\CouplThermStructCNTs_0.90L_0.100Mpa_Res7.dat");
            //ExportToFile.ExportGeometryDataWithTemperatures(Assembly.CalculateFinalNodalCoordinates(elementsAssembly.Nodes, fullStructuralSol3), fullThermalSol8, @"C:\Users\Public\Documents\CouplThermStructCNTs_0.90L_0.100Mpa_Res8.dat");
            //ExportToFile.ExportGeometryDataWithTemperatures(Assembly.CalculateFinalNodalCoordinates(elementsAssembly.Nodes, fullStructuralSol4), fullThermalSol9, @"C:\Users\Public\Documents\CouplThermStructCNTs_0.90L_0.100Mpa_Res9.dat");
            //ExportToFile.ExportGeometryDataWithTemperatures(Assembly.CalculateFinalNodalCoordinates(elementsAssembly.Nodes, fullStructuralSol5), fullThermalSol10, @"C:\Users\Public\Documents\CouplThermStructCNTs_0.90L_0.100Mpa_Res10.dat");
            //VectorOperations.PrintVectorToFile(fullThermalSol6, @"C:\Users\Public\Documents\CouplThermStructCNTs_0.30L_0.100Mpa_Res6.dat");
            //VectorOperations.PrintVectorToFile(fullThermalSol7, @"C:\Users\Public\Documents\CouplThermStructCNTs_0.30L_0.100Mpa_Res7.dat");
            //VectorOperations.PrintVectorToFile(fullThermalSol8, @"C:\Users\Public\Documents\CouplThermStructCNTs_0.30L_0.100Mpa_Res8.dat");
            //VectorOperations.PrintVectorToFile(fullThermalSol9, @"C:\Users\Public\Documents\CouplThermStructCNTs_0.30L_0.100Mpa_Res9.dat");
            //VectorOperations.PrintVectorToFile(fullThermalSol10, @"C:\Users\Public\Documents\CouplThermStructCNTs_0.30L_0.100Mpa_Res10.dat");

            //VectorOperations.PrintVectorToFile(FullcontactContactivity1, @"C:\Users\Public\Documents\CouplThermStructCNTs_0.30L_0.100Mpa_CC1.dat");
            //VectorOperations.PrintVectorToFile(FullcontactContactivity2, @"C:\Users\Public\Documents\CouplThermStructCNTs_0.30L_0.100Mpa_CC2.dat");
            //VectorOperations.PrintVectorToFile(FullcontactContactivity3, @"C:\Users\Public\Documents\CouplThermStructCNTs_0.30L_0.100Mpa_CC3.dat");
            //VectorOperations.PrintVectorToFile(FullcontactContactivity4, @"C:\Users\Public\Documents\CouplThermStructCNTs_0.30L_0.100Mpa_CC4.dat");
            //VectorOperations.PrintVectorToFile(FullcontactContactivity5, @"C:\Users\Public\Documents\CouplThermStructCNTs_0.30L_0.100Mpa_CC5.dat");
            double[] Xvec1Final = new double[totalNodes / 2];
            double[] Yvec1Final = new double[totalNodes / 2];
            double[] Xvec2Final = new double[totalNodes / 2];
            double[] Yvec2Final = new double[totalNodes / 2];
            double[] Ζvec1Final = new double[totalNodes / 2];
            double[] Ζvec2Final = new double[totalNodes / 2];

            Array.Copy(xFinalNodalCoor, 0, Xvec1Final, 0, totalNodes / 2);
            Array.Copy(yFinalNodalCoor, 0, Yvec1Final, 0, totalNodes / 2);
            Array.Copy(fullThermalSol4, 0, Ζvec1Final, 0, totalNodes / 2);
            Array.Copy(xFinalNodalCoor, totalNodes / 2, Xvec2Final, 0, totalNodes / 2);
            Array.Copy(yFinalNodalCoor, totalNodes / 2, Yvec2Final, 0, totalNodes / 2);
            Array.Copy(fullThermalSol4, totalNodes / 2, Ζvec2Final, 0, totalNodes / 2);

            List <HeatMapData> plots2 = new List <HeatMapData>();
            plots2.Add(new HeatMapData()
            {
                Xcoordinates = Xvec1Final, Ycoordinates = Yvec1Final, Temperatures = Ζvec1Final
            });
            plots2.Add(new HeatMapData()
            {
                Xcoordinates = Xvec2Final, Ycoordinates = Yvec2Final, Temperatures = Ζvec2Final
            });

            ShowToGUI.PlotHeatMap(plots2);

            //string path = @"C:\Users\Public\Documents\Total\1final";
            //string path2 = @"C:\Users\Public\Documents\Total\2final";
            //ExportToFile.CreateContourDataForMatlab(Xvec1Final, Yvec1Final, Ζvec1Final, nodesInYCoor, nodesInXCoor, path);
            //ExportToFile.CreateContourDataForMatlab(Xvec2Final, Yvec2Final, Ζvec2Final, nodesInYCoor, nodesInXCoor, path2);

            //ExportToFile.ExportGeometryDataWithTemperatures(finalNodes, fullTempSol);

            GnuPlot.Close();

            while (true)
            {
                if (File.Exists(AppContext.BaseDirectory + "gnuplot.png") && new FileInfo(AppContext.BaseDirectory + "gnuplot.png").Length > 0)
                {
                    break;
                }
                Thread.Sleep(100);
            }
            GnuPlot.KillProcess();
            #endregion

            return(new Results()
            {
                NonlinearSolution = structuralSolutions, SelectedDOF = 2, SolutionType = "Nonlinear"
            });
        }
예제 #8
0
        public static Results RunExample()
        {
            IAssembly elementsAssembly = CreateAssembly();

            elementsAssembly.CreateElementsAssembly();
            elementsAssembly.ActivateBoundaryConditions = true;
            ShowToGUI.PlotInitialGeometry(elementsAssembly);
            var AccelerationVector = new double[nodesNumber * 2];
            var DisplacementVector = new double[nodesNumber * 2];
            var VelocityVector     = new double[nodesNumber * 2];

            for (int i = 1; i <= 2 * (3 * circles - 1) * steps - 1; i += 2)
            {
                VelocityVector[i] = -50.0;
            }
            InitialConditions initialValues = new InitialConditions();

            initialValues.InitialAccelerationVector = BoundaryConditionsImposition.ReducedVector(AccelerationVector, elementsAssembly.BoundedDOFsVector);
            initialValues.InitialDisplacementVector = BoundaryConditionsImposition.ReducedVector(DisplacementVector, elementsAssembly.BoundedDOFsVector);
            initialValues.InitialVelocityVector     = BoundaryConditionsImposition.ReducedVector(VelocityVector, elementsAssembly.BoundedDOFsVector);
            initialValues.InitialTime = 0.0;
            //ExplicitSolver newSolver = new ExplicitSolver(0.0035, 3500);
            ExplicitSolver newSolver = new ExplicitSolver(0.003, 300);

            newSolver.Assembler = elementsAssembly;
            double[] externalForces = externalForcesStructuralVector;
            foreach (var dof in loadedStructuralDOFs)
            {
                externalForces[dof - 1] = externalForce;
            }
            newSolver.InitialValues             = initialValues;
            newSolver.ExternalForcesVector      = BoundaryConditionsImposition.ReducedVector(externalForces, elementsAssembly.BoundedDOFsVector);
            newSolver.LinearSolver              = new LUFactorization();
            newSolver.ActivateNonLinearSolution = true;
            newSolver.SolveNewmark();
            Tuple <Dictionary <int, double[]>, Dictionary <int, double> > solvectors = newSolver.GetResults();
            //int max = solvectors.Item1.OrderByDescending(m => m.Key).FirstOrDefault().Key;
            //elementsAssembly.UpdateDisplacements(solvectors.Item1.Single(m => m.Key == max).Value);
            Dictionary <int, double[]>         allStepsSolutions = solvectors.Item1;
            Dictionary <int, List <double[]> > stress            = new Dictionary <int, List <double[]> >();
            Dictionary <int, List <double[]> > strain            = new Dictionary <int, List <double[]> >();
            Dictionary <int, List <double[]> > gPoints           = new Dictionary <int, List <double[]> >();
            Dictionary <int, List <double[]> > nodesStress       = new Dictionary <int, List <double[]> >();
            Dictionary <int, List <double[]> > nodesStrain       = new Dictionary <int, List <double[]> >();

            //for (int i = 1; i < allStepsSolutions.Count; i++)
            for (int i = 0; i <= allStepsSolutions.Count - 1; i++)
            {
                elementsAssembly.UpdateDisplacements(allStepsSolutions[i]);
                if (i == allStepsSolutions.Count - 1)
                {
                    stress      = elementsAssembly.GetElementsStresses(allStepsSolutions[i]);
                    strain      = elementsAssembly.GetElementsStains(allStepsSolutions[i]);
                    gPoints     = elementsAssembly.GetElementsGaussPoints(allStepsSolutions[i]);
                    nodesStress = elementsAssembly.GetElementsNodesStresses(allStepsSolutions[i]);
                    nodesStrain = elementsAssembly.GetElementsNodesStains(allStepsSolutions[i]);
                    ExportToFile.ExportMatlabFinalGeometry(elementsAssembly, BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[i], elementsAssembly.BoundedDOFsVector));
                }
            }
            ShowToGUI.PlotFinalGeometry(elementsAssembly);
            double[] fullDynamicSol1  = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[200], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol2  = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[210], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol3  = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[220], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol4  = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[230], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol5  = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[240], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol6  = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[250], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol7  = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[260], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol8  = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[270], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol9  = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[280], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol10 = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[285], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol11 = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[290], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol12 = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[291], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol13 = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[292], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol14 = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[293], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol15 = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[294], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol16 = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[295], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol17 = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[296], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol18 = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[297], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol19 = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[298], elementsAssembly.BoundedDOFsVector);
            double[] fullDynamicSol20 = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(allStepsSolutions[299], elementsAssembly.BoundedDOFsVector);
            VectorOperations.PrintVectorToFile(fullDynamicSol1, @"C:\Users\Public\Documents\Results1.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol2, @"C:\Users\Public\Documents\Results2.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol3, @"C:\Users\Public\Documents\Results3.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol4, @"C:\Users\Public\Documents\Results4.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol5, @"C:\Users\Public\Documents\Results5.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol6, @"C:\Users\Public\Documents\Results6.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol7, @"C:\Users\Public\Documents\Results7.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol8, @"C:\Users\Public\Documents\Results8.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol9, @"C:\Users\Public\Documents\Results9.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol10, @"C:\Users\Public\Documents\Results10.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol11, @"C:\Users\Public\Documents\Results11.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol12, @"C:\Users\Public\Documents\Results12.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol13, @"C:\Users\Public\Documents\Results13.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol14, @"C:\Users\Public\Documents\Results14.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol15, @"C:\Users\Public\Documents\Results15.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol16, @"C:\Users\Public\Documents\Results16.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol17, @"C:\Users\Public\Documents\Results17.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol18, @"C:\Users\Public\Documents\Results18.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol19, @"C:\Users\Public\Documents\Results19.dat");
            VectorOperations.PrintVectorToFile(fullDynamicSol20, @"C:\Users\Public\Documents\Results20.dat");
            VectorOperations.PrintDictionaryofListsofVectorsToFile(stress, @"C:\Users\Public\Documents\Stress.dat");
            VectorOperations.PrintDictionaryofListsofVectorsToFile(strain, @"C:\Users\Public\Documents\Strain.dat");
            VectorOperations.PrintDictionaryofListsofVectorsToFile(gPoints, @"C:\Users\Public\Documents\GaussPoints.dat");
            VectorOperations.PrintDictionaryofListsofVectorsToFile(nodesStress, @"C:\Users\Public\Documents\StressNodes.dat");
            VectorOperations.PrintDictionaryofListsofVectorsToFile(nodesStrain, @"C:\Users\Public\Documents\StrainNodes.dat");
            //newSolver.PrintExplicitSolution();
            Results finalResults = new Results()
            {
                DynamicSolution = newSolver.explicitSolution, TimeSteps = newSolver.TimeAtEachStep, SelectedDOF = 1, SelectedInterval = 1, SolutionType = "Dynamic"
            };

            return(finalResults);
        }