oomph::Hijacked< ELEMENT > Class Template Reference

#include <hijacked_elements.h>

+ Inheritance diagram for oomph::Hijacked< ELEMENT >:

Public Member Functions

 Hijacked ()
 Constructor, call the constructors of the base elements. More...
 
 Hijacked (FiniteElement *const &element_pt, const int &face_index)
 Constructor used for hijacking face elements. More...
 
 Hijacked (FiniteElement *const &element_pt, const int &face_index, const unsigned &id=0)
 
Datahijack_internal_value (const unsigned &n, const unsigned &i, const bool &return_data=true)
 
Datahijack_external_value (const unsigned &n, const unsigned &i, const bool &return_data=true)
 
Datahijack_nodal_value (const unsigned &n, const unsigned &i, const bool &return_data=true)
 
Datahijack_nodal_position_value (const unsigned &n, const unsigned &i, const bool &return_data=true)
 
Datahijack_nodal_spine_value (const unsigned &n, const unsigned &i, const bool &return_data=true)
 
void assign_local_eqn_numbers (const bool &store_local_dof_pt)
 
void get_residuals (Vector< double > &residuals)
 
void get_jacobian (Vector< double > &residuals, DenseMatrix< double > &jacobian)
 
- Public Member Functions inherited from oomph::HijackedElementBase
 HijackedElementBase ()
 
virtual ~HijackedElementBase ()
 Destructor, destroy the storage for the equation numbers. More...
 
void unhijack_all_data ()
 
const doubleresidual_multiplier () const
 Return the value of the residual multiplier. More...
 
double *& residual_multiplier_pt ()
 Return the pointer to the residual multiplier. More...
 

Additional Inherited Members

- Protected Member Functions inherited from oomph::HijackedElementBase
void hijack_global_eqn (long *const &global_eqn_pt)
 
void unhijack_global_eqn (long *const &global_eqn_pt)
 
- Protected Attributes inherited from oomph::HijackedElementBase
std::set< long * > * Hijacked_global_eqn_number_pt
 
Vector< int > * Hijacked_local_eqn_number_pt
 
doubleResidual_multiplier_pt
 
- Static Protected Attributes inherited from oomph::HijackedElementBase
static double Default_residual_multiplier = 0.0
 

Detailed Description

template<class ELEMENT>
class oomph::Hijacked< ELEMENT >

Hijacked elements are elements in which one or more Data values that affect the element's residuals, are determined by another element – the data values are then said to have been hijacked by another element. The main functionality added by the Hijacked element class is that it wipes out those entries in the element's residual vector and those rows in the element's Jacobian matrix that are determined by the "other" elements that have hijacked the values. Note that for continuation in homotopy parameters, it may be desriable to multiply the residuals and corresponding jacobian entries by a "homotopy parameter". The value of this parameter can be set by assigning residual_multiplier_pt() which has a default value of zero. Note: it would be possible to extend the functionality so that different residuals are multiplied by different values, but will this ever be required?

Constructor & Destructor Documentation

◆ Hijacked() [1/3]

template<class ELEMENT >
oomph::Hijacked< ELEMENT >::Hijacked ( )
inline

Constructor, call the constructors of the base elements.

135 : ELEMENT(), HijackedElementBase() {}
HijackedElementBase()
Definition: hijacked_elements.h:49

◆ Hijacked() [2/3]

template<class ELEMENT >
oomph::Hijacked< ELEMENT >::Hijacked ( FiniteElement *const &  element_pt,
const int face_index 
)
inline

Constructor used for hijacking face elements.

139  : ELEMENT(element_pt, face_index), HijackedElementBase()
140  {
141  }

◆ Hijacked() [3/3]

template<class ELEMENT >
oomph::Hijacked< ELEMENT >::Hijacked ( FiniteElement *const &  element_pt,
const int face_index,
const unsigned id = 0 
)
inline

Constructor used for hijacking face elements with specification of ID of additional variables

149  : ELEMENT(element_pt, face_index, id), HijackedElementBase()
150  {
151  }

Member Function Documentation

◆ assign_local_eqn_numbers()

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

Set up the local equation numbers for the underlying element, then set up the local arrays to hold the hijacked variables. If the boolean argument is true then pointers to the associated degrees of freedom are stored in the array Dof_pt

319  {
320  // If things have already been allocated,
321  // clear the local hijacked array, so that if the equation numbers
322  // are reassigned after changes in the boundary conditions, the
323  // correct terms will be in the array.
325  {
327  }
328  // Otherwise allocate it
329  else
330  {
331  Hijacked_local_eqn_number_pt = new Vector<int>;
332  }
333 
334 
335  // Call the hijacked element's assign_local_eqn_numbers
336  ELEMENT::assign_local_eqn_numbers(store_local_dof_pt);
337 
338  // If any values have been hijacked, we need to find the corresponding
339  // local equation numbers
341  {
342  // Now loop over the local array that stores GLOBAL equation numbers
343  // to check if any of the local values have in fact been hijacked
344  // by "somebody"
345  unsigned n_dof = this->ndof();
346  for (unsigned i = 0; i < n_dof; i++)
347  {
348  // Loop over *all* hijacked data
349  for (std::set<long*>::iterator it =
351  it != Hijacked_global_eqn_number_pt->end();
352  ++it)
353  {
354  // If the hijacked (global!) equation is not pinned
355  if (*(*it) >= 0)
356  {
357  // Get the (unsigned) global equation number:
358  // Note that it is only unsigned AFTER the test above.
359  unsigned long hijacked_eqn_number = *(*it);
360 
361  // If a GLOBAL variable used by this element is hijacked add the
362  // variable's LOCAL index to the array
363  if (hijacked_eqn_number == this->eqn_number(i))
364  {
365  Hijacked_local_eqn_number_pt->push_back(i);
366  break;
367  }
368  }
369  }
370  }
371  }
372  }
int i
Definition: BiCGSTAB_step_by_step.cpp:9
std::set< long * > * Hijacked_global_eqn_number_pt
Definition: hijacked_elements.h:86
Vector< int > * Hijacked_local_eqn_number_pt
Definition: hijacked_elements.h:91

References oomph::HijackedElementBase::Hijacked_global_eqn_number_pt, oomph::HijackedElementBase::Hijacked_local_eqn_number_pt, and i.

◆ get_jacobian()

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

Get the residuals and Jacobian matrix from the underlying element, but then wipe the entries in the residual vector and the rows in the Jacobian matrix that correspond to hijacked values – they will be computed by other elements.

396  {
397  // Call the element's get jacobian function
398  ELEMENT::get_jacobian(residuals, jacobian);
399  // Wipe any hijacked dofs
400  unsigned n_hijacked = Hijacked_local_eqn_number_pt->size();
401  unsigned n_dof = this->ndof();
402  for (unsigned i = 0; i < n_hijacked; i++)
403  {
404  // Multiply any hijacked dofs by the residual multiplier
405  //(default value is zero)
406  residuals[(*Hijacked_local_eqn_number_pt)[i]] *= residual_multiplier();
407  // Multiply the row in the Jacobian matrix by the residual
408  // multiplier for consistency
409  for (unsigned j = 0; j < n_dof; j++)
410  {
411  jacobian((*Hijacked_local_eqn_number_pt)[i], j) *=
413  }
414  }
415  }
const double & residual_multiplier() const
Return the value of the residual multiplier.
Definition: hijacked_elements.h:70
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2

References oomph::HijackedElementBase::Hijacked_local_eqn_number_pt, i, j, and oomph::HijackedElementBase::residual_multiplier().

◆ get_residuals()

template<class ELEMENT >
void oomph::Hijacked< ELEMENT >::get_residuals ( Vector< double > &  residuals)
inline

Get the residuals from the underlying element, but then wipe the entries in the residual vector that correspond to hijacked values – they will be computed by other elements.

378  {
379  // Get parent redisuals
380  ELEMENT::get_residuals(residuals);
381  // Multiply any hijacked dofs by the residual multiplier
382  //(default value is zero)
383  unsigned n_hijacked = Hijacked_local_eqn_number_pt->size();
384  for (unsigned i = 0; i < n_hijacked; i++)
385  {
386  residuals[(*Hijacked_local_eqn_number_pt)[i]] *= residual_multiplier();
387  }
388  }
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(), oomph::HijackedElementBase::Hijacked_local_eqn_number_pt, i, and oomph::HijackedElementBase::residual_multiplier().

◆ hijack_external_value()

template<class ELEMENT >
Data* oomph::Hijacked< ELEMENT >::hijack_external_value ( const unsigned n,
const unsigned i,
const bool return_data = true 
)
inline

Hijack the i-th value stored at external data n. Optionally return a custom-made (copied) data object that contains only the hijacked value. Note that the calling program assumes responsibility for this data object and must clean it up. The default is that the data object is returned

191  {
192  // Initialise pointer to zero
193  Data* temp_data_pt = 0;
194  // If desired
195  // create a new Data object containing only the value that is to be
196  // hijacked
197  if (return_data)
198  {
199  temp_data_pt = new HijackedData(i, this->external_data_pt(n));
200  }
201 
202  // Mark the value as hijacked
203  hijack_global_eqn(this->external_data_pt(n)->eqn_number_pt(i));
204 
205  // Return the pointer to the data
206  return temp_data_pt;
207  }
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
void hijack_global_eqn(long *const &global_eqn_pt)
Definition: hijacked_elements.cc:62

References oomph::HijackedElementBase::hijack_global_eqn(), i, and n.

◆ hijack_internal_value()

template<class ELEMENT >
Data* oomph::Hijacked< ELEMENT >::hijack_internal_value ( const unsigned n,
const unsigned i,
const bool return_data = true 
)
inline

Hijack the i-th value stored at internal data n. Optionally return a custom-made (copied) data object that contains only the hijacked value. This can be used as the input to other elements. Note that the calling program assumes responsibility for this data object and must clean it up. The default is that the data object is returned

163  {
164  // Initialise pointer to zero
165  Data* temp_data_pt = 0;
166 
167  // If desired,
168  // Create a new Data object containing only the value that is to be
169  // hijacked
170  if (return_data)
171  {
172  temp_data_pt = new HijackedData(i, this->internal_data_pt(n));
173  }
174 
175  // Mark the value as hijacked
176  hijack_global_eqn(this->internal_data_pt(n)->eqn_number_pt(i));
177 
178  // Return the pointer to the data
179  return temp_data_pt;
180  }

References oomph::HijackedElementBase::hijack_global_eqn(), i, and n.

◆ hijack_nodal_position_value()

template<class ELEMENT >
Data* oomph::Hijacked< ELEMENT >::hijack_nodal_position_value ( const unsigned n,
const unsigned i,
const bool return_data = true 
)
inline

Hijack the i-th positional value stored at node n. Optionaly return a custom-made (copied) data object that contains only the hijacked value. Again, responsibility for the memory allocated lies with the calling function. The default is that the data object is returned

243  {
244  // Can we do the casting?
245  SolidNode* solid_node_pt = dynamic_cast<SolidNode*>(this->node_pt(n));
246  if (solid_node_pt == 0)
247  {
248  std::string error_message = "Failed to cast to SolidNode\n ";
249  error_message += "You may be trying to hijack a non-elastic element\n";
250 
251  throw OomphLibError(
253  }
254 
255  // Initialise pointer to zero
256  Data* temp_data_pt = 0;
257  // If desired
258  // create a new Data object containing only the value that is to be
259  // hijacked
260  if (return_data)
261  {
262  temp_data_pt =
263  new HijackedData(i, solid_node_pt->variable_position_pt());
264  }
265 
266  // Mark the value as hijacked
268  solid_node_pt->variable_position_pt()->eqn_number_pt(i));
269 
270  // Return the pointer to the data
271  return temp_data_pt;
272  }
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86

References oomph::Data::eqn_number_pt(), oomph::HijackedElementBase::hijack_global_eqn(), i, n, OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, oomph::Global_string_for_annotation::string(), and oomph::SolidNode::variable_position_pt().

◆ hijack_nodal_spine_value()

template<class ELEMENT >
Data* oomph::Hijacked< ELEMENT >::hijack_nodal_spine_value ( const unsigned n,
const unsigned i,
const bool return_data = true 
)
inline

Hijack the i-th value stored at the spine that affects local node n. Optionally return a custom-made (copied) data object that contains only the hijacked value. Deletion must be handled at the higher level The default is that the data object is returned

282  {
283  // Can we actually do this casting
284  SpineNode* spine_node_pt = dynamic_cast<SpineNode*>(this->node_pt(n));
285  if (spine_node_pt == 0)
286  {
287  std::string error_message = "Failed to cast to SpineNode\n ";
288  error_message += "You may be trying to hijack a non-spine element\n";
289 
290  throw OomphLibError(
292  }
293 
294  // Initialise pointer to zero
295  Data* temp_data_pt = 0;
296  // If desired
297  // create a new Data object containing only the value that is to be
298  // hijacked
299  if (return_data)
300  {
301  temp_data_pt =
302  new HijackedData(i, spine_node_pt->spine_pt()->spine_height_pt());
303  }
304 
305  // Mark the data as hijacked
307  spine_node_pt->spine_pt()->spine_height_pt()->eqn_number_pt(i));
308 
309  // Return the pointer to the data
310  return temp_data_pt;
311  }

References oomph::Data::eqn_number_pt(), oomph::HijackedElementBase::hijack_global_eqn(), i, n, OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, oomph::Spine::spine_height_pt(), oomph::SpineNode::spine_pt(), and oomph::Global_string_for_annotation::string().

◆ hijack_nodal_value()

template<class ELEMENT >
Data* oomph::Hijacked< ELEMENT >::hijack_nodal_value ( const unsigned n,
const unsigned i,
const bool return_data = true 
)
inline

Hijack the i-th value stored at node n. Optionally return a custom-made (copied) data object that contains only the hijacked value. Once again, the calling program must clean up the allocated Data object. The default is that the data object is returned

217  {
218  // Initialise pointer to zero
219  Data* temp_data_pt = 0;
220  // If desired
221  // create a new Data object containing only the value that is to be
222  // hijacked
223  if (return_data)
224  {
225  temp_data_pt = new HijackedData(i, this->node_pt(n));
226  }
227 
228  // Mark the value as hijacked
229  hijack_global_eqn(this->node_pt(n)->eqn_number_pt(i));
230 
231  // Return the pointer to the data, which may be null
232  return temp_data_pt;
233  }

References oomph::HijackedElementBase::hijack_global_eqn(), i, and n.

Referenced by AirwayReopeningProblem< ELEMENT >::AirwayReopeningProblem(), oomph::BiharmonicFluidProblem< DIM >::impose_traction_free_edge(), and ThreeDimBethertonProblem< ELEMENT >::ThreeDimBethertonProblem().


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