35 #include "constitutive.h" 38 #include "meshes/rectangular_quadmesh.h" 42 using namespace oomph;
51 template <
class ELEMENT>
61 void output(std::ostream &outfile,
const unsigned &n_plot)
65 unsigned el_dim = this->dim();
67 Vector<double> s(el_dim);
68 Vector<double> x(el_dim);
69 DenseMatrix<double> sigma(el_dim,el_dim);
77 outfile <<
"ZONE I=" << n_plot <<
", J=" << n_plot << std::endl;
80 for(
unsigned l2=0;l2<n_plot;l2++)
82 s[1] = -1.0 + l2*2.0/(n_plot-1);
83 for(
unsigned l1=0;l1<n_plot;l1++)
85 s[0] = -1.0 + l1*2.0/(n_plot-1);
88 this->interpolated_x(s,x);
89 this->get_stress(s,sigma);
92 for(
unsigned i=0;i<el_dim;i++)
93 {outfile << x[i] <<
" ";}
96 outfile << sigma(0,0) <<
" " 107 std::ostringstream error_message;
108 error_message <<
"Output for dim !=2 not implemented" << std::endl;
109 throw OomphLibError(error_message.str(),
110 OOMPH_CURRENT_FUNCTION,
111 OOMPH_EXCEPTION_LOCATION);
123 template<
class ELEMENT>
125 public virtual FaceGeometry<ELEMENT>
179 const Vector<double> &n, Vector<double> &traction)
181 unsigned dim = traction.size();
182 for(
unsigned i=0;i<dim;i++)
184 traction[i] = -P*n[i];
194 const Vector<double> &xi,
208 template<
class ELEMENT>
225 {
return Solid_mesh_pt;}
231 void actions_before_adapt();
234 void actions_after_adapt();
243 void set_traction_pt();
246 void create_traction_elements();
249 void delete_traction_elements();
272 template<
class ELEMENT>
291 Vector<double> origin(2);
296 solid_mesh_pt() =
new ElasticRefineableRectangularQuadMesh<ELEMENT>(
297 n_x,n_y,l_x,l_y,origin);
300 solid_mesh_pt()->spatial_error_estimator_pt()=
new Z2ErrorEstimator;
304 unsigned n_element =solid_mesh_pt()->nelement();
305 for(
unsigned i=0;i<n_element;i++)
308 ELEMENT *el_pt =
dynamic_cast<ELEMENT*
>(solid_mesh_pt()->element_pt(i));
311 el_pt->constitutive_law_pt() =
320 unsigned nnod=solid_mesh_pt()->nnode();
321 Trace_node_pt=solid_mesh_pt()->node_pt(nnod-1);
324 solid_mesh_pt()->refine_uniformly();
327 Traction_mesh_pt=
new SolidMesh;
328 create_traction_elements();
335 add_sub_mesh(solid_mesh_pt());
338 add_sub_mesh(traction_mesh_pt());
344 unsigned n_side = mesh_pt()->nboundary_node(3);
347 for(
unsigned i=0;i<n_side;i++)
349 solid_mesh_pt()->boundary_node_pt(3,i)->pin_position(0);
350 solid_mesh_pt()->boundary_node_pt(3,i)->pin_position(1);
354 PVDEquationsBase<2>::pin_redundant_nodal_solid_pressures(
355 solid_mesh_pt()->element_pt());
358 cout << assign_eqn_numbers() << std::endl;
361 Doc_info.set_directory(
"RESLT");
365 sprintf(filename,
"%s/trace.dat",Doc_info.directory().c_str());
366 Trace_file.open(filename);
375 template<
class ELEMENT>
379 delete_traction_elements();
382 rebuild_global_mesh();
391 template<
class ELEMENT>
396 create_traction_elements();
399 rebuild_global_mesh();
402 PVDEquationsBase<2>::pin_redundant_nodal_solid_pressures(
403 solid_mesh_pt()->element_pt());
416 template<
class ELEMENT>
421 unsigned n_element=traction_mesh_pt()->nelement();
422 for(
unsigned i=0;i<n_element;i++)
425 SolidTractionElement<ELEMENT> *el_pt =
426 dynamic_cast<SolidTractionElement<ELEMENT>*
> 427 (traction_mesh_pt()->element_pt(i));
440 template<
class ELEMENT>
447 unsigned n_element = solid_mesh_pt()->nboundary_element(b);
450 for(
unsigned e=0;e<n_element;e++)
453 ELEMENT* bulk_elem_pt =
dynamic_cast<ELEMENT*
>(
454 solid_mesh_pt()->boundary_element_pt(b,e));
457 int face_index = solid_mesh_pt()->face_index_at_boundary(b,e);
460 Traction_mesh_pt->add_element_pt(
new SolidTractionElement<ELEMENT>
461 (bulk_elem_pt,face_index));
475 template<
class ELEMENT>
479 unsigned n_element = Traction_mesh_pt->nelement();
482 for(
unsigned e=0;e<n_element;e++)
485 delete Traction_mesh_pt->element_pt(e);
489 Traction_mesh_pt->flush_element_and_node_storage();
498 template<
class ELEMENT>
510 sprintf(filename,
"%s/soln%i.dat",Doc_info.directory().c_str(),
512 some_file.open(filename);
513 solid_mesh_pt()->output(some_file,n_plot);
519 sprintf(filename,
"%s/exact_soln%i.dat",Doc_info.directory().c_str(),
521 some_file.open(filename);
526 Vector<double> s(el_dim);
527 Vector<double> x(el_dim);
528 Vector<double> xi(el_dim);
529 DenseMatrix<double> sigma(el_dim,el_dim);
539 unsigned nel=solid_mesh_pt()->nelement();
540 for (
unsigned e=0;e<nel;e++)
543 SolidFiniteElement* el_pt=
dynamic_cast<SolidFiniteElement*
>(
544 solid_mesh_pt()->element_pt(e));
547 some_file <<
"ZONE I=" << n_plot <<
", J=" << n_plot << std::endl;
550 for(
unsigned l2=0;l2<n_plot;l2++)
552 s[1] = -1.0 + l2*2.0/(n_plot-1);
553 for(
unsigned l1=0;l1<n_plot;l1++)
555 s[0] = -1.0 + l1*2.0/(n_plot-1);
558 el_pt->interpolated_x(s,x);
559 el_pt->interpolated_xi(s,xi);
562 for(
unsigned i=0;i<el_dim;i++)
563 {some_file << x[i] <<
" ";}
571 sigma(0,0)=c*(6.0*xx*xx*yy-4.0*yy*yy*yy)+
573 sigma(1,1)=2.0*(a+b*yy+c*yy*yy*yy);
574 sigma(1,0)=2.0*(b*xx+3.0*c*xx*yy*yy);
575 sigma(0,1)=sigma(1,0);
578 some_file << sigma(0,0) <<
" " 589 << Trace_node_pt->x(0) <<
" " 590 << Trace_node_pt->x(1) <<
" " 629 unsigned max_adapt=3;
633 double p_increment=1.0e-5;
634 for(
unsigned i=0;i<nstep;i++)
641 problem.newton_solve(max_adapt);
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.
ConstitutiveLaw * Constitutive_law_pt
Pointer to constitutive law.
SolidMesh * Traction_mesh_pt
Pointer to mesh of traction elements.
double P
Uniform pressure.
MySolidElement()
Constructor: Call constructor of underlying element.
void actions_before_newton_solve()
Update function (empty)
ElasticRefineableRectangularQuadMesh< ELEMENT > * Solid_mesh_pt
Pointer to solid mesh.
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...
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)
ofstream Trace_file
Trace file.
void doc_solution()
Doc the solution.
FaceGeometry()
Constructor [this was only required explicitly from gcc 4.5.2 onwards...].
Node * Trace_node_pt
Pointers to node whose position we're tracing.
CantileverProblem()
Constructor:
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.
DocInfo Doc_info
DocInfo object for output.