+++ /dev/null
-#ifndef dealii__cdr_assemble_system_h
-#define dealii__cdr_assemble_system_h
-#include <deal.II/base/quadrature_lib.h>
-#include <deal.II/base/function_parser.h>
-
-#include <deal.II/dofs/dof_handler.h>
-
-#include <deal.II/fe/fe_q.h>
-
-#include <deal.II/lac/constraint_matrix.h>
-
-#include <functional>
-
-#include <deal.II-cdr/parameters.h>
-
-namespace CDR
-{
- using namespace dealii;
-
- template<int dim, typename MatrixType, typename VectorType>
- void assemble_system
- (const DoFHandler<dim> &dof_handler,
- const QGauss<dim> &quad,
- const std::function<Tensor<1, dim>(const Point<dim>)> convection_function,
- const std::function<double(double, const Point<dim>)> forcing_function,
- const CDR::Parameters ¶meters,
- const VectorType ¤t_solution,
- const ConstraintMatrix &constraints,
- const double current_time,
- MatrixType &system_matrix,
- VectorType &system_rhs);
-}
-#endif
+++ /dev/null
-#ifndef dealii__cdr_assemble_system_templates_h
-#define dealii__cdr_assemble_system_templates_h
-#include <deal.II/fe/fe_values.h>
-
-#include <deal.II/lac/vector.h>
-
-#include <vector>
-
-#include <deal.II-cdr/assemble_system.h>
-
-namespace CDR
-{
- using namespace dealii;
-
- template<int dim, typename MatrixType, typename VectorType>
- void assemble_system
- (const DoFHandler<dim> &dof_handler,
- const QGauss<dim> &quad,
- const std::function<Tensor<1, dim>(const Point<dim>)> convection_function,
- const std::function<double(double, const Point<dim>)> forcing_function,
- const CDR::Parameters ¶meters,
- const VectorType ¤t_solution,
- const ConstraintMatrix &constraints,
- const double current_time,
- MatrixType &system_matrix,
- VectorType &system_rhs)
- {
- auto &fe = dof_handler.get_fe();
- const auto dofs_per_cell = fe.dofs_per_cell;
- const double time_step = (parameters.stop_time - parameters.start_time)
- /parameters.n_time_steps;
- FEValues<dim> fe_values(fe, quad, update_values | update_gradients |
- update_quadrature_points | update_JxW_values);
-
- Vector<double> cell_rhs(dofs_per_cell);
- FullMatrix<double> cell_matrix(dofs_per_cell, dofs_per_cell);
-
- Vector<double> current_fe_coefficients(dofs_per_cell);
- std::vector<types::global_dof_index> local_indices(dofs_per_cell);
-
- auto previous_time = current_time - time_step;
-
- for (const auto &cell : dof_handler.active_cell_iterators())
- {
- if (cell->is_locally_owned())
- {
- fe_values.reinit(cell);
- cell_rhs = 0.0;
- cell_matrix = 0.0;
- cell->get_dof_indices(local_indices);
- for (unsigned int i = 0; i < dofs_per_cell; ++i)
- {
- current_fe_coefficients[i] = current_solution[local_indices[i]];
- }
-
- for (unsigned int q = 0; q < quad.size(); ++q)
- {
- const auto current_convection =
- convection_function(fe_values.quadrature_point(q));
- const auto current_forcing =
- forcing_function(current_time, fe_values.quadrature_point(q));
- const auto previous_forcing =
- forcing_function(previous_time, fe_values.quadrature_point(q));
-
- for (unsigned int i = 0; i < dofs_per_cell; ++i)
- {
- for (unsigned int j = 0; j < dofs_per_cell; ++j)
- {
- const auto convection_contribution = current_convection
- *fe_values.shape_grad(j, q);
-
- const double mass_part
- {fe_values.shape_value(i, q)*fe_values.shape_value(j, q)};
- const double system_part
- {time_step/2.0*
- // convection part
- (fe_values.shape_value(i, q)*convection_contribution
- // diffusion part
- + parameters.diffusion_coefficient
- *fe_values.shape_grad(i, q)*fe_values.shape_grad(j, q)
- // reaction part
- + parameters.reaction_coefficient*mass_part)};
- cell_rhs(i) += fe_values.JxW(q)
- *((mass_part - system_part)*current_fe_coefficients[j]
- + time_step/2.0*fe_values.shape_value(i, q)
- *(current_forcing + previous_forcing));
- cell_matrix(i, j) +=
- fe_values.JxW(q)*(mass_part + system_part);
- }
- }
- }
- constraints.distribute_local_to_global
- (cell_matrix, cell_rhs, local_indices, system_matrix, system_rhs, true);
- }
- }
- }
-}
-#endif
+++ /dev/null
-#ifndef dealii__cdr_write_xmdf_output_h
-#define dealii__cdr_write_xmdf_output_h
-#include <deal.II/base/data_out_base.h>
-
-#include <deal.II/dofs/dof_handler.h>
-
-#include <deal.II/lac/vector.h>
-
-#include <deal.II/numerics/data_component_interpretation.h>
-
-#include <string>
-#include <vector>
-
-
-namespace CDR
-{
- using namespace dealii;
-
- class WriteXDMFOutput
- {
- public:
- WriteXDMFOutput(const unsigned int patch_level,
- const bool update_mesh_at_each_step = true);
-
- template<int dim, typename VectorType>
- void write_output(const DoFHandler<dim> &dof_handler,
- const VectorType &solution,
- const unsigned int time_step_n,
- const double current_time);
- private:
- const unsigned int patch_level;
- const bool update_mesh_at_each_step;
- const std::string xdmf_file_name;
- const std::vector<DataComponentInterpretation::DataComponentInterpretation>
- data_component_interpretation;
- std::vector<XDMFEntry> xdmf_entries;
- bool write_mesh;
- };
-}
-#endif
+++ /dev/null
-#ifndef dealii__cdr_write_xmdf_output_templates_h
-#define dealii__cdr_write_xmdf_output_templates_h
-#include <deal.II/base/utilities.h>
-
-#include <deal.II/numerics/data_out.h>
-
-#include <deal.II-cdr/write_xdmf_output.h>
-
-namespace CDR
-{
- template<int dim, typename VectorType>
- void WriteXDMFOutput::write_output(const DoFHandler<dim> &dof_handler,
- const VectorType &solution,
- const unsigned int time_step_n,
- const double current_time)
- {
- DataOut<dim> data_out;
- data_out.attach_dof_handler(dof_handler);
- data_out.add_data_vector(solution, "u", DataOut<dim>::type_dof_data,
- data_component_interpretation);
- data_out.build_patches(patch_level);
-
- auto solution_file_name = "solution-"
- + Utilities::int_to_string(time_step_n, 9) + ".h5";
- std::string mesh_file_name;
- if (update_mesh_at_each_step)
- {
- mesh_file_name = "mesh-"
- + Utilities::int_to_string(time_step_n, 9) + ".h5";
- }
- else
- {
- mesh_file_name = "mesh.h5";
- }
-
- DataOutBase::DataOutFilter data_filter
- (DataOutBase::DataOutFilterFlags(true, true));
- data_out.write_filtered_data(data_filter);
- data_out.write_hdf5_parallel(data_filter, write_mesh, mesh_file_name,
- solution_file_name, MPI_COMM_WORLD);
- if (!update_mesh_at_each_step)
- {
- write_mesh = false;
- }
-
- xdmf_entries.push_back(data_out.create_xdmf_entry
- (data_filter, mesh_file_name, solution_file_name,
- current_time, MPI_COMM_WORLD));
- data_out.write_xdmf_file(xdmf_entries, xdmf_file_name, MPI_COMM_WORLD);
- }
-}
-#endif
+++ /dev/null
-#include <deal.II/lac/trilinos_sparse_matrix.h>
-#include <deal.II/lac/trilinos_vector.h>
-
-#include <deal.II/lac/sparse_matrix.h>
-
-#include <deal.II-cdr/assemble_system.templates.h>
-
-namespace CDR
-{
- using namespace dealii;
-
- template
- void assemble_system<2, SparseMatrix<double>, Vector<double>>
- (const DoFHandler<2> &dof_handler,
- const QGauss<2> &quad,
- const std::function<Tensor<1, 2>(const Point<2>)> convection_function,
- const std::function<double(double, const Point<2>)> forcing_function,
- const CDR::Parameters ¶meters,
- const Vector<double> ¤t_solution,
- const ConstraintMatrix &constraints,
- const double current_time,
- SparseMatrix<double> &system_matrix,
- Vector<double> &system_rhs);
-
- template
- void assemble_system<3, SparseMatrix<double>, Vector<double>>
- (const DoFHandler<3> &dof_handler,
- const QGauss<3> &quad,
- const std::function<Tensor<1, 3>(const Point<3>)> convection_function,
- const std::function<double(double, const Point<3>)> forcing_function,
- const CDR::Parameters ¶meters,
- const Vector<double> ¤t_solution,
- const ConstraintMatrix &constraints,
- const double current_time,
- SparseMatrix<double> &system_matrix,
- Vector<double> &system_rhs);
-
- template
- void assemble_system<2, TrilinosWrappers::SparseMatrix,
- TrilinosWrappers::MPI::Vector>
- (const DoFHandler<2> &dof_handler,
- const QGauss<2> &quad,
- const std::function<Tensor<1, 2>(const Point<2>)> convection_function,
- const std::function<double(double, const Point<2>)> forcing_function,
- const CDR::Parameters ¶meters,
- const TrilinosWrappers::MPI::Vector ¤t_solution,
- const ConstraintMatrix &constraints,
- const double current_time,
- TrilinosWrappers::SparseMatrix &system_matrix,
- TrilinosWrappers::MPI::Vector &system_rhs);
-
- template
- void assemble_system<3, TrilinosWrappers::SparseMatrix,
- TrilinosWrappers::MPI::Vector>
- (const DoFHandler<3> &dof_handler,
- const QGauss<3> &quad,
- const std::function<Tensor<1, 3>(const Point<3>)> convection_function,
- const std::function<double(double, const Point<3>)> forcing_function,
- const CDR::Parameters ¶meters,
- const TrilinosWrappers::MPI::Vector ¤t_solution,
- const ConstraintMatrix &constraints,
- const double current_time,
- TrilinosWrappers::SparseMatrix &system_matrix,
- TrilinosWrappers::MPI::Vector &system_rhs);
-}
+++ /dev/null
-#include <deal.II/lac/trilinos_vector.h>
-
-#include <deal.II-cdr/write_xdmf_output.templates.h>
-
-namespace CDR
-{
- using namespace dealii;
-
- WriteXDMFOutput::WriteXDMFOutput(const unsigned int patch_level,
- const bool update_mesh_at_each_step)
- : patch_level {patch_level},
- update_mesh_at_each_step {update_mesh_at_each_step},
- xdmf_file_name {"solution.xdmf"},
- data_component_interpretation
- {DataComponentInterpretation::component_is_scalar},
- write_mesh {true}
- {}
-
- template
- void WriteXDMFOutput::write_output(const DoFHandler<2> &dof_handler,
- const Vector<double> &solution,
- const unsigned int time_step_n,
- const double current_time);
-
- template
- void WriteXDMFOutput::write_output(const DoFHandler<2> &dof_handler,
- const TrilinosWrappers::MPI::Vector &solution,
- const unsigned int time_step_n,
- const double current_time);
-
- template
- void WriteXDMFOutput::write_output(const DoFHandler<3> &dof_handler,
- const Vector<double> &solution,
- const unsigned int time_step_n,
- const double current_time);
-
- template
- void WriteXDMFOutput::write_output(const DoFHandler<3> &dof_handler,
- const TrilinosWrappers::MPI::Vector &solution,
- const unsigned int time_step_n,
- const double current_time);
-}