Flow123d  DF_patch_fe_mechanics-a6ba684
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 template<unsigned int dim> class StiffnessAssemblyElasticity;
40 template<unsigned int dim> class RhsAssemblyElasticity;
41 template<unsigned int dim> class ConstraintAssemblyElasticity;
42 template<unsigned int dim> class OutpuFieldsAssemblyElasticity;
43 template< template<IntDim...> class DimAssembly> class GenericAssembly;
44 
45 
46 
47 
48 class Elasticity : public EquationBase
49 {
50 public:
51 
52  class EqFields : public FieldSet {
53  public:
54 
55  enum Bc_types {
60  };
61 
62  EqFields();
63 
65 
73  Field<3, FieldValue<3>::Scalar> fracture_sigma; ///< Transition parameter for diffusive transfer on fractures.
75 
76  /// Pointer to DarcyFlow field cross_section
79  Field<3, FieldValue<3>::Scalar > potential_load; ///< Potential of an additional (external) load.
80  Field<3, FieldValue<3>::Scalar > ref_potential_load; ///< Potential of reference external load on boundary. TODO: Switch to BCField when possible.
83 
90 
91  /// @name Instances of FieldModel used in assembly methods
92  // @{
93 
97 
98  // @}
99 
100  std::shared_ptr<FieldFE<3, FieldValue<3>::VectorFixed> > output_field_ptr;
101  std::shared_ptr<FieldFE<3, FieldValue<3>::TensorFixed> > output_stress_ptr;
106 
108 
109  };
110 
111  /// Data of equation parameters
112  class EqData {
113  public:
114 
116  : ls(nullptr), constraint_matrix(nullptr), constraint_vec(nullptr) {}
117 
119  if (ls!=nullptr) delete ls;
120  if (constraint_matrix!=nullptr) MatDestroy(&constraint_matrix);
121  if (constraint_vec!=nullptr) VecDestroy(&constraint_vec);
122  }
123 
124  /// Create DOF handler objects
125  void create_dh(Mesh * mesh);
126 
127  /// Returns quad_order
128  inline unsigned int quad_order() const {
129  return 1;
130  }
131 
132  /// Objects for distribution of dofs.
133  std::shared_ptr<DOFHandlerMultiDim> dh_;
134 
135  /// @name Solution of algebraic system
136  // @{
137 
138  /// Linear algebraic system.
140 
143 
144  // map local element -> constraint index
146 
147  // @}
148 
149  /// Shared Balance object
150  std::shared_ptr<Balance> balance_;
151 
152  };
153 
154 
155  /// Data of output parameters
156  class OutputEqData {
157  public:
158 
160  {}
161 
163 
164  /// Create DOF handler objects
165  void create_dh(Mesh * mesh);
166 
167  /// Returns quad_order
168  inline unsigned int quad_order() const {
169  return 0;
170  }
171 
172  /// Objects for distribution of dofs.
173  std::shared_ptr<DOFHandlerMultiDim> dh_scalar_;
174  std::shared_ptr<DOFHandlerMultiDim> dh_tensor_;
175 
176  };
177 
178 
179  /**
180  * @brief Constructor.
181  * @param init_mesh computational mesh
182  * @param in_rec input record
183  * @param tm time governor (if nullptr then it is created from input record)
184  */
185  Elasticity(Mesh &init_mesh, const Input::Record in_rec, TimeGovernor *tm = nullptr);
186  /**
187 
188  * @brief Declare input record type for the equation TransportDG.
189  */
190  static const Input::Type::Record & get_input_type();
191 
192  /**
193  * @brief Initialize solution in the zero time.
194  */
195  void zero_time_step() override;
196 
197  /**
198  * @brief Computes the solution in one time instant.
199  */
200  void update_solution() override;
201 
202  /// Pass to next time and update equation data.
203  void next_time();
204 
205  /// Solve without updating time step and without output.
206  void solve_linear_system();
207 
208  /**
209  * @brief Postprocesses the solution and writes to output file.
210  */
211  void output_data();
212 
213  /**
214  * @brief Destructor.
215  */
216  ~Elasticity();
217 
218  void initialize() override;
219 
220  // Recompute fields for output (stress, divergence etc.)
221  void update_output_fields();
222 
223  void set_potential_load(const Field<3, FieldValue<3>::Scalar> &potential,
224  const Field<3, FieldValue<3>::Scalar> &ref_potential)
225  {
226  eq_fields_->potential_load = potential;
227  eq_fields_->ref_potential_load = ref_potential;
228  }
229 
231 
232  const Vec &get_solution()
233  { return eq_data_->ls->get_solution(); }
234 
235  inline EqFields &eq_fields() { return *eq_fields_; }
236 
237  inline EqData &eq_data() { return *eq_data_; }
238 
239 
240 
242 
243 
244 
245 
246 private:
247  /// Registrar of class to factory
248  static const int registrar;
249 
250  void preallocate();
251 
252 
254 
255 
256  /// @name Physical parameters
257  // @{
258 
259  /// Fields for model parameters.
260  std::shared_ptr<EqFields> eq_fields_;
261 
262  /// Data for model parameters.
263  std::shared_ptr<EqData> eq_data_;
264 
265  /// Data for output parameters.
266  std::shared_ptr<OutputEqData> output_eq_data_;
267 
268  /// Indicator of contact conditions on fractures.
270 
271 
272  // @}
273 
274 
275 
276  /// @name Output to file
277  // @{
278 
279  std::shared_ptr<OutputTime> output_stream_;
280 
281  /// Record with input specification.
283 
284 
285  // @}
286 
287 
288  static constexpr const char * name_ = "Mechanics_LinearElasticity";
289 
290 
291  /// general assembly objects, hold assembly objects of appropriate dimension
296 
297 };
298 
299 
300 /*
301  * TODO Remove these two methods after implementation new assembly algorithm in HM_Iterative class.
302  */
303 double lame_mu(double young, double poisson);
304 double lame_lambda(double young, double poisson);
305 
306 
307 
308 
309 
310 
311 #endif /* ELASTICITY_HH_ */
Provides the numbering of the finite element degrees of freedom on the computational mesh.
Definition: dofhandler.hh:151
Data of equation parameters.
Definition: elasticity.hh:112
unsigned int quad_order() const
Returns quad_order.
Definition: elasticity.hh:128
LinSys * ls
Linear algebraic system.
Definition: elasticity.hh:139
void create_dh(Mesh *mesh)
Create DOF handler objects.
Definition: elasticity.cc:282
std::shared_ptr< DOFHandlerMultiDim > dh_
Objects for distribution of dofs.
Definition: elasticity.hh:133
std::map< LongIdx, LongIdx > constraint_idx
Definition: elasticity.hh:145
std::shared_ptr< Balance > balance_
Shared Balance object.
Definition: elasticity.hh:150
Field< 3, FieldValue< 3 >::Scalar > potential_load
Potential of an additional (external) load.
Definition: elasticity.hh:79
Field< 3, FieldValue< 3 >::TensorFixed > output_stress
Definition: elasticity.hh:85
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::TensorFixed > > output_stress_ptr
Definition: elasticity.hh:101
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > output_von_mises_stress_ptr
Definition: elasticity.hh:102
Field< 3, FieldValue< 3 >::Scalar > cross_section_min
Definition: elasticity.hh:78
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > output_cross_section_ptr
Definition: elasticity.hh:104
Field< 3, FieldValue< 3 >::Scalar > subdomain
Definition: elasticity.hh:82
Field< 3, FieldValue< 3 >::Scalar > region_id
Definition: elasticity.hh:81
EquationOutput output_fields
Definition: elasticity.hh:107
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::VectorFixed > > output_field_ptr
Definition: elasticity.hh:100
BCField< 3, FieldValue< 3 >::Enum > bc_type
Definition: elasticity.hh:66
Field< 3, FieldValue< 3 >::Scalar > lame_lambda
Definition: elasticity.hh:95
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > output_div_ptr
Definition: elasticity.hh:105
Field< 3, FieldValue< 3 >::Scalar > output_mean_stress
Definition: elasticity.hh:87
BCField< 3, FieldValue< 3 >::VectorFixed > bc_displacement
Definition: elasticity.hh:67
Field< 3, FieldValue< 3 >::Scalar > poisson_ratio
Definition: elasticity.hh:72
Field< 3, FieldValue< 3 >::VectorFixed > output_field
Definition: elasticity.hh:84
Field< 3, FieldValue< 3 >::TensorFixed > initial_stress
Definition: elasticity.hh:74
static const Input::Type::Selection & get_bc_type_selection()
Definition: elasticity.cc:117
BCField< 3, FieldValue< 3 >::VectorFixed > bc_traction
Definition: elasticity.hh:68
Field< 3, FieldValue< 3 >::Scalar > output_von_mises_stress
Definition: elasticity.hh:86
Field< 3, FieldValue< 3 >::Scalar > ref_potential_load
Potential of reference external load on boundary. TODO: Switch to BCField when possible.
Definition: elasticity.hh:80
Field< 3, FieldValue< 3 >::VectorFixed > load
Definition: elasticity.hh:70
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > output_mean_stress_ptr
Definition: elasticity.hh:103
Field< 3, FieldValue< 3 >::Scalar > output_divergence
Definition: elasticity.hh:89
Field< 3, FieldValue< 3 >::Scalar > fracture_sigma
Transition parameter for diffusive transfer on fractures.
Definition: elasticity.hh:73
Field< 3, FieldValue< 3 >::Scalar > young_modulus
Definition: elasticity.hh:71
Field< 3, FieldValue< 3 >::Scalar > dirichlet_penalty
Definition: elasticity.hh:96
Field< 3, FieldValue< 3 >::Scalar > cross_section
Pointer to DarcyFlow field cross_section.
Definition: elasticity.hh:77
Field< 3, FieldValue< 3 >::Scalar > output_cross_section
Definition: elasticity.hh:88
BCField< 3, FieldValue< 3 >::TensorFixed > bc_stress
Definition: elasticity.hh:69
Field< 3, FieldValue< 3 >::Scalar > lame_mu
Definition: elasticity.hh:94
Data of output parameters.
Definition: elasticity.hh:156
std::shared_ptr< DOFHandlerMultiDim > dh_scalar_
Objects for distribution of dofs.
Definition: elasticity.hh:173
std::shared_ptr< DOFHandlerMultiDim > dh_tensor_
Definition: elasticity.hh:174
void create_dh(Mesh *mesh)
Create DOF handler objects.
Definition: elasticity.cc:294
unsigned int quad_order() const
Returns quad_order.
Definition: elasticity.hh:168
std::shared_ptr< EqData > eq_data_
Data for model parameters.
Definition: elasticity.hh:263
static const int registrar
Registrar of class to factory.
Definition: elasticity.hh:248
void update_solution() override
Computes the solution in one time instant.
Definition: elasticity.cc:554
GenericAssembly< RhsAssemblyElasticity > * rhs_assembly_
Definition: elasticity.hh:293
void update_output_fields()
Definition: elasticity.cc:477
void assemble_constraint_matrix()
Definition: elasticity.cc:647
GenericAssembly< OutpuFieldsAssemblyElasticity > * output_fields_assembly_
Definition: elasticity.hh:295
static constexpr const char * name_
Definition: elasticity.hh:288
EqFields & eq_fields()
Definition: elasticity.hh:235
GenericAssembly< StiffnessAssemblyElasticity > * stiffness_assembly_
general assembly objects, hold assembly objects of appropriate dimension
Definition: elasticity.hh:292
void solve_linear_system()
Solve without updating time step and without output.
Definition: elasticity.cc:577
std::shared_ptr< OutputTime > output_stream_
Definition: elasticity.hh:279
void initialize() override
Definition: elasticity.cc:355
void set_potential_load(const Field< 3, FieldValue< 3 >::Scalar > &potential, const Field< 3, FieldValue< 3 >::Scalar > &ref_potential)
Definition: elasticity.hh:223
Input::Record input_rec
Record with input specification.
Definition: elasticity.hh:282
void calculate_cumulative_balance()
Definition: elasticity.cc:638
void output_data()
Postprocesses the solution and writes to output file.
Definition: elasticity.cc:617
~Elasticity()
Destructor.
Definition: elasticity.cc:462
static const Input::Type::Record & get_input_type()
Declare input record type for the equation TransportDG.
Definition: elasticity.cc:48
bool has_contact_
Indicator of contact conditions on fractures.
Definition: elasticity.hh:269
GenericAssembly< ConstraintAssemblyElasticity > * constraint_assembly_
Definition: elasticity.hh:294
Elasticity(Mesh &init_mesh, const Input::Record in_rec, TimeGovernor *tm=nullptr)
Constructor.
Definition: elasticity.cc:311
void zero_time_step() override
Initialize solution in the zero time.
Definition: elasticity.cc:507
const Vec & get_solution()
Definition: elasticity.hh:232
Elasticity FactoryBaseType
Definition: elasticity.hh:241
std::shared_ptr< OutputEqData > output_eq_data_
Data for output parameters.
Definition: elasticity.hh:266
std::shared_ptr< EqFields > eq_fields_
Fields for model parameters.
Definition: elasticity.hh:260
EqData & eq_data()
Definition: elasticity.hh:237
void preallocate()
Definition: elasticity.cc:540
void next_time()
Pass to next time and update equation data.
Definition: elasticity.cc:568
Mesh & mesh()
Definition: equation.hh:181
Container for various descendants of FieldCommonBase.
Definition: field_set.hh:159
Class template representing a field with values dependent on: point, element, and region.
Definition: field.hh:92
Abstract class for the description of a general finite element on a reference simplex in dim dimensio...
Generic class of assemblation.
Accessor to the data with type Type::Record.
Definition: accessors.hh:291
Record type proxy class.
Definition: type_record.hh:182
Template for classes storing finite set of named values.
Definition: mesh.h:362
The class for outputting data during time.
Definition: output_time.hh:51
Basic time management functionality for unsteady (and steady) solvers (class Equation).
double lame_mu(double young, double poisson)
Definition: elasticity.cc:80
double lame_lambda(double young, double poisson)
Definition: elasticity.cc:86
Abstract base class for equation clasess.
Wrappers for linear systems based on MPIAIJ and MATIS format.
unsigned int IntDim
A dimension index type.
Definition: mixed.hh:19
double Scalar
Definitions of particular quadrature rules on simplices.