147 * #include <deal.II/base/quadrature_lib.h>
148 * #include <deal.II/base/logstream.h>
149 * #include <deal.II/base/function.h>
150 * #include <deal.II/base/utilities.h>
152 * #include <deal.II/lac/block_vector.h>
153 * #include <deal.II/lac/full_matrix.h>
154 * #include <deal.II/lac/block_sparse_matrix.h>
155 * #include <deal.II/lac/solver_cg.h>
156 * #include <deal.II/lac/precondition.h>
157 * #include <deal.II/lac/affine_constraints.h>
159 * #include <deal.II/grid/
tria.h>
160 * #include <deal.II/grid/grid_generator.h>
161 * #include <deal.II/grid/tria_accessor.h>
162 * #include <deal.II/grid/tria_iterator.h>
163 * #include <deal.II/grid/grid_tools.h>
164 * #include <deal.II/grid/manifold_lib.h>
165 * #include <deal.II/grid/grid_refinement.h>
166 * #include <deal.II/grid/grid_in.h>
168 * #include <deal.II/dofs/dof_handler.h>
169 * #include <deal.II/dofs/dof_renumbering.h>
170 * #include <deal.II/dofs/dof_accessor.h>
171 * #include <deal.II/dofs/dof_tools.h>
173 * #include <deal.II/fe/fe_q.h>
174 * #include <deal.II/fe/fe_system.h>
175 * #include <deal.II/fe/fe_values.h>
177 * #include <deal.II/numerics/vector_tools.h>
178 * #include <deal.II/numerics/matrix_tools.h>
179 * #include <deal.II/numerics/data_out.h>
180 * #include <deal.II/numerics/error_estimator.h>
181 * #include <deal.II/numerics/derivative_approximation.h>
182 * #include <deal.II/numerics/fe_field_function.h>
184 * #include <deal.II/lac/sparse_direct.h>
185 * #include <deal.II/lac/sparse_ilu.h>
187 * #include <iostream>
195 * #include <armadillo>
198 * #include
"../support_code/ellipsoid_grav.h"
199 * #include
"../support_code/ellipsoid_fit.h"
200 * #include
"../support_code/config_in.h"
204 * As in all programs, the
namespace dealii
212 *
using namespace arma;
215 *
struct InnerPreconditioner;
218 *
struct InnerPreconditioner<2>
224 *
struct InnerPreconditioner<3>
248 *
const double curl = (grad_u[1][0] - grad_u[0][1]);
250 *
const double angle = std::atan(curl);
252 *
const double t[2][2] = { {
cos(angle),
sin(angle) }, {
262 * Class
for remembering material state/properties at each quadrature
point
269 *
struct PointHistory
272 *
double old_phiphi_stress;
280 * Primary
class of this problem
287 *
class StokesProblem
290 * StokesProblem(
const unsigned int degree);
295 *
void assemble_system();
297 *
void output_results()
const;
298 *
void refine_mesh();
299 *
void solution_stesses();
300 *
void smooth_eta_field(std::vector<bool> failing_cells);
302 *
void setup_initial_mesh();
303 *
void do_elastic_steps();
304 *
void do_flow_step();
305 *
void update_time_interval();
306 *
void initialize_eta_and_G();
308 *
void do_ellipse_fits();
309 *
void append_physical_times(
int max_plastic);
310 *
void write_vertices(
unsigned char);
312 *
void setup_quadrature_point_history();
313 *
void update_quadrature_point_history();
315 *
const unsigned int degree;
321 *
unsigned int n_u = 0, n_p = 0;
322 *
unsigned int plastic_iteration = 0;
323 *
unsigned int last_max_plasticity = 0;
326 * std::vector< std::vector <Vector<double> > > quad_viscosities;
327 * std::vector<double> cell_viscosities;
328 * std::vector<PointHistory<dim> > quadrature_point_history;
338 * std::shared_ptr<typename InnerPreconditioner<dim>::type> A_preconditioner;
340 * ellipsoid_fit<dim> ellipsoid;
345 * Class
for boundary conditions and rhs
352 *
class BoundaryValuesP:
public Function<dim>
355 * BoundaryValuesP() :
361 * const unsigned
int component = 0) const override;
367 *
double BoundaryValuesP<dim>::value(
const Point<dim> &p,
368 *
const unsigned int component)
const
370 *
Assert(component < this->n_components,
371 * ExcIndexRange (component, 0, this->n_components));
375 *
Assert(p[0] >= -10.0, ExcLowerRangeType<double>(p[0], -10.0));
381 *
void BoundaryValuesP<dim>::vector_value(
const Point<dim> &p,
384 *
for (
unsigned int c = 0; c < this->n_components; ++c)
385 *
values(c) = BoundaryValuesP<dim>::value(p, c);
389 *
class RightHandSide:
public Function<dim>
392 * RightHandSide () :
Function<dim>(dim+1) {}
398 *
virtual double value(
const Point<dim> &p,
const unsigned int component,
399 * A_Grav_namespace::AnalyticGravity<dim> *aGrav)
const;
402 * A_Grav_namespace::AnalyticGravity<dim> *aGrav)
const;
406 * A_Grav_namespace::AnalyticGravity<dim> *aGrav)
const;
411 *
double RightHandSide<dim>::value(
const Point<dim> &p,
412 *
const unsigned int component,
413 * A_Grav_namespace::AnalyticGravity<dim> *aGrav)
const
416 * std::vector<double> temp_vector(2);
417 * aGrav->get_gravity(p, temp_vector);
419 *
if (component == 0)
421 *
return temp_vector[0] + system_parameters::omegasquared * p[0];
425 *
if (component == 1)
426 *
return temp_vector[1];
433 *
void RightHandSide<dim>::vector_value(
const Point<dim> &p,
435 * A_Grav_namespace::AnalyticGravity<dim> *aGrav)
const
437 *
for (
unsigned int c = 0; c < this->n_components; ++c)
438 *
values(c) = RightHandSide<dim>::value(p, c, aGrav);
442 *
void RightHandSide<dim>::vector_value_list(
445 * A_Grav_namespace::AnalyticGravity<dim> *aGrav)
const
449 *
check whether component is in
450 * the
valid range is up to the
455 * ExcDimensionMismatch(
values.size(), points.size()));
457 *
for (
unsigned int i = 0; i < points.size(); ++i)
458 * this->vector_value(points[i], values[i], aGrav);
463 * Class
for linear solvers and preconditioners
469 *
template<
class Matrix,
class Preconditioner>
473 * InverseMatrix(
const Matrix &m,
const Preconditioner &preconditioner);
482 *
template<
class Matrix,
class Preconditioner>
483 * InverseMatrix<Matrix, Preconditioner>::InverseMatrix(
const Matrix &m,
484 *
const Preconditioner &preconditioner) :
485 *
matrix(&m), preconditioner(&preconditioner)
489 * template<class Matrix, class Preconditioner>
490 * void InverseMatrix<Matrix, Preconditioner>::vmult(
Vector<double> &dst,
491 * const
Vector<double> &src) const
499 * cg.solve(*matrix, dst, src, *preconditioner);
504 * Class
for the SchurComplement
510 *
template<
class Preconditioner>
526 *
template<
class Preconditioner>
527 * SchurComplement<Preconditioner>::SchurComplement(
530 * system_matrix(&system_matrix), A_inverse(&A_inverse), tmp1(
531 * system_matrix.block(0, 0).m()), tmp2(
532 * system_matrix.block(0, 0).m())
536 * template<class Preconditioner>
537 * void SchurComplement<Preconditioner>::vmult(
Vector<double> &dst,
538 * const
Vector<double> &src) const
540 * system_matrix->block(0, 1).vmult(tmp1, src);
541 * A_inverse->vmult(tmp2, tmp1);
542 * system_matrix->block(1, 0).vmult(dst, tmp2);
547 * StokesProblem::StokesProblem
554 * StokesProblem<dim>::StokesProblem(
const unsigned int degree) :
558 * fe(
FE_Q<dim>(degree + 1), dim,
FE_Q<dim>(degree), 1),
560 * quadrature_formula(degree + 2),
573 * void StokesProblem<dim>::setup_dofs()
575 * A_preconditioner.reset();
576 * system_matrix.clear();
578 * dof_handler.distribute_dofs(fe);
581 * std::vector<unsigned int> block_component(dim + 1, 0);
582 * block_component[dim] = 1;
587 * ========================================Apply Boundary Conditions=====================================
591 * constraints.clear();
592 * std::vector<bool> component_maskP(dim + 1,
false);
593 * component_maskP[dim] =
true;
596 * BoundaryValuesP<dim>(), constraints, component_maskP);
599 * std::set<types::boundary_id> no_normal_flux_boundaries;
600 * no_normal_flux_boundaries.insert(99);
602 * no_normal_flux_boundaries, constraints);
605 * constraints.close();
608 * n_u = dofs_per_block[0];
609 * n_p = dofs_per_block[1];
611 * std::cout <<
" Number of active cells: " <<
triangulation.n_active_cells()
612 * << std::endl <<
" Number of degrees of freedom: "
613 * << dof_handler.n_dofs() <<
" (" << n_u <<
'+' << n_p <<
')'
619 * csp.block(0, 0).reinit(n_u, n_u);
620 * csp.block(1, 0).reinit(n_p, n_u);
621 * csp.block(0, 1).reinit(n_u, n_p);
622 * csp.block(1, 1).reinit(n_p, n_p);
624 * csp.collect_sizes();
627 * sparsity_pattern.copy_from(csp);
630 * system_matrix.reinit(sparsity_pattern);
632 * solution.reinit(2);
633 * solution.block(0).reinit(n_u);
634 * solution.block(1).reinit(n_p);
635 * solution.collect_sizes();
637 * system_rhs.reinit(2);
638 * system_rhs.block(0).reinit(n_u);
639 * system_rhs.block(1).reinit(n_p);
640 * system_rhs.collect_sizes();
656 *
double get_eta(
double &r,
double &z);
657 *
double get_G(
unsigned int mat_id);
660 * std::vector<double> get_manual_eta_profile();
665 * std::vector<double> Rheology<dim>::get_manual_eta_profile()
667 * vector<double> etas;
669 *
for (
unsigned int i=0; i < system_parameters::sizeof_depths_eta; ++i)
671 * etas.push_back(system_parameters::depths_eta[i]);
672 * etas.push_back(system_parameters::eta_kinks[i]);
678 *
double Rheology<dim>::get_eta(
double &r,
double &z)
682 * compute local
depth
685 *
double ecc = system_parameters::q_axes[0] / system_parameters::p_axes[0];
686 *
double Rminusr = system_parameters::q_axes[0] - system_parameters::p_axes[0];
687 *
double approx_a =
std::sqrt(r * r + z * z * ecc * ecc);
688 *
double group1 = r * r + z * z - Rminusr * Rminusr;
690 *
double a0 = approx_a;
691 *
double error = 10000;
694 * While
loop finds the a axis of the
"isodepth" ellipse
for which the input
point is on the surface.
695 * An
"isodepth" ellipse is defined as one whose axes a,
b are related to the global axes A, B by: A-h = B-h
701 *
if ((r > system_parameters::q_axes[0] - system_parameters::depths_eta.back()) ||
702 * (z > system_parameters::p_axes[0] - system_parameters::depths_eta.back()))
706 *
while (error >= eps)
708 *
double a02 = a0 * a0;
709 *
double a03 = a0 * a02;
710 *
double a04 = a0 * a03;
711 *
double fofa = a04 - (2 * Rminusr * a03) - (group1 * a02)
712 * + (2 * r * r * Rminusr * a0) - (r * r * Rminusr * Rminusr);
713 *
double fprimeofa = 4 * a03 - (6 * Rminusr * a02) - (2 * group1 * a0)
714 * + (2 * r * r * Rminusr);
715 *
double deltaa = -fofa / fprimeofa;
720 * cout <<
"error = " << error << endl;
730 *
double local_depth = system_parameters::q_axes[0] - a0;
731 *
if (local_depth < 0)
734 *
if (local_depth > system_parameters::depths_eta.back())
736 *
if (system_parameters::eta_kinks.back() < system_parameters::eta_floor)
737 *
return system_parameters::eta_floor;
738 *
else if (system_parameters::eta_kinks.back() > system_parameters::eta_ceiling)
739 *
return system_parameters::eta_ceiling;
741 *
return system_parameters::eta_kinks.back();
744 * std::vector<double> viscosity_function = get_manual_eta_profile();
746 *
unsigned int n_visc_kinks = viscosity_function.size() / 2;
750 * find the correct interval to
do the interpolation in
753 *
int n_minus_one = -1;
754 *
for (
unsigned int n = 1; n <= n_visc_kinks; ++n)
756 *
unsigned int ndeep = 2 * n - 2;
757 *
unsigned int nshallow = 2 * n;
758 *
if (local_depth >= viscosity_function[ndeep] && local_depth <= viscosity_function[nshallow])
759 * n_minus_one = ndeep;
764 * find the viscosity interpolation
767 *
if (n_minus_one == -1)
768 *
return system_parameters::eta_ceiling;
771 *
double visc_exponent =
772 * (viscosity_function[n_minus_one]
774 * / (viscosity_function[n_minus_one]
775 * - viscosity_function[n_minus_one + 2]);
776 *
double visc_base = viscosity_function[n_minus_one + 3]
777 * / viscosity_function[n_minus_one + 1];
780 * This is the
true viscosity given the thermal profile
783 *
double true_eta = viscosity_function[n_minus_one + 1] *
std::pow(visc_base, visc_exponent);
787 * Implement latitude-dependence viscosity
790 *
if (system_parameters::lat_dependence)
792 *
double lat = 180 / PI * std::atan(z / r);
797 *
double taper_depth = 40000;
798 *
double surface_taper = (taper_depth - local_depth) / taper_depth;
799 *
if (surface_taper < 0)
801 *
double log_eta_contrast = surface_taper * system_parameters::eta_Ea * 52.5365 * (T_eq - T_surf) / T_eq / T_surf;
802 * true_eta *=
std::pow(10, log_eta_contrast);
805 *
if (true_eta > system_parameters::eta_ceiling)
806 *
return system_parameters::eta_ceiling;
807 *
else if (true_eta < system_parameters::eta_floor)
808 *
return system_parameters::eta_floor;
816 *
double Rheology<dim>::get_G(
unsigned int mat_id)
818 *
return system_parameters::G[mat_id];
824 * Initialize the eta and G parts of the quadrature_point_history
object
831 *
void StokesProblem<dim>::initialize_eta_and_G()
835 *
const unsigned int n_q_points = quadrature_formula.size();
836 * Rheology<dim> rheology;
839 * dof_handler.begin_active(); cell != dof_handler.end(); ++cell)
841 * PointHistory<dim> *local_quadrature_points_history =
842 *
reinterpret_cast<PointHistory<dim> *
>(cell->user_pointer());
844 * local_quadrature_points_history >= &quadrature_point_history.front(),
845 * ExcInternalError());
847 * local_quadrature_points_history < &quadrature_point_history.back(),
848 * ExcInternalError());
849 * fe_values.reinit(cell);
851 *
for (
unsigned int q = 0; q < n_q_points; ++q)
854 *
double r_value = fe_values.quadrature_point(q)[0];
855 *
double z_value = fe_values.quadrature_point(q)[1];
859 * defines local viscosity
862 *
double local_viscosity = 0;
864 * local_viscosity = rheology.get_eta(r_value, z_value);
866 * local_quadrature_points_history[q].first_eta = local_viscosity;
867 * local_quadrature_points_history[q].new_eta = local_viscosity;
871 * defines local shear modulus
874 *
double local_G = 0;
876 *
unsigned int mat_id = cell->material_id();
878 * local_G = rheology.get_G(mat_id);
879 * local_quadrature_points_history[q].G = local_G;
883 * initializes the phi-phi stress
886 * local_quadrature_points_history[q].old_phiphi_stress = 0;
893 * ====================== ASSEMBLE THE SYSTEM ======================
900 *
void StokesProblem<dim>::assemble_system()
909 *
const unsigned int dofs_per_cell = fe.dofs_per_cell;
911 *
const unsigned int n_q_points = quadrature_formula.size();
916 * std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
920 * runs the gravity script function
923 *
const RightHandSide<dim> right_hand_side;
925 * A_Grav_namespace::AnalyticGravity<dim> *aGrav =
926 *
new A_Grav_namespace::AnalyticGravity<dim>;
927 * std::vector<double> grav_parameters;
928 * grav_parameters.push_back(system_parameters::q_axes[system_parameters::present_timestep * 2 + 0]);
929 * grav_parameters.push_back(system_parameters::p_axes[system_parameters::present_timestep * 2 + 0]);
930 * grav_parameters.push_back(system_parameters::q_axes[system_parameters::present_timestep * 2 + 1]);
931 * grav_parameters.push_back(system_parameters::p_axes[system_parameters::present_timestep * 2 + 1]);
932 * grav_parameters.push_back(system_parameters::rho[0]);
933 * grav_parameters.push_back(system_parameters::rho[1]);
935 * std::cout <<
"Body parameters are: " ;
936 *
for (
int i=0; i<6; ++i)
937 * std::cout << grav_parameters[i] <<
" ";
940 * aGrav->setup_vars(grav_parameters);
942 * std::vector<Vector<double> > rhs_values(n_q_points,
948 * std::vector<SymmetricTensor<2, dim> > phi_grads_u(dofs_per_cell);
949 * std::vector<double> div_phi_u(dofs_per_cell);
950 * std::vector<Tensor<1, dim> > phi_u(dofs_per_cell);
951 * std::vector<double> phi_p(dofs_per_cell);
954 * dof_handler.begin_active(), first_cell = dof_handler.begin_active(),
955 * endc = dof_handler.end();
957 *
for (; cell != endc; ++cell)
959 * PointHistory<dim> *local_quadrature_points_history =
960 *
reinterpret_cast<PointHistory<dim> *
>(cell->user_pointer());
962 * local_quadrature_points_history >= &quadrature_point_history.front(),
963 * ExcInternalError());
965 * local_quadrature_points_history < &quadrature_point_history.back(),
966 * ExcInternalError());
968 *
double cell_area = cell->measure();
971 * append_physical_times(-1);
974 * ExcInternalError());
977 *
unsigned int m_id = cell->material_id();
981 * initializes the rhs vector to the correct g
values
984 * fe_values.reinit(cell);
985 * right_hand_side.vector_value_list(fe_values.get_quadrature_points(),
986 * rhs_values, aGrav);
988 * std::vector<Vector<double> > new_viscosities(quadrature_formula.size(),
Vector<double>(dim + 1));
992 * Finds
vertices where the radius is zero DIM
995 *
bool is_singular =
false;
996 *
for (
unsigned int f = 0; f < GeometryInfo<dim>::faces_per_cell; ++f)
997 *
if (cell->face(f)->center()[0] == 0)
998 * is_singular =
true;
1000 *
if (is_singular ==
false || system_parameters::cylindrical ==
false)
1007 * ===== outputs the local gravity
1010 * std::vector<Point<dim> > quad_points_list(n_q_points);
1011 * quad_points_list = fe_values.get_quadrature_points();
1013 *
if (plastic_iteration
1014 * == (system_parameters::max_plastic_iterations - 1))
1016 *
if (cell != first_cell)
1018 * std::ofstream fout(
"gravity_field.txt", std::ios::app);
1019 * fout << quad_points_list[0] <<
" " << rhs_values[0];
1024 * std::ofstream fout(
"gravity_field.txt");
1025 * fout << quad_points_list[0] <<
" " << rhs_values[0];
1030 *
for (
unsigned int q = 0; q < n_q_points; ++q)
1033 * local_quadrature_points_history[q].old_stress;
1034 *
double &local_old_phiphi_stress =
1035 * local_quadrature_points_history[q].old_phiphi_stress;
1036 *
double r_value = fe_values.quadrature_point(q)[0];
1040 * get local density based on mat
id
1043 *
double local_density = system_parameters::rho[m_id];
1047 * defines local viscosities
1050 *
double local_viscosity = 0;
1051 *
if (plastic_iteration == 0)
1052 * local_viscosity = local_quadrature_points_history[q].first_eta;
1054 * local_viscosity = local_quadrature_points_history[q].new_eta;
1058 * Define the local viscoelastic constants
1061 *
double local_eta_ve = 2
1062 * / ((1 / local_viscosity)
1063 * + (1 / local_quadrature_points_history[q].G
1064 * / system_parameters::current_time_interval));
1065 *
double local_chi_ve = 1
1067 * + (local_quadrature_points_history[q].G
1068 * * system_parameters::current_time_interval
1069 * / local_viscosity));
1071 *
for (
unsigned int k = 0; k < dofs_per_cell; ++k)
1073 * phi_grads_u[k] = fe_values[velocities].symmetric_gradient(k,
1075 * div_phi_u[k] = (fe_values[velocities].divergence(k, q));
1076 * phi_u[k] = (fe_values[velocities].value(k, q));
1077 *
if (system_parameters::cylindrical ==
true)
1079 * div_phi_u[k] *= (r_value);
1080 * div_phi_u[k] += (phi_u[k][0]);
1082 * phi_p[k] = fe_values[pressure].value(k, q);
1085 *
for (
unsigned int i = 0; i < dofs_per_cell; ++i)
1087 *
for (
unsigned int j = 0; j <= i; ++j)
1089 *
if (system_parameters::cylindrical ==
true)
1091 * local_matrix(i, j) += (phi_grads_u[i]
1092 * * phi_grads_u[j] * 2 * local_eta_ve
1094 * + 2 * phi_u[i][0] * phi_u[j][0]
1095 * * local_eta_ve / r_value
1096 * - div_phi_u[i] * phi_p[j]
1097 * * system_parameters::pressure_scale
1098 * - phi_p[i] * div_phi_u[j]
1099 * * system_parameters::pressure_scale
1100 * + phi_p[i] * phi_p[j] * r_value
1101 * * system_parameters::pressure_scale)
1102 * * fe_values.JxW(q);
1106 * local_matrix(i, j) += (phi_grads_u[i]
1107 * * phi_grads_u[j] * 2 * local_eta_ve
1108 * - div_phi_u[i] * phi_p[j]
1109 * * system_parameters::pressure_scale
1110 * - phi_p[i] * div_phi_u[j]
1111 * * system_parameters::pressure_scale
1112 * + phi_p[i] * phi_p[j]) * fe_values.JxW(q);
1115 *
if (system_parameters::cylindrical ==
true)
1117 *
const unsigned int component_i =
1118 * fe.system_to_component_index(i).first;
1119 * local_rhs(i) += (fe_values.shape_value(i, q)
1120 * * rhs_values[q](component_i) * r_value
1122 * - local_chi_ve * phi_grads_u[i] * old_stress
1124 * - local_chi_ve * phi_u[i][0]
1125 * * local_old_phiphi_stress)
1126 * * fe_values.JxW(q);
1130 *
const unsigned int component_i =
1131 * fe.system_to_component_index(i).first;
1132 * local_rhs(i) += fe_values.shape_value(i, q)
1133 * * rhs_values[q](component_i) * fe_values.JxW(q)
1146 * ===== outputs the local gravity
1149 * std::vector<Point<dim> > quad_points_list(n_q_points);
1150 * quad_points_list = fe_values.get_quadrature_points();
1152 *
for (
unsigned int q = 0; q < n_q_points; ++q)
1155 * local_quadrature_points_history[q].old_stress;
1156 *
double &local_old_phiphi_stress =
1157 * local_quadrature_points_history[q].old_phiphi_stress;
1158 *
double r_value = fe_values.quadrature_point(q)[0];
1160 *
double local_density = system_parameters::rho[m_id];
1164 * defines local viscosities
1167 *
double local_viscosity = 0;
1168 *
if (plastic_iteration == 0)
1170 * local_viscosity = local_quadrature_points_history[q].first_eta;
1173 * local_viscosity = local_quadrature_points_history[q].new_eta;
1177 * Define the local viscoelastic constants
1180 *
double local_eta_ve = 2
1181 * / ((1 / local_viscosity)
1182 * + (1 / local_quadrature_points_history[q].G
1183 * / system_parameters::current_time_interval));
1184 *
double local_chi_ve = 1
1186 * + (local_quadrature_points_history[q].G
1187 * * system_parameters::current_time_interval
1188 * / local_viscosity));
1190 *
for (
unsigned int k = 0; k < dofs_per_cell; ++k)
1192 * phi_grads_u[k] = fe_values[velocities].symmetric_gradient(k,
1194 * div_phi_u[k] = (fe_values[velocities].divergence(k, q));
1195 * phi_u[k] = (fe_values[velocities].value(k, q));
1196 *
if (system_parameters::cylindrical ==
true)
1198 * div_phi_u[k] *= (r_value);
1199 * div_phi_u[k] += (phi_u[k][0]);
1201 * phi_p[k] = fe_values[pressure].value(k, q);
1204 *
for (
unsigned int i = 0; i < dofs_per_cell; ++i)
1206 *
for (
unsigned int j = 0; j <= i; ++j)
1208 *
if (system_parameters::cylindrical ==
true)
1210 * local_matrix(i, j) += (phi_grads_u[i]
1211 * * phi_grads_u[j] * 2 * local_eta_ve
1213 * + 2 * phi_u[i][0] * phi_u[j][0]
1214 * * local_eta_ve / r_value
1215 * - div_phi_u[i] * phi_p[j]
1216 * * system_parameters::pressure_scale
1217 * - phi_p[i] * div_phi_u[j]
1218 * * system_parameters::pressure_scale
1219 * + phi_p[i] * phi_p[j] * r_value
1220 * * system_parameters::pressure_scale)
1221 * * fe_values.JxW(q);
1225 * local_matrix(i, j) += (phi_grads_u[i]
1226 * * phi_grads_u[j] * 2 * local_eta_ve
1227 * - div_phi_u[i] * phi_p[j]
1228 * * system_parameters::pressure_scale
1229 * - phi_p[i] * div_phi_u[j]
1230 * * system_parameters::pressure_scale
1231 * + phi_p[i] * phi_p[j]) * fe_values.JxW(q);
1234 *
if (system_parameters::cylindrical ==
true)
1236 *
const unsigned int component_i =
1237 * fe.system_to_component_index(i).first;
1238 * local_rhs(i) += (fe_values.shape_value(i, q)
1239 * * rhs_values[q](component_i) * r_value
1241 * - local_chi_ve * phi_grads_u[i] * old_stress
1243 * - local_chi_ve * phi_u[i][0]
1244 * * local_old_phiphi_stress)
1245 * * fe_values.JxW(q);
1249 *
const unsigned int component_i =
1250 * fe.system_to_component_index(i).first;
1251 * local_rhs(i) += fe_values.shape_value(i, q)
1252 * * rhs_values[q](component_i) * fe_values.JxW(q)
1259 *
for (
unsigned int i = 0; i < dofs_per_cell; ++i)
1260 *
for (
unsigned int j = i + 1; j < dofs_per_cell; ++j)
1261 * local_matrix(i, j) = local_matrix(j, i);
1263 * cell->get_dof_indices(local_dof_indices);
1264 * constraints.distribute_local_to_global(local_matrix, local_rhs,
1265 * local_dof_indices, system_matrix, system_rhs);
1268 * std::cout <<
" Computing preconditioner..." << std::endl << std::flush;
1270 * A_preconditioner = std::shared_ptr<
1271 *
typename InnerPreconditioner<dim>::type>(
1272 *
new typename InnerPreconditioner<dim>::type());
1273 * A_preconditioner->initialize(system_matrix.block(0, 0),
1274 *
typename InnerPreconditioner<dim>::type::AdditionalData());
1281 * ====================== SOLVER ======================
1288 *
void StokesProblem<dim>::solve()
1290 *
const InverseMatrix<SparseMatrix<double>,
1291 *
typename InnerPreconditioner<dim>::type> A_inverse(
1292 * system_matrix.block(0, 0), *A_preconditioner);
1297 * A_inverse.vmult(tmp, system_rhs.block(0));
1298 * system_matrix.block(1, 0).vmult(schur_rhs, tmp);
1299 * schur_rhs -= system_rhs.block(1);
1301 * SchurComplement<typename InnerPreconditioner<dim>::type>
schur_complement(
1302 * system_matrix, A_inverse);
1304 *
int n_iterations = system_parameters::iteration_coefficient
1305 * * solution.block(1).size();
1306 *
double tolerance_goal = system_parameters::tolerance_coefficient
1307 * * schur_rhs.l2_norm();
1309 *
SolverControl solver_control(n_iterations, tolerance_goal);
1312 * std::cout <<
"\nMax iterations and tolerance are: " << n_iterations
1313 * <<
" and " << tolerance_goal << std::endl;
1316 * preconditioner.
initialize(system_matrix.block(1, 1),
1320 * system_matrix.block(1, 1), preconditioner);
1324 * constraints.distribute(solution);
1327 * std::cout <<
" " << solver_control.last_step()
1328 * <<
" outer CG Schur complement iterations for pressure"
1333 * system_matrix.block(0, 1).vmult(tmp, solution.block(1));
1335 * tmp += system_rhs.block(0);
1337 * A_inverse.vmult(solution.block(0), tmp);
1338 * constraints.distribute(solution);
1339 * solution.block(1) *= (system_parameters::pressure_scale);
1345 * ====================== OUTPUT RESULTS ======================
1349 *
void StokesProblem<dim>::output_results() const
1351 * std::vector < std::string > solution_names(dim,
"velocity");
1352 * solution_names.push_back(
"pressure");
1354 * std::vector<DataComponentInterpretation::DataComponentInterpretation> data_component_interpretation(
1356 * data_component_interpretation.push_back(
1361 * data_out.add_data_vector(solution, solution_names,
1363 * data_out.build_patches();
1365 * std::ostringstream filename;
1366 *
if (system_parameters::present_timestep < system_parameters::initial_elastic_iterations)
1368 * filename << system_parameters::output_folder <<
"/time"
1370 * <<
"_elastic_displacements" <<
".txt";
1374 * filename << system_parameters::output_folder <<
"/time"
1379 * std::ofstream output(filename.str().c_str());
1380 * data_out.write_gnuplot(output);
1385 * ====================== FIND AND WRITE TO FILE THE STRESS TENSOR; IMPLEMENT PLASTICITY ======================
1392 *
void StokesProblem<dim>::solution_stesses()
1396 * note most of
this section only works with dim=2
1400 * name the output text files
1403 * std::ostringstream stress_output;
1404 * stress_output << system_parameters::output_folder <<
"/time"
1408 * std::ofstream fout_snew(stress_output.str().c_str());
1409 * fout_snew.close();
1411 * std::ostringstream stresstensor_output;
1412 * stresstensor_output << system_parameters::output_folder <<
"/time"
1416 * std::ofstream fout_sfull(stresstensor_output.str().c_str());
1417 * fout_sfull.close();
1419 * std::ostringstream failed_cells_output;
1420 * failed_cells_output << system_parameters::output_folder <<
"/time"
1424 * std::ofstream fout_failed_cells(failed_cells_output.str().c_str());
1425 * fout_failed_cells.close();
1427 * std::ostringstream plastic_eta_output;
1428 * plastic_eta_output << system_parameters::output_folder <<
"/time"
1432 * std::ofstream fout_vrnew(plastic_eta_output.str().c_str());
1433 * fout_vrnew.close();
1435 * std::ostringstream initial_eta_output;
1436 *
if (plastic_iteration == 0)
1438 * initial_eta_output << system_parameters::output_folder <<
"/time"
1440 * <<
"_baseviscosities.txt";
1441 * std::ofstream fout_baseeta(initial_eta_output.str().c_str());
1442 * fout_baseeta.close();
1445 * std::cout <<
"Running stress calculations for plasticity iteration "
1446 * << plastic_iteration <<
"...\n";
1450 * This makes the
set of points at which the stress tensor is calculated
1453 * std::vector<Point<dim> > points_list(0);
1454 * std::vector<unsigned int> material_list(0);
1456 * dof_handler.begin_active(), endc = dof_handler.end();
1459 * This
loop gets the
gradients of the velocity field and saves it in the tensor_gradient_? objects DIM
1462 *
for (; cell != endc; ++cell)
1464 * points_list.push_back(cell->center());
1465 * material_list.push_back(cell->material_id());
1469 * Make the
FEValues object to evaluate
values and derivatives at quadrature points
1477 * Make the
object that will hold the velocities and velocity
gradients at the quadrature points
1480 * std::vector < std::vector<Tensor<1, dim> >> velocity_grads(quadrature_formula.size(),
1482 * std::vector<Vector<double> > velocities(quadrature_formula.size(),
1486 * Make the
object to find rheology
1489 * Rheology<dim> rheology;
1493 * Write the solution flow velocity and derivative
for each cell
1496 * std::vector<Vector<double> > vector_values(0);
1497 * std::vector < std::vector<Tensor<1, dim> > > gradient_values(0);
1498 * std::vector<bool> failing_cells;
1501 * Write the stresses from the previous step into vectors
1504 * std::vector<SymmetricTensor<2, dim>> old_stress;
1505 * std::vector<double> old_phiphi_stress;
1506 * std::vector<double> cell_Gs;
1508 * dof_handler.begin_active(); cell != dof_handler.end(); ++cell)
1512 * Makes pointer to data in quadrature_point_history
1515 * PointHistory<dim> *local_quadrature_points_history =
1516 *
reinterpret_cast<PointHistory<dim> *
>(cell->user_pointer());
1518 * fe_values.reinit(cell);
1519 * fe_values.get_function_gradients(solution, velocity_grads);
1520 * fe_values.get_function_values(solution, velocities);
1522 * std::vector<Tensor<1, dim>> current_cell_grads(dim+1);
1524 * current_cell_old_stress = 0;
1525 *
double current_cell_old_phiphi_stress = 0;
1526 *
double cell_area = 0;
1530 * Averages across each cell to find
mean velocities,
gradients, and old stresses
1533 *
for (
unsigned int q = 0; q < quadrature_formula.size(); ++q)
1535 * cell_area += fe_values.JxW(q);
1536 * velocities[q] *= fe_values.JxW(q);
1537 * current_cell_velocity += velocities[q];
1538 *
for (
unsigned int i = 0; i < (dim+1); ++i)
1540 * velocity_grads[q][i] *= fe_values.JxW(q);
1541 * current_cell_grads[i] += velocity_grads[q][i];
1543 * current_cell_old_stress += local_quadrature_points_history[q].old_stress * fe_values.JxW(q);
1544 * current_cell_old_phiphi_stress += local_quadrature_points_history[q].old_phiphi_stress * fe_values.JxW(q);
1546 * current_cell_velocity /= cell_area;
1547 *
for (
unsigned int i = 0; i < (dim+1); ++i)
1548 * current_cell_grads[i] /= cell_area;
1549 * current_cell_old_stress /= cell_area;
1550 * current_cell_old_phiphi_stress /= cell_area;
1552 * vector_values.push_back(current_cell_velocity);
1553 * gradient_values.push_back(current_cell_grads);
1554 * old_stress.push_back(current_cell_old_stress);
1555 * old_phiphi_stress.push_back(current_cell_old_phiphi_stress);
1559 * Get cell shear modulus: assumes it
's constant for the cell
1562 * unsigned int mat_id = cell->material_id();
1563 * double local_G = rheology.get_G(mat_id);
1564 * cell_Gs.push_back(local_G);
1569 * tracks where failure occurred
1572 * std::vector<double> reduction_factor;
1573 * unsigned int total_fails = 0;
1574 * if (plastic_iteration == 0)
1575 * cell_viscosities.resize(0);
1578 * loop across all the cells to find and adjust eta of failing cells
1581 * for (unsigned int i = 0; i < triangulation.n_active_cells(); ++i)
1583 * double current_cell_viscosity = 0;
1587 * Fill viscosities vector, analytically if plastic_iteration == 0 and from previous viscosities for later iteration
1590 * if (plastic_iteration == 0)
1592 * double local_viscosity;
1593 * local_viscosity = rheology.get_eta(points_list[i][0], points_list[i][1]);
1594 * current_cell_viscosity = local_viscosity;
1595 * cell_viscosities.push_back(current_cell_viscosity);
1599 * current_cell_viscosity = cell_viscosities[i];
1603 * double cell_eta_ve = 2
1604 * / ((1 / current_cell_viscosity)
1606 * / system_parameters::current_time_interval));
1607 * double cell_chi_ve = 1
1610 * * system_parameters::current_time_interval
1611 * / current_cell_viscosity));
1615 * find local pressure
1618 * double cell_p = vector_values[i].operator()(2);
1621 * find stresses tensor
1622 * makes non-diagonalized local matrix A
1625 * double sigma13 = 0.5
1626 * * (gradient_values[i][0][1] + gradient_values[i][1][0]);
1628 * A << gradient_values[i][0][0] << 0 << sigma13 << endr
1629 * << 0 << vector_values[i].operator()(0) / points_list[i].operator()(0)<< 0 << endr
1630 * << sigma13 << 0 << gradient_values[i][1][1] << endr;
1632 * olddevstress << old_stress[i][0][0] << 0 << old_stress[i][0][1] << endr
1633 * << 0 << old_phiphi_stress[i] << 0 << endr
1634 * << old_stress[i][0][1] << 0 << old_stress[i][1][1] << endr;
1636 * P << cell_p << cell_p << cell_p;
1637 * mat Pmat = diagmat(P);
1639 * B = (cell_eta_ve * A + cell_chi_ve * olddevstress) - Pmat;
1643 * finds principal stresses
1648 * eig_sym(eigval, eigvec, B);
1649 * double sigma1 = -min(eigval);
1650 * double sigma3 = -max(eigval);
1654 * Writes text files for principal stresses, full stress tensor, base viscosities
1657 * std::ofstream fout_snew(stress_output.str().c_str(), std::ios::app);
1658 * fout_snew << " " << sigma1 << " " << sigma3 << "\n";
1659 * fout_snew.close();
1661 * std::ofstream fout_sfull(stresstensor_output.str().c_str(), std::ios::app);
1662 * fout_sfull << A(0,0) << " " << A(1,1) << " " << A(2,2) << " " << A(0,2) << "\n";
1663 * fout_sfull.close();
1665 * if (plastic_iteration == 0)
1667 * std::ofstream fout_baseeta(initial_eta_output.str().c_str(), std::ios::app);
1668 * fout_baseeta << points_list[i]<< " " << current_cell_viscosity << "\n";
1669 * fout_baseeta.close();
1674 * Finds adjusted effective viscosity
1677 * if (system_parameters::plasticity_on)
1679 * if (system_parameters::failure_criterion == 0) //Apply Byerlee's rule
1681 *
if (sigma1 >= 5 * sigma3)
1683 * failing_cells.push_back(
true);
1684 *
double temp_reductionfactor = 1;
1686 * temp_reductionfactor = 100;
1688 * temp_reductionfactor = 1.9 * sigma1 / 5 / sigma3;
1690 * reduction_factor.push_back(temp_reductionfactor);
1695 * Text file of all failure locations
1698 * std::ofstream fout_failed_cells(failed_cells_output.str().c_str(), std::ios::app);
1699 * fout_failed_cells << points_list[i] <<
"\n";
1700 * fout_failed_cells.close();
1704 * reduction_factor.push_back(1);
1705 * failing_cells.push_back(
false);
1710 *
if (system_parameters::failure_criterion == 1)
1712 *
double temp_reductionfactor = 1;
1713 *
if (sigma3 < -114037)
1717 * std::cout <<
" ext ";
1720 * failing_cells.push_back(
true);
1721 * temp_reductionfactor = 10;
1722 * reduction_factor.push_back(temp_reductionfactor);
1727 * Text file of all failure locations
1730 * std::ofstream fout_failed_cells(failed_cells_output.str().c_str(), std::ios::app);
1731 * fout_failed_cells << points_list[i] <<
"\n";
1732 * fout_failed_cells.close();
1736 *
double sigma_c = 160e6;
1737 *
double yield_sigma1 = sigma3 +
std::sqrt( (3.086 * sigma_c * sigma3) + (0.002 * sigma3 * sigma3) );
1738 *
if (sigma1 >= yield_sigma1)
1742 * std::cout <<
" comp ";
1745 * failing_cells.push_back(
true);
1746 * temp_reductionfactor = 1.0 * sigma1 / 5 / sigma3;
1748 * reduction_factor.push_back(temp_reductionfactor);
1753 * Text file of all failure locations
1756 * std::ofstream fout_failed_cells(failed_cells_output.str().c_str(), std::ios::app);
1757 * fout_failed_cells << points_list[i] <<
"\n";
1758 * fout_failed_cells.close();
1762 * reduction_factor.push_back(1);
1763 * failing_cells.push_back(
false);
1769 * std::cout <<
"Specified failure criterion not found\n";
1774 * reduction_factor.push_back(1);
1779 * If there are enough failed cells, update eta at all quadrature points and perform smoothing
1782 * std::cout <<
" Number of failing cells: " << total_fails <<
"\n";
1783 *
double last_max_plasticity_double = last_max_plasticity;
1784 *
double total_fails_double = total_fails;
1785 *
double decrease_in_plasticity = ((last_max_plasticity_double - total_fails_double) / last_max_plasticity_double);
1786 *
if (plastic_iteration == 0)
1787 * decrease_in_plasticity = 1;
1788 * last_max_plasticity = total_fails;
1789 *
if (total_fails <= 100 || decrease_in_plasticity <= 0.2)
1791 * system_parameters::continue_plastic_iterations =
false;
1792 *
for (
unsigned int j=0; j <
triangulation.n_active_cells(); ++j)
1796 * Writes to file the undisturbed cell viscosities
1799 * std::ofstream fout_vrnew(plastic_eta_output.str().c_str(), std::ios::app);
1800 * fout_vrnew <<
" " << cell_viscosities[j] <<
"\n";
1801 * fout_vrnew.close();
1809 * Decrease the eta at quadrature points in failing cells
1812 *
unsigned int cell_no = 0;
1814 * dof_handler.begin_active(); cell != dof_handler.end(); ++cell)
1816 * fe_values.reinit(cell);
1819 * Make local_quadrature_points_history pointer to the cell data
1822 * PointHistory<dim> *local_quadrature_points_history =
1823 *
reinterpret_cast<PointHistory<dim> *
>(cell->user_pointer());
1825 * local_quadrature_points_history >= &quadrature_point_history.front(),
1826 * ExcInternalError());
1828 * local_quadrature_points_history < &quadrature_point_history.back(),
1829 * ExcInternalError());
1831 * quad_viscosities[cell_no].resize(quadrature_formula.size());
1833 *
for (
unsigned int q = 0; q < quadrature_formula.size(); ++q)
1835 *
if (plastic_iteration == 0)
1836 * local_quadrature_points_history[q].new_eta = local_quadrature_points_history[q].first_eta;
1837 * local_quadrature_points_history[q].new_eta /= reduction_factor[cell_no];
1840 * Prevents viscosities from dropping below the
floor necessary
for numerical stability
1843 *
if (local_quadrature_points_history[q].new_eta < system_parameters::eta_floor)
1844 * local_quadrature_points_history[q].new_eta = system_parameters::eta_floor;
1846 * quad_viscosities[cell_no][q].reinit(dim+1);
1847 *
for (
unsigned int ii=0; ii<dim; ++ii)
1848 * quad_viscosities[cell_no][q](ii) = fe_values.quadrature_point(q)[ii];
1849 * quad_viscosities[cell_no][q](dim) = local_quadrature_points_history[q].new_eta;
1853 * smooth_eta_field(failing_cells);
1857 * Writes to file the smoothed eta field (which is defined at each quadrature point)
for each cell
1863 * cell_viscosities.resize(
triangulation.n_active_cells(), 0);
1867 * dof_handler.begin_active(); cell != dof_handler.end(); ++cell)
1869 *
if (failing_cells[cell_no])
1871 * fe_values.reinit(cell);
1874 * Averages across each cell to find
mean eta
1877 *
double cell_area = 0;
1878 *
for (
unsigned int q = 0; q < quadrature_formula.size(); ++q)
1880 * cell_area += fe_values.JxW(q);
1881 * cell_viscosities[cell_no] += quad_viscosities[cell_no][q][dim] * fe_values.JxW(q);
1883 * cell_viscosities[cell_no] /= cell_area;
1890 * std::ofstream fout_vrnew(plastic_eta_output.str().c_str(), std::ios::app);
1891 * fout_vrnew <<
" " << cell_viscosities[cell_no] <<
"\n";
1892 * fout_vrnew.close();
1896 * std::ofstream fout_vrnew(plastic_eta_output.str().c_str(), std::ios::app);
1897 * fout_vrnew <<
" " << cell_viscosities[cell_no] <<
"\n";
1898 * fout_vrnew.close();
1907 * ====================== SMOOTHES THE VISCOSITY FIELD AT ALL QUADRATURE POINTS ======================
1914 *
void StokesProblem<dim>::smooth_eta_field(std::vector<bool> failing_cells)
1916 * std::cout <<
" Smoothing viscosity field...\n";
1917 *
unsigned int cell_no = 0;
1919 * dof_handler.begin_active(); cell != dof_handler.end(); ++cell)
1921 *
if (failing_cells[cell_no])
1924 * PointHistory<dim> *local_quadrature_points_history =
1925 *
reinterpret_cast<PointHistory<dim> *
>(cell->user_pointer());
1929 * Currently
this algorithm does not permit refinement. To permit refinement, daughter cells of neighbors must be identified
1930 * Find pointers and indices of all cells within certain radius
1933 *
bool find_more_cells =
true;
1934 * std::vector<bool> cell_touched(
triangulation.n_active_cells(),
false);
1935 * std::vector< TriaIterator< CellAccessor<dim> > > neighbor_cells;
1936 * std::vector<int> neighbor_indices;
1937 *
unsigned int start_cell = 0;
1938 *
int new_cells_found = 0;
1939 * neighbor_cells.push_back(cell);
1940 * neighbor_indices.push_back(cell_no);
1941 * cell_touched[cell_no] =
true;
1942 *
while (find_more_cells)
1944 * new_cells_found = 0;
1945 *
for (
unsigned int i = start_cell; i<neighbor_cells.size(); ++i)
1947 *
for (
unsigned int f = 0; f < GeometryInfo<dim>::faces_per_cell; ++f)
1949 *
if (!neighbor_cells[i]->face(f)->at_boundary())
1951 *
int test_cell_no = neighbor_cells[i]->neighbor_index(f);
1952 *
if (!cell_touched[test_cell_no])
1953 *
if (cell->center().distance(neighbor_cells[i]->neighbor(f)->center()) < 2 * system_parameters::smoothing_radius)
1957 * What to
do if another nearby cell is found that hasn
't been found before
1960 * neighbor_cells.push_back(neighbor_cells[i]->neighbor(f));
1961 * neighbor_indices.push_back(test_cell_no);
1962 * cell_touched[test_cell_no] = true;
1964 * new_cells_found++;
1969 * if (new_cells_found == 0)
1971 * find_more_cells = false;
1974 * start_cell = neighbor_cells.size() - new_cells_found;
1977 * fe_values.reinit(cell);
1980 * Collect the viscosities at nearby quadrature points
1983 * for (unsigned int q = 0; q < quadrature_formula.size(); ++q)
1985 * std::vector<double> nearby_etas_q;
1986 * for (unsigned int i = 0; i<neighbor_indices.size(); ++i)
1987 * for (unsigned int j=0; j<quadrature_formula.size(); ++j)
1989 * Point<dim> test_q;
1990 * for (unsigned int d=0; d<dim; ++d)
1991 * test_q(d) = quad_viscosities[neighbor_indices[i]][j][d];
1992 * double qq_distance = fe_values.quadrature_point(q).distance(test_q);
1993 * if (qq_distance < system_parameters::smoothing_radius)
1994 * nearby_etas_q.push_back(quad_viscosities[neighbor_indices[i]][j][dim]);
1998 * Write smoothed viscosities to quadrature_points_history; simple boxcar function is the smoothing kernel
2001 * double mean_eta = 0;
2002 * for (unsigned int l = 0; l<nearby_etas_q.size(); ++l)
2004 * mean_eta += nearby_etas_q[l];
2006 * mean_eta /= nearby_etas_q.size();
2007 * local_quadrature_points_history[q].new_eta = mean_eta;
2010 * std::cout << local_quadrature_points_history[q].new_eta << " ";
2021 * ====================== SAVE STRESS TENSOR AT QUADRATURE POINTS ======================
2028 * void StokesProblem<dim>::update_quadrature_point_history()
2030 * std::cout << " Updating stress field...";
2032 * FEValues<dim> fe_values(fe, quadrature_formula,
2033 * update_values | update_gradients | update_quadrature_points);
2037 * Make the object that will hold the velocity gradients
2040 * std::vector < std::vector<Tensor<1, dim> >> velocity_grads(quadrature_formula.size(),
2041 * std::vector < Tensor<1, dim> > (dim + 1));
2042 * std::vector<Vector<double> > velocities(quadrature_formula.size(),
2043 * Vector<double>(dim + 1));
2045 * for (typename DoFHandler<dim>::active_cell_iterator cell =
2046 * dof_handler.begin_active(); cell != dof_handler.end(); ++cell)
2048 * PointHistory<dim> *local_quadrature_points_history =
2049 * reinterpret_cast<PointHistory<dim> *>(cell->user_pointer());
2051 * local_quadrature_points_history >= &quadrature_point_history.front(),
2052 * ExcInternalError());
2054 * local_quadrature_points_history < &quadrature_point_history.back(),
2055 * ExcInternalError());
2057 * fe_values.reinit(cell);
2058 * fe_values.get_function_gradients(solution, velocity_grads);
2059 * fe_values.get_function_values(solution, velocities);
2061 * for (unsigned int q = 0; q < quadrature_formula.size(); ++q)
2065 * Define the local viscoelastic constants
2068 * double local_eta_ve = 2
2069 * / ((1 / local_quadrature_points_history[q].new_eta)
2070 * + (1 / local_quadrature_points_history[q].G
2071 * / system_parameters::current_time_interval));
2072 * double local_chi_ve =
2075 * + (local_quadrature_points_history[q].G
2076 * * system_parameters::current_time_interval
2077 * / local_quadrature_points_history[q].new_eta));
2081 * Compute new stress at each quadrature point
2084 * SymmetricTensor<2, dim> new_stress;
2085 * for (unsigned int i = 0; i < dim; ++i)
2086 * new_stress[i][i] =
2087 * local_eta_ve * velocity_grads[q][i][i]
2089 * * local_quadrature_points_history[q].old_stress[i][i];
2091 * for (unsigned int i = 0; i < dim; ++i)
2092 * for (unsigned int j = i + 1; j < dim; ++j)
2093 * new_stress[i][j] =
2095 * * (velocity_grads[q][i][j]
2096 * + velocity_grads[q][j][i]) / 2
2098 * * local_quadrature_points_history[q].old_stress[i][j];
2105 * AuxFunctions<dim> rotation_object;
2106 * const Tensor<2, dim> rotation = rotation_object.get_rotation_matrix(
2107 * velocity_grads[q]);
2108 * const SymmetricTensor<2, dim> rotated_new_stress = symmetrize(
2109 * transpose(rotation)
2110 * * static_cast<Tensor<2, dim> >(new_stress)
2112 * local_quadrature_points_history[q].old_stress = rotated_new_stress;
2116 * For axisymmetric case, make the phi-phi element of stress tensor
2119 * local_quadrature_points_history[q].old_phiphi_stress =
2120 * (2 * local_eta_ve * velocities[q](0)
2121 * / fe_values.quadrature_point(q)[0]
2123 * * local_quadrature_points_history[q].old_phiphi_stress);
2130 * ====================== REDEFINE THE TIME INTERVAL FOR THE VISCOUS STEPS ======================
2134 * void StokesProblem<dim>::update_time_interval()
2136 * double move_goal_per_step = system_parameters::initial_disp_target;
2137 * if (system_parameters::present_timestep > system_parameters::initial_elastic_iterations)
2139 * move_goal_per_step = system_parameters::initial_disp_target -
2140 * ((system_parameters::initial_disp_target - system_parameters::final_disp_target) /
2141 * system_parameters::total_viscous_steps *
2142 * (system_parameters::present_timestep - system_parameters::initial_elastic_iterations));
2145 * double zero_tolerance = 1e-3;
2146 * double max_velocity = 0;
2147 * for (typename DoFHandler<dim>::active_cell_iterator cell =
2148 * dof_handler.begin_active(); cell != dof_handler.end(); ++cell)// loop over all cells
2150 * if (cell->at_boundary())
2152 * int zero_faces = 0;
2153 * for (unsigned int f=0; f<GeometryInfo<dim>::faces_per_cell; ++f)
2154 * for (unsigned int i=0; i<dim; ++i)
2155 * if (fabs(cell->face(f)->center()[i]) < zero_tolerance)
2157 * if (zero_faces==0)
2159 * for (unsigned int v = 0; v < GeometryInfo<dim>::vertices_per_cell; ++v)
2161 * Point<dim> vertex_velocity;
2162 * Point<dim> vertex_position;
2163 * for (unsigned int d = 0; d < dim; ++d)
2165 * vertex_velocity[d] = solution(cell->vertex_dof_index(v, d));
2166 * vertex_position[d] = cell->vertex(v)[d];
2170 * velocity to be evaluated is the radial component of a surface vertex
2173 * double local_velocity = 0;
2174 * for (unsigned int d = 0; d < dim; ++d)
2176 * local_velocity += vertex_velocity[d] * vertex_position [d];
2178 * local_velocity /= std::sqrt( vertex_position.square() );
2179 * if (local_velocity < 0)
2180 * local_velocity *= -1;
2181 * if (local_velocity > max_velocity)
2183 * max_velocity = local_velocity;
2191 * NOTE: It is possible for this time interval to be very different from that used in the viscoelasticity calculation.
2194 * system_parameters::current_time_interval = move_goal_per_step / max_velocity;
2195 * double step_time_yr = system_parameters::current_time_interval / SECSINYEAR;
2196 * std::cout << "Timestep interval changed to: "
2203 * ====================== MOVE MESH ======================
2210 * void StokesProblem<dim>::move_mesh()
2213 * std::cout << "\n" << " Moving mesh...\n";
2214 * std::vector<bool> vertex_touched(triangulation.n_vertices(), false);
2215 * for (typename DoFHandler<dim>::active_cell_iterator cell =
2216 * dof_handler.begin_active(); cell != dof_handler.end(); ++cell)
2217 * for (unsigned int v = 0; v < GeometryInfo<dim>::vertices_per_cell; ++v)
2218 * if (vertex_touched[cell->vertex_index(v)] == false)
2220 * vertex_touched[cell->vertex_index(v)] = true;
2222 * Point<dim> vertex_displacement;
2223 * for (unsigned int d = 0; d < dim; ++d)
2224 * vertex_displacement[d] = solution(
2225 * cell->vertex_dof_index(v, d));
2226 * cell->vertex(v) += vertex_displacement
2227 * * system_parameters::current_time_interval;
2233 * ====================== WRITE MESH TO FILE ======================
2240 * void StokesProblem<dim>::write_mesh()
2244 * output mesh in ucd
2247 * std::ostringstream initial_mesh_file;
2248 * initial_mesh_file << system_parameters::output_folder << "/time" <<
2249 * Utilities::int_to_string(system_parameters::present_timestep, 2) <<
2251 * std::ofstream out_ucd (initial_mesh_file.str().c_str());
2253 * grid_out.write_ucd (triangulation, out_ucd);
2258 * ====================== FIT ELLIPSE TO SURFACE AND WRITE RADII TO FILE ======================
2265 * void StokesProblem<dim>::do_ellipse_fits()
2267 * std::ostringstream ellipses_filename;
2268 * ellipses_filename << system_parameters::output_folder << "/ellipse_fits.txt";
2271 * Find ellipsoidal axes for all layers
2274 * std::vector<double> ellipse_axes(0);
2277 * compute fit to boundary 0, 1, 2 ...
2280 * std::cout << endl;
2281 * for (unsigned int i = 0; i<system_parameters::sizeof_material_id; ++i)
2283 * ellipsoid.compute_fit(ellipse_axes, system_parameters::material_id[i]);
2284 * system_parameters::q_axes.push_back(ellipse_axes[0]);
2285 * system_parameters::p_axes.push_back(ellipse_axes[1]);
2287 * std::cout << "a_"<< system_parameters::material_id[i] <<" = " << ellipse_axes[0]
2288 * << " " << " c_"<< system_parameters::material_id[i] <<" = " << ellipse_axes[1] << std::endl;
2289 * ellipse_axes.clear();
2291 * std::ofstream fout_ellipses(ellipses_filename.str().c_str(), std::ios::app);
2292 * fout_ellipses << system_parameters::present_timestep << " a_"<< system_parameters::material_id[i] <<" = " << ellipse_axes[0]
2293 * << " " << " c_"<< system_parameters::material_id[i] <<" = " << ellipse_axes[1] << endl;
2294 * fout_ellipses.close();
2300 * ====================== APPEND LINE TO PHYSICAL_TIMES.TXT FILE WITH STEP NUMBER, PHYSICAL TIME, AND # PLASTIC ITERATIONS ======================
2307 * void StokesProblem<dim>::append_physical_times(int max_plastic)
2309 * std::ostringstream times_filename;
2310 * times_filename << system_parameters::output_folder << "/physical_times.txt";
2311 * std::ofstream fout_times(times_filename.str().c_str(), std::ios::app);
2312 * fout_times << system_parameters::present_timestep << " "
2313 * << system_parameters::present_time/SECSINYEAR << " "
2314 * << max_plastic << "\n";
2317 * << system_parameters::q_axes[0] << " " << system_parameters::p_axes[0] << " "
2318 * << system_parameters::q_axes[1] << " " << system_parameters::p_axes[1] << "\n";
2321 * fout_times.close();
2326 * ====================== WRITE VERTICES TO FILE ======================
2333 * void StokesProblem<dim>::write_vertices(unsigned char boundary_that_we_need)
2335 * std::ostringstream vertices_output;
2336 * vertices_output << system_parameters::output_folder << "/time" <<
2337 * Utilities::int_to_string(system_parameters::present_timestep, 2) << "_" <<
2338 * Utilities::int_to_string(boundary_that_we_need, 2) <<
2340 * std::ofstream fout_final_vertices(vertices_output.str().c_str());
2341 * fout_final_vertices.close();
2343 * std::vector<bool> vertex_touched(triangulation.n_vertices(), false);
2345 * if (boundary_that_we_need == 0)
2349 * Figure out if the vertex is on the boundary of the domain
2352 * for (typename Triangulation<dim>::active_cell_iterator cell =
2353 * triangulation.begin_active(); cell != triangulation.end(); ++cell)
2354 * for (unsigned int f = 0; f < GeometryInfo<dim>::faces_per_cell; ++f)
2356 * unsigned char boundary_ids = cell->face(f)->boundary_id();
2357 * if (boundary_ids == boundary_that_we_need)
2359 * for (unsigned int v=0; v<GeometryInfo<dim>::vertices_per_face; ++v)
2360 * if (vertex_touched[cell->face(f)->vertex_index(v)] == false)
2362 * vertex_touched[cell->face(f)->vertex_index(v)] = true;
2363 * std::ofstream fout_final_vertices(vertices_output.str().c_str(), std::ios::app);
2364 * fout_final_vertices << cell->face(f)->vertex(v) << "\n";
2365 * fout_final_vertices.close();
2374 * Figure out if the vertex is on an internal boundary
2377 * for (typename Triangulation<dim>::active_cell_iterator cell =
2378 * triangulation.begin_active(); cell != triangulation.end(); ++cell)
2379 * for (unsigned int f = 0; f < GeometryInfo<dim>::faces_per_cell; ++f)
2381 * if (cell->neighbor(f) != triangulation.end())
2383 * if (cell->material_id() != cell->neighbor(f)->material_id()) //finds face is at internal boundary
2385 * int high_mat_id = std::max(cell->material_id(),
2386 * cell->neighbor(f)->material_id());
2387 * if (high_mat_id == boundary_that_we_need) //finds faces at the correct internal boundary
2389 * for (unsigned int v = 0;
2390 * v < GeometryInfo<dim>::vertices_per_face;
2392 * if (vertex_touched[cell->face(f)->vertex_index(
2395 * vertex_touched[cell->face(f)->vertex_index(
2397 * std::ofstream fout_final_vertices(vertices_output.str().c_str(), std::ios::app);
2398 * fout_final_vertices << cell->face(f)->vertex(v) << "\n";
2399 * fout_final_vertices.close();
2410 * ====================== SETUP INITIAL MESH ======================
2417 * void StokesProblem<dim>::setup_initial_mesh()
2419 * GridIn<dim> grid_in;
2420 * grid_in.attach_triangulation(triangulation);
2421 * std::ifstream mesh_stream(system_parameters::mesh_filename,
2422 * std::ifstream::in);
2423 * grid_in.read_ucd(mesh_stream);
2427 * output initial mesh in eps
2430 * std::ostringstream initial_mesh_file;
2431 * initial_mesh_file << system_parameters::output_folder << "/initial_mesh.eps";
2432 * std::ofstream out_eps (initial_mesh_file.str().c_str());
2434 * grid_out.write_eps (triangulation, out_eps);
2440 * boundary indicator 0 is outer free surface; 1, 2, 3 ... is boundary between layers, 99 is flat boundaries
2443 * typename Triangulation<dim>::active_cell_iterator
2444 * cell=triangulation.begin_active(), endc=triangulation.end();
2446 * unsigned int how_many; // how many components away from cardinal planes
2448 * std::ostringstream boundaries_file;
2449 * boundaries_file << system_parameters::output_folder << "/boundaries.txt";
2450 * std::ofstream fout_boundaries(boundaries_file.str().c_str());
2451 * fout_boundaries.close();
2453 * double zero_tolerance = 1e-3;
2454 * for (; cell != endc; ++cell) // loop over all cells
2456 * for (unsigned int f = 0; f < GeometryInfo<dim>::faces_per_cell; ++f) // loop over all vertices
2458 * if (cell->face(f)->at_boundary())
2465 * std::ofstream fout_boundaries(boundaries_file.str().c_str(), std::ios::app);
2466 * fout_boundaries << cell->face(f)->center()[0] << " " << cell->face(f)->center()[1]<< "\n";
2467 * fout_boundaries.close();
2470 * for (unsigned int i=0; i<dim; ++i)
2471 * if (fabs(cell->face(f)->center()[i]) > zero_tolerance)
2473 * if (how_many==dim)
2474 * cell->face(f)->set_all_boundary_ids(0); // if face center coordinates > zero_tol, set bnry indicators to 0
2476 * cell->face(f)->set_all_boundary_ids(99);
2481 * std::ostringstream ellipses_filename;
2482 * ellipses_filename << system_parameters::output_folder << "/ellipse_fits.txt";
2483 * std::ofstream fout_ellipses(ellipses_filename.str().c_str());
2484 * fout_ellipses.close();
2488 * Find ellipsoidal axes for all layers
2491 * std::vector<double> ellipse_axes(0);
2494 * compute fit to boundary 0, 1, 2 ...
2497 * std::cout << endl;
2498 * for (unsigned int i = 0; i<system_parameters::sizeof_material_id; ++i)
2500 * ellipsoid.compute_fit(ellipse_axes, system_parameters::material_id[i]);
2501 * system_parameters::q_axes.push_back(ellipse_axes[0]);
2502 * system_parameters::p_axes.push_back(ellipse_axes[1]);
2504 * std::cout << "a_"<< system_parameters::material_id[i] <<" = " << ellipse_axes[0]
2505 * << " " << " c_"<< system_parameters::material_id[i] <<" = " << ellipse_axes[1] << std::endl;
2506 * ellipse_axes.clear();
2508 * std::ofstream fout_ellipses(ellipses_filename.str().c_str(), std::ios::app);
2509 * fout_ellipses << system_parameters::present_timestep << " a_"<< system_parameters::material_id[i] <<" = " << ellipse_axes[0]
2510 * << " " << " c_"<< system_parameters::material_id[i] <<" = " << ellipse_axes[1] << endl;
2511 * fout_ellipses.close();
2514 * triangulation.refine_global(system_parameters::global_refinement);
2519 * refines crustal region
2522 * if (system_parameters::crustal_refinement != 0)
2524 * double a = system_parameters::q_axes[0] - system_parameters::crust_refine_region;
2525 * double b = system_parameters::p_axes[0] - system_parameters::crust_refine_region;
2528 * for (unsigned int step = 0;
2529 * step < system_parameters::crustal_refinement; ++step)
2531 * typename ::Triangulation<dim>::active_cell_iterator cell =
2532 * triangulation.begin_active(), endc = triangulation.end();
2533 * for (; cell != endc; ++cell)
2534 * for (unsigned int v = 0;
2535 * v < GeometryInfo<dim>::vertices_per_cell; ++v)
2537 * Point<dim> current_vertex = cell->vertex(v);
2539 * const double x_coord = current_vertex.operator()(0);
2540 * const double y_coord = current_vertex.operator()(1);
2541 * double expected_z = -1;
2543 * if ((x_coord - a) < -1e-10)
2545 * * std::sqrt(1 - (x_coord * x_coord / a / a));
2547 * if (y_coord >= expected_z)
2549 * cell->set_refine_flag();
2553 * triangulation.execute_coarsening_and_refinement();
2560 * output initial mesh in eps
2563 * std::ostringstream refined_mesh_file;
2564 * refined_mesh_file << system_parameters::output_folder << "/refined_mesh.eps";
2565 * std::ofstream out_eps_refined (refined_mesh_file.str().c_str());
2566 * GridOut grid_out_refined;
2567 * grid_out_refined.write_eps (triangulation, out_eps_refined);
2568 * out_eps_refined.close();
2569 * write_vertices(0);
2570 * write_vertices(1);
2576 * ====================== REFINE MESH ======================
2583 * void StokesProblem<dim>::refine_mesh()
2585 * using FunctionMap = std::map<types::boundary_id, const Function<dim> *>;
2586 * Vector<float> estimated_error_per_cell(triangulation.n_active_cells());
2588 * std::vector<bool> component_mask(dim + 1, false);
2589 * component_mask[dim] = true;
2590 * KellyErrorEstimator<dim>::estimate(dof_handler, QGauss<dim - 1>(degree + 1),
2591 * FunctionMap(), solution,
2592 * estimated_error_per_cell, component_mask);
2594 * GridRefinement::refine_and_coarsen_fixed_number(triangulation,
2595 * estimated_error_per_cell, 0.3, 0.0);
2596 * triangulation.execute_coarsening_and_refinement();
2601 * ====================== SET UP THE DATA STRUCTURES TO REMEMBER STRESS FIELD ======================
2605 * void StokesProblem<dim>::setup_quadrature_point_history()
2607 * unsigned int our_cells = 0;
2608 * for (typename Triangulation<dim>::active_cell_iterator cell =
2609 * triangulation.begin_active(); cell != triangulation.end(); ++cell)
2612 * triangulation.clear_user_data();
2614 * quadrature_point_history.resize(our_cells * quadrature_formula.size());
2616 * unsigned int history_index = 0;
2617 * for (typename Triangulation<dim>::active_cell_iterator cell =
2618 * triangulation.begin_active(); cell != triangulation.end(); ++cell)
2620 * cell->set_user_pointer(&quadrature_point_history[history_index]);
2621 * history_index += quadrature_formula.size();
2624 * Assert(history_index == quadrature_point_history.size(), ExcInternalError());
2629 * ====================== DOES ELASTIC STEPS ======================
2633 * void StokesProblem<dim>::do_elastic_steps()
2635 * unsigned int elastic_iteration = 0;
2637 * while (elastic_iteration < system_parameters::initial_elastic_iterations)
2640 * std::cout << "\n\nElastic iteration " << elastic_iteration
2644 * if (system_parameters::present_timestep == 0)
2645 * initialize_eta_and_G();
2647 * if (elastic_iteration == 0)
2648 * system_parameters::current_time_interval =
2649 * system_parameters::viscous_time; //This is the time interval needed in assembling the problem
2651 * std::cout << " Assembling..." << std::endl << std::flush;
2652 * assemble_system();
2654 * std::cout << " Solving..." << std::flush;
2658 * update_quadrature_point_history();
2660 * append_physical_times(0);
2661 * elastic_iteration++;
2662 * system_parameters::present_timestep++;
2663 * do_ellipse_fits();
2664 * write_vertices(0);
2665 * write_vertices(1);
2667 * update_time_interval();
2673 * ====================== DO A SINGLE VISCOELASTOPLASTIC TIMESTEP ======================
2677 * void StokesProblem<dim>::do_flow_step()
2679 * plastic_iteration = 0;
2680 * while (plastic_iteration < system_parameters::max_plastic_iterations)
2682 * if (system_parameters::continue_plastic_iterations == true)
2684 * std::cout << "Plasticity iteration " << plastic_iteration << "\n";
2687 * std::cout << " Assembling..." << std::endl << std::flush;
2688 * assemble_system();
2690 * std::cout << " Solving..." << std::flush;
2694 * solution_stesses();
2696 * if (system_parameters::continue_plastic_iterations == false)
2699 * plastic_iteration++;
2706 * ====================== RUN ======================
2713 * void StokesProblem<dim>::run()
2717 * Sets up mesh and data structure for viscosity and stress at quadrature points
2720 * setup_initial_mesh();
2721 * setup_quadrature_point_history();
2725 * Makes the physical_times.txt file
2728 * std::ostringstream times_filename;
2729 * times_filename << system_parameters::output_folder << "/physical_times.txt";
2730 * std::ofstream fout_times(times_filename.str().c_str());
2731 * fout_times.close();
2735 * Computes elastic timesteps
2738 * do_elastic_steps();
2741 * Computes viscous timesteps
2744 * unsigned int VEPstep = 0;
2745 * while (system_parameters::present_timestep
2746 * < (system_parameters::initial_elastic_iterations
2747 * + system_parameters::total_viscous_steps))
2750 * if (system_parameters::continue_plastic_iterations == false)
2751 * system_parameters::continue_plastic_iterations = true;
2752 * std::cout << "\n\nViscoelastoplastic iteration " << VEPstep << "\n\n";
2755 * Computes plasticity
2759 * update_quadrature_point_history();
2761 * append_physical_times(plastic_iteration);
2762 * system_parameters::present_timestep++;
2763 * system_parameters::present_time = system_parameters::present_time + system_parameters::current_time_interval;
2764 * do_ellipse_fits();
2765 * write_vertices(0);
2766 * write_vertices(1);
2770 * append_physical_times(-1);
2777 * ====================== MAIN ======================
2783 * int main(int argc, char *argv[])
2788 * output program name
2791 * std::cout << "Running: " << argv[0] << std::endl;
2793 * char *cfg_filename = new char[120];
2795 * if (argc == 1) // if no input parameters (as if launched from eclipse)
2797 * std::strcpy(cfg_filename,"config/sample_CeresFE_config.cfg");
2800 * std::strcpy(cfg_filename,argv[1]);
2804 * using namespace dealii;
2805 * using namespace Step22;
2806 * config_in cfg(cfg_filename);
2810 * t1 = std::clock();
2812 * deallog.depth_console(0);
2814 * StokesProblem<2> flow_problem(1);
2815 * flow_problem.run();
2817 * std::cout << std::endl << "\a";
2819 * t2 = std::clock();
2820 * float diff (((float)t2 - (float)t1) / (float)CLOCKS_PER_SEC);
2821 * std::cout << "\n Program run in: " << diff << " seconds" << endl;
2823 * catch (std::exception &exc)
2825 * std::cerr << std::endl << std::endl
2826 * << "----------------------------------------------------"
2828 * std::cerr << "Exception on processing: " << std::endl << exc.what()
2829 * << std::endl << "Aborting!" << std::endl
2830 * << "----------------------------------------------------"
2837 * std::cerr << std::endl << std::endl
2838 * << "----------------------------------------------------"
2840 * std::cerr << "Unknown exception!" << std::endl << "Aborting!"
2842 * << "----------------------------------------------------"
2852<a name="ann-support_code/config_in.h"></a>
2853<h1>Annotated version of support_code/config_in.h</h1>
2862 * * Created on: Aug 17, 2015
2863 * * Author: antonermakov
2867 * #include <iostream>
2868 * #include <iomanip>
2869 * #include <cstdlib>
2871 * #include <libconfig.h++>
2873 * #include "local_math.h"
2875 * using namespace std;
2876 * using namespace libconfig;
2880 * namespace system_parameters
2888 * string mesh_filename;
2889 * string output_folder;
2898 * double omegasquared;
2904 * Rheology parameters
2907 * vector<double> depths_eta;
2908 * vector<double> eta_kinks;
2909 * vector<double> depths_rho;
2910 * vector<double> rho;
2911 * vector<int> material_id;
2914 * double eta_ceiling;
2917 * bool lat_dependence;
2919 * unsigned int sizeof_depths_eta;
2920 * unsigned int sizeof_depths_rho;
2921 * unsigned int sizeof_rho;
2922 * unsigned int sizeof_eta_kinks;
2923 * unsigned int sizeof_material_id;
2924 * unsigned int sizeof_G;
2926 * double pressure_scale;
2929 * bool continue_plastic_iterations;
2933 * plasticity variables
2936 * bool plasticity_on;
2937 * unsigned int failure_criterion;
2938 * unsigned int max_plastic_iterations;
2939 * double smoothing_radius;
2943 * viscoelasticity variables
2946 * unsigned int initial_elastic_iterations;
2947 * double elastic_time;
2948 * double viscous_time;
2949 * double initial_disp_target;
2950 * double final_disp_target;
2951 * double current_time_interval;
2955 * mesh refinement variables
2958 * unsigned int global_refinement;
2959 * unsigned int small_r_refinement;
2960 * unsigned int crustal_refinement;
2961 * double crust_refine_region;
2962 * unsigned int surface_refinement;
2969 * int iteration_coefficient;
2970 * double tolerance_coefficient;
2974 * time step variables
2977 * double present_time;
2978 * unsigned int present_timestep;
2979 * unsigned int total_viscous_steps;
2987 * vector<double> q_axes;
2988 * vector<double> p_axes;
2995 * config_in(char *);
2998 * void write_config();
3001 * void config_in::write_config()
3003 * std::ostringstream config_parameters;
3004 * config_parameters << system_parameters::output_folder << "/run_parameters.txt";
3005 * std::ofstream fout_config(config_parameters.str().c_str());
3012 * fout_config << "mesh filename: " << system_parameters::mesh_filename << endl << endl;
3019 * fout_config << "r_mean = " << system_parameters::r_mean << endl;
3020 * fout_config << "period = " << system_parameters::period << endl;
3021 * fout_config << "omegasquared = " << system_parameters::omegasquared << endl;
3022 * fout_config << "beta = " << system_parameters::beta << endl;
3023 * fout_config << "intercept = " << system_parameters::intercept << endl;
3027 * rheology parameters
3033 * for (unsigned int i=0; i<system_parameters::sizeof_depths_eta; ++i)
3034 * fout_config << "depths_eta[" << i << "] = " << system_parameters::depths_eta[i] << endl;
3036 * for (unsigned int i=0; i<system_parameters::sizeof_eta_kinks; ++i)
3037 * fout_config << "eta_kinks[" << i << "] = " << system_parameters::eta_kinks[i] << endl;
3039 * for (unsigned int i=0; i<system_parameters::sizeof_depths_rho; ++i)
3040 * fout_config << "depths_rho[" << i << "] = " << system_parameters::depths_rho[i] << endl;
3042 * for (unsigned int i=0; i<system_parameters::sizeof_rho; ++i)
3043 * fout_config << "rho[" << i << "] = " << system_parameters::rho[i] << endl;
3045 * for (unsigned int i=0; i<system_parameters::sizeof_material_id; ++i)
3046 * fout_config << "material_id[" << i << "] = " << system_parameters::material_id[i] << endl;
3048 * for (unsigned int i=0; i<system_parameters::sizeof_G; ++i)
3049 * fout_config << "G[" << i << "] = " << system_parameters::G[i] << endl;
3051 * fout_config << "eta_ceiling = " << system_parameters::eta_ceiling << endl;
3052 * fout_config << "eta_floor = " << system_parameters::eta_floor << endl;
3053 * fout_config << "eta_Ea = " << system_parameters::eta_Ea << endl;
3054 * fout_config << "lat_dependence = " << system_parameters::lat_dependence << endl;
3055 * fout_config << "pressure_scale = " << system_parameters::pressure_scale << endl;
3056 * fout_config << "q = " << system_parameters::q << endl;
3057 * fout_config << "cylindrical = " << system_parameters::cylindrical << endl;
3058 * fout_config << "continue_plastic_iterations = " << system_parameters::continue_plastic_iterations << endl;
3062 * Plasticity parameters
3065 * fout_config << "plasticity_on = " << system_parameters::plasticity_on << endl;
3066 * fout_config << "failure_criterion = " << system_parameters::failure_criterion << endl;
3067 * fout_config << "max_plastic_iterations = " << system_parameters::max_plastic_iterations << endl;
3068 * fout_config << "smoothing_radius = " << system_parameters::smoothing_radius << endl;
3072 * Viscoelasticity parameters
3075 * fout_config << "initial_elastic_iterations = " << system_parameters::initial_elastic_iterations << endl;
3076 * fout_config << "elastic_time = " << system_parameters::elastic_time << endl;
3077 * fout_config << "viscous_time = " << system_parameters::viscous_time << endl;
3078 * fout_config << "initial_disp_target = " << system_parameters::initial_disp_target << endl;
3079 * fout_config << "final_disp_target = " << system_parameters::final_disp_target << endl;
3080 * fout_config << "current_time_interval = " << system_parameters::current_time_interval << endl;
3084 * Mesh refinement parameters
3087 * fout_config << "global_refinement = " << system_parameters::global_refinement << endl;
3088 * fout_config << "small_r_refinement = " << system_parameters::small_r_refinement << endl;
3089 * fout_config << "crustal_refinement = " << system_parameters::crustal_refinement << endl;
3090 * fout_config << "crust_refine_region = " << system_parameters::crust_refine_region << endl;
3091 * fout_config << "surface_refinement = " << system_parameters::surface_refinement << endl;
3098 * fout_config << "iteration_coefficient = " << system_parameters::iteration_coefficient << endl;
3099 * fout_config << "tolerance_coefficient = " << system_parameters::tolerance_coefficient << endl;
3103 * Time step parameters
3106 * fout_config << "present_time = " << system_parameters::present_time << endl;
3107 * fout_config << "present_timestep = " << system_parameters::present_timestep << endl;
3108 * fout_config << "total_viscous_steps = " << system_parameters::total_viscous_steps << endl;
3110 * fout_config.close();
3113 * config_in::config_in(char *filename)
3118 * This example reads the configuration file 'example.cfg
' and displays
3119 * some of its contents.
3129 * Read the file. If there is an error, report it and exit.
3134 * cfg.readFile(filename);
3136 * catch (const FileIOException &fioex)
3138 * std::cerr << "I/O error while reading file:" << filename << std::endl;
3140 * catch (const ParseException &pex)
3142 * std::cerr << "Parse error at " << pex.getFile() << ":" << pex.getLine()
3143 * << " - " << pex.getError() << std::endl;
3153 * string msh = cfg.lookup("mesh_filename");
3154 * system_parameters::mesh_filename = msh;
3156 * catch (const SettingNotFoundException &nfex)
3158 * cerr << "No 'mesh_filename
' setting in configuration file." << endl;
3171 * string output = cfg.lookup("output_folder");
3172 * system_parameters::output_folder = output;
3174 * std::cout << "Writing to folder: " << output << endl;
3176 * catch (const SettingNotFoundException &nfex)
3178 * cerr << "No 'output_folder
' setting in configuration file." << endl;
3189 * const Setting &root = cfg.getRoot();
3194 * get body parameters
3199 * const Setting &body_parameters = root["body_parameters"];
3201 * body_parameters.lookupValue("period", system_parameters::period);
3202 * system_parameters::omegasquared = pow(TWOPI / 3600.0 / system_parameters::period, 2.0);
3203 * body_parameters.lookupValue("r_mean", system_parameters::r_mean);
3204 * body_parameters.lookupValue("beta", system_parameters::beta);
3205 * body_parameters.lookupValue("intercept", system_parameters::intercept);
3207 * catch (const SettingNotFoundException &nfex)
3209 * cerr << "We've got a problem in the body parameters block
" << endl;
3215 * Rheology parameters
3225 * get depths_eta ---------------------
3228 * const Setting &set_depths_eta = cfg.lookup("rheology_parameters.depths_eta
");
3230 * unsigned int ndepths_eta = set_depths_eta.getLength();
3231 * system_parameters::sizeof_depths_eta = ndepths_eta;
3233 * for (unsigned int i=0; i<ndepths_eta; ++i)
3235 * system_parameters::depths_eta.push_back(set_depths_eta[i]);
3236 * cout << "depth_eta[
" << i << "] =
" << system_parameters::depths_eta[i] << endl;
3241 * get eta_kinks -------------------------
3244 * const Setting &set_eta_kinks = cfg.lookup("rheology_parameters.eta_kinks
");
3246 * unsigned int neta_kinks = set_eta_kinks.getLength();
3247 * system_parameters::sizeof_eta_kinks = neta_kinks;
3251 * cout << "Number of
depth =
" << ndepths << endl;
3257 * for (unsigned int i=0; i<neta_kinks; ++i)
3259 * system_parameters::eta_kinks.push_back(set_eta_kinks[i]);
3260 * cout << "eta_kinks[
" << i << "] =
" << system_parameters::eta_kinks[i] << endl;
3265 * get depths_rho -------------------------
3268 * const Setting &set_depths_rho = cfg.lookup("rheology_parameters.depths_rho
");
3270 * unsigned int ndepths_rho = set_depths_rho.getLength();
3271 * system_parameters::sizeof_depths_rho = ndepths_rho;
3275 * cout << "Number of
depth =
" << ndepths << endl;
3281 * for (unsigned int i=0; i<ndepths_rho; ++i)
3283 * system_parameters::depths_rho.push_back(set_depths_rho[i]);
3284 * cout << "depths_rho[
" << i << "] =
" << system_parameters::depths_rho[i] << endl;
3289 * get rho -------------------------
3292 * const Setting &set_rho = cfg.lookup("rheology_parameters.rho
");
3294 * unsigned int nrho = set_rho.getLength();
3295 * system_parameters::sizeof_rho = nrho;
3299 * cout << "Number of
depth =
" << ndepths << endl;
3305 * for (unsigned int i=0; i<nrho; ++i)
3307 * system_parameters::rho.push_back(set_rho[i]);
3308 * cout << "rho[
" << i << "] =
" << system_parameters::rho[i] << endl;
3313 * get material_id -------------------------
3316 * const Setting &set_material_id = cfg.lookup("rheology_parameters.material_id
");
3318 * unsigned int nmaterial_id = set_material_id.getLength();
3319 * system_parameters::sizeof_material_id = nmaterial_id;
3323 * cout << "Number of
depth =
" << ndepths << endl;
3329 * for (unsigned int i=0; i<nmaterial_id; ++i)
3331 * system_parameters::material_id.push_back(set_material_id[i]);
3332 * cout << "material_id[
" << i << "] =
" << system_parameters::material_id[i] << endl;
3337 * get G -------------------------
3340 * const Setting &set_G = cfg.lookup("rheology_parameters.G
");
3342 * unsigned int nG = set_G.getLength();
3343 * system_parameters::sizeof_G = nG;
3347 * cout << "Number of
depth =
" << ndepths << endl;
3353 * for (unsigned int i=0; i<nG; ++i)
3355 * system_parameters::G.push_back(set_G[i]);
3356 * cout << "G[
" << i << "] =
" << system_parameters::G[i] << endl;
3359 * const Setting &rheology_parameters = root["rheology_parameters
"];
3360 * rheology_parameters.lookupValue("eta_ceiling
", system_parameters::eta_ceiling);
3361 * rheology_parameters.lookupValue("eta_floor
", system_parameters::eta_floor);
3362 * rheology_parameters.lookupValue("eta_Ea
", system_parameters::eta_Ea);
3363 * rheology_parameters.lookupValue("lat_dependence
", system_parameters::lat_dependence);
3364 * rheology_parameters.lookupValue("pressure_scale
", system_parameters::pressure_scale);
3365 * rheology_parameters.lookupValue("q
", system_parameters::q);
3366 * rheology_parameters.lookupValue("cylindrical
", system_parameters::cylindrical);
3367 * rheology_parameters.lookupValue("continue_plastic_iterations
", system_parameters::continue_plastic_iterations);
3369 * catch (const SettingNotFoundException &nfex)
3371 * cerr << "We
've got a problem in the rheology parameters block" << endl;
3376 * Plasticity parameters
3382 * const Setting &plasticity_parameters = root["plasticity_parameters"];
3383 * plasticity_parameters.lookupValue("plasticity_on", system_parameters::plasticity_on);
3384 * plasticity_parameters.lookupValue("failure_criterion", system_parameters::failure_criterion);
3385 * plasticity_parameters.lookupValue("max_plastic_iterations", system_parameters::max_plastic_iterations);
3386 * plasticity_parameters.lookupValue("smoothing_radius", system_parameters::smoothing_radius);
3388 * catch (const SettingNotFoundException &nfex)
3390 * cerr << "We've got a problem in the plasticity parameters block
" << endl;
3395 * Viscoelasticity parameters
3404 * const Setting &viscoelasticity_parameters = root["viscoelasticity_parameters
"];
3405 * viscoelasticity_parameters.lookupValue("initial_elastic_iterations
", system_parameters::initial_elastic_iterations);
3406 * viscoelasticity_parameters.lookupValue("elastic_time
", system_parameters::elastic_time);
3407 * viscoelasticity_parameters.lookupValue("viscous_time
", system_parameters::viscous_time);
3408 * viscoelasticity_parameters.lookupValue("initial_disp_target
", system_parameters::initial_disp_target);
3409 * viscoelasticity_parameters.lookupValue("final_disp_target
", system_parameters::final_disp_target);
3410 * viscoelasticity_parameters.lookupValue("current_time_interval
", system_parameters::current_time_interval);
3412 * system_parameters::viscous_time *= SECSINYEAR;
3414 * catch (const SettingNotFoundException &nfex)
3416 * cerr << "We
've got a problem in the viscoelasticity parameters block" << endl;
3421 * Mesh refinement parameters
3427 * const Setting &mesh_refinement_parameters = root["mesh_refinement_parameters"];
3428 * mesh_refinement_parameters.lookupValue("global_refinement", system_parameters::global_refinement);
3429 * mesh_refinement_parameters.lookupValue("small_r_refinement", system_parameters::small_r_refinement);
3430 * mesh_refinement_parameters.lookupValue("crustal_refinement", system_parameters::crustal_refinement);
3431 * mesh_refinement_parameters.lookupValue("crust_refine_region", system_parameters::crust_refine_region);
3432 * mesh_refinement_parameters.lookupValue("surface_refinement", system_parameters::surface_refinement);
3434 * catch (const SettingNotFoundException &nfex)
3436 * cerr << "We've got a problem in the mesh refinement parameters block
" << endl;
3446 * const Setting &solve_parameters = root["solve_parameters
"];
3447 * solve_parameters.lookupValue("iteration_coefficient
", system_parameters::iteration_coefficient);
3448 * solve_parameters.lookupValue("tolerance_coefficient
", system_parameters::tolerance_coefficient);
3452 * catch (const SettingNotFoundException &nfex)
3454 * cerr << "We
've got a problem in the solver parameters block" << endl;
3459 * Time step parameters
3464 * const Setting &time_step_parameters = root["time_step_parameters"];
3465 * time_step_parameters.lookupValue("present_time", system_parameters::present_time);
3466 * time_step_parameters.lookupValue("present_timestep", system_parameters::present_timestep);
3467 * time_step_parameters.lookupValue("total_viscous_steps", system_parameters::total_viscous_steps);
3469 * catch (const SettingNotFoundException &nfex)
3471 * cerr << "We've got a problem in the time step parameters block
" << endl;
3485<a name="ann-support_code/ellipsoid_fit.h
"></a>
3486<h1>Annotated version of support_code/ellipsoid_fit.h</h1>
3495 * * Created on: Jul 24, 2015
3496 * * Author: antonermakov
3499 * #include <deal.II/base/quadrature_lib.h>
3500 * #include <deal.II/base/function.h>
3501 * #include <deal.II/base/logstream.h>
3502 * #include <deal.II/lac/vector.h>
3503 * #include <deal.II/lac/full_matrix.h>
3504 * #include <deal.II/lac/sparse_matrix.h>
3505 * #include <deal.II/lac/solver_cg.h>
3506 * #include <deal.II/lac/precondition.h>
3507 * #include <deal.II/grid/tria.h>
3508 * #include <deal.II/dofs/dof_handler.h>
3509 * #include <deal.II/grid/tria_accessor.h>
3510 * #include <deal.II/grid/tria_iterator.h>
3511 * #include <deal.II/dofs/dof_accessor.h>
3512 * #include <deal.II/dofs/dof_tools.h>
3513 * #include <deal.II/fe/fe_q.h>
3514 * #include <deal.II/fe/fe_values.h>
3515 * #include <deal.II/numerics/vector_tools.h>
3516 * #include <deal.II/numerics/matrix_tools.h>
3517 * #include <deal.II/numerics/data_out.h>
3518 * #include <deal.II/grid/grid_in.h>
3519 * #include <deal.II/grid/grid_out.h>
3520 * #include <deal.II/base/point.h>
3521 * #include <deal.II/grid/grid_generator.h>
3523 * #include <fstream>
3524 * #include <sstream>
3525 * #include <iostream>
3526 * #include <iomanip>
3527 * #include <cstdlib>
3530 * #include "local_math.h
"
3532 * using namespace dealii;
3534 * template <int dim>
3535 * class ellipsoid_fit
3538 * inline ellipsoid_fit (Triangulation<dim,dim> *pi)
3540 * p_triangulation = pi;
3542 * void compute_fit(std::vector<double> &ell, unsigned char bndry);
3546 * Triangulation<dim,dim> *p_triangulation;
3553 * This function computes ellipsoid fit to a set of vertices that lie on the
3554 * boundary_that_we_need
3557 * template <int dim>
3558 * void ellipsoid_fit<dim>::compute_fit(std::vector<double> &ell, unsigned char boundary_that_we_need)
3560 * typename Triangulation<dim>::active_cell_iterator cell = p_triangulation->begin_active();
3561 * typename Triangulation<dim>::active_cell_iterator endc = p_triangulation->end();
3563 * FullMatrix<double> A(p_triangulation->n_vertices(),dim);
3564 * Vector<double> x(dim);
3565 * Vector<double> b(p_triangulation->n_vertices());
3567 * std::vector<bool> vertex_touched (p_triangulation->n_vertices(),
3570 * unsigned int j = 0;
3571 * unsigned char boundary_ids;
3572 * std::vector<unsigned int> ind_bnry_row;
3573 * std::vector<unsigned int> ind_bnry_col;
3577 * assemble the sensitivity matrix and r.h.s.
3580 * for (; cell != endc; ++cell)
3582 * if (boundary_that_we_need != 0)
3583 * cell->set_manifold_id(cell->material_id());
3584 * for (unsigned int f = 0; f < GeometryInfo<dim>::faces_per_cell; ++f)
3586 * if (boundary_that_we_need == 0) //if this is the outer surface, then look for boundary ID 0; otherwise look for material ID change.
3588 * boundary_ids = cell->face(f)->boundary_id();
3589 * if (boundary_ids == boundary_that_we_need)
3591 * for (unsigned int v = 0;
3592 * v < GeometryInfo<dim>::vertices_per_face; ++v)
3593 * if (vertex_touched[cell->face(f)->vertex_index(v)]
3596 * vertex_touched[cell->face(f)->vertex_index(v)] =
3598 * for (unsigned int i = 0; i < dim; ++i)
3602 * stiffness matrix entry
3605 * A(j, i) = pow(cell->face(f)->vertex(v)[i], 2);
3614 * if mesh if not full: set the indicator
3618 * ind_bnry_row.push_back(j);
3623 * else //find the faces that are at the boundary between materials, get the vertices, and write them into the stiffness matrix
3625 * if (cell->neighbor(f) != endc)
3627 * if (cell->material_id() != cell->neighbor(f)->material_id()) //finds face is at internal boundary
3629 * int high_mat_id = std::max(cell->material_id(),
3630 * cell->neighbor(f)->material_id());
3631 * if (high_mat_id == boundary_that_we_need) //finds faces at the correct internal boundary
3633 * for (unsigned int v = 0;
3634 * v < GeometryInfo<dim>::vertices_per_face;
3636 * if (vertex_touched[cell->face(f)->vertex_index(
3639 * vertex_touched[cell->face(f)->vertex_index(
3641 * for (unsigned int i = 0; i < dim; ++i)
3645 * stiffness matrix entry
3649 * cell->face(f)->vertex(v)[i], 2);
3658 * if mesh if not full: set the indicator
3662 * ind_bnry_row.push_back(j);
3671 * if (ind_bnry_row.size()>0)
3676 * maxtrix A'*A and vector A'*b; A'*A*x = A'*b -- normal system of equations
3679 * FullMatrix<double> AtA(dim,dim);
3680 * Vector<double> Atb(dim);
3682 * FullMatrix<double> A_out(ind_bnry_row.size(),dim);
3683 * Vector<double> b_out(ind_bnry_row.size());
3685 * for (unsigned int i=0; i<dim; ++i)
3686 * ind_bnry_col.push_back(i);
3688 * for (unsigned int i=0; i<ind_bnry_row.size(); ++i)
3691 * A_out.extract_submatrix_from(A, ind_bnry_row, ind_bnry_col);
3692 * A_out.Tmmult(AtA,A_out,true);
3693 * A_out.Tvmult(Atb,b_out,true);
3697 * solve normal system of equations
3700 * SolverControl solver_control (1000, 1e-12);
3701 * SolverCG<> solver (solver_control);
3702 * solver.solve (AtA, x, Atb, PreconditionIdentity());
3706 * find ellipsoidal axes
3709 * for (unsigned int i=0; i<dim; ++i)
3710 * ell.push_back(sqrt(1.0/x[i]));
3713 * std::cerr << "fit_ellipsoid: no points to fit
" << std::endl;
3720<a name="ann-support_code/ellipsoid_grav.h
"></a>
3721<h1>Annotated version of support_code/ellipsoid_grav.h</h1>
3731 * Started 10/8/2012, R. R. Fu
3733 * Reference Pohanka 2011, Contrib. Geophys. Geodes.
3737 * #include <deal.II/base/point.h>
3738 * #include <fstream>
3739 * #include <iostream>
3741 * namespace A_Grav_namespace
3743 * namespace system_parameters
3745 * double mantle_rho;
3747 * double excess_rho;
3752 * double r_core_polar;
3755 * template <int dim>
3756 * class AnalyticGravity
3759 * void setup_vars (std::vector<double> v);
3760 * void get_gravity (const ::Point<dim> &p, std::vector<double> &g);
3779 * template <int dim>
3780 * void AnalyticGravity<dim>::get_gravity (const ::Point<dim> &p, std::vector<double> &g)
3782 * double rsph = std::sqrt(p[0] * p[0] + p[1] * p[1]);
3783 * double thetasph = std::atan2(p[0], p[1]);
3784 * double costhetasph = std::cos(thetasph);
3788 * convert to elliptical coordinates for silicates
3791 * double stemp = std::sqrt((rsph * rsph - eV * eV + std::sqrt((rsph * rsph - eV * eV) * (rsph * rsph - eV * eV)
3792 * + 4 * eV * eV * rsph * rsph * costhetasph *costhetasph)) / 2);
3793 * double vout = stemp / system_parameters::r_eq / std::sqrt(1 - ecc * ecc);
3794 * double eout = std::acos(rsph * costhetasph / stemp);
3798 * convert to elliptical coordinates for core correction
3801 * double stemp_c = std::sqrt((rsph * rsph - eV_c * eV_c + std::sqrt((rsph * rsph - eV_c * eV_c) * (rsph * rsph - eV_c * eV_c)
3802 * + 4 * eV_c * eV_c * rsph * rsph * costhetasph *costhetasph)) / 2);
3803 * double vout_c = stemp_c / system_parameters::r_core_eq / std::sqrt(1 - ecc_c * ecc_c);
3804 * double eout_c = std::acos(rsph * costhetasph / stemp_c);
3808 * shell contribution
3811 * g[0] = g_coeff * r11 * std::sqrt((1 - ecc * ecc) * vout * vout + ecc * ecc) * std::sin(eout);
3812 * g[1] = g_coeff * r01 * vout * std::cos(eout) / std::sqrt(1 - ecc * ecc);
3819 * double expected_y = system_parameters::r_core_polar * std::sqrt(1 -
3820 * (p[0] * p[0] / system_parameters::r_core_eq / system_parameters::r_core_eq));
3823 * if (p[1] <= expected_y)
3825 * g[0] += g_coeff_c * r11_c * std::sqrt((1 - ecc_c * ecc_c) * vout_c * vout_c + ecc_c * ecc_c) * std::sin(eout_c);
3826 * g[1] += g_coeff_c * r01_c * vout_c * std::cos(eout_c) / std::sqrt(1 - ecc_c * ecc_c);
3830 * double g_coeff_co = - 2.795007963255562e-10 * system_parameters::excess_rho * system_parameters::r_core_eq
3831 * / vout_c / vout_c;
3832 * double r00_co = 0;
3833 * double r01_co = 0;
3834 * double r11_co = 0;
3836 * if (system_parameters::r_core_polar == system_parameters::r_core_eq)
3844 * r00_co = ke_c * vout_c * std::atan2(1, ke_c * vout_c);
3845 * double ke_co2 = ke_c * ke_c * vout_c * vout_c;
3846 * r01_co = 3 * ke_co2 * (1 - r00_co);
3847 * r11_co = 3 * ((ke_co2 + 1) * r00_co - ke_co2) / 2;
3849 * g[0] += g_coeff_co * vout_c * r11_co / std::sqrt((1 - ecc_c* ecc_c) * vout_c * vout_c + ecc_c * ecc_c) * std::sin(eout_c);
3850 * g[1] += g_coeff_co * r01_co * std::cos(eout_c) / std::sqrt(1 - ecc_c * ecc_c);
3854 * template <int dim>
3855 * void AnalyticGravity<dim>::setup_vars (std::vector<double> v)
3857 * system_parameters::r_eq = v[0];
3858 * system_parameters::r_polar = v[1];
3859 * system_parameters::r_core_eq = v[2];
3860 * system_parameters::r_core_polar = v[3];
3861 * system_parameters::mantle_rho = v[4];
3862 * system_parameters::core_rho = v[5];
3863 * system_parameters::excess_rho = system_parameters::core_rho - system_parameters::mantle_rho;
3871 * if (system_parameters::r_polar > system_parameters::r_eq)
3875 * This makes the gravity field nearly that of a sphere in case the body becomes prolate
3878 * std::cout << "\nWarning: The model body has become prolate. \n
";
3883 * ecc = std::sqrt(1 - (system_parameters::r_polar * system_parameters::r_polar / system_parameters::r_eq / system_parameters::r_eq));
3886 * eV = ecc * system_parameters::r_eq;
3887 * ke = std::sqrt(1 - (ecc * ecc)) / ecc;
3888 * r00 = ke * std::atan2(1, ke);
3889 * double ke2 = ke * ke;
3890 * r01 = 3 * ke2 * (1 - r00);
3891 * r11 = 3 * ((ke2 + 1) * r00 - ke2) / 2;
3892 * g_coeff = - 2.795007963255562e-10 * system_parameters::mantle_rho * system_parameters::r_eq;
3899 * if (system_parameters::r_core_polar > system_parameters::r_core_eq)
3901 * std::cout << "\nWarning: The model core has become prolate. \n
";
3906 * ecc_c = std::sqrt(1 - (system_parameters::r_core_polar * system_parameters::r_core_polar / system_parameters::r_core_eq / system_parameters::r_core_eq));
3908 * eV_c = ecc_c * system_parameters::r_core_eq;
3909 * if (system_parameters::r_core_polar == system_parameters::r_core_eq)
3915 * g_coeff_c = - 2.795007963255562e-10 * system_parameters::excess_rho * system_parameters::r_core_eq;
3919 * ke_c = std::sqrt(1 - (ecc_c * ecc_c)) / ecc_c;
3920 * r00_c = ke_c * std::atan2(1, ke_c);
3921 * double ke2_c = ke_c * ke_c;
3922 * r01_c = 3 * ke2_c * (1 - r00_c);
3923 * r11_c = 3 * ((ke2_c + 1) * r00_c - ke2_c) / 2;
3924 * g_coeff_c = - 2.795007963255562e-10 * system_parameters::excess_rho * system_parameters::r_core_eq;
3928 * std::cout << "Loaded variables: ecc =
" << ecc_c << " ke =
" << ke_c << " r00 =
" << r00_c << " r01 =
" << r01_c << " r11 =
" << r11_c << "\n
";
3936<a name="ann-support_code/local_math.h
"></a>
3937<h1>Annotated version of support_code/local_math.h</h1>
3944 * * File: localmath.h
3945 * * Author: antonermakov
3947 * * Created on September 21, 2013, 7:14 PM
3950 * #ifndef LOCAL_MATH_
3951 * #define LOCAL_MATH_
3953 * #define PI 3.14159265358979323846
3954 * #define TWOPI 6.283185307179586476925287
3955 * #define SECSINYEAR 3.155692608e+07
3958 * #define ABS(a) ((a) < 0 ? -(a) : (a))
3962 * double factorial(int n)
3966 * } else if(n == 1) {
3968 * } else if(n == 2) {
3970 * } else if(n == 3) {
3972 * } else if(n == 4) {
3981 * double fudge(int m)
3995 * double sign(double x)
3999 * } else if(x < 0.0) {
4008 * double pv0(double x)
4014 * ans = x - TWOPI*floor(x/TWOPI);
4015 * if(ans > TWOPI/2.0) {
4016 * ans = ans - TWOPI;
4031 * double System::Plm(int m, double x)
4034 * return(1.5*x*x - 0.5);
4035 * } else if(m == 1) {
4036 * return(3.0*x*sqrt(1.0 - x*x));
4037 * } else if(m == 2) {
4038 * return(3.0 - 3.0*x*x);
4046 * double System::DP(int m, double x)
4050 * } else if(m == 1) {
4051 * return((3.0 - 6.0*x*x)/sqrt(1.0 - x*x));
4052 * } else if(m == 2) {
4066 * #endif /* LOCALMATH_H */
void attach_dof_handler(const DoFHandler< dim, spacedim > &)
virtual void vector_value_list(const std::vector< Point< dim > > &points, std::vector< Vector< RangeNumberType > > &values) const
virtual RangeNumberType value(const Point< dim > &p, const unsigned int component=0) const
virtual void vector_value(const Point< dim > &p, Vector< RangeNumberType > &values) const
typename SparseLUDecomposition< number >::AdditionalData AdditionalData
void initialize(const SparseMatrix< somenumber > &matrix, const AdditionalData ¶meters=AdditionalData())
#define DEAL_II_DISABLE_EXTRA_DIAGNOSTICS
#define DEAL_II_ENABLE_EXTRA_DIAGNOSTICS
__global__ void set(Number *val, const Number s, const size_type N)
#define Assert(cond, exc)
#define AssertThrow(cond, exc)
typename ActiveSelector::active_cell_iterator active_cell_iterator
LinearOperator< Range_2, Domain_2, Payload > schur_complement(const LinearOperator< Domain_1, Range_1, Payload > &A_inv, const LinearOperator< Range_1, Domain_2, Payload > &B, const LinearOperator< Range_2, Domain_1, Payload > &C, const LinearOperator< Range_2, Domain_2, Payload > &D)
void loop(ITERATOR begin, std_cxx20::type_identity_t< ITERATOR > end, DOFINFO &dinfo, INFOBOX &info, const std::function< void(DOFINFO &, typename INFOBOX::CellInfo &)> &cell_worker, const std::function< void(DOFINFO &, typename INFOBOX::CellInfo &)> &boundary_worker, const std::function< void(DOFINFO &, DOFINFO &, typename INFOBOX::CellInfo &, typename INFOBOX::CellInfo &)> &face_worker, ASSEMBLER &assembler, const LoopControl &lctrl=LoopControl())
void compute_no_normal_flux_constraints(const DoFHandler< dim, spacedim > &dof_handler, const unsigned int first_vector_component, const std::set< types::boundary_id > &boundary_ids, AffineConstraints< double > &constraints, const Mapping< dim, spacedim > &mapping=(ReferenceCells::get_hypercube< dim >() .template get_default_linear_mapping< dim, spacedim >()))
void make_hanging_node_constraints(const DoFHandler< dim, spacedim > &dof_handler, AffineConstraints< number > &constraints)
void make_sparsity_pattern(const DoFHandler< dim, spacedim > &dof_handler, SparsityPatternBase &sparsity_pattern, const AffineConstraints< number > &constraints=AffineConstraints< number >(), const bool keep_constrained_dofs=true, const types::subdomain_id subdomain_id=numbers::invalid_subdomain_id)
@ update_values
Shape function values.
@ update_JxW_values
Transformed quadrature weights.
@ update_gradients
Shape function gradients.
@ update_quadrature_points
Transformed quadrature points.
std::vector< value_type > l2_norm(const typename ::Triangulation< dim, spacedim >::cell_iterator &parent, const value_type parent_value)
@ component_is_part_of_vector
Expression floor(const Expression &x)
void component_wise(DoFHandler< dim, spacedim > &dof_handler, const std::vector< unsigned int > &target_component=std::vector< unsigned int >())
void Cuthill_McKee(DoFHandler< dim, spacedim > &dof_handler, const bool reversed_numbering=false, const bool use_constraints=false, const std::vector< types::global_dof_index > &starting_indices=std::vector< types::global_dof_index >())
@ valid
Iterator points to a valid object.
@ matrix
Contents is actually a matrix.
Point< spacedim > point(const gp_Pnt &p, const double tolerance=1e-10)
SymmetricTensor< 2, dim, Number > e(const Tensor< 2, dim, Number > &F)
SymmetricTensor< 2, dim, Number > b(const Tensor< 2, dim, Number > &F)
Number angle(const Tensor< 1, spacedim, Number > &a, const Tensor< 1, spacedim, Number > &b)
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)
bool check(const ConstraintKinds kind_in, const unsigned int dim)
int(&) functions(const void *v1, const void *v2)
::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)
::VectorizedArray< Number, width > abs(const ::VectorizedArray< Number, width > &)
const ::parallel::distributed::Triangulation< dim, spacedim > * triangulation
const ::Triangulation< dim, spacedim > & tria