Flow123d  JS_before_hm-919-g5f1bbbf
elasticity.hh
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file elasticity.hh
15  * @brief FEM for linear elasticity.
16  * @author Jan Stebel
17  */
18 
19 #ifndef ELASTICITY_HH_
20 #define ELASTICITY_HH_
21 
22 #include "fields/bc_field.hh"
23 #include "fields/field.hh"
24 #include "fields/field_fe.hh"
25 #include "fields/multi_field.hh"
26 #include "la/linsys.hh"
27 #include "la/vector_mpi.hh"
29 #include "coupling/equation.hh"
30 #include "fem/fe_values_views.hh"
31 #include "tools/mixed.hh"
33 
34 class Distribution;
35 class OutputTime;
36 class DOFHandlerMultiDim;
37 template<unsigned int dim> class FiniteElement;
38 class Elasticity;
39 
40 
41 namespace Mechanics {
42 
43 /**
44  * Auxiliary container class for Finite element and related objects of all dimensions.
45  * Its purpose is to provide templated access to these objects, applicable in
46  * the assembling methods.
47  */
48 class FEObjects {
49 public:
50 
51  FEObjects(Mesh *mesh_, unsigned int fe_order);
52  ~FEObjects();
53 
54  template<unsigned int dim>
55  inline std::shared_ptr<FiniteElement<dim>> fe();
56 
57  template<unsigned int dim>
58  inline Quadrature *q() { return &(q_[dim]); }
59 
60  inline std::shared_ptr<DOFHandlerMultiDim> dh();
61  inline std::shared_ptr<DOFHandlerMultiDim> dh_scalar();
62  inline std::shared_ptr<DOFHandlerMultiDim> dh_tensor();
63 
64 // const FEValuesViews::Vector<dim,3> vec;
65 
66 private:
67 
68  MixedPtr<FiniteElement> fe_; ///< Finite elements for the solution of the mechanics equation.
70 
71 
72  std::shared_ptr<DiscreteSpace> ds_;
73 
74  /// Object for distribution of dofs.
75  std::shared_ptr<DOFHandlerMultiDim> dh_;
76  std::shared_ptr<DOFHandlerMultiDim> dh_scalar_;
77  std::shared_ptr<DOFHandlerMultiDim> dh_tensor_;
78 };
79 
80 
81 } // namespace Mechanics
82 
83 
84 
85 
86 
87 class Elasticity : public EquationBase
88 {
89 public:
90 
91  class EqData : public FieldSet {
92  public:
93 
94  enum Bc_types {
97  bc_type_traction
98  };
99 
100  EqData();
101 
102  static constexpr const char * name() { return "Mechanics_LinearElasticity"; }
103 
104  static string default_output_field() { return "\"displacement\""; }
105 
106  static const Input::Type::Selection & get_bc_type_selection();
107 
108  static IT::Selection get_output_selection();
109 
110 
117  Field<3, FieldValue<3>::Scalar> fracture_sigma; ///< Transition parameter for diffusive transfer on fractures.
118 
119  /// Pointer to DarcyFlow field cross_section
121  Field<3, FieldValue<3>::Scalar > potential_load; ///< Potential of an additional (external) load.
124 
130 
131  std::shared_ptr<FieldFE<3, FieldValue<3>::VectorFixed> > output_field_ptr;
132  std::shared_ptr<FieldFE<3, FieldValue<3>::TensorFixed> > output_stress_ptr;
133  std::shared_ptr<FieldFE<3, FieldValue<3>::Scalar> > output_von_mises_stress_ptr;
134  std::shared_ptr<FieldFE<3, FieldValue<3>::Scalar> > output_cross_section_ptr;
135  std::shared_ptr<FieldFE<3, FieldValue<3>::Scalar> > output_div_ptr;
136 
138 
139  };
140 
141 
142 
143  /**
144  * @brief Constructor.
145  * @param init_mesh computational mesh
146  * @param in_rec input record
147  * @param tm time governor (if nullptr then it is created from input record)
148  */
149  Elasticity(Mesh &init_mesh, const Input::Record in_rec, TimeGovernor *tm = nullptr);
150  /**
151 
152  * @brief Declare input record type for the equation TransportDG.
153  */
154  static const Input::Type::Record & get_input_type();
155 
156  /**
157  * @brief Initialize solution in the zero time.
158  */
159  void zero_time_step() override;
160 
162  { return false; }
163 
164  /**
165  * @brief Computes the solution in one time instant.
166  */
167  void update_solution() override;
168 
169  /// Pass to next time and update equation data.
170  void next_time();
171 
172  /// Solve without updating time step and without output.
173  void solve_linear_system();
174 
175  /**
176  * @brief Postprocesses the solution and writes to output file.
177  */
178  void output_data();
179 
180  /**
181  * @brief Destructor.
182  */
183  ~Elasticity();
184 
185  void initialize() override;
186 
187  // Recompute fields for output (stress, divergence etc.)
188  void update_output_fields();
189 
190  void set_potential_load(const Field<3, FieldValue<3>::Scalar> &potential)
191  { data_.potential_load = potential; }
192 
193  void calculate_cumulative_balance();
194 
195  const Vec &get_solution()
196  { return ls->get_solution(); }
197 
198  inline EqData &data() { return data_; }
199 
200 
202 
203 
204 
205 
206 private:
207  /// Registrar of class to factory
208  static const int registrar;
209 
210  template<unsigned int dim>
211  void compute_output_fields();
212 
213  void preallocate();
214 
215  /**
216  * @brief Assembles the stiffness matrix.
217  *
218  * This routine just calls assemble_volume_integrals(), assemble_fluxes_boundary(),
219  * assemble_fluxes_element_element() and assemble_fluxes_element_side() for each
220  * space dimension.
221  */
222  void assemble_stiffness_matrix();
223 
224  /**
225  * @brief Assembles the volume integrals into the stiffness matrix.
226  */
227  template<unsigned int dim>
228  void assemble_volume_integrals();
229 
230  /**
231  * @brief Assembles the right hand side (forces, boundary conditions, tractions).
232  */
233  void assemble_rhs();
234 
235  /**
236  * @brief Assembles the right hand side vector due to volume sources.
237  */
238  template<unsigned int dim>
239  void assemble_sources();
240 
241  /**
242  * @brief Assembles the fluxes on the boundary.
243  */
244  template<unsigned int dim>
245  void assemble_fluxes_boundary();
246 
247  /**
248  * @brief Assembles the fluxes between elements of different dimensions depending on displacement.
249  */
250  template<unsigned int dim>
251  void assemble_matrix_element_side();
252 
253  /** @brief Assemble fluxes between different dimensions that are independent of displacement. */
254  template<unsigned int dim>
255  void assemble_rhs_element_side();
256 
257 
258  /**
259  * @brief Assembles the r.h.s. components corresponding to the Dirichlet boundary conditions
260  * for a given space dimension.
261  */
262  template<unsigned int dim>
263  void assemble_boundary_conditions();
264 
265  /** @brief Penalty to enforce boundary value in weak sense. */
266  double dirichlet_penalty(SideIter side);
267 
268 
269 
270 
271  /// @name Physical parameters
272  // @{
273 
274  /// Field data for model parameters.
276 
277  // @}
278 
279 
280  /// @name Parameters of the numerical method
281  // @{
282 
283  /// Finite element objects
285 
286  // @}
287 
288 
289 
290  /// @name Solution of algebraic system
291  // @{
292 
293  /// Vector of right hand side.
294  Vec rhs;
295 
296  /// The stiffness matrix.
298 
299  /// Linear algebra system for the transport equation.
301 
302  // @}
303 
304 
305  /// @name Output to file
306  // @{
307 
308  std::shared_ptr<OutputTime> output_stream_;
309 
310  /// Record with input specification.
312 
313 
314  // @}
315 
316 
317 
318 
319  /// @name Other
320  // @{
321 
322  /// Indicates whether matrices have been preallocated.
324 
325  // @}
326 };
327 
328 
329 
330 double lame_mu(double young, double poisson);
331 double lame_lambda(double young, double poisson);
332 
333 
334 
335 
336 
337 
338 #endif /* ELASTICITY_HH_ */
BCField< 3, FieldValue< 3 >::Enum > bc_type
Definition: elasticity.hh:111
std::shared_ptr< DiscreteSpace > ds_
Definition: elasticity.hh:72
BCField< 3, FieldValue< 3 >::VectorFixed > bc_displacement
Definition: elasticity.hh:112
Field< 3, FieldValue< 3 >::TensorFixed > output_stress
Definition: elasticity.hh:126
Field< 3, FieldValue< 3 >::Scalar > young_modulus
Definition: elasticity.hh:115
Abstract base class for equation clasess.
static constexpr const char * name()
Definition: elasticity.hh:102
Container for various descendants of FieldCommonBase.
Definition: field_set.hh:74
double lame_lambda(double young, double poisson)
Definition: elasticity.cc:134
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > output_von_mises_stress_ptr
Definition: elasticity.hh:133
Field< 3, FieldValue< 3 >::Scalar > output_von_mises_stress
Definition: elasticity.hh:127
Field< 3, FieldValue< 3 >::Scalar > region_id
Definition: elasticity.hh:122
Field< 3, FieldValue< 3 >::Scalar > output_cross_section
Definition: elasticity.hh:128
const Vec & get_solution()
Definition: elasticity.hh:195
Wrappers for linear systems based on MPIAIJ and MATIS format.
Class template representing a field with values dependent on: point, element, and region...
Definition: field.hh:92
FEObjects(Mesh *mesh_, unsigned int fe_order)
Definition: elasticity.cc:75
LinSys * ls
Linear algebra system for the transport equation.
Definition: elasticity.hh:300
Definition: mesh.h:78
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::TensorFixed > > output_stress_ptr
Definition: elasticity.hh:132
Field< 3, FieldValue< 3 >::Scalar > cross_section
Pointer to DarcyFlow field cross_section.
Definition: elasticity.hh:120
std::shared_ptr< DOFHandlerMultiDim > dh()
Definition: elasticity.cc:119
Basic time management functionality for unsteady (and steady) solvers (class Equation).
Input::Record input_rec
Record with input specification.
Definition: elasticity.hh:311
Field< 3, FieldValue< 3 >::Scalar > potential_load
Potential of an additional (external) load.
Definition: elasticity.hh:121
Vec rhs
Vector of right hand side.
Definition: elasticity.hh:294
Base class for quadrature rules on simplices in arbitrary dimensions.
Definition: quadrature.hh:48
bool allocation_done
Indicates whether matrices have been preallocated.
Definition: elasticity.hh:323
BCField< 3, FieldValue< 3 >::VectorFixed > bc_traction
Definition: elasticity.hh:113
Accessor to the data with type Type::Record.
Definition: accessors.hh:292
MixedPtr< FiniteElement > fe_
Finite elements for the solution of the mechanics equation.
Definition: elasticity.hh:68
Provides the numbering of the finite element degrees of freedom on the computational mesh...
Definition: dofhandler.hh:151
Field< 3, FieldValue< 3 >::Scalar > output_divergence
Definition: elasticity.hh:129
The class for outputting data during time.
Definition: output_time.hh:50
Mat stiffness_matrix
The stiffness matrix.
Definition: elasticity.hh:297
std::shared_ptr< FiniteElement< dim > > fe()
Quadrature * q()
Definition: elasticity.hh:58
EqData & data()
Definition: elasticity.hh:198
Field< 3, FieldValue< 3 >::VectorFixed > load
Definition: elasticity.hh:114
Field< 3, FieldValue< 3 >::Scalar > fracture_sigma
Transition parameter for diffusive transfer on fractures.
Definition: elasticity.hh:117
Elasticity FactoryBaseType
Definition: elasticity.hh:201
double lame_mu(double young, double poisson)
Definition: elasticity.cc:128
std::array< QGauss, 4 > array
Field< 3, FieldValue< 3 >::Scalar > poisson_ratio
Definition: elasticity.hh:116
std::shared_ptr< DOFHandlerMultiDim > dh_tensor_
Definition: elasticity.hh:77
EquationOutput output_fields
Definition: elasticity.hh:137
static const int registrar
Registrar of class to factory.
Definition: elasticity.hh:208
EqData data_
Field data for model parameters.
Definition: elasticity.hh:275
QGauss::array q_
Definition: elasticity.hh:69
Definitions of particular quadrature rules on simplices.
static string default_output_field()
Definition: elasticity.hh:104
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::VectorFixed > > output_field_ptr
Definition: elasticity.hh:131
void set_potential_load(const Field< 3, FieldValue< 3 >::Scalar > &potential)
Definition: elasticity.hh:190
std::shared_ptr< DOFHandlerMultiDim > dh_
Object for distribution of dofs.
Definition: elasticity.hh:75
std::shared_ptr< DOFHandlerMultiDim > dh_scalar()
Definition: elasticity.cc:120
Record type proxy class.
Definition: type_record.hh:182
Abstract class for the description of a general finite element on a reference simplex in dim dimensio...
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > output_div_ptr
Definition: elasticity.hh:135
std::shared_ptr< DOFHandlerMultiDim > dh_tensor()
Definition: elasticity.cc:121
bool evaluate_time_constraint(double &)
Definition: elasticity.hh:161
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > output_cross_section_ptr
Definition: elasticity.hh:134
Field< 3, FieldValue< 3 >::VectorFixed > output_field
Definition: elasticity.hh:125
std::shared_ptr< DOFHandlerMultiDim > dh_scalar_
Definition: elasticity.hh:76
Template for classes storing finite set of named values.
Field< 3, FieldValue< 3 >::Scalar > subdomain
Definition: elasticity.hh:123
std::shared_ptr< OutputTime > output_stream_
Definition: elasticity.hh:308
Mechanics::FEObjects * feo
Finite element objects.
Definition: elasticity.hh:284