BrethertonElement< ELEMENT > Class Template Reference
+ Inheritance diagram for BrethertonElement< ELEMENT >:

Public Types

typedef void(* InflowFctPt) (const Vector< double > &x, Vector< double > &veloc)
 

Public Member Functions

 BrethertonElement ()
 Constructor: Call the constructor of the underlying element. More...
 
void activate_inflow_dependency_on_external_data (const Vector< Data * > &inflow_ext_data, const unsigned &inflow_boundary, InflowFctPt inflow_fct_pt)
 
void assign_local_eqn_numbers (const bool &store_local_dof_pt)
 
void get_jacobian (Vector< double > &residuals, DenseMatrix< double > &jacobian)
 

Private Member Functions

void reassign_inflow ()
 

Private Attributes

Vector< Data * > Inflow_ext_data
 Storage for the external Data that affects the inflow. More...
 
DenseMatrix< intInflow_ext_data_eqn
 
unsigned Inflow_boundary
 Number of the inflow boundary in the global mesh. More...
 
InflowFctPt Inflow_fct_pt
 

Detailed Description

template<class ELEMENT>
class BrethertonElement< ELEMENT >

"Bretherton element" is a fluid element (of type ELEMENT) for which the (inflow) velocity at those nodes that are located on a specified Mesh boundary is prescribed by Dirichlet boundary conditions. The key is that prescribed velocity profile can be a function of some external Data – this dependency must be taken into account when computing the element's Jacobian matrix.

This element type is useful, for instance, in the Bretherton problem, where the parabolic "inflow" profile is a function of the film thickness (represented by Spine heights) at the "outflow".

Member Typedef Documentation

◆ InflowFctPt

template<class ELEMENT >
typedef void(* BrethertonElement< ELEMENT >::InflowFctPt) (const Vector< double > &x, Vector< double > &veloc)

Typedef for pointer (global) function that specifies the the inflow

Constructor & Destructor Documentation

◆ BrethertonElement()

template<class ELEMENT >
BrethertonElement< ELEMENT >::BrethertonElement ( )
inline

Constructor: Call the constructor of the underlying element.

163 : ELEMENT() {}

Member Function Documentation

◆ activate_inflow_dependency_on_external_data()

template<class ELEMENT >
void BrethertonElement< ELEMENT >::activate_inflow_dependency_on_external_data ( const Vector< Data * > &  inflow_ext_data,
const unsigned inflow_boundary,
InflowFctPt  inflow_fct_pt 
)
inline

Activate the dependency of the "inflow" on the external data. Pass the vector of pointers to the external Data that affects the inflow, the id of the boundary on which the inflow condition is to be applied and the function pointer to to the global function that defines the inflow

175  {
176  // Copy data that affects the inflow
177  unsigned n_ext=inflow_ext_data.size();
178  Inflow_ext_data.resize(n_ext);
179  for (unsigned i=0;i<n_ext;i++)
180  {
181  Inflow_ext_data[i]=inflow_ext_data[i];
182  }
183  // Set inflow boundary
184  Inflow_boundary=inflow_boundary;
185  // Set fct pointer to inflow condition
186  Inflow_fct_pt=inflow_fct_pt;
187  }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
unsigned Inflow_boundary
Number of the inflow boundary in the global mesh.
Definition: bretherton.cc:390
InflowFctPt Inflow_fct_pt
Definition: bretherton.cc:394
Vector< Data * > Inflow_ext_data
Storage for the external Data that affects the inflow.
Definition: bretherton.cc:383

References i.

◆ assign_local_eqn_numbers()

template<class ELEMENT >
void BrethertonElement< ELEMENT >::assign_local_eqn_numbers ( const bool store_local_dof_pt)
inline

Overload assign local equation numbers: Add the dependency on the external Data that affects the inflow profile

193  {
194  // Call the element's local equation numbering procedure first
195  ELEMENT::assign_local_eqn_numbers(store_local_dof_pt);
196 
197  // Now add the equation numbers for the Data that affects the inflow
198  // profile
199 
200  // Number of local equations so far
201  unsigned local_eqn_count = this->ndof();
202 
203  // Find out max. number of values stored at all Data values
204  // that affect the inflow
205  unsigned max_nvalue=0;
206  unsigned n_ext=Inflow_ext_data.size();
207  for (unsigned i=0;i<n_ext;i++)
208  {
209  // The external Data:
210  Data* data_pt=Inflow_ext_data[i];
211  // Number of values
212  unsigned n_val=data_pt->nvalue();
213  if (n_val>max_nvalue) max_nvalue=n_val;
214  }
215 
216  // Allocate sufficient storage
217  Inflow_ext_data_eqn.resize(n_ext,max_nvalue);
218 
219  //A local queue to store the global equation numbers
220  std::deque<unsigned long> global_eqn_number_queue;
221 
222  // Loop over external Data that affect the "inflow"
223  for (unsigned i=0;i<n_ext;i++)
224  {
225  // The external Data:
226  Data* data_pt=Inflow_ext_data[i];
227 
228  // Loop over number of values:
229  unsigned n_val=data_pt->nvalue();
230  for (unsigned ival=0;ival<n_val;ival++)
231  {
232 
233  // Is it free or pinned?
234  long eqn_number=data_pt->eqn_number(ival);
235  if (eqn_number>=0)
236  {
237  // Add global equation number to local storage
238  global_eqn_number_queue.push_back(eqn_number);
239  // Store local equation number associated with this external dof
240  Inflow_ext_data_eqn(i,ival)=local_eqn_count;
241  // Increment counter for local dofs
242  local_eqn_count++;
243  }
244  else
245  {
246  Inflow_ext_data_eqn(i,ival)=-1;
247  }
248  }
249  }
250 
251  //Now add our global equations numbers to the internal element storage
252  this->add_global_eqn_numbers(global_eqn_number_queue,
253  GeneralisedElement::Dof_pt_deque);
254  }
DenseMatrix< int > Inflow_ext_data_eqn
Definition: bretherton.cc:387
Definition: nodes.h:86
long & eqn_number(const unsigned &i)
Return the equation number of the i-th stored variable.
Definition: nodes.h:367
unsigned nvalue() const
Return number of values stored in data object (incl pinned ones).
Definition: nodes.h:483
void resize(const unsigned long &n)
Definition: matrices.h:498

References oomph::Data::eqn_number(), i, and oomph::Data::nvalue().

◆ get_jacobian()

template<class ELEMENT >
void BrethertonElement< ELEMENT >::get_jacobian ( Vector< double > &  residuals,
DenseMatrix< double > &  jacobian 
)
inline

Overloaded Jacobian computation: Computes the Jacobian of the underlying element and then adds the FD operations to evaluate the derivatives w.r.t. the Data values that affect the inflow.

263  {
264  // Loop over Data values that affect the inflow
265  unsigned n_ext=Inflow_ext_data.size();
266 
267  // Call "normal" jacobian first.
268  ELEMENT::get_jacobian(residuals,jacobian);
269 
270  if (n_ext==0) return;
271 
272  // Get ready for FD operations
273  Vector<double> residuals_plus(residuals.size());
274  double fd_step=1.0e-8;
275 
276  // Loop over Data values that affect the inflow
277  for (unsigned i=0;i<n_ext;i++)
278  {
279  // Get Data item
280  Data* data_pt=Inflow_ext_data[i];
281 
282  // Loop over values
283  unsigned n_val=data_pt->nvalue();
284  for (unsigned ival=0;ival<n_val;ival++)
285  {
286  // Local equation number
287  int local_eqn=Inflow_ext_data_eqn(i,ival);
288 
289  // Dof or pinned?
290  if (local_eqn>=0)
291  {
292  //get pointer to the data value
293  double *value_pt = data_pt->value_pt(ival);
294 
295  //Backup Data value
296  double backup = *value_pt;
297 
298  // Do FD step
299  *value_pt += fd_step;
300 
301  // Re-assign the inflow velocities for nodes in this element
302  reassign_inflow();
303 
304 
305  // Fill in the relevant column in the Jacobian matrix
306  unsigned n_dof = this->ndof();
307  //Zero the residuals
308  for(unsigned idof=0;idof<n_dof;idof++) {residuals_plus[idof] = 0.0;}
309  // Re-compute the element residual
310  this->get_residuals(residuals_plus);
311 
312  for(unsigned idof=0;idof<n_dof;idof++)
313  {
314  jacobian(idof,local_eqn)=
315  (residuals_plus[idof]-residuals[idof])/fd_step;
316  }
317 
318  //Reset spine height
319  *value_pt = backup;
320 
321  }
322  // Note: Re-assignment of inflow is done on the fly during next loop
323  }
324  }
325 
326  // Final re-assign for the inflow velocities for nodes in this element
327  reassign_inflow();
328 
329  }
void reassign_inflow()
Definition: bretherton.cc:339
double * value_pt(const unsigned &i) const
Definition: nodes.h:324
void get_residuals(const Vector< double > &param, const Vector< double > &unknowns, Vector< double > &residuals)
Global residual fct.
Definition: spring_contact.cc:65

References GlobalFct::get_residuals(), i, oomph::Data::nvalue(), and oomph::Data::value_pt().

◆ reassign_inflow()

template<class ELEMENT >
void BrethertonElement< ELEMENT >::reassign_inflow ( )
inlineprivate

For all nodes that are located on specified boundary re-assign the inflow velocity, using the function pointed to by the function pointer

340  {
341  // Loop over all nodes in element -- if they are
342  // on inflow boundary, re-assign their velocities
343  Vector<double> x(2);
344  Vector<double> veloc(2);
345  unsigned n_nod = this->nnode();
346  for (unsigned j=0;j<n_nod;j++)
347  {
348  Node* nod_pt = this->node_pt(j);
349 
350  if(nod_pt->is_on_boundary(Inflow_boundary))
351  {
352 #ifdef PARANOID
353  for (unsigned i=0;i<2;i++)
354  {
355  if (nod_pt->eqn_number(0)>=0)
356  {
357  std::ostringstream error_stream;
358  error_stream
359  << "We're assigning a Dirichlet condition for the "
360  << i << "-th "
361  << "velocity, even though it is not pinned!\n"
362  << "This can't be right! I'm bailing out..."
363  << std::endl;
364 
365  throw OomphLibError(error_stream.str(),
368  }
369  }
370 #endif
371  // Get inflow profile
372  x[0]=nod_pt->x(0);
373  x[1]=nod_pt->x(1);
374  Inflow_fct_pt(x,veloc);
375  nod_pt->set_value(0,veloc[0]);
376  nod_pt->set_value(1,veloc[1]);
377  }
378  }
379  }
void set_value(const unsigned &i, const double &value_)
Definition: nodes.h:271
Definition: nodes.h:906
double & x(const unsigned &i)
Return the i-th nodal coordinate.
Definition: nodes.h:1060
virtual bool is_on_boundary() const
Definition: nodes.h:1373
Definition: oomph_definitions.h:222
list x
Definition: plotDoE.py:28
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

References oomph::Data::eqn_number(), i, oomph::Node::is_on_boundary(), j, OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, oomph::Data::set_value(), plotDoE::x, and oomph::Node::x().

Member Data Documentation

◆ Inflow_boundary

template<class ELEMENT >
unsigned BrethertonElement< ELEMENT >::Inflow_boundary
private

Number of the inflow boundary in the global mesh.

◆ Inflow_ext_data

template<class ELEMENT >
Vector<Data*> BrethertonElement< ELEMENT >::Inflow_ext_data
private

Storage for the external Data that affects the inflow.

◆ Inflow_ext_data_eqn

template<class ELEMENT >
DenseMatrix<int> BrethertonElement< ELEMENT >::Inflow_ext_data_eqn
private

Storage for the local equation numbers associated the Data values that affect the inflow

◆ Inflow_fct_pt

template<class ELEMENT >
InflowFctPt BrethertonElement< ELEMENT >::Inflow_fct_pt
private

Function pointer to the global function that specifies the inflow velocity profile on the global mesh boundary Inflow_boundary


The documentation for this class was generated from the following file: