MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
HopFunc1< A > Class Template Reference

#include <HopFunc.h>

+ Inheritance diagram for HopFunc1< A >:
+ Collaboration diagram for HopFunc1< A >:

Public Member Functions

void dataOpVec (const Eref &e, const vector< A > &arg, const OpFunc1Base< A > *op) const
 
 HopFunc1 (HopIndex hopIndex)
 
unsigned int localFieldOpVec (const Eref &er, const vector< A > &arg, const OpFunc1Base< A > *op) const
 Executes the local vector assignment. Returns number of entries. More...
 
unsigned int localOpVec (Element *elm, const vector< A > &arg, const OpFunc1Base< A > *op, unsigned int k) const
 Executes the local vector assignment. Returns current arg index. More...
 
void op (const Eref &e, A arg) const
 
void opVec (const Eref &er, const vector< A > &arg, const OpFunc1Base< A > *op) const
 
unsigned int remoteOpVec (const Eref &er, const vector< A > &arg, const OpFunc1Base< A > *op, unsigned int start, unsigned int end) const
 Dispatches remote vector assignment. start and end are arg index. More...
 
- Public Member Functions inherited from OpFunc1Base< A >
bool checkFinfo (const Finfo *s) const
 
const OpFunc * makeHopFunc (HopIndex hopIndex) const
 
void opBuffer (const Eref &e, double *buf) const
 Executes the OpFunc by converting args. More...
 
void opVecBuffer (const Eref &e, double *buf) const
 Executes the OpFunc for all data by converting a vector of args. More...
 
string rttiType () const
 
- Public Member Functions inherited from OpFunc
 OpFunc ()
 
unsigned int opIndex () const
 
bool setIndex (unsigned int i)
 Used when rebuilding the Fid->OpFunc mapping. More...
 
virtual ~OpFunc ()
 

Private Attributes

HopIndex hopIndex_
 

Additional Inherited Members

- Static Public Member Functions inherited from OpFunc
static const OpFunc * lookop (unsigned int opIndex)
 
static unsigned int rebuildOpIndex ()
 cleans out the entire Ops vector. Returns size of orig vector. More...
 

Detailed Description

template<class A>
class HopFunc1< A >

Definition at line 45 of file HopFunc.h.

Constructor & Destructor Documentation

template<class A >
HopFunc1< A >::HopFunc1 ( HopIndex  hopIndex)
inline

Definition at line 48 of file HopFunc.h.

49  : hopIndex_( hopIndex )
50  {;}
HopIndex hopIndex_
Definition: HopFunc.h:175

Member Function Documentation

template<class A >
void HopFunc1< A >::dataOpVec ( const Eref &  e,
const vector< A > &  arg,
const OpFunc1Base< A > *  op 
) const
inline

Definition at line 123 of file HopFunc.h.

References Eref::dataIndex(), Eref::element(), Element::getNode(), Element::getNumOnNode(), Element::isGlobal(), HopFunc1< A >::localOpVec(), mooseMyNode(), mooseNumNodes(), HopFunc1< A >::remoteOpVec(), and Element::startDataIndex().

Referenced by HopFunc1< A >::opVec().

125  {
126  Element* elm = e.element();
127  vector< unsigned int > endOnNode( mooseNumNodes(), 0 );
128  unsigned int lastEnd = 0;
129  for ( unsigned int i = 0; i < mooseNumNodes(); ++i ) {
130  endOnNode[i] = elm->getNumOnNode(i) + lastEnd;
131  lastEnd = endOnNode[i];
132  }
133  unsigned int k = 0; // counter for index to arg vector.
134  // The global case just sends all entries to all nodes.
135  for ( unsigned int i = 0; i < mooseNumNodes(); ++i ) {
136  if ( i == mooseMyNode() ) {
137  k = localOpVec( elm, arg, op, k );
138  assert( k == endOnNode[i] );
139  } else {
140  if ( !elm->isGlobal() ) {
141  unsigned int start = elm->startDataIndex( i );
142  if ( start < elm->numData() ) {
143  Eref starter( elm, start );
144  assert( elm->getNode( starter.dataIndex() ) == i );
145  k = remoteOpVec( starter, arg, op, k, endOnNode[i]);
146  }
147  }
148  }
149  }
150  if ( elm->isGlobal() ) {
151  Eref starter( elm, 0 );
152  remoteOpVec( starter, arg, op, 0, arg.size() );
153  }
154  }
unsigned int localOpVec(Element *elm, const vector< A > &arg, const OpFunc1Base< A > *op, unsigned int k) const
Executes the local vector assignment. Returns current arg index.
Definition: HopFunc.h:59
Element * element() const
Definition: Eref.h:42
unsigned int remoteOpVec(const Eref &er, const vector< A > &arg, const OpFunc1Base< A > *op, unsigned int start, unsigned int end) const
Dispatches remote vector assignment. start and end are arg index.
Definition: HopFunc.h:96
unsigned int mooseNumNodes()
Definition: HopFunc.cpp:87
virtual unsigned int getNumOnNode(unsigned int node) const =0
Definition: Eref.h:26
unsigned int mooseMyNode()
Definition: HopFunc.cpp:92
virtual bool isGlobal() const =0
True if there is a copy of every dataEntry on all nodes.
virtual unsigned int getNode(unsigned int dataIndex) const =0
Returns node number of specified dataIndex.
virtual unsigned int startDataIndex(unsigned int nodeNum) const =0
Returns start dataIndex on specified node.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class A >
unsigned int HopFunc1< A >::localFieldOpVec ( const Eref &  er,
const vector< A > &  arg,
const OpFunc1Base< A > *  op 
) const
inline

Executes the local vector assignment. Returns number of entries.

Definition at line 78 of file HopFunc.h.

References Eref::dataIndex(), Eref::element(), Eref::getNode(), Element::localDataStart(), mooseMyNode(), Element::numField(), and OpFunc1Base< A >::op().

Referenced by HopFunc1< A >::opVec().

82  {
83  assert( er.getNode() == mooseMyNode() );
84  unsigned int di = er.dataIndex();
85  Element* elm = er.element();
86  unsigned int numField =
87  elm->numField( di - er.element()->localDataStart() );
88  for ( unsigned int q = 0; q < numField; ++q ) {
89  Eref temp( elm, di, q );
90  op->op( temp, arg[ q % arg.size() ] );
91  }
92  return numField;
93  }
virtual void op(const Eref &e, A arg) const =0
unsigned int getNode() const
Definition: Eref.cpp:52
unsigned int dataIndex() const
Definition: Eref.h:50
Element * element() const
Definition: Eref.h:42
virtual unsigned int numField(unsigned int rawIndex) const =0
Returns number of field entries for specified data.
Definition: Eref.h:26
unsigned int mooseMyNode()
Definition: HopFunc.cpp:92
virtual unsigned int localDataStart() const =0
Returns index of first data entry on this node.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class A >
unsigned int HopFunc1< A >::localOpVec ( Element *  elm,
const vector< A > &  arg,
const OpFunc1Base< A > *  op,
unsigned int  k 
) const
inline

Executes the local vector assignment. Returns current arg index.

Definition at line 59 of file HopFunc.h.

References Element::localDataStart(), Element::numField(), Element::numLocalData(), and OpFunc1Base< A >::op().

Referenced by HopFunc1< A >::dataOpVec().

63  {
64  unsigned int numLocalData = elm->numLocalData();
65  unsigned int start = elm->localDataStart();
66  for ( unsigned int p = 0; p < numLocalData; ++p ) {
67  unsigned int numField = elm->numField( p );
68  for ( unsigned int q = 0; q < numField; ++q ) {
69  Eref er( elm, p + start, q );
70  op->op( er, arg[ k % arg.size() ] );
71  k++;
72  }
73  }
74  return k;
75  }
virtual void op(const Eref &e, A arg) const =0
virtual unsigned int numField(unsigned int rawIndex) const =0
Returns number of field entries for specified data.
Definition: Eref.h:26
virtual unsigned int localDataStart() const =0
Returns index of first data entry on this node.
virtual unsigned int numLocalData() const =0
Returns number of local data entries on this node.

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

template<class A >
void HopFunc1< A >::op ( const Eref &  e,
A  arg 
) const
inlinevirtual

Implements OpFunc1Base< A >.

Definition at line 51 of file HopFunc.h.

References addToBuf(), dispatchBuffers(), HopFunc1< A >::hopIndex_, and Conv< T >::val2buf().

52  {
53  double* buf = addToBuf( e, hopIndex_, Conv< A >::size( arg ) );
54  Conv< A >::val2buf( arg, &buf );
56  }
static void val2buf(const T &val, double **buf)
Definition: Conv.h:56
double * addToBuf(const Eref &e, HopIndex hopIndex, unsigned int size)
Definition: HopFunc.cpp:29
Definition: Conv.h:30
void dispatchBuffers(const Eref &e, HopIndex hopIndex)
Definition: HopFunc.cpp:47
HopIndex hopIndex_
Definition: HopFunc.h:175

+ Here is the call graph for this function:

template<class A >
void HopFunc1< A >::opVec ( const Eref &  er,
const vector< A > &  arg,
const OpFunc1Base< A > *  op 
) const
inlinevirtual

Reimplemented from OpFunc1Base< A >.

Definition at line 156 of file HopFunc.h.

References HopFunc1< A >::dataOpVec(), Eref::element(), Eref::getNode(), Element::hasFields(), Element::isGlobal(), HopFunc1< A >::localFieldOpVec(), mooseMyNode(), and HopFunc1< A >::remoteOpVec().

158  {
159  Element* elm = er.element();
160  if ( elm->hasFields() ) {
161  if ( er.getNode() == mooseMyNode() ) {
162  // True for globals as well as regular objects on current node
163  localFieldOpVec( er, arg, op );
164  }
165  if ( elm->isGlobal() || er.getNode() != mooseMyNode() ) {
166  // Go just to the node where the fields reside, and
167  // assign the vector there. May be all nodes if global.
168  remoteOpVec( er, arg, op, 0, arg.size() );
169  }
170  } else {
171  dataOpVec( er, arg, op );
172  }
173  }
unsigned int localFieldOpVec(const Eref &er, const vector< A > &arg, const OpFunc1Base< A > *op) const
Executes the local vector assignment. Returns number of entries.
Definition: HopFunc.h:78
unsigned int getNode() const
Definition: Eref.cpp:52
Element * element() const
Definition: Eref.h:42
unsigned int remoteOpVec(const Eref &er, const vector< A > &arg, const OpFunc1Base< A > *op, unsigned int start, unsigned int end) const
Dispatches remote vector assignment. start and end are arg index.
Definition: HopFunc.h:96
virtual bool hasFields() const =0
unsigned int mooseMyNode()
Definition: HopFunc.cpp:92
virtual bool isGlobal() const =0
True if there is a copy of every dataEntry on all nodes.
void dataOpVec(const Eref &e, const vector< A > &arg, const OpFunc1Base< A > *op) const
Definition: HopFunc.h:123

+ Here is the call graph for this function:

template<class A >
unsigned int HopFunc1< A >::remoteOpVec ( const Eref &  er,
const vector< A > &  arg,
const OpFunc1Base< A > *  op,
unsigned int  start,
unsigned int  end 
) const
inline

Dispatches remote vector assignment. start and end are arg index.

Definition at line 96 of file HopFunc.h.

References addToBuf(), dispatchBuffers(), HopFunc1< A >::hopIndex_, and mooseNumNodes().

Referenced by HopFunc1< A >::dataOpVec(), and HopFunc1< A >::opVec().

100  {
101  unsigned int k = start;
102  unsigned int nn = end - start;
103  if ( mooseNumNodes() > 1 && nn > 0 ) {
104  // nn includes dataIndices. FieldIndices are handled by
105  // other functions.
106  vector< A > temp( nn );
107  // Have to do the insertion entry by entry because the
108  // argument vector may wrap around.
109  for ( unsigned int j = 0; j < nn; ++j ) {
110  unsigned int x = k % arg.size();
111  temp[j] = arg[x];
112  k++;
113  }
114  double* buf = addToBuf( er, hopIndex_,
115  Conv< vector< A > >::size( temp ) );
116  Conv< vector< A > >::val2buf( temp, &buf );
117  dispatchBuffers( er, hopIndex_ );
118  // HopIndex says that it is a SetVec call.
119  }
120  return k;
121  }
double * addToBuf(const Eref &e, HopIndex hopIndex, unsigned int size)
Definition: HopFunc.cpp:29
Definition: Conv.h:30
unsigned int mooseNumNodes()
Definition: HopFunc.cpp:87
void dispatchBuffers(const Eref &e, HopIndex hopIndex)
Definition: HopFunc.cpp:47
HopIndex hopIndex_
Definition: HopFunc.h:175

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

template<class A >
HopIndex HopFunc1< A >::hopIndex_
private

Definition at line 175 of file HopFunc.h.

Referenced by HopFunc1< A >::op(), and HopFunc1< A >::remoteOpVec().


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