34 #include "linear_elasticity.h"    37 #include "meshes/rectangular_quadmesh.h"    41 using namespace oomph;
    65  IsotropicElasticityTensor 
E(Nu);
    71   u[0] = -Amplitude*cos(2.0*MathematicalConstants::Pi*x[0]/Lx)*
    72         exp(2.0*MathematicalConstants::Pi*(x[1]-Ly))/
    73         (2.0/(1.0+
Nu)*MathematicalConstants::Pi);
    74   u[1] = -Amplitude*sin(2.0*MathematicalConstants::Pi*x[0]/Lx)*
    75         exp(2.0*MathematicalConstants::Pi*(x[1]-Ly))/
    76         (2.0/(1.0+
Nu)*MathematicalConstants::Pi);
    81                        const Vector<double> &x,
    82                        const Vector<double> &n,
    83                        Vector<double> &result)
    85   result[0] = -Amplitude*cos(2.0*MathematicalConstants::Pi*x[0]/Lx);
    86   result[1] = -Amplitude*sin(2.0*MathematicalConstants::Pi*x[0]/Lx);
    94 template<
class ELEMENT>
   102                                const double &lx, 
const double &ly);
   114    delete_traction_elements();
   117    rebuild_global_mesh();
   124    assign_traction_elements();
   127    rebuild_global_mesh();
   131  void doc_solution(DocInfo& doc_info);
   136  void assign_traction_elements();
   142    unsigned n_element = Surface_mesh_pt->nelement();
   145    for(
unsigned e=0;e<n_element;e++)
   148      delete Surface_mesh_pt->element_pt(e);
   152    Surface_mesh_pt->flush_element_and_node_storage();
   168 template<
class ELEMENT>
   170 (
const unsigned &nx, 
const unsigned &ny,
   171  const double &lx, 
const double& ly)
   174  Bulk_mesh_pt = 
new RefineableRectangularQuadMesh<ELEMENT>(nx,ny,lx,ly);
   177  Bulk_mesh_pt->spatial_error_estimator_pt()=
new Z2ErrorEstimator;
   182  unsigned n_node = Bulk_mesh_pt->nboundary_node(1);
   183  for(
unsigned n=0;n<n_node;n++)
   185    Bulk_mesh_pt->boundary_node_pt(1,n)
   186     ->make_periodic(Bulk_mesh_pt->boundary_node_pt(3,n));
   195   Vector<TreeRoot*> left_root_pt(ny);
   196   Vector<TreeRoot*> right_root_pt(ny);
   197   for(
unsigned i=0;i<ny;i++) 
   200      dynamic_cast<ELEMENT*
>(Bulk_mesh_pt->element_pt(i*nx))->
   201      tree_pt()->root_pt();
   203      dynamic_cast<ELEMENT*
>(Bulk_mesh_pt->element_pt(nx-1+i*nx))->
   204      tree_pt()->root_pt();
   208    using namespace QuadTreeNames;
   211   for(
unsigned i=0;i<ny;i++) 
   215     left_root_pt[i]->neighbour_pt(W) = right_root_pt[i];
   216     left_root_pt[i]->set_neighbour_periodic(W); 
   220     right_root_pt[i]->neighbour_pt(
E) = left_root_pt[i];
   221     right_root_pt[i]->set_neighbour_periodic(
E);     
   226  Surface_mesh_pt=
new Mesh;
   227  assign_traction_elements();
   233  unsigned num_nod=Bulk_mesh_pt->nboundary_node(ibound);
   234  for (
unsigned inod=0;inod<num_nod;inod++)
   237    Node* nod_pt=Bulk_mesh_pt->boundary_node_pt(ibound,inod);
   247       nod_pt->set_value(0,0);
   248       nod_pt->set_value(1,0);
   262       nod_pt->set_value(0,u[0]);
   263       nod_pt->set_value(1,u[1]);
   270  unsigned n_el = Bulk_mesh_pt->nelement();
   271  for(
unsigned e=0;e<n_el;e++)
   274    ELEMENT *el_pt = 
dynamic_cast<ELEMENT*
>(Bulk_mesh_pt->element_pt(e));
   285  Vector<unsigned> refine_pattern(1,0);
   286  Bulk_mesh_pt->refine_selected_elements(refine_pattern);
   289  add_sub_mesh(Bulk_mesh_pt);
   290  add_sub_mesh(Surface_mesh_pt);
   296  cout << assign_eqn_numbers() << 
" equations assigned" << std::endl; 
   303 template<
class ELEMENT>
   309  unsigned n_neigh = Bulk_mesh_pt->nboundary_element(bound); 
   312  for(
unsigned n=0;n<n_neigh;n++)
   315    FiniteElement *traction_element_pt 
   316     = 
new LinearElasticityTractionElement<ELEMENT>
   317     (Bulk_mesh_pt->boundary_element_pt(bound,n),
   318      Bulk_mesh_pt->face_index_at_boundary(bound,n));
   321    Surface_mesh_pt->add_element_pt(traction_element_pt);
   325  unsigned n_traction =  Surface_mesh_pt->nelement();
   326  for(
unsigned e=0;e<n_traction;e++)
   329    LinearElasticityTractionElement<ELEMENT> *el_pt = 
   330     dynamic_cast<LinearElasticityTractionElement<ELEMENT>* 
>   331     (Surface_mesh_pt->element_pt(e));
   343 template<
class ELEMENT>
   353  sprintf(filename,
"%s/soln.dat",doc_info.directory().c_str());
   354  some_file.open(filename);
   355  Bulk_mesh_pt->output(some_file,npts);
   359  sprintf(filename,
"%s/exact_soln.dat",doc_info.directory().c_str());
   360  some_file.open(filename);
   361  Bulk_mesh_pt->output_fct(some_file,npts,
   368  sprintf(filename,
"%s/error.dat",doc_info.directory().c_str());
   369  some_file.open(filename);
   370  Bulk_mesh_pt->compute_error(some_file,
   376  cout << 
"\nNorm of error    " << sqrt(error) << std::endl; 
   377  cout << 
"Norm of solution : " << sqrt(norm) << std::endl << std::endl;
   387 int main(
int argc, 
char* argv[]) 
   399  doc_info.set_directory(
"RESLT");
   406  unsigned max_adapt=4; 
   407  problem.newton_solve(max_adapt);
 void actions_after_newton_solve()
Update after solve is empty. 
void actions_before_adapt()
Actions before adapt: Wipe the mesh of traction elements. 
Periodic loading problem. 
RefineablePeriodicLoadProblem(const unsigned &nx, const unsigned &ny, const double &lx, const double &ly)
Constructor: Pass number of elements in x and y directions and lengths. 
void actions_before_newton_solve()
Update before solve is empty. 
bool Finite
Specify problem to be solved (boundary conditons for finite or infinite domain). 
void assign_traction_elements()
Allocate traction elements on the top surface. 
double Lx
Length of domain in x direction. 
void actions_after_adapt()
Actions after adapt: Rebuild the mesh of traction elements. 
TreeBasedRefineableMeshBase * Bulk_mesh_pt
Pointer to the (refineable!) bulk mesh. 
void periodic_traction(const double &time, const Vector< double > &x, const Vector< double > &n, Vector< double > &result)
The traction function. 
Namespace for global parameters. 
Mesh * Surface_mesh_pt
Pointer to the mesh of traction elements. 
int main(int argc, char *argv[])
Driver code for PeriodicLoad linearly elastic problem. 
void doc_solution(DocInfo &doc_info)
Doc the solution. 
double Amplitude
Amplitude of traction applied. 
double Nu
Define Poisson coefficient Nu. 
void exact_solution(const Vector< double > &x, Vector< double > &u)
The exact solution for infinite depth case. 
void delete_traction_elements()
Kill traction elements on the top surface. 
IsotropicElasticityTensor E(Nu)
The elasticity tensor. 
double Ly
Length of domain in y direction.