Flow123d  JS_before_hm-62-ge56f9d5
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"
28 #include "flow/mh_dofhandler.hh"
30 #include "fem/mapping_p1.hh"
31 #include "coupling/equation.hh"
32 #include "fem/fe_values_views.hh"
33 
34 class Distribution;
35 class OutputTime;
36 class DOFHandlerMultiDim;
37 template<unsigned int dim, unsigned int spacedim> class FEValuesBase;
38 template<unsigned int dim> class FiniteElement;
39 template<unsigned int dim, unsigned int spacedim> class Mapping;
40 class Quadrature;
41 class Elasticity;
42 
43 
44 namespace Mechanics {
45 
46 /**
47  * Auxiliary container class for Finite element and related objects of all dimensions.
48  * Its purpose is to provide templated access to these objects, applicable in
49  * the assembling methods.
50  */
51 class FEObjects {
52 public:
53 
54  FEObjects(Mesh *mesh_, unsigned int fe_order);
55  ~FEObjects();
56 
57  template<unsigned int dim>
58  inline FiniteElement<dim> *fe();
59 
60  template<unsigned int dim>
61  inline Quadrature *q() { return q_[dim]; }
62 
63  template<unsigned int dim>
64  inline MappingP1<dim,3> *mapping();
65 
66  inline std::shared_ptr<DOFHandlerMultiDim> dh();
67  inline std::shared_ptr<DOFHandlerMultiDim> dh_scalar();
68  inline std::shared_ptr<DOFHandlerMultiDim> dh_tensor();
69 
70 // const FEValuesViews::Vector<dim,3> vec;
71 
72 private:
73 
74  /// Finite elements for the solution of the mechanics equation.
79 
80  /// Quadratures used in assembling methods.
82 
83  /// Auxiliary mappings of reference elements.
87 
88  std::shared_ptr<DiscreteSpace> ds_;
89 
90  /// Object for distribution of dofs.
91  std::shared_ptr<DOFHandlerMultiDim> dh_;
92  std::shared_ptr<DOFHandlerMultiDim> dh_scalar_;
93  std::shared_ptr<DOFHandlerMultiDim> dh_tensor_;
94 };
95 
96 
97 } // namespace Mechanics
98 
99 
100 
101 
102 
103 class Elasticity : public EquationBase
104 {
105 public:
106 
107  class EqData : public FieldSet {
108  public:
109 
110  enum Bc_types {
113  bc_type_traction
114  };
115 
116  EqData();
117 
118  static constexpr const char * name() { return "Mechanics_LinearElasticity"; }
119 
120  static string default_output_field() { return "\"displacement\""; }
121 
122  static const Input::Type::Selection & get_bc_type_selection();
123 
124  static IT::Selection get_output_selection();
125 
126 
133  Field<3, FieldValue<3>::Scalar> fracture_sigma; ///< Transition parameter for diffusive transfer on fractures.
134 
135  /// Pointer to DarcyFlow field cross_section
137  Field<3, FieldValue<3>::Scalar > potential_load; ///< Potential of an additional (external) load.
140 
146 
147  std::shared_ptr<FieldFE<3, FieldValue<3>::VectorFixed> > output_field_ptr;
148  std::shared_ptr<FieldFE<3, FieldValue<3>::TensorFixed> > output_stress_ptr;
149  std::shared_ptr<FieldFE<3, FieldValue<3>::Scalar> > output_von_mises_stress_ptr;
150  std::shared_ptr<FieldFE<3, FieldValue<3>::Scalar> > output_cross_section_ptr;
151  std::shared_ptr<FieldFE<3, FieldValue<3>::Scalar> > output_div_ptr;
152 
154 
155  };
156 
157 
158 
159  /**
160  * @brief Constructor.
161  * @param init_mesh computational mesh
162  * @param in_rec input record
163  * @param tm time governor (if nullptr then it is created from input record)
164  */
165  Elasticity(Mesh &init_mesh, const Input::Record in_rec, TimeGovernor *tm = nullptr);
166  /**
167 
168  * @brief Declare input record type for the equation TransportDG.
169  */
170  static const Input::Type::Record & get_input_type();
171 
172  /**
173  * @brief Initialize solution in the zero time.
174  */
175  void zero_time_step() override;
176 
178  { return false; }
179 
180  /**
181  * @brief Computes the solution in one time instant.
182  */
183  void update_solution() override;
184 
185  /// Pass to next time and update equation data.
186  void next_time();
187 
188  /// Solve without updating time step and without output.
189  void solve_linear_system();
190 
191  /**
192  * @brief Postprocesses the solution and writes to output file.
193  */
194  void output_data();
195 
196  /**
197  * @brief Destructor.
198  */
199  ~Elasticity();
200 
201  void initialize() override;
202 
203  void output_vector_gather();
204 
205  void set_potential_load(const Field<3, FieldValue<3>::Scalar> &potential)
206  { data_.potential_load = potential; }
207 
208  void calculate_cumulative_balance();
209 
210  const Vec &get_solution()
211  { return ls->get_solution(); }
212 
213  inline EqData &data() { return data_; }
214 
215 
217 
218 
219 
220 
221 private:
222  /// Registrar of class to factory
223  static const int registrar;
224 
225  void update_output_fields();
226 
227  template<unsigned int dim>
228  void compute_output_fields();
229 
230  void preallocate();
231 
232  /**
233  * @brief Assembles the stiffness matrix.
234  *
235  * This routine just calls assemble_volume_integrals(), assemble_fluxes_boundary(),
236  * assemble_fluxes_element_element() and assemble_fluxes_element_side() for each
237  * space dimension.
238  */
239  void assemble_stiffness_matrix();
240 
241  /**
242  * @brief Assembles the volume integrals into the stiffness matrix.
243  */
244  template<unsigned int dim>
245  void assemble_volume_integrals();
246 
247  /**
248  * @brief Assembles the right hand side (forces, boundary conditions, tractions).
249  */
250  void assemble_rhs();
251 
252  /**
253  * @brief Assembles the right hand side vector due to volume sources.
254  */
255  template<unsigned int dim>
256  void assemble_sources();
257 
258  /**
259  * @brief Assembles the fluxes on the boundary.
260  */
261  template<unsigned int dim>
262  void assemble_fluxes_boundary();
263 
264  /**
265  * @brief Assembles the fluxes between elements of different dimensions depending on displacement.
266  */
267  template<unsigned int dim>
268  void assemble_matrix_element_side();
269 
270  /** @brief Assemble fluxes between different dimensions that are independent of displacement. */
271  template<unsigned int dim>
272  void assemble_rhs_element_side();
273 
274 
275  /**
276  * @brief Assembles the r.h.s. components corresponding to the Dirichlet boundary conditions
277  * for a given space dimension.
278  */
279  template<unsigned int dim>
280  void assemble_boundary_conditions();
281 
282  /** @brief Penalty to enforce boundary value in weak sense. */
283  double dirichlet_penalty(SideIter side);
284 
285 
286 
287 
288  /// @name Physical parameters
289  // @{
290 
291  /// Field data for model parameters.
293 
294  // @}
295 
296 
297  /// @name Parameters of the numerical method
298  // @{
299 
300  /// Finite element objects
302 
303  // @}
304 
305 
306 
307  /// @name Solution of algebraic system
308  // @{
309 
310  /// Vector of right hand side.
311  Vec rhs;
312 
313  /// The stiffness matrix.
315 
316  /// Linear algebra system for the transport equation.
318 
319  // @}
320 
321 
322  /// @name Output to file
323  // @{
324 
325  std::shared_ptr<OutputTime> output_stream_;
326 
327  /// Record with input specification.
329 
330 
331  // @}
332 
333 
334 
335 
336  /// @name Other
337  // @{
338 
339  /// Indicates whether matrices have been preallocated.
341 
342  // @}
343 };
344 
345 
346 
347 double lame_mu(double young, double poisson);
348 double lame_lambda(double young, double poisson);
349 
350 
351 
352 
353 
354 
355 #endif /* ELASTICITY_HH_ */
BCField< 3, FieldValue< 3 >::Enum > bc_type
Definition: elasticity.hh:127
std::shared_ptr< DiscreteSpace > ds_
Definition: elasticity.hh:88
BCField< 3, FieldValue< 3 >::VectorFixed > bc_displacement
Definition: elasticity.hh:128
Class MappingP1 implements the affine transformation of the unit cell onto the actual cell...
Field< 3, FieldValue< 3 >::TensorFixed > output_stress
Definition: elasticity.hh:142
Field< 3, FieldValue< 3 >::Scalar > young_modulus
Definition: elasticity.hh:131
Quadrature * q_[4]
Quadratures used in assembling methods.
Definition: elasticity.hh:81
Abstract base class for equation clasess.
static constexpr const char * name()
Definition: elasticity.hh:118
Container for various descendants of FieldCommonBase.
Definition: field_set.hh:71
double lame_lambda(double young, double poisson)
Definition: elasticity.cc:163
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > output_von_mises_stress_ptr
Definition: elasticity.hh:149
FiniteElement< 3 > * fe3_
Definition: elasticity.hh:78
std::shared_ptr< DOFHandlerMultiDim > dh_scalar()
Definition: elasticity.cc:149
Field< 3, FieldValue< 3 >::Scalar > output_von_mises_stress
Definition: elasticity.hh:143
Field< 3, FieldValue< 3 >::Scalar > region_id
Definition: elasticity.hh:138
Field< 3, FieldValue< 3 >::Scalar > output_cross_section
Definition: elasticity.hh:144
const Vec & get_solution()
Definition: elasticity.hh:210
FEObjects(Mesh *mesh_, unsigned int fe_order)
Definition: elasticity.cc:77
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:83
FiniteElement< dim > * fe()
LinSys * ls
Linear algebra system for the transport equation.
Definition: elasticity.hh:317
Definition: mesh.h:76
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::TensorFixed > > output_stress_ptr
Definition: elasticity.hh:148
Field< 3, FieldValue< 3 >::Scalar > cross_section
Pointer to DarcyFlow field cross_section.
Definition: elasticity.hh:136
Basic time management functionality for unsteady (and steady) solvers (class Equation).
MappingP1< 2, 3 > * map2_
Definition: elasticity.hh:85
Input::Record input_rec
Record with input specification.
Definition: elasticity.hh:328
Field< 3, FieldValue< 3 >::Scalar > potential_load
Potential of an additional (external) load.
Definition: elasticity.hh:137
Vec rhs
Vector of right hand side.
Definition: elasticity.hh:311
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:340
MappingP1< 3, 3 > * map3_
Definition: elasticity.hh:86
MappingP1< 1, 3 > * map1_
Auxiliary mappings of reference elements.
Definition: elasticity.hh:84
BCField< 3, FieldValue< 3 >::VectorFixed > bc_traction
Definition: elasticity.hh:129
Abstract class for the mapping between reference and actual cell.
Definition: fe_values.hh:38
Accessor to the data with type Type::Record.
Definition: accessors.hh:292
FiniteElement< 0 > * fe0_
Finite elements for the solution of the mechanics equation.
Definition: elasticity.hh:75
std::shared_ptr< DOFHandlerMultiDim > dh()
Definition: elasticity.cc:148
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:145
FiniteElement< 1 > * fe1_
Definition: elasticity.hh:76
The class for outputting data during time.
Definition: output_time.hh:50
Mat stiffness_matrix
The stiffness matrix.
Definition: elasticity.hh:314
Quadrature * q()
Definition: elasticity.hh:61
EqData & data()
Definition: elasticity.hh:213
Field< 3, FieldValue< 3 >::VectorFixed > load
Definition: elasticity.hh:130
Field< 3, FieldValue< 3 >::Scalar > fracture_sigma
Transition parameter for diffusive transfer on fractures.
Definition: elasticity.hh:133
Elasticity FactoryBaseType
Definition: elasticity.hh:216
double lame_mu(double young, double poisson)
Definition: elasticity.cc:157
Field< 3, FieldValue< 3 >::Scalar > poisson_ratio
Definition: elasticity.hh:132
std::shared_ptr< DOFHandlerMultiDim > dh_tensor_
Definition: elasticity.hh:93
EquationOutput output_fields
Definition: elasticity.hh:153
static const int registrar
Registrar of class to factory.
Definition: elasticity.hh:223
EqData data_
Field data for model parameters.
Definition: elasticity.hh:292
static string default_output_field()
Definition: elasticity.hh:120
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::VectorFixed > > output_field_ptr
Definition: elasticity.hh:147
void set_potential_load(const Field< 3, FieldValue< 3 >::Scalar > &potential)
Definition: elasticity.hh:205
std::shared_ptr< DOFHandlerMultiDim > dh_
Object for distribution of dofs.
Definition: elasticity.hh:91
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...
Base class for FEValues and FESideValues.
Definition: fe_values.hh:37
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > output_div_ptr
Definition: elasticity.hh:151
MappingP1< dim, 3 > * mapping()
bool evaluate_time_constraint(double &)
Definition: elasticity.hh:177
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > output_cross_section_ptr
Definition: elasticity.hh:150
FiniteElement< 2 > * fe2_
Definition: elasticity.hh:77
Field< 3, FieldValue< 3 >::VectorFixed > output_field
Definition: elasticity.hh:141
std::shared_ptr< DOFHandlerMultiDim > dh_scalar_
Definition: elasticity.hh:92
std::shared_ptr< DOFHandlerMultiDim > dh_tensor()
Definition: elasticity.cc:150
Template for classes storing finite set of named values.
Field< 3, FieldValue< 3 >::Scalar > subdomain
Definition: elasticity.hh:139
std::shared_ptr< OutputTime > output_stream_
Definition: elasticity.hh:325
Mechanics::FEObjects * feo
Finite element objects.
Definition: elasticity.hh:301