public void TestTrigonometricRelations()
        {
            var randomSimplices = Simplex3D.RandomSamples(NUMBER_SAMPLES);

            foreach (var randomSimplex in randomSimplices)
            {
                randomSimplex.Compute(MESH_STEPS, false);
                var trianlges = randomSimplex.Triangles;

                foreach (var triangle in trianlges)
                {
                    var trigonometricRelations = Relations();

                    foreach (var trigonometricRelation in trigonometricRelations)
                    {
                        var deviation = Math.Abs(trigonometricRelation(triangle) - .0);

                        if (deviation >= TOLERANCE)
                        {
                            throw new Exception($"Deviation to high!");
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        private static void Execute(Options options)
        {
            var path = "C:\\Users\\bergerd\\simplices.csv";

            var samples = ShearTriangle2D.RandomSamples(50000);

            //foreach(var sample in samples)
            //    VariousHelpers.SampleToFile(path, sample);


            Console.WriteLine(MessageAtStart(options));

            var randomSimplices = Simplex3D.RandomSamples(options.NumberSamples);
            var counter         = 0;
            var progressBar     = new ProgressBar();
            var nbThreads       = 7;
            var vols            = new double[nbThreads];

            if (File.Exists(path))
            {
                File.Delete(path);
            }

            var partition = VariousHelpers.GetPartition(options.NumberSamples, nbThreads);

            Parallel.For(0, nbThreads, ell =>
            {
                for (int i = partition[ell][0]; i < partition[ell][1]; i++)
                {
                    var stopWatch = new Stopwatch();
                    stopWatch.Start();
                    randomSimplices[i].Compute(3000);
                    stopWatch.Stop();
                    counter += 1;
                    Debug.WriteLine($"Successfully generated {counter} random samples.");

                    lock (_simplexLock)
                    {
                        progressBar.Report(counter, options.NumberSamples, stopWatch.Elapsed.TotalSeconds);
                        VariousHelpers.SampleToFile(path, randomSimplices[i]);
                    }
                }
            });


            /*
             * var sampleFactory = new SampleFactory(options.NumberSamples, options.Dimension, options.Integrate,
             *  options.MeshSteps, options.MaxNorm, options.ZeroAmongEdges, options.ComputeAngles, options.ComputeAnalytical);
             *
             * var progressBar = new ProgressBar();
             * sampleFactory.RaiseSampleCreatorEvent += progressBar.HandleSampleCreationEvent;
             *
             * Console.WriteLine(_computing);
             * (var randomSimplices, var hyperRandomComplexes) = sampleFactory.RandomSamples();
             */
        }
        public void TestAngleBetweenFacesII()
        {
            var randomSimplices = Simplex3D.RandomSamples(NUMBER_SAMPLES);

            foreach (var randomSimplex in randomSimplices)
            {
                var normalABCD = randomSimplex.Angle("A", "B", "C", "D");
                var normalBACD = randomSimplex.Angle("B", "A", "C", "D");
                var normalABDC = randomSimplex.Angle("A", "B", "D", "C");
                var normalBADC = randomSimplex.Angle("B", "A", "D", "C");

                if (Math.Abs(normalABCD - normalBACD) >= TOLERANCE)
                {
                    throw new Exception($"Deviation to high!");
                }

                if (Math.Abs(normalABCD - normalABDC) >= TOLERANCE)
                {
                    throw new Exception($"Deviation to high!");
                }

                if (Math.Abs(normalABCD - normalBADC) >= TOLERANCE)
                {
                    throw new Exception($"Deviation to high!");
                }

                if (Math.Abs(normalBACD - normalABDC) >= TOLERANCE)
                {
                    throw new Exception($"Deviation to high!");
                }

                if (Math.Abs(normalBACD - normalBADC) >= TOLERANCE)
                {
                    throw new Exception($"Deviation to high!");
                }

                if (Math.Abs(normalABDC - normalBADC) >= TOLERANCE)
                {
                    throw new Exception($"Deviation to high!");
                }
            }
        }
        public void TestAngleBetweenFacesI()
        {
            var randomSimplices = Simplex3D.RandomSamples(NUMBER_SAMPLES);

            foreach (var randomSimplex in randomSimplices)
            {
                var normalABC = randomSimplex.NormalOnFace("A", "B", "C");
                var normalABD = randomSimplex.NormalOnFace("A", "D", "B");
                var A         = randomSimplex.GetPoint("A");
                var angleA    = Math.PI - Simplex3D.Angle(A, normalABC, normalABD);

                var normalBCA = randomSimplex.NormalOnFace("B", "C", "A");
                var normalBAD = randomSimplex.NormalOnFace("B", "A", "D");
                var B         = randomSimplex.GetPoint("B");
                var angleB    = Math.PI - Simplex3D.Angle(B, normalBCA, normalBAD);

                if (Math.Abs(angleA - angleB) >= TOLERANCE)
                {
                    throw new Exception($"Deviation to high!");
                }
            }
        }
 public List <Simplex3D> FastRandomSamples3D()
 {
     return(Simplex3D.RandomSamples(NbSamples, MaxNorm));
 }