Flow123d  JS_before_hm-1601-gc6ac32d
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 OutpuFieldsAssemblyElasticity;
42 template< template<IntDim...> class DimAssembly> class GenericAssembly;
43 
44 
45 
46 
47 class Elasticity : public EquationBase
48 {
49 public:
50 
51  class EqFields : public FieldSet {
52  public:
53 
54  enum Bc_types {
58  };
59 
60  EqFields();
61 
63 
70  Field<3, FieldValue<3>::Scalar> fracture_sigma; ///< Transition parameter for diffusive transfer on fractures.
71 
72  /// Pointer to DarcyFlow field cross_section
74  Field<3, FieldValue<3>::Scalar > potential_load; ///< Potential of an additional (external) load.
77 
83 
84  /// @name Instances of FieldModel used in assembly methods
85  // @{
86 
90 
91  // @}
92 
93  std::shared_ptr<FieldFE<3, FieldValue<3>::VectorFixed> > output_field_ptr;
94  std::shared_ptr<FieldFE<3, FieldValue<3>::TensorFixed> > output_stress_ptr;
95  std::shared_ptr<FieldFE<3, FieldValue<3>::Scalar> > output_von_mises_stress_ptr;
96  std::shared_ptr<FieldFE<3, FieldValue<3>::Scalar> > output_cross_section_ptr;
97  std::shared_ptr<FieldFE<3, FieldValue<3>::Scalar> > output_div_ptr;
98 
100 
101  };
102 
103  class EqData {
104  public:
105 
106  static constexpr const char * name() { return "Mechanics_LinearElasticity"; }
107 
108  static string default_output_field() { return "\"displacement\""; }
109 
110  static IT::Selection get_output_selection();
111 
113  : ls(nullptr) {}
114 
116  if (ls!=nullptr) delete ls;
117  }
118 
119  /// Create DOF handler objects
120  void create_dh(Mesh * mesh, unsigned int fe_order);
121 
122  /// Objects for distribution of dofs.
123  std::shared_ptr<DOFHandlerMultiDim> dh_;
124  std::shared_ptr<DOFHandlerMultiDim> dh_scalar_;
125  std::shared_ptr<DOFHandlerMultiDim> dh_tensor_;
126 
127  /// @name Solution of algebraic system
128  // @{
129 
130  /// Linear algebra system for the transport equation.
132 
133  // @}
134 
135  /// Shared Balance object
136  std::shared_ptr<Balance> balance_;
137 
138  };
139 
140 
141  /**
142  * @brief Constructor.
143  * @param init_mesh computational mesh
144  * @param in_rec input record
145  * @param tm time governor (if nullptr then it is created from input record)
146  */
147  Elasticity(Mesh &init_mesh, const Input::Record in_rec, TimeGovernor *tm = nullptr);
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 
160  { return false; }
161 
162  /**
163  * @brief Computes the solution in one time instant.
164  */
165  void update_solution() override;
166 
167  /// Pass to next time and update equation data.
168  void next_time();
169 
170  /// Solve without updating time step and without output.
171  void solve_linear_system();
172 
173  /**
174  * @brief Postprocesses the solution and writes to output file.
175  */
176  void output_data();
177 
178  /**
179  * @brief Destructor.
180  */
181  ~Elasticity();
182 
183  void initialize() override;
184 
185  // Recompute fields for output (stress, divergence etc.)
186  void update_output_fields();
187 
188  void set_potential_load(const Field<3, FieldValue<3>::Scalar> &potential)
189  { eq_fields_->potential_load = potential; }
190 
192 
193  const Vec &get_solution()
194  { return eq_data_->ls->get_solution(); }
195 
196  inline EqFields &eq_fields() { return *eq_fields_; }
197 
198  inline EqData &eq_data() { return *eq_data_; }
199 
200 
201 
203 
204 
205 
206 
207 private:
208  /// Registrar of class to factory
209  static const int registrar;
210 
211  void preallocate();
212 
213 
214 
215 
216  /// @name Physical parameters
217  // @{
218 
219  /// Fields for model parameters.
220  std::shared_ptr<EqFields> eq_fields_;
221 
222  /// Data for model parameters.
223  std::shared_ptr<EqData> eq_data_;
224 
225 
226  // @}
227 
228 
229  /// @name Solution of algebraic system
230  // @{
231 
232  /// Vector of right hand side.
233  Vec rhs;
234 
235  /// The stiffness matrix.
237 
238  // @}
239 
240 
241  /// @name Output to file
242  // @{
243 
244  std::shared_ptr<OutputTime> output_stream_;
245 
246  /// Record with input specification.
248 
249 
250  // @}
251 
252 
253 
254 
255  /// @name Other
256  // @{
257 
258  /// Indicates whether matrices have been preallocated.
260 
261  // @}
262 
263  /// general assembly objects, hold assembly objects of appropriate dimension
267 
268 };
269 
270 
271 /*
272  * TODO Remove these two methods after implementation new assembly algorithm in HM_Iterative class.
273  */
274 double lame_mu(double young, double poisson);
275 double lame_lambda(double young, double poisson);
276 
277 
278 
279 
280 
281 
282 #endif /* ELASTICITY_HH_ */
Abstract base class for equation clasess.
static constexpr const char * name()
Definition: elasticity.hh:106
Container for various descendants of FieldCommonBase.
Definition: field_set.hh:159
Field< 3, FieldValue< 3 >::Scalar > young_modulus
Definition: elasticity.hh:68
Field< 3, FieldValue< 3 >::Scalar > lame_mu
Definition: elasticity.hh:87
void preallocate()
Definition: elasticity.cc:463
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::VectorFixed > > output_field_ptr
Definition: elasticity.hh:93
Field< 3, FieldValue< 3 >::Scalar > cross_section
Pointer to DarcyFlow field cross_section.
Definition: elasticity.hh:73
LinSys * ls
Linear algebra system for the transport equation.
Definition: elasticity.hh:131
std::shared_ptr< EqFields > eq_fields_
Fields for model parameters.
Definition: elasticity.hh:220
const Vec & get_solution()
Definition: elasticity.hh:193
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:94
const Mesh * mesh() const
Returns pointer to mesh.
Definition: field_set.hh:370
static const Input::Type::Record & get_input_type()
Declare input record type for the equation TransportDG.
Definition: elasticity.cc:46
Field< 3, FieldValue< 3 >::Scalar > dirichlet_penalty
Definition: elasticity.hh:89
Definition: mesh.h:77
BCField< 3, FieldValue< 3 >::VectorFixed > bc_traction
Definition: elasticity.hh:66
std::shared_ptr< EqData > eq_data_
Data for model parameters.
Definition: elasticity.hh:223
Field< 3, FieldValue< 3 >::Scalar > lame_lambda
Definition: elasticity.hh:88
~Elasticity()
Destructor.
Definition: elasticity.cc:386
Field< 3, FieldValue< 3 >::Scalar > region_id
Definition: elasticity.hh:75
void update_solution() override
Computes the solution in one time instant.
Definition: elasticity.cc:479
Field< 3, FieldValue< 3 >::VectorFixed > load
Definition: elasticity.hh:67
std::shared_ptr< DOFHandlerMultiDim > dh_scalar_
Definition: elasticity.hh:124
Basic time management functionality for unsteady (and steady) solvers (class Equation).
Input::Record input_rec
Record with input specification.
Definition: elasticity.hh:247
Vec rhs
Vector of right hand side.
Definition: elasticity.hh:233
GenericAssembly< OutpuFieldsAssemblyElasticity > * output_fields_assembly_
Definition: elasticity.hh:266
Field< 3, FieldValue< 3 >::VectorFixed > output_field
Definition: elasticity.hh:78
bool allocation_done
Indicates whether matrices have been preallocated.
Definition: elasticity.hh:259
GenericAssembly< RhsAssemblyElasticity > * rhs_assembly_
Definition: elasticity.hh:265
static const Input::Type::Selection & get_bc_type_selection()
Definition: elasticity.cc:113
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > output_cross_section_ptr
Definition: elasticity.hh:96
Field< 3, FieldValue< 3 >::Scalar > poisson_ratio
Definition: elasticity.hh:69
std::shared_ptr< DOFHandlerMultiDim > dh_tensor_
Definition: elasticity.hh:125
void solve_linear_system()
Solve without updating time step and without output.
Definition: elasticity.cc:502
EquationOutput output_fields
Definition: elasticity.hh:99
Field< 3, FieldValue< 3 >::Scalar > potential_load
Potential of an additional (external) load.
Definition: elasticity.hh:74
void update_output_fields()
Definition: elasticity.cc:403
Accessor to the data with type Type::Record.
Definition: accessors.hh:291
GenericAssembly< StiffnessAssemblyElasticity > * stiffness_assembly_
general assembly objects, hold assembly objects of appropriate dimension
Definition: elasticity.hh:264
Provides the numbering of the finite element degrees of freedom on the computational mesh...
Definition: dofhandler.hh:151
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::TensorFixed > > output_stress_ptr
Definition: elasticity.hh:94
void zero_time_step() override
Initialize solution in the zero time.
Definition: elasticity.cc:429
The class for outputting data during time.
Definition: output_time.hh:51
void output_data()
Postprocesses the solution and writes to output file.
Definition: elasticity.cc:550
Mat stiffness_matrix
The stiffness matrix.
Definition: elasticity.hh:236
Field< 3, FieldValue< 3 >::Scalar > output_divergence
Definition: elasticity.hh:82
unsigned int IntDim
A dimension index type.
Definition: mixed.hh:19
Elasticity FactoryBaseType
Definition: elasticity.hh:202
BCField< 3, FieldValue< 3 >::Enum > bc_type
Definition: elasticity.hh:64
EqFields & eq_fields()
Definition: elasticity.hh:196
std::shared_ptr< DOFHandlerMultiDim > dh_
Objects for distribution of dofs.
Definition: elasticity.hh:123
Field< 3, FieldValue< 3 >::Scalar > output_cross_section
Definition: elasticity.hh:81
static const int registrar
Registrar of class to factory.
Definition: elasticity.hh:209
Field< 3, FieldValue< 3 >::Scalar > subdomain
Definition: elasticity.hh:76
void next_time()
Pass to next time and update equation data.
Definition: elasticity.cc:493
Generic class of assemblation.
void initialize() override
Definition: elasticity.cc:317
std::shared_ptr< Balance > balance_
Shared Balance object.
Definition: elasticity.hh:136
Definitions of particular quadrature rules on simplices.
static string default_output_field()
Definition: elasticity.hh:108
void set_potential_load(const Field< 3, FieldValue< 3 >::Scalar > &potential)
Definition: elasticity.hh:188
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > output_div_ptr
Definition: elasticity.hh:97
Record type proxy class.
Definition: type_record.hh:182
Field< 3, FieldValue< 3 >::TensorFixed > output_stress
Definition: elasticity.hh:79
Abstract class for the description of a general finite element on a reference simplex in dim dimensio...
BCField< 3, FieldValue< 3 >::VectorFixed > bc_displacement
Definition: elasticity.hh:65
void calculate_cumulative_balance()
Definition: elasticity.cc:571
bool evaluate_time_constraint(double &)
Definition: elasticity.hh:159
Elasticity(Mesh &init_mesh, const Input::Record in_rec, TimeGovernor *tm=nullptr)
Constructor.
Definition: elasticity.cc:272
Field< 3, FieldValue< 3 >::Scalar > output_von_mises_stress
Definition: elasticity.hh:80
EqData & eq_data()
Definition: elasticity.hh:198
Template for classes storing finite set of named values.
Field< 3, FieldValue< 3 >::Scalar > fracture_sigma
Transition parameter for diffusive transfer on fractures.
Definition: elasticity.hh:70
std::shared_ptr< OutputTime > output_stream_
Definition: elasticity.hh:244
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > output_von_mises_stress_ptr
Definition: elasticity.hh:95