Ejemplo n.º 1
0
    def _solve_eigen(self,mp,echo=0):
        self.skipTestIfApplicationsNotAvailable("LinearSolversApplication")
        from KratosMultiphysics import LinearSolversApplication
        if not LinearSolversApplication.HasFEAST():
            self.skipTest("FEAST is missing in the compilation")

        eigensolver_settings = KratosMultiphysics.Parameters("""{
            "solver_type": "feast",
            "symmetric": true,
            "e_min": 1.0e-2,
            "e_max": 25.0,
            "subspace_size": 7
        }""")

        eigen_solver = eigen_solver_factory.ConstructSolver(eigensolver_settings)
        builder_and_solver = KratosMultiphysics.ResidualBasedBlockBuilderAndSolver(eigen_solver)

        eigen_scheme = StructuralMechanicsApplication.EigensolverDynamicScheme()
        mass_matrix_diagonal_value = 1.0
        stiffness_matrix_diagonal_value = -1.0
        eig_strategy = StructuralMechanicsApplication.EigensolverStrategy(mp,
                                                                    eigen_scheme,
                                                                    builder_and_solver,
                                                                    mass_matrix_diagonal_value,
                                                                    stiffness_matrix_diagonal_value)

        eig_strategy.SetEchoLevel(echo)
        eig_strategy.Solve()
Ejemplo n.º 2
0
    def _solve_eigenvalue_problem(self, mp, use_block_builder, echo=0):
        eigensolver_settings = KratosMultiphysics.Parameters("""
        {
            "max_iteration"         : 1000,
            "tolerance"             : 1e-6,
            "number_of_eigenvalues" : 2,
            "echo_level"            : 0,
            "normalize_eigenvectors": true
        }
        """)

        eigen_solver = LinearSolversApplication.EigensystemSolver(eigensolver_settings)
        if use_block_builder:
            builder_and_solver = KratosMultiphysics.ResidualBasedBlockBuilderAndSolver(eigen_solver)
        else:
            builder_and_solver = KratosMultiphysics.ResidualBasedEliminationBuilderAndSolver(eigen_solver)

        eigen_scheme = StructuralMechanicsApplication.EigensolverDynamicScheme()
        compute_modal_decomposition = True
        # see "structural_mechanics_eigensolver.py", values are for the "EigensystemSolver"
        mass_matrix_diagonal_value = 0.0
        stiffness_matrix_diagonal_value = 1.0
        eig_strategy = StructuralMechanicsApplication.EigensolverStrategy(mp,
                                                                          eigen_scheme,
                                                                          builder_and_solver,
                                                                          mass_matrix_diagonal_value,
                                                                          stiffness_matrix_diagonal_value,
                                                                          compute_modal_decomposition)
        eig_strategy.SetEchoLevel(echo)
        eig_strategy.Solve()
Ejemplo n.º 3
0
def ConstructSolver(configuration):
    if not isinstance(configuration, KM.Parameters):
        raise Exception(
            "input is expected to be provided as a Kratos Parameters object")

    solver_type = configuration["solver_type"].GetString()
    if "Application." in solver_type:  # the module in which the solver is implemented was specified
        split_name = solver_type.split(".")
        solver_type = split_name[1]

    if KratosSolvers.DenseLinearSolverFactory().Has(solver_type):
        KM.Logger.PrintInfo("Eigen-Linear-Solver-Factory",
                            "Constructing a dense linear-solver")
        return KratosSolvers.DenseLinearSolverFactory().Create(configuration)
    elif KratosSolvers.ComplexDenseLinearSolverFactory().Has(solver_type):
        KM.Logger.PrintInfo("Eigen-Linear-Solver-Factory",
                            "Constructing a complex dense linear-solver")
        return KratosSolvers.ComplexDenseLinearSolverFactory().Create(
            configuration)
    else:
        # fall back to the standard linear solver factory
        return python_linear_solver_factory.ConstructSolver(configuration)
Ejemplo n.º 4
0
 def test_FEAST_with_eigen_solver(self):
     from KratosMultiphysics import LinearSolversApplication
     if not LinearSolversApplication.HasFEAST():
         self.skipTest("FEAST is not available")
     self._RunParametrized("""
         {
             "test_list" : [
                 {
                     "solver_type": "feast",
                     "symmetric": true,
                     "e_min": 0.01,
                     "e_max": 0.20,
                     "subspace_size": 5
                 }
             ]
         }
         """)
    def _solve_prebuckling_problem(self,mp,NumOfNodes,iterations,echo=0):
        eigensolver_settings = KratosMultiphysics.Parameters("""
        {
            "max_iteration"         : 1000,
            "tolerance"             : 1e-6,
            "number_of_eigenvalues" : 1,
            "echo_level"            : 0,
            "normalize_eigenvectors": false
        }
        """)

        buckling_settings = KratosMultiphysics.Parameters("""
        {
            "initial_load_increment"    : 1.0,
            "small_load_increment"      : 0.0005,
            "path_following_step"       : 0.5,
            "convergence_ratio"         : 0.005,
            "make_matrices_symmetric"   : true
        }
        """)

        eigen_solver = LinearSolversApplication.EigensystemSolver(eigensolver_settings)
        eigen_solver_ = KratosMultiphysics.ResidualBasedEliminationBuilderAndSolver(eigen_solver)
        convergence_criterion = KratosMultiphysics.DisplacementCriteria(1e-4,1e-9)
        scheme = KratosMultiphysics.ResidualBasedIncrementalUpdateStaticScheme()
        linear_solver = KratosMultiphysics.SkylineLUFactorizationSolver()
        builder_and_solver = KratosMultiphysics.ResidualBasedEliminationBuilderAndSolver(linear_solver)
        convergence_criterion.SetEchoLevel(echo)

        eig_strategy = StructuralMechanicsApplication.PrebucklingStrategy( mp,
                                                                           scheme,
                                                                           eigen_solver_,
                                                                           builder_and_solver,
                                                                           convergence_criterion,
                                                                           10,
                                                                           buckling_settings )
        eig_strategy.SetEchoLevel(echo)
        LoadFactor = []
        for i in range(iterations):
            eig_strategy.Solve()
            if( i%2 == 1):
                LoadFactor.append( mp.ProcessInfo[StructuralMechanicsApplication.EIGENVALUE_VECTOR][0] )
            self._updateConditions(mp,NumOfNodes)
        return LoadFactor
 def test_eigen_dense_Householder_QR_decomposition_3x3(self):
     decomposition = LinearSolversApplication.EigenDenseHouseholderQRDecomposition()
     self._execute_eigen_dense_qr_decomposition_test(decomposition, self._square_matrix_3x3, False)
import KratosMultiphysics

import KratosMultiphysics.StructuralMechanicsApplication as StructuralMechanicsApplication
import KratosMultiphysics.KratosUnittest as KratosUnittest
from KratosMultiphysics import eigen_solver_factory

from math import sqrt, sin, cos, pi, exp, atan

from KratosMultiphysics import kratos_utilities
if kratos_utilities.CheckIfApplicationsAvailable("LinearSolversApplication"):
    from KratosMultiphysics import LinearSolversApplication
    feast_available = LinearSolversApplication.HasFEAST()
else:
    feast_available = False


class SpringDamperElementTests(KratosUnittest.TestCase):
    def setUp(self):
        pass

    def _add_variables(self, mp):
        mp.AddNodalSolutionStepVariable(KratosMultiphysics.DISPLACEMENT)
        mp.AddNodalSolutionStepVariable(KratosMultiphysics.ROTATION)
        mp.AddNodalSolutionStepVariable(KratosMultiphysics.REACTION)
        mp.AddNodalSolutionStepVariable(KratosMultiphysics.REACTION_MOMENT)
        mp.AddNodalSolutionStepVariable(KratosMultiphysics.VELOCITY)
        mp.AddNodalSolutionStepVariable(KratosMultiphysics.ANGULAR_VELOCITY)
        mp.AddNodalSolutionStepVariable(KratosMultiphysics.ACCELERATION)
        mp.AddNodalSolutionStepVariable(
            KratosMultiphysics.ANGULAR_ACCELERATION)
        mp.AddNodalSolutionStepVariable(KratosMultiphysics.VOLUME_ACCELERATION)
Ejemplo n.º 8
0
def AssembleTestSuites():
    ''' Populates the test suites to run.

    Populates the test suites to run. At least, it should pupulate the suites:
    "small", "nighlty" and "all"

    Return
    ------

    suites: A dictionary of suites
        The set of suites with its test_cases added.
    '''
    suites = KratosUnittest.KratosSuites

    # Create a test suit with the selected tests (Small tests):
    # These tests are executed by the continuous integration tool, so they have to be very fast!
    # Execution time << 1 sec on a regular PC !!!
    # If the tests in the smallSuite take too long then merging to master will not be possible!
    smallSuite = suites[
        'small']  # These tests are executed by the continuous integration tool
    nightSuite = suites[
        'nightly']  # These tests are executed in the nightly build

    ### Adding the self-contained tests
    # Constitutive Law tests
    smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TTestConstitutiveLaw]))
    nightSuite.addTest(
        TSimpleSmallDeformationPlasticityMCTest('test_execution'))
    smallSuite.addTest(
        TSimpleSmallDeformationPlasticityVMTest('test_execution'))
    nightSuite.addTest(
        TSerialParallelRuleOfMixturesCubeDamageTest('test_execution'))
    nightSuite.addTest(TAnisotropyTest('test_execution'))
    nightSuite.addTest(TInitialStateElasticityTest('test_execution'))
    smallSuite.addTest(
        TSimpleSmallDeformationPlasticityDPTest('test_execution'))
    smallSuite.addTest(
        TSimpleSmallDeformationPlasticityTTest('test_execution'))
    nightSuite.addTest(
        TBigCubeSmallDeformationPlasticityMCTest('test_execution'))
    nightSuite.addTest(
        TBigCubeSmallDeformationPlasticityVMTest('test_execution'))
    nightSuite.addTest(
        TBigCubeSmallDeformationPlasticityDPTest('test_execution'))
    nightSuite.addTest(
        TBigCubeSmallDeformationPlasticityTTest('test_execution'))
    nightSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TTestPerfectPlasticityImplementationVerification]))
    # Mass calculation tests
    smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TTestMassCalculation]))
    smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TTestComputeCenterOfGravity]))
    smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TTestComputeMassMomentOfInertia]))
    # Axis projection tests
    smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TTestAxisProjection]))
    # Force distribution process
    smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TTestDistributeLoadOnSurfaceProcess]))
    # Solids
    smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TTestPatchTestSmallStrain]))
    smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TTestPatchTestSmallStrainBbar]))
    smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TTestPatchTestLargeStrain]))
    smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TTestQuadraticElements]))
    smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TTestPatchTestSmallDisplacementMixedVolumetricStrain]))
    # Shells
    smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TTestPatchTestShells]))
    nightSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases([
        TTestPatchTestShellsStressRec
    ]))  # TODO should be in smallSuite but is too slow
    nightSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases([
        TTestPatchTestShellsOrthotropic
    ]))  # TODO should be in smallSuite but is too slow
    # Membranes
    nightSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TDynamicPatchTestMembrane]))
    smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TStaticPatchTestMembrane]))
    # Formfinding
    smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TTestPatchTestFormfinding]))
    # Trusses
    smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TTestTruss3D2N]))
    # Beams
    smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TStaticPatchTestBeam3D2N]))
    smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TStaticPatchTestBeam2D2N]))
    nightSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TDynamicPatchTestBeam3D2N]))
    nightSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TDynamicPatchTestBeam2D2N]))
    # Loading Conditions
    smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TTestLoadingConditionsPoint]))
    smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TTestLoadingConditionsLine]))
    smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TTestLoadingConditionsSurface]))
    # Dynamic Eigenvalue Analysis
    smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TTestDynamicEigenvalueAnalysis]))
    # Buckling analysis test
    nightSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TTestPrebucklingAnalysis]))
    # Nodal Damping
    nightSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TNodalDampingTests]))  # TODO should be in smallSuite but is too slow
    # Dynamic basic tests
    smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TFastDynamicSchemesTests]))
    # Eigenvalues Postprocessing Process test
    smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TTestPostprocessEigenvaluesProcess]))
    smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TestEigenSolverWithConstraints]))
    smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TestEigenSolverWithDifferentDofs]))
    # Custom Scipy Solver test
    nightSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TestCustomScipyBaseSolver]))
    # local-axis visualization tests
    smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TTestLocalAxisVisualization]))
    # Adjoint Elements and Conditions
    smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TTestCrBeamAdjointElement]))
    smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TTestShellThinAdjointElement3D3N]))
    smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TTestTrussAdjointElement]))
    smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TTestTrussLinearAdjointElement]))
    smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TTestAdjointLoadingConditions]))
    # RVE tests
    nightSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TTestRVESimplestTest]))
    # Element damping test
    smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TSpringDamperElementTests]))
    # Perturb geometry process test
    smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TTestPerturbGeometryUtility]))

    ### Adding Small Tests
    # Basic moving mesh test (leave these in the smallSuite to have the Exection script tested)
    smallSuite.addTest(TSimpleMeshMovingTest('test_execution'))
    # Basic restart test (leave these in the smallSuite to have the Exection script tested)
    smallSuite.addTest(TTestSmallDisplacement2D4N('test_execution'))
    smallSuite.addTest(TTestTotalLagrangian2D3N('test_execution'))
    smallSuite.addTest(TTestUpdatedLagrangian3D8N('test_execution'))

    ### Adding Nightly Tests
    # Patch test Small Displacements
    nightSuite.addTest(TSDTwoDShearQuaPatchTest('test_execution'))
    nightSuite.addTest(TSDTwoDShearTriPatchTest('test_execution'))
    nightSuite.addTest(TSDTwoDTensionQuaPatchTest('test_execution'))
    nightSuite.addTest(TSDTwoDTensionTriPatchTest('test_execution'))
    nightSuite.addTest(TSDThreeDShearHexaPatchTest('test_execution'))
    nightSuite.addTest(TSDThreeDShearTetraPatchTest('test_execution'))
    nightSuite.addTest(TSDThreeDTensionHexaPatchTest('test_execution'))
    nightSuite.addTest(TSDThreeDTensionTetraPatchTest('test_execution'))
    # Patch test Total Lagrangian
    nightSuite.addTest(TTLTwoDShearQuaPatchTest('test_execution'))
    nightSuite.addTest(TTLTwoDShearTriPatchTest('test_execution'))
    nightSuite.addTest(TTLTwoDTensionQuaPatchTest('test_execution'))
    nightSuite.addTest(TTLTwoDTensionTriPatchTest('test_execution'))
    nightSuite.addTest(TTLThreeDShearHexaPatchTest('test_execution'))
    nightSuite.addTest(TTLThreeDShearTetraPatchTest('test_execution'))
    nightSuite.addTest(TTLThreeDTensionHexaPatchTest('test_execution'))
    nightSuite.addTest(TTLThreeDTensionTetraPatchTest('test_execution'))
    # Patch test Updated Lagrangian
    nightSuite.addTest(TULTwoDShearQuaPatchTest('test_execution'))
    nightSuite.addTest(TULTwoDShearTriPatchTest('test_execution'))
    nightSuite.addTest(TULTwoDTensionQuaPatchTest('test_execution'))
    nightSuite.addTest(TULTwoDTensionTriPatchTest('test_execution'))
    nightSuite.addTest(TULThreeDShearHexaPatchTest('test_execution'))
    nightSuite.addTest(TULThreeDShearTetraPatchTest('test_execution'))
    nightSuite.addTest(TULThreeDTensionHexaPatchTest('test_execution'))
    nightSuite.addTest(TULThreeDTensionTetraPatchTest('test_execution'))
    # SPRISM tests
    nightSuite.addTest(TSprismMembranePatchTests('test_execution'))
    nightSuite.addTest(TSprismBendingPatchTests('test_execution'))
    # Mixed displacement - volumetric strain tests
    nightSuite.addTest(TTestCookMembrane('test_cook_membrane_2d'))
    nightSuite.addTest(
        TTestCookMembrane('test_cook_membrane_incompressible_2d'))
    # Membrane tests
    nightSuite.addTest(TFofi4PointTentCableTests('test_execution'))
    nightSuite.addTest(TMembraneHemisphereTests('test_execution'))
    nightSuite.addTest(TMembraneOrthotropicDiagonalTests('test_execution'))
    nightSuite.addTest(TMembraneOrthotropicHorizontalTests('test_execution'))
    nightSuite.addTest(TMembranePreStressHorizontalTests('test_execution'))
    nightSuite.addTest(TMembranePreStressDiagonalTests('test_execution'))
    # 2Node Element tests
    nightSuite.addTest(T3D2NTrussDynamicTest('test_execution'))
    nightSuite.addTest(T3D2NTrussLinearTest('test_execution'))
    nightSuite.addTest(T3D2NTrussTest('test_execution'))
    nightSuite.addTest(
        T3D2NTrussLinearCompressionPlasticTest('test_execution'))
    nightSuite.addTest(T3D2NTrussLinearTensionPlasticTest('test_execution'))
    nightSuite.addTest(
        T3D2NTrussNonLinearSnapthroughPlasticTest('test_execution'))
    nightSuite.addTest(T3D2NTrussNonLinearTensionPlasticTest('test_execution'))
    nightSuite.addTest(T3D2NBeamCrTest('test_execution'))
    nightSuite.addTest(T3D2NBeamCrNonLinearTest('test_execution'))
    nightSuite.addTest(T3D2NBeamCrLinearTest('test_execution'))
    nightSuite.addTest(T3D2NBeamCrDynamicTest('test_execution'))
    nightSuite.addTest(T3D2NNLDispCtrlTest('test_execution'))
    # Shell tests
    nightSuite.addTest(
        TShellT3IsotropicLinearStaticStructScordelisLoRoofTests(
            'test_execution'))
    nightSuite.addTest(
        TShellT3AndQ4LinearStaticStructScordelisLoRoofTests('test_execution'))
    nightSuite.addTest(
        TShellT3AndQ4LinearStaticStructPinchedCylinderTests('test_execution'))
    nightSuite.addTest(
        TShellT3AndQ4LinearStaticStructPinchedHemisphereTests(
            'test_execution'))
    # nightSuite.addTest(TShellT3AndQ4LinearStaticStructClampedCylinderOrthotropicTests('test_execution'))
    nightSuite.addTest(
        TShellT3AndQ4NonLinearStaticStructHingedCylRoofSnapthroughTests(
            'test_execution'))
    # nightSuite.addTest(TShellT3AndQ4NonLinearStaticStructHingedCylRoofSnapthroughOrthotropicTests('test_execution'))
    # nightSuite.addTest(TShellT3AndQ4NonLinearDynamicStructOscillatingPlateTests('test_execution'))
    # nightSuite.addTest(TShellT3AndQ4NonLinearDynamicStructOscillatingPlateLumpedTests('test_execution'))
    # Constitutive Law tests
    nightSuite.addTest(TSmallDeformationPlasticityTest('test_execution'))
    nightSuite.addTest(TSimpleJ2PlasticityTest('test_execution'))
    nightSuite.addTest(
        TRigidFaceTestWithImposeRigidMovementProcess('test_execution'))
    nightSuite.addTest(TRigidBlockTest('test_execution'))
    nightSuite.addTest(TRigidEliminationTest('test_execution'))
    nightSuite.addTest(TRigidSphereFailing('test_execution'))
    nightSuite.addTest(TRigidSphereFailingExplicit('test_execution'))
    # 2.5D solid element test
    nightSuite.addTest(TSolid2p5DElementTest('test_execution'))

    if has_linear_solvers_application:
        from KratosMultiphysics import LinearSolversApplication
        if LinearSolversApplication.HasFEAST():
            # Eigenvalues tests
            smallSuite.addTest(TEigenQ4Thick2x2PlateTests('test_execution'))
            smallSuite.addTest(TEigenTL3D8NCubeTests('test_execution'))
            nightSuite.addTest(TEigen3D3NThinCircleTests('test_execution'))
            # Harmonic analysis test
            smallSuite.addTests(
                KratosUnittest.TestLoader().loadTestsFromTestCases(
                    [THarmonicAnalysisTests]))
            # Rayleigh process test
            nightSuite.addTest(TRayleighProcessTest('test_execution'))
        else:
            print("FEAST not available in LinearSolversApplication")

    nightSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [THarmonicAnalysisTestsWithHDF5]))

    nightSuite.addTest(
        TTestAdjointSensitivityAnalysisBeamStructureLocalStress(
            'test_execution'))
    nightSuite.addTest(
        TTestAdjointSensitivityAnalysisBeamStructureNodalDisplacement(
            'test_execution'))
    nightSuite.addTest(
        TTestAdjointSensitivityAnalysisBeamStructureStrainEnergy(
            'test_execution'))
    nightSuite.addTest(
        TTestAdjointSensitivityAnalysisBeamStructureNodalReaction(
            'test_execution'))
    nightSuite.addTest(
        TTestAdjointSensitivityAnalysisShellStructureLocalStress(
            'test_execution'))
    nightSuite.addTest(
        TTestAdjointSensitivityAnalysisShellStructureNodalDisplacement(
            'test_execution'))
    nightSuite.addTest(
        TTestAdjointSensitivityAnalysisShellStructureStrainEnergy(
            'test_execution'))
    nightSuite.addTest(
        TTestAdjointSensitivityAnalysisSpringDamperElement('test_execution'))
    nightSuite.addTest(
        TTestAdjointSensitivityAnalysisLinearTrussStructure('test_execution'))
    nightSuite.addTest(
        TTestAdjointSensitivityAnalysisNonLinearTrussStructure(
            'test_execution'))

    nightSuite.addTest(TTestMassResponseFunction('test_execution'))
    nightSuite.addTest(TTestStrainEnergyResponseFunction('test_execution'))
    nightSuite.addTest(TTestEigenfrequencyResponseFunction('test_execution'))
    nightSuite.addTest(
        TTestAdjointStrainEnergyResponseFunction('test_execution'))
    nightSuite.addTest(
        TTestAdjointDisplacementResponseFunction('test_execution'))
    nightSuite.addTest(TTestAdjointStressResponseFunction('test_execution'))
    nightSuite.addTest(TTestAdjointMaxStressResponseFunction('test_execution'))

    # Dynamic basic tests
    nightSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases(
        [TDynamicSchemesTests]))

    nightSuite.addTests(smallSuite)

    ### Adding Validation Tests
    # For very long tests that should not be in nighly and you can use to validate
    validationSuite = suites['validation']
    # SPRISM tests
    # validationSuite.addTest(TSprismPanTests('test_execution')) # FIXME: Needs get up to date
    validationSuite.addTest(T2D2NBeamCrTest(
        'test_execution'))  # TODO should be in nightSuite but is too slow
    validationSuite.addTest(
        TMembraneMultiLinearIsotropicPlaneStressTests(
            'test_execution'))  # TODO should be in nightSuite but is too slow
    # Pendulus tests with Solid Elements
    validationSuite.addTest(TPendulusTLTest('test_execution'))
    validationSuite.addTest(TPendulusULTest('test_execution'))
    # Pendulus Tests with Shell Elements
    # validationSuite.addTest(TShellT3AndQ4NonLinearDynamicStructPendulusTests('test_execution'))
    # validationSuite.addTest(TShellT3AndQ4NonLinearDynamicStructPendulusLumpedTests('test_execution'))
    # validationSuite.addTest(TShellT3AndQ4NonLinearDynamicUnstructPendulusTests('test_execution'))
    # validationSuite.addTest(TShellT3AndQ4NonLinearDynamicUnstructPendulusLumpedTests('test_execution'))
    # Shell tests
    validationSuite.addTest(
        TShellT3AndQ4LinearStaticUnstructScordelisLoRoofTests(
            'test_execution'))
    validationSuite.addTest(
        TShellT3AndQ4LinearStaticUnstructUnstructPinchedCylinderTests(
            'test_execution'))
    validationSuite.addTest(
        TShellT3AndQ4LinearStaticUnstructPinchedHemisphereTests(
            'test_execution'))
    # validationSuite.addTest(TShellT3AndQ4LinearStaticUnstructClampedCylinderOrthotropicTests('test_execution'))
    validationSuite.addTest(
        TShellT3AndQ4NonLinearStaticUnstructHingedCylRoofSnapthroughTests(
            'test_execution'))
    # validationSuite.addTest(TShellT3AndQ4NonLinearStaticUnstructHingedCylRoofSnapthroughOrthotropicTests('test_execution'))
    # validationSuite.addTest(TShellT3AndQ4NonLinearDynamicUnstructOscillatingPlateTests('test_execution'))
    # validationSuite.addTest(TShellT3AndQ4NonLinearDynamicUnstructOscillatingPlateLumpedTests('test_execution'))

    # CL tests
    validationSuite.addTest(TTensileTestStructuralTest('test_execution'))

    # Explicit solid beam
    validationSuite.addTest(TExplicitSolidBeam('test_execution'))

    ### OLD Shell Tests Start, will be removed soon, Philipp Bucher, 31.01.2018 |---
    # They have been moved to validation temporarily until they will be removed
    validationSuite.addTest(TShellT3ThinDrillingRollUpTests('test_execution'))
    validationSuite.addTest(TShellT3IsotropicScordelisTests('test_execution'))
    validationSuite.addTest(TShellQ4ThickBendingRollUpTests('test_execution'))
    # validationSuite.addTest(TShellQ4ThickDrillingRollUpTests('test_execution'))
    validationSuite.addTest(
        TShellQ4ThickOrthotropicLaminateLinearStaticTests('test_execution'))
    validationSuite.addTest(TShellT3ThinBendingRollUpTests('test_execution'))
    validationSuite.addTest(
        TShellT3ThinOrthotropicLaminateLinearStaticTests('test_execution'))
    validationSuite.addTest(TShellT3ThickLinearStaticTests('test_execution'))
    validationSuite.addTest(
        TShellT3ThickNonLinearStaticTests('test_execution'))
    validationSuite.addTest(TShellT3ThickLinearDynamicTests('test_execution'))
    validationSuite.addTest(
        TShellT3ThickNonLinearDynamicTests('test_execution'))
    validationSuite.addTest(
        TShellT3ThickOrthotropicLaminateLinearStaticTests('test_execution'))
    validationSuite.addTest(TShellQ4ThinLinearStaticTests('test_execution'))
    validationSuite.addTest(TShellQ4ThinNonLinearStaticTests('test_execution'))
    validationSuite.addTest(TShellQ4ThinLinearDynamicTests('test_execution'))
    validationSuite.addTest(
        TShellQ4ThinNonLinearDynamicTests('test_execution'))
    validationSuite.addTest(
        TShellQ4ThinOrthotropicLaminateLinearStaticTests('test_execution'))
    ### ---| OLD Shell Tests End

    # Create a test suit that contains all the tests:
    allSuite = suites['all']
    allSuite.addTests(nightSuite)  # Already contains the smallSuite
    validationSuite.addTests(allSuite)  # Validation contains all

    return suites
from __future__ import print_function, absolute_import, division
import os
import KratosMultiphysics

import KratosMultiphysics.KratosUnittest as KratosUnittest
from KratosMultiphysics import eigen_solver_factory
import KratosMultiphysics.LinearSolversApplication as LinearSolversApplication

from math import sqrt

@KratosUnittest.skipUnless(LinearSolversApplication.HasFEAST(),"FEAST not found in LinearSolversApplication, skipping.")
class TestFeastEigensystemSolver(KratosUnittest.TestCase):
    def test_real_symmetric_gev(self):

        space = KratosMultiphysics.UblasSparseSpace()

        settings = KratosMultiphysics.Parameters('''{
            "solver_type": "feast",
            "symmetric": true,
            "number_of_eigenvalues": 3,
            "search_lowest_eigenvalues": true,
            "e_min": 0.0,
            "e_max": 0.2,
            "echo_level": 0
         }''')

        K = KratosMultiphysics.CompressedMatrix()

        this_file_dir = os.path.dirname(os.path.realpath(__file__))
        base_dir = os.path.dirname(os.path.dirname(os.path.dirname(this_file_dir)))
        matrix_file_path = os.path.join(base_dir, "kratos", "tests", "auxiliar_files_for_python_unittest", "sparse_matrix_files", "A.mm")
Ejemplo n.º 10
0
def ConstructSolver(settings):
    if not isinstance(settings, KM.Parameters):
        raise Exception("Input is expected to be provided as a Kratos Parameters object")

    solver_type = settings["solver_type"].GetString()

    if solver_type == "eigen_eigensystem":
        if kratos_utils.CheckIfApplicationsAvailable("LinearSolversApplication"):
            from KratosMultiphysics import LinearSolversApplication
            eigen_solver = LinearSolversApplication.EigensystemSolver(settings)
            return eigen_solver
        else:
            raise Exception("LinearSolversApplication not available")

    if solver_type == "spectra_sym_g_eigs_shift":
        if kratos_utils.CheckIfApplicationsAvailable("LinearSolversApplication"):
            from KratosMultiphysics import LinearSolversApplication
            eigen_solver = LinearSolversApplication.SpectraSymGEigsShiftSolver(settings)
            return eigen_solver
        else:
            raise Exception("LinearSolversApplication not available")


    elif solver_type == "dense_eigensolver":
        if kratos_utils.CheckIfApplicationsAvailable("LinearSolversApplication"):
            from KratosMultiphysics import LinearSolversApplication
            eigen_solver = LinearSolversApplication.DenseEigenvalueSolver(settings)
            return eigen_solver
        else:
            raise Exception("LinearSolversApplication not available")

    elif solver_type == "feast":
        if kratos_utils.CheckIfApplicationsAvailable("LinearSolversApplication"):
            from KratosMultiphysics import LinearSolversApplication
            if LinearSolversApplication.HasFEAST():
                is_symmetric = settings["symmetric"].GetBool() if settings.Has("symmetric") else True
                eigen_solver = LinearSolversApplication.FEASTSymmetricEigensystemSolver(settings) if is_symmetric else LinearSolversApplication.FEASTGeneralEigensystemSolver(settings)
                return eigen_solver
            else:
                raise Exception("FEAST not available in LinearSolversApplication")
        else:
            raise Exception("LinearSolversApplication not available")

    elif solver_type == "feast_complex":
        if kratos_utils.CheckIfApplicationsAvailable("LinearSolversApplication"):
            from KratosMultiphysics import LinearSolversApplication
            if LinearSolversApplication.HasFEAST():
                is_symmetric = settings["symmetric"].GetBool() if settings.Has("symmetric") else True
                eigen_solver = LinearSolversApplication.ComplexFEASTSymmetricEigensystemSolver(settings) if is_symmetric else LinearSolversApplication.ComplexFEASTGeneralEigensystemSolver(settings)
                return eigen_solver
            else:
                raise Exception("FEAST not available in LinearSolversApplication")
        else:
            raise Exception("LinearSolversApplication not available")

    linear_solver_configuration = settings["linear_solver_settings"]
    if linear_solver_configuration.Has("solver_type"): # user specified a linear solver
        linear_solver = linear_solver_factory.ConstructSolver(linear_solver_configuration)
    else:
        linear_solver = linear_solver_factory.CreateFastestAvailableDirectLinearSolver()

    if solver_type == "power_iteration_eigenvalue_solver":
        eigen_solver = KM.PowerIterationEigenvalueSolver( settings, linear_solver)
    elif solver_type == "power_iteration_highest_eigenvalue_solver":
        eigen_solver = KM.PowerIterationHighestEigenvalueSolver( settings, linear_solver)
    elif solver_type == "rayleigh_quotient_iteration_eigenvalue_solver":
        eigen_solver = KM.RayleighQuotientIterationEigenvalueSolver( settings, linear_solver)
    else:
        raise Exception("Solver type not found. Asking for :" + solver_type)

    return eigen_solver
Ejemplo n.º 11
0
 def test_eigen_dense_BDC_SVD_3x3(self):
     decomposition = LinearSolversApplication.EigenDenseBDCSVD()
     self._execute_eigen_dense_decomposition_test(decomposition, self._square_matrix_3x3)
 def test_eigen_dense_column_pivoting_Householder_QR_decomposition_10x3_random(self):
     decomposition = LinearSolversApplication.EigenDenseColumnPivotingHouseholderQRDecomposition()
     self._execute_eigen_dense_qr_decomposition_test(decomposition, lambda : self._random_matrix_mxn(10,3), True)
 def test_eigen_dense_column_pivoting_Householder_QR_decomposition_3x3(self):
     decomposition = LinearSolversApplication.EigenDenseColumnPivotingHouseholderQRDecomposition()
     self._execute_eigen_dense_qr_decomposition_test(decomposition, self._square_matrix_3x3, True)
 def test_eigen_dense_Householder_QR_decomposition_10x3_random(self):
     decomposition = LinearSolversApplication.EigenDenseHouseholderQRDecomposition()
     self._execute_eigen_dense_qr_decomposition_test(decomposition, lambda : self._random_matrix_mxn(10,3), False)
Ejemplo n.º 15
0
def AssembleTestSuites():
    ''' Populates the test suites to run.
    Populates the test suites to run. At least, it should pupulate the suites:
    "small", "nighlty" and "all"
    Return
    ------
    suites: A dictionary of suites
        The set of suites with its test_cases added.
    '''

    suites = KratosUnittest.KratosSuites

    smallSuite = suites['small']
    smallSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases([
        # Single patch test - checks iga essentials
        SinglePatchTest,
        # Truss tests
        TTrussElementTests,
        # Membrane tests
        MembraneSinglePatchFourPointSailLinearStatic,
        MembraneSinglePatchFourPointSailNonLinearStatic,
        # 3p Shell KL
        ScordelisRoofShell3pTest,
        LinearBeamShell3pTest,
        # 5p Shell Director
        # ScordelisRoofShell5pTest, -- commented as it contains heap error in ubuntu/CI
        # Weak support tests
        SinglePatchRefinedSupportPenaltyTest,
        SinglePatchRefinedSupportLagrangeTest,
        # Coupling tests
        TwoPatchCouplingPenaltyShell3pTest,
        TwoPatchCouplingLagrangeShell3pTest,
        TwoPatchRefinedCouplingPenaltyMembraneTest,
        TwoPatchRefinedCouplingLagrangeMembraneTest,
        # Rotation/G_1 coupling tests
        TwoPatchCantileverCouplingPenaltyTest,
        TwoPatchCantileverRefinedCouplingPenaltyTest,
        # Volumes
        TTestNurbsVolumeElements,
        # Modelers
        TTestModelers
    ]))

    if has_linear_solvers_application:
        from KratosMultiphysics import LinearSolversApplication
        if LinearSolversApplication.HasFEAST():
            smallSuite.addTests(
                KratosUnittest.TestLoader().loadTestsFromTestCases([
                    # Weak support Nitsche test
                    SinglePatchRefinedSupportNitscheTest,
                    # Coupling Nitsche tests
                    TwoPatchCouplingNitscheShell3pTest,
                    TwoPatchRefinedCouplingNitscheMembraneTest
                ]))
        else:
            print("FEAST not available in LinearSolversApplication")

    nightSuite = suites['nightly']
    nightSuite.addTests(smallSuite)
    nightSuite.addTests(KratosUnittest.TestLoader().loadTestsFromTestCases([
        # Membrane tests
        MembraneSinglePatchFourPointSailImplicitDynamic,
        # 5p Shell Hierarchic
        TShell5pHierarchicLinearThickBeamTest,
        TShell5pHierarchicLinearScordelisTest,
        TShell5pHierarchicNonLinearThickBeamTest
    ]))

    allSuite = suites['all']
    allSuite.addTests(nightSuite)

    return suites
 def test_eigen_dense_Jacobi_SVD_3x10_random_thin(self):
     decomposition = LinearSolversApplication.EigenDenseJacobiSVD()
     self._execute_eigen_dense_svd_test(decomposition, lambda : self._random_matrix_mxn(3,10), True)
 def test_eigen_dense_Jacobi_SVD_5x4_random(self):
     decomposition = LinearSolversApplication.EigenDenseJacobiSVD()
     self._execute_eigen_dense_svd_test(decomposition, lambda : self._random_matrix_mxn(5,4))
 def test_eigen_dense_Jacobi_SVD_3x3(self):
     decomposition = LinearSolversApplication.EigenDenseJacobiSVD()
     self._execute_eigen_dense_svd_test(decomposition, self._square_matrix_3x3)
 def test_eigen_dense_BDC_SVD_5x4_random_thin(self):
     decomposition = LinearSolversApplication.EigenDenseBDCSVD()
     self._execute_eigen_dense_svd_test(decomposition, lambda : self._random_matrix_mxn(5,4), True)
 def test_eigen_dense_BDC_SVD_3x10_random(self):
     decomposition = LinearSolversApplication.EigenDenseBDCSVD()
     self._execute_eigen_dense_svd_test(decomposition, lambda : self._random_matrix_mxn(3,10))