oomph::CopiedData Class Reference

#include <nodes.h>

+ Inheritance diagram for oomph::CopiedData:

Public Member Functions

void clear_copied_pointers ()
 Clear the pointers to the copied data. More...
 
 CopiedData (Data *const &data_pt)
 Constructor. More...
 
 CopiedData (const Data &data)=delete
 (Shallow) copy constructor More...
 
void operator= (const CopiedData &)=delete
 Broken assignment operator. More...
 
 ~CopiedData ()
 
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 Copied 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 values are copied. 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 making a shallow copy of a data object. The class contains a copy of an entire other Data object.

Constructor & Destructor Documentation

◆ CopiedData() [1/2]

oomph::CopiedData::CopiedData ( Data *const &  data_pt)

Constructor.

Constructor, creates a CopiedData object with all values copied from another Data object.

1410  : Data(data_pt->time_stepper_pt(), data_pt->nvalue(), false),
1411  Copied_data_pt(data_pt)
1412  {
1413  // Don't allow copying of a copy
1414  if (data_pt->is_a_copy())
1415  {
1416  std::ostringstream error_stream;
1417  error_stream << "The data you are trying to copy is already a copy"
1418  << std::endl;
1419  error_stream << "Please copy the original data" << std::endl;
1420  error_stream << "In a later version, I might do this for you,"
1421  << " but not today" << std::endl;
1422 
1423  throw OomphLibError(
1424  error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
1425  }
1426 
1427  // Copy the pointer to the value.
1428  Value = data_pt->Value;
1429  // Copy the pointer to the equation number
1430  Eqn_number = data_pt->Eqn_number;
1431  // Inform the original data that it has been copied
1432  data_pt->add_copy(this);
1433  }
Data * Copied_data_pt
Pointer to the Data object from which the values are copied.
Definition: nodes.h:655
long * Eqn_number
Definition: nodes.h:116
double ** Value
Definition: nodes.h:112
Data()
Default constructor.
Definition: nodes.cc:237
#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.

◆ CopiedData() [2/2]

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

(Shallow) copy constructor

◆ ~CopiedData()

oomph::CopiedData::~CopiedData ( )
inline

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

676  {
677  // Inform the Copied data that this copy is being deleted
678  // If the original has already been deleted
679  // Copied_data_pt will be set to NULL and this will not be
680  // necessary
681  if (Copied_data_pt)
682  {
684  }
685  // Now null out the storage
686  Copied_data_pt = 0;
687  Value = 0;
688  Eqn_number = 0;
689  }
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::CopiedData::assign_eqn_numbers ( unsigned long &  global_ndof,
Vector< double * > &  dof_pt 
)
inlinevirtual

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

Reimplemented from oomph::Data.

709  {
710  return;
711  }

◆ clear_copied_pointers()

void oomph::CopiedData::clear_copied_pointers ( )
virtual

Clear the pointers to the copied data.

Clear ther pointers to the copied data.

Reimplemented from oomph::Data.

1399  {
1400  Copied_data_pt = 0;
1401  Value = 0;
1402  Eqn_number = 0;
1403  }

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

◆ is_a_copy() [1/2]

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

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

Reimplemented from oomph::Data.

694  {
695  return true;
696  }

◆ is_a_copy() [2/2]

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

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

Reimplemented from oomph::Data.

702  {
703  return true;
704  }

◆ operator=()

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

Broken assignment operator.

◆ reset_copied_pointers()

void oomph::CopiedData::reset_copied_pointers ( )
privatevirtual

Reset the pointers to the copied data.

/////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////

Reimplemented from oomph::Data.

1382  {
1383  // Set the new number of values
1385 
1386  // Copy the pointer to the value. This will give the appropriate
1387  //"slice" of the array
1389 
1390  // Copy the pointer to the equation numbers
1392  }
unsigned Nvalue
Number of values stored in the data object.
Definition: nodes.h:135
unsigned nvalue() const
Return number of values stored in data object (incl pinned ones).
Definition: nodes.h:483

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

◆ resize()

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

We do not allow Copied Data to be resized.

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

Reimplemented from oomph::Data.

1439  {
1440  throw OomphLibError("CopiedData cannot be resized",
1443  }

References OOMPH_CURRENT_FUNCTION, and OOMPH_EXCEPTION_LOCATION.

Member Data Documentation

◆ Copied_data_pt

Data* oomph::CopiedData::Copied_data_pt
private

Pointer to the Data object from which the values are copied.

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


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