public static void CheckStaticCondensation()
        {
            double tolerance = 1E-10;

            Model model = CreateModel();
            int   id    = model.Subdomains.First().ID;

            var solver  = (new SkylineSolver.Builder()).BuildSolver(model);
            var problem = new ProblemStructural(model, solver);

            // Prepare model
            model.ConnectDataStructures();

            // Order dofs and initialize linear system
            solver.OrderDofs(true);
            ILinearSystem linearSystem = solver.LinearSystems.First().Value;

            linearSystem.Reset(); // Necessary to define the linear system's size

            // Build and assign global matrices
            (IMatrixView Kff, IMatrixView Kfc, IMatrixView Kcf, IMatrixView Kcc) =
                problem.CalculateSubMatrices(model.Subdomains.First());
            linearSystem.Matrix = Kff;

            // Static condensation: Kcondensed = Kcc - Kcf * inv(Kff) * Kfc
            Dictionary <int, Matrix> invKffTimesKfc = solver.InverseSystemMatrixTimesOtherMatrix(
                new Dictionary <int, IMatrixView>()
            {
                { id, Kfc }
            });
            IMatrixView condensedK = Kcc.Subtract(Kcf.MultiplyRight(invKffTimesKfc[id]));

            // Checks
            Assert.True(expectedCondensedK.Equals(condensedK, tolerance));
        }
        public static void CheckSubmatrices()
        {
            double tolerance = 1E-10;

            Model model = CreateModel();
            int   id    = model.Subdomains.First().ID;

            var solver  = (new SkylineSolver.Builder()).BuildSolver(model);
            var problem = new ProblemStructural(model, solver);

            // Prepare model
            model.ConnectDataStructures();

            // Order dofs and initialize linear system
            solver.OrderDofs(true);
            ILinearSystem linearSystem = solver.LinearSystems.First().Value;

            linearSystem.Reset(); // Necessary to define the linear system's size

            // Build and assign global matrices
            (IMatrixView Kff, IMatrixView Kfc, IMatrixView Kcf, IMatrixView Kcc) =
                problem.CalculateSubMatrices(model.Subdomains.First());

            // Checks
            Assert.True(expectedKff.Equals(Kff, tolerance));
            Assert.True(expectedKcf.Transpose().Equals(Kfc, tolerance));
            Assert.True(expectedKcf.Equals(Kcf, tolerance));
            Assert.True(expectedKcc.Equals(Kcc, tolerance));
        }