37 #include "constitutive.h" 41 #include "meshes/triangle_mesh.h" 44 using namespace oomph;
72 const Vector<double> &n, Vector<double> &traction)
74 unsigned dim = traction.size();
75 for(
unsigned i=0;i<dim;i++)
77 traction[i] = -P*n[i];
88 template<
class ELEMENT>
104 void doc_solution(DocInfo& doc_info);
107 double get_strain_energy();
110 void actions_before_adapt();
113 void actions_after_adapt();
136 template<
class ELEMENT>
138 Incompressible(false)
144 Vector<TriangleMeshCurveSection*> boundary_segment_pt(4);
147 Vector<Vector<double> > bound_seg(2);
148 for(
unsigned i=0;i<2;i++) {bound_seg[i].resize(2);}
157 unsigned bound_id = 0;
160 boundary_segment_pt[0] =
new TriangleMeshPolyLine(bound_seg,bound_id);
172 boundary_segment_pt[1] =
new TriangleMeshPolyLine(bound_seg,bound_id);
184 boundary_segment_pt[2] =
new TriangleMeshPolyLine(bound_seg,bound_id);
196 boundary_segment_pt[3] =
new TriangleMeshPolyLine(bound_seg,bound_id);
209 double uniform_element_area=0.2;
215 TriangleMeshParameters triangle_mesh_parameters(
219 triangle_mesh_parameters.element_area() =
220 uniform_element_area;
224 new RefineableSolidTriangleMesh<ELEMENT>(
225 triangle_mesh_parameters);
233 Z2ErrorEstimator* error_estimator_pt=
new Z2ErrorEstimator;
234 Solid_mesh_pt->spatial_error_estimator_pt()=error_estimator_pt;
265 cout <<
"Number of equations: " << assign_eqn_numbers() << std::endl;
273 template<
class ELEMENT>
286 sprintf(filename,
"%s/soln%i.dat",doc_info.directory().c_str(),
288 some_file.open(filename);
294 sprintf(filename,
"%s/traction%i.dat",doc_info.directory().c_str(),
296 some_file.open(filename);
302 sprintf(filename,
"%s/boundaries.dat",doc_info.directory().c_str());
303 some_file.open(filename);
312 template<
class ELEMENT>
315 double strain_energy=0.0;
317 for(
unsigned e=0;e<n_element;e++)
320 ELEMENT *el_pt =
dynamic_cast<ELEMENT*
>(
Solid_mesh_pt->element_pt(e));
322 double pot_en, kin_en;
323 el_pt->get_energy(pot_en,kin_en);
324 strain_energy += pot_en;
327 return strain_energy;
334 template<
class ELEMENT>
351 template<
class ELEMENT>
360 for(
unsigned e=0;e<n_element;e++)
363 ELEMENT* bulk_elem_pt =
dynamic_cast<ELEMENT*
>(
370 SolidTractionElement<ELEMENT> *el_pt =
371 new SolidTractionElement<ELEMENT>(bulk_elem_pt,face_index);
381 this->rebuild_global_mesh();
386 unsigned num_nod= mesh_pt()->nboundary_node(ibound);
387 for (
unsigned inod=0;inod<num_nod;inod++)
390 SolidNode* nod_pt=
Solid_mesh_pt->boundary_node_pt(ibound,inod);
393 for (
unsigned i=0;i<2;i++) {nod_pt->pin_position(i);}
399 for(
unsigned e=0;e<n_element;e++)
402 ELEMENT *el_pt =
dynamic_cast<ELEMENT*
>(
Solid_mesh_pt->element_pt(e));
405 el_pt->constitutive_law_pt() =
412 dynamic_cast<TPVDElementWithContinuousPressure<2>*
>(el_pt)
423 int main(
int argc,
char **argv)
430 doc_info.set_directory(
"RESLT");
437 std::ofstream strain(
"RESLT/s_energy.dat");
438 std::cout <<
"Running with pure displacement formulation\n";
449 double pressure_increment=0.1e-2;
453 for (
unsigned istep=0;istep<nstep;istep++)
456 problem.newton_solve(1);
459 std::cout <<
"Strain energy is " << strain_energy <<
"\n";
468 if(istep==2) {pressure_increment *= -1.0;}
480 std::ofstream strain(
"RESLT_pres_disp/s_energy.dat");
481 std::cout <<
"Running with pressure/displacement formulation\n";
484 doc_info.set_directory(
"RESLT_pres_disp");
486 doc_info.number() = 0;
490 ProjectablePVDElementWithContinuousPressure<
491 TPVDElementWithContinuousPressure<2> > > problem;
499 double pressure_increment=0.1e-2;
502 for (
unsigned istep=0;istep<nstep;istep++)
505 problem.newton_solve(1);
507 double strain_energy = problem.get_strain_energy();
508 std::cout <<
"Strain energy is "<< strain_energy <<
"\n";
513 problem.doc_solution(doc_info);
516 if(istep==2) {pressure_increment *= -1.0;}
528 std::ofstream strain(
"RESLT_pres_disp_incomp/s_energy.dat");
530 "Running with pressure/displacement formulation (incompressible) \n";
533 doc_info.set_directory(
"RESLT_pres_disp_incomp");
535 doc_info.number() = 0;
539 ProjectablePVDElementWithContinuousPressure<
540 TPVDElementWithContinuousPressure<2> > > problem;
544 const unsigned n_element = problem.mesh_pt()->nelement();
545 for(
unsigned e=0;e<n_element;e++)
548 PVDEquationsWithPressure<2> *cast_el_pt =
549 dynamic_cast<PVDEquationsWithPressure<2>*
>(
550 problem.mesh_pt()->element_pt(e));
560 problem.set_incompressible();
563 problem.doc_solution(doc_info);
568 double pressure_increment=0.1e-2;
571 for (
unsigned istep=0;istep<nstep;istep++)
574 problem.newton_solve(1);
576 double strain_energy = problem.get_strain_energy();
577 std::cout <<
"Strain energy is " << strain_energy <<
"\n";
582 problem.doc_solution(doc_info);
585 if(istep==2) {pressure_increment *= -1.0;}
void set_incompressible()
Set the problem to be incompressible.
int main(int argc, char **argv)
Demonstrate how to solve an unstructured solid problem.
void doc_solution(DocInfo &doc_info)
Doc the solution.
Unstructured solid problem.
void actions_before_adapt()
Remove Traction Mesh.
bool Incompressible
Boolean flag used in an incompressible problem.
SolidMesh * Traction_mesh_pt
Pointer to mesh of traction elements.
UnstructuredSolidProblem()
Constructor:
double P
Uniform pressure.
ConstitutiveLaw * Constitutive_law_pt
Pointer to constitutive law.
void actions_after_adapt()
Add on the traction elements after adaptation.
double get_strain_energy()
Calculate the strain energy.
TriangleMeshPolygon * Outer_boundary_polyline_pt
Triangle mesh polygon for outer boundary.
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...
RefineableSolidTriangleMesh< ELEMENT > * Solid_mesh_pt
Bulk mesh.
~UnstructuredSolidProblem()
Destructor (empty)
double Nu
Poisson's ratio.