refineable_line_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-2023 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 RefineableQElement<1> class
27 #ifndef OOMPH_REFINEABLE_LINE_ELEMENT_HEADER
28 #define OOMPH_REFINEABLE_LINE_ELEMENT_HEADER
29 
30 // Config header generated by autoconfig
31 #ifdef HAVE_CONFIG_H
32 #include <oomph-lib-config.h>
33 #endif
34 
35 // oomph-lib headers
36 #include "binary_tree.h"
37 #include "macro_element.h"
38 #include "refineable_elements.h"
39 #include "Qelements.h"
40 
41 namespace oomph
42 {
43  // Forward definition for mesh.
44  class Mesh;
45 
46  //=======================================================================
47  /// Refineable version of QElement<1,NNODE_1D>.
48  ///
49  /// Refinement is performed by binary tree procedures. When the element
50  /// is subdivided, the geometry of its sons is established by calls to
51  /// their father's \c get_x(...) function which refers to:
52  /// - the father element's geometric FE mapping (this is the default)
53  /// or
54  /// - a MacroElement's MacroElement::macro_map (if the pointer to the
55  /// macro element is non-NULL)
56  ///
57  /// The class provides a generic RefineableQElement<1>::build() function
58  /// which deals with generic isoparametric QElements in which all values
59  /// are associated with nodes. The RefineableQElement<1>::further_build()
60  /// function provides an interface for any element-specific non-generic
61  /// build operations.
62  //=======================================================================
63  template<>
64  class RefineableQElement<1> : public virtual RefineableElement,
65  public virtual LineElementBase
66  {
67  public:
68  /// Shorthand for pointer to an argument-free void member
69  /// function of the refineable element
70  typedef void (RefineableQElement<1>::*VoidMemberFctPt)();
71 
72  /// Constructor: Pass refinement level (default 0 = root)
74  {
75 #ifdef LEAK_CHECK
76  LeakCheckNames::RefineableQElement<1> _build += 1;
77 #endif
78  }
79 
80  /// Broken copy constructor
81  RefineableQElement(const RefineableQElement<1>& dummy) = delete;
82 
83  /// Broken assignment operator
84  // Commented out broken assignment operator because this can lead to a
85  // conflict warning when used in the virtual inheritence hierarchy.
86  // Essentially the compiler doesn't realise that two separate
87  // implementations of the broken function are the same and so, quite
88  // rightly, it shouts.
89  /*void operator=(const RefineableQElement<1>&) = delete;*/
90 
91  /// Destructor
93  {
94 #ifdef LEAK_CHECK
95  LeakCheckNames::RefineableQElement<1> _build -= 1;
96 #endif
97  }
98 
99  /// A refineable line element has two sons
100  unsigned required_nsons() const
101  {
102  return 2;
103  }
104 
105  /// If a neighbouring element has already created a node at a
106  /// position corresponding to the local fractional position within the
107  /// present element, s_fraction, return a pointer to that node. If
108  /// not, return NULL (0). If the node is on a periodic boundary the
109  /// flag is_periodic is true, otherwise it will be false.
110  Node* node_created_by_neighbour(const Vector<double>& s_fraction,
111  bool& is_periodic);
112 
113  /// If a neighbouring element has already created a node at a
114  /// position corresponding to the local fractional position within the
115  /// present element, s_fraction, return a pointer to that node. If
116  /// not, return NULL (0). If the node is on a periodic boundary the
117  /// flag is_periodic is true, otherwise it will be false.
119  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 
127  /// Build the element, i.e. give it nodal positions, apply BCs,
128  /// etc. Pointers to any new nodes will be returned in new_node_pt.
129  /// If it is open, the positions of the new nodes will be written to
130  /// the file stream new_nodes_file.
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 
136  /// Check the integrity of the element: ensure that the position
137  /// and values are continuous across the element edges.
138  void check_integrity(double& max_error);
139 
140  /// Print corner nodes, using colour
141  void output_corners(std::ostream& outfile, const std::string& colour) const;
142 
143  /// Pointer to binary tree representation of this element
145  {
146  return dynamic_cast<BinaryTree*>(Tree_pt);
147  }
148 
149  /// Pointer to binary tree representation of this element (const version)
151  {
152  return dynamic_cast<BinaryTree*>(Tree_pt);
153  }
154 
155  /// Line elements have no hanging nodes so this is deliberately left empty
157 
158  protected:
159  /// Coincidence between son nodal points and father boundaries:
160  /// Father_bound[node_1d](jnod_son,son_type) = {L/R/OMEGA}
161  static std::map<unsigned, DenseMatrix<int>> Father_bound;
162 
163  /// Setup static matrix for coincidence between son nodal points
164  /// and father boundaries
165  void setup_father_bounds();
166 
167  /// Line elements have no hanging nodes so this is deliberately left empty
168  void setup_hang_for_value(const int& value_id) {}
169 
170  /// Line elements have no hanging nodes so this is deliberately left empty
171  void binary_hang_helper(const int& value_id,
172  const int& my_edge,
173  std::ofstream& output_hangfile)
174  {
175  }
176  };
177 
178 
179  //=======================================================================
180  /// Refineable version of Solid line elements
181  //=======================================================================
182  template<>
183  class RefineableSolidQElement<1> : public virtual RefineableQElement<1>,
184  public virtual RefineableSolidElement,
185  public virtual QSolidElementBase
186  {
187  public:
188  /// Constructor, just call the constructor of the RefineableQElement<1>
191  {
192  // Issue a warning about this class
193  std::string warning_message =
194  "The class RefinableSolidQElement<1> has not been implemented or\n";
195  warning_message +=
196  "tested. It is safest to assume that all functions do not do what\n";
197  warning_message +=
198  "they claim to. The `build()' function is deliberately broken.";
199 
200  throw OomphLibWarning(
201  warning_message,
202  "RefineableSolidQElement<1>::RefineableSolidQElement()",
203  OOMPH_EXCEPTION_LOCATION);
204  }
205 
206  /// Broken copy constructor
208 
209  /// Broken assignment operator
210  /*void operator=(const RefineableSolidQElement<1>&) = delete;*/
211 
212  /// Virtual Destructor
214 
215 
216  /// Final over-ride: Use version in QSolidElementBase
217  void set_macro_elem_pt(MacroElement* macro_elem_pt)
218  {
220  }
221 
222  /// Final over-ride: Use version in QSolidElementBase
223  void set_macro_elem_pt(MacroElement* macro_elem_pt,
224  MacroElement* undeformed_macro_elem_pt)
225  {
227  undeformed_macro_elem_pt);
228  }
229 
230  /// Use the generic finite difference routine defined in
231  /// RefineableSolidElement to calculate the Jacobian matrix
232  void get_jacobian(Vector<double>& residuals, DenseMatrix<double>& jacobian)
233  {
234  RefineableSolidElement::get_jacobian(residuals, jacobian);
235  }
236 
237  /// Build the element, i.e. give it nodal positions, apply BCs, etc.
238  /// Incl. documention into new_nodes_file
239  // NOTE: FOR SOME REASON THIS NEEDS TO LIVE IN *.H TO WORK ON INTEL
240  void build(Mesh*& mesh_pt,
241  Vector<Node*>& new_node_pt,
242  bool& was_already_built,
243  std::ofstream& new_nodes_file)
244  {
245  throw OomphLibError("This function has not been implemented yet:",
246  OOMPH_CURRENT_FUNCTION,
247  OOMPH_EXCEPTION_LOCATION);
248  }
249  };
250 
251 } // namespace oomph
252 
253 #endif
BinaryTree class: Recursively defined, generalised binary tree.
Definition: binary_tree.h:92
virtual void get_jacobian(Vector< double > &residuals, DenseMatrix< double > &jacobian)
Calculate the elemental Jacobian matrix "d equation / d variable".
Definition: elements.h:990
Base class for all line elements.
Definition: Qelements.h:466
Base class for MacroElement s that are used during mesh refinement in domains with curvlinear and/or ...
Definition: macro_element.h:73
A general mesh class.
Definition: mesh.h:67
Nodes are derived from Data, but, in addition, have a definite (Eulerian) position in a space of a gi...
Definition: nodes.h:906
An OomphLibError object which should be thrown when an run-time error is encountered....
An OomphLibWarning object which should be created as a temporary object to issue a warning....
/////////////////////////////////////////////////////////////////////// /////////////////////////////...
Definition: Qelements.h:331
virtual void set_macro_elem_pt(MacroElement *macro_elem_pt)
Broken assignment operator.
Definition: Qelements.h:349
RefineableElements are FiniteElements that may be subdivided into children to provide a better local ...
Refineable version of QElement<1,NNODE_1D>.
Node * node_created_by_son_of_neighbour(const Vector< double > &s_fraction, bool &is_periodic)
If a neighbouring element has already created a node at a position corresponding to the local fractio...
unsigned required_nsons() const
A refineable line element has two sons.
RefineableQElement(const RefineableQElement< 1 > &dummy)=delete
Broken copy constructor.
BinaryTree * binary_tree_pt() const
Pointer to binary tree representation of this element (const version)
static std::map< unsigned, DenseMatrix< int > > Father_bound
Coincidence between son nodal points and father boundaries: Father_bound[node_1d](jnod_son,...
void setup_hanging_nodes(Vector< std::ofstream * > &output_stream)
Line elements have no hanging nodes so this is deliberately left empty.
void binary_hang_helper(const int &value_id, const int &my_edge, std::ofstream &output_hangfile)
Line elements have no hanging nodes so this is deliberately left empty.
RefineableQElement()
Constructor: Pass refinement level (default 0 = root)
BinaryTree * binary_tree_pt()
Pointer to binary tree representation of this element.
void setup_hang_for_value(const int &value_id)
Line elements have no hanging nodes so this is deliberately left empty.
virtual ~RefineableQElement()
Broken assignment operator.
A class that is used to template the refineable Q elements by dimension. It's really nothing more tha...
Definition: Qelements.h:2259
/////////////////////////////////////////////////////////////////// /////////////////////////////////...
Refineable version of Solid line elements.
RefineableSolidQElement()
Constructor, just call the constructor of the RefineableQElement<1>
void build(Mesh *&mesh_pt, Vector< Node * > &new_node_pt, bool &was_already_built, std::ofstream &new_nodes_file)
Build the element, i.e. give it nodal positions, apply BCs, etc. Incl. documention into new_nodes_fil...
RefineableSolidQElement(const RefineableSolidQElement< 1 > &dummy)=delete
Broken copy constructor.
void get_jacobian(Vector< double > &residuals, DenseMatrix< double > &jacobian)
Use the generic finite difference routine defined in RefineableSolidElement to calculate the Jacobian...
void set_macro_elem_pt(MacroElement *macro_elem_pt, MacroElement *undeformed_macro_elem_pt)
Final over-ride: Use version in QSolidElementBase.
virtual ~RefineableSolidQElement()
Broken assignment operator.
void set_macro_elem_pt(MacroElement *macro_elem_pt)
Final over-ride: Use version in QSolidElementBase.
A class that is used to template the solid refineable Q elements by dimension. It's really nothing mo...
Definition: Qelements.h:2286
std::string string(const unsigned &i)
Return the i-th string or "" if the relevant string hasn't been defined.
long RefineableQElement< 2 > _build
Vector< std::string > colour
Tecplot colours.
//////////////////////////////////////////////////////////////////// ////////////////////////////////...