Example #1
0
        public void BuildMatrices()
        {
            if (childAnalyzer == null)
            {
                throw new InvalidOperationException("Monte Carlo analyzer must contain an embedded analyzer.");
            }
            if (currentSimulation < 0)
            {
                InitializeCoefficientsProvider();
            }

            provider.Reset();
            coefficientsProvider.CurrentOrder = -1;
            childAnalyzer.BuildMatrices();

            matrices[0] = new Dictionary <int, IMatrix2D <double> >(subdomains.Count);
            foreach (var subdomain in subdomains.Values)
            {
                SkylineMatrix2D <double> k = (SkylineMatrix2D <double>)subdomain.Matrix;
                matrices[0].Add(subdomain.ID, (SkylineMatrix2D <double>)k.Clone());
            }
            for (int i = 0; i < expansionOrder; i++)
            {
                provider.Reset();
                coefficientsProvider.CurrentOrder = i;
                childAnalyzer.BuildMatrices();

                matrices[i + 1] = new Dictionary <int, IMatrix2D <double> >(subdomains.Count);
                foreach (var subdomain in subdomains.Values)
                {
                    SkylineMatrix2D <double> k = (SkylineMatrix2D <double>)subdomain.Matrix;
                    matrices[i + 1].Add(subdomain.ID, (SkylineMatrix2D <double>)k.Clone());
                }
            }

            //matrices.Clear();
            //provider.Reset();
            //coefficientsProvider.CurrentOrder = -1;
            //childAnalyzer.BuildMatrices();

            //foreach (var subdomain in subdomains.Values)
            //{
            //    SkylineMatrix2D<double> k = (SkylineMatrix2D<double>)subdomain.Matrix;
            //    matrices.Add(subdomain.ID, (SkylineMatrix2D<double>)k.Clone());
            //}
            //for (int i = 0; i < expansionOrder; i++)
            //{
            //    provider.Reset();
            //    coefficientsProvider.CurrentOrder = i;
            //    childAnalyzer.BuildMatrices();

            //    foreach (var subdomain in subdomains.Values)
            //    {
            //        SkylineMatrix2D<double> k = (SkylineMatrix2D<double>)subdomain.Matrix;
            //        matrices[subdomain.ID].LinearCombination(new double[] { randomNumbers[currentSimulation][i] }, new IMatrix2D<double>[] { k });
            //    }
            //}
            //foreach (var subdomain in subdomains.Values)
            //    subdomain.Matrix = matrices[subdomain.ID];
        }
        public void BuildMatrices()
        {
            if (childAnalyzer == null)
            {
                throw new InvalidOperationException("Monte Carlo analyzer must contain an embedded analyzer.");
            }
            if (currentSimulation < 0)
            {
                if (stiffnessMatrixProductionMode == StiffnessMatrixProductionMode.LoadFromDiskAndCalculate)
                {
                    var fileName = String.Format(@"{0}-Order.txt", fileNameForLogging);
                    using (var sw = File.OpenText(fileName))
                    {
                        while (!sw.EndOfStream)
                        {
                            matrixOrder.Add(Int32.Parse(sw.ReadLine()));
                        }
                    }
                }
                return;
            }

            if (stiffnessMatrixProductionMode == StiffnessMatrixProductionMode.LoadFromDiskAndCalculate)
            {
                ReadMatricesFromFile(currentSimulation);
            }
            else
            {
                provider.Reset();
                childAnalyzer.BuildMatrices();
            }
            WriteMatricesToFile(currentSimulation);
        }
 public void BuildMatrices()
 {
     if (childAnalyzer == null)
     {
         throw new InvalidOperationException("Monte Carlo analyzer must contain an embedded analyzer.");
     }
     provider.Reset();
     childAnalyzer.BuildMatrices();
 }
        public void BuildMatrices()
        {
            if (childAnalyzer == null)
            {
                throw new InvalidOperationException("Polynomial chaos analyzer must contain an embedded analyzer.");
            }
            if (currentSimulation < 0)
            {
                InitializeCoefficientsProvider();
            }

            for (int i = 0; i < coefficientsProvider.NoOfMatrices; i++)
            {
                provider.Reset();
                coefficientsProvider.CurrentOrder = i;
                childAnalyzer.BuildMatrices();

                matrices[i + 1] = new Dictionary <int, IMatrix2D <double> >(subdomains.Count);
                foreach (var subdomain in subdomains.Values)
                {
                    SkylineMatrix2D <double> k = (SkylineMatrix2D <double>)subdomain.Matrix;
                    matrices[i + 1].Add(subdomain.ID, (SkylineMatrix2D <double>)k.Clone());
                }
            }

            provider.Reset();
            coefficientsProvider.CurrentOrder = -1;
            childAnalyzer.BuildMatrices();

            matrices[0] = new Dictionary <int, IMatrix2D <double> >(subdomains.Count);
            foreach (var subdomain in subdomains.Values)
            {
                SkylineMatrix2D <double> k = (SkylineMatrix2D <double>)subdomain.Matrix;
                matrices[0].Add(subdomain.ID, (SkylineMatrix2D <double>)k.Clone());
            }
        }