hp_refineable_elements.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// Version 1.0; svn revision $LastChangedRevision$
7 //LIC//
8 //LIC// $LastChangedDate$
9 //LIC//
10 //LIC// Copyright (C) 2006-2016 Matthias Heil and Andrew Hazel
11 //LIC//
12 //LIC// This library is free software; you can redistribute it and/or
13 //LIC// modify it under the terms of the GNU Lesser General Public
14 //LIC// License as published by the Free Software Foundation; either
15 //LIC// version 2.1 of the License, or (at your option) any later version.
16 //LIC//
17 //LIC// This library is distributed in the hope that it will be useful,
18 //LIC// but WITHOUT ANY WARRANTY; without even the implied warranty of
19 //LIC// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 //LIC// Lesser General Public License for more details.
21 //LIC//
22 //LIC// You should have received a copy of the GNU Lesser General Public
23 //LIC// License along with this library; if not, write to the Free Software
24 //LIC// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 //LIC// 02110-1301 USA.
26 //LIC//
27 //LIC// The authors may be contacted at oomph-lib@maths.man.ac.uk.
28 //LIC//
29 //LIC//====================================================================
30 //Header file for classes that define hp-refineable element objects
31 
32 //Include guard to prevent multiple inclusions of the header
33 #ifndef OOMPH_HP_REFINEABLE_ELEMENTS_HEADER
34 #define OOMPH_HP_REFINEABLE_ELEMENTS_HEADER
35 
36 // Config header generated by autoconfig
37 #ifdef HAVE_CONFIG_H
38  #include <oomph-lib-config.h>
39 #endif
40 
41 #include "refineable_elements.h"
45 #include "mesh.h"
46 
47 namespace oomph
48 {
49 //======================================================================
50 /// p-refineable version of RefineableQElement<1,INITIAL_NNODE_1D>.
51 /// Generic class definitions
52 //======================================================================
53 template<unsigned INITIAL_NNODE_1D>
54 class PRefineableQElement<1,INITIAL_NNODE_1D> : public RefineableQElement<1>,
55  public virtual QElement<1,INITIAL_NNODE_1D>,
56  public virtual PRefineableElement
57  {
58 public:
59 
60  /// Constructor
62  {}
63 
64  /// Destructor
65  virtual ~PRefineableQElement() {}
66 
67  /// \short Initial setup of element (set the correct p-order and
68  /// integration scheme) If an adopted father is specified, information
69  /// from this is used instead of using the father found from the tree.
70  void initial_setup(Tree* const &adopted_father_pt=0, const unsigned &initial_p_order=0);
71 
72  /// \short Pre-build (search father for required nodes which may already
73  /// exist)
74  void pre_build(Mesh*& mesh_pt, Vector<Node*>& new_node_pt);
75 
76  /// \short p-refine the element (refine if inc>0, unrefine if inc<0).
77  void p_refine(const int &inc,
78  Mesh* const &mesh_pt,
79  GeneralisedElement* const &clone_pt);
80 
81  /// Overload the shape functions
82  void shape(const Vector<double> &s, Shape &psi) const;
83 
84  void dshape_local(const Vector<double> &s, Shape &psi, DShape &dpsi) const;
85 
86  void d2shape_local(const Vector<double> &s, Shape &psi, DShape &dpsids,
87  DShape &d2psids) const;
88 
89  /// \short Perform additional hanging node procedures for variables
90  /// that are not interpolated by all nodes (e.g. lower order interpolations
91  /// for the pressure in Taylor Hood).
93 
94  /// \short Returns the number of nodes along each edge of the element.
95  /// Overloaded to return the (variable) p-order rather than the template
96  /// argument.
97  unsigned nnode_1d() const {return this->p_order();}
98 
99  /// Get the initial P_order
100  unsigned initial_p_order() const {return INITIAL_NNODE_1D;}
101 
102  // Overloaded from QElement<1,NNODE_1D> to use nnode_1d() instead of
103  // template argument.
104  Node* get_node_at_local_coordinate(const Vector<double> &s) const;
105 
106  Node* node_created_by_son_of_neighbour(const Vector<double> &s_fraction,
107  bool &is_periodic);
108 
109  // Overload nodal positions -- these elements have GLL-spaced nodes.
110  /// Get local coordinates of node j in the element; vector sets its own size
111  void local_coordinate_of_node(const unsigned& n, Vector<double>& s) const;
112 
113  /// Get the local fractino of node j in the element
114  void local_fraction_of_node(const unsigned &n, Vector<double> &s_fraction);
115 
116  /// The local one-d fraction is the same
117  double local_one_d_fraction_of_node(const unsigned &n1d, const unsigned &i);
118 
119  /// Rebuild the element. This needs to find any nodes in the sons which
120  /// are still required.
121  void rebuild_from_sons(Mesh* &mesh_pt);
122 
123  /// \short Check the integrity of interpolated values across element
124  /// boundaries.
125  void check_integrity(double& max_error);
126 
127 protected:
128 
129  /// \short Set up hanging node information. Empty for 1D elements.
130  void binary_hang_helper(const int &value_id, const int &my_edge,
131  std::ofstream& output_hangfile);
132 
133 };
134 
135 //=======================================================================
136 /// p-refineable version of RefineableQElement<2,INITIAL_NNODE_1D>.
137 //=======================================================================
138 template<unsigned INITIAL_NNODE_1D>
139 class PRefineableQElement<2,INITIAL_NNODE_1D> : public RefineableQElement<2>,
140  public virtual QElement<2,INITIAL_NNODE_1D>,
141  public virtual PRefineableElement
142  {
143 public:
144 
145  /// Constructor
147  {}
148 
149  /// Destructor
150  virtual ~PRefineableQElement() {}
151 
152  /// \short Initial setup of element (set the correct p-order and
153  /// integration scheme) If an adopted father is specified, information
154  /// from this is used instead of using the father found from the tree.
155  void initial_setup(Tree* const &adopted_father_pt=0, const unsigned &initial_p_order=0);
156 
157  /// \short Pre-build (search father for required nodes which may already
158  /// exist)
159  void pre_build(Mesh*& mesh_pt, Vector<Node*>& new_node_pt);
160 
161  /// \short p-refine the element (refine if inc>0, unrefine if inc<0).
162  void p_refine(const int &inc,
163  Mesh* const &mesh_pt,
164  GeneralisedElement* const &clone_pt);
165 
166  /// Overload the shape functions
167  void shape(const Vector<double> &s, Shape &psi) const;
168 
169  void dshape_local(const Vector<double> &s, Shape &psi, DShape &dpsi) const;
170 
171  void d2shape_local(const Vector<double> &s, Shape &psi, DShape &dpsids,
172  DShape &d2psids) const;
173 
174  /// \short Perform additional hanging node procedures for variables
175  /// that are not interpolated by all nodes (e.g. lower order interpolations
176  /// for the pressure in Taylor Hood).
178 
179  /// \short Returns the number of nodes along each edge of the element.
180  /// Overloaded to return the (variable) p-order rather than the template
181  /// argument.
182  unsigned nnode_1d() const {return this->p_order();}
183 
184  /// Get the initial P_order
185  unsigned initial_p_order() const {return INITIAL_NNODE_1D;}
186 
187  // Overloaded from QElement<2,NNODE_1D> to use nnode_1d() instead of
188  // template argument.
189  Node* get_node_at_local_coordinate(const Vector<double> &s) const;
190 
191  Node* node_created_by_neighbour(const Vector<double> &s_fraction,
192  bool &is_periodic);
193 
194  Node* node_created_by_son_of_neighbour(const Vector<double> &s_fraction,
195  bool &is_periodic);
196 
197  // Overload nodal positions -- these elements have GLL-spaced nodes.
198  /// Get local coordinates of node j in the element; vector sets its own size
199  void local_coordinate_of_node(const unsigned& n, Vector<double>& s) const;
200 
201  /// Get the local fractino of node j in the element
202  void local_fraction_of_node(const unsigned &n, Vector<double> &s_fraction);
203 
204  /// The local one-d fraction is the same
205  double local_one_d_fraction_of_node(const unsigned &n1d, const unsigned &i);
206 
207  /// Rebuild the element. This needs to find any nodes in the sons which
208  /// are still required.
209  void rebuild_from_sons(Mesh* &mesh_pt);
210 
211  /// \short Check the integrity of interpolated values across element
212  /// boundaries.
213  /// Note: with the mortar method, continuity is enforced weakly across non-
214  /// conforming element boundaries, so it makes no sense to check the
215  /// continuity of interpolated values across these boundaries.
216  void check_integrity(double& max_error);
217 
218 protected:
219 
220  /// \short Set up hanging node information.
221  /// Overloaded to implement the mortar method rather than constrained
222  /// approximation. This enforces continuity weakly via an integral matching
223  /// condition at non-conforming element boundaries.
224  void quad_hang_helper(const int &value_id, const int &my_edge,
225  std::ofstream& output_hangfile);
226 
227 };
228 
229 //=======================================================================
230 /// p-refineable version of RefineableQElement<3,INITIAL_NNODE_1D>.
231 //=======================================================================
232 template<unsigned INITIAL_NNODE_1D>
233 class PRefineableQElement<3,INITIAL_NNODE_1D> : public RefineableQElement<3>,
234  public virtual QElement<3,INITIAL_NNODE_1D>,
235  public virtual PRefineableElement
236  {
237 public:
238 
239  /// Constructor
241  {}
242 
243  /// Destructor
244  virtual ~PRefineableQElement() {}
245 
246  /// \short Initial setup of element (set the correct p-order and
247  /// integration scheme) If an adopted father is specified, information
248  /// from this is used instead of using the father found from the tree.
249  void initial_setup(Tree* const &adopted_father_pt=0, const unsigned &initial_p_order=0);
250 
251  /// \short Pre-build (search father for required nodes which may already
252  /// exist)
253  void pre_build(Mesh*& mesh_pt, Vector<Node*>& new_node_pt);
254 
255  /// \short p-refine the element (refine if inc>0, unrefine if inc<0).
256  void p_refine(const int &inc,
257  Mesh* const &mesh_pt,
258  GeneralisedElement* const &clone_pt);
259 
260  /// Overload the shape functions
261  void shape(const Vector<double> &s, Shape &psi) const;
262 
263  void dshape_local(const Vector<double> &s, Shape &psi, DShape &dpsi) const;
264 
265  void d2shape_local(const Vector<double> &s, Shape &psi, DShape &dpsids,
266  DShape &d2psids) const;
267 
268  /// \short Perform additional hanging node procedures for variables
269  /// that are not interpolated by all nodes (e.g. lower order interpolations
270  /// for the pressure in Taylor Hood).
272 
273  /// \short Returns the number of nodes along each edge of the element.
274  /// Overloaded to return the (variable) p-order rather than the template
275  /// argument.
276  unsigned nnode_1d() const {return this->p_order();}
277 
278  /// Get the initial P_order
279  unsigned initial_p_order() const {return INITIAL_NNODE_1D;}
280 
281  // Overloaded from QElement<3,NNODE_1D> to use nnode_1d() instead of
282  // template argument.
283  Node* get_node_at_local_coordinate(const Vector<double> &s) const;
284 
285  Node* node_created_by_neighbour(const Vector<double> &s_fraction);
286 
287  Node* node_created_by_son_of_neighbour(const Vector<double> &s_fraction);
288 
289  // Overload nodal positions -- these elements have GLL-spaced nodes.
290  /// Get local coordinates of node j in the element; vector sets its own size
291  void local_coordinate_of_node(const unsigned& n, Vector<double>& s) const;
292 
293  /// Get the local fractino of node j in the element
294  void local_fraction_of_node(const unsigned &n, Vector<double> &s_fraction);
295 
296  /// The local one-d fraction is the same
297  double local_one_d_fraction_of_node(const unsigned &n1d, const unsigned &i);
298 
299  /// Rebuild the element. This needs to find any nodes in the sons which
300  /// are still required.
301  void rebuild_from_sons(Mesh* &mesh_pt);
302 
303  /// \short Check the integrity of interpolated values across element
304  /// boundaries.
305  /// Note: with the mortar method, continuity is enforced weakly across non-
306  /// conforming element boundaries, so it makes no sense to check the
307  /// continuity of interpolated values across these boundaries.
308  void check_integrity(double& max_error);
309 
310 protected:
311 
312  /// \short Set up hanging node information.
313  /// Overloaded to implement the mortar method rather than constrained
314  /// approximation. This enforces continuity weakly via an integral matching
315  /// condition at non-conforming element boundaries.
316  void oc_hang_helper(const int &value_id, const int &my_face,
317  std::ofstream& output_hangfile);
318 
319 };
320 
321 }
322 
323 #endif
A Generalised Element class.
Definition: elements.h:76
void further_setup_hanging_nodes()
Perform additional hanging node procedures for variables that are not interpolated by all nodes (e...
cstr elem_len * i
Definition: cfortran.h:607
unsigned nnode_1d() const
Returns the number of nodes along each edge of the element. Overloaded to return the (variable) p-ord...
unsigned nnode_1d() const
Returns the number of nodes along each edge of the element. Overloaded to return the (variable) p-ord...
Nodes are derived from Data, but, in addition, have a definite (Eulerian) position in a space of a gi...
Definition: nodes.h:852
unsigned initial_p_order() const
Get the initial P_order.
static char t char * s
Definition: cfortran.h:572
unsigned initial_p_order() const
Get the initial P_order.
void shape(const double &s, double *Psi)
Definition for 1D Lagrange shape functions. The value of all the shape functions at the local coordin...
Definition: shape.h:549
unsigned nnode_1d() const
Returns the number of nodes along each edge of the element. Overloaded to return the (variable) p-ord...
p-refineable version of RefineableElement
unsigned initial_p_order() const
Get the initial P_order.
void further_setup_hanging_nodes()
Perform additional hanging node procedures for variables that are not interpolated by all nodes (e...
void further_setup_hanging_nodes()
Perform additional hanging node procedures for variables that are not interpolated by all nodes (e...
A general mesh class.
Definition: mesh.h:74