refineable_brick_element.h
Go to the documentation of this file.
1 // LIC// ====================================================================
2 // LIC// This file forms part of oomph-lib, the object-oriented,
3 // LIC// multi-physics finite-element library, available
4 // LIC// at http://www.oomph-lib.org.
5 // LIC//
6 // LIC// Copyright (C) 2006-2022 Matthias Heil and Andrew Hazel
7 // LIC//
8 // LIC// This library is free software; you can redistribute it and/or
9 // LIC// modify it under the terms of the GNU Lesser General Public
10 // LIC// License as published by the Free Software Foundation; either
11 // LIC// version 2.1 of the License, or (at your option) any later version.
12 // LIC//
13 // LIC// This library is distributed in the hope that it will be useful,
14 // LIC// but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // LIC// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // LIC// Lesser General Public License for more details.
17 // LIC//
18 // LIC// You should have received a copy of the GNU Lesser General Public
19 // LIC// License along with this library; if not, write to the Free Software
20 // LIC// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 // LIC// 02110-1301 USA.
22 // LIC//
23 // LIC// The authors may be contacted at oomph-lib@maths.man.ac.uk.
24 // LIC//
25 // LIC//====================================================================
26 #ifndef OOMPH_REFINEABLE_BRICK_ELEMENT_HEADER
27 #define OOMPH_REFINEABLE_BRICK_ELEMENT_HEADER
28 
29 // Config header generated by autoconfig
30 #ifdef HAVE_CONFIG_H
31 #include <oomph-lib-config.h>
32 #endif
33 
34 // ooomph-lib includes
35 #include "octree.h"
36 #include "refineable_elements.h"
37 #include "Qelements.h"
38 
39 namespace oomph
40 {
41  class Mesh;
42 
43  //=======================================================================
64  //=======================================================================
65  template<>
66  class RefineableQElement<3> : public virtual RefineableElement,
67  public virtual BrickElementBase
68  {
69  public:
72  typedef void (RefineableQElement<3>::*VoidMemFctPt)();
73 
76  {
77 #ifdef LEAK_CHECK
78  LeakCheckNames::RefineableQElement<3> _build += 1;
79 #endif
80  }
81 
83  RefineableQElement<3>(const RefineableQElement<3>& dummy) = delete;
84 
86  // Commented out broken assignment operator because this can lead to a
87  // conflict warning when used in the virtual inheritence hierarchy.
88  // Essentially the compiler doesn't realise that two separate
89  // implementations of the broken function are the same and so, quite
90  // rightly, it shouts.
91  /*void operator=(const RefineableQElement<3>&) = delete;*/
92 
94  virtual ~RefineableQElement<3>()
95  {
96 #ifdef LEAK_CHECK
97  LeakCheckNames::RefineableQElement<3> _build -= 1;
98 #endif
99  }
100 
102  unsigned required_nsons() const
103  {
104  return 8;
105  }
106 
111  virtual Node* node_created_by_neighbour(const Vector<double>& s_fraction,
112  bool& is_periodic);
113 
119  const Vector<double>& s_fraction, bool& is_periodic)
120  {
121  // It is impossible for this situation to arise in meshes
122  // containing elements of uniform p-order. This is here so
123  // that it can be overloaded for p-refineable elements.
124  return 0;
125  }
126 
131  virtual void build(Mesh*& mesh_pt,
132  Vector<Node*>& new_node_pt,
133  bool& was_already_built,
134  std::ofstream& new_nodes_file);
135 
138  void check_integrity(double& max_error);
139 
141  void output_corners(std::ostream& outfile, const std::string& colour) const;
142 
145  {
146  return dynamic_cast<OcTree*>(Tree_pt);
147  }
148 
150  OcTree* octree_pt() const
151  {
152  return dynamic_cast<OcTree*>(Tree_pt);
153  }
154 
158  void setup_hanging_nodes(Vector<std::ofstream*>& output_stream);
159 
163  virtual void further_setup_hanging_nodes() = 0;
164 
165  protected:
172  static std::map<unsigned, DenseMatrix<int>> Father_bound;
173 
176  void setup_father_bounds();
177 
185  void get_face_bcs(const int& edge, Vector<int>& bound_cons) const;
186 
194  void get_boundaries(const int& edge, std::set<unsigned>& boundaries) const;
195 
211  void get_bcs(int bound, Vector<int>& bound_cons) const;
212 
215  void interpolated_zeta_on_face(const unsigned& boundary,
216  const int& face,
217  const Vector<double>& s,
219 
222  void setup_hang_for_value(const int& value_id);
223 
226  virtual void oc_hang_helper(const int& value_id,
227  const int& my_edge,
228  std::ofstream& output_hangfile);
229  };
230 
231 
232  //========================================================================
234  //========================================================================
235  template<>
236  class RefineableSolidQElement<3> : public virtual RefineableQElement<3>,
237  public virtual RefineableSolidElement,
238  public virtual QSolidElementBase
239  {
240  public:
244  {
245  }
246 
247 
250 
252  /*void operator=(const RefineableSolidQElement<3>&) = delete;*/
253 
256 
257 
259  void set_macro_elem_pt(MacroElement* macro_elem_pt)
260  {
262  }
263 
265  void set_macro_elem_pt(MacroElement* macro_elem_pt,
266  MacroElement* undeformed_macro_elem_pt)
267  {
269  undeformed_macro_elem_pt);
270  }
271 
274  void get_jacobian(Vector<double>& residuals, DenseMatrix<double>& jacobian)
275  {
276  RefineableSolidElement::get_jacobian(residuals, jacobian);
277  }
278 
282  void get_face_solid_bcs(const int& edge,
283  Vector<int>& solid_bound_cons) const;
284 
289  void get_solid_bcs(int bound, Vector<int>& solid_bound_cons) const;
290 
293  // NOTE: FOR SOME REASON THIS NEEDS TO LIVE IN *.H TO WORK ON INTEL
294  void build(Mesh*& mesh_pt,
295  Vector<Node*>& new_node_pt,
296  bool& was_already_built,
297  std::ofstream& new_nodes_file)
298  {
299  using namespace OcTreeNames;
300 
301  // Call the standard (non-elastic) build function
303  mesh_pt, new_node_pt, was_already_built, new_nodes_file);
304 
305  // Are we done?
306  if (was_already_built) return;
307 
308  // Now need to loop over the nodes again and set solid variables
309 
310  // What type of son am I? Ask my quadtree representation...
311  int son_type = octree_pt()->son_type();
312 
313  // Which element (!) is my father? (We must have a father
314  // since was_already_built is false...)
315  RefineableSolidQElement<3>* father_el_pt =
316  dynamic_cast<RefineableSolidQElement<3>*>(
317  Tree_pt->father_pt()->object_pt());
318 
319 
320 #ifdef PARANOID
321  // Currently we can't handle the case of generalised coordinates
322  // since we haven't established how they should be interpolated
323  // Buffer this case:
324  if (static_cast<SolidNode*>(father_el_pt->node_pt(0))
325  ->nlagrangian_type() != 1)
326  {
327  throw OomphLibError(
328  "We can't handle generalised nodal positions (yet).\n",
331  }
332 #endif
333 
334 
335  // Now get coordinates and stuff
336  Vector<int> s_lo(3);
337  Vector<int> s_hi(3);
338  Vector<double> s(3);
339  Vector<double> xi(3);
340  Vector<double> xi_fe(3);
341  Vector<double> x(3);
342  Vector<double> x_fe(3);
343 
344  // Get the number of 1d nodes
345  unsigned n_p = nnode_1d();
346 
347 
348  // Setup vertex coordinates in father element:
349  //--------------------------------------------
350 
351  // find the s_lo coordinates
352  s_lo = octree_pt()->Direction_to_vector[son_type];
353 
354  // just scale them, because the Direction_to_vector
355  // doesn't really gives s_lo;
356  for (int i = 0; i < 3; i++)
357  {
358  s_lo[i] = (s_lo[i] + 1) / 2 - 1;
359  }
360 
361  // setup s_hi (Actually s_hi[i]=s_lo[i]+1)
362  for (int i = 0; i < 3; i++)
363  {
364  s_hi[i] = s_lo[i] + 1;
365  }
366 
367  // Pass Undeformed macro element pointer on to sons and
368  // set coordinates in macro element
369  if (father_el_pt->Undeformed_macro_elem_pt != 0)
370  {
371  Undeformed_macro_elem_pt = father_el_pt->Undeformed_macro_elem_pt;
372  for (unsigned i = 0; i < 3; i++)
373  {
374  s_macro_ll(i) =
375  father_el_pt->s_macro_ll(i) +
376  0.5 * (s_lo[i] + 1.0) *
377  (father_el_pt->s_macro_ur(i) - father_el_pt->s_macro_ll(i));
378  s_macro_ur(i) =
379  father_el_pt->s_macro_ll(i) +
380  0.5 * (s_hi[i] + 1.0) *
381  (father_el_pt->s_macro_ur(i) - father_el_pt->s_macro_ll(i));
382  }
383  }
384 
385 
386  unsigned jnod = 0;
387  Vector<double> x_small(3);
388  Vector<double> x_large(3);
389 
390  Vector<double> s_fraction(3);
391 
392 
393  // Loop over nodes in element
394  for (unsigned i0 = 0; i0 < n_p; i0++)
395  {
396  // Get the fractional position of the node in the direction of s[0]
397  s_fraction[0] = local_one_d_fraction_of_node(i0, 0);
398  // Local coordinate in father element
399  s[0] = s_lo[0] + (s_hi[0] - s_lo[0]) * s_fraction[0];
400 
401  for (unsigned i1 = 0; i1 < n_p; i1++)
402  {
403  // Get the fractional position of the node in the direction of s[1]
404  s_fraction[1] = local_one_d_fraction_of_node(i1, 1);
405  // Local coordinate in father element
406  s[1] = s_lo[1] + (s_hi[1] - s_lo[1]) * s_fraction[1];
407 
408  for (unsigned i2 = 0; i2 < n_p; i2++)
409  {
410  // Get the fractional position of the node in the direction of s[2]
411  s_fraction[2] = local_one_d_fraction_of_node(i2, 2);
412  // Local coordinate in father element
413  s[2] = s_lo[2] + (s_hi[2] - s_lo[2]) * s_fraction[2];
414 
415  // Local node number
416  jnod = i0 + n_p * i1 + n_p * n_p * i2;
417 
418  // Get position from father element -- this uses the macro
419  // element representation(s) if appropriate. If the node
420  // turns out to be a hanging node later on, then
421  // its position gets adjusted in line with its
422  // hanging node interpolation.
423  father_el_pt->get_x_and_xi(s, x_fe, x, xi_fe, xi);
424 
425  // Cast the node to an Solid node
426  SolidNode* elastic_node_pt = static_cast<SolidNode*>(node_pt(jnod));
427 
428  for (unsigned i = 0; i < 3; i++)
429  {
430  // x_fe is the FE representation -- this is all we can
431  // work with in a solid mechanics problem. If you wish
432  // to reposition nodes on curvilinear boundaries of
433  // a domain to their exact positions on those boundaries
434  // you'll have to do this yourself! [Note: We used to
435  // use the macro-element-based representation
436  // to assign the position of pinned nodes but this is not always
437  // correct since pinning doesn't mean "pin in place" or
438  // "pin to the curvilinear boundary". For instance, we could
439  // impose the boundary displacement manually.
440  elastic_node_pt->x(i) = x_fe[i];
441 
442  // Lagrangian coordinates can come from undeformed macro element
443  if (Use_undeformed_macro_element_for_new_lagrangian_coords)
444  {
445  elastic_node_pt->xi(i) = xi[i];
446  }
447  else
448  {
449  elastic_node_pt->xi(i) = xi_fe[i];
450  }
451  }
452 
453  // Are there any history values to be dealt with?
454  TimeStepper* time_stepper_pt =
455  father_el_pt->node_pt(0)->time_stepper_pt();
456 
457  // Number of history values (incl. present)
458  unsigned ntstorage = time_stepper_pt->ntstorage();
459  if (ntstorage != 1)
460  {
461  // Loop over # of history values (excluding present which has been
462  // done above)
463  for (unsigned t = 1; t < ntstorage; t++)
464  {
465  // History values can (and in the case of Newmark timestepping,
466  // the scheme most likely to be used for Solid computations, do)
467  // include non-positional values, e.g. velocities and accels.
468 
469  // Set previous positions of the new node
470  for (unsigned i = 0; i < 3; i++)
471  {
472  elastic_node_pt->x(t, i) =
473  father_el_pt->interpolated_x(t, s, i);
474  }
475  }
476  }
477  } // End of s2 loop
478  } // End of vertical loop over nodes in element
479 
480  } // End of horizontal loop over nodes in element
481  }
482  };
483 
484 
485 } // namespace oomph
486 
487 #endif
int i
Definition: BiCGSTAB_step_by_step.cpp:9
Base class for all brick elements.
Definition: Qelements.h:1233
TimeStepper *& time_stepper_pt()
Return the pointer to the timestepper.
Definition: nodes.h:238
Node *& node_pt(const unsigned &n)
Return a pointer to the local node n.
Definition: elements.h:2175
virtual double interpolated_x(const Vector< double > &s, const unsigned &i) const
Return FE interpolated coordinate x[i] at local coordinate s.
Definition: elements.cc:3962
virtual void get_jacobian(Vector< double > &residuals, DenseMatrix< double > &jacobian)
Definition: elements.h:990
Definition: macro_element.h:73
Definition: mesh.h:67
Definition: nodes.h:906
double & x(const unsigned &i)
Return the i-th nodal coordinate.
Definition: nodes.h:1060
Definition: octree.h:114
Definition: oomph_definitions.h:222
double & s_macro_ll(const unsigned &i)
Definition: Qelements.h:186
double & s_macro_ur(const unsigned &i)
Definition: Qelements.h:202
Base class for Solid Qelements.
Definition: Qelements.h:331
virtual void set_macro_elem_pt(MacroElement *macro_elem_pt)
Broken assignment operator.
Definition: Qelements.h:349
void get_x_and_xi(const Vector< double > &s, Vector< double > &x_fe, Vector< double > &x, Vector< double > &xi_fe, Vector< double > &xi) const
Definition: Qelements.h:379
Definition: refineable_elements.h:97
Definition: refineable_brick_element.h:68
static std::map< unsigned, DenseMatrix< int > > Father_bound
Definition: refineable_brick_element.h:172
unsigned required_nsons() const
A refineable brick element has eight sons.
Definition: refineable_brick_element.h:102
OcTree * octree_pt() const
Pointer to octree representation of this element.
Definition: refineable_brick_element.h:150
virtual void further_setup_hanging_nodes()=0
virtual Node * node_created_by_son_of_neighbour(const Vector< double > &s_fraction, bool &is_periodic)
Definition: refineable_brick_element.h:118
OcTree * octree_pt()
Pointer to octree representation of this element.
Definition: refineable_brick_element.h:144
Definition: Qelements.h:2259
Definition: refineable_elements.h:874
Refineable version of Solid brick elements.
Definition: refineable_brick_element.h:239
void build(Mesh *&mesh_pt, Vector< Node * > &new_node_pt, bool &was_already_built, std::ofstream &new_nodes_file)
Definition: refineable_brick_element.h:294
void set_macro_elem_pt(MacroElement *macro_elem_pt)
Final over-ride: Use version in QSolidElementBase.
Definition: refineable_brick_element.h:259
RefineableSolidQElement()
Constructor, just call the constructor of the RefineableQElement<2>
Definition: refineable_brick_element.h:242
void get_jacobian(Vector< double > &residuals, DenseMatrix< double > &jacobian)
Definition: refineable_brick_element.h:274
RefineableSolidQElement(const RefineableSolidQElement< 3 > &dummy)=delete
Broken copy constructor.
void set_macro_elem_pt(MacroElement *macro_elem_pt, MacroElement *undeformed_macro_elem_pt)
Final over-ride: Use version in QSolidElementBase.
Definition: refineable_brick_element.h:265
virtual ~RefineableSolidQElement()
Broken assignment operator.
Definition: refineable_brick_element.h:255
Definition: Qelements.h:2286
MacroElement * Undeformed_macro_elem_pt
Pointer to the element's "undeformed" macro element (NULL by default)
Definition: elements.h:4076
Definition: nodes.h:1686
unsigned nlagrangian_type() const
Definition: nodes.h:1877
double & xi(const unsigned &i)
Reference to i-th Lagrangian position.
Definition: nodes.h:1883
Definition: timesteppers.h:231
unsigned ntstorage() const
Definition: timesteppers.h:601
RealScalar s
Definition: level1_cplx_impl.h:130
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
double max_error
Definition: MortaringCantileverCompareToNonMortaring.cpp:188
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
Vector< std::string > colour
Tecplot colours.
Definition: oomph_utilities.cc:1159
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
Definition: AnisotropicHookean.h:10
list x
Definition: plotDoE.py:28
t
Definition: plotPSD.py:36
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86