pi-DoMUS: Parallel Deal.II MUltiphysics Solver
compressible_neo_hookean_direct.h
Go to the documentation of this file.
1 #ifndef _compressible_neo_hookean_h_
2 #define _compressible_neo_hookean_h_
3 
5 #include <deal2lkit/parsed_function.h>
6 
7 
8 #include <deal.II/fe/fe_values.h>
13 
17 
18 #include <deal.II/lac/solver_cg.h>
20 
21 
22 template <int dim, int spacedim>
23 class CompressibleNeoHookeanInterface : public ConservativeInterface<dim,spacedim,dim, CompressibleNeoHookeanInterface<dim,spacedim>, LADealII >
24 {
25  typedef FEValuesCache<dim,spacedim> Scratch;
26  typedef Assembly::CopyData::piDoMUSPreconditioner<dim,dim> CopyPreconditioner;
27  typedef Assembly::CopyData::piDoMUSSystem<dim,dim> CopySystem;
28  typedef BlockVector<double> VEC;
29 
30 public:
31 
32  /* specific and useful functions for this very problem */
34 
36 
39 
40 
41  /* these functions MUST have the follwowing names
42  * because they are called by the ConservativeInterface class
43  */
44 
45  template<typename Number>
47  Scratch &,
48  CopyPreconditioner &,
49  Number &energy) const;
50 
51  template<typename Number>
53  Scratch &,
54  CopySystem &,
55  Number &energy) const;
56 
61  LinearOperator<VEC> &) const;
62 
63 private:
64  double E;
65  double nu;
66  double mu;
67  double lambda;
68 
69 
70  mutable shared_ptr<TrilinosWrappers::PreconditionAMG> Amg_preconditioner;
71  mutable shared_ptr<TrilinosWrappers::PreconditionJacobi> Mp_preconditioner;
72  mutable shared_ptr<TrilinosWrappers::PreconditionJacobi> T_preconditioner;
73 
74 };
75 
76 template <int dim, int spacedim>
78  ConservativeInterface<dim,spacedim,dim,CompressibleNeoHookeanInterface<dim,spacedim>,LADealII >("Compressible NeoHookean Interface",
79  "FESystem[FE_Q(1)^d]",
80  "u,u,u", "1", "1","1")
81 {};
82 
83 
84 template <int dim, int spacedim>
85 template<typename Number>
87  Scratch &fe_cache,
88  CopyPreconditioner &data,
89  Number &energy) const
90 {
91  Number alpha = this->alpha;
92  this->reinit(alpha, cell, fe_cache);
93 
94  const FEValuesExtractors::Vector displacement(0);
95  auto &us = fe_cache.get_values("solution", "u", displacement, alpha);
96 
97  const unsigned int n_q_points = us.size();
98 
99  auto &JxW = fe_cache.get_JxW_values();
100  energy = 0;
101  for (unsigned int q=0; q<n_q_points; ++q)
102  {
103  const Tensor <1, dim, Number> &u = us[q];
104 
105  energy += 0.5*(u*u)*JxW[q];
106  }
107 }
108 
109 template <int dim, int spacedim>
110 template<typename Number>
112  Scratch &fe_cache,
113  CopySystem &data,
114  Number &energy) const
115 {
116  Number alpha = this->alpha;
117  this->reinit(alpha, cell, fe_cache);
118 
119  const FEValuesExtractors::Vector displacement(0);
120  auto &us = fe_cache.get_values("solution", "u", displacement, alpha);
121  auto &us_dot = fe_cache.get_values("solution_dot", "u_dot", displacement, alpha);
122  auto &Fs = fe_cache.get_deformation_gradients("solution", "Fu", displacement, alpha);
123 
124  const unsigned int n_q_points = us.size();
125 
126  auto &JxW = fe_cache.get_JxW_values();
127  energy = 0;
128  for (unsigned int q=0; q<n_q_points; ++q)
129  {
130 
131  const Tensor <1, dim, Number> &u = us[q];
132  const Tensor <1, dim, Number> &u_dot = us_dot[q];
133  const Tensor <2, dim, Number> &F = Fs[q];
134  const Tensor<2, dim, Number> C = transpose(F)*F;
135 
136  Number Ic = trace(C);
137  Number J = determinant(F);
138  Number lnJ = std::log (J);
139 
140  Number psi = (mu/2.)*(Ic-dim) - mu*lnJ + (lambda/2.)*(lnJ)*(lnJ);
141 
142  energy += (psi)*JxW[q];
143 
144  }
145 
146 }
147 
148 
149 template <int dim, int spacedim>
151 {
153  this->add_parameter(prm, &E, "Young's modulus", "10.0", Patterns::Double(0.0));
154  this->add_parameter(prm, &nu, "Poisson's ratio", "0.3", Patterns::Double(0.0));
155 }
156 
157 template <int dim, int spacedim>
159 {
161  mu = E/(2.0*(1.+nu));
162  lambda = (E *nu)/((1.+nu)*(1.-2.*nu));
163 }
164 
165 // template <int dim, int spacedim>
166 // void
167 // CompressibleNeoHookeanInterface<dim,spacedim>::compute_system_operators(const DoFHandler<dim,spacedim> &dh,
168 // const TrilinosWrappers::BlockSparseMatrix &matrix,
169 // const TrilinosWrappers::BlockSparseMatrix &preconditioner_matrix,
170 // LinearOperator<VEC> &system_op,
171 // LinearOperator<VEC> &prec_op) const
172 // {
173 //
174 // std::vector<std::vector<bool> > constant_modes;
175 // FEValuesExtractors::Vector displacement(0);
176 // DoFTools::extract_constant_modes (dh, dh.get_fe().component_mask(displacement),
177 // constant_modes);
178 //
179 // Mp_preconditioner.reset (new TrilinosWrappers::PreconditionJacobi());
180 // Amg_preconditioner.reset (new TrilinosWrappers::PreconditionAMG());
181 //
182 // TrilinosWrappers::PreconditionAMG::AdditionalData Amg_data;
183 // Amg_data.constant_modes = constant_modes;
184 // Amg_data.elliptic = true;
185 // Amg_data.higher_order_elements = true;
186 // Amg_data.smoother_sweeps = 2;
187 // Amg_data.aggregation_threshold = 0.02;
188 //
189 // // Mp_preconditioner->initialize (preconditioner_matrix.block(0,0));
190 // Amg_preconditioner->initialize (preconditioner_matrix.block(0,0),
191 // Amg_data);
192 //
193 //
194 // auto A = linear_operator< TrilinosWrappers::MPI::Vector >( matrix.block(0,0) );
195 //
196 // static ReductionControl solver_control_pre(5000, 1e-8);
197 // static SolverCG<TrilinosWrappers::MPI::Vector> solver_CG(solver_control_pre);
198 // auto A_inv = inverse_operator( A, solver_CG, *Amg_preconditioner);
199 //
200 // auto P00 = A_inv;
201 //
202 // // ASSEMBLE THE PROBLEM:
203 // system_op = block_operator<1, 1, VEC >({{
204 // {{ A }}
205 // }
206 // });
207 //
208 //
209 // //const auto S = linear_operator<VEC>(matrix);
210 //
211 // prec_op = block_operator<1, 1, VEC >({{
212 // {{ P00}} ,
213 // }
214 // });
215 // }
216 
217 
219 
220 #endif
Definition: conservative.h:20
Definition: lac_type.h:33
void declare_parameters(ParameterHandler &prm)
Definition: compressible_neo_hookean.h:63
ActiveSelector::active_cell_iterator active_cell_iterator
Definition: compressible_neo_hookean.h:14
CompressibleNeoHookeanInterface()
Definition: compressible_neo_hookean.h:54
void preconditioner_energy(const typename DoFHandler< dim, spacedim >::active_cell_iterator &, Scratch &, CopyPreconditioner &, Number &energy) const
Definition: compressible_neo_hookean.h:92
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_direct.h:33
void parse_parameters_call_back()
Definition: compressible_neo_hookean.h:71
void system_energy(const typename DoFHandler< dim, spacedim >::active_cell_iterator &, Scratch &, CopySystem &, Number &energy) const
Definition: compressible_neo_hookean.h:117