35 #include "constitutive.h" 38 #include "meshes/rectangular_quadmesh.h" 42 using namespace oomph;
53 template <
class ELEMENT>
63 void output(std::ostream &outfile,
const unsigned &n_plot)
67 unsigned el_dim = this->dim();
69 Vector<double> s(el_dim);
70 Vector<double> x(el_dim);
71 DenseMatrix<double> sigma(el_dim,el_dim);
79 outfile <<
"ZONE I=" << n_plot <<
", J=" << n_plot << std::endl;
82 for(
unsigned l2=0;l2<n_plot;l2++)
84 s[1] = -1.0 + l2*2.0/(n_plot-1);
85 for(
unsigned l1=0;l1<n_plot;l1++)
87 s[0] = -1.0 + l1*2.0/(n_plot-1);
90 this->interpolated_x(s,x);
91 this->get_stress(s,sigma);
94 for(
unsigned i=0;i<el_dim;i++)
95 {outfile << x[i] <<
" ";}
98 outfile << sigma(0,0) <<
" " 109 std::ostringstream error_message;
110 error_message <<
"Output for dim !=2 not implemented" << std::endl;
111 throw OomphLibError(error_message.str(),
112 OOMPH_CURRENT_FUNCTION,
113 OOMPH_EXCEPTION_LOCATION);
125 template<
class ELEMENT>
126 class FaceGeometry<MySolidElement<ELEMENT> > :
127 public virtual FaceGeometry<ELEMENT>
191 const Vector<double> &n, Vector<double> &traction)
193 unsigned dim = traction.size();
194 for(
unsigned i=0;i<dim;i++)
196 traction[i] = -P*n[i];
205 void gravity(
const double& time,
206 const Vector<double> &xi,
220 template<
class ELEMENT>
239 {
return Solid_mesh_pt;}
245 {
return Solid_mesh_pt;}
254 void actions_before_adapt();
257 void actions_after_adapt();
263 void run_it(
const unsigned& i_case);
269 void set_traction_pt();
272 void create_traction_elements();
275 void delete_traction_elements();
287 ElasticRefineableRectangularQuadMesh<ELEMENT>* Solid_mesh_pt;
298 SolidMesh* Traction_mesh_pt;
309 template<
class ELEMENT>
329 Vector<double> origin(2);
336 solid_mesh_pt() =
new ElasticRefineableRectangularQuadMesh<ELEMENT>(
337 n_x,n_y,l_x,l_y,origin);
340 dynamic_cast<ElasticRefineableRectangularQuadMesh<ELEMENT>*
>(
341 solid_mesh_pt())->spatial_error_estimator_pt()=
new Z2ErrorEstimator;
346 solid_mesh_pt() =
new ElasticRectangularQuadMesh<ELEMENT>(
347 n_x,n_y,l_x,l_y,origin);
354 unsigned n_element =solid_mesh_pt()->nelement();
355 for(
unsigned i=0;i<n_element;i++)
358 ELEMENT *el_pt =
dynamic_cast<ELEMENT*
>(solid_mesh_pt()->element_pt(i));
361 el_pt->constitutive_law_pt() =
370 el_pt->enable_evaluate_jacobian_by_fd();
374 el_pt->disable_evaluate_jacobian_by_fd();
380 PVDEquationsWithPressure<2>* test_pt =
381 dynamic_cast<PVDEquationsWithPressure<2>*
>(
382 solid_mesh_pt()->element_pt(i));
385 test_pt->set_incompressible();
392 unsigned nnod=solid_mesh_pt()->nnode();
393 Trace_node_pt=solid_mesh_pt()->node_pt(nnod-1);
398 dynamic_cast<ElasticRefineableRectangularQuadMesh<ELEMENT>*
>(
399 solid_mesh_pt())->refine_uniformly();
404 Traction_mesh_pt=
new SolidMesh;
405 create_traction_elements();
412 add_sub_mesh(solid_mesh_pt());
415 add_sub_mesh(traction_mesh_pt());
421 unsigned n_side = mesh_pt()->nboundary_node(3);
424 for(
unsigned i=0;i<n_side;i++)
426 solid_mesh_pt()->boundary_node_pt(3,i)->pin_position(0);
427 solid_mesh_pt()->boundary_node_pt(3,i)->pin_position(1);
432 PVDEquationsBase<2>::pin_redundant_nodal_solid_pressures(
433 solid_mesh_pt()->element_pt());
436 cout << assign_eqn_numbers() << std::endl;
445 template<
class ELEMENT>
449 delete_traction_elements();
452 rebuild_global_mesh();
461 template<
class ELEMENT>
466 create_traction_elements();
469 rebuild_global_mesh();
472 PVDEquationsBase<2>::pin_redundant_nodal_solid_pressures(
473 solid_mesh_pt()->element_pt());
486 template<
class ELEMENT>
491 unsigned n_element=traction_mesh_pt()->nelement();
492 for(
unsigned i=0;i<n_element;i++)
495 SolidTractionElement<ELEMENT> *el_pt =
496 dynamic_cast<SolidTractionElement<ELEMENT>*
> 497 (traction_mesh_pt()->element_pt(i));
510 template<
class ELEMENT>
517 unsigned n_element = solid_mesh_pt()->nboundary_element(b);
520 for(
unsigned e=0;e<n_element;e++)
523 ELEMENT* bulk_elem_pt =
dynamic_cast<ELEMENT*
>(
524 solid_mesh_pt()->boundary_element_pt(b,e));
527 int face_index = solid_mesh_pt()->face_index_at_boundary(b,e);
530 Traction_mesh_pt->add_element_pt(
new SolidTractionElement<ELEMENT>
531 (bulk_elem_pt,face_index));
545 template<
class ELEMENT>
549 unsigned n_element = Traction_mesh_pt->nelement();
552 for(
unsigned e=0;e<n_element;e++)
555 delete Traction_mesh_pt->element_pt(e);
559 Traction_mesh_pt->flush_element_and_node_storage();
568 template<
class ELEMENT>
580 sprintf(filename,
"%s/soln%i.dat",Doc_info.directory().c_str(),
582 some_file.open(filename);
583 solid_mesh_pt()->output(some_file,n_plot);
589 sprintf(filename,
"%s/exact_soln%i.dat",Doc_info.directory().c_str(),
591 some_file.open(filename);
596 Vector<double> s(el_dim);
597 Vector<double> x(el_dim);
598 Vector<double> xi(el_dim);
599 DenseMatrix<double> sigma(el_dim,el_dim);
609 unsigned nel=solid_mesh_pt()->nelement();
610 for (
unsigned e=0;e<nel;e++)
613 ELEMENT* el_pt=
dynamic_cast<ELEMENT*
>(
614 solid_mesh_pt()->element_pt(e));
617 some_file <<
"ZONE I=" << n_plot <<
", J=" << n_plot << std::endl;
620 for(
unsigned l2=0;l2<n_plot;l2++)
622 s[1] = -1.0 + l2*2.0/(n_plot-1);
623 for(
unsigned l1=0;l1<n_plot;l1++)
625 s[0] = -1.0 + l1*2.0/(n_plot-1);
628 el_pt->interpolated_x(s,x);
629 el_pt->interpolated_xi(s,xi);
632 for(
unsigned i=0;i<el_dim;i++)
633 {some_file << x[i] <<
" ";}
641 sigma(0,0)=c*(6.0*xx*xx*yy-4.0*yy*yy*yy)+
643 sigma(1,1)=2.0*(a+b*yy+c*yy*yy*yy);
644 sigma(1,0)=2.0*(b*xx+3.0*c*xx*yy*yy);
645 sigma(0,1)=sigma(1,0);
648 some_file << sigma(0,0) <<
" " 659 << Trace_node_pt->x(0) <<
" " 660 << Trace_node_pt->x(1) <<
" " 675 template<
class ELEMENT>
679 #ifdef TIME_SOLID_JAC 680 PVDEquationsBase<2>::Solid_timer.reset();
687 sprintf(dirname,
"RESLT_refine%i",i_case);
689 sprintf(dirname,
"RESLT_norefine%i",i_case);
692 Doc_info.set_directory(dirname);
696 sprintf(filename,
"%s/trace.dat",Doc_info.directory().c_str());
697 Trace_file.open(filename);
709 double p_increment=1.0e-5;
710 for(
unsigned i=0;i<nstep;i++)
721 unsigned max_adapt=1;
723 newton_solve(max_adapt);
736 #ifdef TIME_SOLID_JAC 738 std::cout <<
"Total fill_in... : " 739 << PVDEquationsBase<2>::Solid_timer.cumulative_time(0)
742 std::cout <<
"Total d_stress_dG: " 743 << PVDEquationsBase<2>::Solid_timer.cumulative_time(1)
746 std::cout <<
"Total Jac : " 747 << PVDEquationsBase<2>::Solid_timer.cumulative_time(2)
750 PVDEquationsBase<2>::Solid_timer.reset();
767 bool incompress=
false;
774 for (
unsigned i=0;i<2;i++)
790 problem(incompress,use_fd);
792 problem.
run_it(0+i*ncase);
798 problem(incompress,use_fd);
800 problem.
run_it(0+i*ncase);
809 RefineableQPVDElementWithContinuousPressure<2> > >
810 problem(incompress,use_fd);
812 problem.run_it(1+i*ncase);
818 QPVDElementWithContinuousPressure<2> > >
819 problem(incompress,use_fd);
821 problem.run_it(1+i*ncase);
830 RefineableQPVDElementWithPressure<2> > > problem(incompress,use_fd);
832 problem.run_it(2+i*ncase);
838 QPVDElementWithPressure<2> > > problem(incompress,use_fd);
840 problem.run_it(2+i*ncase);
859 new IsotropicStrainEnergyFunctionConstitutiveLaw(
869 RefineableQPVDElementWithContinuousPressure<2> > >
870 problem(incompress,use_fd);
872 problem.run_it(3+i*ncase);
878 QPVDElementWithContinuousPressure<2> > >
879 problem(incompress,use_fd);
881 problem.run_it(3+i*ncase);
891 RefineableQPVDElementWithPressure<2> > >
892 problem(incompress,use_fd);
894 problem.run_it(4+i*ncase);
900 QPVDElementWithPressure<2> > >
901 problem(incompress,use_fd);
903 problem.run_it(4+i*ncase);
916 std::cout <<
"\n\n\n CR Total fill_in... : bla \n\n\n " << std::endl;
ElasticRefineableRectangularQuadMesh< ELEMENT > *& solid_mesh_pt()
Access function for the solid mesh.
void delete_traction_elements()
Delete traction elements.
double Gravity
Non-dim gravity.
void set_traction_pt()
Pass pointer to traction function to the elements in the traction mesh.
Problem class for the cantilever "beam" structure.
ElasticRectangularQuadMesh< ELEMENT > * Solid_mesh_pt
Pointer to solid mesh.
ConstitutiveLaw * Constitutive_law_pt
Pointer to constitutive law.
double P
Uniform pressure.
MySolidElement()
Constructor: Call constructor of underlying element.
void actions_before_newton_solve()
Update function (empty)
void actions_after_adapt()
Actions after adapt: Rebuild the mesh of traction elements.
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...
void run_it(const unsigned &i_case)
Run the job – doc in RESLTi_case.
SolidMesh *& traction_mesh_pt()
Access function to the mesh of surface traction elements.
void output(std::ostream &outfile, const unsigned &n_plot)
Overload output function:
double H
Half height of beam.
void actions_after_newton_solve()
Update function (empty)
void doc_solution()
Doc the solution.
FaceGeometry()
Constructor [this was only required explicitly from gcc 4.5.2 onwards...].
double C1
"Mooney Rivlin" coefficient for generalised Mooney Rivlin law
StrainEnergyFunction * Strain_energy_function_pt
Pointer to strain energy function.
CantileverProblem()
Constructor:
double C2
"Mooney Rivlin" coefficient for generalised Mooney Rivlin law
ElasticRectangularQuadMesh< ELEMENT > *& solid_mesh_pt()
Access function for the solid mesh.
void actions_before_adapt()
Actions before adapt: Wipe the mesh of traction elements.
void create_traction_elements()
Create traction elements.
double Nu
Poisson's ratio.