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

[← Previous Example] [Next Example → 020-CreateBundleAndSave.cpp ]. More...

#include <fiber/bundle/Bundle.hpp>
#include <fiber/finit/FinitAPI.h>
#include <fiber/field/ArrayRef.hpp>
#include <fiber/field/UniformCartesianArray.hpp>

Functions

int main ()
 Creating an (unfragmented) uniform grid with a scalar field.
 

Detailed Description

[← Previous Example] [Next Example → 020-CreateBundleAndSave.cpp ].

In FiberLib Tutorial

#include <fiber/bundle/Bundle.hpp>
#include <fiber/finit/FinitAPI.h>
#include <fiber/field/ArrayRef.hpp>
#include <fiber/field/UniformCartesianArray.hpp>
using namespace Fiber;
using namespace Eagle::PhysicalSpace;
/**
* @brief Creating an (unfragmented) uniform grid with a scalar field.
* Create a grid of size 31x43x17 at time 0.0 named "DemoGrid" with
* bounding box [-1.0, -1.0, -0.5]x[1.0, 1.0, 0.5] and add a field
* named "Values" of type double .
* For demonstration purposes, compute some values from the coordinates
* on each point of this field using x^2+y^2+z^2.
*/
int main()
{
// Initialize I/O layers (only required for standalone binaries)
Finit();
//
// Create a bundle object with a grid at T=1.0, named "DemoGrid", in
// a three-dimensional Cartesian representation, using the default
// coordinate system.
//
Representation&myCartesianRepresentation = BP[0.0]["DemoGrid"].makeCartesianRepresentation(3);
//
// Save the bundle to a file, even future data
// that are added to the bundle later. This feature
// is called "binding" a file to the Bundle.
//
BP->bindTo("UniformUnfragmentedGrid.f5");
//
// Create two fields, no data or fragmentation specified yet
//
RefPtr<Field>&Positions = myCartesianRepresentation[ FIBER_POSITIONS ];
Eagle::point3 BBoxMin(-1.0, -1.0, -0.5), BBoxMax( 1.0, 1.0, 0.5);
//
// Define the size of the dataset
//
const MultiIndex<3> Dims = MIndex(31,43,17);
//
// Produce uniform coordinates for the given fragment.
//
Positions->createCreator(Coordinates);
// writing field information in addition to coordinate info
{
for(MultiIndex<3> I : Dims)
{
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();
}
Values->createCreator(GridValues);
}
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 Representation is a set of Field objects, each of them accessed via some FieldID identifier.
Definition Representation.hpp:101
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

Function Documentation

◆ main()

int main ( )

Creating an (unfragmented) uniform grid with a scalar field.

Create a grid of size 31x43x17 at time 0.0 named "DemoGrid" with bounding box [-1.0, -1.0, -0.5]x[1.0, 1.0, 0.5] and add a field named "Values" of type double . For demonstration purposes, compute some values from the coordinates on each point of this field using x^2+y^2+z^2.