31 #include "constitutive.h"
34 #include "meshes/rectangular_quadmesh.h"
38 using namespace oomph;
47 template <
class ELEMENT>
57 void output(std::ostream &outfile,
const unsigned &n_plot)
61 unsigned el_dim = this->dim();
63 Vector<double> s(el_dim);
64 Vector<double> x(el_dim);
65 DenseMatrix<double> sigma(el_dim,el_dim);
73 outfile <<
"ZONE I=" << n_plot <<
", J=" << n_plot << std::endl;
76 for(
unsigned l2=0;l2<n_plot;l2++)
78 s[1] = -1.0 + l2*2.0/(n_plot-1);
79 for(
unsigned l1=0;l1<n_plot;l1++)
81 s[0] = -1.0 + l1*2.0/(n_plot-1);
84 this->interpolated_x(s,x);
85 this->get_stress(s,sigma);
88 for(
unsigned i=0;i<el_dim;i++)
89 {outfile << x[i] <<
" ";}
92 outfile << sigma(0,0) <<
" "
103 std::ostringstream error_message;
104 error_message <<
"Output for dim !=2 not implemented" << std::endl;
105 throw OomphLibError(error_message.str(),
106 OOMPH_CURRENT_FUNCTION,
107 OOMPH_EXCEPTION_LOCATION);
119 template<
class ELEMENT>
121 public virtual FaceGeometry<ELEMENT>
175 const Vector<double> &n, Vector<double> &traction)
177 unsigned dim = traction.size();
178 for(
unsigned i=0;i<dim;i++)
180 traction[i] = -
P*n[i];
190 const Vector<double> &xi,
204 template<
class ELEMENT>
221 {
return Solid_mesh_pt;}
227 void actions_before_adapt();
230 void actions_after_adapt();
239 void set_traction_pt();
242 void create_traction_elements();
245 void delete_traction_elements();
268 template<
class ELEMENT>
287 Vector<double> origin(2);
292 solid_mesh_pt() =
new ElasticRefineableRectangularQuadMesh<ELEMENT>(
293 n_x,n_y,l_x,l_y,origin);
296 solid_mesh_pt()->spatial_error_estimator_pt()=
new Z2ErrorEstimator;
300 unsigned n_element =solid_mesh_pt()->nelement();
301 for(
unsigned i=0;i<n_element;i++)
304 ELEMENT *el_pt =
dynamic_cast<ELEMENT*
>(solid_mesh_pt()->element_pt(i));
307 el_pt->constitutive_law_pt() =
316 unsigned nnod=solid_mesh_pt()->nnode();
317 Trace_node_pt=solid_mesh_pt()->node_pt(nnod-1);
320 solid_mesh_pt()->refine_uniformly();
323 Traction_mesh_pt=
new SolidMesh;
324 create_traction_elements();
331 add_sub_mesh(solid_mesh_pt());
334 add_sub_mesh(traction_mesh_pt());
340 unsigned n_side = mesh_pt()->nboundary_node(3);
343 for(
unsigned i=0;i<n_side;i++)
345 solid_mesh_pt()->boundary_node_pt(3,i)->pin_position(0);
346 solid_mesh_pt()->boundary_node_pt(3,i)->pin_position(1);
350 PVDEquationsBase<2>::pin_redundant_nodal_solid_pressures(
351 solid_mesh_pt()->element_pt());
354 cout << assign_eqn_numbers() << std::endl;
357 Doc_info.set_directory(
"RESLT");
361 sprintf(filename,
"%s/trace.dat",Doc_info.directory().c_str());
362 Trace_file.open(filename);
371 template<
class ELEMENT>
375 delete_traction_elements();
378 rebuild_global_mesh();
387 template<
class ELEMENT>
392 create_traction_elements();
395 rebuild_global_mesh();
398 PVDEquationsBase<2>::pin_redundant_nodal_solid_pressures(
399 solid_mesh_pt()->element_pt());
412 template<
class ELEMENT>
417 unsigned n_element=traction_mesh_pt()->nelement();
418 for(
unsigned i=0;i<n_element;i++)
421 SolidTractionElement<ELEMENT> *el_pt =
422 dynamic_cast<SolidTractionElement<ELEMENT>*
>
423 (traction_mesh_pt()->element_pt(i));
436 template<
class ELEMENT>
443 unsigned n_element = solid_mesh_pt()->nboundary_element(b);
446 for(
unsigned e=0;e<n_element;e++)
449 ELEMENT* bulk_elem_pt =
dynamic_cast<ELEMENT*
>(
450 solid_mesh_pt()->boundary_element_pt(b,e));
453 int face_index = solid_mesh_pt()->face_index_at_boundary(b,e);
456 Traction_mesh_pt->add_element_pt(
new SolidTractionElement<ELEMENT>
457 (bulk_elem_pt,face_index));
471 template<
class ELEMENT>
475 unsigned n_element = Traction_mesh_pt->nelement();
478 for(
unsigned e=0;e<n_element;e++)
481 delete Traction_mesh_pt->element_pt(e);
485 Traction_mesh_pt->flush_element_and_node_storage();
494 template<
class ELEMENT>
506 sprintf(filename,
"%s/soln%i.dat",Doc_info.directory().c_str(),
508 some_file.open(filename);
509 solid_mesh_pt()->output(some_file,n_plot);
515 sprintf(filename,
"%s/exact_soln%i.dat",Doc_info.directory().c_str(),
517 some_file.open(filename);
522 Vector<double> s(el_dim);
523 Vector<double> x(el_dim);
524 Vector<double> xi(el_dim);
525 DenseMatrix<double> sigma(el_dim,el_dim);
535 unsigned nel=solid_mesh_pt()->nelement();
536 for (
unsigned e=0;e<nel;e++)
539 SolidFiniteElement* el_pt=
dynamic_cast<SolidFiniteElement*
>(
540 solid_mesh_pt()->element_pt(e));
543 some_file <<
"ZONE I=" << n_plot <<
", J=" << n_plot << std::endl;
546 for(
unsigned l2=0;l2<n_plot;l2++)
548 s[1] = -1.0 + l2*2.0/(n_plot-1);
549 for(
unsigned l1=0;l1<n_plot;l1++)
551 s[0] = -1.0 + l1*2.0/(n_plot-1);
554 el_pt->interpolated_x(s,x);
555 el_pt->interpolated_xi(s,xi);
558 for(
unsigned i=0;i<el_dim;i++)
559 {some_file << x[i] <<
" ";}
567 sigma(0,0)=c*(6.0*xx*xx*yy-4.0*yy*yy*yy)+
569 sigma(1,1)=2.0*(a+b*yy+c*yy*yy*yy);
570 sigma(1,0)=2.0*(b*xx+3.0*c*xx*yy*yy);
571 sigma(0,1)=sigma(1,0);
574 some_file << sigma(0,0) <<
" "
585 << Trace_node_pt->x(0) <<
" "
586 << Trace_node_pt->x(1) <<
" "
625 unsigned max_adapt=3;
629 double p_increment=1.0e-5;
630 for(
unsigned i=0;i<nstep;i++)
637 problem.newton_solve(max_adapt);
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
Pointer to solid mesh.
ElasticRefineableRectangularQuadMesh< ELEMENT > *& solid_mesh_pt()
Access function for the solid mesh.
void actions_before_newton_solve()
Update function (empty)
DocInfo Doc_info
DocInfo object for output.
void actions_after_newton_solve()
Update function (empty)
void actions_before_adapt()
Actions before adapt: Wipe the mesh of traction elements.
SolidMesh * Traction_mesh_pt
Pointer to mesh of traction elements.
void doc_solution()
Doc the solution.
Node * Trace_node_pt
Pointers to node whose position we're tracing.
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.
ofstream Trace_file
Trace file.
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.
double Gravity
Non-dim gravity.
double H
Half height of beam.