pi-DoMUS: Parallel Deal.II MUltiphysics Solver
compressible_neo_hookean.h
Go to the documentation of this file.
1 #ifndef _pidoums_compressible_neo_hookean_h_
2 #define _pidoums_compressible_neo_hookean_h_
3 
4 #include "pde_system_interface.h"
5 
10 
11 //typedef LATrilinos LAC;
12 
13 template <int dim, int spacedim, typename LAC=LATrilinos>
14 class CompressibleNeoHookeanInterface : public PDESystemInterface<dim,spacedim, CompressibleNeoHookeanInterface<dim,spacedim,LAC>, LAC>
15 {
16 
17 public:
20 
23 
24  // interface with the PDESystemInterface :)
25 
26 
27  template <typename EnergyType, typename ResidualType>
29  FEValuesCache<dim,spacedim> &scratch,
30  std::vector<EnergyType> &energies,
31  std::vector<std::vector<ResidualType> > &local_residuals,
32  bool compute_only_system_terms) const;
33 
34 
36  const std::vector<shared_ptr<LATrilinos::BlockMatrix> >,
39 
40 private:
41  double E;
42  double nu;
43  double mu;
44  double lambda;
45 
46  mutable shared_ptr<TrilinosWrappers::PreconditionJacobi> preconditioner;
47 
48 
49 
50 };
51 
52 template <int dim, int spacedim, typename LAC>
55  PDESystemInterface<dim,spacedim,CompressibleNeoHookeanInterface<dim,spacedim,LAC>, LAC >("Compressible NeoHookean Parameters",
56  dim,2,
57  "FESystem[FE_Q(1)^d]",
58  "u,u,u","1")
59 {}
60 
61 
62 template <int dim, int spacedim, typename LAC>
64 {
66  this->add_parameter(prm, &E, "Young's modulus", "10.0", Patterns::Double(0.0));
67  this->add_parameter(prm, &nu, "Poisson's ratio", "0.3", Patterns::Double(0.0));
68 }
69 
70 template <int dim, int spacedim, typename LAC>
72 {
73  mu = E/(2.0*(1.+nu));
74  lambda = (E *nu)/((1.+nu)*(1.-2.*nu));
75 }
76 
77 
78 
79 template <int dim, int spacedim, typename LAC>
80 template <typename EnergyType, typename ResidualType>
81 void
84  FEValuesCache<dim,spacedim> &fe_cache,
85  std::vector<EnergyType> &energies,
86  std::vector<std::vector<ResidualType> > &,
87  bool compute_only_system_terms) const
88 {
89  const FEValuesExtractors::Vector displacement(0);
90 
92  //
93  EnergyType et = 0; // dummy number to define the type of variables
94  this->reinit (et, cell, fe_cache);
95  auto &us = fe_cache.get_values("solution", "u", displacement, et);
96  auto &Fs = fe_cache.get_deformation_gradients("solution", "Fu", displacement, et);
97 
98  const unsigned int n_q_points = us.size();
99  auto &JxW = fe_cache.get_JxW_values();
100 
101 
102  for (unsigned int q=0; q<n_q_points; ++q)
103  {
105  auto &u = us[q];
106  auto &F = Fs[q];
107  auto C = transpose(F)*F;
108 
109  auto Ic = trace(C);
110  auto J = determinant(F);
111  auto lnJ = std::log (J);
112 
113  EnergyType psi = (mu/2.)*(Ic-dim) - mu*lnJ + (lambda/2.)*(lnJ)*(lnJ);
114 
115  energies[0] += (psi)*JxW[q];
116 
117  if (!compute_only_system_terms)
118  energies[1] += 0.5*u*u*JxW[q];
119 
120  (void)compute_only_system_terms;
121 
122  }
123 
124 
125 }
126 
127 
128 template <int dim, int spacedim, typename LAC>
129 void
131  const std::vector<shared_ptr<LATrilinos::BlockMatrix> > matrices,
134 {
135 
136  preconditioner.reset (new TrilinosWrappers::PreconditionJacobi());
137  preconditioner->initialize(matrices[1]->block(0,0));
138  auto P = linear_operator<LATrilinos::VectorType::BlockType>(matrices[1]->block(0,0));
139 
140  auto A = linear_operator<LATrilinos::VectorType::BlockType>( matrices[0]->block(0,0) );
141 
142  static ReductionControl solver_control_pre(5000, 1e-4);
143  static SolverCG<LATrilinos::VectorType::BlockType> solver_CG(solver_control_pre);
144  auto P_inv = inverse_operator( P, solver_CG, *preconditioner);
145 
146  auto P00 = P_inv;
147 
148  // ASSEMBLE THE PROBLEM:
149  system_op = block_operator<1, 1, LATrilinos::VectorType>({{
150  {{ A }}
151  }
152  });
153 
154  prec_op = block_operator<1, 1, LATrilinos::VectorType>({{
155  {{ P00}} ,
156  }
157  });
158 }
159 
160 #endif
Definition: lac_type.h:33
void declare_parameters(ParameterHandler &prm)
Definition: compressible_neo_hookean.h:63
void energies_and_residuals(const typename DoFHandler< dim, spacedim >::active_cell_iterator &cell, FEValuesCache< dim, spacedim > &scratch, std::vector< EnergyType > &energies, std::vector< std::vector< ResidualType > > &local_residuals, bool compute_only_system_terms) const
Definition: compressible_neo_hookean.h:83
ActiveSelector::active_cell_iterator active_cell_iterator
This is the class that users should derive from.
Definition: pde_system_interface.h:46
Definition: compressible_neo_hookean.h:14
CompressibleNeoHookeanInterface()
Definition: compressible_neo_hookean.h:54
LinearOperator< typename Solver::vector_type, typename Solver::vector_type > inverse_operator(const LinearOperator< typename Solver::vector_type, typename Solver::vector_type > &op, Solver &solver, const Preconditioner &preconditioner)
void compute_system_operators(const DoFHandler< dim, spacedim > &, const std::vector< shared_ptr< LATrilinos::BlockMatrix > >, LinearOperator< LATrilinos::VectorType > &, LinearOperator< LATrilinos::VectorType > &) const
Definition: compressible_neo_hookean.h:130
~CompressibleNeoHookeanInterface()
Definition: compressible_neo_hookean.h:18
void parse_parameters_call_back()
Definition: compressible_neo_hookean.h:71