perturbed_spines.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 // Header file for perturbed spine nodes, elements and meshes
27 
28 #ifndef OOMPH_PERTURBED_SPINES_HEADER
29 #define OOMPH_PERTURBED_SPINES_HEADER
30 
31 // oomph-lib includes
32 #include "generic.h"
33 
34 namespace oomph
35 {
36 
37  // Forward declaration
38  class PerturbedSpineNode;
39 
40 //=======================================================================
47 //=======================================================================
49 {
50 
51  public:
52 
57  {
58  Geom_data_pt.resize(1);
59 
60  // Create Data for the two "heights". By default they are free
61  Geom_data_pt[0] = new Data(2);
62  }
63 
67  PerturbedSpine(TimeStepper* const &time_stepper_pt,
69  {
70  Geom_data_pt.resize(1);
71 
72  // Create Data for the two "heights". By default they are free
73  Geom_data_pt[0] = new Data(time_stepper_pt,2);
74  }
75 
80  const double& height) : Base_spine_pt(base_spine_pt)
81  {
82  Geom_data_pt.resize(1);
83 
84  // Create Data for the two "heights". By default they are free
85  Geom_data_pt[0] = new Data(2);
86 
87  // Set value
88  for(unsigned i=0;i<2;i++) { Geom_data_pt[0]->set_value(i,height); }
89  }
90 
95  ~PerturbedSpine() { delete Geom_data_pt[0]; }
96 
99 
101  double& height(const unsigned& i)
102  {
103  return *(Geom_data_pt[0]->value_pt(i));
104  }
105 
108  double& height(const unsigned& t, const unsigned& i)
109  {
110  return *(Geom_data_pt[0]->value_pt(t,i));
111  }
112 
114  Data*& height_pt() { return Geom_data_pt[0]; }
115 
118  Data* height_pt() const { return Geom_data_pt[0]; }
119 
122  {
124  }
125 
129  {
131  }
132 
135  {
137  }
138 
142  {
144  }
145 
148  unsigned ngeom_data() { return Geom_data_pt.size(); }
149 
154  {
155  unsigned n_geom_data=geom_data_pt.size();
156  Geom_data_pt.resize(n_geom_data+1);
157  for (unsigned i=1;i<n_geom_data;i++)
158  {
160  }
161  }
162 
166  {
167  Geom_data_pt.push_back(geom_data_pt);
168  }
169 
172  Data*& geom_data_pt(const unsigned& i){return Geom_data_pt[i];}
173 
176  Data* geom_data_pt(const unsigned& i) const {return Geom_data_pt[i];}
177 
180 
183  unsigned ngeom_object(){return Geom_object_pt.size();}
184 
188  {
189  unsigned n_geom_object=geom_object_pt.size();
190  Geom_object_pt.resize(n_geom_object);
191  for (unsigned i=0;i<n_geom_object;i++)
192  {
194  }
195  }
196 
200  {
201  Geom_object_pt.push_back(geom_object_pt);
202  }
203 
206  GeomObject*& geom_object_pt(const unsigned& i) { return Geom_object_pt[i]; }
207 
210  GeomObject* geom_object_pt(const unsigned& i) const
211  {
212  return Geom_object_pt[i];
213  }
214 
217 
220  unsigned ngeom_parameter() { return Geom_parameter.size(); }
221 
227 
230  void add_geom_parameter(const double &geom_parameter)
231  { Geom_parameter.push_back(geom_parameter); }
232 
235  double& geom_parameter(const unsigned& i)
236  { return Geom_parameter[i]; }
237 
240  const double &geom_parameter(const unsigned& i) const
241  { return Geom_parameter[i]; }
242 
243 
244  private:
245 
248 
251 
255 
259 
264 
265 }; // End of PerturbedSpine class definition
266 
267 
268 
269 // Forward declaration
270 class PerturbedSpineMesh;
271 
272 //=======================================================================
274 //=======================================================================
275 class PerturbedSpineNode : public Node
276 {
277  private:
278 
281 
283  double Fraction;
284 
288 
292 
293 
294  public:
295 
297  PerturbedSpineNode(const unsigned &n_dim,
298  const unsigned &n_position_type,
299  const unsigned &initial_nvalue) :
300  Node(n_dim,n_position_type,initial_nvalue),
303 
306  const unsigned &n_dim,
307  const unsigned &n_position_type,
308  const unsigned &initial_nvalue) :
309  Node(time_stepper_pt,n_dim,n_position_type,initial_nvalue),
312 
315 
317  double &fraction() { return Fraction; }
318 
320  unsigned& node_update_fct_id() { return Node_update_fct_id; }
321 
325 
327  double &h(const unsigned& i) { return PerturbedSpine_pt->height(i); }
328 
331  void node_update(const bool& update_all_time_levels_for_new_node=false);
332 
334  unsigned ngeom_data() const
335  {
337  else { return 0; }
338  }
339 
341  unsigned ngeom_object() const
342  {
344  else { return 0; }
345  }
346 
349 
352  {
353  return &(PerturbedSpine_pt->geom_object_pt(0));
354  }
355 
356 }; // End of PerturbedSpineNode class definition
357 
358 
359 
363 
364 
365 
366 //=======================================================================
369 //=======================================================================
371 {
372  public:
373 
376 
379 
380 };
381 
382 
383 
384 //=======================================================================
390 //=======================================================================
391 template<class ELEMENT>
393 public ElementWithSpecificMovingNodes<ELEMENT,PerturbedSpineNode>,
395 {
396  private:
397 
401 
409 
410 
411  public:
412 
418 
421  const int &face_index) :
423  face_index),
426 
429  {
431  {
433  }
434  }
435 
438  inline int spine_local_eqn(const unsigned &n, const unsigned &i)
439  {
440 #ifdef RANGE_CHECKING
441  const unsigned n_node = this->nnode();
442  if(n >= n_node)
443  {
444  std::ostringstream error_message;
445  error_message << "Range Error: Node number " << n
446  << " is not in the range (0,"
447  << n_node-1 << ")";
448  throw OomphLibError(error_message.str(),
449  "PerturbedSpineElement::spine_local_eqn()",
451  }
452 #endif
453 
454 #ifdef PARANOID
455  // The perturbed spine "height" only has two components
456  if(i>=2)
457  {
458  std::ostringstream error_message;
459  error_message << "Perturbed spines only have two height components:"
460  << "\nComponent i=" << i
461  << " is not in the range (0,2)";
462  throw OomphLibError(error_message.str(),
463  "PerturbedSpineElement::spine_local_eqn()",
465  }
466  // If there is no spine then you can't get the local equation
468  {
469  std::ostringstream error_stream;
470  error_stream
471  << "PerturbedSpineNode " << n << " does not have a PerturbedSpine\n"
472  << "attached, so you can't get its local equation number. Check that\n"
473  << "the Mesh is correctly associating PerturbedSpines with is Nodes\n";
474  throw OomphLibError(error_stream.str(),
475  "PerturbedSpineElement<ELEMENT>::spine_local_eqn()",
477  }
478 #endif
479  return this->geometric_data_local_eqn(PerturbedSpine_geometric_index[n],i);
480  }
481 
482 
486  const unsigned &n, const unsigned &i)
487  {
488  return this->spine_local_eqn(n,i);
489  }
490 
491 }; // End of PerturbedSpineElement<ELEMENT> class definition
492 
493 
494 
495 //=======================================================================
498 //=======================================================================
499 template<class ELEMENT>
501 public virtual FaceGeometry<ELEMENT>
502 {
503  public:
504 
506  FaceGeometry() : FaceGeometry<ELEMENT>() {}
507 };
508 
509 //=======================================================================
512 //=======================================================================
513 template<class ELEMENT>
515 public virtual FaceGeometry<FaceGeometry<ELEMENT> >
516 {
517  public:
518 
521 };
522 
523 //=======================================================================
526 //=======================================================================
527 template<class ELEMENT>
529 public virtual FaceGeometry<FaceGeometry<ELEMENT> >
530 {
531  public:
532 
535 };
536 
537 
538 
542 
543 
544 
545 //========================================================================
551 //========================================================================
552 class PerturbedSpineMesh : public virtual Mesh
553 {
554  protected:
555 
558 
559  public:
560 
563  {
564  // Set the range of PerturbedSpine_pt
565  unsigned long PerturbedSpine_pt_range = PerturbedSpine_pt.size();
566 
567  // Loop over the entries in reverse and free memory
568  for(unsigned long i=PerturbedSpine_pt_range;i>0;i--)
569  {
570  delete PerturbedSpine_pt[i-1]; PerturbedSpine_pt[i-1] = 0;
571  }
572  }
573 
575  PerturbedSpine* const & perturbed_spine_pt(const unsigned long &i) const
576  {
577  return PerturbedSpine_pt[i];
578  }
579 
581  unsigned long nspine() const { return PerturbedSpine_pt.size(); }
582 
584  void add_perturbed_spine_pt(PerturbedSpine* const &spine_pt)
585  {
586  PerturbedSpine_pt.push_back(spine_pt);
587  }
588 
590  PerturbedSpineNode* node_pt(const unsigned long &n)
591  {
592 #ifdef PARANOID
593  if(!dynamic_cast<PerturbedSpineNode*>(Node_pt[n]))
594  {
595  std::ostringstream error_message;
596  error_message << "Node " << n << "is a "
597  << typeid(Node_pt[n]).name()
598  << ", not a PerturbedSpineNode" << std::endl;
599 
600  throw OomphLibError(error_message.str(),
601  "PerturbedSpineMesh::node_pt()",
603  }
604 #endif
605 
606  // Return a cast to the pointer to the node
607  return (dynamic_cast<PerturbedSpineNode*>(Node_pt[n]));
608  }
609 
613  PerturbedSpineNode* element_node_pt(const unsigned long &e,
614  const unsigned &n)
615  {
616 #ifdef PARANOID
617  // Try to cast to FiniteElement
618  FiniteElement* el_pt=dynamic_cast<FiniteElement*>(Element_pt[e]);
619  if (el_pt==0)
620  {
621  throw OomphLibError(
622  "Can't execute element_node_pt(...) for non FiniteElements",
623  "PerturbedSpineMesh::element_node_pt()",
625  }
626  if(!dynamic_cast<PerturbedSpineNode*>(el_pt->node_pt(n)))
627  {
628  std::ostringstream error_message;
629  error_message << "Node " << n << "is a "
630  << typeid(el_pt->node_pt(n)).name()
631  << ", not a PerturbedSpineNode" << std::endl;
632 
633  throw OomphLibError(error_message.str(),
634  "PerturbedSpineMesh::node_pt()",
636  }
637 #endif
638  // Return a cast to the node pointer
639  return(dynamic_cast<PerturbedSpineNode*>(
640  dynamic_cast<FiniteElement*>(Element_pt[e])->node_pt(n)));
641  }
642 
644  unsigned long assign_global_eqn_numbers(Vector<double *> &Dof_pt);
645 
650  void node_update(const bool& update_all_solid_nodes=false);
651 
654  virtual void perturbed_spine_node_update(PerturbedSpineNode* spine_node_pt)=0;
655 
657  void dump(std::ofstream &dump_file,const bool &use_old_ordering=true) const;
658 
661  void read(std::ifstream &restart_file);
662 
663 }; // End of PerturbedSpineMesh class definition
664 
665 
666 
667 
668 } // End of oomph namespace
669 
670 #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.)
Definition: nodes.h:86
TimeStepper *& time_stepper_pt()
Return the pointer to the timestepper.
Definition: nodes.h:238
int geometric_data_local_eqn(const unsigned &n, const unsigned &i)
Definition: element_with_moving_nodes.h:126
unsigned ngeom_data() const
Definition: element_with_moving_nodes.h:345
Definition: element_with_moving_nodes.h:382
FaceGeometry()
Constructor.
Definition: perturbed_spines.h:520
FaceGeometry()
Constructor.
Definition: perturbed_spines.h:506
FaceGeometry()
Constructor.
Definition: perturbed_spines.h:534
Definition: elements.h:4998
Definition: elements.h:1313
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
Definition: mesh.h:67
Vector< Node * > Node_pt
Vector of pointers to nodes.
Definition: mesh.h:183
Vector< GeneralisedElement * > Element_pt
Vector of pointers to generalised elements.
Definition: mesh.h:186
Definition: nodes.h:906
Definition: oomph_definitions.h:222
Definition: perturbed_spines.h:395
PerturbedSpineElement()
Constructor, call the constructor of the base element.
Definition: perturbed_spines.h:414
PerturbedSpineElement(FiniteElement *const &element_pt, const int &face_index)
Constructor used for spine face elements.
Definition: perturbed_spines.h:420
virtual int get_local_eqn_number_corresponding_to_geometric_dofs(const unsigned &n, const unsigned &i)
Definition: perturbed_spines.h:485
void complete_setup_of_dependencies()
Construct and fill the node_update_data vector.
Definition: perturbed_spines.cc:76
~PerturbedSpineElement()
Destructor, clean up the storage allocated to the local equation numbers.
Definition: perturbed_spines.h:428
unsigned * PerturbedSpine_geometric_index
Definition: perturbed_spines.h:400
int spine_local_eqn(const unsigned &n, const unsigned &i)
Definition: perturbed_spines.h:438
Definition: perturbed_spines.h:371
PerturbedSpineFiniteElement()
Empty constructor.
Definition: perturbed_spines.h:375
virtual ~PerturbedSpineFiniteElement()
Emtpty virtual destructor.
Definition: perturbed_spines.h:378
Definition: perturbed_spines.h:553
void node_update(const bool &update_all_solid_nodes=false)
Definition: perturbed_spines.cc:147
void dump(std::ofstream &dump_file, const bool &use_old_ordering=true) const
Overload the dump function so that the spine data is dumped.
Definition: perturbed_spines.cc:216
void add_perturbed_spine_pt(PerturbedSpine *const &spine_pt)
Add a perturbed spine to the mesh.
Definition: perturbed_spines.h:584
unsigned long assign_global_eqn_numbers(Vector< double * > &Dof_pt)
Assign equation numbers for perturbed spines.
Definition: perturbed_spines.cc:192
virtual ~PerturbedSpineMesh()
Destructor to clean up the memory allocated to the perturbed spines.
Definition: perturbed_spines.h:562
unsigned long nspine() const
Return the number of perturbed spines in the mesh.
Definition: perturbed_spines.h:581
virtual void perturbed_spine_node_update(PerturbedSpineNode *spine_node_pt)=0
PerturbedSpineNode * element_node_pt(const unsigned long &e, const unsigned &n)
Definition: perturbed_spines.h:613
Vector< PerturbedSpine * > PerturbedSpine_pt
A PerturbedSpine mesh contains a Vector of pointers to perturbed spines.
Definition: perturbed_spines.h:557
PerturbedSpineNode * node_pt(const unsigned long &n)
Return a pointer to the n-th global PerturbedSpineNode.
Definition: perturbed_spines.h:590
PerturbedSpine *const & perturbed_spine_pt(const unsigned long &i) const
Return the i-th perturbed spine in the mesh.
Definition: perturbed_spines.h:575
void read(std::ifstream &restart_file)
Overload the read function so that the spine data is also read.
Definition: perturbed_spines.cc:244
Class for nodes that ‘live’ on perturbed spines.
Definition: perturbed_spines.h:276
PerturbedSpineMesh * PerturbedSpine_mesh_pt
Definition: perturbed_spines.h:287
GeomObject ** all_geom_object_pt()
Return the vector of all geometric objects.
Definition: perturbed_spines.h:351
unsigned ngeom_object() const
Return the number of geometric objects, zero if no spine.
Definition: perturbed_spines.h:341
void node_update(const bool &update_all_time_levels_for_new_node=false)
Definition: perturbed_spines.cc:50
unsigned Node_update_fct_id
Definition: perturbed_spines.h:291
unsigned & node_update_fct_id()
Access function to ID of node update function (within specific mesh)
Definition: perturbed_spines.h:320
double Fraction
Private double that represents the fixed fraction along the spine.
Definition: perturbed_spines.h:283
PerturbedSpineNode(TimeStepper *const &time_stepper_pt, const unsigned &n_dim, const unsigned &n_position_type, const unsigned &initial_nvalue)
Unsteady Constructor, initialise pointers to zero.
Definition: perturbed_spines.h:305
double & fraction()
Set reference to fraction along spine.
Definition: perturbed_spines.h:317
double & h(const unsigned &i)
Access function to i-th component of spine "height".
Definition: perturbed_spines.h:327
PerturbedSpine *& perturbed_spine_pt()
Access function to perturbed spine.
Definition: perturbed_spines.h:314
PerturbedSpine * PerturbedSpine_pt
Private internal data pointer to a perturbed spine.
Definition: perturbed_spines.h:280
unsigned ngeom_data() const
Return the number of geometric data, zero if no spine.
Definition: perturbed_spines.h:334
Data ** all_geom_data_pt()
Return the vector of all geometric data.
Definition: perturbed_spines.h:348
PerturbedSpineNode(const unsigned &n_dim, const unsigned &n_position_type, const unsigned &initial_nvalue)
Steady Constructor, initialise pointers to zero.
Definition: perturbed_spines.h:297
PerturbedSpineMesh *& spine_mesh_pt()
Definition: perturbed_spines.h:324
Definition: perturbed_spines.h:49
unsigned ngeom_object()
Definition: perturbed_spines.h:183
PerturbedSpineNode *& node_at_bottom_of_spine_pt()
Access function to SpineNode at bottom of spine.
Definition: perturbed_spines.h:121
Data *& height_pt()
Access function to Data object that stores the spine "heights".
Definition: perturbed_spines.h:114
void add_geom_object_pt(GeomObject *geom_object_pt)
Definition: perturbed_spines.h:199
Vector< GeomObject * > Geom_object_pt
Definition: perturbed_spines.h:254
PerturbedSpine(Spine *&base_spine_pt)
Definition: perturbed_spines.h:56
double & height(const unsigned &t, const unsigned &i)
Definition: perturbed_spines.h:108
unsigned ngeom_data()
Definition: perturbed_spines.h:148
Vector< Data * > & vector_geom_data_pt()
Return the vector of geometric data.
Definition: perturbed_spines.h:179
~PerturbedSpine()
Definition: perturbed_spines.h:95
void add_geom_parameter(const double &geom_parameter)
Definition: perturbed_spines.h:230
Data *& geom_data_pt(const unsigned &i)
Definition: perturbed_spines.h:172
Data * height_pt() const
Definition: perturbed_spines.h:118
Spine *& base_spine_pt()
Access function to pointer to base spine.
Definition: perturbed_spines.h:98
Vector< double > Geom_parameter
Definition: perturbed_spines.h:258
PerturbedSpineNode * node_at_top_of_spine_pt() const
Definition: perturbed_spines.h:141
PerturbedSpineNode * node_at_bottom_of_spine_pt() const
Definition: perturbed_spines.h:128
double & height(const unsigned &i)
Access function to i-th component of spine "height".
Definition: perturbed_spines.h:101
void set_geom_parameter(const Vector< double > &geom_parameter)
Definition: perturbed_spines.h:225
PerturbedSpine(Spine *&base_spine_pt, const double &height)
Definition: perturbed_spines.h:79
GeomObject * geom_object_pt(const unsigned &i) const
Definition: perturbed_spines.h:210
void set_geom_data_pt(const Vector< Data * > &geom_data_pt)
Definition: perturbed_spines.h:153
GeomObject *& geom_object_pt(const unsigned &i)
Definition: perturbed_spines.h:206
PerturbedSpine(TimeStepper *const &time_stepper_pt, Spine *&base_spine_pt)
Definition: perturbed_spines.h:67
PerturbedSpineNode * Node_at_top_of_spine_pt
Definition: perturbed_spines.h:263
void add_geom_data_pt(Data *geom_data_pt)
Definition: perturbed_spines.h:165
const double & geom_parameter(const unsigned &i) const
Definition: perturbed_spines.h:240
Spine * Base_spine_pt
Pointer to corresponding (real) spine in the base problem.
Definition: perturbed_spines.h:247
void set_geom_object_pt(const Vector< GeomObject * > &geom_object_pt)
Definition: perturbed_spines.h:187
double & geom_parameter(const unsigned &i)
Definition: perturbed_spines.h:235
unsigned ngeom_parameter()
Definition: perturbed_spines.h:220
PerturbedSpineNode * Node_at_bottom_of_spine_pt
Definition: perturbed_spines.h:262
PerturbedSpineNode *& node_at_top_of_spine_pt()
Access function to SpineNode at top of spine.
Definition: perturbed_spines.h:134
Vector< GeomObject * > & vector_geom_object_pt()
Return vector of all geometric objects that affect this spine.
Definition: perturbed_spines.h:216
Vector< Data * > Geom_data_pt
Vector that stores the pointers to additional geometric Data.
Definition: perturbed_spines.h:250
Data * geom_data_pt(const unsigned &i) const
Definition: perturbed_spines.h:176
Definition: spines.h:64
Definition: timesteppers.h:231
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
Definition: AnisotropicHookean.h:10
string name
Definition: plotDoE.py:33
t
Definition: plotPSD.py:36
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61