public (List <Simplex>, List <SimplexComplex>) RandomSamples()
        {
            var riemannianSpace = Geometries.GetSpace(CurvatureType, Dim);
            var randomSimplices = Simplex.RandomSamples(NbSamples, Dim, riemannianSpace, ZeroAmongEdges, MaxNorm);
            var randomComplexes = new List <SimplexComplex>();
            var counter         = 0;

            foreach (var randomSimplex in randomSimplices)
            {
                var stopWatch = new Stopwatch();
                stopWatch.Start();

                var simplexComplex = new SimplexComplex(randomSimplex);
                simplexComplex.Propagate();

                if (Integrate)
                {
                    simplexComplex.Integrate(MeshSteps, null, ComputeAnalytical);
                }

                if (ComputeAngles)
                {
                    simplexComplex.ComputeAngles();
                }

                counter++;

                stopWatch.Stop();
                var sampleCreationEventArgs = new SampleCreationEventArgs(counter, NbSamples, stopWatch.Elapsed.TotalSeconds);
                OnSampleCreationEvent(sampleCreationEventArgs);
                randomComplexes.Add(simplexComplex);
            }

            return(randomSimplices, randomComplexes);
        }
        public void TestDefect2Dim()
        {
            var ambiantSpace  = Geometries.GetSpace(CurvatureType.NEGATIVE, 2);
            var randomSamples = Simplex.RandomSamples(NUMBER_SAMPLES, 2, ambiantSpace, true, MAX_NORM);
            var counter       = 0;

            foreach (var simplex in randomSamples)
            {
                foreach (var face in simplex.Faces)
                {
                    var normalVector = VariousHelpers.GetNormalVector(face);

                    foreach (var dirVector in face.DirectionalVectors)
                    {
                        var scalarProduct = dirVector.DotProduct(normalVector);

                        if (Math.Abs(scalarProduct) >= TOLERANCE)
                        {
                            throw new Exception($"Deviation to high for simplex number {counter}");
                        }
                    }
                    counter++;
                }
            }
        }
        public void TestAngleComputation2Dim()
        {
            var ambiantSpace  = Geometries.GetSpace(CurvatureType.FLAT, 2);
            var randomSamples = Simplex.RandomSamples(NUMBER_SAMPLES, 2, ambiantSpace, true, MAX_NORM);
            var counter       = 0;

            foreach (var simplex in randomSamples)
            {
                var faceA = simplex.Faces[0];
                var faceB = simplex.Faces[1];
                var faceC = simplex.Faces[2];

                var normVectorA = VariousHelpers.GetNormalVector(faceA);
                var normVectorB = VariousHelpers.GetNormalVector(faceB);
                var normVectorC = VariousHelpers.GetNormalVector(faceC);

                var alpha = Math.PI - VariousHelpers.Angle(normVectorB, normVectorC);
                var beta  = Math.PI - VariousHelpers.Angle(normVectorA, normVectorC);
                var gamma = Math.PI - VariousHelpers.Angle(normVectorA, normVectorB);

                if (Math.Abs(alpha + beta + gamma - Math.PI) >= TOLERANCE)
                {
                    throw new Exception($"Deviation to high for simplex number {counter}");
                }

                counter++;
            }
        }
        public void TestNormVectorComputation()
        {
            for (int iDim = 2; iDim < 10; iDim++)
            {
                var ambiantSpace  = Geometries.GetSpace(CurvatureType.FLAT, iDim);
                var randomSamples = Simplex.RandomSamples(NUMBER_SAMPLES, iDim, ambiantSpace, true, MAX_NORM);
                var counter       = 0;

                foreach (var simplex in randomSamples)
                {
                    var normalVectorSum = Vector <double> .Build.DenseOfArray(new double[iDim]);

                    foreach (var face in simplex.Faces)
                    {
                        var normalVector = VariousHelpers.GetNormalVector(face);
                        face.Integrate(0, true);
                        var volumeFace       = face.Volume;
                        var normNormalVector = normalVector.L2Norm();
                        normalVectorSum += volumeFace * normalVector;
                    }

                    if (Math.Abs(normalVectorSum.L2Norm()) >= TOLERANCE)
                    {
                        throw new Exception($"Deviation to high for simplex number {counter}");
                    }

                    counter++;
                }
            }
        }
Ejemplo n.º 5
0
        public void TestRelations(string relation)
        {
            var ambiantSpace   = Geometries.GetSpace(CurvatureType.FLAT, 2);
            var randomSamples  = Simplex.RandomSamples(NUMBER_SAMPLES, 2, ambiantSpace, true, MAX_NORM);
            var counter        = 0;
            var anlgeRelations = GetAnlgeRelations();

            foreach (var simplex in randomSamples)
            {
                foreach (var angleRelation in anlgeRelations)
                {
                    var faceA = simplex.Faces[0];
                    var faceB = simplex.Faces[1];
                    var faceC = simplex.Faces[2];

                    var normVectorA = VariousHelpers.GetNormalVector(faceA);
                    var normVectorB = VariousHelpers.GetNormalVector(faceB);
                    var normVectorC = VariousHelpers.GetNormalVector(faceC);

                    var alpha = Math.PI - VariousHelpers.Angle(normVectorB, normVectorC);
                    var beta  = Math.PI - VariousHelpers.Angle(normVectorA, normVectorC);
                    var gamma = Math.PI - VariousHelpers.Angle(normVectorA, normVectorB);

                    var value = angleRelation.Value(alpha, beta, gamma);

                    if (Math.Abs(value) >= TOLERANCE)
                    {
                        throw new Exception($"Deviation to high for simplex number {counter}");
                    }
                }

                counter++;
            }
        }
        public void TestRelations()
        {
            var ambiantSpace  = Geometries.GetSpace(CurvatureType.FLAT, 2);
            var randomSamples = Simplex.RandomSamples(NUMBER_SAMPLES, 2, ambiantSpace, true, MAX_NORM);
            var counter       = 0;

            foreach (var simplex in randomSamples)
            {
                var faceSum = Vector <double> .Build.DenseOfArray(new double[2]);

                foreach (var face in simplex.Faces)
                {
                    faceSum += face.DirectionalVectors[0];
                }

                if (Math.Abs(faceSum.L2Norm()) >= TOLERANCE)
                {
                    throw new Exception($"Deviation to high for simplex number {counter}");
                }

                counter++;
            }
        }
Ejemplo n.º 7
0
        public void TestLength(CurvatureType curvatureType)
        {
            var ambiantSpace  = Geometries.GetSpace(CurvatureType.NEGATIVE, 2);
            var randomSamples = Simplex.RandomSamples(NUMBER_SAMPLES, 2, ambiantSpace, true, MAX_NORM);
            var counter       = 0;

            foreach (var simplex in randomSamples)
            {
                foreach (var face in simplex.Faces)
                {
                    face.Integrate(MESH_STEPS, true);
                    var volumeAnalytical = face.Volume;
                    face.Integrate(MESH_STEPS, false);
                    var volume = face.Volume;

                    if (Math.Abs(volumeAnalytical - volume) >= TOLERANCE)
                    {
                        throw new Exception($"Deviation to high for simplex number {counter}");
                    }
                }

                counter++;
            }
        }