Flow123d  3.9.0-44fe12069
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 {
59  };
60 
61  EqFields();
62 
64 
72  Field<3, FieldValue<3>::Scalar> fracture_sigma; ///< Transition parameter for diffusive transfer on fractures.
74 
75  /// Pointer to DarcyFlow field cross_section
77  Field<3, FieldValue<3>::Scalar > potential_load; ///< Potential of an additional (external) load.
78  Field<3, FieldValue<3>::Scalar > ref_potential_load; ///< Potential of reference external load on boundary. TODO: Switch to BCField when possible.
81 
88 
89  /// @name Instances of FieldModel used in assembly methods
90  // @{
91 
95 
96  // @}
97 
98  std::shared_ptr<FieldFE<3, FieldValue<3>::VectorFixed> > output_field_ptr;
99  std::shared_ptr<FieldFE<3, FieldValue<3>::TensorFixed> > output_stress_ptr;
100  std::shared_ptr<FieldFE<3, FieldValue<3>::Scalar> > output_von_mises_stress_ptr;
101  std::shared_ptr<FieldFE<3, FieldValue<3>::Scalar> > output_mean_stress_ptr;
102  std::shared_ptr<FieldFE<3, FieldValue<3>::Scalar> > output_cross_section_ptr;
103  std::shared_ptr<FieldFE<3, FieldValue<3>::Scalar> > output_div_ptr;
104 
106 
107  };
108 
109  class EqData {
110  public:
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 algebraic system.
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 
159  /**
160  * @brief Computes the solution in one time instant.
161  */
162  void update_solution() override;
163 
164  /// Pass to next time and update equation data.
165  void next_time();
166 
167  /// Solve without updating time step and without output.
168  void solve_linear_system();
169 
170  /**
171  * @brief Postprocesses the solution and writes to output file.
172  */
173  void output_data();
174 
175  /**
176  * @brief Destructor.
177  */
178  ~Elasticity();
179 
180  void initialize() override;
181 
182  // Recompute fields for output (stress, divergence etc.)
183  void update_output_fields();
184 
185  void set_potential_load(const Field<3, FieldValue<3>::Scalar> &potential,
186  const Field<3, FieldValue<3>::Scalar> &ref_potential)
187  {
188  eq_fields_->potential_load = potential;
189  eq_fields_->ref_potential_load = ref_potential;
190  }
191 
193 
194  const Vec &get_solution()
195  { return eq_data_->ls->get_solution(); }
196 
197  inline EqFields &eq_fields() { return *eq_fields_; }
198 
199  inline EqData &eq_data() { return *eq_data_; }
200 
201 
202 
204 
205 
206 
207 
208 private:
209  /// Registrar of class to factory
210  static const int registrar;
211 
212  void preallocate();
213 
214 
215 
216 
217  /// @name Physical parameters
218  // @{
219 
220  /// Fields for model parameters.
221  std::shared_ptr<EqFields> eq_fields_;
222 
223  /// Data for model parameters.
224  std::shared_ptr<EqData> eq_data_;
225 
226 
227  // @}
228 
229 
230  /// @name Output to file
231  // @{
232 
233  std::shared_ptr<OutputTime> output_stream_;
234 
235  /// Record with input specification.
237 
238 
239  // @}
240 
241 
242  static constexpr const char * name_ = "Mechanics_LinearElasticity";
243 
244 
245  /// general assembly objects, hold assembly objects of appropriate dimension
249 
250 };
251 
252 
253 /*
254  * TODO Remove these two methods after implementation new assembly algorithm in HM_Iterative class.
255  */
256 double lame_mu(double young, double poisson);
257 double lame_lambda(double young, double poisson);
258 
259 
260 
261 
262 
263 
264 #endif /* ELASTICITY_HH_ */
bc_field.hh
Elasticity::input_rec
Input::Record input_rec
Record with input specification.
Definition: elasticity.hh:236
Elasticity::EqFields::poisson_ratio
Field< 3, FieldValue< 3 >::Scalar > poisson_ratio
Definition: elasticity.hh:71
Elasticity::EqFields
Definition: elasticity.hh:51
Elasticity::EqFields::output_stress_ptr
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::TensorFixed > > output_stress_ptr
Definition: elasticity.hh:99
Elasticity::EqFields::output_fields
EquationOutput output_fields
Definition: elasticity.hh:105
Elasticity::EqFields::bc_stress
BCField< 3, FieldValue< 3 >::TensorFixed > bc_stress
Definition: elasticity.hh:68
Elasticity::update_output_fields
void update_output_fields()
Definition: elasticity.cc:425
StiffnessAssemblyElasticity
Definition: assembly_elasticity.hh:35
Elasticity::eq_fields
EqFields & eq_fields()
Definition: elasticity.hh:197
Elasticity::EqFields::Bc_types
Bc_types
Definition: elasticity.hh:54
LinSys
Definition: la_linsys_new.hh:169
fe_values_views.hh
vector_mpi.hh
Elasticity::EqFields::initial_stress
Field< 3, FieldValue< 3 >::TensorFixed > initial_stress
Definition: elasticity.hh:73
lame_lambda
double lame_lambda(double young, double poisson)
Definition: elasticity.cc:83
Elasticity::next_time
void next_time()
Pass to next time and update equation data.
Definition: elasticity.cc:513
Elasticity::solve_linear_system
void solve_linear_system()
Solve without updating time step and without output.
Definition: elasticity.cc:522
lame_mu
double lame_mu(double young, double poisson)
Definition: elasticity.cc:77
Elasticity::EqFields::output_divergence
Field< 3, FieldValue< 3 >::Scalar > output_divergence
Definition: elasticity.hh:87
Elasticity::EqData::ls
LinSys * ls
Linear algebraic system.
Definition: elasticity.hh:131
Elasticity::EqFields::bc_type
BCField< 3, FieldValue< 3 >::Enum > bc_type
Definition: elasticity.hh:65
Elasticity::EqFields::output_mean_stress_ptr
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > output_mean_stress_ptr
Definition: elasticity.hh:101
Elasticity::EqFields::subdomain
Field< 3, FieldValue< 3 >::Scalar > subdomain
Definition: elasticity.hh:80
linsys.hh
Wrappers for linear systems based on MPIAIJ and MATIS format.
Elasticity::EqFields::output_cross_section
Field< 3, FieldValue< 3 >::Scalar > output_cross_section
Definition: elasticity.hh:86
Elasticity::set_potential_load
void set_potential_load(const Field< 3, FieldValue< 3 >::Scalar > &potential, const Field< 3, FieldValue< 3 >::Scalar > &ref_potential)
Definition: elasticity.hh:185
Elasticity::EqFields::output_div_ptr
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > output_div_ptr
Definition: elasticity.hh:103
field_fe.hh
Elasticity::name_
static constexpr const char * name_
Definition: elasticity.hh:242
Elasticity::FactoryBaseType
Elasticity FactoryBaseType
Definition: elasticity.hh:203
Elasticity::EqFields::output_stress
Field< 3, FieldValue< 3 >::TensorFixed > output_stress
Definition: elasticity.hh:83
Elasticity::EqData::dh_
std::shared_ptr< DOFHandlerMultiDim > dh_
Objects for distribution of dofs.
Definition: elasticity.hh:123
Elasticity
Definition: elasticity.hh:47
Elasticity::calculate_cumulative_balance
void calculate_cumulative_balance()
Definition: elasticity.cc:583
EquationBase::mesh
Mesh & mesh()
Definition: equation.hh:179
equation_output.hh
Distribution
Definition: distribution.hh:50
Elasticity::registrar
static const int registrar
Registrar of class to factory.
Definition: elasticity.hh:210
Elasticity::EqData::~EqData
~EqData()
Definition: elasticity.hh:115
Elasticity::EqFields::fracture_sigma
Field< 3, FieldValue< 3 >::Scalar > fracture_sigma
Transition parameter for diffusive transfer on fractures.
Definition: elasticity.hh:72
Elasticity::initialize
void initialize() override
Definition: elasticity.cc:337
Elasticity::EqFields::output_von_mises_stress_ptr
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > output_von_mises_stress_ptr
Definition: elasticity.hh:100
Elasticity::EqFields::bc_displacement
BCField< 3, FieldValue< 3 >::VectorFixed > bc_displacement
Definition: elasticity.hh:66
Elasticity::EqFields::output_von_mises_stress
Field< 3, FieldValue< 3 >::Scalar > output_von_mises_stress
Definition: elasticity.hh:84
Input::Record
Accessor to the data with type Type::Record.
Definition: accessors.hh:291
quadrature_lib.hh
Definitions of particular quadrature rules on simplices.
DOFHandlerMultiDim
Provides the numbering of the finite element degrees of freedom on the computational mesh.
Definition: dofhandler.hh:151
EquationOutput
Definition: equation_output.hh:44
TimeGovernor
Basic time management functionality for unsteady (and steady) solvers (class Equation).
Definition: time_governor.hh:317
Elasticity::get_solution
const Vec & get_solution()
Definition: elasticity.hh:194
Elasticity::EqFields::lame_mu
Field< 3, FieldValue< 3 >::Scalar > lame_mu
Definition: elasticity.hh:92
OutputTime
The class for outputting data during time.
Definition: output_time.hh:51
Elasticity::Elasticity
Elasticity(Mesh &init_mesh, const Input::Record in_rec, TimeGovernor *tm=nullptr)
Constructor.
Definition: elasticity.cc:295
Elasticity::eq_data
EqData & eq_data()
Definition: elasticity.hh:199
Elasticity::preallocate
void preallocate()
Definition: elasticity.cc:488
Elasticity::EqFields::output_field_ptr
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::VectorFixed > > output_field_ptr
Definition: elasticity.hh:98
Elasticity::EqFields::cross_section
Field< 3, FieldValue< 3 >::Scalar > cross_section
Pointer to DarcyFlow field cross_section.
Definition: elasticity.hh:76
FieldSet
Container for various descendants of FieldCommonBase.
Definition: field_set.hh:159
equation.hh
Abstract base class for equation clasess.
EquationBase
Definition: equation.hh:57
Input::Type::Selection
Template for classes storing finite set of named values.
Definition: type_selection.hh:65
Elasticity::EqFields::young_modulus
Field< 3, FieldValue< 3 >::Scalar > young_modulus
Definition: elasticity.hh:70
OutpuFieldsAssemblyElasticity
Definition: assembly_elasticity.hh:568
Elasticity::EqFields::bc_type_displacement
@ bc_type_displacement
Definition: elasticity.hh:55
Elasticity::output_stream_
std::shared_ptr< OutputTime > output_stream_
Definition: elasticity.hh:233
FiniteElement
Abstract class for the description of a general finite element on a reference simplex in dim dimensio...
Definition: discrete_space.hh:26
Input::Type::Record
Record type proxy class.
Definition: type_record.hh:182
Elasticity::EqData::balance_
std::shared_ptr< Balance > balance_
Shared Balance object.
Definition: elasticity.hh:136
Elasticity::EqFields::output_mean_stress
Field< 3, FieldValue< 3 >::Scalar > output_mean_stress
Definition: elasticity.hh:85
Elasticity::EqFields::ref_potential_load
Field< 3, FieldValue< 3 >::Scalar > ref_potential_load
Potential of reference external load on boundary. TODO: Switch to BCField when possible.
Definition: elasticity.hh:78
Mesh
Definition: mesh.h:361
RhsAssemblyElasticity
Definition: assembly_elasticity.hh:284
Elasticity::EqData::dh_tensor_
std::shared_ptr< DOFHandlerMultiDim > dh_tensor_
Definition: elasticity.hh:125
multi_field.hh
Elasticity::EqFields::bc_traction
BCField< 3, FieldValue< 3 >::VectorFixed > bc_traction
Definition: elasticity.hh:67
Elasticity::EqFields::dirichlet_penalty
Field< 3, FieldValue< 3 >::Scalar > dirichlet_penalty
Definition: elasticity.hh:94
Elasticity::EqFields::lame_lambda
Field< 3, FieldValue< 3 >::Scalar > lame_lambda
Definition: elasticity.hh:93
Elasticity::EqFields::load
Field< 3, FieldValue< 3 >::VectorFixed > load
Definition: elasticity.hh:69
Elasticity::eq_fields_
std::shared_ptr< EqFields > eq_fields_
Fields for model parameters.
Definition: elasticity.hh:221
Elasticity::EqFields::bc_type_stress
@ bc_type_stress
Definition: elasticity.hh:58
Elasticity::~Elasticity
~Elasticity()
Destructor.
Definition: elasticity.cc:411
Elasticity::EqFields::region_id
Field< 3, FieldValue< 3 >::Scalar > region_id
Definition: elasticity.hh:79
Elasticity::output_fields_assembly_
GenericAssembly< OutpuFieldsAssemblyElasticity > * output_fields_assembly_
Definition: elasticity.hh:248
Elasticity::get_input_type
static const Input::Type::Record & get_input_type()
Declare input record type for the equation TransportDG.
Definition: elasticity.cc:47
Elasticity::EqFields::output_field
Field< 3, FieldValue< 3 >::VectorFixed > output_field
Definition: elasticity.hh:82
Elasticity::rhs_assembly_
GenericAssembly< RhsAssemblyElasticity > * rhs_assembly_
Definition: elasticity.hh:247
BCField
Definition: bc_field.hh:32
Elasticity::update_solution
void update_solution() override
Computes the solution in one time instant.
Definition: elasticity.cc:499
Elasticity::EqData
Definition: elasticity.hh:109
Elasticity::EqFields::EqFields
EqFields()
Definition: elasticity.cc:128
Field
Class template representing a field with values dependent on: point, element, and region.
Definition: field.hh:92
Elasticity::EqFields::bc_type_traction
@ bc_type_traction
Definition: elasticity.hh:57
Elasticity::stiffness_assembly_
GenericAssembly< StiffnessAssemblyElasticity > * stiffness_assembly_
general assembly objects, hold assembly objects of appropriate dimension
Definition: elasticity.hh:246
Elasticity::EqData::EqData
EqData()
Definition: elasticity.hh:112
Elasticity::EqFields::output_cross_section_ptr
std::shared_ptr< FieldFE< 3, FieldValue< 3 >::Scalar > > output_cross_section_ptr
Definition: elasticity.hh:102
Elasticity::EqData::dh_scalar_
std::shared_ptr< DOFHandlerMultiDim > dh_scalar_
Definition: elasticity.hh:124
Elasticity::eq_data_
std::shared_ptr< EqData > eq_data_
Data for model parameters.
Definition: elasticity.hh:224
Elasticity::EqData::create_dh
void create_dh(Mesh *mesh, unsigned int fe_order)
Create DOF handler objects.
Definition: elasticity.cc:270
mixed.hh
GenericAssembly
Generic class of assemblation.
Definition: generic_assembly.hh:160
Elasticity::zero_time_step
void zero_time_step() override
Initialize solution in the zero time.
Definition: elasticity.cc:455
Elasticity::output_data
void output_data()
Postprocesses the solution and writes to output file.
Definition: elasticity.cc:562
field.hh
Elasticity::EqFields::get_bc_type_selection
static const Input::Type::Selection & get_bc_type_selection()
Definition: elasticity.cc:114
Elasticity::EqFields::potential_load
Field< 3, FieldValue< 3 >::Scalar > potential_load
Potential of an additional (external) load.
Definition: elasticity.hh:77
FieldValue
Definition: field_values.hh:645
Elasticity::EqFields::bc_type_displacement_normal
@ bc_type_displacement_normal
Definition: elasticity.hh:56
IntDim
unsigned int IntDim
A dimension index type.
Definition: mixed.hh:19