33 #include "constitutive.h"
37 #include "meshes/triangle_mesh.h"
40 using namespace oomph;
68 const Vector<double> &n, Vector<double> &traction)
70 unsigned dim = traction.size();
71 for(
unsigned i=0;i<dim;i++)
73 traction[i] = -
P*n[i];
84 template<
class ELEMENT>
100 void doc_solution(DocInfo& doc_info);
103 double get_strain_energy();
106 void actions_before_adapt();
109 void actions_after_adapt();
132 template<
class ELEMENT>
134 Incompressible(false)
140 Vector<TriangleMeshCurveSection*> boundary_segment_pt(4);
143 Vector<Vector<double> > bound_seg(2);
144 for(
unsigned i=0;i<2;i++) {bound_seg[i].resize(2);}
153 unsigned bound_id = 0;
156 boundary_segment_pt[0] =
new TriangleMeshPolyLine(bound_seg,bound_id);
168 boundary_segment_pt[1] =
new TriangleMeshPolyLine(bound_seg,bound_id);
180 boundary_segment_pt[2] =
new TriangleMeshPolyLine(bound_seg,bound_id);
192 boundary_segment_pt[3] =
new TriangleMeshPolyLine(bound_seg,bound_id);
205 double uniform_element_area=0.2;
211 TriangleMeshParameters triangle_mesh_parameters(
215 triangle_mesh_parameters.element_area() =
216 uniform_element_area;
220 new RefineableSolidTriangleMesh<ELEMENT>(
221 triangle_mesh_parameters);
229 Z2ErrorEstimator* error_estimator_pt=
new Z2ErrorEstimator;
230 Solid_mesh_pt->spatial_error_estimator_pt()=error_estimator_pt;
261 cout <<
"Number of equations: " << assign_eqn_numbers() << std::endl;
269 template<
class ELEMENT>
282 sprintf(filename,
"%s/soln%i.dat",doc_info.directory().c_str(),
284 some_file.open(filename);
285 Solid_mesh_pt->output(some_file,npts);
290 sprintf(filename,
"%s/traction%i.dat",doc_info.directory().c_str(),
292 some_file.open(filename);
293 Traction_mesh_pt->output(some_file,npts);
298 sprintf(filename,
"%s/boundaries.dat",doc_info.directory().c_str());
299 some_file.open(filename);
300 Solid_mesh_pt->output_boundaries(some_file);
308 template<
class ELEMENT>
311 double strain_energy=0.0;
312 const unsigned n_element = Solid_mesh_pt->nelement();
313 for(
unsigned e=0;e<n_element;e++)
316 ELEMENT *el_pt =
dynamic_cast<ELEMENT*
>(Solid_mesh_pt->element_pt(e));
318 double pot_en, kin_en;
319 el_pt->get_energy(pot_en,kin_en);
320 strain_energy += pot_en;
323 return strain_energy;
330 template<
class ELEMENT>
334 unsigned n_element = Traction_mesh_pt->nelement();
337 for(
unsigned e=0;e<n_element;e++) {
delete Traction_mesh_pt->element_pt(e);}
340 Traction_mesh_pt->flush_element_and_node_storage();
347 template<
class ELEMENT>
354 unsigned n_element = Solid_mesh_pt->nboundary_element(b);
356 for(
unsigned e=0;e<n_element;e++)
359 ELEMENT* bulk_elem_pt =
dynamic_cast<ELEMENT*
>(
360 Solid_mesh_pt->boundary_element_pt(b,e));
363 int face_index = Solid_mesh_pt->face_index_at_boundary(b,e);
366 SolidTractionElement<ELEMENT> *el_pt =
367 new SolidTractionElement<ELEMENT>(bulk_elem_pt,face_index);
370 Traction_mesh_pt->add_element_pt(el_pt);
377 this->rebuild_global_mesh();
382 unsigned num_nod= mesh_pt()->nboundary_node(ibound);
383 for (
unsigned inod=0;inod<num_nod;inod++)
386 SolidNode* nod_pt=Solid_mesh_pt->boundary_node_pt(ibound,inod);
389 for (
unsigned i=0;i<2;i++) {nod_pt->pin_position(i);}
394 n_element = Solid_mesh_pt->nelement();
395 for(
unsigned e=0;e<n_element;e++)
398 ELEMENT *el_pt =
dynamic_cast<ELEMENT*
>(Solid_mesh_pt->element_pt(e));
401 el_pt->constitutive_law_pt() =
408 dynamic_cast<TPVDElementWithContinuousPressure<2>*
>(el_pt)
409 ->set_incompressible();
419 int main(
int argc,
char **argv)
426 doc_info.set_directory(
"RESLT");
433 std::ofstream strain(
"RESLT/s_energy.dat");
434 std::cout <<
"Running with pure displacement formulation\n";
445 double pressure_increment=0.1e-2;
449 for (
unsigned istep=0;istep<nstep;istep++)
452 problem.newton_solve(1);
455 std::cout <<
"Strain energy is " << strain_energy <<
"\n";
464 if(istep==2) {pressure_increment *= -1.0;}
476 std::ofstream strain(
"RESLT_pres_disp/s_energy.dat");
477 std::cout <<
"Running with pressure/displacement formulation\n";
480 doc_info.set_directory(
"RESLT_pres_disp");
482 doc_info.number() = 0;
486 ProjectablePVDElementWithContinuousPressure<
487 TPVDElementWithContinuousPressure<2> > > problem;
495 double pressure_increment=0.1e-2;
498 for (
unsigned istep=0;istep<nstep;istep++)
501 problem.newton_solve(1);
503 double strain_energy = problem.get_strain_energy();
504 std::cout <<
"Strain energy is "<< strain_energy <<
"\n";
509 problem.doc_solution(doc_info);
512 if(istep==2) {pressure_increment *= -1.0;}
524 std::ofstream strain(
"RESLT_pres_disp_incomp/s_energy.dat");
526 "Running with pressure/displacement formulation (incompressible) \n";
529 doc_info.set_directory(
"RESLT_pres_disp_incomp");
531 doc_info.number() = 0;
535 ProjectablePVDElementWithContinuousPressure<
536 TPVDElementWithContinuousPressure<2> > > problem;
540 const unsigned n_element = problem.mesh_pt()->nelement();
541 for(
unsigned e=0;e<n_element;e++)
544 PVDEquationsWithPressure<2> *cast_el_pt =
545 dynamic_cast<PVDEquationsWithPressure<2>*
>(
546 problem.mesh_pt()->element_pt(e));
556 problem.set_incompressible();
559 problem.doc_solution(doc_info);
564 double pressure_increment=0.1e-2;
567 for (
unsigned istep=0;istep<nstep;istep++)
570 problem.newton_solve(1);
572 double strain_energy = problem.get_strain_energy();
573 std::cout <<
"Strain energy is " << strain_energy <<
"\n";
578 problem.doc_solution(doc_info);
581 if(istep==2) {pressure_increment *= -1.0;}
Unstructured solid problem.
UnstructuredSolidProblem()
Constructor:
~UnstructuredSolidProblem()
Destructor (empty)
TriangleMeshPolygon * Outer_boundary_polyline_pt
Triangle mesh polygon for outer boundary.
SolidMesh * Traction_mesh_pt
Pointer to mesh of traction elements.
void actions_before_adapt()
Remove Traction Mesh.
double get_strain_energy()
Calculate the strain energy.
bool Incompressible
Boolean flag used in an incompressible problem.
void set_incompressible()
Set the problem to be incompressible.
void doc_solution(DocInfo &doc_info)
Doc the solution.
void actions_after_adapt()
Add on the traction elements after adaptation.
RefineableSolidTriangleMesh< ELEMENT > * Solid_mesh_pt
Bulk mesh.
//////////////////////////////////////////////////////////////////// ////////////////////////////////...
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.
ConstitutiveLaw * Constitutive_law_pt
Pointer to constitutive law.
double Nu
Poisson's ratio.
int main(int argc, char **argv)
Demonstrate how to solve an unstructured solid problem.