From c3b144bc22878f240ee0b4b8825256f940d27215 Mon Sep 17 00:00:00 2001 From: Weixiong Zheng Date: Thu, 27 Jul 2017 10:46:40 -0700 Subject: [PATCH] Changed aq and builders #10 --- src/aqdata/aq_base.cc | 1 + src/aqdata/aq_base.h | 3 +- src/common/bart_driver.cc | 1 - src/common/bart_tools.cc | 10 +++- src/common/bart_tools.h | 2 + src/iteration/iteration_base.cc | 101 +++++++++++++------------------- 6 files changed, 54 insertions(+), 64 deletions(-) diff --git a/src/aqdata/aq_base.cc b/src/aqdata/aq_base.cc index 331bab14d..18d6cd98c 100644 --- a/src/aqdata/aq_base.cc +++ b/src/aqdata/aq_base.cc @@ -14,6 +14,7 @@ n_group(prm.get_integer("number of groups")), n_azi(prm.get_integer("angular quadrature order")), have_reflective_bc(prm.get_bool("have reflective BC")) { + this->make_aq (prm); } template diff --git a/src/aqdata/aq_base.h b/src/aqdata/aq_base.h index bb46c9e59..40b9c7111 100644 --- a/src/aqdata/aq_base.h +++ b/src/aqdata/aq_base.h @@ -21,8 +21,6 @@ class AQBase virtual void produce_angular_quad (); virtual void initialize_component_index (); void print_angular_quad (); - - void make_aq (ParameterHandler &prm); unsigned int get_sn_order (); unsigned int get_n_dir (); @@ -59,6 +57,7 @@ class AQBase reflective_direction_index; private: + void make_aq (ParameterHandler &prm); std::string produce_quadrature_name (); void initialize_ref_bc_index (); diff --git a/src/common/bart_driver.cc b/src/common/bart_driver.cc index f748df00f..7e863c0d1 100644 --- a/src/common/bart_driver.cc +++ b/src/common/bart_driver.cc @@ -42,7 +42,6 @@ pcout(std::cout, Utilities::MPI::this_mpi_process(MPI_COMM_WORLD)==0) { aqd_ptr = build_aq_model (prm) - aqd_ptr->make_aq (prm); n_total_ho_vars = aqd_ptr->get_n_total_ho_vars (); n_azi = aqd_ptr->get_sn_order (); n_dir = aqd_ptr->get_n_dir (); diff --git a/src/common/bart_tools.cc b/src/common/bart_tools.cc index fed8e688e..6fb93dcd9 100644 --- a/src/common/bart_tools.cc +++ b/src/common/bart_tools.cc @@ -14,9 +14,17 @@ std_cxx11::shared_ptr > build_mesh (ParameterHandler &prm) return mesh_class; } +std_cxx11::shared_ptr build_material (ParameterHandler &prm) +{ + std_cxx11::shared_ptr material_class = + std_cxx11::shared_ptr + (new MaterialProperties (prm)); + return material_class; +} + template std_cxx11::shared_ptr > -build_iterative_solver (ParameterHandler &prm, +build_transport_iteration (ParameterHandler &prm, const std_cxx11::shared_ptr > msh_ptr, const std_cxx11::shared_ptr > aqd_ptr) { diff --git a/src/common/bart_tools.h b/src/common/bart_tools.h index ed4019e48..34402f2c5 100644 --- a/src/common/bart_tools.h +++ b/src/common/bart_tools.h @@ -14,6 +14,8 @@ template std_cxx11::shared_ptr > build_mesh (ParameterHandler &prm); +std_cxx11::shared_ptr build_material (ParameterHandler &prm); + template std_cxx11::shared_ptr > build_iterative_solver (ParameterHandler &prm, diff --git a/src/iteration/iteration_base.cc b/src/iteration/iteration_base.cc index d7a8aff8e..a5b5c70dd 100644 --- a/src/iteration/iteration_base.cc +++ b/src/iteration/iteration_base.cc @@ -16,14 +16,8 @@ using namespace dealii; template -TransportBase::TransportBase (ParameterHandler &prm) +IterationBase::IterationBase (ParameterHandler &prm) : -mpi_communicator (MPI_COMM_WORLD), -triangulation (mpi_communicator, - typename Triangulation::MeshSmoothing - (Triangulation::smoothing_on_refinement | - Triangulation::smoothing_on_coarsening)), -dof_handler (triangulation), err_k_tol(1.0e-6), err_phi_tol(1.0e-7), err_phi_eigen_tol(1.0e-5), @@ -41,21 +35,19 @@ pcout(std::cout, (new ProblemDefinition(prm)); msh_ptr = std_cxx11::shared_ptr > (new MeshGenerator(prm)); - mat_ptr = std_cxx11::shared_ptr - (new MaterialProperties(prm)); + mat_ptr = build_material (prm); this->process_input (); sflx_proc.resize (n_group); sflx_proc_prev_gen.resize (n_group); } template -TransportBase::~TransportBase () +IterationBase::~IterationBase () { - dof_handler.clear(); } template -void TransportBase::process_input () +void IterationBase::process_input () { // basic parameters { @@ -116,18 +108,7 @@ void TransportBase::process_input () } template -void TransportBase::initialize_aq (ParameterHandler &prm) -{ - aq_name = prm.get ("angular quadrature name"); - AssertThrow (aq_name=="lsgc", - ExcMessage("only LS-GC quadrature is implemented now.")); - if (aq_name=="lsgc") - aqd_ptr = std_cxx11::shared_ptr > (new AQLSGC(prm)); - aqd_ptr->make_aq (prm); -} - -template -void TransportBase::report_system () +void IterationBase::report_system () { pcout << "SN quadrature order: " << n_azi << std::endl << "Number of angles: " << n_dir << std::endl @@ -155,7 +136,7 @@ void TransportBase::report_system () } template -void TransportBase::setup_system () +void IterationBase::setup_system () { radio ("setup system"); initialize_dealii_objects (); @@ -163,7 +144,7 @@ void TransportBase::setup_system () } template -void TransportBase::initialize_system_matrices_vectors () +void IterationBase::initialize_system_matrices_vectors () { DynamicSparsityPattern dsp (relevant_dofs); @@ -263,7 +244,7 @@ void TransportBase::initialize_system_matrices_vectors () } template -void TransportBase::assemble_ho_system () +void IterationBase::assemble_ho_system () { radio ("Assemble volumetric bilinear forms"); assemble_ho_volume_boundary (); @@ -278,7 +259,7 @@ void TransportBase::assemble_ho_system () } template -void TransportBase::initialize_dealii_objects () +void IterationBase::initialize_dealii_objects () { if (discretization=="dfem") fe = (new FE_DGQ (p_order)); @@ -327,7 +308,7 @@ void TransportBase::initialize_dealii_objects () } template -void TransportBase::assemble_ho_volume_boundary () +void IterationBase::assemble_ho_volume_boundary () { // volumetric pre-assembly matrices std::vector > > @@ -398,7 +379,7 @@ void TransportBase::assemble_ho_volume_boundary () // The following is a virtual function for integraing cell bilinear form; // It can be overriden if cell pre-assembly is desirable template -void TransportBase:: +void IterationBase:: pre_assemble_cell_matrices (const std_cxx11::shared_ptr > fv, typename DoFHandler::active_cell_iterator &cell, @@ -410,7 +391,7 @@ pre_assemble_cell_matrices // The following is a virtual function for integraing cell bilinear form; // It must be overriden template -void TransportBase::integrate_cell_bilinear_form +void IterationBase::integrate_cell_bilinear_form (const std_cxx11::shared_ptr > fv, typename DoFHandler::active_cell_iterator &cell, FullMatrix &cell_matrix, @@ -424,7 +405,7 @@ void TransportBase::integrate_cell_bilinear_form // The following is a virtual function for integraing boundary bilinear form; // It must be overriden template -void TransportBase::integrate_boundary_bilinear_form +void IterationBase::integrate_boundary_bilinear_form (const std_cxx11::shared_ptr > fvf, typename DoFHandler::active_cell_iterator &cell, unsigned int &fn,/*face number*/ @@ -435,7 +416,7 @@ void TransportBase::integrate_boundary_bilinear_form } template -void TransportBase::integrate_reflective_boundary_linear_form +void IterationBase::integrate_reflective_boundary_linear_form (const std_cxx11::shared_ptr > fvf, typename DoFHandler::active_cell_iterator &cell, unsigned int &fn,/*face number*/ @@ -446,7 +427,7 @@ void TransportBase::integrate_reflective_boundary_linear_form } template -void TransportBase::assemble_ho_interface () +void IterationBase::assemble_ho_interface () { FullMatrix vp_up (dofs_per_cell, dofs_per_cell); FullMatrix vp_un (dofs_per_cell, dofs_per_cell); @@ -507,7 +488,7 @@ void TransportBase::assemble_ho_interface () // The following is a virtual function for integrating DG interface for HO system // it must be overriden template -void TransportBase::integrate_interface_bilinear_form +void IterationBase::integrate_interface_bilinear_form (const std_cxx11::shared_ptr > fvf, const std_cxx11::shared_ptr > fvf_nei, typename DoFHandler::active_cell_iterator &cell, @@ -523,7 +504,7 @@ void TransportBase::integrate_interface_bilinear_form } template -void TransportBase::generate_moments () +void IterationBase::generate_moments () { // FitIt: only scalar flux is generated for now AssertThrow(do_nda==false, ExcMessage("Moments are generated only without NDA")); @@ -539,22 +520,22 @@ void TransportBase::generate_moments () } template -void TransportBase::generate_ho_rhs () +void IterationBase::generate_ho_rhs () { } template -void TransportBase::NDA_PI () +void IterationBase::NDA_PI () { } template -void TransportBase::NDA_SI () +void IterationBase::NDA_SI () { } template -void TransportBase::scale_fiss_transfer_matrices () +void IterationBase::scale_fiss_transfer_matrices () { AssertThrow (do_nda==false, ExcMessage("we don't scale fission transfer without NDA")); @@ -574,12 +555,12 @@ void TransportBase::scale_fiss_transfer_matrices () } template -void TransportBase::generate_ho_fixed_source () +void IterationBase::generate_ho_fixed_source () { } template -void TransportBase::initialize_fiss_process () +void IterationBase::initialize_fiss_process () { for (unsigned int g=0; g::initialize_fiss_process () } template -void TransportBase::update_ho_moments_in_fiss () +void IterationBase::update_ho_moments_in_fiss () { for (unsigned int g=0; g::update_ho_moments_in_fiss () } template -void TransportBase::update_fiss_source_keff () +void IterationBase::update_fiss_source_keff () { keff_prev_gen = keff; fission_source_prev_gen = fission_source; @@ -611,7 +592,7 @@ void TransportBase::update_fiss_source_keff () } template -void TransportBase::power_iteration () +void IterationBase::power_iteration () { double err_k = 1.0; double err_phi = 1.0; @@ -635,7 +616,7 @@ void TransportBase::power_iteration () } template -void TransportBase::source_iteration () +void IterationBase::source_iteration () { unsigned int ct = 0; double err_phi = 1.0; @@ -661,12 +642,12 @@ void TransportBase::source_iteration () } template -void TransportBase::postprocess () +void IterationBase::postprocess () {// do nothing in the base class } template -double TransportBase::estimate_fiss_source (std::vector > &phis_this_process) +double IterationBase::estimate_fiss_source (std::vector > &phis_this_process) { double fiss_source = 0.0; for (unsigned int ic=0; ic::estimate_fiss_source (std::vector > &p } template -double TransportBase::estimate_k (double &fiss_source, +double IterationBase::estimate_k (double &fiss_source, double &fiss_source_prev_gen, double &k_prev_gen) { @@ -701,7 +682,7 @@ double TransportBase::estimate_k (double &fiss_source, } template -double TransportBase::estimate_phi_diff +double IterationBase::estimate_phi_diff (std::vector &phis_newer, std::vector &phis_older) { @@ -718,7 +699,7 @@ double TransportBase::estimate_phi_diff } template -void TransportBase::do_iterations () +void IterationBase::do_iterations () { sol_ptr->initialize_ho_preconditioners (vec_ho_sys, vec_ho_rhs); if (is_eigen_problem) @@ -747,26 +728,26 @@ void TransportBase::do_iterations () //functions used to cout information for diagonose or just simply cout template -void TransportBase::radio (std::string str) +void IterationBase::radio (std::string str) { pcout << str << std::endl; } template -void TransportBase::radio (std::string str1, std::string str2) +void IterationBase::radio (std::string str1, std::string str2) { pcout << str1 << ": " << str2 << std::endl; } template -void TransportBase::radio (std::string str, +void IterationBase::radio (std::string str, double num) { pcout << str << ": " << num << std::endl; } template -void TransportBase::radio (std::string str1, unsigned int num1, +void IterationBase::radio (std::string str1, unsigned int num1, std::string str2, unsigned int num2, std::string str3, unsigned int num3) { @@ -776,24 +757,24 @@ void TransportBase::radio (std::string str1, unsigned int num1, } template -void TransportBase::radio (std::string str, +void IterationBase::radio (std::string str, unsigned int num) { pcout << str << ": " << num << std::endl; } template -void TransportBase::radio (std::string str, bool boolean) +void IterationBase::radio (std::string str, bool boolean) { pcout << str << ": " << (boolean?"true":"false") << std::endl; } template -void TransportBase::radio () +void IterationBase::radio () { pcout << "-------------------------------------" << std::endl << std::endl; } // explicit instantiation to avoid linking error -template class TransportBase<2>; -template class TransportBase<3>; +template class IterationBase<2>; +template class IterationBase<3>;