5 #ifndef _neo_hookean_two_fields_interface_h_
6 #define _neo_hookean_two_fields_interface_h_
9 #include <deal2lkit/parsed_function.h>
26 template <
int dim,
int spacedim,
typename LAC>
39 template <
typename EnergyType,
typename Res
idualType>
41 FEValuesCache<dim,spacedim> &scratch,
42 std::vector<EnergyType> &energies,
43 std::vector<std::vector<ResidualType> > &local_residuals,
44 bool compute_only_system_terms)
const;
48 const std::vector<shared_ptr<LATrilinos::BlockMatrix> >,
56 mutable shared_ptr<TrilinosWrappers::PreconditionAMG> Amg_preconditioner;
57 mutable shared_ptr<TrilinosWrappers::PreconditionJacobi> P_preconditioner;
61 template <
int dim,
int spacedim,
typename LAC>
65 "FESystem[FE_Q(2)^d-FE_Q(1)]",
71 template <
int dim,
int spacedim,
typename LAC>
72 template<
typename EnergyType,
typename Res
idualType>
74 FEValuesCache<dim,spacedim> &fe_cache,
75 std::vector<EnergyType> &energies,
76 std::vector<std::vector<ResidualType> > &,
77 bool compute_only_system_terms)
const
79 EnergyType alpha = this->alpha;
80 this->reinit(alpha, cell, fe_cache);
84 auto &grad_us = fe_cache.get_gradients(
"solution",
"u", displacement, alpha);
85 auto &Fs = fe_cache.get_deformation_gradients(
"solution",
"Fu", displacement, alpha);
88 auto &ps = fe_cache.get_values(
"solution",
"p", pressure, alpha);
90 auto &JxW = fe_cache.get_JxW_values();
92 const unsigned int n_q_points = ps.size();
95 for (
unsigned int q=0; q<n_q_points; ++q)
99 const EnergyType &p = ps[q];
102 auto &grad_u = grad_us[q];
104 EnergyType Ic = trace(C);
105 EnergyType J = determinant(F);
107 EnergyType psi = (
mu/2.)*(Ic-dim)-p*(J-1.);
108 energies[0] += (psi)*JxW[q];
109 if (!compute_only_system_terms)
110 energies[1] += (scalar_product(grad_u,grad_u) + 0.5*p*p)*JxW[q];
115 template <
int dim,
int spacedim,
typename LAC>
122 template <
int dim,
int spacedim,
typename LAC>
125 couplings[0]=
"1,1;1,0";
126 couplings[1]=
"1,0;0,1";
129 template <
int dim,
int spacedim,
typename LAC>
132 const std::vector<shared_ptr<LATrilinos::BlockMatrix> > matrices,
137 std::vector<std::vector<bool> > constant_modes;
152 P_preconditioner->initialize (matrices[1]->block(1,1));
153 Amg_preconditioner->initialize (matrices[1]->block(0,0),Amg_data);
157 auto A = linear_operator< TrilinosWrappers::MPI::Vector >( matrices[0]->block(0,0) );
158 auto Bt = linear_operator< TrilinosWrappers::MPI::Vector >( matrices[0]->block(0,1) );
160 auto B = linear_operator< TrilinosWrappers::MPI::Vector >( matrices[0]->block(1,0) );
161 auto ZeroP = 0*linear_operator< TrilinosWrappers::MPI::Vector >( matrices[0]->block(1,1) );
163 auto Mp = linear_operator< TrilinosWrappers::MPI::Vector >( matrices[1]->block(1,1) );
172 auto P10 = Schur_inv * B * A_inv;
173 auto P11 = -1 * Schur_inv;
176 system_op = block_operator<2, 2, LATrilinos::VectorType >({{
185 prec_op = block_operator<2, 2, LATrilinos::VectorType >({{
Definition: lac_type.h:33
double aggregation_threshold
std::vector< std::vector< bool > > constant_modes
void set_matrix_couplings(std::vector< std::string > &couplings) const
Definition: neo_hookean_two_fields.h:123
ActiveSelector::active_cell_iterator active_cell_iterator
This is the class that users should derive from.
Definition: pde_system_interface.h:46
unsigned int smoother_sweeps
NeoHookeanTwoFieldsInterface()
Definition: neo_hookean_two_fields.h:62
virtual void declare_parameters(ParameterHandler &prm)
Definition: neo_hookean_two_fields.h:116
LinearOperator< Range, Domain > null_operator(const LinearOperator< Range, Domain > &op)
void compute_system_operators(const DoFHandler< dim, spacedim > &, const std::vector< shared_ptr< LATrilinos::BlockMatrix > >, LinearOperator< LATrilinos::VectorType > &, LinearOperator< LATrilinos::VectorType > &) const
Definition: neo_hookean_two_fields.h:131
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)
Definition: neo_hookean_two_fields.h:27
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: neo_hookean_two_fields.h:73
const FiniteElement< dim, spacedim > & get_fe() const
bool higher_order_elements