746 *
sparsity_pattern.copy_from(
dsp);
748 *
system_matrix.
reinit(sparsity_pattern);
755 * <a name=
"ElasticProblemassemble_system"></a>
789 *
const unsigned int dofs_per_cell = fe.n_dofs_per_cell();
795 *
std::vector<types::global_dof_index> local_dof_indices(dofs_per_cell);
806 *
std::vector<double>
mu_values(n_q_points);
826 *
std::vector<Tensor<1, dim>>
rhs_values(n_q_points);
833 *
for (
const auto &cell : dof_handler.active_cell_iterators())
847 *
mu.value_list(fe_values.get_quadrature_points(),
mu_values);
858 * <
code>fe.system_to_component_index(i).first</
code> function
call
880 *
for (
const unsigned int i : fe_values.dof_indices())
883 *
fe.system_to_component_index(i).
first;
885 *
for (
const unsigned int j : fe_values.dof_indices())
888 *
fe.system_to_component_index(
j).
first;
890 *
for (
const unsigned int q_point :
891 *
fe_values.quadrature_point_indices())
935 *
(fe_values.shape_grad(i,
q_point) *
936 *
fe_values.shape_grad(
j,
q_point) *
951 *
for (
const unsigned int i : fe_values.dof_indices())
954 *
fe.system_to_component_index(i).
first;
956 *
for (
const unsigned int q_point :
957 *
fe_values.quadrature_point_indices())
971 *
cell->get_dof_indices(local_dof_indices);
972 *
constraints.distribute_local_to_global(
982 * <a name=
"ElasticProblemsolve"></a>
983 * <
h4>ElasticProblem::solve</
h4>
1000 *
preconditioner.initialize(system_matrix, 1.2);
1002 *
cg.solve(system_matrix, solution,
system_rhs, preconditioner);
1004 *
constraints.distribute(solution);
1011 * <a name=
"ElasticProblemrefine_grid"></a>
1012 * <
h4>ElasticProblem::refine_grid</
h4>
1028 *
template <
int dim>
1051 * <a name=
"ElasticProblemoutput_results"></a>
1063 *
To do this,
the DataOut::add_vector() function
wants a vector
of
1092 *
data_out.attach_dof_handler(dof_handler);
1126 *
data_out.build_patches();
1128 *
std::ofstream output(
"solution-" + std::to_string(cycle) +
".vtk");
1129 *
data_out.write_vtk(output);
1137 * <a name=
"ElasticProblemrun"></a>
1138 * <
h4>ElasticProblem::run</
h4>
1171 * Triangulation::refine_and_coarsen_fixed_number()
will not flag any cells
1189 *
for (
unsigned int cycle = 0; cycle < 8; ++cycle)
1191 *
std::cout <<
"Cycle " << cycle <<
':' << std::endl;
1201 *
std::cout <<
" Number of active cells: "
1206 *
std::cout <<
" Number of degrees of freedom: " << dof_handler.n_dofs()
1219 * <a name=
"Thecodemaincodefunction"></a>
1236 *
catch (std::exception &exc)
1238 *
std::cerr << std::endl
1240 *
<<
"----------------------------------------------------"
1242 *
std::cerr <<
"Exception on processing: " << std::endl
1243 *
<< exc.what() << std::endl
1244 *
<<
"Aborting!" << std::endl
1245 *
<<
"----------------------------------------------------"
1252 *
std::cerr << std::endl
1254 *
<<
"----------------------------------------------------"
1256 *
std::cerr <<
"Unknown exception!" << std::endl
1257 *
<<
"Aborting!" << std::endl
1258 *
<<
"----------------------------------------------------"
1278<
img src=
"https://www.dealii.org/images/steps/developer/step-8.x.png" alt=
"">
1281<
img src=
"https://www.dealii.org/images/steps/developer/step-8.y.png" alt=
"">
1293this is so, remember that we have just defined our finite element as a
1294collection of two components (in <code>dim=2</code> dimensions). Nowhere have
1295we said that this is not just a pressure and a concentration (two scalar
1296quantities) but that the two components actually are the parts of a
1297vector-valued quantity, namely the displacement. Absent this knowledge, the
1298DataOut class assumes that all individual variables we print are separate
1299scalars, and VisIt and Paraview then faithfully assume that this is indeed what it is. In
1300other words, once we have written the data as scalars, there is nothing in
1301these programs that allows us to paste these two scalar fields back together as a
1302vector field. Where we would have to attack this problem is at the root,
1303namely in <code>ElasticProblem::output_results()</code>. We won't
do so here but
1306anyway that would show how this would look if implemented as discussed in
1307@ref step_22 "step-22". The vector field then looks like this (VisIt and Paraview
1308randomly select a few
1309hundred vertices from which to draw the vectors; drawing them from each
1310individual vertex would make the picture unreadable):
1312<img src="https://www.dealii.org/images/steps/developer/step-8.vectors.png" alt="">
1315We note that one may have intuitively expected the
1316solution to be symmetric about the @f$x@f$- and @f$y@f$-axes since the @f$x@f$- and
1317@f$y@f$-forces are symmetric with respect to these axes. However, the force
1318considered as a vector is not symmetric and consequently neither is
1322<a name="PlainProg"></a>
1323<h1> The plain program</h1>
void reinit(value_type *starting_element, const std::size_t n_elements)
static void estimate(const Mapping< dim, spacedim > &mapping, const DoFHandler< dim, spacedim > &dof, const Quadrature< dim - 1 > &quadrature, const std::map< types::boundary_id, const Function< spacedim, typename InputVector::value_type > * > &neumann_bc, const InputVector &solution, Vector< float > &error, const ComponentMask &component_mask=ComponentMask(), const Function< spacedim > *coefficients=nullptr, const unsigned int n_threads=numbers::invalid_unsigned_int, const types::subdomain_id subdomain_id=numbers::invalid_subdomain_id, const types::material_id material_id=numbers::invalid_material_id, const Strategy strategy=cell_diameter_over_24)
static ::ExceptionBase & ExcNotImplemented()
#define Assert(cond, exc)
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())
@ update_values
Shape function values.
@ update_JxW_values
Transformed quadrature weights.
@ update_gradients
Shape function gradients.
@ update_quadrature_points
Transformed quadrature points.
void hyper_cube(Triangulation< dim, spacedim > &tria, const double left=0., const double right=1., const bool colorize=false)
void refine(Triangulation< dim, spacedim > &tria, const Vector< Number > &criteria, const double threshold, const unsigned int max_to_mark=numbers::invalid_unsigned_int)
void refine_and_coarsen_fixed_number(Triangulation< dim, spacedim > &triangulation, const Vector< Number > &criteria, const double top_fraction_of_cells, const double bottom_fraction_of_cells, const unsigned int max_n_cells=std::numeric_limits< unsigned int >::max())
@ matrix
Contents is actually a matrix.
@ symmetric
Matrix is symmetric.
@ general
No special properties.
void cell_matrix(FullMatrix< double > &M, const FEValuesBase< dim > &fe, const FEValuesBase< dim > &fetest, const ArrayView< const std::vector< double > > &velocity, const double factor=1.)
Point< spacedim > point(const gp_Pnt &p, const double tolerance=1e-10)
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
void call(const std::function< RT()> &function, internal::return_value< RT > &ret_val)
VectorType::value_type * begin(VectorType &V)
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)
int(&) functions(const void *v1, const void *v2)
void assemble(const MeshWorker::DoFInfoBox< dim, DOFINFO > &dinfo, A *assembler)
const ::parallel::distributed::Triangulation< dim, spacedim > * triangulation