adaptive_unstructured_two_d_solid.cc File Reference
#include "generic.h"
#include "solid.h"
#include "constitutive.h"
#include "meshes/triangle_mesh.h"
#include "meshes/quad_from_triangle_mesh.h"

Classes

class  MyMesh< ELEMENT >
 Triangle-based mesh upgraded to become a solid mesh. More...
 
class  UnstructuredSolidProblem< ELEMENT, MESH >
 Unstructured solid problem. More...
 

Namespaces

 Global_Physical_Variables
 Global variables.
 

Functions

void Global_Physical_Variables::constant_pressure (const Vector< double > &xi, const Vector< double > &x, const Vector< double > &n, Vector< double > &traction)
 Constant pressure load. More...
 
int main (int argc, char **argv)
 Demonstrate how to solve an unstructured solid problem. More...
 

Function Documentation

◆ main()

int main ( int argc  ,
char **  argv 
)

Demonstrate how to solve an unstructured solid problem.

462 {
463  // Store command line arguments
464  CommandLineArgs::setup(argc,argv);
465 
466  // Define case to be run
467  unsigned i_case=0;
469 
470  // Parse command line
472 
473  // Doc what has actually been specified on the command line
475 
476  // Number of adaptations
477  unsigned max_adapt=2;
478 
479  // Number of steps
480  unsigned nstep=3;
481 
482  // Create generalised Hookean constitutive equations
485 
486  // Open an output file for the strain data
487  std::ofstream strain("RESLT/s_energy.dat");
488 
489  if (i_case==0)
490  {
491  std::cout << "Running with pure displacement formulation\n";
492 
493  typedef RefineableQPVDElement<2,3> ELEMENT;
494  typedef MyMesh<ELEMENT> MESH;
495 
496  // Set up the problem
498 
499  // Output initial configuration
500  problem.doc_solution();
501 
502  // Parameter study
504  double pressure_increment=0.1e-2;
505 
506  for (unsigned istep=0;istep<nstep;istep++)
507  {
508  // Solve the problem with one round of adaptivity
509  problem.newton_solve(max_adapt);
510 
511  double strain_energy = problem.get_strain_energy();
512  std::cout << "Strain energy is " << strain_energy << "\n";
513 
514  // Output strain energy to file
515  strain << Global_Physical_Variables::P << " " << strain_energy << std::endl;
516 
517  // Output solution
518  problem.doc_solution();
519 
520  // On the 3rd run
521  if (istep==2)
522  {
523  pressure_increment*=-1.0;
524  }
525 
526  // Increase (or decrease) load
527  Global_Physical_Variables::P+=pressure_increment;
528  }
529 
530  strain.close();
531  } //end_displacement_formulation
532  else if (i_case==1)
533  // Repeat for displacement/pressure formulation
534  {
535  std::cout << "Running with pressure/displacement formulation\n";
536 
538  typedef MyMesh<ELEMENT> MESH;
539 
540  // Set up the problem
542 
543  // Output initial configuration
544  problem.doc_solution();
545 
546  // Parameter study
548  double pressure_increment=0.1e-2;
549 
550  // Loop over the steps
551  for (unsigned istep=0;istep<nstep;istep++)
552  {
553  // Solve the problem
554  problem.newton_solve(max_adapt);
555 
556  double strain_energy = problem.get_strain_energy();
557  std::cout << "Strain energy is "<< strain_energy << "\n";
558 
559  // Output strain energy to file
560  strain << Global_Physical_Variables::P << " " << strain_energy << std::endl;
561 
562  // Output solution
563  problem.doc_solution();
564 
565  // On the 3rd run
566  if (istep==2)
567  {
568  pressure_increment *= -1.0;
569  }
570 
571  // Increase (or decrease) pressure load
572  Global_Physical_Variables::P+=pressure_increment;
573  }
574 
575  strain.close();
576  }
577  else if (i_case==2)
578  // Repeat for displacement/pressure formulation enforcing incompressibility
579  {
580  std::cout << "Running with pressure/displacement "
581  << "formulation (incompressible) " << std::endl;
582 
584  typedef MyMesh<ELEMENT> MESH;
585 
586  // Set up the problem
588 
589  // Loop over all elements and set incompressibility flag
590  {
591  const unsigned n_element = problem.mesh_pt()->nelement();
592  for(unsigned e=0;e<n_element;e++)
593  {
594  // Cast the element to the equation base of our 2D elasticity elements
595  PVDEquationsWithPressure<2> *cast_el_pt =
596  dynamic_cast<PVDEquationsWithPressure<2>*>(
597  problem.mesh_pt()->element_pt(e));
598 
599  // If the cast was successful, it's a bulk element,
600  // so set the incompressibilty flag
601  if (cast_el_pt)
602  {
603  cast_el_pt->set_incompressible();
604  }
605  }
606  }
607 
608  // Turn on the incompressibity flag so that elements stay incompressible
609  // after refinement
610  problem.set_incompressible();
611 
612  // Output initial configuration
613  problem.doc_solution();
614 
615  // Parameter study
617  double pressure_increment=0.1e-2;
618 
619  for (unsigned istep=0;istep<nstep;istep++)
620  {
621  // Solve the problem
622  problem.newton_solve(max_adapt);
623 
624  double strain_energy=problem.get_strain_energy();
625  std::cout << "Strain energy is " << strain_energy << "\n";
626 
627  // Output strain energy to file
628  strain << Global_Physical_Variables::P << " " << strain_energy << std::endl;
629 
630  // Output solution
631  problem.doc_solution();
632 
633  // On the 3rd run
634  if (istep==2)
635  {
636  pressure_increment *= -1.0;
637  }
638 
639  // Increase (or decrease) pressure load
640  Global_Physical_Variables::P+=pressure_increment;
641  }
642 
643  strain.close();
644  }
645 
646 } // end main
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Triangle-based mesh upgraded to become a solid mesh.
Definition: adaptive_unstructured_two_d_solid.cc:54
Unstructured solid problem.
Definition: adaptive_unstructured_two_d_solid.cc:117
Definition: constitutive_laws.h:699
Definition: solid_elements.h:863
void set_incompressible()
Set the material to be incompressible.
Definition: solid_elements.h:881
Definition: refineable_solid_elements.h:826
Class for refineable QPVDElement elements.
Definition: refineable_solid_elements.h:181
void setup(Time *time_pt)
Create all GeomObjects needed to define the cylinder and the flag.
Definition: turek_flag_non_fsi.cc:277
double P
Uniform pressure.
Definition: TwenteMeshGluing.cpp:77
double Nu
Poisson's ratio.
Definition: TwenteMeshGluing.cpp:71
ConstitutiveLaw * Constitutive_law_pt
Pointer to constitutive law.
Definition: TwenteMeshGluing.cpp:65
void specify_command_line_flag(const std::string &command_line_flag, const std::string &doc)
Specify possible argument-free command line flag.
Definition: oomph_utilities.cc:451
void parse_and_assign(int argc, char *argv[], const bool &throw_on_unrecognised_args)
Definition: oomph_utilities.cc:760
void doc_specified_flags()
Document specified command line flags.
Definition: oomph_utilities.cc:610
Constructor for SteadyAxisymAdvectionDiffusion problem
Definition: steady_axisym_advection_diffusion.cc:213

References Global_Physical_Variables::Constitutive_law_pt, oomph::CommandLineArgs::doc_specified_flags(), e(), Global_Physical_Variables::Nu, Global_Physical_Variables::P, oomph::CommandLineArgs::parse_and_assign(), problem, oomph::PVDEquationsWithPressure< DIM >::set_incompressible(), Flag_definition::setup(), and oomph::CommandLineArgs::specify_command_line_flag().