#include <fiber/bundle/Bundle.hpp>
#include <fiber/finit/FinitAPI.h>
#include <fiber/field/ArrayRef.hpp>
#include <fiber/field/UniformCartesianArray.hpp>
#include <memcore/MemUsage.hpp>
#undef Verbose
#define Verbose(X) AppVerbose("Example",X)
{
Finit();
try
{
const int kB = 1024, MB = kB*kB;
#if 0
theGlobalCache->setMaxCost( 1*kB );
#else
theGlobalCache->setMaxCost( 7*MB );
#endif
Representation&myCartesianRepresentation = BP[1.0][
"DemoGrid"].makeCartesianRepresentation(3);
BP->bindToNew("050_BigDataOutOfCoreFragments.f5");
RefPtr<Field>&Positions = myCartesianRepresentation[ FIBER_POSITIONS ];
Eagle::point3 BBoxMin(-1.0, -1.0, -0.5), BBoxMax( 1.0, 1.0, 0.5);
const int nTilesX = 4, nTilesY = 4;
Eagle::tvector3 FragmentDiagonal = (BBoxMax - BBoxMin).multiply( 1.0/ nTilesX, 1.0/ nTilesY, 1.0);
{
VerboseSection(1,' ');
{
VerboseSection(1,' ');
for(int tileY = 0; tileY < nTilesY; tileY++)
for(int tileX = 0; tileX < nTilesX; tileX++)
{
const char xc[] = { char('0' + tileX),0},
yc[] = { char('0' + tileY),0};
string FragmentName = "tile";
FragmentName += xc;
FragmentName += "x";
FragmentName += yc;
Verbose(0) << "****Creating new fragment [" << FragmentName << "], currently using "
<< ", cache uses "
<< theGlobalCache->totalCost() << " Bytes ("
<< theGlobalCache->totalCost()/MB << "MB)";
Eagle::point3 FragmentBBoxMin = BBoxMin + FragmentDiagonal.multiply( tileX, tileY, 0.0);
RefPtr<UniformCartesianArray>
FragmentDiagonal.multiply(1.0/(Dims[0]-1), 1.0/(Dims[1]-1), 1.0/(Dims[2]-1) ) );
Coordinates->CacheInfoString = "Coordinates for " + FragmentName;
Positions->createCreator(Coordinates, FragmentName);
Positions->setFragmentOffset( FragmentName,
MIndex( tileX*Dims[0], tileY*Dims[1], 0*Dims[2] ) );
{
GridValues->CacheInfoString = "Data for " + FragmentName;
for(auto I : Dims)
{
double& value = GridValues[ I ];
Eagle::point3 P = Pts[ I ];
value = P.x()*P.x() - P.y()*P.y() + P.z()*P.z();
}
Values << FragmentName << GridValues;
}
}
}
Verbose(0) << "Before purging: cache uses "<< theGlobalCache->totalCost() << " Bytes.";
theGlobalCache->purge();
}
Verbose(0) << "After purging: cache uses "<< theGlobalCache->totalCost() << " Bytes.";
}
{
Verbose(0) << " Out of memory, could not handle object "
else
Verbose(0) << " Out of memory.";
}
return 0;
}
int main()
Demonstrates minimal usage of the FiberLib Create Bundle, insert a time slice, and safe it to a file.
Definition 010-SimpleSave.cpp:13
An array reference class, which is a convenience class for reference pointers to multidimensional mem...
Definition ArrayRef.hpp:28
Convenience class that implements a pointer to a Bundle object but adds some useful member funtions t...
Definition Bundle.hpp:779
A multidimensional index that is automatically a lower-dimensional index via recursion.
Definition MultiIndex.hpp:449
A Representation is a set of Field objects, each of them accessed via some FieldID identifier.
Definition Representation.hpp:101
static RefPtr< Cache, CacheBase > & MemCache()
StrongPtr< Object, ObjectBase > RefPtr
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
unsigned long long getMemUsage()
const RefPtr< Cacheable > myCacheable