supg_advection_diffusion_elements.cc
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: 1097 $
7 //LIC//
8 //LIC// $LastChangedDate: 2015-12-17 11:53:17 +0000 (Thu, 17 Dec 2015) $
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//====================================================================
31 
32 
33 namespace oomph
34 {
35 
36 //======================================================================
37 /// \short QSUPGAdvectionDiffusionElement<DIM,NNODE_1D> elements are
38 /// SUPG-stabilised Advection Diffusion elements with
39 /// NNODE_1D nodal points in each coordinate direction. Inherits
40 /// from QAdvectionDiffusionElement and overwrites their
41 /// test functions
42 ///
43 //======================================================================
44 
45 //======================================================================
46 /// \short Define the shape functions and test functions and derivatives
47 /// w.r.t. global coordinates and return Jacobian of mapping.
48 ///
49 /// SUPG stabilisation: Petrov-Galerkin, i.e. test functions \f$ \ne \f$
50 /// shape functions
51 //======================================================================
52 template<unsigned DIM, unsigned NNODE_1D>
55  Shape &psi,
56  DShape &dpsidx,
57  Shape &test,
58  DShape &dtestdx) const
59 {
60 
61  //Call the geometrical shape functions and derivatives
62  double J = QElement<DIM,NNODE_1D>::dshape_eulerian(s,psi,dpsidx);
63 
64  //Find out how many nodes there are
65  unsigned n_node = this->nnode();
66 
67  //Calculate Eulerian coordinates
68  Vector<double> interpolated_x(DIM,0.0);
69 
70  // Loop over nodes
71  for(unsigned l=0;l<n_node;l++)
72  {
73  // Loop over directions
74  for(unsigned j=0;j<DIM;j++)
75  {
76  interpolated_x[j]+=this->nodal_position(l,j)*psi[l];
77  }
78  }
79 
80  //Get wind
81  Vector<double> wind(DIM);
82  //Dummy ipt argument
83  unsigned ipt=0;
84  this->get_wind_adv_diff(ipt,s,interpolated_x,wind);
85 
86  //Loop over the test functions and derivatives and set them equal to the
87  //shape functions + add stabilisation
88  for(unsigned j=0;j<n_node;j++)
89  {
90  test[j] = psi[j];
91 
92  for (unsigned i=0;i<DIM;i++)
93  {
94  dtestdx(j,i) = dpsidx(j,i);
95  test[j]+=Tau_SUPG*wind[i]*dpsidx(j,i);
96  }
97  }
98 
99  //Return the jacobian
100  return J;
101 }
102 
103 
104 //======================================================================
105 /// \short Define the shape functions and test functions and derivatives
106 /// w.r.t. global coordinates and return Jacobian of mapping.
107 ///
108 /// SUPG stabilisation: Petrov-Galerkin, i.e. test functions \f$ \ne \f$
109 /// shape functions
110 //======================================================================
111 template<unsigned DIM, unsigned NNODE_1D>
114  const unsigned &ipt,
115  Shape &psi,
116  DShape &dpsidx,
117  Shape &test,
118  DShape &dtestdx) const
119 {
120  //Call the geometrical shape functions and derivatives
121  double J = this->dshape_eulerian_at_knot(ipt,psi,dpsidx);
122 
123  //Find out how many nodes there are
124  unsigned n_node = this->nnode();
125 
126  //Calculate Eulerian coordinates
127  Vector<double> interpolated_x(DIM,0.0);
128 
129  // Loop over nodes
130  for(unsigned l=0;l<n_node;l++)
131  {
132  // Loop over directions
133  for(unsigned j=0;j<DIM;j++)
134  {
135  interpolated_x[j]+=this->nodal_position(l,j)*psi(l);
136  }
137  }
138 
139  //Find the dimension of the element
140  unsigned Dim = this->dim();
141  //Storage for the local coordinates of the integration point
142  Vector<double> s(Dim);
143  //Set the local coordinate
144  for(unsigned i=0;i<Dim;i++) {s[i] = this->integral_pt()->knot(ipt,i);}
145 
146  //Get wind
147  Vector<double> wind(DIM);
148  this->get_wind_adv_diff(ipt,s,interpolated_x,wind);
149 
150  //Loop over the test functions and derivatives and set them equal to the
151  //shape functions + add stabilisation
152  for(unsigned j=0;j<n_node;j++)
153  {
154  test(j) = psi(j);
155  for (unsigned i=0;i<DIM;i++)
156  {
157  dtestdx(j,i) = dpsidx(j,i);
158  test(j) += Tau_SUPG*wind[i]*dpsidx(j,i);
159  }
160  }
161 
162 
163  //Return the jacobian
164  return J;
165 }
166 
167 
168 
169 // Force template instantiation.
173 
174 
178 
179 
180 
181 // Force template instantiation.
185 
186 
190 
191 
192 }
Refineable version of QSUPGAdvectionDiffusionElement. Inherit from the standard QSUPGAdvectionDiffusi...
cstr elem_len * i
Definition: cfortran.h:607
unsigned Dim
Dimension of zeta tuples (set by get_dim_helper) – needed because we store the scalar coordinates in ...
Definition: multi_domain.cc:66
double dshape_and_dtest_eulerian_adv_diff(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.
QSUPGAdvectionDiffusionElement<DIM,NNODE_1D> elements are SUPG-stabilised Advection Diffusion element...
static char t char * s
Definition: cfortran.h:572
double dshape_and_dtest_eulerian_at_knot_adv_diff(const unsigned &ipt, Shape &psi, DShape &dpsidx, Shape &test, DShape &dtestdx) const
Shape, test functions & derivs. w.r.t. to global coords. Return Jacobian.