30 #include "linear_elasticity.h"
33 #include "meshes/rectangular_quadmesh.h"
37 using namespace oomph;
61 IsotropicElasticityTensor
E(
Nu);
67 u[0] = -
Amplitude*cos(2.0*MathematicalConstants::Pi*x[0]/
Lx)*
68 exp(2.0*MathematicalConstants::Pi*(x[1]-
Ly))/
69 (2.0/(1.0+
Nu)*MathematicalConstants::Pi);
70 u[1] = -
Amplitude*sin(2.0*MathematicalConstants::Pi*x[0]/
Lx)*
71 exp(2.0*MathematicalConstants::Pi*(x[1]-
Ly))/
72 (2.0/(1.0+
Nu)*MathematicalConstants::Pi);
77 const Vector<double> &x,
78 const Vector<double> &n,
79 Vector<double> &result)
81 result[0] = -
Amplitude*cos(2.0*MathematicalConstants::Pi*x[0]/
Lx);
82 result[1] = -
Amplitude*sin(2.0*MathematicalConstants::Pi*x[0]/
Lx);
90 template<
class ELEMENT>
98 const double &lx,
const double &ly);
110 delete_traction_elements();
113 rebuild_global_mesh();
120 assign_traction_elements();
123 rebuild_global_mesh();
127 void doc_solution(DocInfo& doc_info);
132 void assign_traction_elements();
138 unsigned n_element = Surface_mesh_pt->nelement();
141 for(
unsigned e=0;e<n_element;e++)
144 delete Surface_mesh_pt->element_pt(e);
148 Surface_mesh_pt->flush_element_and_node_storage();
164 template<
class ELEMENT>
166 (
const unsigned &nx,
const unsigned &ny,
167 const double &lx,
const double& ly)
170 Bulk_mesh_pt =
new RefineableRectangularQuadMesh<ELEMENT>(nx,ny,lx,ly);
173 Bulk_mesh_pt->spatial_error_estimator_pt()=
new Z2ErrorEstimator;
178 unsigned n_node = Bulk_mesh_pt->nboundary_node(1);
179 for(
unsigned n=0;n<n_node;n++)
181 Bulk_mesh_pt->boundary_node_pt(1,n)
182 ->make_periodic(Bulk_mesh_pt->boundary_node_pt(3,n));
191 Vector<TreeRoot*> left_root_pt(ny);
192 Vector<TreeRoot*> right_root_pt(ny);
193 for(
unsigned i=0;i<ny;i++)
196 dynamic_cast<ELEMENT*
>(Bulk_mesh_pt->element_pt(i*nx))->
197 tree_pt()->root_pt();
199 dynamic_cast<ELEMENT*
>(Bulk_mesh_pt->element_pt(nx-1+i*nx))->
200 tree_pt()->root_pt();
204 using namespace QuadTreeNames;
207 for(
unsigned i=0;i<ny;i++)
211 left_root_pt[i]->neighbour_pt(W) = right_root_pt[i];
212 left_root_pt[i]->set_neighbour_periodic(W);
216 right_root_pt[i]->neighbour_pt(
E) = left_root_pt[i];
217 right_root_pt[i]->set_neighbour_periodic(
E);
222 Surface_mesh_pt=
new Mesh;
223 assign_traction_elements();
229 unsigned num_nod=Bulk_mesh_pt->nboundary_node(ibound);
230 for (
unsigned inod=0;inod<num_nod;inod++)
233 Node* nod_pt=Bulk_mesh_pt->boundary_node_pt(ibound,inod);
243 nod_pt->set_value(0,0);
244 nod_pt->set_value(1,0);
258 nod_pt->set_value(0,u[0]);
259 nod_pt->set_value(1,u[1]);
266 unsigned n_el = Bulk_mesh_pt->nelement();
267 for(
unsigned e=0;e<n_el;e++)
270 ELEMENT *el_pt =
dynamic_cast<ELEMENT*
>(Bulk_mesh_pt->element_pt(e));
281 Vector<unsigned> refine_pattern(1,0);
282 Bulk_mesh_pt->refine_selected_elements(refine_pattern);
285 add_sub_mesh(Bulk_mesh_pt);
286 add_sub_mesh(Surface_mesh_pt);
292 cout << assign_eqn_numbers() <<
" equations assigned" << std::endl;
299 template<
class ELEMENT>
305 unsigned n_neigh = Bulk_mesh_pt->nboundary_element(bound);
308 for(
unsigned n=0;n<n_neigh;n++)
311 FiniteElement *traction_element_pt
312 =
new LinearElasticityTractionElement<ELEMENT>
313 (Bulk_mesh_pt->boundary_element_pt(bound,n),
314 Bulk_mesh_pt->face_index_at_boundary(bound,n));
317 Surface_mesh_pt->add_element_pt(traction_element_pt);
321 unsigned n_traction = Surface_mesh_pt->nelement();
322 for(
unsigned e=0;e<n_traction;e++)
325 LinearElasticityTractionElement<ELEMENT> *el_pt =
326 dynamic_cast<LinearElasticityTractionElement<ELEMENT>*
>
327 (Surface_mesh_pt->element_pt(e));
339 template<
class ELEMENT>
349 sprintf(filename,
"%s/soln.dat",doc_info.directory().c_str());
350 some_file.open(filename);
351 Bulk_mesh_pt->output(some_file,npts);
355 sprintf(filename,
"%s/exact_soln.dat",doc_info.directory().c_str());
356 some_file.open(filename);
357 Bulk_mesh_pt->output_fct(some_file,npts,
364 sprintf(filename,
"%s/error.dat",doc_info.directory().c_str());
365 some_file.open(filename);
366 Bulk_mesh_pt->compute_error(some_file,
372 cout <<
"\nNorm of error " << sqrt(error) << std::endl;
373 cout <<
"Norm of solution : " << sqrt(norm) << std::endl << std::endl;
383 int main(
int argc,
char* argv[])
395 doc_info.set_directory(
"RESLT");
402 unsigned max_adapt=4;
403 problem.newton_solve(max_adapt);
Periodic loading problem.
void assign_traction_elements()
Allocate traction elements on the top surface.
void delete_traction_elements()
Kill traction elements on the top surface.
void actions_after_newton_solve()
Update after solve is empty.
Mesh * Surface_mesh_pt
Pointer to the mesh of traction elements.
TreeBasedRefineableMeshBase * Bulk_mesh_pt
Pointer to the (refineable!) bulk mesh.
void actions_before_adapt()
Actions before adapt: Wipe the mesh of traction elements.
void doc_solution(DocInfo &doc_info)
Doc the solution.
void actions_after_adapt()
Actions after adapt: Rebuild the mesh of traction elements.
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.
Namespace for global parameters.
void periodic_traction(const double &time, const Vector< double > &x, const Vector< double > &n, Vector< double > &result)
The traction function.
double Amplitude
Amplitude of traction applied.
double Nu
Define Poisson coefficient Nu.
double Ly
Length of domain in y direction.
IsotropicElasticityTensor E(Nu)
The elasticity tensor.
bool Finite
Specify problem to be solved (boundary conditons for finite or infinite domain).
void exact_solution(const Vector< double > &x, Vector< double > &u)
The exact solution for infinite depth case.
double Lx
Length of domain in x direction.
int main(int argc, char *argv[])
Driver code for PeriodicLoad linearly elastic problem.