flux_control_elements_bk.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 //Include guard to prevent multiple inclusions of the header
27 #ifndef OOMPH_FLUX_CONTROL_ELEMENTS
28 #define OOMPH_FLUX_CONTROL_ELEMENTS
29 
30 // NOTE: This does not appeared to be used. So I have renmaed it from
31 // flux_control_elements.h to flux_control_elements_bk.h
32 
33 namespace oomph
34 {
35 
36 
40 
41 
42 // CHECK WE DETECT OF HANGING NODES SOMEWHERE IN TRACTION MESH
43 
44 // Forward declaration
45 template <class ELEMENT> class NavierStokesFluxControlElement;
46 
47 //======================================================================
51 //======================================================================
52 template <class ELEMENT>
54 {
55 public:
56 
59  NetFluxControlElement(Mesh* flux_control_mesh_pt,
60  double* prescribed_outflow_value_pt) :
61  Flux_control_mesh_pt(flux_control_mesh_pt),
62  Prescribed_outflow_value_pt(prescribed_outflow_value_pt)
63  {
64  // Construct Pressure_data_pt
65  Pressure_data_pt = new Data(1);
66 
67  // Add the new Data to internal Data for this element
69 
70  // pin pressure data
71  // Pressure_data_pt->pin(0);
72 
73  // Loop over elements in the Flux_control_mesh to add
74  // Data from the elements in the flux control
75  // mesh to the external data for this element
76  unsigned n_el = Flux_control_mesh_pt->nelement();
77  for (unsigned e=0; e<n_el; e++)
78  {
79  // Get pointer to the element
80  FiniteElement * f_el_pt =
82 
83  // Loop over the nodes
84  unsigned n_node = f_el_pt->nnode();
85  for(unsigned n=0;n<n_node;n++)
86  {
87  add_external_data(f_el_pt->node_pt(n));
88  }
89  }
90  }
91 
94 
97  {
98  BrokenCopy::broken_copy("NetFluxControlElement");
99  }
100 
105 
106 
111  {
112  // Initialise volume flux
113  double volume_flux = 0.0;
114 
115  // Loop over elements in Flux_control_mesh_pt and calculate flux
116  unsigned n_el = Flux_control_mesh_pt->nelement();
117  for (unsigned e=0; e<n_el; e++)
118  {
119  // Get a pointer to the element
121 
122  // Cast to NavierStokesFluxControlElement
123  NavierStokesFluxControlElement<ELEMENT>* flux_control_el_pt =
124  dynamic_cast<NavierStokesFluxControlElement<ELEMENT>* >(el_pt);
125 
126  // Add the elemental volume flux
127  volume_flux += flux_control_el_pt->get_volume_flux();
128  }
129 
130  residuals[0] = volume_flux - *Prescribed_outflow_value_pt;
131  }
132 
133 
134 
135 
145 // unsigned nblock_types()
146 // {
147 // return 2;
148 // }
149 
164 // void get_block_numbers_for_unknowns(
165 // std::list<std::pair<unsigned long, unsigned> >& block_lookup_list)
166 // {
167 // // pair to store block lookup prior to being added to list
168 // std::pair<unsigned,unsigned> block_lookup;
169 //
170 // block_lookup.first = eqn_number(0);
171 // block_lookup.second = 1;
172 //
173 // // add to list
174 // block_lookup_list.push_front(block_lookup);
175 // }
176 
177 
178 private:
179 
183 
187 
190 
191 };
192 
196 
197 
198 
199 //======================================================================
206 //======================================================================
207 template <class ELEMENT>
209  public virtual NavierStokesSurfacePowerElement<ELEMENT>
210 {
211 public:
212 
216  const int &face_index) :
217  NavierStokesSurfacePowerElement<ELEMENT>(element_pt, face_index)
218  {
219 #ifdef PARANOID
220  {
221  //Check that the element is not a refineable 3d element
222  ELEMENT* elem_pt = new ELEMENT;
223  //If it's three-d
224  if(elem_pt->dim()==3)
225  {
226  //Is it refineable
227  if(dynamic_cast<RefineableElement*>(elem_pt))
228  {
229  //Issue a warning
231  "This flux element will not work correctly if nodes are hanging\n",
232  "NavierStokesFluxControlElement::Constructor",
234  }
235  }
236  }
237 #endif
238 
239  //Attach the geometrical information to the element. N.B. This function
240  //also assigns nbulk_value from the required_nvalue of the bulk element
241  element_pt->build_face_element(face_index,this);
242 
243  //Set the dimension from the dimension of the first node
244  Dim = this->node_pt(0)->ndim();
245  }
246 
249 
252  unsigned nblock_types()
253  {
254  return 2;
255  }
256 
260  std::list<std::pair<unsigned long, unsigned> >& block_lookup_list)
261  {}
262 
265  {
266  //Call the generic residuals function using a dummy matrix argument
269  }
270 
271 /* ///This function returns the residuals and the jacobian */
272 /* inline void fill_in_contribution_to_jacobian(Vector<double> &residuals, */
273 /* DenseMatrix<double> &jacobian) */
274 /* { */
275 /* //Call the generic routine */
276 /* fill_in_generic_residual_contribution_fluid_traction(residuals,jacobian); */
277 /* } */
278 
280  void output(std::ostream &outfile) {FiniteElement::output(outfile);}
281 
283  void output(std::ostream &outfile, const unsigned &nplot)
284  {FiniteElement::output(outfile,nplot);}
285 
288  void add_pressure_data(Data* pressure_data_pt)
289  {
290  Pressure_data_id = this->add_external_data(pressure_data_pt);
291  }
292 
293 protected:
294 
295 
301  virtual inline int u_local_eqn(const unsigned &n, const unsigned &i)
302  {return this->nodal_local_eqn(n,i);}
303 
306  inline double shape_and_test_at_knot(const unsigned &ipt,
307  Shape &psi, Shape &test)
308  const
309  {
310  //Find number of nodes
311  unsigned n_node = this->nnode();
312  //Calculate the shape functions
313  this->shape_at_knot(ipt,psi);
314  //Set the test functions to be the same as the shape functions
315  for(unsigned i=0;i<n_node;i++) {test[i] = psi[i];}
316  //Return the value of the jacobian
317  return this->J_eulerian_at_knot(ipt);
318  }
319 
320 
325  Vector<double> &residuals,
326  DenseMatrix<double> &jacobian)
327  {
328  //Find out how many nodes there are
329  unsigned n_node = this->nnode();
330 
331  //Set up memory for the shape and test functions
332  Shape psif(n_node), testf(n_node);
333 
334  //Set the value of n_intpt
335  unsigned n_intpt = this->integral_pt()->nweight();
336 
337  //Integers to store local equation numbers
338  int local_eqn=0;
339 
340  // Get the pressure at the outflow
341  double pressure = this->external_data_pt(Pressure_data_id)->value(0);
342 
343  //Loop over the integration points
344  for(unsigned ipt=0;ipt<n_intpt;ipt++)
345  {
346  //Get the integral weight
347  double w = this->integral_pt()->weight(ipt);
348 
349  //Find the shape and test functions and return the Jacobian
350  //of the mapping
351  double J = shape_and_test_at_knot(ipt,psif,testf);
352 
353  //Premultiply the weights and the Jacobian
354  double W = w*J;
355 
356  //Need to find position to feed into Traction function
358 
359  //Initialise to zero
360  for(unsigned i=0;i<Dim;i++) {interpolated_x[i] = 0.0;}
361 
362  //Calculate velocities and derivatives
363  for(unsigned l=0;l<n_node;l++)
364  {
365  //Loop over velocity components
366  for(unsigned i=0;i<Dim;i++) {interpolated_x[i] +=
367  this->nodal_position(l,i)*psif[l];}
368  }
369 
370  // Get the outer unit normal
371  Vector<double> unit_normal(Dim);
372  this->outer_unit_normal(ipt, unit_normal);
373 
374  // Calculate the traction
375  Vector<double> traction(Dim);
376  for (unsigned i=0; i<Dim; i++)
377  {
378  traction[i] = pressure*unit_normal[i];
379  }
380 
381  //Loop over the test functions
382  for(unsigned l=0;l<n_node;l++)
383  {
384  //Loop over the velocity components
385  for(unsigned i=0;i<Dim;i++)
386  {
387  local_eqn = u_local_eqn(l,i);
388  /*IF it's not a boundary condition*/
389  if(local_eqn >= 0)
390  {
391  //Add the user-defined traction terms
392  residuals[local_eqn] += traction[i]*testf[l]*W;
393 
394  //Assuming the the traction DOES NOT depend upon velocities
395  //or pressures, the jacobian is always zero, so no jacobian
396  //terms are required
397 
398  }
399  } //End of loop over dimension
400  } //End of loop over shape functions
401 
402  }
403 
404  }
405 
406 private:
407 
411 
413  unsigned Dim;
414 
415 
416 };
417 
418 #endif
419 
420 
421 
422 }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
Array< double, 1, 3 > e(1./3., 0.5, 2.)
JacobiRotation< float > J
Definition: Jacobi_makeJacobi.cpp:3
RowVector3d w
Definition: Matrix_resize_int.cpp:3
Definition: nodes.h:86
double value(const unsigned &i) const
Definition: nodes.h:293
int & face_index()
Definition: elements.h:4626
void outer_unit_normal(const Vector< double > &s, Vector< double > &unit_normal) const
Compute outer unit normal at the specified local coordinate.
Definition: elements.cc:6006
double interpolated_x(const Vector< double > &s, const unsigned &i) const
Definition: elements.h:4528
double J_eulerian_at_knot(const unsigned &ipt) const
Definition: elements.cc:5328
Definition: elements.h:1313
Node *& node_pt(const unsigned &n)
Return a pointer to the local node n.
Definition: elements.h:2175
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
Integral *const & integral_pt() const
Return the pointer to the integration scheme (const version)
Definition: elements.h:1963
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
Definition: elements.h:73
Data *& external_data_pt(const unsigned &i)
Return a pointer to i-th external data object.
Definition: elements.h:659
unsigned add_external_data(Data *const &data_pt, const bool &fd=true)
Definition: elements.cc:307
static DenseMatrix< double > Dummy_matrix
Definition: elements.h:227
unsigned add_internal_data(Data *const &data_pt, const bool &fd=true)
Definition: elements.cc:62
virtual unsigned nweight() const =0
Return the number of integration points of the scheme.
virtual double weight(const unsigned &i) const =0
Return weight of i-th integration point.
Definition: mesh.h:67
FiniteElement * finite_element_pt(const unsigned &e) const
Definition: mesh.h:473
GeneralisedElement *& element_pt(const unsigned long &e)
Return pointer to element e.
Definition: mesh.h:448
unsigned long nelement() const
Return number of elements in the mesh.
Definition: mesh.h:590
Definition: navier_stokes_flux_control_elements.h:351
void fill_in_generic_residual_contribution_fluid_traction(Vector< double > &residuals, DenseMatrix< double > &jacobian)
Definition: flux_control_elements_bk.h:324
unsigned Pressure_data_id
Definition: flux_control_elements_bk.h:410
void output(std::ostream &outfile, const unsigned &nplot)
Output function: x,y,[z],u,v,[w],p in tecplot format.
Definition: flux_control_elements_bk.h:283
double get_volume_flux()
Function to get the integral of the volume flux.
Definition: navier_stokes_flux_control_elements.h:416
unsigned nblock_types()
Definition: flux_control_elements_bk.h:252
double shape_and_test_at_knot(const unsigned &ipt, Shape &psi, Shape &test) const
Definition: flux_control_elements_bk.h:306
void output(std::ostream &outfile)
Overload the output function.
Definition: flux_control_elements_bk.h:280
~NavierStokesFluxControlElement()
Destructor should not delete anything.
Definition: flux_control_elements_bk.h:248
unsigned Dim
The highest dimension of the problem.
Definition: flux_control_elements_bk.h:413
virtual int u_local_eqn(const unsigned &n, const unsigned &i)
Definition: flux_control_elements_bk.h:301
void fill_in_contribution_to_residuals(Vector< double > &residuals)
This function returns just the residuals.
Definition: flux_control_elements_bk.h:264
void add_pressure_data(Data *pressure_data_pt)
Definition: flux_control_elements_bk.h:288
void get_dof_numbers_for_unknowns(std::list< std::pair< unsigned long, unsigned > > &block_lookup_list)
Definition: flux_control_elements_bk.h:259
NavierStokesFluxControlElement(FiniteElement *const &element_pt, const int &face_index)
Definition: flux_control_elements_bk.h:215
Definition: navier_stokes_surface_power_elements.h:52
Definition: flux_control_elements_bk.h:54
double * Prescribed_outflow_value_pt
Pointer to the value that stores the prescribed outflow.
Definition: flux_control_elements_bk.h:189
void fill_in_contribution_to_residuals(Vector< double > &residuals)
Definition: flux_control_elements_bk.h:110
NetFluxControlElement(const NetFluxControlElement &)
Broken copy constructor.
Definition: flux_control_elements_bk.h:96
NetFluxControlElement(Mesh *flux_control_mesh_pt, double *prescribed_outflow_value_pt)
Definition: flux_control_elements_bk.h:59
Data * Pressure_data_pt
Definition: flux_control_elements_bk.h:182
Data * pressure_data_pt() const
Definition: flux_control_elements_bk.h:104
~NetFluxControlElement()
Empty Destructor - Data gets deleted automatically.
Definition: flux_control_elements_bk.h:93
Mesh * Flux_control_mesh_pt
Definition: flux_control_elements_bk.h:186
unsigned ndim() const
Return (Eulerian) spatial dimension of the node.
Definition: nodes.h:1054
Definition: oomph_definitions.h:267
Definition: refineable_elements.h:97
Definition: shape.h:76
void broken_copy(const std::string &class_name)
Issue error message and terminate execution.
Definition: oomph_utilities.cc:212
@ 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