382 * #include <deal.II/base/utilities.h>
383 * #include <deal.II/base/quadrature_lib.h>
384 * #include <deal.II/base/function.h>
385 * #include <deal.II/base/logstream.h>
386 * #include <deal.II/lac/vector.h>
387 * #include <deal.II/lac/full_matrix.h>
388 * #include <deal.II/lac/dynamic_sparsity_pattern.h>
389 * #include <deal.II/lac/sparse_matrix.h>
390 * #include <deal.II/lac/solver_cg.h>
391 * #include <deal.II/lac/precondition.h>
392 * #include <deal.II/lac/affine_constraints.h>
393 * #include <deal.II/grid/
tria.h>
394 * #include <deal.II/grid/grid_generator.h>
395 * #include <deal.II/grid/grid_refinement.h>
396 * #include <deal.II/grid/grid_out.h>
397 * #include <deal.II/dofs/dof_handler.h>
398 * #include <deal.II/dofs/dof_tools.h>
399 * #include <deal.II/fe/fe_q.h>
400 * #include <deal.II/fe/fe_system.h>
401 * #include <deal.II/fe/fe_values.h>
402 * #include <deal.II/numerics/data_out.h>
403 * #include <deal.II/numerics/vector_tools.h>
404 * #include <deal.II/numerics/error_estimator.h>
405 * #include <deal.II/numerics/solution_transfer.h>
406 * #include <deal.II/numerics/matrix_tools.h>
407 * #include <deal.II/lac/sparse_direct.h>
408 * #include <deal.II/base/timer.h>
410 * #include <deal.II/grid/manifold_lib.h>
411 * #include <deal.II/grid/grid_tools.h>
413 * #include <
boost/math/special_functions/ellint_1.hpp>
416 * #include <iostream>
419 *
namespace SwiftHohenbergSolver
430 *
enum MeshType {HYPERCUBE, CYLINDER, SPHERE, TORUS, SINUSOID};
439 *
enum InitialConditionType {HOTSPOT, PSUEDORANDOM, RANDOM};
451 *
template<
int spacedim>
456 * Currently
this only works
for a 3-dimensional embedding space
457 * because we are explicitly referencing the x, y, and z coordinates
460 *
Assert(spacedim == 3, ExcNotImplemented());
464 * Retruns a
point where the x-coordinate is unchanged but the y and z coordinates are adjusted
465 * by a
cos wave of period 20, amplitude .5, and vertical
shift 1
482 *
template <
int dim,
int spacedim, MeshType MESH, InitialConditionType ICTYPE>
488 * / @brief Default constructor, initializes all variables and objects with
default values
503 * SHEquation(
const unsigned int degree
504 * ,
double time_step_denominator
505 * ,
unsigned int ref_num
506 * ,
double r_constant = 0.5
507 * ,
double g1_constant = 0.5
508 * , std::string output_file_name =
"solution-"
509 * ,
double end_time = 0.5);
513 *
void setup_system();
514 *
void solve_time_step();
515 *
void output_results()
const;
524 *
void make_cylinder();
527 * / @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))
530 *
void make_sinusoid();
533 * / @brief Generates a spherical mesh of radius 6*pi
using GridGenerator and refines it refinement_number times.
536 *
void make_sphere();
539 * / @brief Generates a
torus mesh with inner radius 4 and outer radius 9
using GridGenerator and refines it refinement_number times.
545 * / @brief Generates a hypercube mesh with sidelenth 12*pi
using GridGenerator and refines it refinement_number times.
548 *
void make_hypercube();
553 * / @brief The degree of finite element to be used,
default 1
556 *
const unsigned int degree;
560 * / @brief Object holding the mesh
570 * / @brief Object which understands which finite elements are at each node
577 * / @brief Describes the sparsity of the system
matrix, allows
for more efficient storage
584 * / @brief Object holding the system
matrix, stored as a sparse
matrix
595 * / @brief Stores the solution from the previous timestep. Used to compute non-linear terms
606 * / @brief Stores the current time, in the units of the problem
612 * / @brief The amount time is increased each iteration/ the denominator of the discretized time derivative
618 * / @brief Counts the number of iterations that have ellapsed
621 *
unsigned int timestep_number;
624 * / @brief Used to compute the time_step: time_step = 1/timestep_denominator
627 *
unsigned int timestep_denominator;
630 * / @brief Determines how much to globally
refine each mesh
633 *
unsigned int refinement_number;
637 * / @brief Coefficient of the linear term in the SH equation. This is often taken to be
constant and g_1 allowed to vary
643 * / @brief Coefficient of the quadratic term in the SH equation. Determines whether hexagonal lattices can form
649 * / @brief A control parameter
for the cubic term. Can be useful
for testing, in
this code we let k=1 in all cases
656 * / @brief Name used to create output file. Should not include extension
659 *
const std::string output_file_name;
663 * / @brief Determines when the solver terminates, endtime of ~100 are useful to see equilibrium results
666 *
const double end_time;
675 *
template <
int spacedim>
676 *
class BoundaryValues :
public Function<spacedim>
684 *
const unsigned int component = 0)
const override;
696 *
template <
int spacedim>
698 *
const unsigned int component)
const
719 *
template<
int spacedim, MeshType MESH, InitialConditionType ICTYPE>
720 *
class InitialCondition :
public Function<spacedim>
725 * / @brief The
value of the parameter r, used to determine a bound
for the magnitude of the
initial conditions
731 * / @brief A
center point, used to determine the location of the hot spot
for the HotSpot
initial condition
737 * / @brief Radius of the hot spot
743 * / @brief Stores the randomly generated coefficients
for planar sine waves along the x-axis, used
for psuedorandom
initial conditions
746 *
double x_sin_coefficients[10];
749 * / @brief Stores the randomly generated coefficients
for planar sine waves along the y-axis, used
for psuedorandom
initial conditions
752 *
double y_sin_coefficients[10];
763 *
for(
int i = 0; i < 10; ++i){
774 * InitialCondition(
const double r,
775 *
const double radius)
780 *
for(
int i = 0; i < 10; ++i){
815 *
double InitialCondition<2, HYPERCUBE, HOTSPOT>::value(
817 *
const unsigned int component)
const
819 *
if(component == 0){
820 *
if(p.square() <= radius){
838 *
double InitialCondition<3, CYLINDER, HOTSPOT>::value(
840 *
const unsigned int component)
const
842 *
if(component == 0){
845 *
if(compare.square() <= radius){
863 *
double InitialCondition<3, SPHERE, HOTSPOT>::value(
865 *
const unsigned int component)
const
867 *
if(component == 0){
870 *
if(compare.square() <= radius){
888 *
double InitialCondition<3, TORUS, HOTSPOT>::value(
890 *
const unsigned int component)
const
892 *
if(component == 0){
895 *
if(compare.square() <= radius){
913 *
double InitialCondition<3, SINUSOID, HOTSPOT>::value(
915 *
const unsigned int component)
const
917 *
if(component == 0){
920 *
if(compare.square() <= radius){
938 *
double InitialCondition<2, HYPERCUBE, PSUEDORANDOM>::value(
940 *
const unsigned int component)
const
942 *
if(component == 0){
945 *
for(
int i=0; i < 10; ++i){
946 * x_val += x_sin_coefficients[i]*
std::sin(2*3.141592653*p(0)/((i+1)*1.178097245));
947 * y_val += y_sin_coefficients[i]*
std::sin(2*3.141592653*p(1)/((i+1)*1.178097245));
950 *
return x_val*y_val;
963 *
double InitialCondition<3, CYLINDER, PSUEDORANDOM>::value(
965 *
const unsigned int component)
const
967 *
if(component == 0){
970 *
double width = ((std::atan2(p(1),p(2)) - 3.1415926)/3.1415926)*18.84955592;
971 *
for(
int i=0; i < 10; ++i){
972 * x_val += x_sin_coefficients[i]*
std::sin(2*3.141592653*p(0)/((i+1)*1.178097245));
973 * w_val += y_sin_coefficients[i]*
std::sin(2*3.141592653*width/((i+1)*1.178097245));
976 *
return x_val*w_val;
989 *
double InitialCondition<3, SPHERE, PSUEDORANDOM>::value(
991 *
const unsigned int component)
const
993 *
if(component == 0){
996 *
for(
int i=0; i < 10; ++i){
997 * x_val += x_sin_coefficients[i]*
std::sin(2*3.141592653*p(0)/((i+1)*1.178097245));
998 * y_val += y_sin_coefficients[i]*
std::sin(2*3.141592653*p(1)/((i+1)*1.178097245));
1001 *
return x_val*y_val;
1014 *
double InitialCondition<3, TORUS, PSUEDORANDOM>::value(
1016 *
const unsigned int component)
const
1018 *
if(component == 0){
1021 *
for(
int i=0; i < 10; ++i){
1022 * x_val += x_sin_coefficients[i]*
std::sin(2*3.141592653*p(0)/((i+1)*1.178097245));
1023 * z_val += y_sin_coefficients[i]*
std::sin(2*3.141592653*p(2)/((i+1)*1.178097245));
1026 *
return x_val*z_val;
1039 *
double InitialCondition<3, SINUSOID, PSUEDORANDOM>::value(
1041 *
const unsigned int component)
const
1043 *
if(component == 0){
1046 *
double width = ((std::atan2(p(1),p(2)) - 3.1415926)/3.1415926)*18.84955592;
1047 *
for(
int i=0; i < 10; ++i){
1048 * x_val += x_sin_coefficients[i]*
std::sin(2*3.141592653*p(0)/((i+1)*1.178097245));
1049 * w_val += y_sin_coefficients[i]*
std::sin(2*3.141592653*width/((i+1)*1.178097245));
1052 *
return x_val*w_val;
1065 *
double InitialCondition<2, HYPERCUBE, RANDOM>::value(
1067 *
const unsigned int component)
const
1069 *
if(component == 0){
1083 *
double InitialCondition<3, CYLINDER, RANDOM>::value(
1085 *
const unsigned int component)
const
1087 *
if(component == 0){
1101 *
double InitialCondition<3, SPHERE, RANDOM>::value(
1103 *
const unsigned int component)
const
1105 *
if(component == 0){
1119 *
double InitialCondition<3, TORUS, RANDOM>::value(
1121 *
const unsigned int component)
const
1123 *
if(component == 0){
1137 *
double InitialCondition<3, SINUSOID, RANDOM>::value(
1139 *
const unsigned int component)
const
1141 *
if(component == 0){
1149 *
template <
int dim,
int spacedim, MeshType MESH, InitialConditionType ICTYPE>
1150 * SHEquation<dim, spacedim, MESH, ICTYPE>::SHEquation()
1154 * , time_step(1. / 1500)
1155 * , timestep_denominator(1500)
1156 * , refinement_number(4)
1160 * , output_file_name(
"solution-")
1164 *
template <
int dim,
int spacedim, MeshType MESH, InitialConditionType ICTYPE>
1165 * SHEquation<dim, spacedim, MESH, ICTYPE>::SHEquation(
const unsigned int degree,
1166 *
double time_step_denominator,
1167 *
unsigned int ref_num,
1168 *
double r_constant,
1169 *
double g1_constant,
1170 * std::string output_file_name,
1175 * , time_step(1. / time_step_denominator)
1176 * , timestep_denominator(time_step_denominator)
1177 * , refinement_number(ref_num)
1181 * , output_file_name(output_file_name)
1182 * , end_time(end_time)
1192 *
template <
int dim,
int spacedim, MeshType MESH, InitialConditionType ICTYPE>
1193 *
void SHEquation<dim, spacedim, MESH, ICTYPE>::setup_system()
1195 * dof_handler.distribute_dofs(fe);
1199 * Counts the DoF
's for outputting to consolse
1202 * const std::vector<types::global_dof_index> dofs_per_component =
1203 * DoFTools::count_dofs_per_fe_component(dof_handler);
1204 * const unsigned int n_u = dofs_per_component[0],
1205 * n_v = dofs_per_component[1];
1207 * std::cout << "Number of active cells: " << triangulation.n_active_cells()
1209 * << "Total number of cells: " << triangulation.n_cells()
1211 * << "Number of degrees of freedom: " << dof_handler.n_dofs()
1212 * << " (" << n_u << '+
' << n_v << ')
' << std::endl;
1214 * DynamicSparsityPattern dsp(dof_handler.n_dofs());
1216 * DoFTools::make_sparsity_pattern(dof_handler,
1218 * sparsity_pattern.copy_from(dsp);
1220 * system_matrix.reinit(sparsity_pattern);
1222 * solution.reinit(dof_handler.n_dofs());
1223 * old_solution.reinit(dof_handler.n_dofs());
1224 * system_rhs.reinit(dof_handler.n_dofs());
1228 * /** @brief Uses a direct solver to invert the system matrix, then multiplies the RHS vector by the inverted matrix to get the solution.
1229 * * Also includes a timer feature, which is currently commented out, but can be helpful to compute how long a run will take
1230 * * @tparam dim The dimension of the manifold
1231 * * @tparam spacedim The dimension of the ambient space
1232 * * @tparam MESH The type of mesh being used, doesn't change how
this function works
1233 * * @tparam ICTYPE The type of initial condition used, doesn
't change how this function works
1235 * template <int dim, int spacedim, MeshType MESH, InitialConditionType ICTYPE>
1236 * void SHEquation<dim, spacedim, MESH, ICTYPE>::solve_time_step()
1240 * std::cout << "Solving linear system" << std::endl;
1247 * SparseDirectUMFPACK direct_solver;
1249 * direct_solver.initialize(system_matrix);
1251 * direct_solver.vmult(solution, system_rhs);
1256 * std::cout << "done (" << timer.cpu_time() << " s)" << std::endl;
1263 * /** @brief Converts the solution vector into a .vtu file and labels the outputs as u and v
1264 * * @tparam dim The dimension of the manifold
1265 * * @tparam spacedim The dimension of the ambient space
1266 * * @tparam MESH The type of mesh being used, doesn't change how
this function works
1267 * * @tparam ICTYPE The type of initial condition used, doesn
't change how this function works
1269 * template <int dim, int spacedim, MeshType MESH, InitialConditionType ICTYPE>
1270 * void SHEquation<dim, spacedim, MESH, ICTYPE>::output_results() const
1272 * std::vector<std::string> solution_names(1, "u");
1273 * solution_names.emplace_back("v");
1274 * std::vector<DataComponentInterpretation::DataComponentInterpretation>
1276 * DataComponentInterpretation::component_is_scalar);
1277 * interpretation.push_back(DataComponentInterpretation::component_is_scalar);
1279 * DataOut<dim, spacedim> data_out;
1280 * data_out.add_data_vector(dof_handler,
1283 * interpretation /*,
1284 * DataOut<dim, spacedim>::type_dof_data*/);
1286 * data_out.build_patches(degree + 1);
1290 * Takes the output_file_name string and appends timestep_number with up to three leading 0's
1293 *
const std::string filename =
1296 * std::ofstream output(filename);
1297 * data_out.write_vtu(output);
1302 * Below are all the different
template cases
for the make_grid() function
1306 *
void SHEquation<2, 2, HYPERCUBE, HOTSPOT>::make_grid()
1312 *
void SHEquation<2, 3, CYLINDER, HOTSPOT>::make_grid()
1318 *
void SHEquation<2, 3, SPHERE, HOTSPOT>::make_grid()
1324 *
void SHEquation<2, 3, TORUS, HOTSPOT>::make_grid()
1330 *
void SHEquation<2, 3, SINUSOID, HOTSPOT>::make_grid()
1336 *
void SHEquation<2, 2, HYPERCUBE, PSUEDORANDOM>::make_grid()
1342 *
void SHEquation<2, 3, CYLINDER, PSUEDORANDOM>::make_grid()
1348 *
void SHEquation<2, 3, SPHERE, PSUEDORANDOM>::make_grid()
1354 *
void SHEquation<2, 3, TORUS, PSUEDORANDOM>::make_grid()
1360 *
void SHEquation<2, 3, SINUSOID, PSUEDORANDOM>::make_grid()
1366 *
void SHEquation<2, 2, HYPERCUBE, RANDOM>::make_grid()
1372 *
void SHEquation<2, 3, CYLINDER, RANDOM>::make_grid()
1378 *
void SHEquation<2, 3, SPHERE, RANDOM>::make_grid()
1384 *
void SHEquation<2, 3, TORUS, RANDOM>::make_grid()
1390 *
void SHEquation<2, 3, SINUSOID, RANDOM>::make_grid()
1403 *
template <
int dim,
int spacedim, MeshType MESH, InitialConditionType ICTYPE>
1404 *
void SHEquation<dim, spacedim, MESH, ICTYPE>::run()
1412 * Counts total time ellapsed
1418 * Counts number of iterations
1421 * timestep_number = 0;
1425 * Sets the
random seed so runs are repeatable, remove
for varying
random initial conditions
1430 * InitialCondition<spacedim, MESH, ICTYPE> initial_conditions(r, 0.5);
1434 * Applies the
initial conditions to the old_solution
1438 * initial_conditions,
1440 * solution = old_solution;
1451 * Sets up the quadrature formula and
FEValues object
1454 *
const QGauss<dim> quadrature_formula(degree + 2);
1460 *
const unsigned int dofs_per_cell = fe.n_dofs_per_cell();
1467 * The vector which stores the global indices that each local
index connects to
1470 * std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
1474 * Extracts the finite elements associated to u and v
1482 * Loops over the cells to create the system
matrix. We
do this only once becase the timestep is
constant
1485 *
for(
const auto &cell : dof_handler.active_cell_iterators()){
1489 * fe_values.reinit(cell);
1491 * cell->get_dof_indices(local_dof_indices);
1493 *
for(
const unsigned int q_index : fe_values.quadrature_point_indices()){
1495 *
for(
const unsigned int i : fe_values.dof_indices()){
1498 * These are the ith finite elements associated to u and v
1501 *
const double phi_i_u = fe_values[u].value(i, q_index);
1503 *
const double phi_i_v = fe_values[v].value(i, q_index);
1506 *
for(
const unsigned int j : fe_values.dof_indices())
1510 * These are the jth finite elements associated to u and v
1513 * const double phi_j_u = fe_values[u].
value(j, q_index);
1515 *
const double phi_j_v = fe_values[v].value(j, q_index);
1520 * This formula comes from expanding the PDE system
1523 *
cell_matrix(i, j) += (phi_i_u*phi_j_u - time_step*r*phi_i_u*phi_j_u
1524 * + time_step*phi_i_u*phi_j_v - time_step*grad_phi_i_u*grad_phi_j_v
1525 * + phi_i_v*phi_j_u - grad_phi_i_v*grad_phi_j_u
1526 * - phi_i_v*phi_j_v)*fe_values.JxW(q_index);
1533 * Loops over the dof indices to fill the entries of the system_matrix with the local data
1536 *
for(
unsigned int i : fe_values.dof_indices()){
1537 *
for(
unsigned int j : fe_values.dof_indices()){
1538 * system_matrix.add(local_dof_indices[i],
1539 * local_dof_indices[j],
1547 * Loops over time, incrementing by timestep, to create the RHS, solve the linear system, then output the result
1550 *
while (time <= end_time)
1554 * Increments time and timestep_number
1557 * time += time_step;
1558 * ++timestep_number;
1562 * Outputs to console the number of iterations and current time. Currently outputs once every
"second"
1565 *
if(timestep_number%timestep_denominator == 0){
1566 * std::cout <<
"Time step " << timestep_number <<
" at t=" << time
1572 * Resets the system_rhs vector. THIS IS VERY IMPORTANT TO ENSURE THE SYSTEM IS SOLVED CORRECTLY AT EACH TIMESTEP
1579 * Loops over cells, then quadrature points, then dof indices to construct the RHS
1582 *
for(
const auto &cell : dof_handler.active_cell_iterators()){
1585 * Resets the cell_rhs. THIS IS ALSO VERY IMPORTANT TO ENSURE THE SYSTEM IS SOLVED CORRECTLY
1592 * Resets the
FEValues object to only the current cell
1595 * fe_values.
reinit(cell);
1597 * cell->get_dof_indices(local_dof_indices);
1601 * Loop over the quadrature points
1604 *
for(
const unsigned int q_index : fe_values.quadrature_point_indices()){
1607 * Stores the
value of the previous solution at the quadrature
point
1614 * Loops over the dof indices to get the
value of Un1
1617 *
for(
const unsigned int i : fe_values.dof_indices()){
1618 * Un1 += old_solution(local_dof_indices[i])*fe_values[u].value(i, q_index);
1623 * 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
1626 *
for(
const unsigned int i : fe_values.dof_indices()){
1627 * cell_rhs(i) += (Un1 + time_step*g1*
std::pow(Un1, 2) - time_step*k*
std::pow(Un1, 3))
1628 * *fe_values[u].
value(i, q_index)*fe_values.JxW(q_index);
1634 * Loops over the dof indices to store the local data in the global RHS vector
1637 *
for(
unsigned int i : fe_values.dof_indices()){
1638 * system_rhs(local_dof_indices[i]) += cell_rhs(i);
1645 * This is where Dirichlet conditions are applied, or Neumann conditions
if the code is commented out
1664 * solve_time_step();
1668 * Outputs the solution at regular intervals, currently once every
"second" The SH equation evolves slowly in time, so
this saves disk space
1671 *
if(timestep_number%timestep_denominator == 0){
1675 * old_solution = solution;
1679 *
template <
int dim,
int spacedim, MeshType MESH, InitialConditionType ICTYPE>
1680 *
void SHEquation<dim, spacedim, MESH, ICTYPE>::make_cylinder()
1692 * Extracts the boundary mesh with ID 0, which happens to be the tube part of the
cylinder
1699 * The manifold information is lost upon boundary extraction. This sets the mesh boundary type to be a
cylinder again
1709 *
template <
int dim,
int spacedim, MeshType MESH, InitialConditionType ICTYPE>
1710 *
void SHEquation<dim, spacedim, MESH, ICTYPE>::make_sinusoid()
1714 * Same process as above
1730 * 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
1731 * mesh is fine enough to resolve this
1734 * GridTools::transform(transform_function<spacedim>, triangulation);
1737 * template <int dim, int spacedim, MeshType MESH, InitialConditionType ICTYPE>
1738 * void SHEquation<dim, spacedim, MESH, ICTYPE>::make_sphere()
1740 * GridGenerator::hyper_sphere(triangulation, Point<3>(0, 0, 0), 18.41988074);
1741 * triangulation.refine_global(refinement_number);
1744 * template <int dim, int spacedim, MeshType MESH, InitialConditionType ICTYPE>
1745 * void SHEquation<dim, spacedim, MESH, ICTYPE>::make_torus()
1747 * GridGenerator::torus(triangulation, 9., 4.);
1748 * triangulation.refine_global(refinement_number);
1750 * template <int dim, int spacedim, MeshType MESH, InitialConditionType ICTYPE>
1751 * void SHEquation<dim, spacedim, MESH, ICTYPE>::make_hypercube()
1753 * GridGenerator::hyper_cube(triangulation, -18.84955592, 18.84955592);
1754 * triangulation.refine_global(refinement_number);
1756 * } // namespace SwiftHohenbergSolver
1762 * using namespace SwiftHohenbergSolver;
1766 * An array of mesh types. We itterate over this to allow for longer runs without having to stop the code
1769 * MeshType mesh_types[5] = {HYPERCUBE, CYLINDER, SPHERE, TORUS, SINUSOID};
1772 * An array of initial condition types. We itterate this as well, for the same reason
1775 * InitialConditionType ic_types[3] = {HOTSPOT, PSUEDORANDOM, RANDOM};
1779 * Controls how long the code runs
1782 * const double end_time = 100.;
1786 * The number of times we refine the hypercube mesh
1789 * const unsigned int ref_num = 6;
1793 * The timestep will be 1/timestep_denominator
1796 * const unsigned int timestep_denominator = 25;
1800 * Loops over mesh types, then initial condition types, then loops over values of g_1
1803 * for(const auto MESH : mesh_types){
1804 * for(const auto ICTYPE: ic_types){
1805 * for(int i = 0; i < 8; ++i){
1808 * The value of g_1 passed to the solver object
1811 * const double g_constant = 0.2*i;
1815 * Used to distinguish the start of each run
1818 * std::cout<< std::endl << std::endl;
1823 * Switch statement that determines what template parameters are used by the solver object. Template parameters must be known at compile time, so we cannot
1824 * pass this as a varible unfortunately. In each case, we create a filename string (named appropriately for the particular case), output to the console what
1825 * 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
1826 * 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
1827 * decrease the refinement number by 2.
1836 * std::string filename = "HYPERCUBE-HOTSPOT-G1-0.2x" + Utilities::int_to_string(i, 1) + "-";
1837 * std::cout << "Running: " << filename << std::endl << std::endl;
1839 * SHEquation<2, 2, HYPERCUBE, HOTSPOT> heat_equation_solver(1, timestep_denominator,
1840 * ref_num, 0.3, g_constant,
1841 * filename, end_time);
1842 * heat_equation_solver.run();
1846 * case PSUEDORANDOM:
1848 * std::string filename = "HYPERCUBE-PSUEDORANDOM-G1-0.2x" + Utilities::int_to_string(i, 1) + "-";
1849 * std::cout << "Running: " << filename << std::endl << std::endl;
1851 * SHEquation<2, 2, HYPERCUBE, PSUEDORANDOM> heat_equation_solver(1, timestep_denominator,
1852 * ref_num, 0.3, g_constant,
1853 * filename, end_time);
1854 * heat_equation_solver.run();
1860 * std::string filename = "HYPERCUBE-RANDOM-G1-0.2x" + Utilities::int_to_string(i, 1) + "-";
1861 * std::cout << "Running: " << filename << std::endl << std::endl;
1863 * SHEquation<2, 2, HYPERCUBE, RANDOM> heat_equation_solver(1, timestep_denominator,
1864 * ref_num, 0.3, g_constant,
1865 * filename, end_time);
1866 * heat_equation_solver.run();
1875 * std::string filename = "CYLINDER-HOTSPOT-G1-0.2x" + Utilities::int_to_string(i, 1) + "-";
1876 * std::cout << "Running: " << filename << std::endl << std::endl;
1878 * SHEquation<2, 3, CYLINDER, HOTSPOT> heat_equation_solver(1, timestep_denominator,
1879 * ref_num-1, 0.3, g_constant,
1880 * filename, end_time);
1881 * heat_equation_solver.run();
1885 * case PSUEDORANDOM:
1887 * std::string filename = "CYLINDER-PSUEDORANDOM-G1-0.2x" + Utilities::int_to_string(i, 1) + "-";
1888 * std::cout << "Running: " << filename << std::endl << std::endl;
1890 * SHEquation<2, 3, CYLINDER, PSUEDORANDOM> heat_equation_solver(1, timestep_denominator,
1891 * ref_num-1, 0.3, g_constant,
1892 * filename, end_time);
1893 * heat_equation_solver.run();
1899 * std::string filename = "CYLINDER-RANDOM-G1-0.2x" + Utilities::int_to_string(i, 1) + "-";
1900 * std::cout << "Running: " << filename << std::endl << std::endl;
1902 * SHEquation<2, 3, CYLINDER, RANDOM> heat_equation_solver(1, timestep_denominator,
1903 * ref_num-1, 0.3, g_constant,
1904 * filename, end_time);
1905 * heat_equation_solver.run();
1914 * std::string filename = "SPHERE-HOTSPOT-G1-0.2x" + Utilities::int_to_string(i, 1) + "-";
1915 * std::cout << "Running: " << filename << std::endl << std::endl;
1917 * SHEquation<2, 3, SPHERE, HOTSPOT> heat_equation_solver(1, timestep_denominator,
1918 * ref_num-1, 0.3, g_constant,
1919 * filename, end_time);
1920 * heat_equation_solver.run();
1924 * case PSUEDORANDOM:
1926 * std::string filename = "SPHERE-PSUEDORANDOM-G1-0.2x" + Utilities::int_to_string(i, 1) + "-";
1927 * std::cout << "Running: " << filename << std::endl << std::endl;
1929 * SHEquation<2, 3, SPHERE, PSUEDORANDOM> heat_equation_solver(1, timestep_denominator,
1930 * ref_num-1, 0.3, g_constant,
1931 * filename, end_time);
1932 * heat_equation_solver.run();
1938 * std::string filename = "SPHERE-RANDOM-G1-0.2x" + Utilities::int_to_string(i, 1) + "-";
1939 * std::cout << "Running: " << filename << std::endl << std::endl;
1941 * SHEquation<2, 3, SPHERE, RANDOM> heat_equation_solver(1, timestep_denominator,
1942 * ref_num-1, 0.3, g_constant,
1943 * filename, end_time);
1944 * heat_equation_solver.run();
1953 * std::string filename = "TORUS-HOTSPOT-G1-0.2x" + Utilities::int_to_string(i, 1) + "-";
1954 * std::cout << "Running: " << filename << std::endl << std::endl;
1956 * SHEquation<2, 3, TORUS, HOTSPOT> heat_equation_solver(1, timestep_denominator,
1957 * ref_num-2, 0.3, g_constant,
1958 * filename, end_time);
1959 * heat_equation_solver.run();
1963 * case PSUEDORANDOM:
1965 * std::string filename = "TORUS-PSUEDORANDOM-G1-0.2x" + Utilities::int_to_string(i, 1) + "-";
1966 * std::cout << "Running: " << filename << std::endl << std::endl;
1968 * SHEquation<2, 3, TORUS, PSUEDORANDOM> heat_equation_solver(1, timestep_denominator,
1969 * ref_num-2, 0.3, g_constant,
1970 * filename, end_time);
1971 * heat_equation_solver.run();
1977 * std::string filename = "TORUS-RANDOM-G1-0.2x" + Utilities::int_to_string(i, 1) + "-";
1978 * std::cout << "Running: " << filename << std::endl << std::endl;
1980 * SHEquation<2, 3, TORUS, RANDOM> heat_equation_solver(1, timestep_denominator,
1981 * ref_num-2, 0.3, g_constant,
1982 * filename, end_time);
1983 * heat_equation_solver.run();
1992 * std::string filename = "SINUSOID-HOTSPOT-G1-0.2x" + Utilities::int_to_string(i, 1) + "-";
1993 * std::cout << "Running: " << filename << std::endl << std::endl;
1995 * SHEquation<2, 3, SINUSOID, HOTSPOT> heat_equation_solver(1, timestep_denominator,
1996 * ref_num-1, 0.3, g_constant,
1997 * filename, end_time);
1998 * heat_equation_solver.run();
2002 * case PSUEDORANDOM:
2004 * std::string filename = "SINUSOID-PSUEDORANDOM-G1-0.2x" + Utilities::int_to_string(i, 1) + "-";
2005 * std::cout << "Running: " << filename << std::endl << std::endl;
2007 * SHEquation<2, 3, SINUSOID, PSUEDORANDOM> heat_equation_solver(1, timestep_denominator,
2008 * ref_num-1, 0.3, g_constant,
2009 * filename, end_time);
2010 * heat_equation_solver.run();
2016 * std::string filename = "SINUSOID-RANDOM-G1-0.2x" + Utilities::int_to_string(i, 1) + "-";
2017 * std::cout << "Running: " << filename << std::endl << std::endl;
2019 * SHEquation<2, 3, SINUSOID, RANDOM> heat_equation_solver(1, timestep_denominator,
2020 * ref_num-1, 0.3, g_constant,
2021 * filename, end_time);
2022 * heat_equation_solver.run();
2031 * catch (std::exception &exc)
2033 * std::cout << "An error occured" << std::endl;
2034 * std::cerr << std::endl
2036 * << "----------------------------------------------------"
2038 * std::cerr << "Exception on processing: " << std::endl
2039 * << exc.what() << std::endl
2040 * << "Aborting!" << std::endl
2041 * << "----------------------------------------------------"
2048 * std::cout << "Error occured, made it past first catch" << std::endl;
2049 * std::cerr << std::endl
2051 * << "----------------------------------------------------"
2053 * std::cerr << "Unknown exception!" << std::endl
2054 * << "Aborting!" << std::endl
2055 * << "----------------------------------------------------"
void reinit(const TriaIterator< DoFCellAccessor< dim, spacedim, level_dof_access > > &cell)
virtual RangeNumberType value(const Point< dim > &p, const unsigned int component=0) const
#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 random(DoFHandler< dim, spacedim > &dof_handler)
void cylinder(Triangulation< dim > &tria, const double radius=1., const double half_length=1.)
void torus(Triangulation< dim, spacedim > &tria, const double R, const double r, const unsigned int n_cells_toroidal=6, const double phi=2.0 *numbers::PI)
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 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
const ::Triangulation< dim, spacedim > & tria