Esempio n. 1
0
        public static Results RunStaticExample()
        {
            ///Structural settings
            IAssembly elementsAssembly = CreateAssembly();

            elementsAssembly.CreateElementsAssembly();
            elementsAssembly.ActivateBoundaryConditions = true;
            double[,] globalStiffnessMatrix             = elementsAssembly.CreateTotalStiffnessMatrix();

            ISolver newSolu = new StaticSolver();

            newSolu.LinearScheme                      = new PCGSolver();
            newSolu.NonLinearScheme                   = new LoadControlledNewtonRaphson();
            newSolu.ActivateNonLinearSolver           = true;
            newSolu.NonLinearScheme.numberOfLoadSteps = 1;


            //Thermal Settings
            IAssembly elementsAssembly2 = CreateThermalAssembly();

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

            ISolver thermalSolution = new StaticSolver();

            thermalSolution.LinearScheme                      = new CholeskyFactorization();
            thermalSolution.NonLinearScheme                   = new LoadControlledNewtonRaphson();
            thermalSolution.ActivateNonLinearSolver           = true;
            thermalSolution.NonLinearScheme.numberOfLoadSteps = 10;

            //double[] externalFlux = new double[] { 0, 0, 0, 0, 250.0, 250.0 };
            //newSolu2.AssemblyData = elementsAssembly;
            //newSolu2.Solve(externalForces);
            //newSolu2.PrintSolution();
            //double[] tempSolution = newSolu.GetSolution();

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

            for (int i = 1; i <= 5; i++)
            {
                newSolu.NonLinearScheme = new LoadControlledNewtonRaphson(solVector2);
                double[] externalForces2 = new double[] { 0, 0, 0, 0, -10000.0 * i, -10000.0 * i };
                newSolu.AssemblyData = elementsAssembly;
                newSolu.Solve(externalForces2);
                solVector2 = newSolu.GetSolution();
                structuralSolutions.Add(solVector2);
            }
            Dictionary <int, double[]> intForces             = newSolu.GetInternalForces();
            Dictionary <int, double[]> elementInternalForces = elementsAssembly.GetElementsInternalForces(structuralSolutions[0]);
            List <string> elementTypes = elementsAssembly.GetElementsType();

            double[]        temperatures     = new double[6];
            List <double[]> thermalSolutions = new List <double[]>();

            for (int i = 1; i <= 5; i++)
            {
                thermalSolution.NonLinearScheme = new LoadControlledNewtonRaphson(temperatures);
                double[] externalHeatFlux = new double[] { 0, 0, 0, 0, 250.0, 250.0 };
                thermalSolution.AssemblyData = elementsAssembly2;
                thermalSolution.Solve(externalHeatFlux);
                temperatures = thermalSolution.GetSolution();
                thermalSolutions.Add(temperatures);
            }


            //double[] completeFinalSolutionVector = BoundaryConditionsImposition.CreateFullVectorFromReducedVector(solVector2, new int[] { 1, 2, 3, 4, 5, 7, 9, 11, 13, 15 });            Dictionary<int, INode> finalNodesList = new Dictionary<int, INode>();
            //finalNodesList = Assembly.CalculateFinalNodalCoordinates(elementsAssembly.Nodes, completeFinalSolutionVector);

            return(new Results()
            {
                NonlinearSolution = structuralSolutions, SelectedDOF = 2, SolutionType = "Nonlinear"
            });
        }