Field3D
MACField< Data_T > Class Template Reference

This subclass of Field implements a standard MAC field. Refer to your favorite fluid simulations book for an explanation. More...

#include <MACField.h>

Inheritance diagram for MACField< Data_T >:
ResizableField< Data_T > WritableField< Data_T > Field< Data_T > FieldRes FieldBase RefBase

Classes

class  const_mac_comp_iterator
 
class  mac_comp_iterator
 

Public Types

typedef MACField< Data_T > class_type
 
typedef CubicMACFieldInterp
< Data_T > 
CubicInterp
 
typedef LinearMACFieldInterp
< Data_T > 
LinearInterp
 
typedef boost::intrusive_ptr
< MACField
Ptr
 
typedef Data_T::BaseType real_t
 This typedef is used to refer to the scalar component type of the vectors. More...
 
typedef std::vector< PtrVec
 
- Public Types inherited from ResizableField< Data_T >
typedef ResizableField< Data_T > class_type
 
typedef boost::intrusive_ptr
< ResizableField
Ptr
 
- Public Types inherited from WritableField< Data_T >
typedef WritableField< Data_T > class_type
 
typedef boost::intrusive_ptr
< WritableField
Ptr
 
- Public Types inherited from Field< Data_T >
typedef Field< Data_T > class_type
 
typedef boost::intrusive_ptr
< Field
Ptr
 
typedef Data_T value_type
 Allows us to reference the template class. More...
 
typedef std::vector< PtrVec
 This is a convenience typedef for the list that Field3DInputFile::readScalarLayers() and Field3DInputFile::readVectorLayers() will return its data in. More...
 
- Public Types inherited from FieldRes
typedef FieldRes class_type
 
typedef boost::intrusive_ptr
< FieldRes
Ptr
 
typedef std::vector< PtrVec
 
- Public Types inherited from FieldBase
typedef FieldBase class_type
 
typedef boost::intrusive_ptr
< FieldBase
Ptr
 
- Public Types inherited from RefBase
typedef boost::intrusive_ptr
< RefBase
Ptr
 

Public Member Functions

virtual void clear (const Data_T &value)
 Clears all the voxels in the storage. More...
 
void copyMAC (MACField::Ptr other)
 TEMP: Copies the MAC field data from another MAC field. This should be re-implemented using proper iterators over the field. More...
 
V3i getComponentSize () const
 Returns the size of U,V,W components. More...
 
real_t uCenter (int i, int j, int k) const
 Returns the u-component interpolated to the cell center. More...
 
real_t vCenter (int i, int j, int k) const
 Returns the v-component interpolated to the cell center. More...
 
real_t wCenter (int i, int j, int k) const
 Returns the w-component interpolated to the cell center. More...
 
Constructors & destructor
 MACField ()
 Constructs an empty buffer. More...
 
From Field
virtual Data_T value (int i, int j, int k) const
 
virtual long long int memSize () const
 Returns the memory usage (in bytes) More...
 
From WritableField
virtual Data_T & lvalue (int i, int j, int k)
 This will return the appropriate interpolated value but setting that to something else does not change the MAC field. More...
 
MAC-component access
const real_tu (int i, int j, int k) const
 Read access to value on u-facing wall. More...
 
real_tu (int i, int j, int k)
 Write access to value on u-facing wall. More...
 
const real_tv (int i, int j, int k) const
 Read access to value on v-facing wall. More...
 
real_tv (int i, int j, int k)
 Write access to value on v-facing wall. More...
 
const real_tw (int i, int j, int k) const
 Read access to value on w-facing wall. More...
 
real_tw (int i, int j, int k)
 Write access to value on w-facing wall. More...
 
MAC-component iterators

A note about MAC iterators The subset that we choose to iterate over is defined by voxels, not MAC face coordinates. Thus, iterator from (0, 0, 0) to (0, 0, 0) will actually visit (0, 0, 0) and (1, 0, 0) for the u component, and (0, 0, 0) to (0, 1, 0) for the v component...

const_mac_comp_iterator cbegin_comp (MACComponent comp) const
 Const iterator to first element. "cbegin" matches the tr1 c++ standard. More...
 
const_mac_comp_iterator cbegin_comp (MACComponent comp, const Box3i &subset) const
 Const iterator to first element of specific subset. More...
 
const_mac_comp_iterator cend_comp (MACComponent comp) const
 Const iterator to first element. "cbegin" matches the tr1 c++ standard. More...
 
const_mac_comp_iterator cend_comp (MACComponent comp, const Box3i &subset) const
 Const iterator to first element of specific subset. More...
 
mac_comp_iterator begin_comp (MACComponent comp)
 Iterator to first element. More...
 
mac_comp_iterator begin_comp (MACComponent comp, const Box3i &subset)
 Iterator to first element of specific subset. More...
 
mac_comp_iterator end_comp (MACComponent comp)
 Iterator to first element. More...
 
mac_comp_iterator end_comp (MACComponent comp, const Box3i &subset)
 Iterator to first element of specific subset. More...
 
From FieldBase
virtual std::string className () const
 Returns the class name of the object. Used by the class pool and when writing the data to disk. More...
 
virtual FieldBase::Ptr clone () const
 Returns a pointer to a copy of the field, pure virtual so ensure derived classes properly implement it. More...
 
- Public Member Functions inherited from ResizableField< Data_T >
void copyFrom (typename Field< Data_T >::Ptr other)
 Copies the data from another Field, also resizes. More...
 
template<class Data_T2 >
void copyFrom (typename Field< Data_T2 >::Ptr other)
 Copies the data from another Field of another template class, also resizes. More...
 
void matchDefinition (FieldRes::Ptr fieldToMatch)
 Sets up this field so that resolution and mapping matches the other. More...
 
void setSize (const V3i &size)
 Resizes the object. More...
 
void setSize (const Box3i &extents)
 Resizes the object. More...
 
void setSize (const Box3i &extents, const Box3i &dataWindow)
 Resizes the object. More...
 
void setSize (const V3i &size, int padding)
 Resizes the object with padding. More...
 
- Public Member Functions inherited from WritableField< Data_T >
iterator begin ()
 Iterator to first element. More...
 
iterator begin (const Box3i &subset)
 Iterator to first element of specific subset. More...
 
iterator end ()
 Iterator pointing one element past the last valid one. More...
 
iterator end (const Box3i &subset)
 Iterator pointing one element past the last valid one (for a subset) More...
 
- Public Member Functions inherited from Field< Data_T >
const_iterator cbegin () const
 Const iterator to first element. "cbegin" matches the tr1 c++ standard. More...
 
const_iterator cbegin (const Box3i &subset) const
 Const iterator to first element of specific subset. More...
 
const_iterator cend () const
 Const iterator pointing one element past the last valid one. More...
 
const_iterator cend (const Box3i &subset) const
 Const iterator pointing one element past the last valid one (for a subset) More...
 
virtual std::string dataTypeString () const
 
virtual ~Field ()
 Dtor. More...
 
- Public Member Functions inherited from FieldRes
V3i const dataResolution () const
 
const Box3idataWindow () const
 Returns the data window. Any coordinate inside this window is safe to pass to value() in the Field subclass. More...
 
const Box3iextents () const
 Returns the extents of the data. This signifies the relevant area that the data exists over. However, the data window (below) may be smaller than the extents, in which case it is only safe to call value() for those coordinate inside the data window. More...
 
 FieldRes ()
 This constructor ensures that we have a valid mapping at all times. More...
 
 FieldRes (const FieldRes &src)
 Base class copy constructor. More...
 
bool isInBounds (int i, int j, int k) const
 Returns true is the indicies are in bounds of the data window. More...
 
FieldMapping::Ptr mapping ()
 Returns a pointer to the mapping. More...
 
const FieldMapping::Ptr mapping () const
 Returns a pointer to the mapping. More...
 
void setMapping (FieldMapping::Ptr mapping)
 Sets the field's mapping. More...
 
- Public Member Functions inherited from FieldBase
 FieldBase ()
 Constructor. More...
 
 FieldBase (const FieldBase &)
 Copy Constructor. More...
 
virtual ~FieldBase ()
 Destructor. More...
 
FieldMetadata< FieldBase > & metadata ()
 accessor to the m_metadata class More...
 
const FieldMetadata< FieldBase > & metadata () const
 Read only access to the m_metadata class. More...
 
virtual void metadataHasChanged (const std::string &)
 This function should implemented by concrete classes to get the callback when metadata changes. More...
 
void copyMetadata (const FieldBase &field)
 Copies the metadata from a second field. More...
 
- Public Member Functions inherited from RefBase
void ref () const
 Used by boost::intrusive_pointer. More...
 
size_t refcnt ()
 Used by boost::intrusive_pointer. More...
 
void unref () const
 Used by boost::intrusive_pointer. More...
 
 RefBase ()
 
 RefBase (const RefBase &)
 Copy constructor. More...
 
RefBaseoperator= (const RefBase &)
 Assignment operator. More...
 
virtual ~RefBase ()
 Destructor. More...
 
virtual bool checkRTTI (const char *typenameStr)=0
 This function is only implemented by concrete classes and triggers the actual RTTI check through matchRTTI();. More...
 
bool matchRTTI (const char *typenameStr)
 Performs a check to see if the given typename string matches this class' This needs to be implemented in -all- subclasses, even abstract ones. More...
 

Static Public Member Functions

static const char * classType ()
 
static const char * staticClassName ()
 
- Static Public Member Functions inherited from ResizableField< Data_T >
static const char * classType ()
 
static const char * staticClassName ()
 
- Static Public Member Functions inherited from WritableField< Data_T >
static const char * classType ()
 
static const char * staticClassName ()
 
- Static Public Member Functions inherited from Field< Data_T >
static const char * classType ()
 
static const char * staticClassName ()
 
- Static Public Member Functions inherited from FieldRes
static const char * classType ()
 
static const char * staticClassName ()
 
- Static Public Member Functions inherited from FieldBase
static const char * classType ()
 
static const char * staticClassName ()
 
- Static Public Member Functions inherited from RefBase
static const char * classType ()
 

Public Attributes

 DEFINE_FIELD_RTTI_CONCRETE_CLASS
 
- Public Attributes inherited from ResizableField< Data_T >
 DEFINE_FIELD_RTTI_ABSTRACT_CLASS
 
- Public Attributes inherited from WritableField< Data_T >
 DEFINE_FIELD_RTTI_ABSTRACT_CLASS
 
- Public Attributes inherited from Field< Data_T >
 DEFINE_FIELD_RTTI_ABSTRACT_CLASS
 
- Public Attributes inherited from FieldRes
 DEFINE_FIELD_RTTI_ABSTRACT_CLASS
 
- Public Attributes inherited from FieldBase
std::string attribute
 Optional name of the attribute the field represents. More...
 
std::string name
 Optional name of the field. More...
 

Protected Member Functions

virtual void sizeChanged ()
 Subclasses should re-implement this if they need to perform memory allocations, etc. every time the size of the storage changes. More...
 
const real_tuPtr (int i, int j, int k) const
 Direct access to value on u-facing wall. More...
 
real_tuPtr (int i, int j, int k)
 Direct access to value on u-facing wall. More...
 
const real_tvPtr (int i, int j, int k) const
 Direct access to value on v-facing wall. More...
 
real_tvPtr (int i, int j, int k)
 Direct access to value on v-facing wall. More...
 
const real_twPtr (int i, int j, int k) const
 Direct access to value on w-facing wall. More...
 
real_twPtr (int i, int j, int k)
 Direct access to value on w-facing wall. More...
 

Protected Attributes

Data_T m_dummy
 Dummy storage of a temp value that lvalue() can write to. More...
 
std::vector< real_tm_u
 U component storage. More...
 
V3i m_uSize
 Size of U grid along each axis. More...
 
int m_uSizeXY
 Size of xy slice for u component. More...
 
std::vector< real_tm_v
 V component storage. More...
 
V3i m_vSize
 Size of V grid along each axis. More...
 
int m_vSizeXY
 Size of xy slice for v component. More...
 
std::vector< real_tm_w
 W component storage. More...
 
V3i m_wSize
 Size of W grid along each axis. More...
 
int m_wSizeXY
 Size of xy slice for w component. More...
 
- Protected Attributes inherited from FieldRes
Box3i m_dataWindow
 Defines the area where data is allocated. This should be treated as a closed (i.e. inclusive) interval. More...
 
Box3i m_extents
 Defines the extents of the the storage. This may be larger or smaller than the data window, and in the case where it is larger, care must be taken not to access voxels outside the data window. This should be treated as a closed (i.e. inclusive) interval. More...
 
FieldMapping::Ptr m_mapping
 Pointer to the field's mapping. More...
 

Private Types

typedef ResizableField< Data_T > base
 

Static Private Attributes

static TemplatedFieldType
< MACField< Data_T > > 
ms_classType
 

Additional Inherited Members

- Protected Types inherited from ResizableField< Data_T >
typedef WritableField< Data_T > base
 
- Protected Types inherited from FieldRes
typedef MatrixFieldMapping default_mapping
 
- Static Protected Attributes inherited from ResizableField< Data_T >
static TemplatedFieldType
< ResizableField< Data_T > > 
ms_classType
 

Detailed Description

template<class Data_T>
class MACField< Data_T >

This subclass of Field implements a standard MAC field. Refer to your favorite fluid simulations book for an explanation.

The definition for u,v,w indexing used can be found on page 25 in Bridson - Fluid Simulation for Computer Graphics

Note
This class can only be templated on Vec3 instances.

Definition at line 95 of file MACField.h.

Member Typedef Documentation

template<class Data_T>
typedef boost::intrusive_ptr<MACField> MACField< Data_T >::Ptr

Definition at line 101 of file MACField.h.

template<class Data_T>
typedef std::vector<Ptr> MACField< Data_T >::Vec

Definition at line 102 of file MACField.h.

template<class Data_T>
typedef Data_T::BaseType MACField< Data_T >::real_t

This typedef is used to refer to the scalar component type of the vectors.

Definition at line 105 of file MACField.h.

template<class Data_T>
typedef LinearMACFieldInterp<Data_T> MACField< Data_T >::LinearInterp

Definition at line 107 of file MACField.h.

template<class Data_T>
typedef CubicMACFieldInterp<Data_T> MACField< Data_T >::CubicInterp

Definition at line 108 of file MACField.h.

template<class Data_T>
typedef MACField<Data_T> MACField< Data_T >::class_type

Definition at line 112 of file MACField.h.

template<class Data_T>
typedef ResizableField<Data_T> MACField< Data_T >::base
private

Definition at line 337 of file MACField.h.

Constructor & Destructor Documentation

template<class Data_T >
MACField< Data_T >::MACField ( )

Constructs an empty buffer.

Definition at line 600 of file MACField.h.

Referenced by MACField< Data_T >::clone().

601  : base()
602 {
603 
604 }
ResizableField< Data_T > base
Definition: MACField.h:337

Member Function Documentation

template<class Data_T>
static const char* MACField< Data_T >::staticClassName ( )
inlinestatic

Definition at line 115 of file MACField.h.

Referenced by MACField< Data_T >::className().

116  {
117  return "MACField";
118  }
template<class Data_T>
static const char* MACField< Data_T >::classType ( )
inlinestatic

Definition at line 120 of file MACField.h.

References FieldBase::name.

121  {
123  }
This subclass of Field implements a standard MAC field. Refer to your favorite fluid simulations book...
Definition: MACField.h:95
std::string name
Optional name of the field.
Definition: Field.h:173
template<class Data_T>
void MACField< Data_T >::clear ( const Data_T &  value)
inlinevirtual

Clears all the voxels in the storage.

Reimplemented from WritableField< Data_T >.

Definition at line 609 of file MACField.h.

610 {
611  std::fill(m_u.begin(), m_u.end(), value.x);
612  std::fill(m_v.begin(), m_v.end(), value.y);
613  std::fill(m_w.begin(), m_w.end(), value.z);
614 }
std::vector< real_t > m_v
V component storage.
Definition: MACField.h:309
std::vector< real_t > m_w
W component storage.
Definition: MACField.h:311
virtual Data_T value(int i, int j, int k) const
Definition: MACField.h:619
std::vector< real_t > m_u
U component storage.
Definition: MACField.h:307
template<class Data_T >
Data_T MACField< Data_T >::value ( int  i,
int  j,
int  k 
) const
virtual
Note
This returns the voxel-centered interpolated value

Implements Field< Data_T >.

Definition at line 619 of file MACField.h.

Referenced by convertMACToCellCentered().

620 {
621  return Data_T(uCenter(i, j, k), vCenter(i, j, k), wCenter(i, j, k));
622 }
real_t wCenter(int i, int j, int k) const
Returns the w-component interpolated to the cell center.
Definition: MACField.h:243
real_t uCenter(int i, int j, int k) const
Returns the u-component interpolated to the cell center.
Definition: MACField.h:233
real_t vCenter(int i, int j, int k) const
Returns the v-component interpolated to the cell center.
Definition: MACField.h:238
template<class Data_T >
long long int MACField< Data_T >::memSize ( ) const
virtual

Returns the memory usage (in bytes)

Note
This needs to be re-implemented for any subclass that adds data members. Those classes should also call their superclass and add the combined memory use.

Reimplemented from FieldRes.

Definition at line 627 of file MACField.h.

628 {
629  long long int superClassMemSize = base::memSize();
630  long long int vectorMemSize =
631  (m_u.capacity() + m_v.capacity() + m_w.capacity()) * sizeof(real_t);
632  return sizeof(*this) + vectorMemSize + superClassMemSize;
633 }
std::vector< real_t > m_v
V component storage.
Definition: MACField.h:309
std::vector< real_t > m_w
W component storage.
Definition: MACField.h:311
Data_T::BaseType real_t
This typedef is used to refer to the scalar component type of the vectors.
Definition: MACField.h:105
virtual long long int memSize() const
Returns the memory usage (in bytes)
Definition: Field.h:281
std::vector< real_t > m_u
U component storage.
Definition: MACField.h:307
template<class Data_T >
Data_T & MACField< Data_T >::lvalue ( int  i,
int  j,
int  k 
)
virtual

This will return the appropriate interpolated value but setting that to something else does not change the MAC field.

Warning
See description

Implements WritableField< Data_T >.

Definition at line 638 of file MACField.h.

639 {
640  m_dummy = value(i, j, k);
641  return m_dummy;
642 }
virtual Data_T value(int i, int j, int k) const
Definition: MACField.h:619
Data_T m_dummy
Dummy storage of a temp value that lvalue() can write to.
Definition: MACField.h:327
template<class Data_T >
const MACField< Data_T >::real_t & MACField< Data_T >::u ( int  i,
int  j,
int  k 
) const
inline

Read access to value on u-facing wall.

Note
i coordinate represents i-1/2!

Definition at line 687 of file MACField.h.

Referenced by convertCellCenteredToMAC(), LinearMACFieldInterp< Data_T >::sample(), CubicMACFieldInterp< Data_T >::sample(), and MACField< Data_T >::uCenter().

688 {
689  assert (i >= base::m_dataWindow.min.x);
690  assert (i <= base::m_dataWindow.max.x + 1);
691  assert (j >= base::m_dataWindow.min.y);
692  assert (j <= base::m_dataWindow.max.y);
693  assert (k >= base::m_dataWindow.min.z);
694  assert (k <= base::m_dataWindow.max.z);
695  // Add crop window offset
696  i -= base::m_dataWindow.min.x;
697  j -= base::m_dataWindow.min.y;
698  k -= base::m_dataWindow.min.z;
699  return m_u[i + j * m_uSize.x + k * m_uSizeXY];
700 }
Box3i m_dataWindow
Defines the area where data is allocated. This should be treated as a closed (i.e. inclusive) interval.
Definition: Field.h:299
V3i m_uSize
Size of U grid along each axis.
Definition: MACField.h:314
int m_uSizeXY
Size of xy slice for u component.
Definition: MACField.h:316
std::vector< real_t > m_u
U component storage.
Definition: MACField.h:307
template<class Data_T >
MACField< Data_T >::real_t & MACField< Data_T >::u ( int  i,
int  j,
int  k 
)
inline

Write access to value on u-facing wall.

Note
i coordinate represents i-1/2!

Definition at line 706 of file MACField.h.

707 {
708  assert (i >= base::m_dataWindow.min.x);
709  assert (i <= base::m_dataWindow.max.x + 1);
710  assert (j >= base::m_dataWindow.min.y);
711  assert (j <= base::m_dataWindow.max.y);
712  assert (k >= base::m_dataWindow.min.z);
713  assert (k <= base::m_dataWindow.max.z);
714  // Add crop window offset
715  i -= base::m_dataWindow.min.x;
716  j -= base::m_dataWindow.min.y;
717  k -= base::m_dataWindow.min.z;
718  return m_u[i + j * m_uSize.x + k * m_uSizeXY];
719 }
Box3i m_dataWindow
Defines the area where data is allocated. This should be treated as a closed (i.e. inclusive) interval.
Definition: Field.h:299
V3i m_uSize
Size of U grid along each axis.
Definition: MACField.h:314
int m_uSizeXY
Size of xy slice for u component.
Definition: MACField.h:316
std::vector< real_t > m_u
U component storage.
Definition: MACField.h:307
template<class Data_T >
const MACField< Data_T >::real_t & MACField< Data_T >::v ( int  i,
int  j,
int  k 
) const
inline

Read access to value on v-facing wall.

Note
j coordinate represents j-1/2!

Definition at line 725 of file MACField.h.

Referenced by convertCellCenteredToMAC(), LinearMACFieldInterp< Data_T >::sample(), CubicMACFieldInterp< Data_T >::sample(), and MACField< Data_T >::vCenter().

726 {
727  assert (i >= base::m_dataWindow.min.x);
728  assert (i <= base::m_dataWindow.max.x);
729  assert (j >= base::m_dataWindow.min.y);
730  assert (j <= base::m_dataWindow.max.y + 1);
731  assert (k >= base::m_dataWindow.min.z);
732  assert (k <= base::m_dataWindow.max.z);
733  // Add crop window offset
734  i -= base::m_dataWindow.min.x;
735  j -= base::m_dataWindow.min.y;
736  k -= base::m_dataWindow.min.z;
737  return m_v[i + j * m_vSize.x + k * m_vSizeXY];
738 }
std::vector< real_t > m_v
V component storage.
Definition: MACField.h:309
Box3i m_dataWindow
Defines the area where data is allocated. This should be treated as a closed (i.e. inclusive) interval.
Definition: Field.h:299
int m_vSizeXY
Size of xy slice for v component.
Definition: MACField.h:320
V3i m_vSize
Size of V grid along each axis.
Definition: MACField.h:318
template<class Data_T >
MACField< Data_T >::real_t & MACField< Data_T >::v ( int  i,
int  j,
int  k 
)
inline

Write access to value on v-facing wall.

Note
j coordinate represents j-1/2!

Definition at line 744 of file MACField.h.

745 {
746  assert (i >= base::m_dataWindow.min.x);
747  assert (i <= base::m_dataWindow.max.x);
748  assert (j >= base::m_dataWindow.min.y);
749  assert (j <= base::m_dataWindow.max.y + 1);
750  assert (k >= base::m_dataWindow.min.z);
751  assert (k <= base::m_dataWindow.max.z);
752  // Add crop window offset
753  i -= base::m_dataWindow.min.x;
754  j -= base::m_dataWindow.min.y;
755  k -= base::m_dataWindow.min.z;
756  return m_v[i + j * m_vSize.x + k * m_vSizeXY];
757 }
std::vector< real_t > m_v
V component storage.
Definition: MACField.h:309
Box3i m_dataWindow
Defines the area where data is allocated. This should be treated as a closed (i.e. inclusive) interval.
Definition: Field.h:299
int m_vSizeXY
Size of xy slice for v component.
Definition: MACField.h:320
V3i m_vSize
Size of V grid along each axis.
Definition: MACField.h:318
template<class Data_T >
const MACField< Data_T >::real_t & MACField< Data_T >::w ( int  i,
int  j,
int  k 
) const
inline

Read access to value on w-facing wall.

Note
k coordinate represents k-1/2!

Definition at line 763 of file MACField.h.

Referenced by convertCellCenteredToMAC(), LinearMACFieldInterp< Data_T >::sample(), CubicMACFieldInterp< Data_T >::sample(), and MACField< Data_T >::wCenter().

764 {
765  assert (i >= base::m_dataWindow.min.x);
766  assert (i <= base::m_dataWindow.max.x);
767  assert (j >= base::m_dataWindow.min.y);
768  assert (j <= base::m_dataWindow.max.y);
769  assert (k >= base::m_dataWindow.min.z);
770  assert (k <= base::m_dataWindow.max.z + 1);
771  // Add crop window offset
772  i -= base::m_dataWindow.min.x;
773  j -= base::m_dataWindow.min.y;
774  k -= base::m_dataWindow.min.z;
775  return m_w[i + j * m_wSize.x + k * m_wSizeXY];
776 }
std::vector< real_t > m_w
W component storage.
Definition: MACField.h:311
Box3i m_dataWindow
Defines the area where data is allocated. This should be treated as a closed (i.e. inclusive) interval.
Definition: Field.h:299
int m_wSizeXY
Size of xy slice for w component.
Definition: MACField.h:324
V3i m_wSize
Size of W grid along each axis.
Definition: MACField.h:322
template<class Data_T >
MACField< Data_T >::real_t & MACField< Data_T >::w ( int  i,
int  j,
int  k 
)
inline

Write access to value on w-facing wall.

Note
k coordinate represents k-1/2!

Definition at line 782 of file MACField.h.

783 {
784  assert (i >= base::m_dataWindow.min.x);
785  assert (i <= base::m_dataWindow.max.x);
786  assert (j >= base::m_dataWindow.min.y);
787  assert (j <= base::m_dataWindow.max.y);
788  assert (k >= base::m_dataWindow.min.z);
789  assert (k <= base::m_dataWindow.max.z + 1);
790  // Add crop window offset
791  i -= base::m_dataWindow.min.x;
792  j -= base::m_dataWindow.min.y;
793  k -= base::m_dataWindow.min.z;
794  return m_w[i + j * m_wSize.x + k * m_wSizeXY];
795 }
std::vector< real_t > m_w
W component storage.
Definition: MACField.h:311
Box3i m_dataWindow
Defines the area where data is allocated. This should be treated as a closed (i.e. inclusive) interval.
Definition: Field.h:299
int m_wSizeXY
Size of xy slice for w component.
Definition: MACField.h:324
V3i m_wSize
Size of W grid along each axis.
Definition: MACField.h:322
template<class Data_T >
MACField< Data_T >::const_mac_comp_iterator MACField< Data_T >::cbegin_comp ( MACComponent  comp) const

Const iterator to first element. "cbegin" matches the tr1 c++ standard.

Definition at line 801 of file MACField.h.

References FieldRes::dataResolution(), and MACFieldUtil::makeDataWindowForComponent().

Referenced by MACFieldIO::writeData().

802 {
803  using namespace MACFieldUtil;
804  if (FieldRes::dataResolution() == V3i(0))
805  return cend_comp(comp);
806  Box3i dataWindow =
808  return const_mac_comp_iterator(comp, *this, dataWindow, dataWindow.min);
809 }
Imath::Box3i Box3i
Definition: SpiMathLib.h:77
Box3i makeDataWindowForComponent(Box3i dataWindow, MACComponent comp)
Definition: MACField.h:575
Box3i m_dataWindow
Defines the area where data is allocated. This should be treated as a closed (i.e. inclusive) interval.
Definition: Field.h:299
Imath::V3i V3i
Definition: SpiMathLib.h:71
V3i const dataResolution() const
Definition: Field.h:258
const_mac_comp_iterator cend_comp(MACComponent comp) const
Const iterator to first element. &quot;cbegin&quot; matches the tr1 c++ standard.
Definition: MACField.h:828
const Box3i & dataWindow() const
Returns the data window. Any coordinate inside this window is safe to pass to value() in the Field su...
Definition: Field.h:255
template<class Data_T >
MACField< Data_T >::const_mac_comp_iterator MACField< Data_T >::cbegin_comp ( MACComponent  comp,
const Box3i subset 
) const

Const iterator to first element of specific subset.

Definition at line 815 of file MACField.h.

References MACFieldUtil::makeDataWindowForComponent().

816 {
817  using namespace MACFieldUtil;
818  if (subset.isEmpty())
819  return cend_comp(comp, subset);
821  return const_mac_comp_iterator(comp, *this, dataWindow, subset.min);
822 }
Imath::Box3i Box3i
Definition: SpiMathLib.h:77
Box3i makeDataWindowForComponent(Box3i dataWindow, MACComponent comp)
Definition: MACField.h:575
const_mac_comp_iterator cend_comp(MACComponent comp) const
Const iterator to first element. &quot;cbegin&quot; matches the tr1 c++ standard.
Definition: MACField.h:828
const Box3i & dataWindow() const
Returns the data window. Any coordinate inside this window is safe to pass to value() in the Field su...
Definition: Field.h:255
template<class Data_T >
MACField< Data_T >::const_mac_comp_iterator MACField< Data_T >::cend_comp ( MACComponent  comp) const

Const iterator to first element. "cbegin" matches the tr1 c++ standard.

Definition at line 828 of file MACField.h.

References MACFieldUtil::makeDataWindowForComponent().

829 {
830  using namespace MACFieldUtil;
831  Box3i dataWindow =
833  return const_mac_comp_iterator(comp, *this, dataWindow,
834  V3i(dataWindow.min.x,
835  dataWindow.min.y,
836  dataWindow.max.z + 1));
837 }
Imath::Box3i Box3i
Definition: SpiMathLib.h:77
Box3i makeDataWindowForComponent(Box3i dataWindow, MACComponent comp)
Definition: MACField.h:575
Box3i m_dataWindow
Defines the area where data is allocated. This should be treated as a closed (i.e. inclusive) interval.
Definition: Field.h:299
Imath::V3i V3i
Definition: SpiMathLib.h:71
const Box3i & dataWindow() const
Returns the data window. Any coordinate inside this window is safe to pass to value() in the Field su...
Definition: Field.h:255
template<class Data_T >
MACField< Data_T >::const_mac_comp_iterator MACField< Data_T >::cend_comp ( MACComponent  comp,
const Box3i subset 
) const

Const iterator to first element of specific subset.

Definition at line 843 of file MACField.h.

References MACFieldUtil::makeDataWindowForComponent().

844 {
845  using namespace MACFieldUtil;
847  return const_mac_comp_iterator(comp, *this, dataWindow,
848  V3i(dataWindow.min.x,
849  dataWindow.min.y,
850  dataWindow.max.z + 1));
851 }
Imath::Box3i Box3i
Definition: SpiMathLib.h:77
Box3i makeDataWindowForComponent(Box3i dataWindow, MACComponent comp)
Definition: MACField.h:575
Imath::V3i V3i
Definition: SpiMathLib.h:71
const Box3i & dataWindow() const
Returns the data window. Any coordinate inside this window is safe to pass to value() in the Field su...
Definition: Field.h:255
template<class Data_T >
MACField< Data_T >::mac_comp_iterator MACField< Data_T >::begin_comp ( MACComponent  comp)

Iterator to first element.

Definition at line 857 of file MACField.h.

References FieldRes::dataResolution(), and MACFieldUtil::makeDataWindowForComponent().

Referenced by MACFieldIO::readData().

858 {
859  using namespace MACFieldUtil;
860  if (FieldRes::dataResolution() == V3i(0))
861  return end_comp(comp);
863  return mac_comp_iterator(comp, *this, dataWindow, dataWindow.min);
864 }
Imath::Box3i Box3i
Definition: SpiMathLib.h:77
Box3i makeDataWindowForComponent(Box3i dataWindow, MACComponent comp)
Definition: MACField.h:575
Box3i m_dataWindow
Defines the area where data is allocated. This should be treated as a closed (i.e. inclusive) interval.
Definition: Field.h:299
Imath::V3i V3i
Definition: SpiMathLib.h:71
mac_comp_iterator end_comp(MACComponent comp)
Iterator to first element.
Definition: MACField.h:883
V3i const dataResolution() const
Definition: Field.h:258
const Box3i & dataWindow() const
Returns the data window. Any coordinate inside this window is safe to pass to value() in the Field su...
Definition: Field.h:255
template<class Data_T >
MACField< Data_T >::mac_comp_iterator MACField< Data_T >::begin_comp ( MACComponent  comp,
const Box3i subset 
)

Iterator to first element of specific subset.

Definition at line 870 of file MACField.h.

References MACFieldUtil::makeDataWindowForComponent().

871 {
872  using namespace MACFieldUtil;
873  if (subset.isEmpty())
874  return end_comp(comp, subset);
876  return mac_comp_iterator(comp, *this, dataWindow, subset.min);
877 }
Imath::Box3i Box3i
Definition: SpiMathLib.h:77
Box3i makeDataWindowForComponent(Box3i dataWindow, MACComponent comp)
Definition: MACField.h:575
mac_comp_iterator end_comp(MACComponent comp)
Iterator to first element.
Definition: MACField.h:883
const Box3i & dataWindow() const
Returns the data window. Any coordinate inside this window is safe to pass to value() in the Field su...
Definition: Field.h:255
template<class Data_T >
MACField< Data_T >::mac_comp_iterator MACField< Data_T >::end_comp ( MACComponent  comp)

Iterator to first element.

Definition at line 883 of file MACField.h.

References MACFieldUtil::makeDataWindowForComponent().

884 {
885  using namespace MACFieldUtil;
887  return mac_comp_iterator(comp, *this, dataWindow, V3i(dataWindow.min.x,
888  dataWindow.min.y,
889  dataWindow.max.z + 1));
890 }
Imath::Box3i Box3i
Definition: SpiMathLib.h:77
Box3i makeDataWindowForComponent(Box3i dataWindow, MACComponent comp)
Definition: MACField.h:575
Box3i m_dataWindow
Defines the area where data is allocated. This should be treated as a closed (i.e. inclusive) interval.
Definition: Field.h:299
Imath::V3i V3i
Definition: SpiMathLib.h:71
const Box3i & dataWindow() const
Returns the data window. Any coordinate inside this window is safe to pass to value() in the Field su...
Definition: Field.h:255
template<class Data_T >
MACField< Data_T >::mac_comp_iterator MACField< Data_T >::end_comp ( MACComponent  comp,
const Box3i subset 
)

Iterator to first element of specific subset.

Definition at line 896 of file MACField.h.

References MACFieldUtil::makeDataWindowForComponent().

897 {
898  using namespace MACFieldUtil;
900  return mac_comp_iterator(comp, *this, dataWindow, V3i(dataWindow.min.x,
901  dataWindow.min.y,
902  dataWindow.max.z + 1));
903 }
Imath::Box3i Box3i
Definition: SpiMathLib.h:77
Box3i makeDataWindowForComponent(Box3i dataWindow, MACComponent comp)
Definition: MACField.h:575
Imath::V3i V3i
Definition: SpiMathLib.h:71
const Box3i & dataWindow() const
Returns the data window. Any coordinate inside this window is safe to pass to value() in the Field su...
Definition: Field.h:255
template<class Data_T>
real_t MACField< Data_T >::uCenter ( int  i,
int  j,
int  k 
) const
inline

Returns the u-component interpolated to the cell center.

Definition at line 233 of file MACField.h.

References MACField< Data_T >::u().

234  {
235  return (u(i, j, k) + u(i + 1, j, k)) * 0.5;
236  }
const real_t & u(int i, int j, int k) const
Read access to value on u-facing wall.
Definition: MACField.h:687
template<class Data_T>
real_t MACField< Data_T >::vCenter ( int  i,
int  j,
int  k 
) const
inline

Returns the v-component interpolated to the cell center.

Definition at line 238 of file MACField.h.

References MACField< Data_T >::v().

239  {
240  return (v(i, j, k) + v(i, j + 1, k)) * 0.5;
241  }
const real_t & v(int i, int j, int k) const
Read access to value on v-facing wall.
Definition: MACField.h:725
template<class Data_T>
real_t MACField< Data_T >::wCenter ( int  i,
int  j,
int  k 
) const
inline

Returns the w-component interpolated to the cell center.

Definition at line 243 of file MACField.h.

References MACField< Data_T >::w().

244  {
245  return (w(i, j, k) + w(i, j, k + 1)) * 0.5;
246  }
const real_t & w(int i, int j, int k) const
Read access to value on w-facing wall.
Definition: MACField.h:763
template<class Data_T>
void MACField< Data_T >::copyMAC ( MACField< Data_T >::Ptr  other)
inline

TEMP: Copies the MAC field data from another MAC field. This should be re-implemented using proper iterators over the field.

Definition at line 250 of file MACField.h.

References MACField< Data_T >::m_u, MACField< Data_T >::m_v, MACField< Data_T >::m_w, and ResizableField< Data_T >::matchDefinition().

251  {
252  matchDefinition(other);
253  std::copy(other->m_u.begin(), other->m_u.end(), m_u.begin());
254  std::copy(other->m_v.begin(), other->m_v.end(), m_v.begin());
255  std::copy(other->m_w.begin(), other->m_w.end(), m_w.begin());
256  }
std::vector< real_t > m_v
V component storage.
Definition: MACField.h:309
void matchDefinition(FieldRes::Ptr fieldToMatch)
Sets up this field so that resolution and mapping matches the other.
Definition: Field.h:961
std::vector< real_t > m_w
W component storage.
Definition: MACField.h:311
std::vector< real_t > m_u
U component storage.
Definition: MACField.h:307
template<class Data_T>
V3i MACField< Data_T >::getComponentSize ( ) const
inline

Returns the size of U,V,W components.

Definition at line 261 of file MACField.h.

References MACField< Data_T >::m_u, MACField< Data_T >::m_v, and MACField< Data_T >::m_w.

Referenced by MACFieldIO::writeData(), and MACFieldIO::writeInternal().

262  { return V3i(m_u.size(), m_v.size(), m_w.size()); }
std::vector< real_t > m_v
V component storage.
Definition: MACField.h:309
std::vector< real_t > m_w
W component storage.
Definition: MACField.h:311
Imath::V3i V3i
Definition: SpiMathLib.h:71
std::vector< real_t > m_u
U component storage.
Definition: MACField.h:307
template<class Data_T>
virtual std::string MACField< Data_T >::className ( ) const
inlinevirtual

Returns the class name of the object. Used by the class pool and when writing the data to disk.

Note
This is different from classType for any templated class, as classType() will include the template parameter(s) but className remains just the name of the template itself.

Implements FieldBase.

Definition at line 269 of file MACField.h.

References MACField< Data_T >::staticClassName().

270  { return staticClassName(); }
static const char * staticClassName()
Definition: MACField.h:115
template<class Data_T>
virtual FieldBase::Ptr MACField< Data_T >::clone ( ) const
inlinevirtual

Returns a pointer to a copy of the field, pure virtual so ensure derived classes properly implement it.

Implements FieldBase.

Definition at line 272 of file MACField.h.

References MACField< Data_T >::MACField().

273  { return Ptr(new MACField(*this)); }
boost::intrusive_ptr< MACField > Ptr
Definition: MACField.h:101
MACField()
Constructs an empty buffer.
Definition: MACField.h:600
template<class Data_T >
void MACField< Data_T >::sizeChanged ( )
protectedvirtual

Subclasses should re-implement this if they need to perform memory allocations, etc. every time the size of the storage changes.

Note
Make sure to call the base class version in subclasses!

Reimplemented from ResizableField< Data_T >.

Definition at line 647 of file MACField.h.

648 {
649  // Call base class
651 
652  V3i baseSize =
654 
655  if (std::min(std::min(baseSize.x, baseSize.y), baseSize.z) < 0)
656  throw Exc::ResizeException("Attempt to resize ResizableField object "
657  "using negative size. Data window was: " +
658  boost::lexical_cast<std::string>(baseSize));
659 
660  // Calculate the size for each component of the MAC field
661  m_uSize = baseSize + V3i(1, 0, 0);
662  m_vSize = baseSize + V3i(0, 1, 0);
663  m_wSize = baseSize + V3i(0, 0, 1);
664 
665  // Calculate the size of each z slice
666  m_uSizeXY = m_uSize.x * m_uSize.y;
667  m_vSizeXY = m_vSize.x * m_vSize.y;
668  m_wSizeXY = m_wSize.x * m_wSize.y;
669 
670  // Allocate memory
671  try {
672  m_u.resize(m_uSize.x * m_uSize.y * m_uSize.z);
673  m_v.resize(m_vSize.x * m_vSize.y * m_vSize.z);
674  m_w.resize(m_wSize.x * m_wSize.y * m_wSize.z);
675  }
676  catch (std::bad_alloc &e) {
677  throw Exc::MemoryException("Couldn't allocate MACField of size " +
678  boost::lexical_cast<std::string>(baseSize));
679  }
680 
681 }
std::vector< real_t > m_v
V component storage.
Definition: MACField.h:309
std::vector< real_t > m_w
W component storage.
Definition: MACField.h:311
virtual void sizeChanged()
Subclasses should re-implement this if they need to perform memory allocations, etc. every time the size of the storage changes.
Definition: Field.h:866
Box3i m_dataWindow
Defines the area where data is allocated. This should be treated as a closed (i.e. inclusive) interval.
Definition: Field.h:299
Imath::V3i V3i
Definition: SpiMathLib.h:71
int m_wSizeXY
Size of xy slice for w component.
Definition: MACField.h:324
int m_vSizeXY
Size of xy slice for v component.
Definition: MACField.h:320
V3i m_uSize
Size of U grid along each axis.
Definition: MACField.h:314
int m_uSizeXY
Size of xy slice for u component.
Definition: MACField.h:316
V3i m_vSize
Size of V grid along each axis.
Definition: MACField.h:318
V3i m_wSize
Size of W grid along each axis.
Definition: MACField.h:322
std::vector< real_t > m_u
U component storage.
Definition: MACField.h:307
template<class Data_T >
const MACField< Data_T >::real_t * MACField< Data_T >::uPtr ( int  i,
int  j,
int  k 
) const
inlineprotected

Direct access to value on u-facing wall.

Note
i coordinate represents i-1/2!

Definition at line 909 of file MACField.h.

910 {
911  // Add crop window offset
912  i -= base::m_dataWindow.min.x;
913  j -= base::m_dataWindow.min.y;
914  k -= base::m_dataWindow.min.z;
915  return &m_u[i + j * m_uSize.x + k * m_uSizeXY];
916 }
Box3i m_dataWindow
Defines the area where data is allocated. This should be treated as a closed (i.e. inclusive) interval.
Definition: Field.h:299
V3i m_uSize
Size of U grid along each axis.
Definition: MACField.h:314
int m_uSizeXY
Size of xy slice for u component.
Definition: MACField.h:316
std::vector< real_t > m_u
U component storage.
Definition: MACField.h:307
template<class Data_T >
MACField< Data_T >::real_t * MACField< Data_T >::uPtr ( int  i,
int  j,
int  k 
)
inlineprotected

Direct access to value on u-facing wall.

Note
i coordinate represents i-1/2!

Definition at line 922 of file MACField.h.

923 {
924  // Add crop window offset
925  i -= base::m_dataWindow.min.x;
926  j -= base::m_dataWindow.min.y;
927  k -= base::m_dataWindow.min.z;
928  return &m_u[i + j * m_uSize.x + k * m_uSizeXY];
929 }
Box3i m_dataWindow
Defines the area where data is allocated. This should be treated as a closed (i.e. inclusive) interval.
Definition: Field.h:299
V3i m_uSize
Size of U grid along each axis.
Definition: MACField.h:314
int m_uSizeXY
Size of xy slice for u component.
Definition: MACField.h:316
std::vector< real_t > m_u
U component storage.
Definition: MACField.h:307
template<class Data_T >
const MACField< Data_T >::real_t * MACField< Data_T >::vPtr ( int  i,
int  j,
int  k 
) const
inlineprotected

Direct access to value on v-facing wall.

Note
j coordinate represents j-1/2!

Definition at line 935 of file MACField.h.

936 {
937  // Add crop window offset
938  i -= base::m_dataWindow.min.x;
939  j -= base::m_dataWindow.min.y;
940  k -= base::m_dataWindow.min.z;
941  return &m_v[i + j * m_vSize.x + k * m_vSizeXY];
942 }
std::vector< real_t > m_v
V component storage.
Definition: MACField.h:309
Box3i m_dataWindow
Defines the area where data is allocated. This should be treated as a closed (i.e. inclusive) interval.
Definition: Field.h:299
int m_vSizeXY
Size of xy slice for v component.
Definition: MACField.h:320
V3i m_vSize
Size of V grid along each axis.
Definition: MACField.h:318
template<class Data_T >
MACField< Data_T >::real_t * MACField< Data_T >::vPtr ( int  i,
int  j,
int  k 
)
inlineprotected

Direct access to value on v-facing wall.

Note
j coordinate represents j-1/2!

Definition at line 948 of file MACField.h.

949 {
950  // Add crop window offset
951  i -= base::m_dataWindow.min.x;
952  j -= base::m_dataWindow.min.y;
953  k -= base::m_dataWindow.min.z;
954  return &m_v[i + j * m_vSize.x + k * m_vSizeXY];
955 }
std::vector< real_t > m_v
V component storage.
Definition: MACField.h:309
Box3i m_dataWindow
Defines the area where data is allocated. This should be treated as a closed (i.e. inclusive) interval.
Definition: Field.h:299
int m_vSizeXY
Size of xy slice for v component.
Definition: MACField.h:320
V3i m_vSize
Size of V grid along each axis.
Definition: MACField.h:318
template<class Data_T >
const MACField< Data_T >::real_t * MACField< Data_T >::wPtr ( int  i,
int  j,
int  k 
) const
inlineprotected

Direct access to value on w-facing wall.

Note
k coordinate represents k-1/2!

Definition at line 961 of file MACField.h.

962 {
963  // Add crop window offset
964  i -= base::m_dataWindow.min.x;
965  j -= base::m_dataWindow.min.y;
966  k -= base::m_dataWindow.min.z;
967  return &m_w[i + j * m_wSize.x + k * m_wSizeXY];
968 }
std::vector< real_t > m_w
W component storage.
Definition: MACField.h:311
Box3i m_dataWindow
Defines the area where data is allocated. This should be treated as a closed (i.e. inclusive) interval.
Definition: Field.h:299
int m_wSizeXY
Size of xy slice for w component.
Definition: MACField.h:324
V3i m_wSize
Size of W grid along each axis.
Definition: MACField.h:322
template<class Data_T >
MACField< Data_T >::real_t * MACField< Data_T >::wPtr ( int  i,
int  j,
int  k 
)
inlineprotected

Direct access to value on w-facing wall.

Note
k coordinate represents k-1/2!

Definition at line 974 of file MACField.h.

975 {
976  // Add crop window offset
977  i -= base::m_dataWindow.min.x;
978  j -= base::m_dataWindow.min.y;
979  k -= base::m_dataWindow.min.z;
980  return &m_w[i + j * m_wSize.x + k * m_wSizeXY];
981 }
std::vector< real_t > m_w
W component storage.
Definition: MACField.h:311
Box3i m_dataWindow
Defines the area where data is allocated. This should be treated as a closed (i.e. inclusive) interval.
Definition: Field.h:299
int m_wSizeXY
Size of xy slice for w component.
Definition: MACField.h:324
V3i m_wSize
Size of W grid along each axis.
Definition: MACField.h:322

Member Data Documentation

template<class Data_T>
MACField< Data_T >::DEFINE_FIELD_RTTI_CONCRETE_CLASS

Definition at line 113 of file MACField.h.

template<class Data_T>
std::vector<real_t> MACField< Data_T >::m_u
protected

U component storage.

Definition at line 307 of file MACField.h.

Referenced by MACField< Data_T >::copyMAC(), and MACField< Data_T >::getComponentSize().

template<class Data_T>
std::vector<real_t> MACField< Data_T >::m_v
protected

V component storage.

Definition at line 309 of file MACField.h.

Referenced by MACField< Data_T >::copyMAC(), and MACField< Data_T >::getComponentSize().

template<class Data_T>
std::vector<real_t> MACField< Data_T >::m_w
protected

W component storage.

Definition at line 311 of file MACField.h.

Referenced by MACField< Data_T >::copyMAC(), and MACField< Data_T >::getComponentSize().

template<class Data_T>
V3i MACField< Data_T >::m_uSize
protected

Size of U grid along each axis.

Definition at line 314 of file MACField.h.

template<class Data_T>
int MACField< Data_T >::m_uSizeXY
protected

Size of xy slice for u component.

Definition at line 316 of file MACField.h.

template<class Data_T>
V3i MACField< Data_T >::m_vSize
protected

Size of V grid along each axis.

Definition at line 318 of file MACField.h.

template<class Data_T>
int MACField< Data_T >::m_vSizeXY
protected

Size of xy slice for v component.

Definition at line 320 of file MACField.h.

template<class Data_T>
V3i MACField< Data_T >::m_wSize
protected

Size of W grid along each axis.

Definition at line 322 of file MACField.h.

template<class Data_T>
int MACField< Data_T >::m_wSizeXY
protected

Size of xy slice for w component.

Definition at line 324 of file MACField.h.

template<class Data_T>
Data_T MACField< Data_T >::m_dummy
mutableprotected

Dummy storage of a temp value that lvalue() can write to.

Definition at line 327 of file MACField.h.

template<class Data_T>
TemplatedFieldType<MACField<Data_T> > MACField< Data_T >::ms_classType
staticprivate

Definition at line 333 of file MACField.h.


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