18 #include <deal.II/base/utilities.h>
19 #include <deal.II/base/quadrature_lib.h>
20 #include <deal.II/base/function.h>
21 #include <deal.II/base/logstream.h>
22 #include <deal.II/lac/vector.h>
23 #include <deal.II/lac/full_matrix.h>
24 #include <deal.II/lac/dynamic_sparsity_pattern.h>
25 #include <deal.II/lac/sparse_matrix.h>
26 #include <deal.II/lac/solver_cg.h>
27 #include <deal.II/lac/solver_bicgstab.h>
28 #include <deal.II/lac/solver_gmres.h>
29 #include <deal.II/lac/precondition.h>
30 #include <deal.II/lac/constraint_matrix.h>
31 #include <deal.II/grid/tria.h>
32 #include <deal.II/grid/grid_generator.h>
33 #include <deal.II/grid/grid_refinement.h>
34 #include <deal.II/grid/tria_accessor.h>
35 #include <deal.II/grid/tria_iterator.h>
36 #include <deal.II/dofs/dof_handler.h>
37 #include <deal.II/dofs/dof_renumbering.h>
38 #include <deal.II/dofs/dof_accessor.h>
39 #include <deal.II/dofs/dof_tools.h>
40 #include <deal.II/fe/fe_q.h>
41 #include <deal.II/fe/fe_system.h>
42 #include <deal.II/fe/fe_values.h>
43 #include <deal.II/numerics/vector_tools.h>
44 #include <deal.II/numerics/matrix_tools.h>
45 #include <deal.II/numerics/solution_transfer.h>
46 #include <deal.II/numerics/error_estimator.h>
47 #include <deal.II/numerics/fe_field_function.h>
48 #include <deal.II/base/table_handler.h>
54 #include <deal.II/grid/manifold_lib.h>
55 #include <deal.II/grid/tria_boundary_lib.h>
56 #include <deal.II/base/parsed_function.h>
57 #include <deal.II/lac/sparse_direct.h>
68 using namespace dealii;
77 void init(std::string file_path);
78 void run(
const std::string parameter_file =
"");
86 void assemble_system();
88 void interpolate_boundary_values(
89 Function<dim>*
function,
90 std::map<types::global_dof_index, double> &boundary_values)
const;
92 void apply_boundary_values_and_constraints();
94 void solve_linear_system();
98 bool solve_nonlinear_problem();
100 void set_time_step_size(
double new_size);
104 void write_solution();
108 FESystem<dim,dim>
fe;
160 void append_verification_table();
162 void write_verification_table();
166 std::string verification_table_file_name =
"verification_table.txt";
176 velocity_extractor(0),
177 pressure_extractor(dim),
178 temperature_extractor(dim + 1),
179 dof_handler(this->triangulation),
180 source_function(dim + 2),
181 initial_values_function(dim + 2),
182 boundary_function(dim + 2),
183 exact_solution_function(dim + 2)
202 if (this->params.verification.enabled)
204 std::remove(this->verification_table_file_name.c_str());
215 this->params = Parameters::read<dim>(
217 this->source_function,
218 this->initial_values_function,
219 this->boundary_function,
220 this->exact_solution_function);
225 this->manifold_descriptors,
226 this->boundary_count,
227 this->params.geometry.grid_name,
228 params.geometry.sizes);
235 SphericalManifold<dim> spherical_manifold;
237 for (
unsigned int i = 0; i < this->manifold_ids.size(); i++)
239 if (this->manifold_descriptors[i] ==
"spherical")
241 this->triangulation.set_manifold(this->manifold_ids[i], spherical_manifold);
247 this->triangulation.refine_global(this->params.refinement.initial_global_cycles);
251 this->setup_system();
255 this->set_time_step_size(this->params.time.initial_step_size);
257 this->time_step_counter = 0;
259 VectorTools::interpolate(
261 this->initial_values_function,
264 this->write_solution();
266 for (this->time_step_counter = 1; this->time_step_counter < this->params.time.max_steps; ++this->time_step_counter)
268 if (this->time > (this->params.time.end*(1. -
EPSILON) -
EPSILON))
275 this->write_solution();
277 if (this->params.verification.enabled)
279 this->append_verification_table();
282 if (this->params.time.stop_when_steady)
284 Vector<double> time_residual = this->solution;
285 time_residual -= this->old_solution;
287 double unsteadiness = time_residual.l2_norm()/this->solution.l2_norm();
289 std::cout <<
"Unsteadiness, || w_{n+1} - w_n || / || w_{n+1} || = " << unsteadiness << std::endl;
291 if (unsteadiness < this->params.time.steady_tolerance)
293 std::cout <<
"Reached steady state." << std::endl;
306 this->triangulation.set_manifold(0);
ConstraintMatrix constraints
Definition: phaseflow.h:118
std::vector< unsigned int > manifold_ids
Definition: phaseflow.h:147
const FEValuesExtractors::Scalar temperature_extractor
Definition: phaseflow.h:114
DoFHandler< dim > dof_handler
Definition: phaseflow.h:116
Parameters::StructuredParameters params
Definition: phaseflow.h:76
TableHandler verification_table
Definition: phaseflow.h:164
double new_time
Definition: phaseflow.h:138
Vector< double > solution
Definition: phaseflow.h:124
const unsigned int SCALAR_DEGREE
Definition: pf_global_parameters.h:22
unsigned int boundary_count
Definition: phaseflow.h:144
Functions::ParsedFunction< dim > boundary_function
Definition: phaseflow.h:156
const double EPSILON
Definition: pf_global_parameters.h:24
double time
Definition: phaseflow.h:136
const FEValuesExtractors::Scalar pressure_extractor
Definition: phaseflow.h:112
void create_coarse_grid(Triangulation< dim > &triangulation, std::vector< unsigned int > &manifold_ids, std::vector< std::string > &manifold_descriptors, unsigned int &boundary_count, const std::string grid_name, const std::vector< double > sizes)
Definition: my_grid_generator.h:17
Vector< double > system_rhs
Definition: phaseflow.h:134
Vector< double > old_solution
Definition: phaseflow.h:130
Phaseflow()
Definition: phaseflow.h:171
Vector< double > newton_solution
Definition: phaseflow.h:128
std::vector< std::string > manifold_descriptors
Definition: phaseflow.h:150
Functions::ParsedFunction< dim > source_function
Definition: phaseflow.h:152
Vector< double > newton_residual
Definition: phaseflow.h:126
double time_step_size
Definition: phaseflow.h:140
const FEValuesExtractors::Vector velocity_extractor
Definition: phaseflow.h:110
Definition: pf_parameters.h:119
SparsityPattern sparsity_pattern
Definition: phaseflow.h:120
FESystem< dim, dim > fe
Definition: phaseflow.h:108
Triangulation< dim > triangulation
Definition: phaseflow.h:106
SparseMatrix< double > system_matrix
Definition: phaseflow.h:122
unsigned int time_step_counter
Definition: phaseflow.h:142
Functions::ParsedFunction< dim > exact_solution_function
Definition: phaseflow.h:158
Vector< double > old_newton_solution
Definition: phaseflow.h:132
Functions::ParsedFunction< dim > initial_values_function
Definition: phaseflow.h:154
Definition: phaseflow.h:71