Plugins
small_strain_mech.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2015: G-CSC, Goethe University Frankfurt
3  * Authors: Raphael Prohl, Andreas Vogel
4  *
5  * This file is part of UG4.
6  *
7  * UG4 is free software: you can redistribute it and/or modify it under the
8  * terms of the GNU Lesser General Public License version 3 (as published by the
9  * Free Software Foundation) with the following additional attribution
10  * requirements (according to LGPL/GPL v3 §7):
11  *
12  * (1) The following notice must be displayed in the Appropriate Legal Notices
13  * of covered and combined works: "Based on UG4 (www.ug4.org/license)".
14  *
15  * (2) The following notice must be displayed at a prominent place in the
16  * terminal output of covered works: "Based on UG4 (www.ug4.org/license)".
17  *
18  * (3) The following bibliography is recommended for citation and must be
19  * preserved in all covered files:
20  * "Reiter, S., Vogel, A., Heppner, I., Rupp, M., and Wittum, G. A massively
21  * parallel geometric multigrid solver on hierarchically distributed grids.
22  * Computing and visualization in science 16, 4 (2013), 151-164"
23  * "Vogel, A., Reiter, S., Rupp, M., Nägel, A., and Wittum, G. UG4 -- a novel
24  * flexible software system for simulating pde based models on high performance
25  * computers. Computing and visualization in science 16, 4 (2013), 165-179"
26  *
27  * This program is distributed in the hope that it will be useful,
28  * but WITHOUT ANY WARRANTY; without even the implied warranty of
29  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
30  * GNU Lesser General Public License for more details.
31  */
32 
33 #ifndef SMALL_STRAIN_MECH_H_
34 #define SMALL_STRAIN_MECH_H_
35 
36 #include <stdio.h>
37 #include <string>
38 
39 #include "bridge/bridge.h"
40 
47 
50 
51 namespace ug{
52 namespace SmallStrainMechanics{
53 
57 
99 template <typename TDomain>
101  : public IElemDisc<TDomain>
102 {
103  private:
106 
109 
112 
113  public:
116 
118  static const int dim = base_type::dim;
119 
122 
123  public:
125  SmallStrainMechanicsElemDisc(const char* functions, const char* subsets);
126 
129 
132  { m_spMatLaw = spMatLaw;}
133 
136  { return m_spMatLaw;}
137 
140  m_spOutWriter = spOutWriter; m_bOutWriter = true;
141  m_spOutWriter->preprocess();
142  }
143 
150  void set_volume_forces(number vel);
151  void set_volume_forces(number vel_x, number vel_y);
152  void set_volume_forces(number vel_x, number vel_y, number vel_z);
153  #ifdef UG_FOR_LUA
154  void set_volume_forces(const char* fctName);
155  #endif
157 
164  void set_div_factor(number val);
165 #ifdef UG_FOR_LUA
166  void set_div_factor(const char* fctName);
167 #endif
169 
170  void set_compress_factor(number val);
171 
180 
182  void set_quad_order(const size_t order) {m_quadOrder = order; m_bQuadOrderUserDef = true;}
184  int get_quad_order() {return m_quadOrder;}
185 
186  void set_mass_scale(double val) { m_massScale = val; }
187 
189  void init_state_variables(const size_t order);
190 
192  template<typename TElem>
193  void contact_forces_elem_ips_avg(LocalVector& locForce, GridObject* side, TElem* elem,
194  const MathVector<dim> sideCoPos[], int numElemCorners, const LocalVector& locU,
195  std::vector<DoFIndex> vActiveSetLoc);
196 
198  template <typename TSide, typename TElem>
199  void contact_forces_elem_midpoint(LocalVector& locForce, TSide* side, TElem* elem,
200  const MathVector<dim> sideCoPos[], const LocalVector& locU,
201  std::vector<DoFIndex> vActiveSetLoc);
202 
203 
205  virtual void prepare_setting(const std::vector<LFEID>& vLfeID, bool bNonRegularGrid)
206  {
207  // check number
208  if(vLfeID.size() != (size_t)dim)
209  UG_THROW("SmallStrainMechanics: Needs exactly "<<dim<<" functions.");
210 
211  // check & set order
212  for(size_t i = 0; i < vLfeID.size(); ++i)
213  if(vLfeID[i].order() < 1)
214  UG_THROW("SmallStrainMechanics: Adaptive order not implemented.");
215 
216  // remember lfeID;
217  m_lfeID = vLfeID[0];
218 
219  // set order
220  m_order = vLfeID[0].order();
221 
222  // update assemble functions
224  }
225 
226 
228  std::string config_string() const
229  {
230  std::stringstream ss;
231  ss << "SmallStrainMechanics " << dim << "d ";
232  if(dim == 2)
233  ss << " [Plain Strain / Ebener Verzerrungszustand]";
234  ss << "\n";
235  ss << " order of disc scheme = " << m_order
236  << ", shape function set " << m_lfeID
237  << ", Mass Scale = " << m_massScale
238  << "\n";
240  ss << " User Defined Quad Order = " << m_quadOrder << "\n";
241 
242  ss << " Material Configuration: " << ConfigShift(m_spMatLaw->m_materialConfiguration) << "\n";
243 
244  return ss.str();
245  }
246 
247  private:
248  size_t num_fct() const {return dim;}
249 
251  void set_assemble_funcs();
252 
253  void register_all_fe_funcs(int order, int quadOrder);
254  template <typename TElem, typename TFEGeom>
255  void register_fe_func();
256 
258  template<typename TElem, typename TFEGeom>
259  void prep_timestep_elem(const number time, const LocalVector& u, GridObject* elem, const MathVector<dim> vCornerCoords[]);
260 
261  template<typename TElem, typename TFEGeom>
262  void prep_elem_loop(const ReferenceObjectID roid, const int si);
263 
264  template<typename TElem, typename TFEGeom>
265  void prep_elem(const LocalVector& u, GridObject* elem, const ReferenceObjectID roid, const MathVector<dim> vCornerCoords[]);
266 
267  template<typename TElem, typename TFEGeom>
268  void fsh_elem_loop();
269 
270  template<typename TElem, typename TFEGeom>
271  void add_jac_A_elem(LocalMatrix& J, const LocalVector& u, GridObject* elem, const MathVector<dim> vCornerCoords[]);
272 
273  template<typename TElem, typename TFEGeom>
274  void add_jac_M_elem(LocalMatrix& J, const LocalVector& u, GridObject* elem, const MathVector<dim> vCornerCoords[]);
275 
276  template<typename TElem, typename TFEGeom>
277  void add_def_A_elem(LocalVector& d, const LocalVector& u, GridObject* elem, const MathVector<dim> vCornerCoords[]);
278 
279  template<typename TElem, typename TFEGeom>
280  void add_def_M_elem(LocalVector& d, const LocalVector& u, GridObject* elem, const MathVector<dim> vCornerCoords[]);
281 
282  template<typename TElem, typename TFEGeom>
283  void add_rhs_elem(LocalVector& d, GridObject* elem, const MathVector<dim> vCornerCoords[]);
284 
285  template<typename TElem, typename TFEGeom>
286  void fsh_timestep_elem(const number time, const LocalVector& u, GridObject* elem, const MathVector<dim> vCornerCoords[]);
287 
288 
290  void update_geo_elem(TBaseElem* elem, DimFEGeometry<dim>& geo);
291 
293  void print_mat_constants(const number lambda,
294  const number mu, const number E, const number v);
295 
296  protected:
297  template <typename TElem, typename TFEGeom>
298  void lin_def_pressure(const LocalVector& u,
299  std::vector<std::vector<number> > vvvLinDef[],
300  const size_t nip);
301 
302  template <typename TElem, typename TFEGeom>
303  void lin_def_volume_forces(const LocalVector& u,
304  std::vector<std::vector<MathVector<dim> > > vvvLinDef[],
305  const size_t nip);
306 
307 
308  template <typename TElem, typename TFEGeom>
309  void lin_def_viscous_forces0(const LocalVector& u,
310  std::vector<std::vector<MathVector<dim> > > vvvLinDef[],
311  const size_t nip);
312 
313  template <typename TElem, typename TFEGeom>
314  void lin_def_viscous_forces1(const LocalVector& u,
315  std::vector<std::vector<MathVector<dim> > > vvvLinDef[],
316  const size_t nip);
317 
319  template <typename TElem, typename TFEGeom>
321  const MathVector<dim> vGlobIP[],
322  const MathVector<TFEGeom::Type::dim> vLocIP[],
323  const size_t nip,
324  MathVector<dim> vValue[],
325  bool bDeriv,
326  std::vector<std::vector<MathVector<dim> > > vvvDeriv[]);
327 
328  private:
331 
334 
339 
341  int m_order;
342 
345 
349 
350  double m_massScale;
351 
354 
357 
360 
363 
364 
365  public:
369 
373 
374 
375  protected:
380 
381 
383  template <typename TElem, typename TFEGeom>
384  void ex_divergence_fe(number vValue[],
385  const MathVector<dim> vGlobIP[],
386  number time, int si,
387  const LocalVector& u,
388  GridObject* elem,
389  const MathVector<dim> vCornerCoords[],
390  const MathVector<TFEGeom::dim> vLocIP[],
391  const size_t nip,
392  bool bDeriv,
393  std::vector<std::vector<number> > vvvDeriv[]);
394 
395 
397  template <typename TElem, typename TFEGeom>
398  void ex_displacement_fe(MathVector<dim> vValue[],
399  const MathVector<dim> vGlobIP[],
400  number time, int si,
401  const LocalVector& u,
402  GridObject* elem,
403  const MathVector<dim> vCornerCoords[],
404  const MathVector<TFEGeom::dim> vLocIP[],
405  const size_t nip,
406  bool bDeriv,
407  std::vector<std::vector<MathVector<dim> > > vvvDeriv[]);
408 
410  template <typename TElem, typename TFEGeom>
411  void ex_stress_fe(MathMatrix<dim,dim> vValue[],
412  const MathVector<dim> vGlobIP[],
413  number time, int si,
414  const LocalVector& u,
415  GridObject* elem,
416  const MathVector<dim> vCornerCoords[],
417  const MathVector<TFEGeom::dim> vLocIP[],
418  const size_t nip,
419  bool bDeriv,
420  std::vector<std::vector<MathMatrix<dim,dim> > > vvvDeriv[]);
421 
422 
423 };
424 
425 // end group small_strain_mechanics
427 
428 } //end of namespace SmallStrainMechanics
429 } //end of namespace ug
430 
431 
432 
433 #endif /* SMALL_STRAIN_MECH_H_ */
number time() const
TDomain::position_type position_type
static const int dim
Definition: mat_law_interface.h:44
Definition: mech_output_writer.h:52
int m_order
current order of disc scheme
Definition: small_strain_mech.h:341
void register_fe_func()
Definition: small_strain_mech.cpp:1424
void prep_timestep_elem(const number time, const LocalVector &u, GridObject *elem, const MathVector< dim > vCornerCoords[])
assemble methods
Definition: small_strain_mech.cpp:251
virtual ~SmallStrainMechanicsElemDisc()
destructor
Definition: small_strain_mech.cpp:908
SmartPtr< DataExport< number, dim > > m_exDivergence
Export.
Definition: small_strain_mech.h:377
void set_viscous_forces(SmartPtr< CplUserData< MathVector< dim >, dim > > user0, SmartPtr< CplUserData< MathVector< dim >, dim > > user1)
Definition: small_strain_mech.cpp:152
SmartPtr< CplUserData< MathVector< dim >, dim > > VectorExport
Definition: small_strain_mech.h:367
SmartPtr< CplUserData< number, dim > > NumberExport
Definition: small_strain_mech.h:366
void set_assemble_funcs()
sets the requested assembling routines
Definition: small_strain_mech.cpp:844
void ex_stress_fe(MathMatrix< dim, dim > vValue[], const MathVector< dim > vGlobIP[], number time, int si, const LocalVector &u, GridObject *elem, const MathVector< dim > vCornerCoords[], const MathVector< TFEGeom::dim > vLocIP[], const size_t nip, bool bDeriv, std::vector< std::vector< MathMatrix< dim, dim > > > vvvDeriv[])
computes the stress
Definition: small_strain_mech.cpp:924
double m_massScale
Definition: small_strain_mech.h:350
virtual void prepare_setting(const std::vector< LFEID > &vLfeID, bool bNonRegularGrid)
type of trial space for each function used
Definition: small_strain_mech.h:205
SmartPtr< DataExport< MathVector< dim >, dim > > m_exDisplacement
Definition: small_strain_mech.h:378
void lin_def_volume_forces(const LocalVector &u, std::vector< std::vector< MathVector< dim > > > vvvLinDef[], const size_t nip)
Definition: small_strain_mech.cpp:708
DataImport< MathVector< dim >, dim > m_imViscousForces[2]
data import for viscous forces
Definition: small_strain_mech.h:362
void fsh_timestep_elem(const number time, const LocalVector &u, GridObject *elem, const MathVector< dim > vCornerCoords[])
Definition: small_strain_mech.cpp:807
void init_state_variables(const size_t order)
initialize state/"inner" variables
Definition: small_strain_mech.cpp:200
void set_output_writer(SmartPtr< MechOutputWriter< TDomain > > spOutWriter)
set an output writer
Definition: small_strain_mech.h:139
void add_jac_A_elem(LocalMatrix &J, const LocalVector &u, GridObject *elem, const MathVector< dim > vCornerCoords[])
Definition: small_strain_mech.cpp:336
SmartPtr< IMaterialLaw< TDomain > > m_spMatLaw
material law
Definition: small_strain_mech.h:330
void set_compress_factor(number val)
Definition: small_strain_mech.cpp:161
void set_material_law(SmartPtr< IMaterialLaw< TDomain > > spMatLaw)
adds a material law
Definition: small_strain_mech.h:131
SmartPtr< MathTensor4< dim, dim, dim, dim > > m_spElastTensor
elasticity tensor
Definition: small_strain_mech.h:333
bool m_bMatLawPassedToOutWriter
Definition: small_strain_mech.h:338
DataImport< number, dim > m_imDivergence
Data import for the reaction term.
Definition: small_strain_mech.h:356
void register_all_fe_funcs(int order, int quadOrder)
SmartPtr< IMaterialLaw< TDomain > > get_material_law()
gets the material law
Definition: small_strain_mech.h:135
void contact_forces_elem_ips_avg(LocalVector &locForce, GridObject *side, TElem *elem, const MathVector< dim > sideCoPos[], int numElemCorners, const LocalVector &locU, std::vector< DoFIndex > vActiveSetLoc)
computing contact forces elementwise by averaging over all integration points
size_t num_fct() const
Definition: small_strain_mech.h:248
base_type::domain_type domain_type
Domain type.
Definition: small_strain_mech.h:115
void lin_def_pressure(const LocalVector &u, std::vector< std::vector< number > > vvvLinDef[], const size_t nip)
Definition: small_strain_mech.cpp:678
void set_quad_order(const size_t order)
sets the quad order
Definition: small_strain_mech.h:182
LFEID m_lfeID
current shape function set
Definition: small_strain_mech.h:344
void print_mat_constants(const number lambda, const number mu, const number E, const number v)
prints material constants
void contact_forces_elem_midpoint(LocalVector &locForce, TSide *side, TElem *elem, const MathVector< dim > sideCoPos[], const LocalVector &locU, std::vector< DoFIndex > vActiveSetLoc)
computing contact forces elementwise at every element midpoint
void lin_def_viscous_forces0(const LocalVector &u, std::vector< std::vector< MathVector< dim > > > vvvLinDef[], const size_t nip)
Definition: small_strain_mech.cpp:742
SmallStrainMechanicsElemDisc< TDomain > this_type
own type
Definition: small_strain_mech.h:108
SmartPtr< DataExport< MathMatrix< dim, dim >, dim > > m_exStressTensor
Definition: small_strain_mech.h:379
std::string config_string() const
returns config information of small strain mechanics ElemDisc and material law
Definition: small_strain_mech.h:228
SmartPtr< CplUserData< MathMatrix< dim, dim >, dim > > MatrixExport
Definition: small_strain_mech.h:368
DataImport< number, dim > m_imCompressIndex
Data import for the compressibility term.
Definition: small_strain_mech.h:359
void ex_displacement_fe(MathVector< dim > vValue[], const MathVector< dim > vGlobIP[], number time, int si, const LocalVector &u, GridObject *elem, const MathVector< dim > vCornerCoords[], const MathVector< TFEGeom::dim > vLocIP[], const size_t nip, bool bDeriv, std::vector< std::vector< MathVector< dim > > > vvvDeriv[])
computes the displacement
Definition: small_strain_mech.cpp:1034
void prep_elem_loop(const ReferenceObjectID roid, const int si)
Definition: small_strain_mech.cpp:261
void set_volume_forces(SmartPtr< CplUserData< MathVector< dim >, dim > > user)
Definition: small_strain_mech.cpp:62
void update_geo_elem(TBaseElem *elem, DimFEGeometry< dim > &geo)
updates the geometry for a given element
Definition: small_strain_mech.cpp:171
VectorExport displacement()
Definition: small_strain_mech.h:371
void lin_def_viscous_forces1(const LocalVector &u, std::vector< std::vector< MathVector< dim > > > vvvLinDef[], const size_t nip)
Definition: small_strain_mech.cpp:776
int get_quad_order()
gets the quad order
Definition: small_strain_mech.h:184
void ex_divergence_fe(number vValue[], const MathVector< dim > vGlobIP[], number time, int si, const LocalVector &u, GridObject *elem, const MathVector< dim > vCornerCoords[], const MathVector< TFEGeom::dim > vLocIP[], const size_t nip, bool bDeriv, std::vector< std::vector< number > > vvvDeriv[])
computes the divergence of displacement
Definition: small_strain_mech.cpp:1134
domain_traits< TDomain::dim >::grid_base_object TBaseElem
base element type of associated domain
Definition: small_strain_mech.h:111
void set_mass_scale(double val)
Definition: small_strain_mech.h:186
void prep_elem(const LocalVector &u, GridObject *elem, const ReferenceObjectID roid, const MathVector< dim > vCornerCoords[])
Definition: small_strain_mech.cpp:309
IElemDisc< TDomain > base_type
Base class type.
Definition: small_strain_mech.h:105
DataImport< MathVector< dim >, dim > m_imVolForce
data import for volume forces
Definition: small_strain_mech.h:353
static const int dim
World dimension.
Definition: small_strain_mech.h:118
SmallStrainMechanicsElemDisc(const char *functions, const char *subsets)
constructor
Definition: small_strain_mech.cpp:868
SmartPtr< MechOutputWriter< TDomain > > m_spOutWriter
output writer
Definition: small_strain_mech.h:336
int m_quadOrder
Definition: small_strain_mech.h:348
void add_def_A_elem(LocalVector &d, const LocalVector &u, GridObject *elem, const MathVector< dim > vCornerCoords[])
Definition: small_strain_mech.cpp:448
void add_jac_M_elem(LocalMatrix &J, const LocalVector &u, GridObject *elem, const MathVector< dim > vCornerCoords[])
Definition: small_strain_mech.cpp:419
MatrixExport stress()
Definition: small_strain_mech.h:372
void add_rhs_elem(LocalVector &d, GridObject *elem, const MathVector< dim > vCornerCoords[])
Definition: small_strain_mech.cpp:572
base_type::position_type position_type
Position type.
Definition: small_strain_mech.h:121
NumberExport divergence()
Definition: small_strain_mech.h:370
bool m_bOutWriter
Definition: small_strain_mech.h:337
void set_div_factor(SmartPtr< CplUserData< number, dim > > user)
Definition: small_strain_mech.cpp:128
void add_def_M_elem(LocalVector &d, const LocalVector &u, GridObject *elem, const MathVector< dim > vCornerCoords[])
Definition: small_strain_mech.cpp:564
bool m_bQuadOrderUserDef
current integration order
Definition: small_strain_mech.h:347
void fsh_elem_loop()
Definition: small_strain_mech.cpp:303
void ex_displacement(const LocalVector &u, const MathVector< dim > vGlobIP[], const MathVector< TFEGeom::Type::dim > vLocIP[], const size_t nip, MathVector< dim > vValue[], bool bDeriv, std::vector< std::vector< MathVector< dim > > > vvvDeriv[])
computes the displacements (and derivatives)
#define UG_THROW(msg)
double number
ReferenceObjectID
UG_API std::string ConfigShift(std::string s)