Tdisplacement_based_foeppl_von_karman_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 TFoepplvonKarman elements
31 #ifndef OOMPH_TFOEPPLVONKARMAN_DISPLACEMENT_ELEMENTS_HEADER
32 #define OOMPH_TFOEPPLVONKARMAN_DISPLACEMENT_ELEMENTS_HEADER
33 
34 
35 // Config header generated by autoconfig
36 #ifdef HAVE_CONFIG_H
37  #include <oomph-lib-config.h>
38 #endif
39 
40 
41 //OOMPH-LIB headers
42 #include "../generic/nodes.h"
43 #include "../generic/oomph_utilities.h"
44 #include "../generic/Telements.h"
45 #include "../generic/error_estimator.h"
46 
48 
49 namespace oomph
50 {
51 
52 /////////////////////////////////////////////////////////////////////////
53 /////////////////////////////////////////////////////////////////////////
54 // TDisplacementBasedFoepplvonKarmanElement
55 ////////////////////////////////////////////////////////////////////////
56 ////////////////////////////////////////////////////////////////////////
57 
58 
59 // -----------------------------------------------------------------------
60 // THE TRIANGLE ELEMENT
61 // -----------------------------------------------------------------------
62 
63 
64 //======================================================================
65 /// TDisplacementBasedFoepplvonKarmanElement<NNODE_1D> elements are
66 /// isoparametric
67 /// triangular 2-dimensional Foeppl von Karman elements with NNODE_1D
68 /// nodal points along each element edge. Inherits from TElement and
69 /// DisplacementBasedFoepplvonKarmanEquations
70 //======================================================================
71 template <unsigned NNODE_1D>
72 class TDisplacementBasedFoepplvonKarmanElement : public virtual TElement<2,NNODE_1D>,
74  public virtual ElementWithZ2ErrorEstimator
75 {
76 
77 public:
78 
79  ///\short Constructor: Call constructors for TElement and
80  /// Foeppl von Karman equations
83  { }
84 
85 
86  /// Broken copy constructor
88  {
89  BrokenCopy::broken_copy("TDisplacementBasedFoepplvonKarmanElement");
90  }
91 
92  /// Broken assignment operator
94  {
95  BrokenCopy::broken_assign("TDisplacementBasedFoepplvonKarmanElement");
96  }
97 
98  /// \short Access function for Nvalue: # of `values' (pinned or
99  /// dofs) at node n (always returns the same value at every node, 4)
100  inline unsigned required_nvalue(const unsigned &n) const
101  {return Initial_Nvalue;}
102 
103  /// \short The number of dof types that degrees of freedom in this
104  /// element are sub-divided into
105  unsigned ndof_types() const
106  {
107  // NOTE: this assumes "clamped" bcs
108  // [0]: laplacian w interior
109  // [1]: laplacian w boundary
110  // [2]: W
111  // [3]: Ux
112  // [4]: Uy
113  return 5;
114  }
115 
116  /// \short Create a list of pairs for all unknowns in this element,
117  /// so that the first entry in each pair contains the global
118  /// equation number of the unknown, while the second one contains
119  /// the number of the dof type that this unknown is associated with.
120  /// (Function can obviously only be called if the equation numbering
121  /// scheme has been set up.)
122  /// Dof_types
123  /// 0,1: Laplacian;
124  /// 2: Bending w
125  /// 3: Displacements Ux and Uy
126  /// The indexing of the dofs in the element is like below
127  /// [0]: w
128  /// [1]: laplacian w
129  /// [2]: U_x
130  /// [3]: U_y
132  std::list<std::pair<unsigned long,unsigned> >& dof_lookup_list) const
133  {
134  // number of nodes
135  const unsigned n_node = this->nnode();
136 
137  // temporary pair (used to store dof lookup prior to being added to list)
138  std::pair<unsigned,unsigned> dof_lookup;
139 
140  // loop over the nodes
141  for (unsigned n = 0; n < n_node; n++)
142  {
143  // Zeroth nodal value: displacement
144  //---------------------------------
145  unsigned v=0;
146 
147  // determine local eqn number
148  int local_eqn_number = this->nodal_local_eqn(n, v);
149 
150  // ignore pinned values
151  if (local_eqn_number >= 0)
152  {
153  // store dof lookup in temporary pair: Global equation
154  // number is the first entry in pair
155  dof_lookup.first = this->eqn_number(local_eqn_number);
156 
157  // set dof type numbers: Dof type is the second entry in pair
158  dof_lookup.second = 2;
159 
160  // add to list
161  dof_lookup_list.push_front(dof_lookup);
162  }
163 
164  // First nodal value: Laplacian
165  //-----------------------------
166  v=1;
167 
168  // determine local eqn number
169  local_eqn_number = this->nodal_local_eqn(n, v);
170 
171  // ignore pinned values
172  if (local_eqn_number >= 0)
173  {
174  // store dof lookup in temporary pair: Global equation
175  // number is the first entry in pair
176  dof_lookup.first = this->eqn_number(local_eqn_number);
177 
178  // Is it a boundary node? If so: It's dof type 1
179  if (node_pt(n)->is_on_boundary(0) || node_pt(n)->is_on_boundary(1))
180  {
181  dof_lookup.second = 1;
182  }
183  // otherwise it's in the interior: It's dof type 0
184  else
185  {
186  dof_lookup.second = 0;
187  }
188 
189  // add to list
190  dof_lookup_list.push_front(dof_lookup);
191  }
192 
193  // Second nodal value: U_x
194  //---------------------------------
195  v=2;
196 
197  // determine local eqn number
198  local_eqn_number = this->nodal_local_eqn(n, v);
199 
200  // ignore pinned values
201  if (local_eqn_number >= 0)
202  {
203  // store dof lookup in temporary pair: Global equation
204  // number is the first entry in pair
205  dof_lookup.first = this->eqn_number(local_eqn_number);
206 
207  // set dof type numbers: Dof type is the second entry in pair
208  dof_lookup.second = 3;
209 
210  // add to list
211  dof_lookup_list.push_front(dof_lookup);
212  }
213 
214  // Third nodal value: U_y
215  //---------------------------------
216  v=3;
217 
218  // determine local eqn number
219  local_eqn_number = this->nodal_local_eqn(n, v);
220 
221  // ignore pinned values
222  if (local_eqn_number >= 0)
223  {
224  // store dof lookup in temporary pair: Global equation
225  // number is the first entry in pair
226  dof_lookup.first = this->eqn_number(local_eqn_number);
227 
228  // set dof type numbers: Dof type is the second entry in pair
229  dof_lookup.second = 4;
230 
231  // add to list
232  dof_lookup_list.push_front(dof_lookup);
233  }
234 
235  } // for (n < n_node)
236 
237  }
238 
239  /// \short Output function:
240  /// x,y,w
241  void output(std::ostream &outfile)
242  {
244  }
245 
246  /// \short Output function:
247  /// x,y,w at n_plot^2 plot points
248  void output(std::ostream &outfile, const unsigned &n_plot)
249  {
251  }
252 
253 
254  /// \short C-style output function:
255  /// x,y,w
256  void output(FILE* file_pt)
257  {
259  }
260 
261 
262  /// \short C-style output function:
263  /// x,y,w at n_plot^2 plot points
264  void output(FILE* file_pt, const unsigned &n_plot)
265  {
267  }
268 
269 
270  /// \short Output function for an exact solution:
271  /// x,y,w_exact
272  void output_fct(std::ostream &outfile, const unsigned &n_plot,
274  {
275  DisplacementBasedFoepplvonKarmanEquations::output_fct(outfile,n_plot,exact_soln_pt);
276  }
277 
278 
279  /// \short Output function for a time-dependent exact solution.
280  /// x,y,w_exact (calls the steady version)
281  void output_fct(std::ostream &outfile, const unsigned &n_plot,
282  const double& time,
284  {
285  DisplacementBasedFoepplvonKarmanEquations::output_fct(outfile,n_plot,time,exact_soln_pt);
286  }
287 
288 protected:
289 
290  /// Shape, test functions & derivs. w.r.t. to global coords. Return Jacobian.
291  inline double dshape_and_dtest_eulerian_fvk(const Vector<double> &s,
292  Shape &psi,
293  DShape &dpsidx,
294  Shape &test,
295  DShape &dtestdx) const;
296 
297 
298  /// Shape, test functions & derivs. w.r.t. to global coords. Return Jacobian.
299  inline double dshape_and_dtest_eulerian_at_knot_fvk(const unsigned &ipt,
300  Shape &psi,
301  DShape &dpsidx,
302  Shape &test,
303  DShape &dtestdx) const;
304 
305  /// \short Order of recovery shape functions for Z2 error estimation:
306  /// Same order as shape functions.
307  unsigned nrecovery_order() {return (NNODE_1D-1);}
308 
309  /// Number of 'flux' terms for Z2 error estimation
310  unsigned num_Z2_flux_terms() {return 2;}//The dimension
311 
312  /// Get 'flux' for Z2 error recovery: Standard flux.from FvK equations
314  {this->get_gradient_of_deflection(s,flux);}
315 
316  /// \short Number of vertex nodes in the element
317  unsigned nvertex_node() const
319 
320  /// \short Pointer to the j-th vertex node in the element
321  Node* vertex_node_pt(const unsigned& j) const
323 
324 private:
325 
326  /// Static unsigned that holds the (same) number of variables at every node
327  static const unsigned Initial_Nvalue;
328 
329 
330 };
331 
332 
333 
334 
335 //Inline functions:
336 
337 
338 //======================================================================
339 /// Define the shape functions and test functions and derivatives
340 /// w.r.t. global coordinates and return Jacobian of mapping.
341 ///
342 /// Galerkin: Test functions = shape functions
343 //======================================================================
344 template<unsigned NNODE_1D>
346  const Vector<double> &s,
347  Shape &psi,
348  DShape &dpsidx,
349  Shape &test,
350  DShape &dtestdx) const
351 {
352  unsigned n_node = this->nnode();
353 
354  //Call the geometrical shape functions and derivatives
355  double J = this->dshape_eulerian(s,psi,dpsidx);
356 
357  //Loop over the test functions and derivatives and set them equal to the
358  //shape functions
359  for(unsigned i=0;i<n_node;i++)
360  {
361  test[i] = psi[i];
362  dtestdx(i,0) = dpsidx(i,0);
363  dtestdx(i,1) = dpsidx(i,1);
364  }
365 
366  //Return the jacobian
367  return J;
368 }
369 
370 
371 
372 //======================================================================
373 /// Define the shape functions and test functions and derivatives
374 /// w.r.t. global coordinates and return Jacobian of mapping.
375 ///
376 /// Galerkin: Test functions = shape functions
377 //======================================================================
378 template<unsigned NNODE_1D>
381  const unsigned &ipt,
382  Shape &psi,
383  DShape &dpsidx,
384  Shape &test,
385  DShape &dtestdx) const
386 {
387 
388  //Call the geometrical shape functions and derivatives
389  double J = this->dshape_eulerian_at_knot(ipt,psi,dpsidx);
390 
391  //Set the pointers of the test functions
392  test = psi;
393  dtestdx = dpsidx;
394 
395  //Return the jacobian
396  return J;
397 
398 }
399 
400 
401 //=======================================================================
402 /// Face geometry for the TDisplacementBasedFoepplvonKarmanElement
403 // elements:The spatial / dimension of the face elements is one lower
404 // than that of the / bulk element but they have the same number of
405 // points / along their 1D edges.
406 //=======================================================================
407 template<unsigned NNODE_1D>
409  public virtual TElement<1,NNODE_1D>
410 {
411 
412 public:
413 
414  /// \short Constructor: Call the constructor for the
415  /// appropriate lower-dimensional TElement
416  FaceGeometry() : TElement<1,NNODE_1D>() {}
417 
418 };
419 
420 } // namespace oomph
421 
422 #endif
TDisplacementBasedFoepplvonKarmanElement()
Constructor: Call constructors for TElement and Foeppl von Karman equations.
void broken_copy(const std::string &class_name)
Issue error message and terminate execution.
void operator=(const TDisplacementBasedFoepplvonKarmanElement< NNODE_1D > &)
Broken assignment operator.
void output(std::ostream &outfile)
Output with default number of plot points.
unsigned nvertex_node() const
Number of vertex nodes in the element.
double dshape_and_dtest_eulerian_fvk(const Vector< double > &s, Shape &psi, DShape &dpsidx, Shape &test, DShape &dtestdx) const
Shape, test functions & derivs. w.r.t. to global coords. Return Jacobian.
Base class for finite elements that can compute the quantities that are required for the Z2 error est...
unsigned num_Z2_flux_terms()
Number of &#39;flux&#39; terms for Z2 error estimation.
virtual double dshape_eulerian_at_knot(const unsigned &ipt, Shape &psi, DShape &dpsidx) const
Return the geometric shape functions and also first derivatives w.r.t. global coordinates at the ipt-...
Definition: elements.cc:3254
void get_Z2_flux(const Vector< double > &s, Vector< double > &flux)
Get &#39;flux&#39; for Z2 error recovery: Standard flux.from FvK equations.
unsigned ndof_types() const
The number of dof types that degrees of freedom in this element are sub-divided into.
cstr elem_len * i
Definition: cfortran.h:607
void get_gradient_of_deflection(const Vector< double > &s, Vector< double > &gradient) const
Get gradient of deflection: gradient[i] = dw/dx_i.
void output_fct(std::ostream &outfile, const unsigned &n_plot, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt)
Output function for an exact solution: x,y,w_exact.
void(* UnsteadyExactSolutionFctPt)(const double &, const Vector< double > &, Vector< double > &)
Function pointer for function that computes Vector-valued time-dependent function as ...
Definition: elements.h:1729
Nodes are derived from Data, but, in addition, have a definite (Eulerian) position in a space of a gi...
Definition: nodes.h:852
void output(std::ostream &outfile, const unsigned &n_plot)
Output function: x,y,w at n_plot^2 plot points.
TDisplacementBasedFoepplvonKarmanElement(const TDisplacementBasedFoepplvonKarmanElement< NNODE_1D > &dummy)
Broken copy constructor.
unsigned required_nvalue(const unsigned &n) const
Access function for Nvalue: # of `values&#39; (pinned or dofs) at node n (always returns the same value a...
double dshape_and_dtest_eulerian_at_knot_fvk(const unsigned &ipt, Shape &psi, DShape &dpsidx, Shape &test, DShape &dtestdx) const
Shape, test functions & derivs. w.r.t. to global coords. Return Jacobian.
void(* SteadyExactSolutionFctPt)(const Vector< double > &, Vector< double > &)
Function pointer for function that computes vector-valued steady "exact solution" as ...
Definition: elements.h:1723
double dshape_eulerian(const Vector< double > &s, Shape &psi, DShape &dpsidx) const
Compute the geometric shape functions and also first derivatives w.r.t. global coordinates at local c...
Definition: elements.cc:3227
static char t char * s
Definition: cfortran.h:572
void get_dof_numbers_for_unknowns(std::list< std::pair< unsigned long, unsigned > > &dof_lookup_list) const
Create a list of pairs for all unknowns in this element, so that the first entry in each pair contain...
unsigned long eqn_number(const unsigned &ieqn_local) const
Return the global equation number corresponding to the ieqn_local-th local equation number...
Definition: elements.h:709
Node * vertex_node_pt(const unsigned &j) const
Pointer to the j-th vertex node in the element.
Node *& node_pt(const unsigned &n)
Return a pointer to the local node n.
Definition: elements.h:2109
void output_fct(std::ostream &outfile, const unsigned &n_plot, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt)
Output exact soln: x,y,w_exact at n_plot^DIM plot points.
unsigned nrecovery_order()
Order of recovery shape functions for Z2 error estimation: Same order as shape functions.
static const unsigned Initial_Nvalue
Static unsigned that holds the (same) number of variables at every node.
void broken_assign(const std::string &class_name)
Issue error message and terminate execution.
FaceGeometry()
Constructor: Call the constructor for the appropriate lower-dimensional TElement. ...
int local_eqn_number(const unsigned long &ieqn_global) const
Return the local equation number corresponding to the ieqn_global-th global equation number...
Definition: elements.h:731
unsigned nnode() const
Return the number of nodes.
Definition: elements.h:2146
void output(FILE *file_pt, const unsigned &n_plot)
C-style output function: x,y,w at n_plot^2 plot points.
void output_fct(std::ostream &outfile, const unsigned &n_plot, const double &time, FiniteElement::UnsteadyExactSolutionFctPt exact_soln_pt)
Output function for a time-dependent exact solution. x,y,w_exact (calls the steady version) ...
int nodal_local_eqn(const unsigned &n, const unsigned &i) const
Return the local equation number corresponding to the i-th value at the n-th local node...
Definition: elements.h:1386