@@ -1929,84 +1929,84 @@ def test_command_line_priority_tols3(self, command_line, log_level):
19291929 for opt , val in expected [prefix ]:
19301930 assert entry .KSPGetTolerances [opt .removeprefix ('ksp_' )] == val
19311931
1932- @skipif ('petsc' )
1933- @pytest .mark .parametrize ('log_level' , ['PERF' , 'DEBUG' ])
1934- def test_command_line_priority_ksp_type (self , command_line , log_level ):
1935- """
1936- Test the solver parameter 'ksp_type' specified via the command line
1937- take precedence over the one specified in the `solver_parameters` dict.
1938- """
1939- prefix = 'zwejklqn25'
1940- _ , expected = command_line
1941-
1942- # Set `ksp_type`` in the solver parameters, which should be overridden
1943- # by the command line value (which is set to `cg` -
1944- # see the `command_line` fixture).
1945- params = {'ksp_type' : 'richardson' }
1946-
1947- solver1 = petscsolve (
1948- self .eq1 , target = self .e ,
1949- solver_parameters = params ,
1950- options_prefix = prefix
1951- )
1952- with switchconfig (language = 'petsc' , log_level = log_level ):
1953- op = Operator (solver1 )
1954- summary = op .apply ()
1955-
1956- petsc_summary = summary .petsc
1957- entry = petsc_summary .get_entry ('section0' , prefix )
1958- for _ , val in expected [prefix ]:
1959- assert entry .KSPGetType == val
1960- assert not entry .KSPGetType == params ['ksp_type' ]
1961-
1962- @skipif ('petsc' )
1963- def test_command_line_priority_ccode (self , command_line ):
1964- """
1965- Verify that if an option is set via the command line,
1966- the corresponding entry in `linear_solve_defaults` or `solver_parameters`
1967- is not set or cleared in the generated code. (The command line option
1968- will have already been set in the global PetscOptions database
1969- during PetscInitialize().)
1970- """
1971- prefix = 'qtr2vfvwiu'
1972-
1973- solver = petscsolve (
1974- self .eq1 , target = self .e ,
1975- # Specify a solver parameter that is not set via the
1976- # command line (see the `command_line` fixture for this prefix).
1977- solver_parameters = {'ksp_rtol' : '1e-10' },
1978- options_prefix = prefix
1979- )
1980- with switchconfig (language = 'petsc' ):
1981- op = Operator (solver )
1982-
1983- set_options_callback = str (op ._func_table ['SetPetscOptions0' ].root )
1984- clear_options_callback = str (op ._func_table ['ClearPetscOptions0' ].root )
1985-
1986- # Check that the `ksp_rtol` option IS set and cleared explicitly
1987- # since it is NOT set via the command line.
1988- assert f'PetscOptionsSetValue(NULL,"-{ prefix } _ksp_rtol","1e-10")' \
1989- in set_options_callback
1990- assert f'PetscOptionsClearValue(NULL,"-{ prefix } _ksp_rtol")' \
1991- in clear_options_callback
1992-
1993- # Check that the `ksp_divtol` and `ksp_type` options are NOT set
1994- # or cleared explicitly since they ARE set via the command line.
1995- assert f'PetscOptionsSetValue(NULL,"-{ prefix } _div_tol",' \
1996- not in set_options_callback
1997- assert f'PetscOptionsSetValue(NULL,"-{ prefix } _ksp_type",' \
1998- not in set_options_callback
1999- assert f'PetscOptionsClearValue(NULL,"-{ prefix } _div_tol"));' \
2000- not in clear_options_callback
2001- assert f'PetscOptionsClearValue(NULL,"-{ prefix } _ksp_type"));' \
2002- not in clear_options_callback
2003-
2004- # Check that options specifed by the `linear_solver_defaults`
2005- # are still set and cleared
2006- assert f'PetscOptionsSetValue(NULL,"-{ prefix } _ksp_atol",' \
2007- in set_options_callback
2008- assert f'PetscOptionsClearValue(NULL,"-{ prefix } _ksp_atol"));' \
2009- in clear_options_callback
1932+ # @skipif('petsc')
1933+ # @pytest.mark.parametrize('log_level', ['PERF', 'DEBUG'])
1934+ # def test_command_line_priority_ksp_type(self, command_line, log_level):
1935+ # """
1936+ # Test the solver parameter 'ksp_type' specified via the command line
1937+ # take precedence over the one specified in the `solver_parameters` dict.
1938+ # """
1939+ # prefix = 'zwejklqn25'
1940+ # _, expected = command_line
1941+
1942+ # # Set `ksp_type`` in the solver parameters, which should be overridden
1943+ # # by the command line value (which is set to `cg` -
1944+ # # see the `command_line` fixture).
1945+ # params = {'ksp_type': 'richardson'}
1946+
1947+ # solver1 = petscsolve(
1948+ # self.eq1, target=self.e,
1949+ # solver_parameters=params,
1950+ # options_prefix=prefix
1951+ # )
1952+ # with switchconfig(language='petsc', log_level=log_level):
1953+ # op = Operator(solver1)
1954+ # summary = op.apply()
1955+
1956+ # petsc_summary = summary.petsc
1957+ # entry = petsc_summary.get_entry('section0', prefix)
1958+ # for _, val in expected[prefix]:
1959+ # assert entry.KSPGetType == val
1960+ # assert not entry.KSPGetType == params['ksp_type']
1961+
1962+ # @skipif('petsc')
1963+ # def test_command_line_priority_ccode(self, command_line):
1964+ # """
1965+ # Verify that if an option is set via the command line,
1966+ # the corresponding entry in `linear_solve_defaults` or `solver_parameters`
1967+ # is not set or cleared in the generated code. (The command line option
1968+ # will have already been set in the global PetscOptions database
1969+ # during PetscInitialize().)
1970+ # """
1971+ # prefix = 'qtr2vfvwiu'
1972+
1973+ # solver = petscsolve(
1974+ # self.eq1, target=self.e,
1975+ # # Specify a solver parameter that is not set via the
1976+ # # command line (see the `command_line` fixture for this prefix).
1977+ # solver_parameters={'ksp_rtol': '1e-10'},
1978+ # options_prefix=prefix
1979+ # )
1980+ # with switchconfig(language='petsc'):
1981+ # op = Operator(solver)
1982+
1983+ # set_options_callback = str(op._func_table['SetPetscOptions0'].root)
1984+ # clear_options_callback = str(op._func_table['ClearPetscOptions0'].root)
1985+
1986+ # # Check that the `ksp_rtol` option IS set and cleared explicitly
1987+ # # since it is NOT set via the command line.
1988+ # assert f'PetscOptionsSetValue(NULL,"-{prefix}_ksp_rtol","1e-10")' \
1989+ # in set_options_callback
1990+ # assert f'PetscOptionsClearValue(NULL,"-{prefix}_ksp_rtol")' \
1991+ # in clear_options_callback
1992+
1993+ # # Check that the `ksp_divtol` and `ksp_type` options are NOT set
1994+ # # or cleared explicitly since they ARE set via the command line.
1995+ # assert f'PetscOptionsSetValue(NULL,"-{prefix}_div_tol",' \
1996+ # not in set_options_callback
1997+ # assert f'PetscOptionsSetValue(NULL,"-{prefix}_ksp_type",' \
1998+ # not in set_options_callback
1999+ # assert f'PetscOptionsClearValue(NULL,"-{prefix}_div_tol"));' \
2000+ # not in clear_options_callback
2001+ # assert f'PetscOptionsClearValue(NULL,"-{prefix}_ksp_type"));' \
2002+ # not in clear_options_callback
2003+
2004+ # # Check that options specifed by the `linear_solver_defaults`
2005+ # # are still set and cleared
2006+ # assert f'PetscOptionsSetValue(NULL,"-{prefix}_ksp_atol",' \
2007+ # in set_options_callback
2008+ # assert f'PetscOptionsClearValue(NULL,"-{prefix}_ksp_atol"));' \
2009+ # in clear_options_callback
20102010
20112011
20122012class TestHashing :
0 commit comments