Fish - FiberLib for VISH 0.3
Fish - The Fiber Bundle API for the Vish Visualization Shell
Functions
060-RegularFragmentTopology.cpp File Reference

[← Previous Example] [Next Example → 061-RegularFragmentTopologyWithHigherTopology.cpp ]. More...

#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>

Functions

int main ()
 

Detailed Description

[← Previous Example] [Next Example → 061-RegularFragmentTopologyWithHigherTopology.cpp ].

In FiberLib Tutorial

#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>
using namespace Fiber;
using namespace Eagle::PhysicalSpace;
int main()
{
// Initialize I/O layers (required for standalone programs)
Finit();
RefPtr<Cache>&theGlobalCache = Cache::MemCache();
const int KiB = 1024, MiB = KiB*KiB;
#if 1
theGlobalCache->setMaxCost( 3*MiB );
#endif
//
// Create a bundle object with a grid at T=1.0, named "DemoGrid", in
// a three-dimensional Cartesian representation, using the default
// coordinate system.
//
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);
MultiIndex<3> NumberOfFragments =
#if 0
MIndex(7,9,3); // large dataset
#else
MIndex(3,2,1); // small dataset
#endif
const MultiIndex<3> BlockSize = { 64,64,64 }; // blocksize is 256k
MyUniGrid3D = FragmentedUniformGrid3D::create( NumberOfFragments,
myGrid,
{
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;
}
const MultiIndex<3>&N = MyUniGrid3D.NumberOfFragments();
//
// Iterate over all fragments
//
{
Verbose(0) << "Iterating over " << N << " fragments.";
for(MultiIndex<3> FragmentIndex : N)
{
RefPtr<FragmentID> fID = MyUniGrid3D.getFragmentID( FragmentIndex );
//
// Add some data to each field fragment.
//
{
GridValues->CacheInfoString = "Data for " + fID->Name();
auto U = MyUniGrid3D.getCoords(FragmentIndex);
if (!U)
{
Verbose(0) << "Unsuitable fragment coordinates: " << MyUniGrid3D.FragmentCoordinates;
Verbose(0) << "Unsuitable positions: " << 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 ];
//
// Some analytic function here used to produce some
// halfway interestingly looking scalar field.
//
value = P.x()*P.x() - P.y()*P.y() + P.z()*P.z();
}
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
}
}
printf("After fragment loop: cache uses %ld Bytes\n", long(theGlobalCache->totalCost() ));fflush(stdout);
return 0;
}
Convenience class that implements a pointer to a Bundle object but adds some useful member funtions t...
Definition Bundle.hpp:779
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition CreativeIterator.hpp:34
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
Convenience class for procedural linear arrays in cartesian coordinates.
Definition UniformCartesianArray.hpp:22
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
Definition FragmentedUniformGrid3D.hpp:12