Skip to content

Commit

Permalink
Cleaning and sorting things up gradually SlaybaughLab#10
Browse files Browse the repository at this point in the history
  • Loading branch information
Weixiong Zheng committed Jul 25, 2017
1 parent bdb941e commit aed7808
Show file tree
Hide file tree
Showing 8 changed files with 81 additions and 585 deletions.
2 changes: 1 addition & 1 deletion src/aqdata/lsgc.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ class LSGC : public AQBase<dim>
void produce_angular_quad ();
};

#endif//__aq_lsgc_h__
#endif//__lsgc_h__
41 changes: 41 additions & 0 deletions src/common/bart_builder.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,47 @@ build_aq_model (ParameterHandler &prm)
return aq_class;
}

void radio (std::string str)
{
pcout << str << std::endl;
}

void radio (std::string str1, std::string str2)
{
pcout << str1 << ": " << str2 << std::endl;
}

void radio (std::string str,
double num)
{
pcout << str << ": " << num << std::endl;
}

void radio (std::string str1, unsigned int num1,
std::string str2, unsigned int num2,
std::string str3, unsigned int num3)
{
pcout << str1 << ": " << num1 << ", ";
pcout << str2 << ": " << num2 << ", ";
pcout << str3 << ": " << num3 << std::endl;;
}

void radio (std::string str,
unsigned int num)
{
pcout << str << ": " << num << std::endl;
}

void radio (std::string str, bool boolean)
{
pcout << str << ": " << (boolean?"true":"false") << std::endl;
}

void radio ()
{
pcout << "-------------------------------------" << std::endl << std::endl;
}

template std_cxx11::shared_ptr<TransportBase<2> > build_transport_model;
template std_cxx11::shared_ptr<TransportBase<3> > build_transport_model;
template std_cxx11::shared_ptr<AQBase<2> > build_aq_model;
Expand Down
16 changes: 16 additions & 0 deletions src/common/bart_builder.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,20 @@ template <int dim>
std_cxx11::shared_ptr<AQBase<dim> >
build_aq_model (ParameterHandler &prm);

void radio (std::string str);

void radio (std::string str1, std::string str2);

void radio (std::string str, double num);

void radio (std::string str1, unsigned int num1,
std::string str2, unsigned int num2,
std::string str3, unsigned int num3);

void radio (std::string str, unsigned int num);

void radio (std::string str, bool boolean);

void radio ();

#endif //__bart_builder_h__
28 changes: 0 additions & 28 deletions src/common/bart_driver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -636,33 +636,6 @@ void TransportBase<dim>::postprocess ()
{// do nothing in the base class
}

template <int dim>
double TransportBase<dim>::estimate_fiss_source (std::vector<Vector<double> > &phis_this_process)
{
double fiss_source = 0.0;
for (unsigned int ic=0; ic<local_cells.size(); ++ic)
{
typename DoFHandler<dim>::active_cell_iterator cell = local_cells[ic];
std::vector<std::vector<double> > local_phis (n_group,
std::vector<double> (n_q));
unsigned int material_id = cell->material_id ();
if (is_material_fissile[material_id])
{
fv->reinit (cell);
for (unsigned int g=0; g<n_group; ++g)
fv->get_function_values (phis_this_process[g],
local_phis[g]);
for (unsigned int qi=0; qi<n_q; ++qi)
for (unsigned int g=0; g<n_group; ++g)
fiss_source += (all_nusigf[material_id][g] *
local_phis[g][qi] *
fv->JxW(qi));
}
}
double global_fiss_source = Utilities::MPI::sum (fiss_source, mpi_communicator);
return global_fiss_source;
}

template <int dim>
double TransportBase<dim>::estimate_k (double &fiss_source,
double &fiss_source_prev_gen,
Expand Down Expand Up @@ -768,7 +741,6 @@ void TransportBase<dim>::run ()
ref_bd_cells,
is_cell_at_bd,
is_cell_at_ref_bd);
//msh_ptr.reset ();
setup_system ();
report_system ();
assemble_ho_system ();
Expand Down
133 changes: 15 additions & 118 deletions src/iteration/iteration_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -203,23 +203,23 @@ void TransportBase<dim>::initialize_system_matrices_vectors ()
{
if (do_nda)
{
vec_lo_sys.push_back (new LA::MPI::SparseMatrix);
vec_lo_rhs.push_back (new LA::MPI::Vector);
vec_lo_sflx.push_back (new LA::MPI::Vector);
vec_lo_sflx_old.push_back (new LA::MPI::Vector);
vec_lo_fixed_rhs.push_back (new LA::MPI::Vector);
vec_lo_sys.push_back (new PETScWrappers::MPI::SparseMatrix);
vec_lo_rhs.push_back (new PETScWrappers::MPI::Vector);
vec_lo_sflx.push_back (new PETScWrappers::MPI::Vector);
vec_lo_sflx_old.push_back (new PETScWrappers::MPI::Vector);
vec_lo_fixed_rhs.push_back (new PETScWrappers::MPI::Vector);
}

vec_ho_sflx.push_back (new LA::MPI::Vector);
vec_ho_sflx_prev_gen.push_back (new LA::MPI::Vector);
vec_ho_sflx_old.push_back (new LA::MPI::Vector);
vec_ho_sflx.push_back (new PETScWrappers::MPI::Vector);
vec_ho_sflx_prev_gen.push_back (new PETScWrappers::MPI::Vector);
vec_ho_sflx_old.push_back (new PETScWrappers::MPI::Vector);

for (unsigned int i_dir=0; i_dir<n_dir; ++i_dir)
{
vec_ho_sys.push_back (new LA::MPI::SparseMatrix);
vec_aflx.push_back (new LA::MPI::Vector);
vec_ho_rhs.push_back (new LA::MPI::Vector);
vec_ho_fixed_rhs.push_back (new LA::MPI::Vector);
vec_ho_sys.push_back (new PETScWrappers::MPI::SparseMatrix);
vec_aflx.push_back (new PETScWrappers::MPI::Vector);
vec_ho_rhs.push_back (new PETScWrappers::MPI::Vector);
vec_ho_fixed_rhs.push_back (new PETScWrappers::MPI::Vector);
}
}

Expand Down Expand Up @@ -660,17 +660,6 @@ void TransportBase<dim>::source_iteration ()
}
}

template <int dim>
void TransportBase<dim>::renormalize_sflx
(std::vector<LA::MPI::Vector*> &target_sflxes)
{
AssertThrow (target_sflxes.size()==n_group,
ExcMessage("vector of scalar fluxes must have a size of n_group"));
double norm_factor = target_sflxes[0]->max ();
for (unsigned int g=0; g<n_group; ++g)
*target_sflxes[g] /= norm_factor;
}

template <int dim>
void TransportBase<dim>::postprocess ()
{// do nothing in the base class
Expand Down Expand Up @@ -713,15 +702,15 @@ double TransportBase<dim>::estimate_k (double &fiss_source,

template <int dim>
double TransportBase<dim>::estimate_phi_diff
(std::vector<LA::MPI::Vector*> &phis_newer,
std::vector<LA::MPI::Vector*> &phis_older)
(std::vector<PETScWrappers::MPI::Vector*> &phis_newer,
std::vector<PETScWrappers::MPI::Vector*> &phis_older)
{
AssertThrow (phis_newer.size ()== phis_older.size (),
ExcMessage ("n_groups for different phis should be identical"));
double err = 0.0;
for (unsigned int i=0; i<phis_newer.size (); ++i)
{
LA::MPI::Vector dif = *(phis_newer)[i];
PETScWrappers::MPI::Vector dif = *(phis_newer)[i];
dif -= *(phis_older)[i];
err = std::max (err, dif.l1_norm () / phis_newer[i]->l1_norm ());
}
Expand Down Expand Up @@ -756,98 +745,6 @@ void TransportBase<dim>::do_iterations ()
}
}

template <int dim>
void TransportBase<dim>::output_results () const
{
std::string sec_name = "Graphical output";
DataOut<dim> data_out;
data_out.attach_dof_handler (dof_handler);

for (unsigned int g=0; g<n_group; ++g)
{
std::ostringstream os;
os << "ho_phi_g_" << g;
data_out.add_data_vector (sflx_proc[g], os.str ());
}

Vector<float> subdomain (triangulation.n_active_cells ());
for (unsigned int i=0; i<subdomain.size(); ++i)
subdomain(i) = triangulation.locally_owned_subdomain ();
data_out.add_data_vector (subdomain, "subdomain");

data_out.build_patches ();

const std::string filename =
(namebase + "-" + discretization + "-" + Utilities::int_to_string
(triangulation.locally_owned_subdomain (), 4));
std::ofstream output ((filename + ".vtu").c_str ());
data_out.write_vtu (output);

if (Utilities::MPI::this_mpi_process(mpi_communicator) == 0)
{
std::vector<std::string> filenames;
for (unsigned int i=0;
i<Utilities::MPI::n_mpi_processes(mpi_communicator);
++i)
filenames.push_back (namebase + "-" + discretization + "-" +
Utilities::int_to_string (i, 4) + ".vtu");
std::ostringstream os;
os << namebase << "-" << discretization << "-" << global_refinements << ".pvtu";
std::ofstream master_output ((os.str()).c_str ());
data_out.write_pvtu_record (master_output, filenames);
}
}

template <int dim>
void TransportBase<dim>::run ()
{
radio ("making grid");
msh_ptr->make_grid (triangulation);
msh_ptr->get_relevant_cell_iterators (dof_handler,
local_cells,
ref_bd_cells,
is_cell_at_bd,
is_cell_at_ref_bd);
//msh_ptr.reset ();
setup_system ();
report_system ();
assemble_ho_system ();
do_iterations ();
output_results();
}

// wrapper functions used to retrieve info from various Hash tables
template <int dim>
unsigned int TransportBase<dim>::get_component_index
(unsigned int incident_angle_index, unsigned int g)
{
// retrieve component indecis given direction and group
// must be used after initializing the index map
return component_index[std::make_pair (incident_angle_index, g)];
}

template <int dim>
unsigned int TransportBase<dim>::get_component_direction (unsigned int comp_ind)
{
return inverse_component_index[comp_ind].first;
}

template <int dim>
unsigned int TransportBase<dim>::get_component_group (unsigned int comp_ind)
{
return inverse_component_index[comp_ind].second;
}

template <int dim>
unsigned int TransportBase<dim>::get_reflective_direction_index
(unsigned int boundary_id, unsigned int incident_angle_index)
{
AssertThrow (is_reflective_bc[boundary_id],
ExcMessage ("must be reflective boundary to retrieve the reflective boundary"));
return reflective_direction_index[std::make_pair (boundary_id,
incident_angle_index)];
}

//functions used to cout information for diagonose or just simply cout
template <int dim>
void TransportBase<dim>::radio (std::string str)
Expand Down
4 changes: 2 additions & 2 deletions src/transport/even_parity.cc
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,8 @@ void EvenParity<dim>::generate_ho_fixed_source ()
this->vec_ho_fixed_rhs[k]->compress (VectorOperation::add);
}// first direction per group
else
*(this->vec_ho_fixed_rhs[k]) =
*(this->vec_ho_fixed_rhs[this->get_component_index(0, g)]);
*vec_ho_fixed_rhs[k] =
*vec_ho_fixed_rhs[this->get_component_index(0, g)];
}
}

Expand Down
Loading

0 comments on commit aed7808

Please sign in to comment.