#include <fiber/bundle/Bundle.hpp>
#include <fiber/finit/FinitAPI.h>
#include <fiber/field/ArrayRef.hpp>
#include <fiber/field/RegularlyFragmentedField.hpp>
#include <fiber/field/UniformCartesianArray.hpp>
#include <fiber/grid/types/FragmentedUniformGrid3D.hpp>
{
Finit();
const int KiB = 1024, MiB = KiB*KiB;
#if 1
theGlobalCache->setMaxCost( 3*MiB );
#endif
Grid&myGrid = BP[0.0][
"DemoGrid"];
BP->bindTo("outfile.f5");
#if 0
Verbose(0) << " --> have regular positions.";
else
Verbose(0) << " --> we do NOT have regular positions.";
#endif
Eagle::point3 BBoxMin(-1.0, -1.0, -0.5), BBoxMax( 1.0, 1.0, 0.5);
#if 0
MIndex(7,9,3);
#else
MIndex(3,2,1);
#endif
myGrid,
BBoxMin,
BlockSize,
BBoxMax);
if (!MyUniGrid3D)
{
Verbose(0) << "Could not create a fragmented uniform grid - incompatible bind file?";
return 0;
}
if (MyUniGrid3D.
Positions->nFragments() == 0)
{
Verbose(0) << " error, no input fragments found!";
return 1;
}
RefPtr< RegularlyFragmentedField<3> > Values = MyUniGrid3D.
newVertexField(
"Values");
{
VerboseSection(0,' ');
Verbose(0) << "Iterating over " << N << " fragments.";
{
RefPtr<FragmentID> fID = MyUniGrid3D.
getFragmentID( FragmentIndex );
{
GridValues->CacheInfoString = "Data for " + fID->Name();
auto U = MyUniGrid3D.
getCoords(FragmentIndex);
if (!U)
{
Verbose(0) <<
"Unsuitable positions: " << MyUniGrid3D.
Positions;
RefPtr< RegularlyFragmentedField<3> > R = MyUniGrid3D.
Positions;
Verbose(1) << "Fragments: " << R->getNumberOfFragments() << " Index: " << FragmentIndex;
Verbose(1) << "Regular Positions:\n" << R->xml();
auto C = MyUniGrid3D.getCoordCreator( FragmentIndex );
Verbose(0) << "Creator: " << C;
if (C) Verbose(0) << "Data: " << C->create();
break;
}
{
double& value = GridValues[ I ];
Eagle::point3 P = Pts[ I ];
value = P.x()*P.x() - P.y()*P.y() + P.z()*P.z();
}
if (MemBase::Creator_t
ValueCreator = Values->createCreator(GridValues, fID) )
{
ValueCreator->touch();
}
}
printf("**** At fragment [%s] cache uses %ld Bytes (%ldMiB) \n",
fID->Name().c_str(), long(theGlobalCache->totalCost() ),
long(theGlobalCache->totalCost() )/MiB
);fflush(stdout);
}
}
printf("After fragment loop: cache uses %ld Bytes\n", long(theGlobalCache->totalCost() ));fflush(stdout);
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 Grid is a set of Skeleton objects, each of them accessed via some unique SkeletonID object.
Definition Grid.hpp:60
RefPtr< Field > getCartesianPositions() const
Shortcut function: get the coordinates of the vertices in the default cartesian chart.
Definition Grid.hpp:246
A multidimensional index that is automatically a lower-dimensional index via recursion.
Definition MultiIndex.hpp:449
A convenience class for optimized handling of fields that are fragmented in a regular manner (n-dimen...
Definition RegularlyFragmentedField.hpp:27
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
RefPtr< RegularlyFragmentedField< VertexDims > > newVertexField(const char *Fieldname)
Create a new regularly fragmented field on the vertices under the given name, overwriting an existing...
Definition grid/types/RegularlyFragmentedGrid.hpp:338
RefPtr< RegularlyFragmentedField< VertexDims > > Positions
Field for the vertex coordinates.
Definition grid/types/RegularlyFragmentedGrid.hpp:310
MultiIndex< VertexDims > NumberOfFragments() const
Get the number of fragments here as multi-dimensional index.
Definition grid/types/RegularlyFragmentedGrid.hpp:374
RefPtr< FragmentID > getFragmentID(const MultiIndex< VertexDims > &FragmentIndex) const
Get the fragment ID for the given fragment index.
Definition grid/types/RegularlyFragmentedGrid.hpp:122