380 * #include <deal.II/base/utilities.h>
381 * #include <deal.II/base/quadrature_lib.h>
382 * #include <deal.II/base/function.h>
383 * #include <deal.II/base/logstream.h>
384 * #include <deal.II/lac/vector.h>
385 * #include <deal.II/lac/full_matrix.h>
386 * #include <deal.II/lac/dynamic_sparsity_pattern.h>
387 * #include <deal.II/lac/sparse_matrix.h>
388 * #include <deal.II/lac/solver_cg.h>
389 * #include <deal.II/lac/precondition.h>
390 * #include <deal.II/lac/affine_constraints.h>
391 * #include <deal.II/grid/tria.h>
392 * #include <deal.II/grid/grid_generator.h>
393 * #include <deal.II/grid/grid_refinement.h>
394 * #include <deal.II/grid/grid_out.h>
395 * #include <deal.II/dofs/dof_handler.h>
396 * #include <deal.II/dofs/dof_tools.h>
397 * #include <deal.II/fe/fe_q.h>
398 * #include <deal.II/fe/fe_system.h>
399 * #include <deal.II/fe/fe_values.h>
400 * #include <deal.II/numerics/data_out.h>
401 * #include <deal.II/numerics/vector_tools.h>
402 * #include <deal.II/numerics/error_estimator.h>
403 * #include <deal.II/numerics/solution_transfer.h>
404 * #include <deal.II/numerics/matrix_tools.h>
405 * #include <deal.II/lac/sparse_direct.h>
406 * #include <deal.II/base/timer.h>
408 * #include <deal.II/grid/manifold_lib.h>
409 * #include <deal.II/grid/grid_tools.h>
411 * #include <
boost/math/special_functions/ellint_1.hpp>
414 * #include <iostream>
417 *
namespace SwiftHohenbergSolver
428 *
enum MeshType {HYPERCUBE, CYLINDER, SPHERE, TORUS, SINUSOID};
437 *
enum InitialConditionType {HOTSPOT, PSUEDORANDOM, RANDOM};
449 *
template<
int spacedim>
454 * Currently
this only works
for a 3-dimensional embedding space
455 * because we are explicitly referencing the x, y, and z coordinates
458 *
Assert(spacedim == 3, ExcNotImplemented());
462 * Returns a
point where the x-coordinate is unchanged but the y and z coordinates are adjusted
463 * by a
cos wave of period 20, amplitude .5, and vertical
shift 1
480 *
template <
int dim,
int spacedim, MeshType MESH, InitialConditionType ICTYPE>
486 * / @brief Default constructor, initializes all variables and objects with
default values
501 * SHEquation(
const unsigned int degree
502 * ,
double time_step_denominator
503 * ,
unsigned int ref_num
504 * ,
double r_constant = 0.5
505 * ,
double g1_constant = 0.5
506 * , std::string output_file_name =
"solution-"
507 * ,
double end_time = 0.5);
511 *
void setup_system();
512 *
void solve_time_step();
513 *
void output_results()
const;
522 *
void make_cylinder();
525 * / @brief Uses the same process as creating a
cylinder, but then also warps the boundary of the
cylinder by the function (1 + 0.5*
cos(pi*x/10))
528 *
void make_sinusoid();
531 * / @brief Generates a spherical mesh of radius 6*pi
using GridGenerator and refines it refinement_number times.
534 *
void make_sphere();
537 * / @brief Generates a
torus mesh with inner radius 4 and outer radius 9
using GridGenerator and refines it refinement_number times.
543 * / @brief Generates a hypercube mesh with sidelenth 12*pi
using GridGenerator and refines it refinement_number times.
546 *
void make_hypercube();
551 * / @brief The degree of finite element to be used,
default 1
554 *
const unsigned int degree;
558 * / @brief Object holding the mesh
568 * / @brief Object which understands which finite elements are at each node
575 * / @brief Describes the sparsity of the system
matrix, allows
for more efficient storage
582 * / @brief Object holding the system
matrix, stored as a sparse
matrix
593 * / @brief Stores the solution from the previous timestep. Used to compute non-linear terms
604 * / @brief Stores the current time, in the units of the problem
610 * / @brief The amount time is increased each iteration/ the denominator of the discretized time derivative
616 * / @brief Counts the number of iterations that have elapsed
619 *
unsigned int timestep_number;
622 * / @brief Used to compute the time_step: time_step = 1/timestep_denominator
625 *
unsigned int timestep_denominator;
628 * / @brief Determines how much to globally
refine each mesh
631 *
unsigned int refinement_number;
635 * / @brief Coefficient of the linear term in the SH equation. This is often taken to be
constant and g_1 allowed to vary
641 * / @brief Coefficient of the quadratic term in the SH equation. Determines whether hexagonal lattices can form
647 * / @brief A control parameter
for the cubic term. Can be useful
for testing, in
this code we let k=1 in all cases
654 * / @brief Name used to create output file. Should not include extension
657 *
const std::string output_file_name;
661 * / @brief Determines when the solver terminates, endtime of ~100 are useful to see equilibrium results
664 *
const double end_time;
673 *
template <
int spacedim>
674 *
class BoundaryValues :
public Function<spacedim>
682 *
const unsigned int component = 0)
const override;
694 *
template <
int spacedim>
696 *
const unsigned int component)
const
717 *
template<
int spacedim, MeshType MESH, InitialConditionType ICTYPE>
718 *
class InitialCondition :
public Function<spacedim>
723 * / @brief The
value of the parameter r, used to determine a bound
for the magnitude of the
initial conditions
729 * / @brief A
center point, used to determine the location of the hot spot
for the HotSpot
initial condition
735 * / @brief Radius of the hot spot
741 * / @brief Stores the randomly generated coefficients
for planar sine waves along the x-axis, used
for psuedorandom
initial conditions
744 *
double x_sin_coefficients[10];
747 * / @brief Stores the randomly generated coefficients
for planar sine waves along the y-axis, used
for psuedorandom
initial conditions
750 *
double y_sin_coefficients[10];
761 *
for(
int i = 0; i < 10; ++i){
772 * InitialCondition(
const double r,
773 *
const double radius)
778 *
for(
int i = 0; i < 10; ++i){
813 *
double InitialCondition<2, HYPERCUBE, HOTSPOT>::value(
815 *
const unsigned int component)
const
817 *
if(component == 0){
818 *
if(p.square() <= radius){
836 *
double InitialCondition<3, CYLINDER, HOTSPOT>::value(
838 *
const unsigned int component)
const
840 *
if(component == 0){
843 *
if(compare.square() <= radius){
861 *
double InitialCondition<3, SPHERE, HOTSPOT>::value(
863 *
const unsigned int component)
const
865 *
if(component == 0){
868 *
if(compare.square() <= radius){
886 *
double InitialCondition<3, TORUS, HOTSPOT>::value(
888 *
const unsigned int component)
const
890 *
if(component == 0){
893 *
if(compare.square() <= radius){
911 *
double InitialCondition<3, SINUSOID, HOTSPOT>::value(
913 *
const unsigned int component)
const
915 *
if(component == 0){
918 *
if(compare.square() <= radius){
936 *
double InitialCondition<2, HYPERCUBE, PSUEDORANDOM>::value(
938 *
const unsigned int component)
const
940 *
if(component == 0){
943 *
for(
int i=0; i < 10; ++i){
944 * x_val += x_sin_coefficients[i]*
std::sin(2*3.141592653*p(0)/((i+1)*1.178097245));
945 * y_val += y_sin_coefficients[i]*
std::sin(2*3.141592653*p(1)/((i+1)*1.178097245));
948 *
return x_val*y_val;
961 *
double InitialCondition<3, CYLINDER, PSUEDORANDOM>::value(
963 *
const unsigned int component)
const
965 *
if(component == 0){
968 *
double width = ((std::atan2(p(1),p(2)) - 3.1415926)/3.1415926)*18.84955592;
969 *
for(
int i=0; i < 10; ++i){
970 * x_val += x_sin_coefficients[i]*
std::sin(2*3.141592653*p(0)/((i+1)*1.178097245));
971 * w_val += y_sin_coefficients[i]*
std::sin(2*3.141592653*width/((i+1)*1.178097245));
974 *
return x_val*w_val;
987 *
double InitialCondition<3, SPHERE, PSUEDORANDOM>::value(
989 *
const unsigned int component)
const
991 *
if(component == 0){
994 *
for(
int i=0; i < 10; ++i){
995 * x_val += x_sin_coefficients[i]*
std::sin(2*3.141592653*p(0)/((i+1)*1.178097245));
996 * y_val += y_sin_coefficients[i]*
std::sin(2*3.141592653*p(1)/((i+1)*1.178097245));
999 *
return x_val*y_val;
1012 *
double InitialCondition<3, TORUS, PSUEDORANDOM>::value(
1014 *
const unsigned int component)
const
1016 *
if(component == 0){
1019 *
for(
int i=0; i < 10; ++i){
1020 * x_val += x_sin_coefficients[i]*
std::sin(2*3.141592653*p(0)/((i+1)*1.178097245));
1021 * z_val += y_sin_coefficients[i]*
std::sin(2*3.141592653*p(2)/((i+1)*1.178097245));
1024 *
return x_val*z_val;
1037 *
double InitialCondition<3, SINUSOID, PSUEDORANDOM>::value(
1039 *
const unsigned int component)
const
1041 *
if(component == 0){
1044 *
double width = ((std::atan2(p(1),p(2)) - 3.1415926)/3.1415926)*18.84955592;
1045 *
for(
int i=0; i < 10; ++i){
1046 * x_val += x_sin_coefficients[i]*
std::sin(2*3.141592653*p(0)/((i+1)*1.178097245));
1047 * w_val += y_sin_coefficients[i]*
std::sin(2*3.141592653*width/((i+1)*1.178097245));
1050 *
return x_val*w_val;
1063 *
double InitialCondition<2, HYPERCUBE, RANDOM>::value(
1065 *
const unsigned int component)
const
1067 *
if(component == 0){
1081 *
double InitialCondition<3, CYLINDER, RANDOM>::value(
1083 *
const unsigned int component)
const
1085 *
if(component == 0){
1099 *
double InitialCondition<3, SPHERE, RANDOM>::value(
1101 *
const unsigned int component)
const
1103 *
if(component == 0){
1117 *
double InitialCondition<3, TORUS, RANDOM>::value(
1119 *
const unsigned int component)
const
1121 *
if(component == 0){
1135 *
double InitialCondition<3, SINUSOID, RANDOM>::value(
1137 *
const unsigned int component)
const
1139 *
if(component == 0){
1147 *
template <
int dim,
int spacedim, MeshType MESH, InitialConditionType ICTYPE>
1148 * SHEquation<dim, spacedim, MESH, ICTYPE>::SHEquation()
1152 * , time_step(1. / 1500)
1153 * , timestep_denominator(1500)
1154 * , refinement_number(4)
1158 * , output_file_name(
"solution-")
1162 *
template <
int dim,
int spacedim, MeshType MESH, InitialConditionType ICTYPE>
1163 * SHEquation<dim, spacedim, MESH, ICTYPE>::SHEquation(
const unsigned int degree,
1164 *
double time_step_denominator,
1165 *
unsigned int ref_num,
1166 *
double r_constant,
1167 *
double g1_constant,
1168 * std::string output_file_name,
1173 * , time_step(1. / time_step_denominator)
1174 * , timestep_denominator(time_step_denominator)
1175 * , refinement_number(ref_num)
1179 * , output_file_name(output_file_name)
1180 * , end_time(end_time)
1190 *
template <
int dim,
int spacedim, MeshType MESH, InitialConditionType ICTYPE>
1191 *
void SHEquation<dim, spacedim, MESH, ICTYPE>::setup_system()
1193 * dof_handler.distribute_dofs(fe);
1197 * Counts the DoF
's for outputting to consolse
1200 * const std::vector<types::global_dof_index> dofs_per_component =
1201 * DoFTools::count_dofs_per_fe_component(dof_handler);
1202 * const unsigned int n_u = dofs_per_component[0],
1203 * n_v = dofs_per_component[1];
1205 * std::cout << "Number of active cells: " << triangulation.n_active_cells()
1207 * << "Total number of cells: " << triangulation.n_cells()
1209 * << "Number of degrees of freedom: " << dof_handler.n_dofs()
1210 * << " (" << n_u << '+
' << n_v << ')
' << std::endl;
1212 * DynamicSparsityPattern dsp(dof_handler.n_dofs());
1214 * DoFTools::make_sparsity_pattern(dof_handler,
1216 * sparsity_pattern.copy_from(dsp);
1218 * system_matrix.reinit(sparsity_pattern);
1220 * solution.reinit(dof_handler.n_dofs());
1221 * old_solution.reinit(dof_handler.n_dofs());
1222 * system_rhs.reinit(dof_handler.n_dofs());
1226 * /** @brief Uses a direct solver to invert the system matrix, then multiplies the RHS vector by the inverted matrix to get the solution.
1227 * * Also includes a timer feature, which is currently commented out, but can be helpful to compute how long a run will take
1228 * * @tparam dim The dimension of the manifold
1229 * * @tparam spacedim The dimension of the ambient space
1230 * * @tparam MESH The type of mesh being used, doesn't change how
this function works
1231 * * @tparam ICTYPE The type of initial condition used, doesn
't change how this function works
1233 * template <int dim, int spacedim, MeshType MESH, InitialConditionType ICTYPE>
1234 * void SHEquation<dim, spacedim, MESH, ICTYPE>::solve_time_step()
1238 * std::cout << "Solving linear system" << std::endl;
1245 * SparseDirectUMFPACK direct_solver;
1247 * direct_solver.initialize(system_matrix);
1249 * direct_solver.vmult(solution, system_rhs);
1254 * std::cout << "done (" << timer.cpu_time() << " s)" << std::endl;
1261 * /** @brief Converts the solution vector into a .vtu file and labels the outputs as u and v
1262 * * @tparam dim The dimension of the manifold
1263 * * @tparam spacedim The dimension of the ambient space
1264 * * @tparam MESH The type of mesh being used, doesn't change how
this function works
1265 * * @tparam ICTYPE The type of initial condition used, doesn
't change how this function works
1267 * template <int dim, int spacedim, MeshType MESH, InitialConditionType ICTYPE>
1268 * void SHEquation<dim, spacedim, MESH, ICTYPE>::output_results() const
1270 * std::vector<std::string> solution_names(1, "u");
1271 * solution_names.emplace_back("v");
1272 * std::vector<DataComponentInterpretation::DataComponentInterpretation>
1274 * DataComponentInterpretation::component_is_scalar);
1275 * interpretation.push_back(DataComponentInterpretation::component_is_scalar);
1277 * DataOut<dim, spacedim> data_out;
1278 * data_out.add_data_vector(dof_handler,
1281 * interpretation /*,
1282 * DataOut<dim, spacedim>::type_dof_data*/);
1284 * data_out.build_patches(degree + 1);
1288 * Takes the output_file_name string and appends timestep_number with up to three leading 0's
1291 *
const std::string filename =
1294 * std::ofstream output(filename);
1295 * data_out.write_vtu(output);
1300 * Below are all the different
template cases
for the make_grid() function
1304 *
void SHEquation<2, 2, HYPERCUBE, HOTSPOT>::make_grid()
1310 *
void SHEquation<2, 3, CYLINDER, HOTSPOT>::make_grid()
1316 *
void SHEquation<2, 3, SPHERE, HOTSPOT>::make_grid()
1322 *
void SHEquation<2, 3, TORUS, HOTSPOT>::make_grid()
1328 *
void SHEquation<2, 3, SINUSOID, HOTSPOT>::make_grid()
1334 *
void SHEquation<2, 2, HYPERCUBE, PSUEDORANDOM>::make_grid()
1340 *
void SHEquation<2, 3, CYLINDER, PSUEDORANDOM>::make_grid()
1346 *
void SHEquation<2, 3, SPHERE, PSUEDORANDOM>::make_grid()
1352 *
void SHEquation<2, 3, TORUS, PSUEDORANDOM>::make_grid()
1358 *
void SHEquation<2, 3, SINUSOID, PSUEDORANDOM>::make_grid()
1364 *
void SHEquation<2, 2, HYPERCUBE, RANDOM>::make_grid()
1370 *
void SHEquation<2, 3, CYLINDER, RANDOM>::make_grid()
1376 *
void SHEquation<2, 3, SPHERE, RANDOM>::make_grid()
1382 *
void SHEquation<2, 3, TORUS, RANDOM>::make_grid()
1388 *
void SHEquation<2, 3, SINUSOID, RANDOM>::make_grid()
1401 *
template <
int dim,
int spacedim, MeshType MESH, InitialConditionType ICTYPE>
1402 *
void SHEquation<dim, spacedim, MESH, ICTYPE>::run()
1410 * Counts total time elapsed
1416 * Counts number of iterations
1419 * timestep_number = 0;
1423 * Sets the
random seed so runs are repeatable, remove
for varying
random initial conditions
1428 * InitialCondition<spacedim, MESH, ICTYPE> initial_conditions(r, 0.5);
1432 * Applies the
initial conditions to the old_solution
1436 * initial_conditions,
1438 * solution = old_solution;
1449 * Sets up the quadrature formula and
FEValues object
1452 *
const QGauss<dim> quadrature_formula(degree + 2);
1458 *
const unsigned int dofs_per_cell = fe.n_dofs_per_cell();
1465 * The vector which stores the global indices that each local
index connects to
1468 * std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
1472 * Extracts the finite elements associated to u and v
1480 * Loops over the cells to create the system
matrix. We
do this only once because the timestep is
constant
1483 *
for(
const auto &cell : dof_handler.active_cell_iterators()){
1487 * fe_values.reinit(cell);
1489 * cell->get_dof_indices(local_dof_indices);
1491 *
for(
const unsigned int q_index : fe_values.quadrature_point_indices()){
1493 *
for(
const unsigned int i : fe_values.dof_indices()){
1496 * These are the ith finite elements associated to u and v
1499 *
const double phi_i_u = fe_values[u].value(i, q_index);
1501 *
const double phi_i_v = fe_values[v].value(i, q_index);
1504 *
for(
const unsigned int j : fe_values.dof_indices())
1508 * These are the jth finite elements associated to u and v
1511 * const double phi_j_u = fe_values[u].
value(j, q_index);
1513 *
const double phi_j_v = fe_values[v].value(j, q_index);
1518 * This formula comes from expanding the PDE system
1521 *
cell_matrix(i, j) += (phi_i_u*phi_j_u - time_step*r*phi_i_u*phi_j_u
1522 * + time_step*phi_i_u*phi_j_v - time_step*grad_phi_i_u*grad_phi_j_v
1523 * + phi_i_v*phi_j_u - grad_phi_i_v*grad_phi_j_u
1524 * - phi_i_v*phi_j_v)*fe_values.JxW(q_index);
1531 * Loops over the dof indices to fill the entries of the system_matrix with the local data
1534 *
for(
unsigned int i : fe_values.dof_indices()){
1535 *
for(
unsigned int j : fe_values.dof_indices()){
1536 * system_matrix.add(local_dof_indices[i],
1537 * local_dof_indices[j],
1545 * Loops over time, incrementing by timestep, to create the RHS, solve the linear system, then output the result
1548 *
while (time <= end_time)
1552 * Increments time and timestep_number
1555 * time += time_step;
1556 * ++timestep_number;
1560 * Outputs to console the number of iterations and current time. Currently outputs once every
"second"
1563 *
if(timestep_number%timestep_denominator == 0){
1564 * std::cout <<
"Time step " << timestep_number <<
" at t=" << time
1570 * Resets the system_rhs vector. THIS IS VERY IMPORTANT TO ENSURE THE SYSTEM IS SOLVED CORRECTLY AT EACH TIMESTEP
1577 * Loops over cells, then quadrature points, then dof indices to construct the RHS
1580 *
for(
const auto &cell : dof_handler.active_cell_iterators()){
1583 * Resets the cell_rhs. THIS IS ALSO VERY IMPORTANT TO ENSURE THE SYSTEM IS SOLVED CORRECTLY
1590 * Resets the
FEValues object to only the current cell
1593 * fe_values.
reinit(cell);
1595 * cell->get_dof_indices(local_dof_indices);
1599 * Loop over the quadrature points
1602 *
for(
const unsigned int q_index : fe_values.quadrature_point_indices()){
1605 * Stores the
value of the previous solution at the quadrature
point
1612 * Loops over the dof indices to get the
value of Un1
1615 *
for(
const unsigned int i : fe_values.dof_indices()){
1616 * Un1 += old_solution(local_dof_indices[i])*fe_values[u].value(i, q_index);
1621 * Loops over the dof indices,
using Un1 to construct the RHS
for the current timestep. Un1 is used to account
for the nonlinear terms in the SH equation
1624 *
for(
const unsigned int i : fe_values.dof_indices()){
1625 * cell_rhs(i) += (Un1 + time_step*g1*
std::pow(Un1, 2) - time_step*k*
std::pow(Un1, 3))
1626 * *fe_values[u].
value(i, q_index)*fe_values.JxW(q_index);
1632 * Loops over the dof indices to store the local data in the global RHS vector
1635 *
for(
unsigned int i : fe_values.dof_indices()){
1636 * system_rhs(local_dof_indices[i]) += cell_rhs(i);
1643 * This is where Dirichlet conditions are applied, or Neumann conditions
if the code is commented out
1662 * solve_time_step();
1666 * Outputs the solution at regular intervals, currently once every
"second" The SH equation evolves slowly in time, so
this saves disk space
1669 *
if(timestep_number%timestep_denominator == 0){
1673 * old_solution = solution;
1677 *
template <
int dim,
int spacedim, MeshType MESH, InitialConditionType ICTYPE>
1678 *
void SHEquation<dim, spacedim, MESH, ICTYPE>::make_cylinder()
1690 * Extracts the boundary mesh with ID 0, which happens to be the tube part of the
cylinder
1697 * The manifold information is lost upon boundary extraction. This sets the mesh boundary type to be a
cylinder again
1707 *
template <
int dim,
int spacedim, MeshType MESH, InitialConditionType ICTYPE>
1708 *
void SHEquation<dim, spacedim, MESH, ICTYPE>::make_sinusoid()
1712 * Same process as above
1728 * We warp the mesh after refinement to avoid a jagged mesh. We can
't tell the code that the boundary should be a perfect sine wave, so we only warp after the
1729 * mesh is fine enough to resolve this
1732 * GridTools::transform(transform_function<spacedim>, triangulation);
1735 * template <int dim, int spacedim, MeshType MESH, InitialConditionType ICTYPE>
1736 * void SHEquation<dim, spacedim, MESH, ICTYPE>::make_sphere()
1738 * GridGenerator::hyper_sphere(triangulation, Point<3>(0, 0, 0), 18.41988074);
1739 * triangulation.refine_global(refinement_number);
1742 * template <int dim, int spacedim, MeshType MESH, InitialConditionType ICTYPE>
1743 * void SHEquation<dim, spacedim, MESH, ICTYPE>::make_torus()
1745 * GridGenerator::torus(triangulation, 9., 4.);
1746 * triangulation.refine_global(refinement_number);
1748 * template <int dim, int spacedim, MeshType MESH, InitialConditionType ICTYPE>
1749 * void SHEquation<dim, spacedim, MESH, ICTYPE>::make_hypercube()
1751 * GridGenerator::hyper_cube(triangulation, -18.84955592, 18.84955592);
1752 * triangulation.refine_global(refinement_number);
1754 * } // namespace SwiftHohenbergSolver
1760 * using namespace SwiftHohenbergSolver;
1764 * An array of mesh types. We iterate over this to allow for longer runs without having to stop the code
1767 * MeshType mesh_types[5] = {HYPERCUBE, CYLINDER, SPHERE, TORUS, SINUSOID};
1770 * An array of initial condition types. We iterate this as well, for the same reason
1773 * InitialConditionType ic_types[3] = {HOTSPOT, PSUEDORANDOM, RANDOM};
1777 * Controls how long the code runs
1780 * const double end_time = 100.;
1784 * The number of times we refine the hypercube mesh
1787 * const unsigned int ref_num = 6;
1791 * The timestep will be 1/timestep_denominator
1794 * const unsigned int timestep_denominator = 25;
1798 * Loops over mesh types, then initial condition types, then loops over values of g_1
1801 * for(const auto MESH : mesh_types){
1802 * for(const auto ICTYPE: ic_types){
1803 * for(int i = 0; i < 8; ++i){
1806 * The value of g_1 passed to the solver object
1809 * const double g_constant = 0.2*i;
1813 * Used to distinguish the start of each run
1816 * std::cout<< std::endl << std::endl;
1821 * Switch statement that determines what template parameters are used by the solver object. Template parameters must be known at compile time, so we cannot
1822 * pass this as a variable unfortunately. In each case, we create a filename string (named appropriately for the particular case), output to the console what
1823 * we are running, create the solver object, and call run(). Note that for the cylinder, sphere, and sinusoid we decrease the refinement number by 1. This keeps
1824 * the number of dofs used in these cases comparable to the number of dofs on the 2D hypercube (otherwise the number of dofs is much larger). For the torus, we
1825 * decrease the refinement number by 2.
1834 * std::string filename = "HYPERCUBE-HOTSPOT-G1-0.2x" + Utilities::int_to_string(i, 1) + "-";
1835 * std::cout << "Running: " << filename << std::endl << std::endl;
1837 * SHEquation<2, 2, HYPERCUBE, HOTSPOT> heat_equation_solver(1, timestep_denominator,
1838 * ref_num, 0.3, g_constant,
1839 * filename, end_time);
1840 * heat_equation_solver.run();
1844 * case PSUEDORANDOM:
1846 * std::string filename = "HYPERCUBE-PSUEDORANDOM-G1-0.2x" + Utilities::int_to_string(i, 1) + "-";
1847 * std::cout << "Running: " << filename << std::endl << std::endl;
1849 * SHEquation<2, 2, HYPERCUBE, PSUEDORANDOM> heat_equation_solver(1, timestep_denominator,
1850 * ref_num, 0.3, g_constant,
1851 * filename, end_time);
1852 * heat_equation_solver.run();
1858 * std::string filename = "HYPERCUBE-RANDOM-G1-0.2x" + Utilities::int_to_string(i, 1) + "-";
1859 * std::cout << "Running: " << filename << std::endl << std::endl;
1861 * SHEquation<2, 2, HYPERCUBE, RANDOM> heat_equation_solver(1, timestep_denominator,
1862 * ref_num, 0.3, g_constant,
1863 * filename, end_time);
1864 * heat_equation_solver.run();
1873 * std::string filename = "CYLINDER-HOTSPOT-G1-0.2x" + Utilities::int_to_string(i, 1) + "-";
1874 * std::cout << "Running: " << filename << std::endl << std::endl;
1876 * SHEquation<2, 3, CYLINDER, HOTSPOT> heat_equation_solver(1, timestep_denominator,
1877 * ref_num-1, 0.3, g_constant,
1878 * filename, end_time);
1879 * heat_equation_solver.run();
1883 * case PSUEDORANDOM:
1885 * std::string filename = "CYLINDER-PSUEDORANDOM-G1-0.2x" + Utilities::int_to_string(i, 1) + "-";
1886 * std::cout << "Running: " << filename << std::endl << std::endl;
1888 * SHEquation<2, 3, CYLINDER, PSUEDORANDOM> heat_equation_solver(1, timestep_denominator,
1889 * ref_num-1, 0.3, g_constant,
1890 * filename, end_time);
1891 * heat_equation_solver.run();
1897 * std::string filename = "CYLINDER-RANDOM-G1-0.2x" + Utilities::int_to_string(i, 1) + "-";
1898 * std::cout << "Running: " << filename << std::endl << std::endl;
1900 * SHEquation<2, 3, CYLINDER, RANDOM> heat_equation_solver(1, timestep_denominator,
1901 * ref_num-1, 0.3, g_constant,
1902 * filename, end_time);
1903 * heat_equation_solver.run();
1912 * std::string filename = "SPHERE-HOTSPOT-G1-0.2x" + Utilities::int_to_string(i, 1) + "-";
1913 * std::cout << "Running: " << filename << std::endl << std::endl;
1915 * SHEquation<2, 3, SPHERE, HOTSPOT> heat_equation_solver(1, timestep_denominator,
1916 * ref_num-1, 0.3, g_constant,
1917 * filename, end_time);
1918 * heat_equation_solver.run();
1922 * case PSUEDORANDOM:
1924 * std::string filename = "SPHERE-PSUEDORANDOM-G1-0.2x" + Utilities::int_to_string(i, 1) + "-";
1925 * std::cout << "Running: " << filename << std::endl << std::endl;
1927 * SHEquation<2, 3, SPHERE, PSUEDORANDOM> heat_equation_solver(1, timestep_denominator,
1928 * ref_num-1, 0.3, g_constant,
1929 * filename, end_time);
1930 * heat_equation_solver.run();
1936 * std::string filename = "SPHERE-RANDOM-G1-0.2x" + Utilities::int_to_string(i, 1) + "-";
1937 * std::cout << "Running: " << filename << std::endl << std::endl;
1939 * SHEquation<2, 3, SPHERE, RANDOM> heat_equation_solver(1, timestep_denominator,
1940 * ref_num-1, 0.3, g_constant,
1941 * filename, end_time);
1942 * heat_equation_solver.run();
1951 * std::string filename = "TORUS-HOTSPOT-G1-0.2x" + Utilities::int_to_string(i, 1) + "-";
1952 * std::cout << "Running: " << filename << std::endl << std::endl;
1954 * SHEquation<2, 3, TORUS, HOTSPOT> heat_equation_solver(1, timestep_denominator,
1955 * ref_num-2, 0.3, g_constant,
1956 * filename, end_time);
1957 * heat_equation_solver.run();
1961 * case PSUEDORANDOM:
1963 * std::string filename = "TORUS-PSUEDORANDOM-G1-0.2x" + Utilities::int_to_string(i, 1) + "-";
1964 * std::cout << "Running: " << filename << std::endl << std::endl;
1966 * SHEquation<2, 3, TORUS, PSUEDORANDOM> heat_equation_solver(1, timestep_denominator,
1967 * ref_num-2, 0.3, g_constant,
1968 * filename, end_time);
1969 * heat_equation_solver.run();
1975 * std::string filename = "TORUS-RANDOM-G1-0.2x" + Utilities::int_to_string(i, 1) + "-";
1976 * std::cout << "Running: " << filename << std::endl << std::endl;
1978 * SHEquation<2, 3, TORUS, RANDOM> heat_equation_solver(1, timestep_denominator,
1979 * ref_num-2, 0.3, g_constant,
1980 * filename, end_time);
1981 * heat_equation_solver.run();
1990 * std::string filename = "SINUSOID-HOTSPOT-G1-0.2x" + Utilities::int_to_string(i, 1) + "-";
1991 * std::cout << "Running: " << filename << std::endl << std::endl;
1993 * SHEquation<2, 3, SINUSOID, HOTSPOT> heat_equation_solver(1, timestep_denominator,
1994 * ref_num-1, 0.3, g_constant,
1995 * filename, end_time);
1996 * heat_equation_solver.run();
2000 * case PSUEDORANDOM:
2002 * std::string filename = "SINUSOID-PSUEDORANDOM-G1-0.2x" + Utilities::int_to_string(i, 1) + "-";
2003 * std::cout << "Running: " << filename << std::endl << std::endl;
2005 * SHEquation<2, 3, SINUSOID, PSUEDORANDOM> heat_equation_solver(1, timestep_denominator,
2006 * ref_num-1, 0.3, g_constant,
2007 * filename, end_time);
2008 * heat_equation_solver.run();
2014 * std::string filename = "SINUSOID-RANDOM-G1-0.2x" + Utilities::int_to_string(i, 1) + "-";
2015 * std::cout << "Running: " << filename << std::endl << std::endl;
2017 * SHEquation<2, 3, SINUSOID, RANDOM> heat_equation_solver(1, timestep_denominator,
2018 * ref_num-1, 0.3, g_constant,
2019 * filename, end_time);
2020 * heat_equation_solver.run();
2029 * catch (std::exception &exc)
2031 * std::cout << "An error occurred" << std::endl;
2032 * std::cerr << std::endl
2034 * << "----------------------------------------------------"
2036 * std::cerr << "Exception on processing: " << std::endl
2037 * << exc.what() << std::endl
2038 * << "Aborting!" << std::endl
2039 * << "----------------------------------------------------"
2046 * std::cout << "Error occurred, made it past first catch" << std::endl;
2047 * std::cerr << std::endl
2049 * << "----------------------------------------------------"
2051 * std::cerr << "Unknown exception!" << std::endl
2052 * << "Aborting!" << std::endl
2053 * << "----------------------------------------------------"
void reinit(const TriaIterator< DoFCellAccessor< dim, spacedim, level_dof_access > > &cell)
Function(const unsigned int n_components=1, const time_type initial_time=0.0)
virtual RangeNumberType value(const Point< dim > &p, const unsigned int component=0) const
void refine_global(const unsigned int times=1)
#define Assert(cond, exc)
#define AssertIndexRange(index, range)
@ update_values
Shape function values.
@ update_JxW_values
Transformed quadrature weights.
@ update_gradients
Shape function gradients.
@ update_quadrature_points
Transformed quadrature points.
void set_manifold(const types::manifold_id number, const Manifold< dim, spacedim > &manifold_object)
void set_all_manifold_ids(const types::manifold_id number)
void random(DoFHandler< dim, spacedim > &dof_handler)
void cylinder(Triangulation< dim > &tria, const double radius=1., const double half_length=1.)
return_type extract_boundary_mesh(const MeshType< dim, spacedim > &volume_mesh, MeshType< dim - 1, spacedim > &surface_mesh, const std::set< types::boundary_id > &boundary_ids=std::set< types::boundary_id >())
void torus(Triangulation< dim, spacedim > &tria, const double centerline_radius, const double inner_radius, const unsigned int n_cells_toroidal=6, const double phi=2.0 *numbers::PI)
void refine(Triangulation< dim, spacedim > &tria, const Vector< Number > &criteria, const double threshold, const unsigned int max_to_mark=numbers::invalid_unsigned_int)
@ matrix
Contents is actually a matrix.
void cell_matrix(FullMatrix< double > &M, const FEValuesBase< dim > &fe, const FEValuesBase< dim > &fetest, const ArrayView< const std::vector< double > > &velocity, const double factor=1.)
Point< spacedim > point(const gp_Pnt &p, const double tolerance=1e-10)
std::string int_to_string(const unsigned int value, const unsigned int digits=numbers::invalid_unsigned_int)
void run(const Iterator &begin, const std_cxx20::type_identity_t< Iterator > &end, Worker worker, Copier copier, const ScratchData &sample_scratch_data, const CopyData &sample_copy_data, const unsigned int queue_length, const unsigned int chunk_size)
::VectorizedArray< Number, width > cos(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > sin(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > sqrt(const ::VectorizedArray< Number, width > &)
::VectorizedArray< Number, width > pow(const ::VectorizedArray< Number, width > &, const Number p)
const ::parallel::distributed::Triangulation< dim, spacedim > * triangulation