34 #include "time_harmonic_fourier_decomposed_linear_elasticity.h" 37 #include "meshes/triangle_mesh.h" 41 using namespace oomph;
50 std::complex<double>
Nu(0.3,0.05);
53 std::complex<double>
E(1.0,0.01);
57 std::complex<double>
mu =
E/2.0/(1.0+
Nu);
64 std::complex<double>
Omega_sq (10.0,5.0);
79 const std::complex<double>
I(0.0,1.0);
83 const Vector<double> &n,
84 Vector<std::complex<double> > &result)
86 result[0] = -6.0*pow(x[0],2)*mu*cos(x[1])-
87 lambda*(
I*double(Fourier_wavenumber)*pow(x[0],2)*pow(x[1],3)+
88 (4.0*pow(x[0],2)+pow(x[0],3))*cos(x[1]));
89 result[1] = -mu*(3.0*pow(x[0],2)-pow(x[0],3))*sin(x[1]);
90 result[2] = -mu*pow(x[0],2)*(2*pow(x[1],3)+
I*double(Fourier_wavenumber)*
98 Vector<std::complex<double> > &result)
101 x[0]*(-2.0*
I*lambda*double(Fourier_wavenumber)*pow(x[1],3)-cos(x[1])*
102 (lambda*(8.0+3.0*x[0])-
103 mu*(pow(
double(Fourier_wavenumber),2)
104 -16.0+x[0]*(x[0]-3.0))+pow(x[0],2)*
Omega_sq));
106 x[0]*sin(x[1])*(mu*(pow(
double(Fourier_wavenumber),2)-9.0)+
107 4.0*x[0]*(lambda+
mu)+pow(x[0],2)*
109 3.0*
I*double(Fourier_wavenumber)*pow(x[0],2)*pow(x[1],2)*(lambda+
mu);
111 -x[0]*(8.0*mu*pow(x[1],3)-pow(
double(Fourier_wavenumber),2)*pow(x[1],3)*
112 (lambda+2.0*
mu)+pow(x[0],2)*(pow(x[1],3)*
Omega_sq+6.0*mu*x[1])+
113 I*cos(x[1])*double(Fourier_wavenumber)*
114 (lambda*(4.0+x[0])+mu*(6.0+x[0])));
122 u[0] = pow(x[0],3)*cos(x[1]);
123 u[1] = pow(x[0],3)*sin(x[1]);
124 u[2] = pow(x[0],3)*pow(x[1],3);
137 template<
class ELEMENT>
159 delete_traction_elements();
162 rebuild_global_mesh();
171 assign_traction_elements();
174 rebuild_global_mesh();
177 complete_problem_setup();
181 void doc_solution(DocInfo& doc_info);
186 void assign_traction_elements();
189 void delete_traction_elements();
192 void complete_problem_setup();
197 RefineableTriangleMesh<ELEMENT>* Bulk_mesh_pt;
207 Mesh* Surface_mesh_pt;
215 template<
class ELEMENT>
218 (
const double& rmin,
const double& rmax,
const double &zmin,
const double& zmax)
223 Vector<TriangleMeshCurveSection*> boundary_polyline_pt(4);
226 Vector<Vector<double> > bound_coords(2);
227 bound_coords[0].resize(2);
228 bound_coords[1].resize(2);
231 bound_coords[0][0]=
rmin;
232 bound_coords[0][1]=
zmin;
233 bound_coords[1][0]=
rmax;
234 bound_coords[1][1]=
zmin;
237 unsigned boundary_id=0;
238 boundary_polyline_pt[0]=
new TriangleMeshPolyLine(bound_coords,boundary_id);
241 bound_coords[0][0]=
rmax;
242 bound_coords[0][1]=
zmin;
243 bound_coords[1][0]=
rmax;
244 bound_coords[1][1]=
zmax;
248 boundary_polyline_pt[1]=
new TriangleMeshPolyLine(bound_coords,boundary_id);
252 bound_coords[0][0]=
rmax;
253 bound_coords[0][1]=
zmax;
254 bound_coords[1][0]=
rmin;
255 bound_coords[1][1]=
zmax;
259 boundary_polyline_pt[2]=
new TriangleMeshPolyLine(bound_coords,boundary_id);
262 bound_coords[0][0]=
rmin;
263 bound_coords[0][1]=
zmax;
264 bound_coords[1][0]=
rmin;
265 bound_coords[1][1]=
zmin;
269 boundary_polyline_pt[3]=
new TriangleMeshPolyLine(bound_coords,boundary_id);
272 TriangleMeshClosedCurve* closed_curve_pt=
273 new TriangleMeshPolygon(boundary_polyline_pt);
277 TriangleMeshParameters triangle_mesh_parameters(closed_curve_pt);
280 double uniform_element_area=0.2;
281 triangle_mesh_parameters.element_area() = uniform_element_area;
286 Bulk_mesh_pt=
new RefineableTriangleMesh<ELEMENT>(triangle_mesh_parameters);
289 Bulk_mesh_pt->spatial_error_estimator_pt()=
new Z2ErrorEstimator;
294 Bulk_mesh_pt=
new TriangleMesh<ELEMENT>(triangle_mesh_parameters);
299 Surface_mesh_pt=
new Mesh;
300 assign_traction_elements();
303 complete_problem_setup();
306 add_sub_mesh(Bulk_mesh_pt);
307 add_sub_mesh(Surface_mesh_pt);
313 cout << assign_eqn_numbers() <<
" equations assigned" << std::endl;
322 template<
class ELEMENT>
341 for (
unsigned ibound=0;ibound<=2;ibound++)
343 unsigned num_nod=Bulk_mesh_pt->nboundary_node(ibound);
344 for (
unsigned inod=0;inod<num_nod;inod++)
347 Node* nod_pt=Bulk_mesh_pt->boundary_node_pt(ibound,inod);
354 nod_pt->pin(0);nod_pt->pin(1);nod_pt->pin(2);
355 nod_pt->pin(3);nod_pt->pin(4);nod_pt->pin(5);
362 nod_pt->set_value(0,u[0]);
363 nod_pt->set_value(1,u[1]);
364 nod_pt->set_value(2,u[2]);
365 nod_pt->set_value(3,u[3]);
366 nod_pt->set_value(4,u[4]);
367 nod_pt->set_value(5,u[5]);
375 unsigned n_el = Bulk_mesh_pt->nelement();
376 for(
unsigned e=0;e<n_el;e++)
379 ELEMENT *el_pt =
dynamic_cast<ELEMENT*
>(Bulk_mesh_pt->element_pt(e));
399 unsigned n_traction = Surface_mesh_pt->nelement();
400 for(
unsigned e=0;e<n_traction;e++)
403 TimeHarmonicFourierDecomposedLinearElasticityTractionElement<ELEMENT>*
405 dynamic_cast<TimeHarmonicFourierDecomposedLinearElasticityTractionElement
406 <ELEMENT
>* >(Surface_mesh_pt->element_pt(e));
417 template<
class ELEMENT>
421 unsigned bound, n_neigh;
425 n_neigh = Bulk_mesh_pt->nboundary_element(bound);
428 for(
unsigned n=0;n<n_neigh;n++)
431 FiniteElement *traction_element_pt
432 =
new TimeHarmonicFourierDecomposedLinearElasticityTractionElement<ELEMENT>
433 (Bulk_mesh_pt->boundary_element_pt(bound,n),
434 Bulk_mesh_pt->face_index_at_boundary(bound,n));
437 Surface_mesh_pt->add_element_pt(traction_element_pt);
447 template<
class ELEMENT>
452 unsigned n_element = Surface_mesh_pt->nelement();
455 for(
unsigned e=0;e<n_element;e++)
458 delete Surface_mesh_pt->element_pt(e);
462 Surface_mesh_pt->flush_element_and_node_storage();
470 template<
class ELEMENT>
481 sprintf(filename,
"%s/soln.dat",doc_info.directory().c_str());
482 some_file.open(filename);
483 Bulk_mesh_pt->output(some_file,npts);
487 sprintf(filename,
"%s/exact_soln.dat",doc_info.directory().c_str());
488 some_file.open(filename);
489 Bulk_mesh_pt->output_fct(some_file,npts,
496 sprintf(filename,
"%s/error.dat",doc_info.directory().c_str());
497 some_file.open(filename);
498 Bulk_mesh_pt->compute_error(some_file,
504 cout <<
"\nNorm of error: " << sqrt(error) << std::endl;
505 cout <<
"Norm of solution: " << sqrt(norm) << std::endl << std::endl;
510 sprintf(filename,
"%s/norm.dat",doc_info.directory().c_str());
511 some_file.open(filename);
512 some_file << norm << std::endl;
521 int main(
int argc,
char* argv[])
528 doc_info.set_directory(
"RESLT");
534 <ProjectableTimeHarmonicFourierDecomposedLinearElasticityElement
535 <TTimeHarmonicFourierDecomposedLinearElasticityElement<3> > >
540 unsigned max_adapt=3;
541 problem.newton_solve(max_adapt);
547 <TTimeHarmonicFourierDecomposedLinearElasticityElement<3> >
552 problem.newton_solve();
558 problem.doc_solution(doc_info);
const std::complex< double > I(0.0, 1.0)
Define the imaginary unit.
void complete_problem_setup()
Helper function to complete problem setup.
void boundary_traction(const Vector< double > &x, const Vector< double > &n, Vector< std::complex< double > > &result)
The traction function at r=rmin: (t_r, t_z, t_theta)
std::complex< double > lambda
std::complex< double > Nu(0.3, 0.05)
Define Poisson's ratio Nu.
int Fourier_wavenumber
Define Fourier wavenumber.
void doc_solution(DocInfo &doc_info)
Doc the solution.
void delete_traction_elements()
Delete traction elements.
void actions_after_adapt()
Actions after adapt: Rebuild the mesh of traction elements.
FourierDecomposedTimeHarmonicLinearElasticityProblem(const unsigned &nr, const unsigned &nz, const double &rmin, const double &rmax, const double &zmin, const double &zmax)
Constructor: Pass number of elements in r and z directions and boundary locations.
void body_force(const Vector< double > &x, Vector< std::complex< double > > &result)
The body force function; returns vector of complex doubles in the order (b_r, b_z, b_theta)
void actions_before_newton_solve()
Update before solve is empty.
Namespace for global parameters.
std::complex< double > E(1.0, 0.01)
Define the non-dimensional Young's modulus.
double Lr
Length of domain in r direction.
double Lz
Length of domain in z-direction.
void exact_solution(const Vector< double > &x, Vector< double > &u)
The exact solution in a flat-packed vector:
std::complex< double > mu
void actions_after_newton_solve()
Update after solve is empty.
void assign_traction_elements()
Allocate traction elements on the bottom surface.
std::complex< double > Omega_sq(10.0, 5.0)
Define the non-dimensional square angular frequency of time-harmonic motion.
void actions_before_adapt()
Actions before adapt: Wipe the mesh of traction elements.
int main(int argc, char *argv[])
Driver code.