30 #include "time_harmonic_fourier_decomposed_linear_elasticity.h"
33 #include "meshes/triangle_mesh.h"
37 using namespace oomph;
46 std::complex<double>
Nu(0.3,0.05);
49 std::complex<double>
E(1.0,0.01);
53 std::complex<double>
mu =
E/2.0/(1.0+
Nu);
60 std::complex<double>
Omega_sq (10.0,5.0);
75 const std::complex<double>
I(0.0,1.0);
79 const Vector<double> &n,
80 Vector<std::complex<double> > &result)
82 result[0] = -6.0*pow(x[0],2)*
mu*cos(x[1])-
84 (4.0*pow(x[0],2)+pow(x[0],3))*cos(x[1]));
85 result[1] = -
mu*(3.0*pow(x[0],2)-pow(x[0],3))*sin(x[1]);
94 Vector<std::complex<double> > &result)
100 -16.0+x[0]*(x[0]-3.0))+pow(x[0],2)*
Omega_sq));
118 u[0] = pow(x[0],3)*cos(x[1]);
119 u[1] = pow(x[0],3)*sin(x[1]);
120 u[2] = pow(x[0],3)*pow(x[1],3);
133 template<
class ELEMENT>
155 delete_traction_elements();
158 rebuild_global_mesh();
167 assign_traction_elements();
170 rebuild_global_mesh();
173 complete_problem_setup();
193 RefineableTriangleMesh<ELEMENT>* Bulk_mesh_pt;
203 Mesh* Surface_mesh_pt;
211 template<
class ELEMENT>
214 (
const double&
rmin,
const double&
rmax,
const double &
zmin,
const double&
zmax)
219 Vector<TriangleMeshCurveSection*> boundary_polyline_pt(4);
222 Vector<Vector<double> > bound_coords(2);
223 bound_coords[0].resize(2);
224 bound_coords[1].resize(2);
227 bound_coords[0][0]=
rmin;
228 bound_coords[0][1]=
zmin;
229 bound_coords[1][0]=
rmax;
230 bound_coords[1][1]=
zmin;
233 unsigned boundary_id=0;
234 boundary_polyline_pt[0]=
new TriangleMeshPolyLine(bound_coords,boundary_id);
237 bound_coords[0][0]=
rmax;
238 bound_coords[0][1]=
zmin;
239 bound_coords[1][0]=
rmax;
240 bound_coords[1][1]=
zmax;
244 boundary_polyline_pt[1]=
new TriangleMeshPolyLine(bound_coords,boundary_id);
248 bound_coords[0][0]=
rmax;
249 bound_coords[0][1]=
zmax;
250 bound_coords[1][0]=
rmin;
251 bound_coords[1][1]=
zmax;
255 boundary_polyline_pt[2]=
new TriangleMeshPolyLine(bound_coords,boundary_id);
258 bound_coords[0][0]=
rmin;
259 bound_coords[0][1]=
zmax;
260 bound_coords[1][0]=
rmin;
261 bound_coords[1][1]=
zmin;
265 boundary_polyline_pt[3]=
new TriangleMeshPolyLine(bound_coords,boundary_id);
268 TriangleMeshClosedCurve* closed_curve_pt=
269 new TriangleMeshPolygon(boundary_polyline_pt);
273 TriangleMeshParameters triangle_mesh_parameters(closed_curve_pt);
276 double uniform_element_area=0.2;
277 triangle_mesh_parameters.element_area() = uniform_element_area;
282 Bulk_mesh_pt=
new RefineableTriangleMesh<ELEMENT>(triangle_mesh_parameters);
285 Bulk_mesh_pt->spatial_error_estimator_pt()=
new Z2ErrorEstimator;
290 Bulk_mesh_pt=
new TriangleMesh<ELEMENT>(triangle_mesh_parameters);
295 Surface_mesh_pt=
new Mesh;
296 assign_traction_elements();
299 complete_problem_setup();
302 add_sub_mesh(Bulk_mesh_pt);
303 add_sub_mesh(Surface_mesh_pt);
309 cout << assign_eqn_numbers() <<
" equations assigned" << std::endl;
318 template<
class ELEMENT>
337 for (
unsigned ibound=0;ibound<=2;ibound++)
339 unsigned num_nod=Bulk_mesh_pt->nboundary_node(ibound);
340 for (
unsigned inod=0;inod<num_nod;inod++)
343 Node* nod_pt=Bulk_mesh_pt->boundary_node_pt(ibound,inod);
350 nod_pt->pin(0);nod_pt->pin(1);nod_pt->pin(2);
351 nod_pt->pin(3);nod_pt->pin(4);nod_pt->pin(5);
358 nod_pt->set_value(0,u[0]);
359 nod_pt->set_value(1,u[1]);
360 nod_pt->set_value(2,u[2]);
361 nod_pt->set_value(3,u[3]);
362 nod_pt->set_value(4,u[4]);
363 nod_pt->set_value(5,u[5]);
371 unsigned n_el = Bulk_mesh_pt->nelement();
372 for(
unsigned e=0;e<n_el;e++)
375 ELEMENT *el_pt =
dynamic_cast<ELEMENT*
>(Bulk_mesh_pt->element_pt(e));
395 unsigned n_traction = Surface_mesh_pt->nelement();
396 for(
unsigned e=0;e<n_traction;e++)
399 TimeHarmonicFourierDecomposedLinearElasticityTractionElement<ELEMENT>*
401 dynamic_cast<TimeHarmonicFourierDecomposedLinearElasticityTractionElement
402 <ELEMENT
>* >(Surface_mesh_pt->element_pt(e));
413 template<
class ELEMENT>
417 unsigned bound, n_neigh;
421 n_neigh = Bulk_mesh_pt->nboundary_element(bound);
424 for(
unsigned n=0;n<n_neigh;n++)
427 FiniteElement *traction_element_pt
428 =
new TimeHarmonicFourierDecomposedLinearElasticityTractionElement<ELEMENT>
429 (Bulk_mesh_pt->boundary_element_pt(bound,n),
430 Bulk_mesh_pt->face_index_at_boundary(bound,n));
433 Surface_mesh_pt->add_element_pt(traction_element_pt);
443 template<
class ELEMENT>
448 unsigned n_element = Surface_mesh_pt->nelement();
451 for(
unsigned e=0;e<n_element;e++)
454 delete Surface_mesh_pt->element_pt(e);
458 Surface_mesh_pt->flush_element_and_node_storage();
466 template<
class ELEMENT>
477 sprintf(filename,
"%s/soln.dat",doc_info.directory().c_str());
478 some_file.open(filename);
479 Bulk_mesh_pt->output(some_file,npts);
483 sprintf(filename,
"%s/exact_soln.dat",doc_info.directory().c_str());
484 some_file.open(filename);
485 Bulk_mesh_pt->output_fct(some_file,npts,
492 sprintf(filename,
"%s/error.dat",doc_info.directory().c_str());
493 some_file.open(filename);
494 Bulk_mesh_pt->compute_error(some_file,
500 cout <<
"\nNorm of error: " << sqrt(error) << std::endl;
501 cout <<
"Norm of solution: " << sqrt(norm) << std::endl << std::endl;
506 sprintf(filename,
"%s/norm.dat",doc_info.directory().c_str());
507 some_file.open(filename);
508 some_file << norm << std::endl;
517 int main(
int argc,
char* argv[])
524 doc_info.set_directory(
"RESLT");
530 <ProjectableTimeHarmonicFourierDecomposedLinearElasticityElement
531 <TTimeHarmonicFourierDecomposedLinearElasticityElement<3> > >
536 unsigned max_adapt=3;
537 problem.newton_solve(max_adapt);
543 <TTimeHarmonicFourierDecomposedLinearElasticityElement<3> >
548 problem.newton_solve();
554 problem.doc_solution(doc_info);
Class to validate time harmonic linear elasticity (Fourier decomposed)
void actions_before_adapt()
Actions before adapt: Wipe 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 actions_after_adapt()
Actions after adapt: Rebuild the mesh of traction elements.
void assign_traction_elements()
Allocate traction elements on the bottom surface.
void actions_after_newton_solve()
Update after solve is empty.
void delete_traction_elements()
Delete traction elements.
void actions_before_newton_solve()
Update before solve is empty.
void complete_problem_setup()
Helper function to complete problem setup.
void doc_solution(DocInfo &doc_info)
Doc the solution.
Namespace for global parameters.
double Lz
Length of domain in z-direction.
const std::complex< double > I(0.0, 1.0)
Define the imaginary unit.
std::complex< double > lambda
double Lr
Length of domain in r direction.
std::complex< double > mu
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 > Nu(0.3, 0.05)
Define Poisson's ratio Nu.
void exact_solution(const Vector< double > &x, Vector< double > &u)
The exact solution in a flat-packed vector:
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,...
std::complex< double > Omega_sq(10.0, 5.0)
Define the non-dimensional square angular frequency of time-harmonic motion.
std::complex< double > E(1.0, 0.01)
Define the non-dimensional Young's modulus.
int Fourier_wavenumber
Define Fourier wavenumber.
int main(int argc, char *argv[])
Driver code.