macro_element_node_update_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_MACRO_ELEMENT_NODE_UPDATE_ELEMENTS_HEADER
27 #define OOMPH_MACRO_ELEMENT_NODE_UPDATE_ELEMENTS_HEADER
28 
29 #include "geom_objects.h"
30 #include "mesh.h"
31 #include "elements.h"
33 #include "domain.h"
34 
35 namespace oomph
36 {
39  // MacroElementNodeUpdate nodes
42 
43 
44  //========================================================================
47  //========================================================================
49  {
50  public:
54  MacroElementNodeUpdateNode(const unsigned& n_dim,
55  const unsigned& n_position_type,
56  const unsigned& initial_nvalue)
57  : Node(n_dim, n_position_type, initial_nvalue)
58  {
59  // By default, only the nodal position is updated and no auxiliary
60  // updates of function values are performed.
61  }
62 
67  const unsigned& n_dim,
68  const unsigned& n_position_type,
69  const unsigned& initial_nvalue)
70  : Node(time_stepper_pt, n_dim, n_position_type, initial_nvalue)
71  {
72  // By default, only the nodal position is updated and no auxiliary
73  // updates of function values are performed.
74  }
75 
78 
80  // Commented out broken assignment operator because this can lead to a
81  // conflict warning when used in the virtual inheritence hierarchy.
82  // Essentially the compiler doesn't realise that two separate
83  // implementations of the broken function are the same and so, quite
84  // rightly, it shouts.
85  /*void operator=(const MacroElementNodeUpdateNode&) = delete;*/
86 
89 
97  void node_update(const bool& update_all_time_levels_for_new_node = false);
98 
102  {
103  return Node_update_element_pt;
104  }
105 
106 
110  {
112  }
113 
115  unsigned ngeom_object() const
116  {
117  return Geom_object_pt.size();
118  }
119 
123  {
124  return Geom_object_pt;
125  }
126 
127 
130  GeomObject* geom_object_pt(const unsigned& i)
131  {
132  return Geom_object_pt[i];
133  }
134 
135 
139  {
140  return Geom_object_pt;
141  }
142 
145  {
146  if (Geom_object_pt.size() > 0)
147  {
148  return &(Geom_object_pt[0]);
149  }
150  else
151  {
152  return 0;
153  }
154  }
155 
164  {
168  }
169 
170 
171  private:
175 
179 
183  };
184 
185 
188  // MacroElementNodeUpdate elements
191 
192 
193  //========================================================================
195  //========================================================================
197  {
198  public:
201 
204  const MacroElementNodeUpdateElementBase&) = delete;
205 
208 
211 
216  virtual void set_node_update_info(
218 
220  inline unsigned ngeom_object()
221  {
222  return Geom_object_pt.size();
223  }
224 
228  {
229  return Geom_object_pt;
230  }
231 
234  GeomObject* geom_object_pt(const unsigned& i)
235  {
236  return Geom_object_pt[i];
237  }
238 
239 
240  protected:
244  };
245 
246 
247  //========================================================================
259  //========================================================================
260  template<class ELEMENT>
262  : public ElementWithSpecificMovingNodes<ELEMENT,
263  MacroElementNodeUpdateNode>,
265  {
266  public:
271  {
272  }
273 
276  const int& face_index)
278  element_pt, face_index),
280  {
281  }
282 
285  delete;
286 
289 
291  /*void operator=(const MacroElementNodeUpdateElement&) = delete;*/
292 
298  {
299  // Store local copy of geom object vector, so it can be passed on
300  // to son elements (and their nodes) during refinement
301  unsigned ngeom_object = geom_object_pt.size();
303  for (unsigned i = 0; i < ngeom_object; i++)
304  {
306  }
307 
308  // Loop over nodes in element
309  unsigned n_node = this->nnode();
310  for (unsigned j = 0; j < n_node; j++)
311  {
312  // Get local coordinate in element (Vector sets its own size)
313  Vector<double> s_in_node_update_element;
314  this->local_coordinate_of_node(j, s_in_node_update_element);
315 
316  // Pass the lot to the node
317  static_cast<MacroElementNodeUpdateNode*>(this->node_pt(j))
319  this, s_in_node_update_element, geom_object_pt);
320  }
321  }
322 
323 
330  void rebuild_from_sons(Mesh*& mesh_pt)
331  {
332  // First call the element's own rebuild_from_sons() function
333  ELEMENT::rebuild_from_sons(mesh_pt);
334 
335  // Now loop over nodes in element
336  unsigned n_node = this->nnode();
337  for (unsigned j = 0; j < n_node; j++)
338  {
339  // Get local coordinate in element (Vector sets its own size)
340  Vector<double> s_in_node_update_element;
341  this->local_coordinate_of_node(j, s_in_node_update_element);
342 
343  // Pass the lot to the node
344  static_cast<MacroElementNodeUpdateNode*>(this->node_pt(j))
346  this, s_in_node_update_element, Geom_object_pt);
347  }
348  }
349  };
350 
351 
352  //========================================================================
358  //========================================================================
359  class MacroElementNodeUpdateMesh : public virtual Mesh
360  {
361  public:
364 
367 
370 
372  /*void operator=(const MacroElementNodeUpdateMesh&) = delete;*/
373 
377  {
378  return Macro_domain_pt;
379  }
380 
387  void node_update(const bool& update_all_solid_nodes = false)
388  {
389 #ifdef PARANOID
390  if (update_all_solid_nodes)
391  {
392  std::string error_message =
393  "Doesn't make sense to use an MacroElementNodeUpdateMesh with\n";
394  error_message +=
395  "SolidElements so specifying update_all_solid_nodes=true\n";
396  error_message += "doesn't make sense either\n";
397 
398  throw OomphLibError(
400  }
401 #endif
402 
403  // Loop over all nodes and update their positions -- hanging nodes
404  // are updated via their masters; auxiliary update function
405  // is performed by node, too
406  unsigned n_node = nnode();
407  for (unsigned n = 0; n < n_node; n++)
408  {
410  dynamic_cast<MacroElementNodeUpdateNode*>(node_pt(n));
411 #ifdef PARANOID
412  if (nod_pt == 0)
413  {
414  std::ostringstream error_message;
415  error_message << "Failed to cast to MacroElementNodeUpdateNode.\n"
416  << "Node is of type: " << typeid(node_pt(n)).name()
417  << std::endl;
418 
419  throw OomphLibError(error_message.str(),
422  }
423 #endif
424  nod_pt->node_update();
425  }
426 
427 #ifdef OOMPH_HAS_MPI
428  // Update positions for external halo nodes attached to this mesh
429  // Loop over processors
430  for (std::map<unsigned, Vector<Node*>>::iterator it =
431  External_halo_node_pt.begin();
432  it != External_halo_node_pt.end();
433  it++)
434  {
435  int iproc = (*it).first;
436  unsigned n_ext_halo_node = nexternal_halo_node(iproc);
437  for (unsigned n = 0; n < n_ext_halo_node; n++)
438  {
440  dynamic_cast<MacroElementNodeUpdateNode*>(
441  external_halo_node_pt(iproc, n));
442 #ifdef PARANOID
443  if (nod_pt == 0)
444  {
445  std::ostringstream error_message;
446  error_message
447  << "Failed to cast (ext. halo) to MacroElementNodeUpdateNode.\n"
448  << "Node is of type: " << typeid(node_pt(n)).name() << std::endl;
449 
450  throw OomphLibError(error_message.str(),
453  }
454 #endif
455  nod_pt->node_update();
456  }
457  } // end loop over processors
458 #endif // (ifdef OOMPH_HAS_MPI)
459  }
460 
461 #ifdef OOMPH_HAS_MPI
465  void distribute(OomphCommunicator* comm_pt,
466  const Vector<unsigned>& element_domain,
467  Vector<GeneralisedElement*>& deleted_element_pt,
468  DocInfo& doc_info,
469  const bool& report_stats,
470  const bool& overrule_keep_as_halo_element_status)
471  {
472  // Call underlying Mesh::distribute first
473  Mesh::distribute(comm_pt,
474  element_domain,
475  deleted_element_pt,
476  doc_info,
477  report_stats,
478  overrule_keep_as_halo_element_status);
479 
480  // Storage for number of processors
481  int n_proc = comm_pt->nproc();
482 
483  // The original call to set_node_update_info on the
484  // non-distributed problem may have set a macro element which no
485  // longer exists for some halo nodes which are on halo elements
486  // within the distributed Mesh; this deals with the problem by
487  // recalling the set_node_update_info for every halo element
488  for (int iproc = 0; iproc < n_proc; iproc++)
489  {
490  Vector<GeneralisedElement*> halo_el_pt = halo_element_pt(iproc);
491  unsigned n_halo_el = halo_el_pt.size();
492  for (unsigned e = 0; e < n_halo_el; e++)
493  {
494  // Cast to a MacroElementNodeUpdateElement
495  MacroElementNodeUpdateElementBase* macro_el_pt =
496  dynamic_cast<MacroElementNodeUpdateElementBase*>(halo_el_pt[e]);
497 
498  // The vector of GeomObjects should not change!
499  Vector<GeomObject*> geom_object_pt = macro_el_pt->geom_object_pt();
500 
501  // So we can just call set_node_update_info for the element!
502  macro_el_pt->set_node_update_info(geom_object_pt);
503  }
504  }
505  }
506 #endif
507 
511  {
513  }
514 
517  {
518  return Geom_object_vector_pt;
519  }
520 
521  private:
525 
528  };
529 
530 
534 
535 
536  //=======================================================================
540  //=======================================================================
541  template<class ELEMENT>
543  : public virtual FaceGeometry<ELEMENT>
544  {
545  public:
547  FaceGeometry() : FaceGeometry<ELEMENT>() {}
548  };
549 
550 } // namespace oomph
551 
552 #endif
int i
Definition: BiCGSTAB_step_by_step.cpp:9
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
Array< double, 1, 3 > e(1./3., 0.5, 2.)
TimeStepper *& time_stepper_pt()
Return the pointer to the timestepper.
Definition: nodes.h:238
Definition: oomph_utilities.h:499
Definition: domain.h:67
Definition: element_with_moving_nodes.h:382
FaceGeometry()
Constructor calls the constructor of the underlying ELEMENT.
Definition: macro_element_node_update_element.h:547
Definition: elements.h:4998
Definition: elements.h:1313
virtual void local_coordinate_of_node(const unsigned &j, Vector< double > &s) const
Definition: elements.h:1842
Node *& node_pt(const unsigned &n)
Return a pointer to the local node n.
Definition: elements.h:2175
unsigned nnode() const
Return the number of nodes.
Definition: elements.h:2210
Definition: geom_objects.h:101
Base class for elements that allow MacroElement-based node update.
Definition: macro_element_node_update_element.h:197
virtual ~MacroElementNodeUpdateElementBase()
Virtual destructor (empty)
Definition: macro_element_node_update_element.h:210
unsigned ngeom_object()
Number of geometric objects involved in node update function.
Definition: macro_element_node_update_element.h:220
Vector< GeomObject * > & geom_object_pt()
Definition: macro_element_node_update_element.h:227
Vector< GeomObject * > Geom_object_pt
Definition: macro_element_node_update_element.h:243
MacroElementNodeUpdateElementBase()
Constructor (empty)
Definition: macro_element_node_update_element.h:200
GeomObject * geom_object_pt(const unsigned &i)
Definition: macro_element_node_update_element.h:234
virtual void set_node_update_info(const Vector< GeomObject * > &geom_object_pt)=0
void operator=(const MacroElementNodeUpdateElementBase &)=delete
Broken assignment operator.
MacroElementNodeUpdateElementBase(const MacroElementNodeUpdateElementBase &)=delete
Broken copy constructor.
Definition: macro_element_node_update_element.h:265
~MacroElementNodeUpdateElement()
Empty destructor to clean up allocated memory.
Definition: macro_element_node_update_element.h:288
void rebuild_from_sons(Mesh *&mesh_pt)
Definition: macro_element_node_update_element.h:330
void set_node_update_info(const Vector< GeomObject * > &geom_object_pt)
Broken assignment operator.
Definition: macro_element_node_update_element.h:297
MacroElementNodeUpdateElement(FiniteElement *const &element_pt, const int &face_index)
Constructor used for face elements.
Definition: macro_element_node_update_element.h:275
MacroElementNodeUpdateElement()
Constructor: Call constructor of underlying element.
Definition: macro_element_node_update_element.h:268
MacroElementNodeUpdateElement(const MacroElementNodeUpdateElement &)=delete
Broken copy constructor.
Definition: macro_element_node_update_element.h:360
Vector< GeomObject * > Geom_object_vector_pt
Definition: macro_element_node_update_element.h:524
Domain * Macro_domain_pt
Domain associated with MacroElementNodeUpdateNodeMesh.
Definition: macro_element_node_update_element.h:527
void set_geom_object_vector_pt(Vector< GeomObject * > geom_object_vector_pt)
Definition: macro_element_node_update_element.h:510
MacroElementNodeUpdateMesh(const MacroElementNodeUpdateMesh &)=delete
Broken copy constructor.
MacroElementNodeUpdateMesh()
Constructor (empty)
Definition: macro_element_node_update_element.h:363
void node_update(const bool &update_all_solid_nodes=false)
Definition: macro_element_node_update_element.h:387
virtual ~MacroElementNodeUpdateMesh()
Virtual destructor (empty)
Definition: macro_element_node_update_element.h:366
Vector< GeomObject * > geom_object_vector_pt()
Access function to the vector of GeomObject.
Definition: macro_element_node_update_element.h:516
Domain *& macro_domain_pt()
Broken assignment operator.
Definition: macro_element_node_update_element.h:376
Definition: macro_element_node_update_element.h:49
void node_update(const bool &update_all_time_levels_for_new_node=false)
Definition: macro_element_node_update_element.cc:48
virtual ~MacroElementNodeUpdateNode()
Broken assignment operator.
Definition: macro_element_node_update_element.h:88
MacroElementNodeUpdateNode(const MacroElementNodeUpdateNode &)=delete
Broken copy constructor.
Vector< double > & s_in_node_update_element()
Definition: macro_element_node_update_element.h:109
Vector< GeomObject * > & geom_object_pt()
Definition: macro_element_node_update_element.h:122
MacroElementNodeUpdateNode(const unsigned &n_dim, const unsigned &n_position_type, const unsigned &initial_nvalue)
Definition: macro_element_node_update_element.h:54
MacroElementNodeUpdateNode(TimeStepper *time_stepper_pt, const unsigned &n_dim, const unsigned &n_position_type, const unsigned &initial_nvalue)
Definition: macro_element_node_update_element.h:66
FiniteElement *& node_update_element_pt()
Definition: macro_element_node_update_element.h:101
Vector< double > S_in_node_update_element
Definition: macro_element_node_update_element.h:178
GeomObject * geom_object_pt(const unsigned &i)
Definition: macro_element_node_update_element.h:130
GeomObject ** all_geom_object_pt()
Return all geometric objects that affect the node update.
Definition: macro_element_node_update_element.h:144
Vector< GeomObject * > Geom_object_pt
Definition: macro_element_node_update_element.h:182
unsigned ngeom_object() const
Number of geometric objects involved in node update function.
Definition: macro_element_node_update_element.h:115
FiniteElement * Node_update_element_pt
Definition: macro_element_node_update_element.h:174
void set_node_update_info(FiniteElement *node_update_element_pt, const Vector< double > &s_in_node_update_element, const Vector< GeomObject * > &geom_object_pt)
Definition: macro_element_node_update_element.h:161
Vector< GeomObject * > & vector_geom_object_pt()
Definition: macro_element_node_update_element.h:138
Definition: mesh.h:67
unsigned long nnode() const
Return number of nodes in the mesh.
Definition: mesh.h:596
Node *& node_pt(const unsigned long &n)
Return pointer to global node n.
Definition: mesh.h:436
Definition: nodes.h:906
Definition: communicator.h:54
int nproc() const
number of processors
Definition: communicator.h:157
Definition: oomph_definitions.h:222
Definition: timesteppers.h:231
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
Definition: AnisotropicHookean.h:10
string name
Definition: plotDoE.py:33
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2