oomph::SolidHelpers Namespace Reference

Namespace for solid mechanics helper functions. More...

Functions

template<class ELEMENT >
void doc_2D_principal_stress (DocInfo &doc_info, SolidMesh *mesh_pt)
 

Detailed Description

Namespace for solid mechanics helper functions.

/////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////

Function Documentation

◆ doc_2D_principal_stress()

template<class ELEMENT >
void oomph::SolidHelpers::doc_2D_principal_stress ( DocInfo doc_info,
SolidMesh mesh_pt 
)

Document the principal stresses in a 2D SolidMesh pointed to by mesh_pt, in the directory specified by the DocInfo object, in a format that can be processed with tecplot macro.

2380  {
2381  // Output principal stress vectors at the centre of all elements
2382  std::ofstream pos_file;
2383  std::ofstream neg_file;
2384  std::ostringstream filename;
2385  filename << doc_info.directory() << "/pos_principal_stress"
2386  << doc_info.number() << ".dat";
2387  pos_file.open(filename.str().c_str());
2388  filename.str("");
2389  filename << doc_info.directory() << "/neg_principal_stress"
2390  << doc_info.number() << ".dat";
2391  neg_file.open(filename.str().c_str());
2392 
2393  // Write dummy data in both so there's at lest one zone in each
2394  pos_file << 0.0 << " " << 0.0 << " " << 0.0 << " " << 0.0 << " "
2395  << std::endl;
2396  neg_file << 0.0 << " " << 0.0 << " " << 0.0 << " " << 0.0 << " "
2397  << std::endl;
2398 
2399 
2400  Vector<double> s(2);
2401  Vector<double> x(2);
2402  s[0] = 0.0;
2403  s[1] = 0.0;
2404  unsigned n_solid_element = mesh_pt->nelement();
2405  for (unsigned e = 0; e < n_solid_element; e++)
2406  {
2407  ELEMENT* el_pt = dynamic_cast<ELEMENT*>(mesh_pt->element_pt(e));
2408 
2409  // Get principal stress
2410  DenseMatrix<double> principal_stress_vector(2);
2411  Vector<double> principal_stress(2);
2412  el_pt->get_principal_stress(
2413  s, principal_stress_vector, principal_stress);
2414 
2415  // Get position of centre of element
2416  el_pt->interpolated_x(s, x);
2417 
2418  // compute vectors at 45 degree for nearly hydrostatic pressure state
2420 
2421  bool hydrostat = false;
2422 
2423  // Max. relative difference between principal stresses
2424  // required to classify stress state as non-hydrostatic: 1%
2425  double dev_max = 1.0e-2;
2426  if (principal_stress[0] != 0.0)
2427  {
2428  if (std::fabs((principal_stress[0] - principal_stress[1]) /
2429  principal_stress[0]) < dev_max)
2430  {
2431  hydrostat = true;
2432  double Cos = cos(0.25 * 3.14159);
2433  double Sin = sin(0.25 * 3.14159);
2434  rot(0, 0) = Cos * principal_stress_vector(0, 0) -
2435  Sin * principal_stress_vector(0, 1);
2436  rot(0, 1) = Sin * principal_stress_vector(0, 0) +
2437  Cos * principal_stress_vector(0, 1);
2438  rot(1, 0) = Cos * principal_stress_vector(1, 0) -
2439  Sin * principal_stress_vector(1, 1);
2440  rot(1, 1) = Sin * principal_stress_vector(1, 0) +
2441  Cos * principal_stress_vector(1, 1);
2442  }
2443  }
2444 
2445  // Loop over two principal stresses:
2446  for (unsigned i = 0; i < 2; i++)
2447  {
2448  if (principal_stress[i] > 0.0)
2449  {
2450  pos_file << x[0] << " " << x[1] << " "
2451  << principal_stress_vector(i, 0) << " "
2452  << principal_stress_vector(i, 1) << std::endl;
2453  pos_file << x[0] << " " << x[1] << " "
2454  << -principal_stress_vector(i, 0) << " "
2455  << -principal_stress_vector(i, 1) << std::endl;
2456  if (hydrostat)
2457  {
2458  pos_file << x[0] << " " << x[1] << " " << rot(i, 0) << " "
2459  << rot(i, 1) << std::endl;
2460  pos_file << x[0] << " " << x[1] << " " << -rot(i, 0) << " "
2461  << -rot(i, 1) << std::endl;
2462  }
2463  }
2464  else
2465  {
2466  neg_file << x[0] << " " << x[1] << " "
2467  << principal_stress_vector(i, 0) << " "
2468  << principal_stress_vector(i, 1) << std::endl;
2469  neg_file << x[0] << " " << x[1] << " "
2470  << -principal_stress_vector(i, 0) << " "
2471  << -principal_stress_vector(i, 1) << std::endl;
2472  if (hydrostat)
2473  {
2474  neg_file << x[0] << " " << x[1] << " " << rot(i, 0) << " "
2475  << rot(i, 1) << std::endl;
2476  neg_file << x[0] << " " << x[1] << " " << -rot(i, 0) << " "
2477  << -rot(i, 1) << std::endl;
2478  }
2479  }
2480  }
2481  }
2482 
2483  pos_file.close();
2484  neg_file.close();
2485  }
AnnoyingScalar cos(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:136
AnnoyingScalar sin(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:137
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Array< double, 1, 3 > e(1./3., 0.5, 2.)
RealScalar s
Definition: level1_cplx_impl.h:130
EIGEN_BLAS_FUNC() rot(int *n, Scalar *px, int *incx, Scalar *py, int *incy, Scalar *pc, Scalar *ps)
Definition: level1_real_impl.h:88
string filename
Definition: MergeRestartFiles.py:39
Real fabs(const Real &a)
Definition: boostmultiprec.cpp:117
list x
Definition: plotDoE.py:28

References cos(), oomph::DocInfo::directory(), e(), oomph::Mesh::element_pt(), boost::multiprecision::fabs(), MergeRestartFiles::filename, i, oomph::Mesh::nelement(), oomph::DocInfo::number(), rot(), s, sin(), and plotDoE::x.