31 #include "constitutive.h" 
   34 #include "meshes/rectangular_quadmesh.h" 
   38 using namespace oomph;
 
   49 template <
class ELEMENT>
 
   59  void output(std::ostream &outfile, 
const unsigned &n_plot)
 
   63    unsigned el_dim = this->dim();
 
   65    Vector<double> s(el_dim);
 
   66    Vector<double> x(el_dim);
 
   67    DenseMatrix<double> sigma(el_dim,el_dim);
 
   75      outfile << 
"ZONE I=" << n_plot << 
", J=" << n_plot << std::endl;
 
   78      for(
unsigned l2=0;l2<n_plot;l2++)
 
   80        s[1] = -1.0 + l2*2.0/(n_plot-1);
 
   81        for(
unsigned l1=0;l1<n_plot;l1++)
 
   83          s[0] = -1.0 + l1*2.0/(n_plot-1);
 
   86          this->interpolated_x(s,x);
 
   87          this->get_stress(s,sigma);
 
   90          for(
unsigned i=0;i<el_dim;i++) 
 
   91           {outfile << x[i] << 
" ";}
 
   94          outfile << sigma(0,0) << 
" " 
  105      std::ostringstream error_message;
 
  106      error_message << 
"Output for dim !=2 not implemented" << std::endl;
 
  107      throw OomphLibError(error_message.str(),
 
  108                          OOMPH_CURRENT_FUNCTION,
 
  109                          OOMPH_EXCEPTION_LOCATION);
 
  121 template<
class ELEMENT>
 
  123  public virtual FaceGeometry<ELEMENT>
 
  187                         const Vector<double> &n, Vector<double> &traction)
 
  189   unsigned dim = traction.size();
 
  190   for(
unsigned i=0;i<dim;i++)
 
  192     traction[i] = -
P*n[i];
 
  201  void gravity(
const double& time, 
 
  202               const Vector<double> &xi, 
 
  216 template<
class ELEMENT>
 
  235   {
return Solid_mesh_pt;} 
 
  241   {
return Solid_mesh_pt;} 
 
  259  void run_it(
const unsigned& i_case);
 
  283  ElasticRefineableRectangularQuadMesh<ELEMENT>* Solid_mesh_pt;
 
  294  SolidMesh* Traction_mesh_pt;
 
  305 template<
class ELEMENT>
 
  325  Vector<double> origin(2);
 
  332  solid_mesh_pt() = 
new ElasticRefineableRectangularQuadMesh<ELEMENT>(
 
  333   n_x,n_y,l_x,l_y,origin);
 
  336  dynamic_cast<ElasticRefineableRectangularQuadMesh<ELEMENT>* 
>(
 
  337   solid_mesh_pt())->spatial_error_estimator_pt()=
new Z2ErrorEstimator;
 
  342  solid_mesh_pt() = 
new ElasticRectangularQuadMesh<ELEMENT>(
 
  343   n_x,n_y,l_x,l_y,origin);
 
  350  unsigned n_element =solid_mesh_pt()->nelement();
 
  351  for(
unsigned i=0;i<n_element;i++)
 
  354    ELEMENT *el_pt = 
dynamic_cast<ELEMENT*
>(solid_mesh_pt()->element_pt(i));
 
  357    el_pt->constitutive_law_pt() =
 
  366      el_pt->enable_evaluate_jacobian_by_fd();
 
  370      el_pt->disable_evaluate_jacobian_by_fd();
 
  376      PVDEquationsWithPressure<2>* test_pt = 
 
  377       dynamic_cast<PVDEquationsWithPressure<2>*
>(
 
  378        solid_mesh_pt()->element_pt(i));
 
  381        test_pt->set_incompressible();
 
  388  unsigned nnod=solid_mesh_pt()->nnode();
 
  389  Trace_node_pt=solid_mesh_pt()->node_pt(nnod-1);
 
  394  dynamic_cast<ElasticRefineableRectangularQuadMesh<ELEMENT>* 
>(
 
  395   solid_mesh_pt())->refine_uniformly();
 
  400  Traction_mesh_pt=
new SolidMesh;
 
  401  create_traction_elements();
 
  408  add_sub_mesh(solid_mesh_pt());
 
  411  add_sub_mesh(traction_mesh_pt());
 
  417  unsigned n_side = mesh_pt()->nboundary_node(3);
 
  420  for(
unsigned i=0;i<n_side;i++)
 
  422    solid_mesh_pt()->boundary_node_pt(3,i)->pin_position(0);
 
  423    solid_mesh_pt()->boundary_node_pt(3,i)->pin_position(1);
 
  428  PVDEquationsBase<2>::pin_redundant_nodal_solid_pressures(
 
  429   solid_mesh_pt()->element_pt());
 
  432  cout << assign_eqn_numbers() << std::endl; 
 
  441 template<
class ELEMENT>
 
  445  delete_traction_elements();
 
  448  rebuild_global_mesh();
 
  457 template<
class ELEMENT>
 
  462  create_traction_elements();
 
  465  rebuild_global_mesh();
 
  468  PVDEquationsBase<2>::pin_redundant_nodal_solid_pressures(
 
  469   solid_mesh_pt()->element_pt());
 
  482 template<
class ELEMENT>
 
  487  unsigned n_element=traction_mesh_pt()->nelement();
 
  488  for(
unsigned i=0;i<n_element;i++)
 
  491    SolidTractionElement<ELEMENT> *el_pt = 
 
  492     dynamic_cast<SolidTractionElement<ELEMENT>*
> 
  493     (traction_mesh_pt()->element_pt(i));
 
  506 template<
class ELEMENT>
 
  513  unsigned n_element = solid_mesh_pt()->nboundary_element(b);
 
  516  for(
unsigned e=0;e<n_element;e++)
 
  519    ELEMENT* bulk_elem_pt = 
dynamic_cast<ELEMENT*
>(
 
  520     solid_mesh_pt()->boundary_element_pt(b,e));
 
  523    int face_index = solid_mesh_pt()->face_index_at_boundary(b,e);
 
  526    Traction_mesh_pt->add_element_pt(
new SolidTractionElement<ELEMENT>
 
  527                                     (bulk_elem_pt,face_index));   
 
  541 template<
class ELEMENT>
 
  545  unsigned n_element = Traction_mesh_pt->nelement();
 
  548  for(
unsigned e=0;e<n_element;e++)
 
  551    delete Traction_mesh_pt->element_pt(e);
 
  555  Traction_mesh_pt->flush_element_and_node_storage();
 
  564 template<
class ELEMENT>
 
  576  sprintf(filename,
"%s/soln%i.dat",Doc_info.directory().c_str(),
 
  578  some_file.open(filename);
 
  579  solid_mesh_pt()->output(some_file,n_plot);
 
  585  sprintf(filename,
"%s/exact_soln%i.dat",Doc_info.directory().c_str(),
 
  587  some_file.open(filename);
 
  592  Vector<double> s(el_dim);
 
  593  Vector<double> x(el_dim);
 
  594  Vector<double> xi(el_dim);
 
  595  DenseMatrix<double> sigma(el_dim,el_dim);
 
  605  unsigned nel=solid_mesh_pt()->nelement();
 
  606  for (
unsigned e=0;e<nel;e++)
 
  609    ELEMENT* el_pt=
dynamic_cast<ELEMENT*
>(
 
  610     solid_mesh_pt()->element_pt(e));
 
  613    some_file << 
"ZONE I=" << n_plot << 
", J=" << n_plot << std::endl;
 
  616    for(
unsigned l2=0;l2<n_plot;l2++)
 
  618      s[1] = -1.0 + l2*2.0/(n_plot-1);
 
  619      for(
unsigned l1=0;l1<n_plot;l1++)
 
  621        s[0] = -1.0 + l1*2.0/(n_plot-1);
 
  624        el_pt->interpolated_x(s,x);
 
  625        el_pt->interpolated_xi(s,xi);
 
  628        for(
unsigned i=0;i<el_dim;i++) 
 
  629         {some_file << x[i] << 
" ";}
 
  637          sigma(0,0)=c*(6.0*xx*xx*yy-4.0*yy*yy*yy)+
 
  639          sigma(1,1)=2.0*(a+b*yy+c*yy*yy*yy);
 
  640          sigma(1,0)=2.0*(b*xx+3.0*c*xx*yy*yy);
 
  641          sigma(0,1)=sigma(1,0);
 
  644          some_file << sigma(0,0) << 
" " 
  655             << Trace_node_pt->x(0) << 
" "  
  656             << Trace_node_pt->x(1) << 
" "  
  671 template<
class ELEMENT>
 
  675 #ifdef TIME_SOLID_JAC 
  676   PVDEquationsBase<2>::Solid_timer.reset();
 
  683  sprintf(dirname,
"RESLT_refine%i",i_case);
 
  685  sprintf(dirname,
"RESLT_norefine%i",i_case);
 
  688  Doc_info.set_directory(dirname);
 
  692  sprintf(filename,
"%s/trace.dat",Doc_info.directory().c_str());
 
  693  Trace_file.open(filename);
 
  705  double p_increment=1.0e-5;   
 
  706  for(
unsigned i=0;i<nstep;i++)
 
  717    unsigned max_adapt=1;
 
  719    newton_solve(max_adapt);
 
  732 #ifdef TIME_SOLID_JAC 
  734  std::cout << 
"Total fill_in... : "  
  735            <<   PVDEquationsBase<2>::Solid_timer.cumulative_time(0) 
 
  738  std::cout << 
"Total d_stress_dG: "  
  739            <<   PVDEquationsBase<2>::Solid_timer.cumulative_time(1) 
 
  742  std::cout << 
"Total Jac        : "  
  743            <<   PVDEquationsBase<2>::Solid_timer.cumulative_time(2) 
 
  746   PVDEquationsBase<2>::Solid_timer.reset();
 
  763  bool incompress=
false;
 
  770  for (
unsigned i=0;i<2;i++)
 
  786       problem(incompress,use_fd);
 
  788      problem.
run_it(0+i*ncase);
 
  794       problem(incompress,use_fd);
 
  796      problem.
run_it(0+i*ncase);
 
  805       RefineableQPVDElementWithContinuousPressure<2> > > 
 
  806       problem(incompress,use_fd); 
 
  808      problem.run_it(1+i*ncase);
 
  814       QPVDElementWithContinuousPressure<2> > > 
 
  815       problem(incompress,use_fd); 
 
  817      problem.run_it(1+i*ncase);
 
  826       RefineableQPVDElementWithPressure<2> > > problem(incompress,use_fd); 
 
  828      problem.run_it(2+i*ncase);
 
  834       QPVDElementWithPressure<2> > > problem(incompress,use_fd); 
 
  836      problem.run_it(2+i*ncase);
 
  855      new IsotropicStrainEnergyFunctionConstitutiveLaw(
 
  865       RefineableQPVDElementWithContinuousPressure<2> > > 
 
  866       problem(incompress,use_fd); 
 
  868      problem.run_it(3+i*ncase);
 
  874       QPVDElementWithContinuousPressure<2> > > 
 
  875       problem(incompress,use_fd); 
 
  877      problem.run_it(3+i*ncase);
 
  887       RefineableQPVDElementWithPressure<2> > > 
 
  888       problem(incompress,use_fd); 
 
  890      problem.run_it(4+i*ncase);
 
  896       QPVDElementWithPressure<2> > > 
 
  897       problem(incompress,use_fd); 
 
  899      problem.run_it(4+i*ncase);
 
  912    std::cout << 
"\n\n\n CR Total fill_in... : bla \n\n\n " << std::endl;
 
int main()
Driver for cantilever beam loaded by surface traction and/or gravity.
 
Problem class for the cantilever "beam" structure.
 
ElasticRefineableRectangularQuadMesh< ELEMENT > *& solid_mesh_pt()
Access function for the solid mesh.
 
void actions_before_newton_solve()
Update function (empty)
 
void actions_after_newton_solve()
Update function (empty)
 
void actions_before_adapt()
Actions before adapt: Wipe the mesh of traction elements.
 
void run_it(const unsigned &i_case)
Run the job – doc in RESLTi_case.
 
ElasticRectangularQuadMesh< ELEMENT > *& solid_mesh_pt()
Access function for the solid mesh.
 
void doc_solution()
Doc the solution.
 
void set_traction_pt()
Pass pointer to traction function to the elements in the traction mesh.
 
void create_traction_elements()
Create traction elements.
 
CantileverProblem()
Constructor:
 
void delete_traction_elements()
Delete traction elements.
 
ElasticRectangularQuadMesh< ELEMENT > * Solid_mesh_pt
Pointer to solid mesh.
 
void actions_after_adapt()
Actions after adapt: Rebuild the mesh of traction elements.
 
SolidMesh *& traction_mesh_pt()
Access function to the mesh of surface traction elements.
 
FaceGeometry()
Constructor [this was only required explicitly from gcc 4.5.2 onwards...].
 
Wrapper class for solid elements to modify their output functions.
 
void output(std::ostream &outfile, const unsigned &n_plot)
Overload output function:
 
MySolidElement()
Constructor: Call constructor of underlying element.
 
//////////////////////////////////////////////////////////////////// ////////////////////////////////...
 
void gravity(const double &time, const Vector< double > &xi, Vector< double > &b)
Non-dimensional gravity as body force.
 
void constant_pressure(const Vector< double > &xi, const Vector< double > &x, const Vector< double > &n, Vector< double > &traction)
Constant pressure load. The arguments to this function are imposed on us by the SolidTractionElements...
 
double P
Uniform pressure.
 
double Nu
Poisson's ratio.
 
ConstitutiveLaw * Constitutive_law_pt
Pointer to constitutive law.
 
StrainEnergyFunction * Strain_energy_function_pt
Pointer to strain energy function.
 
double C1
"Mooney Rivlin" coefficient for generalised Mooney Rivlin law
 
double Gravity
Non-dim gravity.
 
double H
Half height of beam.
 
double C2
"Mooney Rivlin" coefficient for generalised Mooney Rivlin law