Field3D
MACField< Data_T >::const_mac_comp_iterator Class Reference

#include <MACField.h>

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

Public Types

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

Public Member Functions

 const_mac_comp_iterator (MACComponent comp, const class_type &field, const Box3i &window, const V3i &currentPos)
 
void copyMAC (typename MACField::Ptr other)
 TEMP: Copies the MAC field data from another MAC field. This should be re-implemented using proper iterators over the field.
 
V3i getComponentSize () const
 Returns the size of U,V,W components.
 
template<class Iter_T>
bool operator!= (const Iter_T &rhs) const
 
const real_toperator* () const
 
const const_mac_comp_iteratoroperator++ ()
 
const real_toperator-> () const
 
template<class Iter_T>
bool operator== (const Iter_T &rhs) const
 
real_t uCenter (int i, int j, int k) const
 Returns the u-component interpolated to the cell center.
 
real_t vCenter (int i, int j, int k) const
 Returns the v-component interpolated to the cell center.
 
real_t wCenter (int i, int j, int k) const
 Returns the w-component interpolated to the cell center.
 
Constructors & destructor
 MACField ()
 Constructs an empty buffer.
 
virtual void clear (const Data_T &value)
 Clears all the voxels in the storage.
 
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)
 
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.
 
MAC-component access
const real_tu (int i, int j, int k) const
 Read access to value on u-facing wall.
 
real_tu (int i, int j, int k)
 Write access to value on u-facing wall.
 
const real_tv (int i, int j, int k) const
 Read access to value on v-facing wall.
 
real_tv (int i, int j, int k)
 Write access to value on v-facing wall.
 
const real_tw (int i, int j, int k) const
 Read access to value on w-facing wall.
 
real_tw (int i, int j, int k)
 Write access to value on w-facing wall.
 
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.
 
const_mac_comp_iterator cbegin_comp (MACComponent comp, const Box3i &subset) const
 Const iterator to first element of specific subset.
 
const_mac_comp_iterator cend_comp (MACComponent comp) const
 Const iterator to first element. "cbegin" matches the tr1 c++ standard.
 
const_mac_comp_iterator cend_comp (MACComponent comp, const Box3i &subset) const
 Const iterator to first element of specific subset.
 
mac_comp_iterator begin_comp (MACComponent comp)
 Iterator to first element.
 
mac_comp_iterator begin_comp (MACComponent comp, const Box3i &subset)
 Iterator to first element of specific subset.
 
mac_comp_iterator end_comp (MACComponent comp)
 Iterator to first element.
 
mac_comp_iterator end_comp (MACComponent comp, const Box3i &subset)
 Iterator to first element of specific subset.
 
- Public Member Functions inherited from ResizableField< Data_T >
void copyFrom (typename Field< Data_T >::Ptr other)
 Copies the data from another Field, also resizes.
 
template<class Data_T2>
void copyFrom (typename Field< Data_T2 >::Ptr other)
 Copies the data from another Field of another template class, also resizes.
 
void matchDefinition (FieldRes::Ptr fieldToMatch)
 Sets up this field so that resolution and mapping matches the other.
 
void setSize (const Box3i &extents)
 Resizes the object.
 
void setSize (const Box3i &extents, const Box3i &dataWindow)
 Resizes the object.
 
void setSize (const V3i &size)
 Resizes the object.
 
void setSize (const V3i &size, int padding)
 Resizes the object with padding.
 
- Public Member Functions inherited from WritableField< Data_T >
iterator begin ()
 Iterator to first element.
 
iterator begin (const Box3i &subset)
 Iterator to first element of specific subset.
 
iterator end ()
 Iterator pointing one element past the last valid one.
 
iterator end (const Box3i &subset)
 Iterator pointing one element past the last valid one (for a subset)
 
- Public Member Functions inherited from Field< Data_T >
const_iterator cbegin () const
 Const iterator to first element. "cbegin" matches the tr1 c++ standard.
 
const_iterator cbegin (const Box3i &subset) const
 Const iterator to first element of specific subset.
 
const_iterator cend () const
 Const iterator pointing one element past the last valid one.
 
const_iterator cend (const Box3i &subset) const
 Const iterator pointing one element past the last valid one (for a subset)
 
virtual std::string dataTypeString () const
 
virtual ~Field ()
 Dtor.
 
- 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.
 
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.
 
 FieldRes ()
 This constructor ensures that we have a valid mapping at all times.
 
 FieldRes (const FieldRes &src)
 Base class copy constructor.
 
bool isInBounds (int i, int j, int k) const
 Returns true is the indicies are in bounds of the data window.
 
FieldMapping::Ptr mapping ()
 Returns a pointer to the mapping.
 
const FieldMapping::Ptr mapping () const
 Returns a pointer to the mapping.
 
virtual void mappingChanged ()
 Tells the subclass that the mapping changed.
 
void setMapping (FieldMapping::Ptr mapping)
 Sets the field's mapping.
 
virtual size_t voxelCount () const
 Counts the number of voxels. For most fields, this is just the volume of the data window, but sparse data structures can override this to return a better value.
 
- Public Member Functions inherited from FieldBase
 FieldBase ()
 Constructor.
 
 FieldBase (const FieldBase &)
 Copy Constructor.
 
virtual ~FieldBase ()
 Destructor.
 
virtual std::string className () const =0
 Returns the class name of the object. Used by the class pool and when writing the data to disk.
 
virtual std::string classType () const =0
 Returns the full class type string.
 
FieldMetadatametadata ()
 accessor to the m_metadata class
 
const FieldMetadatametadata () const
 Read only access to the m_metadata class.
 
void copyMetadata (const FieldBase &field)
 Copies the metadata from a second field.
 
- Public Member Functions inherited from RefBase
void ref () const
 Used by boost::intrusive_pointer.
 
size_t refcnt ()
 Used by boost::intrusive_pointer.
 
void unref () const
 Used by boost::intrusive_pointer.
 
WeakPtr weakPtr () const
 
 RefBase ()
 
 RefBase (const RefBase &)
 Copy constructor.
 
RefBaseoperator= (const RefBase &)
 Assignment operator.
 
virtual ~RefBase ()
 Destructor.
 
virtual bool checkRTTI (const char *typenameStr)=0
 This function is only implemented by concrete classes and triggers the actual RTTI check through matchRTTI();.
 
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.
 
- Public Member Functions inherited from MetadataCallback
virtual void metadataHasChanged (const std::string &)
 Alerts the callback holder that the metadata has changed.
 

Static Public Member Functions

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

Public Attributes

 DEFINE_FIELD_RTTI_CONCRETE_CLASS
 
int x
 Current position.
 
int y
 
int z
 
- 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.
 
std::string name
 Optional name of the field.
 

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.
 
real_tuPtr (int i, int j, int k)
 Direct access to value on u-facing wall.
 
const real_tuPtr (int i, int j, int k) const
 Direct access to value on u-facing wall.
 
real_tvPtr (int i, int j, int k)
 Direct access to value on v-facing wall.
 
const real_tvPtr (int i, int j, int k) const
 Direct access to value on v-facing wall.
 
real_twPtr (int i, int j, int k)
 Direct access to value on w-facing wall.
 
const real_twPtr (int i, int j, int k) const
 Direct access to value on w-facing wall.
 

Protected Attributes

Data_T m_dummy
 Dummy storage of a temp value that lvalue() can write to.
 
std::vector< real_tm_u
 U component storage.
 
V3i m_uSize
 Size of U grid along each axis.
 
int m_uSizeXY
 Size of xy slice for u component.
 
std::vector< real_tm_v
 V component storage.
 
V3i m_vSize
 Size of V grid along each axis.
 
int m_vSizeXY
 Size of xy slice for v component.
 
std::vector< real_tm_w
 W component storage.
 
V3i m_wSize
 Size of W grid along each axis.
 
int m_wSizeXY
 Size of xy slice for w component.
 
- 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.
 
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.
 
FieldMapping::Ptr m_mapping
 Pointer to the field's mapping.
 

Private Types

typedef ResizableField< Data_T > base
 

Private Member Functions

void updatePointer ()
 

Private Attributes

MACComponent m_comp
 Component to look up.
 
const class_typem_field
 Reference to field being iterated over.
 
const real_tm_p
 Pointer to current element.
 
Box3i m_window
 Window to traverse.
 

Static Private Attributes

static TemplatedFieldType< MACField< Data_T > > ms_classType
 

From FieldBase

 FIELD3D_CLASSNAME_CLASSTYPE_IMPLEMENTATION
 
virtual FieldBase::Ptr clone () const
 Returns a pointer to a copy of the field, pure virtual so ensure derived classes properly implement it.
 

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 >::const_mac_comp_iterator

Definition at line 359 of file MACField.h.

Member Typedef Documentation

◆ class_type [1/2]

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

Definition at line 365 of file MACField.h.

◆ real_t [1/2]

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

Definition at line 366 of file MACField.h.

◆ Ptr

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

Definition at line 101 of file MACField.h.

◆ Vec

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

Definition at line 102 of file MACField.h.

◆ real_t [2/2]

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.

◆ LinearInterp

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

Definition at line 107 of file MACField.h.

◆ CubicInterp

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

Definition at line 108 of file MACField.h.

◆ class_type [2/2]

typedef MACField<Data_T> MACField< Data_T >::class_type

Definition at line 112 of file MACField.h.

◆ base

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

Definition at line 336 of file MACField.h.

Constructor & Destructor Documentation

◆ const_mac_comp_iterator()

template<class Data_T>
MACField< Data_T >::const_mac_comp_iterator::const_mac_comp_iterator ( MACComponent comp,
const class_type & field,
const Box3i & window,
const V3i & currentPos )
inline

Definition at line 370 of file MACField.h.

374 : x(currentPos.x), y(currentPos.y), z(currentPos.z),
377 {
378 if (window.intersects(currentPos))
380 }
MACComponent m_comp
Component to look up.
Definition MACField.h:463
const real_t * m_p
Pointer to current element.
Definition MACField.h:459
Box3i m_window
Window to traverse.
Definition MACField.h:461
const class_type & m_field
Reference to field being iterated over.
Definition MACField.h:465
This subclass of Field implements a standard MAC field. Refer to your favorite fluid simulations book...
Definition MACField.h:96

References m_comp, m_field, m_p, m_window, updatePointer(), x, y, and z.

Referenced by operator++().

Member Function Documentation

◆ operator++()

template<class Data_T>
const const_mac_comp_iterator & MACField< Data_T >::const_mac_comp_iterator::operator++ ( )
inline

Definition at line 384 of file MACField.h.

385 {
386 if (x == m_window.max.x) {
387 if (y == m_window.max.y) {
388 if (z == m_window.max.z) {
389 m_p = 0;
390 return *this;
391 } else {
392 x = m_window.min.x;
393 y = m_window.min.y;
394 ++z;
395 }
396 } else {
397 x = m_window.min.x;
398 ++y;
399 }
401 } else {
402 ++x;
403 ++m_p;
404 }
405 return *this;
406 }

References const_mac_comp_iterator(), m_p, m_window, updatePointer(), x, y, and z.

◆ operator==()

template<class Data_T>
template<class Iter_T>
bool MACField< Data_T >::const_mac_comp_iterator::operator== ( const Iter_T & rhs) const
inline

Definition at line 409 of file MACField.h.

410 {
411 return m_p == &(*rhs);
412 }

References m_p.

◆ operator!=()

template<class Data_T>
template<class Iter_T>
bool MACField< Data_T >::const_mac_comp_iterator::operator!= ( const Iter_T & rhs) const
inline

Definition at line 415 of file MACField.h.

416 {
417 return m_p != &(*rhs);
418 }

References m_p.

◆ operator*()

template<class Data_T>
const real_t & MACField< Data_T >::const_mac_comp_iterator::operator* ( ) const
inline

Definition at line 420 of file MACField.h.

421 {
422 return *m_p;
423 }

References m_p.

◆ operator->()

template<class Data_T>
const real_t * MACField< Data_T >::const_mac_comp_iterator::operator-> ( ) const
inline

Definition at line 425 of file MACField.h.

426 {
427 return m_p;
428 }

References m_p.

◆ updatePointer()

template<class Data_T>
void MACField< Data_T >::const_mac_comp_iterator::updatePointer ( )
inlineprivate

Definition at line 439 of file MACField.h.

440 {
441 switch (m_comp) {
442 case MACCompU:
443 m_p = m_field.uPtr(x, y, z);
444 break;
445 case MACCompV:
446 m_p = m_field.vPtr(x, y, z);
447 break;
448 case MACCompW:
449 m_p = m_field.wPtr(x, y, z);
450 break;
451 default:
452 assert(false && "Illegal MACComponent in const_mac_comp_iterator");
453 }
454 }

References m_comp, m_field, m_p, MACCompU, MACCompV, MACCompW, x, y, and z.

Referenced by const_mac_comp_iterator(), and operator++().

◆ staticClassName()

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

Definition at line 115 of file MACField.h.

116 {
117 return "MACField";
118 }

◆ staticClassType()

static const char * MACField< Data_T >::staticClassType ( )
inlinestatic

Definition at line 120 of file MACField.h.

121 {
123 }
std::string name
Optional name of the field.
Definition Field.h:171

◆ MACField()

MACField< Data_T >::MACField ( )

Constructs an empty buffer.

Definition at line 131 of file MACField.h.

612 : base()
613{
614
615}
ResizableField< Data_T > base
Definition MACField.h:336

◆ clear()

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 138 of file MACField.h.

621{
622 std::fill(m_u.begin(), m_u.end(), value.x);
623 std::fill(m_v.begin(), m_v.end(), value.y);
624 std::fill(m_w.begin(), m_w.end(), value.z);
625}
std::vector< real_t > m_u
Definition MACField.h:306
virtual Data_T value(int i, int j, int k) const
Definition MACField.h:630
std::vector< real_t > m_v
Definition MACField.h:308
std::vector< real_t > m_w
Definition MACField.h:310

◆ value()

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 146 of file MACField.h.

631{
632 return Data_T(uCenter(i, j, k), vCenter(i, j, k), wCenter(i, j, k));
633}
real_t vCenter(int i, int j, int k) const
Definition MACField.h:238
real_t uCenter(int i, int j, int k) const
Definition MACField.h:233
real_t wCenter(int i, int j, int k) const
Definition MACField.h:243

◆ memSize()

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 147 of file MACField.h.

639{
640 long long int superClassMemSize = base::memSize();
641 long long int vectorMemSize =
642 (m_u.capacity() + m_v.capacity() + m_w.capacity()) * sizeof(real_t);
643 return sizeof(*this) + vectorMemSize + superClassMemSize;
644}
virtual long long int memSize() const
Returns the memory usage (in bytes)
Definition Field.h:279
MACField< Data_T >::real_t real_t
Definition MACField.h:366

◆ lvalue()

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 159 of file MACField.h.

650{
651 m_dummy = value(i, j, k);
652 return m_dummy;
653}

◆ u() [1/2]

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 170 of file MACField.h.

699{
701 assert (i <= base::m_dataWindow.max.x + 1);
706 // Add crop window offset
707 i -= base::m_dataWindow.min.x;
708 j -= base::m_dataWindow.min.y;
709 k -= base::m_dataWindow.min.z;
710 return m_u[i + j * m_uSize.x + k * m_uSizeXY];
711}
Box3i m_dataWindow
Defines the area where data is allocated. This should be treated as a closed (i.e....
Definition Field.h:310

◆ u() [2/2]

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 173 of file MACField.h.

718{
720 assert (i <= base::m_dataWindow.max.x + 1);
725 // Add crop window offset
726 i -= base::m_dataWindow.min.x;
727 j -= base::m_dataWindow.min.y;
728 k -= base::m_dataWindow.min.z;
729 return m_u[i + j * m_uSize.x + k * m_uSizeXY];
730}

◆ v() [1/2]

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 176 of file MACField.h.

737{
741 assert (j <= base::m_dataWindow.max.y + 1);
744 // Add crop window offset
745 i -= base::m_dataWindow.min.x;
746 j -= base::m_dataWindow.min.y;
747 k -= base::m_dataWindow.min.z;
748 return m_v[i + j * m_vSize.x + k * m_vSizeXY];
749}

◆ v() [2/2]

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 179 of file MACField.h.

756{
760 assert (j <= base::m_dataWindow.max.y + 1);
763 // Add crop window offset
764 i -= base::m_dataWindow.min.x;
765 j -= base::m_dataWindow.min.y;
766 k -= base::m_dataWindow.min.z;
767 return m_v[i + j * m_vSize.x + k * m_vSizeXY];
768}

◆ w() [1/2]

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 182 of file MACField.h.

775{
781 assert (k <= base::m_dataWindow.max.z + 1);
782 // Add crop window offset
783 i -= base::m_dataWindow.min.x;
784 j -= base::m_dataWindow.min.y;
785 k -= base::m_dataWindow.min.z;
786 return m_w[i + j * m_wSize.x + k * m_wSizeXY];
787}

◆ w() [2/2]

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 185 of file MACField.h.

794{
800 assert (k <= base::m_dataWindow.max.z + 1);
801 // Add crop window offset
802 i -= base::m_dataWindow.min.x;
803 j -= base::m_dataWindow.min.y;
804 k -= base::m_dataWindow.min.z;
805 return m_w[i + j * m_wSize.x + k * m_wSizeXY];
806}

◆ cbegin_comp() [1/2]

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 207 of file MACField.h.

813{
814 using namespace MACFieldUtil;
815 if (FieldRes::dataResolution() == V3i(0))
816 return cend_comp(comp);
820}
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:253
const_mac_comp_iterator(MACComponent comp, const class_type &field, const Box3i &window, const V3i &currentPos)
Definition MACField.h:370
const_mac_comp_iterator cend_comp(MACComponent comp) const
Definition MACField.h:839

◆ cbegin_comp() [2/2]

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 209 of file MACField.h.

827{
828 using namespace MACFieldUtil;
829 if (subset.isEmpty())
830 return cend_comp(comp, subset);
832 return const_mac_comp_iterator(comp, *this, dataWindow, subset.min);
833}

◆ cend_comp() [1/2]

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 212 of file MACField.h.

840{
841 using namespace MACFieldUtil;
845 V3i(dataWindow.min.x,
846 dataWindow.min.y,
847 dataWindow.max.z + 1));
848}

◆ cend_comp() [2/2]

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 214 of file MACField.h.

855{
856 using namespace MACFieldUtil;
859 V3i(dataWindow.min.x,
860 dataWindow.min.y,
861 dataWindow.max.z + 1));
862}

◆ begin_comp() [1/2]

MACField< Data_T >::mac_comp_iterator MACField< Data_T >::begin_comp ( MACComponent comp)

Iterator to first element.

Definition at line 218 of file MACField.h.

869{
870 using namespace MACFieldUtil;
871 if (FieldRes::dataResolution() == V3i(0))
872 return end_comp(comp);
874 return mac_comp_iterator(comp, *this, dataWindow, dataWindow.min);
875}
mac_comp_iterator end_comp(MACComponent comp)
Definition MACField.h:894

◆ begin_comp() [2/2]

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 220 of file MACField.h.

882{
883 using namespace MACFieldUtil;
884 if (subset.isEmpty())
885 return end_comp(comp, subset);
887 return mac_comp_iterator(comp, *this, dataWindow, subset.min);
888}

◆ end_comp() [1/2]

MACField< Data_T >::mac_comp_iterator MACField< Data_T >::end_comp ( MACComponent comp)

Iterator to first element.

Definition at line 223 of file MACField.h.

895{
896 using namespace MACFieldUtil;
898 return mac_comp_iterator(comp, *this, dataWindow, V3i(dataWindow.min.x,
899 dataWindow.min.y,
900 dataWindow.max.z + 1));
901}

◆ end_comp() [2/2]

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 225 of file MACField.h.

908{
909 using namespace MACFieldUtil;
911 return mac_comp_iterator(comp, *this, dataWindow, V3i(dataWindow.min.x,
912 dataWindow.min.y,
913 dataWindow.max.z + 1));
914}

◆ uCenter()

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.

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
Definition MACField.h:698

◆ vCenter()

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.

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
Definition MACField.h:736

◆ wCenter()

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.

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
Definition MACField.h:774

◆ copyMAC()

void MACField< Data_T >::copyMAC ( typename MACField::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.

251 {
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 }
void matchDefinition(FieldRes::Ptr fieldToMatch)
Sets up this field so that resolution and mapping matches the other.
Definition Field.h:1003

◆ getComponentSize()

V3i MACField< Data_T >::getComponentSize ( ) const
inline

Returns the size of U,V,W components.

Definition at line 261 of file MACField.h.

262 { return V3i((int)m_u.size(), (int)m_v.size(), (int)m_w.size()); }

◆ clone()

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 271 of file MACField.h.

272 { return Ptr(new MACField(*this)); }
boost::intrusive_ptr< MACField > Ptr
Definition MACField.h:101

◆ sizeChanged()

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 280 of file MACField.h.

659{
660 // Call base class
662
663 V3i baseSize =
665
666 if (std::min(std::min(baseSize.x, baseSize.y), baseSize.z) < 0)
667 throw Exc::ResizeException("Attempt to resize ResizableField object "
668 "using negative size. Data window was: " +
670
671 // Calculate the size for each component of the MAC field
672 m_uSize = baseSize + V3i(1, 0, 0);
673 m_vSize = baseSize + V3i(0, 1, 0);
674 m_wSize = baseSize + V3i(0, 0, 1);
675
676 // Calculate the size of each z slice
677 m_uSizeXY = m_uSize.x * m_uSize.y;
678 m_vSizeXY = m_vSize.x * m_vSize.y;
679 m_wSizeXY = m_wSize.x * m_wSize.y;
680
681 // Allocate memory
682 try {
683 m_u.resize(m_uSize.x * m_uSize.y * m_uSize.z);
684 m_v.resize(m_vSize.x * m_vSize.y * m_vSize.z);
685 m_w.resize(m_wSize.x * m_wSize.y * m_wSize.z);
686 }
687 catch (std::bad_alloc &) {
688 throw Exc::MemoryException("Couldn't allocate MACField of size " +
690 }
691
692}
virtual void sizeChanged()
Subclasses should re-implement this if they need to perform memory allocations, etc....
Definition Field.h:901

◆ uPtr() [1/2]

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 286 of file MACField.h.

921{
922 // Add crop window offset
923 i -= base::m_dataWindow.min.x;
924 j -= base::m_dataWindow.min.y;
925 k -= base::m_dataWindow.min.z;
926 return &m_u[i + j * m_uSize.x + k * m_uSizeXY];
927}

◆ uPtr() [2/2]

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 289 of file MACField.h.

934{
935 // Add crop window offset
936 i -= base::m_dataWindow.min.x;
937 j -= base::m_dataWindow.min.y;
938 k -= base::m_dataWindow.min.z;
939 return &m_u[i + j * m_uSize.x + k * m_uSizeXY];
940}

◆ vPtr() [1/2]

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 292 of file MACField.h.

947{
948 // Add crop window offset
949 i -= base::m_dataWindow.min.x;
950 j -= base::m_dataWindow.min.y;
951 k -= base::m_dataWindow.min.z;
952 return &m_v[i + j * m_vSize.x + k * m_vSizeXY];
953}

◆ vPtr() [2/2]

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 295 of file MACField.h.

960{
961 // Add crop window offset
962 i -= base::m_dataWindow.min.x;
963 j -= base::m_dataWindow.min.y;
964 k -= base::m_dataWindow.min.z;
965 return &m_v[i + j * m_vSize.x + k * m_vSizeXY];
966}

◆ wPtr() [1/2]

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 298 of file MACField.h.

973{
974 // Add crop window offset
975 i -= base::m_dataWindow.min.x;
976 j -= base::m_dataWindow.min.y;
977 k -= base::m_dataWindow.min.z;
978 return &m_w[i + j * m_wSize.x + k * m_wSizeXY];
979}

◆ wPtr() [2/2]

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 301 of file MACField.h.

986{
987 // Add crop window offset
988 i -= base::m_dataWindow.min.x;
989 j -= base::m_dataWindow.min.y;
990 k -= base::m_dataWindow.min.z;
991 return &m_w[i + j * m_wSize.x + k * m_wSizeXY];
992}

Member Data Documentation

◆ x

template<class Data_T>
int MACField< Data_T >::const_mac_comp_iterator::x

Current position.

Definition at line 433 of file MACField.h.

Referenced by const_mac_comp_iterator(), operator++(), and updatePointer().

◆ y

template<class Data_T>
int MACField< Data_T >::const_mac_comp_iterator::y

Definition at line 433 of file MACField.h.

Referenced by const_mac_comp_iterator(), operator++(), and updatePointer().

◆ z

template<class Data_T>
int MACField< Data_T >::const_mac_comp_iterator::z

Definition at line 433 of file MACField.h.

Referenced by const_mac_comp_iterator(), operator++(), and updatePointer().

◆ m_p

template<class Data_T>
const real_t* MACField< Data_T >::const_mac_comp_iterator::m_p
private

Pointer to current element.

Definition at line 459 of file MACField.h.

Referenced by const_mac_comp_iterator(), operator!=(), operator*(), operator++(), operator->(), operator==(), and updatePointer().

◆ m_window

template<class Data_T>
Box3i MACField< Data_T >::const_mac_comp_iterator::m_window
private

Window to traverse.

Definition at line 461 of file MACField.h.

Referenced by const_mac_comp_iterator(), and operator++().

◆ m_comp

template<class Data_T>
MACComponent MACField< Data_T >::const_mac_comp_iterator::m_comp
private

Component to look up.

Definition at line 463 of file MACField.h.

Referenced by const_mac_comp_iterator(), and updatePointer().

◆ m_field

template<class Data_T>
const class_type& MACField< Data_T >::const_mac_comp_iterator::m_field
private

Reference to field being iterated over.

Definition at line 465 of file MACField.h.

Referenced by const_mac_comp_iterator(), and updatePointer().

◆ DEFINE_FIELD_RTTI_CONCRETE_CLASS

MACField< Data_T >::DEFINE_FIELD_RTTI_CONCRETE_CLASS

Definition at line 113 of file MACField.h.

◆ FIELD3D_CLASSNAME_CLASSTYPE_IMPLEMENTATION

MACField< Data_T >::FIELD3D_CLASSNAME_CLASSTYPE_IMPLEMENTATION

Definition at line 269 of file MACField.h.

◆ m_u

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

U component storage.

Definition at line 306 of file MACField.h.

◆ m_v

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

V component storage.

Definition at line 308 of file MACField.h.

◆ m_w

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

W component storage.

Definition at line 310 of file MACField.h.

◆ m_uSize

V3i MACField< Data_T >::m_uSize
protected

Size of U grid along each axis.

Definition at line 313 of file MACField.h.

◆ m_uSizeXY

int MACField< Data_T >::m_uSizeXY
protected

Size of xy slice for u component.

Definition at line 315 of file MACField.h.

◆ m_vSize

V3i MACField< Data_T >::m_vSize
protected

Size of V grid along each axis.

Definition at line 317 of file MACField.h.

◆ m_vSizeXY

int MACField< Data_T >::m_vSizeXY
protected

Size of xy slice for v component.

Definition at line 319 of file MACField.h.

◆ m_wSize

V3i MACField< Data_T >::m_wSize
protected

Size of W grid along each axis.

Definition at line 321 of file MACField.h.

◆ m_wSizeXY

int MACField< Data_T >::m_wSizeXY
protected

Size of xy slice for w component.

Definition at line 323 of file MACField.h.

◆ m_dummy

Data_T MACField< Data_T >::m_dummy
mutableprotected

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

Definition at line 326 of file MACField.h.

◆ ms_classType

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

Definition at line 332 of file MACField.h.


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