Skip to content

Commit

Permalink
Added tests for picard with eigen excutioner
Browse files Browse the repository at this point in the history
  • Loading branch information
fdkong committed Oct 18, 2019
1 parent 9efa420 commit 710d911
Show file tree
Hide file tree
Showing 14 changed files with 58 additions and 160 deletions.
4 changes: 2 additions & 2 deletions framework/include/systems/NonlinearEigenSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ class NonlinearEigenSystem : public NonlinearSystemBase
/*
* A residual vector at MOOSE side for AX
*/
NumericVector<Number> & ResidualVectorAX();
NumericVector<Number> & residualVectorAX();

/*
* A residual vector at MOOSE side for BX
*/
NumericVector<Number> & ResidualVectorBX();
NumericVector<Number> & residualVectorBX();

/**
* Add the eigen tag to the right kernels
Expand Down
3 changes: 1 addition & 2 deletions framework/src/executioners/Eigenvalue.C
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,10 @@ Eigenvalue::execute()
PetscOptionsPush(_eigen_problem.petscOptionsDatabase());
Moose::SlepcSupport::slepcSetOptions(_eigen_problem, _pars);
PetscOptionsPop();
_eigen_problem.petscOptionsInserted() = true;
}
#endif
#endif

std::cout<<"Eigenvalue::execute()"<<std::endl;

Steady::execute();
}
28 changes: 19 additions & 9 deletions framework/src/problems/EigenProblem.C
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ validParams<EigenProblem>()
"Using a negative sign makes eigenvalue kernels consistent with "
"a nonlinear solver");

params.addParam<unsigned int>("active_eigen_index", 0, "Which eigen vector is used to compute residual and also associateed to nonlinear variable");
params.addParam<unsigned int>(
"active_eigen_index",
0,
"Which eigen vector is used to compute residual and also associateed to nonlinear variable");

return params;
}
Expand Down Expand Up @@ -220,20 +223,27 @@ EigenProblem::computeResidualAB(const NumericVector<Number> & soln,
Real
EigenProblem::computeResidualL2Norm()
{
computeResidualAB(*_nl_eigen->currentSolution(), _nl_eigen->ResidualVectorAX(), _nl_eigen->ResidualVectorBX(), _nl_eigen->nonEigenVectorTag(), _nl_eigen->eigenVectorTag());
computeResidualAB(*_nl_eigen->currentSolution(),
_nl_eigen->residualVectorAX(),
_nl_eigen->residualVectorBX(),
_nl_eigen->nonEigenVectorTag(),
_nl_eigen->eigenVectorTag());

Real eigenvalue = 1.0;

if (_active_eigen_index<_nl_eigen->getNumConvergedEigenvalues())
if (_active_eigen_index < _nl_eigen->getNumConvergedEigenvalues())
eigenvalue = _nl_eigen->getNthConvergedEigenvalue(_active_eigen_index).first;

// Scale BX with eigenvalue
_nl_eigen->ResidualVectorBX() *= eigenvalue;
_nl_eigen->residualVectorBX() *= eigenvalue;

// Compute entire residual
_nl_eigen->ResidualVectorAX() -= _nl_eigen->ResidualVectorBX();
if (_negative_sign_eigen_kernel)
_nl_eigen->residualVectorAX() += _nl_eigen->residualVectorBX();
else
_nl_eigen->residualVectorAX() -= _nl_eigen->residualVectorBX();

return _nl_eigen->ResidualVectorAX().l2_norm();
return _nl_eigen->residualVectorAX().l2_norm();
}

#endif
Expand All @@ -248,7 +258,7 @@ EigenProblem::checkProblemIntegrity()
void
EigenProblem::solve()
{
#if PETSC_RELEASE_LESS_THAN(3, 12, 0)
#if !PETSC_RELEASE_LESS_THAN(3, 12, 0)
PetscOptionsPush(_petsc_option_data_base);
#endif

Expand All @@ -264,8 +274,8 @@ EigenProblem::solve()
if (_displaced_problem)
_displaced_problem->syncSolutions();

#if PETSC_RELEASE_LESS_THAN(3, 12, 0)
PetscOptionsPop(_petsc_option_data_base);
#if !PETSC_RELEASE_LESS_THAN(3, 12, 0)
PetscOptionsPop();
#endif
}

Expand Down
7 changes: 4 additions & 3 deletions framework/src/problems/FEProblemBase.C
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,6 @@ FEProblemBase::FEProblemBase(const InputParameters & parameters)
#if !PETSC_RELEASE_LESS_THAN(3, 12, 0)
PetscOptionsCreate(&_petsc_option_data_base);
#endif

}

void
Expand Down Expand Up @@ -478,6 +477,10 @@ FEProblemBase::~FEProblemBase()
_ad_grad_zero[i].release();
_ad_second_zero[i].release();
}

#if !PETSC_RELEASE_LESS_THAN(3, 12, 0)
PetscOptionsDestroy(&_petsc_option_data_base);
#endif
}

Moose::CoordinateSystemType
Expand Down Expand Up @@ -4469,9 +4472,7 @@ FEProblemBase::solve()
_displaced_problem->syncSolutions();

#if !PETSC_RELEASE_LESS_THAN(3, 12, 0)
PetscOptionsView(_petsc_option_data_base, NULL);
PetscOptionsPop();
PetscOptionsView(NULL, NULL);
#endif
}

Expand Down
8 changes: 4 additions & 4 deletions framework/src/systems/NonlinearEigenSystem.C
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ NonlinearEigenSystem::NonlinearEigenSystem(EigenProblem & eigen_problem, const s
_transient_sys(eigen_problem.es().get_system<TransientEigenSystem>(name)),
_eigen_problem(eigen_problem),
_n_eigen_pairs_required(eigen_problem.getNEigenPairsRequired()),
_work_rhs_vector_AX(addVector("work_rhs_vector_Ax",false,PARALLEL)),
_work_rhs_vector_BX(addVector("work_rhs_vector_Bx",false,PARALLEL))
_work_rhs_vector_AX(addVector("work_rhs_vector_Ax", false, PARALLEL)),
_work_rhs_vector_BX(addVector("work_rhs_vector_Bx", false, PARALLEL))
{
sys().attach_assemble_function(Moose::assemble_matrix);

Expand Down Expand Up @@ -254,13 +254,13 @@ NonlinearEigenSystem::RHS()
}

NumericVector<Number> &
NonlinearEigenSystem::ResidualVectorAX()
NonlinearEigenSystem::residualVectorAX()
{
return _work_rhs_vector_AX;
}

NumericVector<Number> &
NonlinearEigenSystem::ResidualVectorBX()
NonlinearEigenSystem::residualVectorBX()
{
return _work_rhs_vector_BX;
}
Expand Down
78 changes: 0 additions & 78 deletions test/tests/kernels/2d_diffusion/2d_diffusion_system.i

This file was deleted.

56 changes: 0 additions & 56 deletions test/tests/preconditioners/hyprematrix/2d_diffusion_hyprematrix.i

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eigen_values_real,eigen_values_imag
-0.27676222863962,0
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eigen_values_real,eigen_values_imag
-0.25820884915355,0
5 changes: 2 additions & 3 deletions test/tests/problems/eigen_problem/ne_coupled_picard.i
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,8 @@
type = Eigenvalue
solve_type = MF_MONOLITH_NEWTON
eigen_problem_type = GEN_NON_HERMITIAN
picard_max_its = 30
picard_rel_tol = 1e-60
picard_max_its = 10
picard_rel_tol = 1e-6
[]

[Postprocessors]
Expand All @@ -109,7 +109,6 @@

[Outputs]
csv = true
file_base = ne_coupled
execute_on = 'timestep_end'
[]

Expand Down
5 changes: 5 additions & 0 deletions test/tests/problems/eigen_problem/ne_coupled_picard_sub.i
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,8 @@
[Executioner]
type = Steady
[]

[Outputs]
exodus = true
execute_on = 'timestep_end'
[]
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
[MultiApps]
[./sub]
type = FullSolveMultiApp
input_files = ne_coupled_picard_masterT_sub.i
input_files = ne_coupled_picard_subT_sub.i
execute_on = timestep_end
[../]
[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,5 @@

[Outputs]
csv = true
file_base = ne_coupled
execute_on = 'timestep_end'
[]
17 changes: 16 additions & 1 deletion test/tests/problems/eigen_problem/tests
Original file line number Diff line number Diff line change
Expand Up @@ -112,5 +112,20 @@
requirement = "Eigenvalue system should be able to handle DG kernels"
[]


[./ne_coupled_picard_eigen_master]
type = 'CSVDiff'
input = 'ne_coupled_picard.i'
csvdiff = 'ne_coupled_picard_out_eigenvalues_0001.csv'
slepc_version = '>=3.12.0'
requirement = "Eigenvalue system shall support Picard iteration using eigenvalue executioner as a master"
[]

[./ne_coupled_picard_eigen_sub]
type = 'CSVDiff'
input = 'ne_coupled_picard_subT.i'
csvdiff = 'ne_coupled_picard_subT_out_sub0_eigenvalues_0001.csv'
slepc_version = '>=3.12.0'
requirement = "Eigenvalue system shall support Picard iteration using eigenvalue executioner as a sub app"
[]

[]

0 comments on commit 710d911

Please sign in to comment.