Skip to content

Commit

Permalink
Iteration class change to be incorporated in (in progress) SlaybaughL…
Browse files Browse the repository at this point in the history
  • Loading branch information
Weixiong Zheng committed Sep 2, 2017
1 parent af9c510 commit c697ce7
Show file tree
Hide file tree
Showing 6 changed files with 100 additions and 44 deletions.
18 changes: 16 additions & 2 deletions src/iteration/eigen_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
template <int dim>
EigenBase<dim>::EigenBase () : IterationBase<dim> (),
err_k_tol(1.0e-6),
err_phi_tol(1.0e-7),
err_phi_eigen_tol(1.0e-5),
err_phi_tol(1.0e-5),
keff(1.0)
{
}
Expand Down Expand Up @@ -43,6 +42,15 @@ void EigenBase<dim>::initialize_fiss_process ()
fission_source = this->trm_ptr->estimate_fiss_source (this->sflx_proc);
}

template <int dim>
void EigenBase<dim>::update_fiss_source_keff ()
{
keff_prev_gen = keff;
fission_source_prev_gen = fission_source;
fission_source = trm_ptr->estimate_fiss_source (sflx_proc);
keff = estimate_k (fission_source, fission_source_prev_gen, keff_prev_gen);
}

template <int dim>
double EigenBase<dim>::estimate_k (double &fiss_source,
double &fiss_source_prev,
Expand All @@ -63,5 +71,11 @@ void EigenBase<dim>::eigen_iteration (double &keff,
{
}

template <int dim>
double EigenBase<dim>::get_keff ()
{
return keff;
}

template class EigenBase<2>;
template class EigenBase<3>;
7 changes: 6 additions & 1 deletion src/iteration/eigen_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,14 @@ class EigenBase : public IterationBase
double estimate_fission_source (std::vector<Vector<double> > &sflx_proc);
double estimate_k (double &fiss_src, double &fiss_src_prev_gen, double &k_prev);
double estimate_k_err (double &k, double &k_prev);


const double err_k_tol;
const double err_phi_tol;

double keff;
double keff_prev;

std::vector<Vector<double> > sflx_proc_old;
}

#endif //__eigen_base_h__
24 changes: 21 additions & 3 deletions src/iteration/in_group_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
template <int dim>
InGroupBase<dim>::InGroupBase ()
:
IterationBase<dim> ()
IterationBase<dim> (),
err_phi_tol(1.0e-6)
{
sol_ptr = build_linalg (prm);
}

template <int dim>
Expand All @@ -15,9 +15,27 @@ InGroupBase<dim>::~InGroupBase ()
}

template <int dim>
InGroupBase<dim>::solve_in_group ()
InGroupBase<dim>::solve_in_group
(std_cxx11::shared_ptr<EquationBase<dim> > equ_ptr,
unsigned int &g)
{
}

template <int dim>
SourceIteration<dim>::SourceIteration
:
InGroupBase<dim> ()
{
}

template <int dim>
SourceIteration<dim>::solve_in_group
(std_cxx11::shared_ptr<EquationBase<dim> > equ_ptr,
unsigned int &g)
{
double err = 1.0;
while (err<this->err_phi_tol)
}

template class InGroupBase<2>;
template class InGroupBase<3>;
25 changes: 22 additions & 3 deletions src/iteration/in_group_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,33 @@
#define __in_group_base_h__

template <int dim>
class InGroupBase : public IterationBase
class InGroupBase : public IterationBase<dim>
{
public:
InGroupBase ();
virtual ~InGroupBase();

// has to be overridden for NDA
virtual void solve_in_group ();
// has to be provided
virtual void solve_in_group
(std_cxx11::shared_ptr<EquationBase<dim> > equ_ptr,
unsigned int &g);

protected:
const double err_phi_tol;

std::vector<Vector<double> > sflx_proc_old;
};

template <int dim>
class SourceIteration : public InGroupBase<dim>
{
public:
SourceIteration ();
~SourceIteration ();

void solve_in_group
(std_cxx11::shared_ptr<EquationBase<dim> > equ_ptr,
unsigned int &g);
};

#endif //__in_group_base_h__
55 changes: 20 additions & 35 deletions src/iteration/mg_base.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#include "mg_base.h"

template <int dim>
MGBase<dim>::MGBase () : IterationBase<dim> ()
MGBase<dim>::MGBase ()
: IterationBase<dim> (),
err_phi_tol(1.0e-5)
{
}

Expand All @@ -12,19 +14,29 @@ MGBase<dim>::~MGBase ()

template <int dim>
void MGBase<dim>::do_iterations
(std::vector<PETScWrappers::MPI::SparseMatrix*> &sys_mats,
std::vector<PETScWrappers::MPI::Vector*> &sys_rhses)
(std::vector<typename DoFHandler<dim>::active_cell_iterator> &local_cells,
std::vector<bool> &is_cell_at_bd,
std::vector<std_cxx11::shared_ptr<EquationBase<dim> > > &equ_ptrs)
{
this->initialize_equations (prm, msh_ptr, aqd_ptr, mat_ptr);
mg_iterations (msh_ptr, aqd_ptr, mat_ptr);
// assemble bilinear form of transport equation
equ_ptrs[0]->assemble_bilinear_forms (local_cells, is_cell_at_bd);
// assemble NDA bilinear form if do_nda
if (do_nda)
equ_ptrs[1]->assemble_bilinear_forms (local_cells, is_cell_at_bd);
// multigroup iterations
mg_iterations (local_cells, is_cell_at_bd, equ_ptrs);
}

template <int dim>
void MGBase<dim>::mg_iterations
(std::vector<PETScWrappers::MPI::SparseMatrix*> &sys_mats,
std::vector<PETScWrappers::MPI::Vector*> &sys_rhses)
(std::vector<typename DoFHandler<dim>::active_cell_iterator> &local_cells,
std::vector<bool> &is_cell_at_bd,
std::vector<std_cxx11::shared_ptr<EquationBase<dim> > > &equ_ptrs)
{// this function needs to be overridden if JFNK is desired

// by default, we give out Jacobi iteration scheme
for (unsigned int g=0; g<n_group; <#increment#>) {
<#statements#>
}
/*
for (unsigned int g=0; g<n_group; ++g)
{
Expand All @@ -49,32 +61,5 @@ void MGBase<dim>::mg_iterations
*/
}

template <int dim>
void MGBase<dim>::generate_system_matrices
(std::vector<PETScWrappers::MPI::SparseMatrix*> &sys_mats,
std_cxx11::shared_ptr<EquationBase<dim> > equ_ptr)
{
equ_ptr->assemble_system ();
}

template <int dim>
void MGBase<dim>::generate_group_rhses
(std::vector<PETScWrappers::MPI::Vector*> &group_rhses, unsigned int &g)
{// invoke win_ptr to assemble rhs per specific MG solver in derived class
}

/*
template <int dim>
void MGBase<dim>::iterate_over_groups
(std::vector<PETScWrappers::MPI::Vector*> &group_rhses)
{
for (unsigned int i=0; i<n_group; ++g)
{
generate_group_rhses (group_rhses, g);
win_ptr->solve_in_group (g);
}
}
*/

template class MGBase<2>;
template class MGBase<3>;
15 changes: 15 additions & 0 deletions src/iteration/mg_base.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#ifndef __mg_base_h__
#define __mg_base_h__

#include "../transport/equation_base.h"

using namespace dealii;

template <int dim>
Expand All @@ -10,13 +12,26 @@ class MGBase : public IterationBase<dim>
MGBase ();
virtual ~MGBase ();

virtual void do_iterations
(std::vector<std_cxx11::shared_ptr<EquationBase<dim> > > &equ_ptrs);

virtual void mg_iterations ();

virtual void generate_system_matrices
(std::vector<PETScWrappers::MPI::SparseMatrix*> &sys_mats);

virtual void generate_group_rhses
(std::vector<PETScWrappers::MPI::Vector*> &group_rhses, unsigned int &g);

virtual void iteration_over_groups
(std::vector<PETScWrappers::MPI::Vector*> &group_rhses);

protected:
const double err_phi_tol;

std::vector<Vector<double> > sflx_proc_old;
// auxiliary flux if it's HOLO methodology: it will be for HO flux
std::vector<Vector<double> > sflx_proc_aux;
}

#endif//__mg_base_h__

0 comments on commit c697ce7

Please sign in to comment.