Flow123d  JS_before_hm-1013-g06f2edc
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 {
99  };
100 
101  EqData();
102 
103  static constexpr const char * name() { return "Mechanics_LinearElasticity"; }
104 
105  static string default_output_field() { return "\"displacement\""; }
106 
107  static const Input::Type::Selection & get_bc_type_selection();
108 
109  static IT::Selection get_output_selection();
110 
111 
119  Field<3, FieldValue<3>::Scalar> fracture_sigma; ///< Transition parameter for diffusive transfer on fractures.
120 
121  /// Pointer to DarcyFlow field cross_section
123  Field<3, FieldValue<3>::Scalar > potential_load; ///< Potential of an additional (external) load.
126 
132 
133  std::shared_ptr<FieldFE<3, FieldValue<3>::VectorFixed> > output_field_ptr;
134  std::shared_ptr<FieldFE<3, FieldValue<3>::TensorFixed> > output_stress_ptr;
135  std::shared_ptr<FieldFE<3, FieldValue<3>::Scalar> > output_von_mises_stress_ptr;
136  std::shared_ptr<FieldFE<3, FieldValue<3>::Scalar> > output_cross_section_ptr;
137  std::shared_ptr<FieldFE<3, FieldValue<3>::Scalar> > output_div_ptr;
138 
140 
141  };
142 
143 
144 
145  /**
146  * @brief Constructor.
147  * @param init_mesh computational mesh
148  * @param in_rec input record
149  * @param tm time governor (if nullptr then it is created from input record)
150  */
151  Elasticity(Mesh &init_mesh, const Input::Record in_rec, TimeGovernor *tm = nullptr);
152  /**
153 
154  * @brief Declare input record type for the equation TransportDG.
155  */
156  static const Input::Type::Record & get_input_type();
157 
158  /**
159  * @brief Initialize solution in the zero time.
160  */
161  void zero_time_step() override;
162 
164  { return false; }
165 
166  /**
167  * @brief Computes the solution in one time instant.
168  */
169  void update_solution() override;
170 
171  /// Pass to next time and update equation data.
172  void next_time();
173 
174  /// Solve without updating time step and without output.
175  void solve_linear_system();
176 
177  /**
178  * @brief Postprocesses the solution and writes to output file.
179  */
180  void output_data();
181 
182  /**
183  * @brief Destructor.
184  */
185  ~Elasticity();
186 
187  void initialize() override;
188 
189  // Recompute fields for output (stress, divergence etc.)
190  void update_output_fields();
191 
192  void set_potential_load(const Field<3, FieldValue<3>::Scalar> &potential)
193  { data_.potential_load = potential; }
194 
195  void calculate_cumulative_balance();
196 
197  const Vec &get_solution()
198  { return ls->get_solution(); }
199 
200  inline EqData &data() { return data_; }
201 
202 
204 
205 
206 
207 
208 private:
209  /// Registrar of class to factory
210  static const int registrar;
211 
212  template<unsigned int dim>
213  void compute_output_fields();
214 
215  void preallocate();
216 
217  /**
218  * @brief Assembles the stiffness matrix.
219  *
220  * This routine just calls assemble_volume_integrals(), assemble_fluxes_boundary(),
221  * assemble_fluxes_element_element() and assemble_fluxes_element_side() for each
222  * space dimension.
223  */
224  void assemble_stiffness_matrix();
225 
226  /**
227  * @brief Assembles the volume integrals into the stiffness matrix.
228  */
229  template<unsigned int dim>
230  void assemble_volume_integrals();
231 
232  /**
233  * @brief Assembles the right hand side (forces, boundary conditions, tractions).
234  */
235  void assemble_rhs();
236 
237  /**
238  * @brief Assembles the right hand side vector due to volume sources.
239  */
240  template<unsigned int dim>
241  void assemble_sources();
242 
243  /**
244  * @brief Assembles the fluxes on the boundary.
245  */
246  template<unsigned int dim>
247  void assemble_fluxes_boundary();
248 
249  /**
250  * @brief Assembles the fluxes between elements of different dimensions depending on displacement.
251  */
252  template<unsigned int dim>
253  void assemble_matrix_element_side();
254 
255  /** @brief Assemble fluxes between different dimensions that are independent of displacement. */
256  template<unsigned int dim>
257  void assemble_rhs_element_side();
258 
259 
260  /**
261  * @brief Assembles the r.h.s. components corresponding to the Dirichlet boundary conditions
262  * for a given space dimension.
263  */
264  template<unsigned int dim>
265  void assemble_boundary_conditions();
266 
267  /** @brief Penalty to enforce boundary value in weak sense. */
268  double dirichlet_penalty(SideIter side);
269 
270 
271 
272 
273  /// @name Physical parameters
274  // @{
275 
276  /// Field data for model parameters.
278 
279  // @}
280 
281 
282  /// @name Parameters of the numerical method
283  // @{
284 
285  /// Finite element objects
287 
288  // @}
289 
290 
291 
292  /// @name Solution of algebraic system
293  // @{
294 
295  /// Vector of right hand side.
296  Vec rhs;
297 
298  /// The stiffness matrix.
300 
301  /// Linear algebra system for the transport equation.
303 
304  // @}
305 
306 
307  /// @name Output to file
308  // @{
309 
310  std::shared_ptr<OutputTime> output_stream_;
311 
312  /// Record with input specification.
314 
315 
316  // @}
317 
318 
319 
320 
321  /// @name Other
322  // @{
323 
324  /// Indicates whether matrices have been preallocated.
326 
327  // @}
328 };
329 
330 
331 
332 double lame_mu(double young, double poisson);
333 double lame_lambda(double young, double poisson);
334 
335 
336 
337 
338 
339 
340 #endif /* ELASTICITY_HH_ */
BCField< 3, FieldValue< 3 >::Enum > bc_type
Definition: elasticity.hh:112
std::shared_ptr< DiscreteSpace > ds_
Definition: elasticity.hh:72
BCField< 3, FieldValue< 3 >::VectorFixed > bc_displacement
Definition: elasticity.hh:113
Field< 3, FieldValue< 3 >::TensorFixed > output_stress
Definition: elasticity.hh:128
Field< 3, FieldValue< 3 >::Scalar > young_modulus
Definition: elasticity.hh:117
Abstract base class for equation clasess.
static constexpr const char * name()
Definition: elasticity.hh:103
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:135
Field< 3, FieldValue< 3 >::Scalar > output_von_mises_stress
Definition: elasticity.hh:129
Field< 3, FieldValue< 3 >::Scalar > region_id
Definition: elasticity.hh:124
Field< 3, FieldValue< 3 >::Scalar > output_cross_section
Definition: elasticity.hh:130
const Vec & get_solution()
Definition: elasticity.hh:197
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:302
Definition: mesh.h:78
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::TensorFixed > > output_stress_ptr
Definition: elasticity.hh:134
Field< 3, FieldValue< 3 >::Scalar > cross_section
Pointer to DarcyFlow field cross_section.
Definition: elasticity.hh:122
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:313
Field< 3, FieldValue< 3 >::Scalar > potential_load
Potential of an additional (external) load.
Definition: elasticity.hh:123
Vec rhs
Vector of right hand side.
Definition: elasticity.hh:296
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:325
BCField< 3, FieldValue< 3 >::VectorFixed > bc_traction
Definition: elasticity.hh:114
Accessor to the data with type Type::Record.
Definition: accessors.hh:291
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:131
The class for outputting data during time.
Definition: output_time.hh:50
Mat stiffness_matrix
The stiffness matrix.
Definition: elasticity.hh:299
std::shared_ptr< FiniteElement< dim > > fe()
Quadrature * q()
Definition: elasticity.hh:58
EqData & data()
Definition: elasticity.hh:200
Field< 3, FieldValue< 3 >::VectorFixed > load
Definition: elasticity.hh:116
Field< 3, FieldValue< 3 >::Scalar > fracture_sigma
Transition parameter for diffusive transfer on fractures.
Definition: elasticity.hh:119
Elasticity FactoryBaseType
Definition: elasticity.hh:203
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:118
std::shared_ptr< DOFHandlerMultiDim > dh_tensor_
Definition: elasticity.hh:77
BCField< 3, FieldValue< 3 >::TensorFixed > bc_stress
Definition: elasticity.hh:115
EquationOutput output_fields
Definition: elasticity.hh:139
static const int registrar
Registrar of class to factory.
Definition: elasticity.hh:210
EqData data_
Field data for model parameters.
Definition: elasticity.hh:277
QGauss::array q_
Definition: elasticity.hh:69
Definitions of particular quadrature rules on simplices.
static string default_output_field()
Definition: elasticity.hh:105
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::VectorFixed > > output_field_ptr
Definition: elasticity.hh:133
void set_potential_load(const Field< 3, FieldValue< 3 >::Scalar > &potential)
Definition: elasticity.hh:192
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:137
std::shared_ptr< DOFHandlerMultiDim > dh_tensor()
Definition: elasticity.cc:121
bool evaluate_time_constraint(double &)
Definition: elasticity.hh:163
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > output_cross_section_ptr
Definition: elasticity.hh:136
Field< 3, FieldValue< 3 >::VectorFixed > output_field
Definition: elasticity.hh:127
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:125
std::shared_ptr< OutputTime > output_stream_
Definition: elasticity.hh:310
Mechanics::FEObjects * feo
Finite element objects.
Definition: elasticity.hh:286