MOOSE - Multiscale Object Oriented Simulation Environment
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
PostMaster.cpp File Reference
#include "header.h"
#include "PostMaster.h"
#include "../shell/Shell.h"
+ Include dependency graph for PostMaster.cpp:

Go to the source code of this file.

Functions

int innerGetVec (const Eref &e, const OpFunc *op, double *getReturnBuf)
 

Function Documentation

int innerGetVec ( const Eref e,
const OpFunc op,
double *  getReturnBuf 
)

Collects all the values and stuffs into getReturnBuf. Returns size of all contents of getReturnBuf, in doubles. Puts number of returned values in getReturnBuf[0]. Note that these are likely to differ if the values returned are not doubles. Examines the eref to decide if this is a DataElement or a FieldElement. If a DataElement, scans through all data entries to fill the returnBuf. If a FieldElement, fills in field entries only of the one specified DataId on this eref.

Definition at line 249 of file PostMaster.cpp.

References Eref::dataIndex(), Eref::element(), Element::hasFields(), Element::localDataStart(), Element::numField(), Element::numLocalData(), OpFunc::opBuffer(), and PostMaster::reserveBufSize.

Referenced by PostMaster::handleRemoteGetVec().

251 {
252  static double buf[PostMaster::reserveBufSize];
253  // Would like to use eref iterator here.
254  Element* elm = e.element();
255  unsigned int start = elm->localDataStart();
256  int k = 1; // first entry is for numOnNode;
257  if ( elm->hasFields() ) {
258  DataId di = e.dataIndex();
259  unsigned int numField = elm->numField( di - start );
260  getReturnBuf[0] = numField;
261  for ( unsigned int j = 0; j < numField; ++j ) {
262  Eref er( elm, di, j );
263  // stuff return value into buf.
264  op->opBuffer( er, buf );
265  unsigned int size = buf[0];
266  memcpy( &getReturnBuf[k], &buf[1], size * sizeof( double ) );
267  k += size;
268  }
269  } else {
270  unsigned int end = start + elm->numLocalData();
271  getReturnBuf[0] = elm->numLocalData();
272  for ( unsigned int i = start; i < end; ++i ) {
273  Eref er( elm, i, 0 );
274  // stuff return value into buf.
275  op->opBuffer( er, buf );
276  unsigned int size = buf[0];
277  memcpy( &getReturnBuf[k], &buf[1], size * sizeof( double ) );
278  k += size;
279  }
280  }
281  return k;
282 }
unsigned int dataIndex() const
Definition: Eref.h:50
Element * element() const
Definition: Eref.h:42
virtual void opBuffer(const Eref &e, double *buf) const =0
Executes the OpFunc by converting args.
virtual unsigned int numField(unsigned int rawIndex) const =0
Returns number of field entries for specified data.
virtual bool hasFields() const =0
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.
unsigned int DataId
Definition: header.h:47
static const unsigned int reserveBufSize
Definition: PostMaster.h:147

+ Here is the call graph for this function:

+ Here is the caller graph for this function: