polar_streamfunction_traction_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// 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 elements that are used to provide streamfunction traction
27 //at inlet and outlet
28 
29 #ifndef OOMPH_POLAR_STREAMFUNCTION_TRACTION_ELEMENTS
30 #define OOMPH_POLAR_STREAMFUNCTION_TRACTION_ELEMENTS
31 
32 //OOMPH-LIB headers
33 #include "generic/Qelements.h"
34 
35 namespace oomph
36 {
37 
38 //======================================================================
41 //======================================================================
42 template <class ELEMENT>
43 class PolarStreamfunctionTractionElement : public virtual FaceGeometry<ELEMENT>,
44 public virtual FaceElement
45 {
46 
47 private:
48 
50  unsigned Dim;
51 
52 protected:
53 
54 
59  virtual inline int s_local_eqn(const unsigned &n)
60  {return nodal_local_eqn(n,0);}
61 
64  inline double shape_and_test_at_knot(const unsigned &ipt,
65  Shape &psi, Shape &test)
66  const
67  {
68  //Find number of nodes
69  unsigned n_node = nnode();
70  //Calculate the shape functions
71  shape_at_knot(ipt,psi);
72  //Set the test functions to be the same as the shape functions
73  for(unsigned i=0;i<n_node;i++) {test[i] = psi[i];}
74  //Return the value of the jacobian
75  return J_eulerian_at_knot(ipt);
76  }
77 
82  DenseMatrix<double> &jacobian,
83  DenseMatrix<double> &mass_matrix,
84  unsigned flag);
86  double *Alpha_pt;
87 
88  //Traction elements need to know whether they're at the inlet or outlet
89  //as the unit outward normal has a differing sign dependent on
90  //the boundary
91  // -1=inlet, 1=outlet
92  int Boundary;
93 
94 public:
95 
97  const double &alpha() const {return *Alpha_pt;}
98 
100  double* &alpha_pt() {return Alpha_pt;}
101 
103  const int boundary() const {return Boundary;}
104 
106  void set_boundary(int bound) {Boundary=bound;}
107 
111  const int &face_index) :
112  FaceGeometry<ELEMENT>(), FaceElement()
113  {
114 #ifdef PARANOID
115  {
116  //Check that the element is not a refineable 3d element
117  ELEMENT* elem_pt = new ELEMENT;
118  //If it's three-d
119  if(elem_pt->dim()==3)
120  {
121  //Is it refineable
122  if(dynamic_cast<RefineableElement*>(elem_pt))
123  {
124  //Issue a warning
126  "This flux element will not work correctly if nodes are hanging\n",
127  "PolarNavierStokesTractionElement::Constructor",
129  }
130  }
131  }
132 #endif
133 
134  //Attach the geometrical information to the element. N.B. This function
135  //also assigns nbulk_value from the required_nvalue of the bulk element
136  element_pt->build_face_element(face_index,this);
137 
138  //Set the dimension from the dimension of the first node
139  Dim = this->node_pt(0)->ndim();
140  }
141 
144 
147  {
148  //Call the generic residuals function with flag set to 0
149  //using a dummy matrix argument
152  }
153 
156  DenseMatrix<double> &jacobian)
157  {
158  //Call the generic routine with the flag set to 1
160  }
161 
165  Vector<double> &residuals,
166  DenseMatrix<double> &jacobian,DenseMatrix<double> &mass_matrix)
167  {
168  //Call the generic routine with the flag set to 2
170  }
171 
173  void output(std::ostream &outfile) {FiniteElement::output(outfile);}
174 
176 void output(std::ostream &outfile, const unsigned &nplot)
177  {FiniteElement::output(outfile,nplot);}
178 
180  double s(const unsigned &l )
181  {return nodal_value(l,0);}
182 
184  double x(const unsigned &l, const unsigned &i )
185  {return nodal_position(l,i);}
186 
187 };
188 
189 
190 
194 
195 
196 
197 //============================================================================
200 //============================================================================
201 template<class ELEMENT>
204  DenseMatrix<double> &jacobian,
205  DenseMatrix<double> &mass_matrix,
206  unsigned flag)
207 {
208  //Find out how many nodes there are
209  unsigned n_node = nnode();
210 
211  //Set up memory for the shape and test functions
212  Shape psif(n_node), testf(n_node);
213 
214  //Set the value of n_intpt
215  unsigned n_intpt = integral_pt()->nweight();
216 
217  //Get Alpha
218  const double Alpha = alpha();
219 
220  //Get boundary multiplier
221  //This is necessary because the sign of the traction is
222  //dependent on the boundary
223  const int multiplier = boundary();
224 
225  //Integers to store local equation numbers
226  int local_eqn=0;
227 
228  //Loop over the integration points
229  for(unsigned ipt=0;ipt<n_intpt;ipt++)
230  {
231  //Get the integral weight
232  double w = integral_pt()->weight(ipt);
233 
234  //Find the shape and test functions and return the Jacobian
235  //of the mapping
236  double J = shape_and_test_at_knot(ipt,psif,testf);
237 
238  //Premultiply the weights and the Jacobian
239  double W = w*J;
240 
241  //Need to find position to feed into Traction function
242  Vector<double> interpolated_x(Dim);
243  double interpolated_v;
244 
245  //Initialise to zero
246  interpolated_v = 0.0;
247  for(unsigned i=0;i<Dim;i++) interpolated_x[i] = 0.0;
248 
249  //Calculate velocities and derivatives:
250  // Loop over nodes
251  for(unsigned l=0;l<n_node;l++)
252  {
253  //Get the nodal value
254  //Assume streamfunction stored as first nodal value and v as third.
255  interpolated_v += this->nodal_value(l,2)*psif[l];
256  //Loop over directions
257  for(unsigned i=0;i<Dim;i++) interpolated_x[i] += this->nodal_position(l,i)*psif[l];
258  }
259 
260  //Now add to the appropriate equations
261 
262  //Loop over the test functions
263  for(unsigned l=0;l<n_node;l++)
264  {
265  local_eqn = s_local_eqn(l);
266  /*IF it's not a boundary condition*/
267  if(local_eqn >= 0)
268  {
269  //Add the user-defined traction terms
270  //Essentially (v*boundary)
271  residuals[local_eqn] += multiplier*interpolated_v*testf[l]*interpolated_x[0]*Alpha*W;
272 
273  //CALCULATE THE JACOBIAN
274  if(flag)
275  {
277 
278  } /*End of Jacobian calculation*/
279 
280  } //end of if not boundary condition statement
281 
282  } //End of loop over shape functions
283 
284  } //End of loop over integration points
285 
286 } //End of fill_in_generic_residual_contribution
287 
288 } //End of namespace oomph
289 
290 #endif
int i
Definition: BiCGSTAB_step_by_step.cpp:9
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
JacobiRotation< float > J
Definition: Jacobi_makeJacobi.cpp:3
RowVector3d w
Definition: Matrix_resize_int.cpp:3
Definition: elements.h:4338
int & face_index()
Definition: elements.h:4626
double J_eulerian_at_knot(const unsigned &ipt) const
Definition: elements.cc:5328
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
double nodal_value(const unsigned &n, const unsigned &i) const
Definition: elements.h:2593
virtual void output(std::ostream &outfile)
Definition: elements.h:3050
virtual void build_face_element(const int &face_index, FaceElement *face_element_pt)
Definition: elements.cc:5132
int nodal_local_eqn(const unsigned &n, const unsigned &i) const
Definition: elements.h:1432
unsigned nnode() const
Return the number of nodes.
Definition: elements.h:2210
double nodal_position(const unsigned &n, const unsigned &i) const
Definition: elements.h:2317
virtual void shape_at_knot(const unsigned &ipt, Shape &psi) const
Definition: elements.cc:3220
static DenseMatrix< double > Dummy_matrix
Definition: elements.h:227
unsigned ndim() const
Return (Eulerian) spatial dimension of the node.
Definition: nodes.h:1054
Definition: oomph_definitions.h:267
Definition: polar_streamfunction_traction_elements.h:45
const int boundary() const
Boundary.
Definition: polar_streamfunction_traction_elements.h:103
double s(const unsigned &l)
local streamfunction
Definition: polar_streamfunction_traction_elements.h:180
unsigned Dim
The highest dimension of the problem.
Definition: polar_streamfunction_traction_elements.h:50
int Boundary
Definition: polar_streamfunction_traction_elements.h:92
void output(std::ostream &outfile, const unsigned &nplot)
Output function: x,y,[z],u,v,[w],p in tecplot format.
Definition: polar_streamfunction_traction_elements.h:176
double * Alpha_pt
Pointer to the angle alpha.
Definition: polar_streamfunction_traction_elements.h:86
void set_boundary(int bound)
Function to set boundary.
Definition: polar_streamfunction_traction_elements.h:106
void fill_in_contribution_to_residuals(Vector< double > &residuals)
This function returns just the residuals.
Definition: polar_streamfunction_traction_elements.h:146
~PolarStreamfunctionTractionElement()
Destructor should not delete anything.
Definition: polar_streamfunction_traction_elements.h:143
void output(std::ostream &outfile)
Overload the output function.
Definition: polar_streamfunction_traction_elements.h:173
double shape_and_test_at_knot(const unsigned &ipt, Shape &psi, Shape &test) const
Definition: polar_streamfunction_traction_elements.h:64
const double & alpha() const
Alpha.
Definition: polar_streamfunction_traction_elements.h:97
double *& alpha_pt()
Pointer to Alpha.
Definition: polar_streamfunction_traction_elements.h:100
void fill_in_generic_residual_contribution(Vector< double > &residuals, DenseMatrix< double > &jacobian, DenseMatrix< double > &mass_matrix, unsigned flag)
Definition: polar_streamfunction_traction_elements.h:203
void fill_in_contribution_to_jacobian_and_mass_matrix(Vector< double > &residuals, DenseMatrix< double > &jacobian, DenseMatrix< double > &mass_matrix)
Definition: polar_streamfunction_traction_elements.h:164
PolarStreamfunctionTractionElement(FiniteElement *const &element_pt, const int &face_index)
Definition: polar_streamfunction_traction_elements.h:110
double x(const unsigned &l, const unsigned &i)
local position
Definition: polar_streamfunction_traction_elements.h:184
void fill_in_contribution_to_jacobian(Vector< double > &residuals, DenseMatrix< double > &jacobian)
This function returns the residuals and the jacobian.
Definition: polar_streamfunction_traction_elements.h:155
virtual int s_local_eqn(const unsigned &n)
Definition: polar_streamfunction_traction_elements.h:59
Definition: refineable_elements.h:97
Definition: shape.h:76
RealScalar alpha
Definition: level1_cplx_impl.h:151
double multiplier(const Vector< double > &xi)
Definition: disk_oscillation.cc:63
static const unsigned Dim
Problem dimension.
Definition: two_d_tilted_square.cc:62
double Alpha
Parameter for steepness of step.
Definition: two_d_adv_diff_adapt.cc:53
@ W
Definition: quadtree.h:63
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
Definition: AnisotropicHookean.h:10
Definition: indexed_view.cpp:20
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61