solid_cubic_mesh.h
Go to the documentation of this file.
1 // This file is part of the MercuryDPM project (https://www.mercurydpm.org).
2 // Copyright (c), The MercuryDPM Developers Team. All rights reserved.
3 // License: BSD 3-Clause License; see the LICENSE file in the root directory.
4 
5 #ifndef SOLID_CUBIC_MESH_H
6 #define SOLID_CUBIC_MESH_H
7 
8 #include "generic.h"
9 #include "solid.h"
11 
12 namespace oomph
13 {
14  // Implement the RefineableSolidCubicMesh. Adds boundary coordinates.
15  template<class ELEMENT>
16  class RefineableSolidCubicMesh : public virtual RefineableSimpleCubicMesh<ELEMENT>, public virtual SolidMesh
17  {
18  public:
19 
20  RefineableSolidCubicMesh(const unsigned &nx, const unsigned &ny,
21  const unsigned &nz,
22  const double &a,
23  const double &b,
24  const double &c,
25  TimeStepper *time_stepper_pt = &Mesh::Default_TimeStepper) :
26  SimpleCubicMesh<ELEMENT>(nx, ny, nz, -a, a, -b, b, -c, c, time_stepper_pt),
27  RefineableSimpleCubicMesh<ELEMENT>(nx, ny, nz, -a, a, -b, b, -c, c, time_stepper_pt),
28  SolidMesh()
29  {
30  // Set the boundary coordinates of the nodes:
31  Vector<double> zeta(2, 0.0);
32  // Loop over boundaries
33  for(unsigned b : {0,1,2,3,4,5})
34  {
35  // Loop over the nodes on that boundary
36  const unsigned n_node = this->nboundary_node(b);
37  for(unsigned l=0; l<n_node; l++)
38  {
39  SolidNode* node_pt = this->boundary_node_pt(b, l);
40  Vector<double> x(3, 0.0);
41  for(unsigned i=0; i<3; i++)
42  {
43  x[i] = node_pt->x(i);
44  }
45  // calculate boundary coordinate of node
47  // assign boundary coordinate of node
50  }
51  // We have set local boundary coordinates
53  }
54 
55  //Assign the initial lagrangian coordinates
57  }
58 
60  // nx, ny, nz: number of elements in the x, y, and z directions
61  // xMax, yMax, zMax: dimensions of the cube (assume the center of the cube is at the origin)
62  // timeStepper: defaults to Steady.
63  RefineableSolidCubicMesh(const unsigned& nx, const unsigned& ny, const unsigned& nz,
64  const double& xMin, const double& xMax, const double& yMin,
65  const double& yMax, const double& zMin, const double& zMax,
66  TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper) :
67  SimpleCubicMesh<ELEMENT>(nx, ny, nz, xMin, xMax, yMin, yMax, zMin, zMax, time_stepper_pt),
68  RefineableSimpleCubicMesh<ELEMENT>(nx, ny, nz, xMin, xMax, yMin, yMax, zMin, zMax, time_stepper_pt),
69  SolidMesh()
70  {
71  // Set the boundary coordinates of the nodes:
72  Vector<double> zeta(2, 0.0);
73  // Loop over boundaries
74  for(unsigned b : {0,1,2,3,4,5})
75  {
76  // Loop over the nodes on that boundary
77  const unsigned n_node = this->nboundary_node(b);
78  for(unsigned l=0; l<n_node; l++)
79  {
80  SolidNode* node_pt = this->boundary_node_pt(b, l);
81  Vector<double> x(3, 0.0);
82  for(unsigned i=0; i<3; i++)
83  {
84  x[i] = node_pt->x(i);
85  }
86  // calculate boundary coordinate of node
87  calculate_boundary_coordinate_of_node(x, b, xMin, xMax, yMin, yMax, zMin, zMax, zeta);
88  // assign boundary coordinate of node
91  }
92  // We have set local boundary coordinates
94  }
95 
96  //Assign the initial lagrangian coordinates
98  }
99 
101  {
103  }
104 
105  void setup_boundary_element_info(std::ostream& outfile)
106  {
108  }
109 
110  static double zeta_linear(const double& min, const double& max, const double& x)
111  {
112  return (2.0*x - max - min)/(max-min);
113  }
114 
115  private:
117  const double& xMin, const double& xMax, const double& yMin,
118  const double& yMax, const double& zMin, const double& zMax,
120  {
121  switch (b)
122  {
123  case 0:
124  zeta[0] = zeta_linear(xMin, xMax, x[0]);
125  zeta[1] = zeta_linear(yMin, yMax, x[1]);
126  break;
127  case 1:
128  zeta[0] = zeta_linear(xMin, xMax, x[0]);
129  zeta[1] = zeta_linear(zMin, zMax, x[2]);
130  break;
131  case 2:
132  zeta[0] = zeta_linear(yMin, yMax, x[1]);
133  zeta[1] = zeta_linear(zMin, zMax, x[2]);
134  break;
135  case 3:
136  zeta[0] = zeta_linear(xMin, xMax, x[0]);
137  zeta[1] = zeta_linear(zMin, zMax, x[2]);
138  break;
139  case 4:
140  zeta[0] = zeta_linear(yMin, yMax, x[1]);
141  zeta[1] = zeta_linear(zMin, zMax, x[2]);
142  break;
143  case 5:
144  zeta[0] = zeta_linear(xMin, xMax, x[0]);
145  zeta[1] = zeta_linear(yMin, yMax, x[1]);
146  break;
147  default:
148  // Change to oomph error
149  std::string error_string = std::to_string(b);
150  error_string += " is not a valid boundary.";
151  throw OomphLibError(error_string,
154  break;
155  }
156  }
157  };
158 
159 } // End namespace
160 
161 #endif
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Scalar * b
Definition: benchVecAdd.cpp:17
void setup_boundary_element_info()
Definition: brick_mesh.h:195
unsigned long nboundary_node(const unsigned &ibound) const
Return number of nodes on a particular boundary.
Definition: mesh.h:833
static Steady< 0 > Default_TimeStepper
The Steady Timestepper.
Definition: mesh.h:75
std::vector< bool > Boundary_coordinate_exists
Definition: mesh.h:190
double & x(const unsigned &i)
Return the i-th nodal coordinate.
Definition: nodes.h:1060
virtual void add_to_boundary(const unsigned &b)
Definition: nodes.cc:2336
virtual void set_coordinates_on_boundary(const unsigned &b, const unsigned &k, const Vector< double > &boundary_zeta)
Definition: nodes.cc:2394
Definition: oomph_definitions.h:222
Refineable version of simple cubic 3D Brick mesh class.
Definition: simple_cubic_mesh.template.h:169
Definition: solid_cubic_mesh.h:17
void setup_boundary_element_info()
Definition: solid_cubic_mesh.h:100
RefineableSolidCubicMesh(const unsigned &nx, const unsigned &ny, const unsigned &nz, const double &xMin, const double &xMax, const double &yMin, const double &yMax, const double &zMin, const double &zMax, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Constructor:
Definition: solid_cubic_mesh.h:63
RefineableSolidCubicMesh(const unsigned &nx, const unsigned &ny, const unsigned &nz, const double &a, const double &b, const double &c, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Definition: solid_cubic_mesh.h:20
static double zeta_linear(const double &min, const double &max, const double &x)
Definition: solid_cubic_mesh.h:110
void calculate_boundary_coordinate_of_node(const Vector< double > &x, const unsigned &b, const double &xMin, const double &xMax, const double &yMin, const double &yMax, const double &zMin, const double &zMax, Vector< double > &zeta)
Definition: solid_cubic_mesh.h:116
void setup_boundary_element_info(std::ostream &outfile)
Definition: solid_cubic_mesh.h:105
Simple cubic 3D Brick mesh class.
Definition: simple_cubic_mesh.template.h:47
const unsigned & ny() const
Access function for number of elements in y directions.
Definition: simple_cubic_mesh.template.h:114
const unsigned & nx() const
Access function for number of elements in x directions.
Definition: simple_cubic_mesh.template.h:108
const unsigned & nz() const
Access function for number of elements in y directions.
Definition: simple_cubic_mesh.template.h:120
Definition: mesh.h:2562
SolidNode * node_pt(const unsigned long &n)
Return a pointer to the n-th global SolidNode.
Definition: mesh.h:2594
void set_lagrangian_nodal_coordinates()
Definition: mesh.cc:9564
SolidNode * boundary_node_pt(const unsigned &b, const unsigned &n)
Return n-th SolidNodes on b-th boundary.
Definition: mesh.h:2612
Definition: nodes.h:1686
Definition: timesteppers.h:231
#define min(a, b)
Definition: datatypes.h:22
#define max(a, b)
Definition: datatypes.h:23
const Scalar * a
Definition: level2_cplx_impl.h:32
EIGEN_STRONG_INLINE const Eigen::CwiseBinaryOp< Eigen::internal::scalar_zeta_op< typename DerivedX::Scalar >, const DerivedX, const DerivedQ > zeta(const Eigen::ArrayBase< DerivedX > &x, const Eigen::ArrayBase< DerivedQ > &q)
Definition: SpecialFunctionsArrayAPI.h:152
int c
Definition: calibrate.py:100
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
std::string to_string(T object, unsigned float_precision=8)
Definition: oomph_utilities.h:189
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
Definition: AnisotropicHookean.h:10
list x
Definition: plotDoE.py:28
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86