jh_includes.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 
27 //Header file for my FluxConstraint and jh_mesh classes
28 
29 namespace oomph
30 {
31 
32 //=======================================================================
34 //=======================================================================
36 {
37  double Flux;
38 
39  protected:
40 
43 
47 
48  public:
51  {
52  //Specify flux
53  Flux=1.0;
54 
55  //Set the external pressure pointer to be zero
56  Pext_pt=0;
57  }
58 
60  void set_pressure_data(Data* pext_pt)
61  {
62  //Set external pressure pointer
63  Pext_pt=pext_pt;
64 
65  // Add to the element's external data so it gets included
66  // in the black-box local equation numbering scheme
68  this->add_external_data(Pext_pt);
69  }
70 
71  //Add the contribution to the residuals
73  {
74  //Storage for local eqn number
75  int pext_local_eqn;
76 
77  if(Pext_pt==0)
78  {
79  pext_local_eqn=-1;
80  }
81  else
82  {
83  //If at a non-zero degree of freedom add in the entry
85  }
86 
87  if(pext_local_eqn >= 0)
88  {
89  residuals[pext_local_eqn] = -Flux;
90  }
91  }
92 
94  DenseMatrix<double> &jacobian)
95  {
96  //Call the residuals
98  //No Jacobian terms :)
99  }
100 
102  DenseMatrix<double> &jacobian,
103  DenseMatrix<double> &mass_matrix)
104  {
105  //Call the residuals
107  //No Jacobian or mass matrix terms :)
108  }
109 
110 };
111 
112 //======================================================================
114 //======================================================================
115 template <class ELEMENT>
116 class jh_mesh : public virtual Refineable_r_mesh<ELEMENT>
117 {
118 protected:
119 
120  //Storage for pointers to my traction elements
125  //Storage for pointers to my shear stress integral elements
128 
129  //Internal storage for traction parameters
130 
131 public:
132 
135  {return Inlet_traction_elt_pt[e];}
140  {return Outlet_traction_elt_pt[e];}
143 
146  {return Flux_constraint_pt;}
147 
158 
161  jh_mesh(const unsigned int &nx,const unsigned int &ny) :
162  Refineable_r_mesh<ELEMENT>(nx,ny)
163  {
164  //Now bolt on traction stuff
165 
166  //Assign fluid elements to vector
168 
169  //Attach traction elements where needed
173 
174  //Attach shear integral elements
176 
177  }
178 
179  //Function to add the traction boundary elements
180  void make_traction_elements(const bool& outlet)
181  {
182  //Specify inlet/outlet specific quantities
183  unsigned ibound; int index; double eta;
184  if(outlet) {ibound=1;index=1;eta=Global_Physical_Variables::eta_outlet; }
185  else {ibound=3;index=-1;eta=Global_Physical_Variables::eta_inlet; }
186 
187  unsigned num_elt = this->nboundary_element(ibound);
188 
189  //Loop over the number of elements on the boundary
190  for(unsigned ielt=0;ielt<num_elt;ielt++)
191  {
192  PolarNavierStokesTractionElement<ELEMENT> *surface_element_pt =
194  (this->boundary_element_pt(ibound,ielt),index);
195  //Push it back onto the Element_pt Vector
196  this->Element_pt.push_back(surface_element_pt);
197 
198  if(outlet) { this->Outlet_traction_elt_pt.push_back(surface_element_pt); }
199  else { this->Inlet_traction_elt_pt.push_back(surface_element_pt); }
200 
201  //Any other information to pass:
202  surface_element_pt->set_eta(eta);
203  surface_element_pt->traction_fct_pt() =
205  surface_element_pt->set_boundary(index);
206  surface_element_pt->alpha_pt() = &Global_Physical_Variables::Alpha;
207 
208  }//End of loop over elements
209 
210  std::cout << std::endl << "Traction elements attached to mesh" << std::endl << std::endl;
211 
212  }//End of make traction elements
213 
214  //Function to add a generalised flux element
216  {
218  //Push it back onto the Element_pt Vector
219  this->Element_pt.push_back(Flux_constraint_pt);
220  }
221 
222  // Function to add shear stress integral elements
224  {
225  //loop over boundaries
226  for(unsigned ibound=0;ibound<4;ibound+=2)
227  {
228  int index;
229  if(ibound==0) index=-2;
230  else index=2;
231 
232  unsigned num_elt = this->nboundary_element(ibound);
233 
234  //Loop over the number of elements along boundary
235  for(unsigned ielt=0;ielt<num_elt;ielt++)
236  {
237  //Element on lower boundary
238  PolarStressIntegralElement<ELEMENT> *surface_element_pt =
240  (this->boundary_element_pt(ibound,ielt),index);
241 
242  //Push it back onto the appropriate vector
243  if(ibound==0)
244  this->Lower_stress_integral_elt_pt.push_back(surface_element_pt);
245  else this->Upper_stress_integral_elt_pt.push_back(surface_element_pt);
246 
247  }//End of loop over elements
248 
249  }//End of loop over boundaries
250 
251  std::cout << std::endl << "Shear elements attached to mesh" << std::endl << std::endl;
252 
253  }//End of make shear elements
254 
255  //Function to remove the traction boundary elements
257  {
258  //Find the number of traction elements
259  unsigned Ntraction = this->inlet_traction_elt_length();
260  Ntraction += this->outlet_traction_elt_length();
261 
262  //If we have traction elements at both ends then we have
263  //one extra element to remove (the flux constraint element)
265  {Ntraction+=1; this->Flux_constraint_pt=0;}
266 
267  //The traction elements are ALWAYS? stored at the end
268  //So delete and remove them
269  for(unsigned e=0;e<Ntraction;e++)
270  {
271  delete this->Element_pt.back();
272  this->Element_pt.pop_back();
273  }
274 
275  //Now clear the vectors of pointers to traction elements
276  Inlet_traction_elt_pt.clear();
277  Outlet_traction_elt_pt.clear();
278 
279  std::cout << std::endl << "Traction elements removed from mesh" << std::endl << std::endl;
280 
281  }//End of remove_traction_elements
282 
283  //Function to remove the traction boundary elements
285  {
286  //Find the number of shear elements
287  unsigned Nshear_lower = this->lower_stress_integral_elt_length();
288  unsigned Nshear_upper = this->upper_stress_integral_elt_length();
289 
290  //So delete and remove shear elements
291  for(unsigned e=0;e<Nshear_lower;e++)
292  {
293  delete this->Lower_stress_integral_elt_pt.back();
294  this->Lower_stress_integral_elt_pt.pop_back();
295  }
296  //So delete and remove shear elements
297  for(unsigned e=0;e<Nshear_upper;e++)
298  {
299  delete this->Upper_stress_integral_elt_pt.back();
300  this->Upper_stress_integral_elt_pt.pop_back();
301  }
302 
303  //Now clear the vectors of pointers to traction elements
306 
307  std::cout << std::endl << "Shear elements removed from mesh" << std::endl << std::endl;
308 
309  }//End of remove_shear_elements
310 
311  //Function to put current fluid elements into a vector of their own
313  {
314  unsigned check=inlet_traction_elt_length();
316 
317  this->Fluid_elt_pt.clear();
318 
319  if(check!=0)
320  {
321  std::cout << "Warning, attempting to assemble fluid element vector ";
322  std::cout << "whilst traction elements are attached to the mesh" << std::endl;
323  }
324  else
325  {
326  unsigned n_elt = this->Element_pt.size();
327  for(unsigned e=0;e<n_elt;e++)
328  {
329  this->Fluid_elt_pt.push_back(this->Element_pt[e]);
330  }
331  }
332  }//End of assign_fluid_element_vector
333 
334 }; //End of jh_mesh class
335 
336 
337 } //End of namespace oomph
338 
Array< double, 1, 3 > e(1./3., 0.5, 2.)
Definition: nodes.h:86
Generalised element used to specify the mass flux (=1)
Definition: jh_includes.h:36
Data * Pext_pt
Pointer to the Data item that stores the external pressure.
Definition: jh_includes.h:42
double Flux
Definition: jh_includes.h:37
void fill_in_contribution_to_residuals(Vector< double > &residuals)
Definition: jh_includes.h:72
void set_pressure_data(Data *pext_pt)
Function for setting up external pressure.
Definition: jh_includes.h:60
void fill_in_contribution_to_jacobian_and_mass_matrix(Vector< double > &residuals, DenseMatrix< double > &jacobian, DenseMatrix< double > &mass_matrix)
Definition: jh_includes.h:101
unsigned External_data_number_of_Pext
Definition: jh_includes.h:46
FluxConstraint()
Constructor there is one bit of internal data, the fixed flux.
Definition: jh_includes.h:50
void fill_in_contribution_to_jacobian(Vector< double > &residuals, DenseMatrix< double > &jacobian)
Definition: jh_includes.h:93
Definition: elements.h:73
unsigned add_external_data(Data *const &data_pt, const bool &fd=true)
Definition: elements.cc:307
int external_local_eqn(const unsigned &i, const unsigned &j)
Definition: elements.h:311
unsigned nboundary_element(const unsigned &b) const
Return number of finite elements that are adjacent to boundary b.
Definition: mesh.h:878
FiniteElement * boundary_element_pt(const unsigned &b, const unsigned &e) const
Return pointer to e-th finite element on boundary b.
Definition: mesh.h:840
Vector< GeneralisedElement * > Element_pt
Vector of pointers to generalised elements.
Definition: mesh.h:186
Definition: polar_fluid_traction_elements.h:54
void(*&)(const double &t, const Vector< double > &x, Vector< double > &result) traction_fct_pt()
Definition: polar_fluid_traction_elements.h:241
void set_eta(double eta)
Function to set Eta.
Definition: polar_fluid_traction_elements.h:185
void set_boundary(int bound)
Function to set boundary.
Definition: polar_fluid_traction_elements.h:173
double *& alpha_pt()
Pointer to Alpha.
Definition: polar_fluid_traction_elements.h:150
Definition: polar_stress_integral_elements.h:53
const unsigned & ny() const
Return number of elements in y direction.
Definition: rectangular_quadmesh.template.h:231
const unsigned & nx() const
Return number of elements in x direction.
Definition: rectangular_quadmesh.template.h:224
My log r spaced mesh.
Definition: refineable_r_mesh.h:37
Vector< GeneralisedElement * > Fluid_elt_pt
Definition: refineable_r_mesh.h:41
My fluid mesh (with traction elements)
Definition: jh_includes.h:117
unsigned inlet_traction_elt_length()
Return length of inlet traction element vector.
Definition: jh_includes.h:137
unsigned upper_stress_integral_elt_length()
Return length of upper stress integral element vector.
Definition: jh_includes.h:157
PolarStressIntegralElement< ELEMENT > * lower_stress_integral_elt_pt(unsigned long e)
Return pointer to shear integral element.
Definition: jh_includes.h:149
PolarStressIntegralElement< ELEMENT > * upper_stress_integral_elt_pt(unsigned long e)
Return pointer to shear integral element.
Definition: jh_includes.h:154
unsigned lower_stress_integral_elt_length()
Return length of lower stress integral element vector.
Definition: jh_includes.h:152
void make_shear_elements()
Definition: jh_includes.h:223
unsigned outlet_traction_elt_length()
Return length of outlet traction element vector.
Definition: jh_includes.h:142
void remove_shear_elements()
Definition: jh_includes.h:284
Vector< PolarStressIntegralElement< ELEMENT > * > Lower_stress_integral_elt_pt
Definition: jh_includes.h:126
void assign_fluid_element_vector()
Definition: jh_includes.h:312
PolarNavierStokesTractionElement< ELEMENT > * inlet_traction_elt_pt(unsigned e)
Return pointer to inlet traction element e.
Definition: jh_includes.h:134
FluxConstraint * Flux_constraint_pt
Generalised element to determine my mass flux (always 1)
Definition: jh_includes.h:124
Vector< PolarNavierStokesTractionElement< ELEMENT > * > Inlet_traction_elt_pt
Definition: jh_includes.h:121
FluxConstraint * flux_constraint_elt_pt()
Return pointer to Flux Cosntraint Element.
Definition: jh_includes.h:145
void make_traction_elements(const bool &outlet)
Definition: jh_includes.h:180
Vector< PolarNavierStokesTractionElement< ELEMENT > * > Outlet_traction_elt_pt
Definition: jh_includes.h:122
void remove_traction_elements()
Definition: jh_includes.h:256
void make_flux_element()
Definition: jh_includes.h:215
Vector< PolarStressIntegralElement< ELEMENT > * > Upper_stress_integral_elt_pt
Definition: jh_includes.h:127
PolarNavierStokesTractionElement< ELEMENT > * outlet_traction_elt_pt(unsigned e)
Return pointer to outlet traction element e.
Definition: jh_includes.h:139
jh_mesh(const unsigned int &nx, const unsigned int &ny)
Definition: jh_includes.h:161
void check(bool b, bool ref)
Definition: fastmath.cpp:12
bool outlet_traction
Definition: jeffery_hamel.cc:82
double eta_inlet
Definition: jeffery_hamel.cc:80
double Alpha
Scaling factor for wall thickness (to be used in an exercise)
Definition: unsteady_ring.cc:73
void traction_function(const double &time, const Vector< double > &x, Vector< double > &traction)
Unused (but assigned) function to specify tractions.
Definition: jeffery_hamel.cc:96
bool inlet_traction
Definition: jeffery_hamel.cc:79
double eta_outlet
Definition: jeffery_hamel.cc:83
double eta
Definition: foeppl_von_karman/circular_disk/circular_disk.cc:45
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
Definition: AnisotropicHookean.h:10