Skip to content

Commit

Permalink
initial capability for setting petsc options per FEProblem. Note that…
Browse files Browse the repository at this point in the history
… this does not finish this ticket. We really need to find a way to name the nonlinear systems and use the proper Petsc prefixing methods for specifying per-solve parameters. ref #1872

r17860
  • Loading branch information
friedmud authored and permcody committed Feb 14, 2014
1 parent c743115 commit 1dd45bf
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 0 deletions.
5 changes: 5 additions & 0 deletions framework/src/base/FEProblem.C
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "ElementH1Error.h"
#include "Function.h"
#include "Material.h"
#include "PetscSupport.h"

#include "ElementPostprocessor.h"
#include "NodalPostprocessor.h"
Expand Down Expand Up @@ -2619,6 +2620,10 @@ FEProblem::init2()
void
FEProblem::solve()
{
#ifdef LIBMESH_HAVE_PETSC
Moose::PetscSupport::petscSetOptions(*this); // Make sure the PETSc options are setup for this app
#endif

Moose::setSolverDefaults(*this);
Moose::perf_log.push("solve()","Solve");
// _solve_only_perf_log.push("solve");
Expand Down
Binary file not shown.
Binary file not shown.
66 changes: 66 additions & 0 deletions test/tests/multiapps/petsc_options/master.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
[Mesh]
type = GeneratedMesh
dim = 2
nx = 10
ny = 10
[]

[Variables]
[./u]
[../]
[]

[Kernels]
[./diff]
type = Diffusion
variable = u
[../]
[./td]
type = TimeDerivative
variable = u
[../]
[]

[BCs]
[./left]
type = DirichletBC
variable = u
boundary = left
value = 0
[../]
[./right]
type = DirichletBC
variable = u
boundary = right
value = 1
[../]
[]

[Executioner]
type = Transient
num_steps = 2
dt = 1
l_max_its = 4
nl_max_its = 2
petsc_options = '-snes_mf_operator -ksp_monitor'
petsc_options_iname = '-pc_type -pc_hypre_type'
petsc_options_value = 'hypre boomeramg'
l_tol = 1e-12
[]

[Output]
output_initial = true
exodus = true
perf_log = true
[]

[MultiApps]
[./sub]
type = TransientMultiApp
app_type = MooseTestApp
execute_on = timestep
positions = '0 0 0'
input_files = sub.i
[../]
[]

53 changes: 53 additions & 0 deletions test/tests/multiapps/petsc_options/sub.i
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
[Mesh]
type = GeneratedMesh
dim = 2
nx = 10
ny = 10
[]

[Variables]
[./u]
[../]
[]

[Kernels]
[./diff]
type = Diffusion
variable = u
[../]
[./td]
type = TimeDerivative
variable = u
[../]
[]

[BCs]
[./left]
type = DirichletBC
variable = u
boundary = left
value = 0
[../]
[./right]
type = DirichletBC
variable = u
boundary = right
value = 1
[../]
[]

[Executioner]
type = Transient
num_steps = 1
dt = 1
petsc_options = '-snes_mf_operator -ksp_monitor'
petsc_options_iname = '-pc_type -sub_pc_type'
petsc_options_value = 'asm ilu'
[]

[Output]
output_initial = true
exodus = true
perf_log = true
[]

8 changes: 8 additions & 0 deletions test/tests/multiapps/petsc_options/tests
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[Tests]
[./test]
type = 'Exodiff'
input = 'master.i'
exodiff = 'master_out.e master_out_sub0.e'
expect_out = '8 KSP'
[../]
[]

0 comments on commit 1dd45bf

Please sign in to comment.