oomph::DShape Class Reference

#include <shape.h>

Public Member Functions

 DShape (const unsigned &N, const unsigned &P)
 Constructor with two parameters: a single-index shape function. More...
 
 DShape (const unsigned &N, const unsigned &M, const unsigned &P)
 Constructor with three paramters: a two-index shape function. More...
 
 DShape ()
 
 DShape (const DShape &dshape)=delete
 Broken copy constructor. More...
 
void operator= (const DShape &dshape)
 
void operator= (DShape *const &dshape_pt)
 
 ~DShape ()
 Destructor, clean up the memory allocated by this object. More...
 
void resize (const unsigned &N, const unsigned &P, const unsigned &M=1)
 
doubleoperator() (const unsigned &i, const unsigned &k)
 Overload the round bracket operator for access to the data. More...
 
const doubleoperator() (const unsigned &i, const unsigned &k) const
 Overload the round bracket operator (const version) More...
 
doubleoperator() (const unsigned &i, const unsigned &j, const unsigned &k)
 Overload the round bracket operator, with 3 indices. More...
 
const doubleoperator() (const unsigned &i, const unsigned &j, const unsigned &k) const
 Overload the round bracket operator (const version) More...
 
doubleraw_direct_access (const unsigned long &i)
 
const doubleraw_direct_access (const unsigned long &i) const
 
unsigned offset (const unsigned long &i, const unsigned long &j) const
 
unsigned long nindex1 () const
 Return the range of index 1 of the derivatives of the shape functions. More...
 
unsigned long nindex2 () const
 Return the range of index 2 of the derivatives of the shape functions. More...
 
unsigned long nindex3 () const
 Return the range of index 3 of the derivatives of the shape functions. More...
 

Private Member Functions

void range_check (const unsigned &i, const unsigned &j, const unsigned &k) const
 Private function that checks whether the indices are in range. More...
 

Private Attributes

doubleDPsi
 
doubleAllocated_storage
 
unsigned Index1
 Size of the first index of the shape function. More...
 
unsigned Index2
 Size of the second index of the shape function. More...
 
unsigned Index3
 Size of the third index of the shape function. More...
 

Detailed Description

A Class for the derivatives of shape functions The class design is essentially the same as Shape, but there is on additional index that is used to indicate the coordinate direction in which the derivative is taken.

Constructor & Destructor Documentation

◆ DShape() [1/4]

oomph::DShape::DShape ( const unsigned N,
const unsigned P 
)
inline

Constructor with two parameters: a single-index shape function.

333  : Index1(N), Index2(1), Index3(P)
334  {
335  Allocated_storage = new double[N * P];
337  }
unsigned Index2
Size of the second index of the shape function.
Definition: shape.h:294
double * Allocated_storage
Definition: shape.h:288
unsigned Index1
Size of the first index of the shape function.
Definition: shape.h:291
unsigned Index3
Size of the third index of the shape function.
Definition: shape.h:297
double * DPsi
Definition: shape.h:283
@ N
Definition: constructor.cpp:22
double P
Uniform pressure.
Definition: TwenteMeshGluing.cpp:77

References Allocated_storage, DPsi, N, and Global_Physical_Variables::P.

◆ DShape() [2/4]

oomph::DShape::DShape ( const unsigned N,
const unsigned M,
const unsigned P 
)
inline

Constructor with three paramters: a two-index shape function.

341  : Index1(N), Index2(M), Index3(P)
342  {
343  Allocated_storage = new double[N * M * P];
345  }
The matrix class, also used for vectors and row-vectors.
Definition: Eigen/Eigen/src/Core/Matrix.h:186

References Allocated_storage, DPsi, N, and Global_Physical_Variables::P.

◆ DShape() [3/4]

oomph::DShape::DShape ( )
inline

Default constructor - just assigns a null pointers and zero index sizes.

349 : DPsi(0), Allocated_storage(0), Index1(0), Index2(0), Index3(0) {}

◆ DShape() [4/4]

oomph::DShape::DShape ( const DShape dshape)
delete

Broken copy constructor.

◆ ~DShape()

oomph::DShape::~DShape ( )
inline

Destructor, clean up the memory allocated by this object.

402  {
403  delete[] Allocated_storage;
404  Allocated_storage = 0;
405  }

References Allocated_storage.

Member Function Documentation

◆ nindex1()

◆ nindex2()

◆ nindex3()

unsigned long oomph::DShape::nindex3 ( ) const
inline

Return the range of index 3 of the derivatives of the shape functions.

507  {
508  return Index3;
509  }

References Index3.

Referenced by oomph::ClampedHermiteShellBoundaryConditionElement::dshape_local().

◆ offset()

unsigned oomph::DShape::offset ( const unsigned long &  i,
const unsigned long &  j 
) const
inline

◆ operator()() [1/4]

double& oomph::DShape::operator() ( const unsigned i,
const unsigned j,
const unsigned k 
)
inline

Overload the round bracket operator, with 3 indices.

447  {
448 #ifdef RANGE_CHECKING
449  range_check(i, j, k);
450 #endif
451  return DPsi[(i * Index2 + j) * Index3 + k];
452  }
void range_check(const unsigned &i, const unsigned &j, const unsigned &k) const
Private function that checks whether the indices are in range.
Definition: shape.h:300
char char char int int * k
Definition: level2_impl.h:374

References DPsi, i, Index2, Index3, j, k, and range_check().

◆ operator()() [2/4]

const double& oomph::DShape::operator() ( const unsigned i,
const unsigned j,
const unsigned k 
) const
inline

Overload the round bracket operator (const version)

458  {
459 #ifdef RANGE_CHECKING
460  range_check(i, j, k);
461 #endif
462  return DPsi[(i * Index2 + j) * Index3 + k];
463  }

References DPsi, i, Index2, Index3, j, k, and range_check().

◆ operator()() [3/4]

double& oomph::DShape::operator() ( const unsigned i,
const unsigned k 
)
inline

Overload the round bracket operator for access to the data.

427  {
428 #ifdef RANGE_CHECKING
429  range_check(i, 0, k);
430 #endif
431  return DPsi[i * Index2 * Index3 + k];
432  }

References DPsi, i, Index2, Index3, k, and range_check().

◆ operator()() [4/4]

const double& oomph::DShape::operator() ( const unsigned i,
const unsigned k 
) const
inline

Overload the round bracket operator (const version)

436  {
437 #ifdef RANGE_CHECKING
438  range_check(i, 0, k);
439 #endif
440  return DPsi[i * Index2 * Index3 + k];
441  }

References DPsi, i, Index2, Index3, k, and range_check().

◆ operator=() [1/2]

void oomph::DShape::operator= ( const DShape dshape)
inline

The assignment operator does a shallow copy (resets the pointer to the data)

357  {
358 #ifdef PARANOID
359  // Check the dimensions
360  if ((dshape.Index1 != Index1) || (dshape.Index2 != Index2) ||
361  (dshape.Index3 != Index3))
362  {
363  std::ostringstream error_stream;
364  error_stream << "Cannot assign DShape object:" << std::endl
365  << "Indices do not match "
366  << "LHS: " << Index1 << " " << Index2 << " " << Index3
367  << ", RHS: " << dshape.Index1 << " " << dshape.Index2
368  << " " << dshape.Index3 << std::endl;
369  throw OomphLibError(
370  error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
371  }
372 #endif
373  DPsi = dshape.DPsi;
374  }
void dshape(const double &s, double DPsi[2][2])
Derivatives of 1D Hermite shape functions.
Definition: shape.h:1206
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86

References DPsi, oomph::OneDimHermite::dshape(), Index1, Index2, Index3, OOMPH_CURRENT_FUNCTION, and OOMPH_EXCEPTION_LOCATION.

◆ operator=() [2/2]

void oomph::DShape::operator= ( DShape *const &  dshape_pt)
inline

The assignment operator does a shallow copy (resets the pointer to the data)

379  {
380 #ifdef PARANOID
381  // Check the dimensions
382  if ((dshape_pt->Index1 != Index1) || (dshape_pt->Index2 != Index2) ||
383  (dshape_pt->Index3 != Index3))
384  {
385  std::ostringstream error_stream;
386  error_stream << "Cannot assign Shape object:" << std::endl
387  << "Indices do not match "
388  << "LHS: " << Index1 << " " << Index2 << " " << Index3
389  << ", RHS: " << dshape_pt->Index1 << " "
390  << dshape_pt->Index2 << " " << dshape_pt->Index3
391  << std::endl;
392  throw OomphLibError(
393  error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
394  }
395 #endif
396  DPsi = dshape_pt->DPsi;
397  }

References DPsi, Index1, Index2, Index3, OOMPH_CURRENT_FUNCTION, and OOMPH_EXCEPTION_LOCATION.

◆ range_check()

void oomph::DShape::range_check ( const unsigned i,
const unsigned j,
const unsigned k 
) const
inlineprivate

Private function that checks whether the indices are in range.

303  {
304  // Check the first index
305  if ((i >= Index1) || (j >= Index2) || (k >= Index3))
306  {
307  std::ostringstream error_stream;
308  error_stream << "Range Error: ";
309  if (i >= Index1)
310  {
311  error_stream << i << " is not in the range (0," << Index1 - 1 << ")"
312  << std::endl;
313  }
314  if (j >= Index2)
315  {
316  error_stream << j << " is not in the range (0," << Index2 - 1 << ")"
317  << std::endl;
318  }
319  if (k >= Index3)
320  {
321  error_stream << k << " is not in the range (0," << Index3 - 1 << ")"
322  << std::endl;
323  }
324  throw OomphLibError(
325  error_stream.str(), OOMPH_CURRENT_FUNCTION, OOMPH_EXCEPTION_LOCATION);
326  }
327  }

References i, Index1, Index2, Index3, j, k, OOMPH_CURRENT_FUNCTION, and OOMPH_EXCEPTION_LOCATION.

Referenced by operator()().

◆ raw_direct_access() [1/2]

◆ raw_direct_access() [2/2]

const double& oomph::DShape::raw_direct_access ( const unsigned long &  i) const
inline

Direct access to internal storage of data in flat-packed C-style column-major format. WARNING: Only for experienced users. Only use this if raw speed is of the essence, as in the solid mechanics problems.

479  {
480  return DPsi[i];
481  }

References DPsi, and i.

◆ resize()

void oomph::DShape::resize ( const unsigned N,
const unsigned P,
const unsigned M = 1 
)
inline

Change the size of the storage. Note that (for some strange reason) index2 is the "optional" index, to conform with the existing constructor.

411  {
412  // Clear old storage
413  delete[] Allocated_storage;
414  Allocated_storage = 0;
415  DPsi = 0;
416 
417  // Allocate new storage
418  Index1 = N;
419  Index2 = M;
420  Index3 = P;
421  Allocated_storage = new double[N * M * P];
423  }
Matrix< RealScalar, Dynamic, Dynamic > M
Definition: bench_gemm.cpp:50

References Allocated_storage, DPsi, Index1, Index2, Index3, N, and Global_Physical_Variables::P.

Member Data Documentation

◆ Allocated_storage

double* oomph::DShape::Allocated_storage
private

Pointer that addresses the storage allocated by the object on construction. This will be the same as DPsi if the object is not copied.

Referenced by DShape(), resize(), and ~DShape().

◆ DPsi

double* oomph::DShape::DPsi
private

Pointer that addresses the storage that will be used to read and set the shape-function derivatives. The values are packed into a flat array of doubles.

Referenced by DShape(), operator()(), operator=(), raw_direct_access(), and resize().

◆ Index1

unsigned oomph::DShape::Index1
private

Size of the first index of the shape function.

Referenced by nindex1(), operator=(), range_check(), and resize().

◆ Index2

unsigned oomph::DShape::Index2
private

Size of the second index of the shape function.

Referenced by nindex2(), offset(), operator()(), operator=(), range_check(), and resize().

◆ Index3

unsigned oomph::DShape::Index3
private

Size of the third index of the shape function.

Referenced by nindex3(), offset(), operator()(), operator=(), range_check(), and resize().


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