Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean driver. #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ SET(_main source/main.cc)
# Normally you shouldn't need to change anything below.
############################################################
# Declare all source files the target consists of:
file(GLOB _files source/*cc)
file(GLOB _files source/*cc include/*h)

# Don't compile the main file into the library
IF(NOT "${_main}" STREQUAL "")
Expand Down
14 changes: 0 additions & 14 deletions docker/debug-release/Dockerfile

This file was deleted.

14 changes: 0 additions & 14 deletions docker/debug/Dockerfile

This file was deleted.

14 changes: 0 additions & 14 deletions docker/release/Dockerfile

This file was deleted.

102 changes: 25 additions & 77 deletions include/driver.h
Original file line number Diff line number Diff line change
@@ -1,117 +1,65 @@
#ifndef driver_h
#define driver_h

#include<deal.II/base/smartpointer.h>
#include<deal.II/base/convergence_table.h>
#include<deal.II/base/quadrature_lib.h>
#include<deal.II/base/quadrature_selector.h>
#include<deal.II/base/parsed_function.h>
#include<deal.II/base/utilities.h>
#include <deal.II/base/utilities.h>
#include <deal.II/base/conditional_ostream.h>

#include<deal.II/lac/full_matrix.h>
#include<deal.II/lac/sparse_matrix.h>
#include<deal.II/lac/matrix_lib.h>
#include<deal.II/lac/vector.h>
#include<deal.II/lac/solver_control.h>
#include<deal.II/lac/solver_gmres.h>
#include<deal.II/lac/precondition.h>
//
//#include <deal.II/lac/trilinos_vector.h>
//#include <deal.II/lac/trilinos_vector.h>
//#include <deal.II/lac/trilinos_sparse_matrix.h>
//#include <deal.II/lac/trilinos_solver.h>
//#include <deal.II/lac/trilinos_precondition.h>
//
//#include <deal.II/lac/petsc_vector.h>
//#include <deal.II/lac/petsc_parallel_vector.h>
//#include <deal.II/lac/petsc_parallel_sparse_matrix.h>
//#include <deal.II/lac/petsc_solver.h>
//#include <deal.II/lac/petsc_precondition.h>

#include<deal.II/grid/tria.h>
#include<deal.II/grid/tria_iterator.h>
#include<deal.II/grid/tria_accessor.h>
#include<deal.II/grid/grid_generator.h>
#include<deal.II/grid/grid_in.h>
#include<deal.II/grid/grid_out.h>
#include<deal.II/grid/tria_boundary_lib.h>

#include<deal.II/dofs/dof_handler.h>
#include<deal.II/dofs/dof_accessor.h>
#include<deal.II/dofs/dof_tools.h>
#include<deal.II/dofs/dof_renumbering.h>
#include<deal.II/fe/fe_q.h>
#include<deal.II/fe/fe_values.h>
#include<deal.II/fe/fe_system.h>
#include<deal.II/fe/mapping_q1_eulerian.h>
#include<deal.II/fe/mapping_q1.h>

#include<deal.II/numerics/data_out.h>
#include<deal.II/numerics/vector_tools.h>
#include<deal.II/numerics/solution_transfer.h>

// And here are a few C++ standard header
// files that we will need:
#include <cmath>
#include <iostream>
#include <fstream>
#include <string>
#include <set>

#include "bem_problem.h"
#include "bem_fma.h"
#include "boundary_conditions.h"
#include "computational_domain.h"

#include <deal2lkit/parameter_acceptor.h>
#include <deal2lkit/utilities.h>
using namespace dealii;

//using namespace TrilinosWrappers::MPI::Vector;
//using namespace TrilinosWrappers::MPI::SparseMatrix;

/**
* This class is in charge of organising the overall BEM simulation. It has interfaces with all the other classes in order to have a complete simulation.
*/
* This class is in charge of organising the overall BEM simulation,
* while timing the various phases. It has interfaces with all the
* other classes in order to have a complete simulation.
*/
template <int dim>
class Driver : public ParameterAcceptor
{
public:

/**
* Initialize variables and setup parameters.
*/
Driver();

~Driver();

/// method to declare the parameters
/// to be read from the parameters file

virtual void declare_parameters(ParameterHandler &prm);

/// method to parse the needed parameters
/// from the parameters file

virtual void parse_parameters(ParameterHandler &prm);


/**
* Sets up BEMProblem and ComputationalDomain, then solve BEM.
*/
void run();

private:

/// Monitor output only on first processor.
ConditionalOStream pcout;

/// Mpi communicator object.
MPI_Comm mpi_communicator;

/// Domain related object.
ComputationalDomain<dim> computational_domain;

/// The actual bem solver.
BEMProblem<dim> bem_problem;

/// Boundary conditions.
BoundaryConditions<dim> boundary_conditions;

ParameterHandler prm;

/// Flag to use global refinement.
bool global_refinement;

/// Total number of processors
const unsigned int n_mpi_processes;

/// The id of this processor.
const unsigned int this_mpi_process;

/// Time monitor object.
TimeMonitor timer;
};

#endif
6 changes: 3 additions & 3 deletions source/bem_fma.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2774,7 +2774,7 @@ void BEMFMA<dim>::compute_geometry_cache()


FESystem<dim-1,dim> gradient_fe(*fma_fe, dim);
DoFHandler<dim-1, dim> gradient_dh(fma_dh->get_tria());
DoFHandler<dim-1, dim> gradient_dh(fma_dh->get_triangulation());

//double tol = 1e-8;
std::vector<Point<dim> > support_points(fma_dh->n_dofs());
Expand Down Expand Up @@ -2827,7 +2827,7 @@ void BEMFMA<dim>::compute_geometry_cache()



for (; cell!=endc,gradient_cell!=gradient_endc; ++cell,++gradient_cell)
for (; cell!=endc; ++cell,++gradient_cell)
{
Assert(cell->index() == gradient_cell->index(), ExcInternalError());

Expand Down Expand Up @@ -2997,7 +2997,7 @@ void BEMFMA<dim>::generate_octree_blocking()
delete blocks[ii];
}

types::global_dof_index maxNumBlocks = num_octree_levels*fma_dh->get_tria().n_active_cells()*fe_v.n_quadrature_points;
types::global_dof_index maxNumBlocks = num_octree_levels*fma_dh->get_triangulation().n_active_cells()*fe_v.n_quadrature_points;
//unsigned int maxNumBlocks = 0;
//for (unsigned int ii = 0; ii < num_octree_levels + 1; ii++)
// {
Expand Down
83 changes: 9 additions & 74 deletions source/driver.cc
Original file line number Diff line number Diff line change
@@ -1,17 +1,4 @@
#include "../include/driver.h"
#include <sys/time.h>


#include "Teuchos_TimeMonitor.hpp"

using Teuchos::Time;
using Teuchos::TimeMonitor;
using Teuchos::RCP;

RCP<Time> TotalTime = Teuchos::TimeMonitor::getNewTimer("Total Time");
RCP<Time> MeshTime = Teuchos::TimeMonitor::getNewTimer("Mesh Time");
RCP<Time> OutputTime = Teuchos::TimeMonitor::getNewTimer("Output Time");
RCP<Time> SolveTime = Teuchos::TimeMonitor::getNewTimer("Solve Time");

using namespace std;

Expand All @@ -22,80 +9,29 @@ Driver<dim>::Driver() :
computational_domain(mpi_communicator),
bem_problem(computational_domain,mpi_communicator),
boundary_conditions(computational_domain, bem_problem),
prm(),
global_refinement(true),
n_mpi_processes (Utilities::MPI::n_mpi_processes(mpi_communicator)),
this_mpi_process (Utilities::MPI::this_mpi_process(mpi_communicator))
{
pcout.set_condition(this_mpi_process == 0);
//PathSearch search_prm("PARAMETER");

// Declare the parameter entries..
// DeclareParameters();
//
// deallog.depth_console(this_mpi_process == 0 ? 3 : 0);
//
// vector<string> args;
// for (int i=0; i<argc; ++i)
// args.push_back (argv[i]);
//
// string default_prm;
// // The default parameter file is the name of the application plus prm
// default_prm = args[0] + ".prm";
//
// prm.read_input(default_prm, false, true);
//
// for (int i=1; i<argc; ++i)
// prm.read_input(args[i], true);
//
// // Now that we have the final version of the parameters, parse them.
// ParseParameters();
//
// // And write the used ones.
// default_prm = args.front() + "_used.prm";
// ofstream outprm(default_prm.c_str());
// prm.print_parameters(outprm, ParameterHandler::ShortText);
}

template <int dim>
Driver<dim>::~Driver()
{}


template <int dim>
void Driver<dim>::declare_parameters (ParameterHandler &prm)
{
prm.declare_entry("Set Global Refinement", "true",
Patterns::Bool());


}

template <int dim>
void Driver<dim>::parse_parameters (ParameterHandler &prm)
{
global_refinement = prm.get_bool("Set Global Refinement");


add_parameter(global_refinement, "Set Global Refinement");
}


template <int dim>
void Driver<dim>::run()
{
{
Teuchos::TimeMonitor LocalTimer(*TotalTime);
auto t_ = timer.scoped_timer("Total Time");
unsigned int local_refinement_cycles = 0;
{
// Teuchos::TimeMonitor LocalTimer(*MeshTime);
//computational_domain.create_initial_mesh();
auto t_ = timer.scoped_timer("Mesh Time");
computational_domain.read_domain();
if (global_refinement)
{
computational_domain.refine_and_resize(computational_domain.n_cycles);
}
else
{
// computational_domain.conditional_refine_and_resize(1);
computational_domain.refine_and_resize(1);
local_refinement_cycles=computational_domain.n_cycles;
}
Expand All @@ -105,7 +41,7 @@ void Driver<dim>::run()
for (unsigned int i = 0; i<=local_refinement_cycles; ++i)
{
{
Teuchos::TimeMonitor LocalTimer(*SolveTime);
auto t_ = timer.scoped_timer("Solve Time");
bem_problem.reinit();
boundary_conditions.solve_problem();
}
Expand All @@ -120,12 +56,11 @@ void Driver<dim>::run()

std::string filename = ( boundary_conditions.output_file_name);
boundary_conditions.compute_errors();
boundary_conditions.output_results(filename);
// }
{
auto t_ = timer.scoped_timer("Output Time");
boundary_conditions.output_results(filename);
}
}
// Write a summary of all timers
Teuchos::TimeMonitor::summarize();
}


template class Driver<3>;