oomph::HijackedData Class Reference

#include <nodes.h>

+ Inheritance diagram for oomph::HijackedData:

Public Member Functions

void clear_copied_pointers ()
 Clear the pointers to the copied data. More...
 
 HijackedData (const unsigned &copied_value, Data *const &data_pt)
 Constructor. More...
 
 HijackedData (const Data &data)=delete
 (Shallow) copy constructor More...
 
void operator= (const HijackedData &)=delete
 Broken assignment operator. More...
 
 ~HijackedData ()
 
bool is_a_copy () const
 
bool is_a_copy (const unsigned &i) const
 
void assign_eqn_numbers (unsigned long &global_ndof, Vector< double * > &dof_pt)
 
void resize (const unsigned &n_value)
 We do not allow Hijacked Data to be resized. More...
 
- Public Member Functions inherited from oomph::Data
 Data ()
 Default constructor. More...
 
 Data (const unsigned &initial_n_value)
 
 Data (TimeStepper *const &time_stepper_pt, const unsigned &initial_n_value, const bool &allocate_storage=true)
 
 Data (const Data &data)=delete
 Broken copy constructor. More...
 
void operator= (const Data &)=delete
 Broken assignment operator. More...
 
virtual ~Data ()
 Destructor, deallocates memory assigned for data. More...
 
void set_time_stepper (TimeStepper *const &time_stepper_pt, const bool &preserve_existing_data)
 
TimeStepper *& time_stepper_pt ()
 Return the pointer to the timestepper. More...
 
TimeStepper *const & time_stepper_pt () const
 Return the pointer to the timestepper (const version). More...
 
void set_value (const unsigned &i, const double &value_)
 
void set_value (const unsigned &t, const unsigned &i, const double &value_)
 
double value (const unsigned &i) const
 
double value (const unsigned &t, const unsigned &i) const
 
void value (Vector< double > &values) const
 Compute Vector of values for the Data value. More...
 
void value (const unsigned &t, Vector< double > &values) const
 
doublevalue_pt (const unsigned &i) const
 
doublevalue_pt (const unsigned &t, const unsigned &i) const
 
bool does_pointer_correspond_to_value (double *const &parameter_pt)
 Check whether the pointer parameter_pt addresses internal data values. More...
 
void copy (Data *orig_data_pt)
 Copy Data values from specified Data object. More...
 
void dump (std::ostream &dump_file) const
 Dump the data object to a file. More...
 
void read (std::ifstream &restart_file)
 Read data object from a file. More...
 
long * eqn_number_pt (const unsigned &i)
 Return the pointer to the equation number of the i-th stored variable. More...
 
long & eqn_number (const unsigned &i)
 Return the equation number of the i-th stored variable. More...
 
long eqn_number (const unsigned &i) const
 Return the equation number of the i-th stored variable. More...
 
void pin (const unsigned &i)
 Pin the i-th stored variable. More...
 
void unpin (const unsigned &i)
 Unpin the i-th stored variable. More...
 
void pin_all ()
 Pin all the stored variables. More...
 
void unpin_all ()
 Unpin all the stored variables. More...
 
bool is_pinned (const unsigned &i) const
 Test whether the i-th variable is pinned (1: true; 0: false). More...
 
bool is_segregated_solve_pinned (const unsigned &i)
 
void constrain (const unsigned &i)
 
void unconstrain (const unsigned &i)
 
void constrain_all ()
 Constrain all the stored variables when the data is made hanging. More...
 
void unconstrain_all ()
 Unconstrain all the stored variables when the data is made nonhanging. More...
 
bool is_constrained (const unsigned &i)
 
unsigned self_test ()
 
unsigned nvalue () const
 Return number of values stored in data object (incl pinned ones). More...
 
unsigned ntstorage () const
 
virtual void describe_dofs (std::ostream &out, const std::string &current_string) const
 
virtual void add_value_pt_to_map (std::map< unsigned, double * > &map_of_value_pt)
 

Private Member Functions

void reset_copied_pointers ()
 Reset the pointers to the copied data. More...
 

Private Attributes

DataCopied_data_pt
 Pointer to the Data object from which the value is copied. More...
 
unsigned Copied_index
 Index of the value that is copied from within the Data object. More...
 

Additional Inherited Members

- Static Public Attributes inherited from oomph::Data
static long Is_pinned = -1
 Static "Magic number" to indicate pinned values. More...
 
static long Is_segregated_solve_pinned = -3
 
static long Is_unclassified = -10
 
static long Is_constrained = -2
 
- Protected Attributes inherited from oomph::Data
Data ** Copy_of_data_pt
 
unsigned Ncopies
 
- Static Protected Attributes inherited from oomph::Data
static TimeStepperDefault_static_time_stepper_pt = new Steady<0>()
 Default (static) timestepper used in steady problems. More...
 

Detailed Description

Custom Data class that is used when HijackingData. The class always contains a single value that is copied from another Data object.

Constructor & Destructor Documentation

◆ HijackedData() [1/2]

oomph::HijackedData::HijackedData ( const unsigned copied_index,
Data *const &  data_pt 
)

Constructor.

Constructor, creates a HijackedData object with a single value that is copied from another Data object. The ordering of the aguments is used to distinguish this case from that of copying all data values, except one independent value.

1333  : Data(data_pt->time_stepper_pt(), 1, false),
1334  Copied_data_pt(data_pt),
1335  Copied_index(copied_index)
1336  {
1337  // Don't allow copying of a copy
1338  if (data_pt->is_a_copy(copied_index))
1339  {
1340  std::ostringstream error_stream;
1341  error_stream << "The data you are trying to hijack is already a copy"
1342  << std::endl;
1343  error_stream << "Please copy the original data" << std::endl;
1344  error_stream << "In a later version, I might do this for you,"
1345  << " but not today" << std::endl;
1346 
1347  throw OomphLibError(
1348  error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
1349  }
1350 
1351  // Copy the pointer to the value. This will give the appropriate
1352  //"slice" of the array
1353  Value = &data_pt->Value[copied_index];
1354  // Copy the pointer to the equation number
1355  Eqn_number = &data_pt->Eqn_number[copied_index];
1356  // Inform the original data that it has been copied
1357  data_pt->add_copy(this);
1358  }
long * Eqn_number
Definition: nodes.h:116
double ** Value
Definition: nodes.h:112
Data()
Default constructor.
Definition: nodes.cc:237
Data * Copied_data_pt
Pointer to the Data object from which the value is copied.
Definition: nodes.h:578
unsigned Copied_index
Index of the value that is copied from within the Data object.
Definition: nodes.h:581
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86

References oomph::Data::add_copy(), oomph::Data::Eqn_number, oomph::Data::is_a_copy(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION, and oomph::Data::Value.

◆ HijackedData() [2/2]

oomph::HijackedData::HijackedData ( const Data data)
delete

(Shallow) copy constructor

◆ ~HijackedData()

oomph::HijackedData::~HijackedData ( )
inline

Destructor informs original object that the copy is being deleted and clears its pointers to the stored values.

602  {
603  // Inform the Copied data that this copy is being deleted
604  // If the original has already been deleted
605  // Copied_data_pt will be set to NULL and this will not be
606  // necessary
607  if (Copied_data_pt)
608  {
610  }
611  // Now null out the storage
612  Copied_data_pt = 0;
613  Value = 0;
614  Eqn_number = 0;
615  }
void remove_copy(Data *const &data_pt)
Definition: nodes.cc:102

References Copied_data_pt, oomph::Data::Eqn_number, oomph::Data::remove_copy(), and oomph::Data::Value.

Member Function Documentation

◆ assign_eqn_numbers()

void oomph::HijackedData::assign_eqn_numbers ( unsigned long &  global_ndof,
Vector< double * > &  dof_pt 
)
inlinevirtual

HijackedData is always a copy, so no equation numbers should be allocated. This function just returns.

Reimplemented from oomph::Data.

635  {
636  return;
637  }

◆ clear_copied_pointers()

void oomph::HijackedData::clear_copied_pointers ( )
virtual

Clear the pointers to the copied data.

Reimplemented from oomph::Data.

1319  {
1320  Copied_data_pt = 0;
1321  Value = 0;
1322  Eqn_number = 0;
1323  }

References Copied_data_pt, oomph::Data::Eqn_number, and oomph::Data::Value.

◆ is_a_copy() [1/2]

bool oomph::HijackedData::is_a_copy ( ) const
inlinevirtual

Return a boolean to indicate whether the data contains any copied values. Hijacked data is always a copy

Reimplemented from oomph::Data.

620  {
621  return true;
622  }

◆ is_a_copy() [2/2]

bool oomph::HijackedData::is_a_copy ( const unsigned i) const
inlinevirtual

Return a boolean to indicate whether the i-th value is a copied value. Hijacked data is always a copy

Reimplemented from oomph::Data.

628  {
629  return true;
630  }

◆ operator=()

void oomph::HijackedData::operator= ( const HijackedData )
delete

Broken assignment operator.

◆ reset_copied_pointers()

void oomph::HijackedData::reset_copied_pointers ( )
privatevirtual

Reset the pointers to the copied data.

Reimplemented from oomph::Data.

1305  {
1306  // Copy the pointer to the value. This will give the appropriate
1307  //"slice" of the array
1309 
1310  // Copy the pointer to the equation number
1312  }

References Copied_data_pt, Copied_index, oomph::Data::Eqn_number, and oomph::Data::Value.

◆ resize()

void oomph::HijackedData::resize ( const unsigned n_value)
virtual

We do not allow Hijacked Data to be resized.

We cannot resize HijackedData, so the resize function throws a warning.

Reimplemented from oomph::Data.

1364  {
1365  throw OomphLibError("HijackedData cannot be resized",
1368  }

References OOMPH_CURRENT_FUNCTION, and OOMPH_EXCEPTION_LOCATION.

Member Data Documentation

◆ Copied_data_pt

Data* oomph::HijackedData::Copied_data_pt
private

Pointer to the Data object from which the value is copied.

Referenced by clear_copied_pointers(), reset_copied_pointers(), and ~HijackedData().

◆ Copied_index

unsigned oomph::HijackedData::Copied_index
private

Index of the value that is copied from within the Data object.

Referenced by reset_copied_pointers().


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