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