Fish - FiberLib for VISH 0.3
Fish - The Fiber Bundle API for the Vish Visualization Shell
uniform_scalar.cpp

Demonstration of Creation of a scalar field on a uniform grid.

Demonstration of Creation of a scalar field on a uniform grid.

#include <iostream>
#include <bundle/Bundle.hpp>
#include <grid/CartesianChart.hpp>
#include <field/DirectProductArray.hpp>
#include <ocean/eagle/PhysicalSpace.hpp>
using namespace Fiber;
using namespace std;
using namespace MemCore;
using namespace Eagle;
/**@example uniform_scalar.cpp Demonstration of Creation of a scalar field on a uniform grid.
*/
int main()
{
// Create a grid object
Grid &G = B[0.0][ "UniformGrid" ];
// Make a 3-dimensional skeleton object to hold vertices within this grid
RefPtr<Skeleton> Vertices = G.makeVertices(3);
// Get a chart object to access data in cartesian coordinates
RefPtr<Chart> myCartesian = G.makeChart( typeid(Fiber::CartesianChart3D) );
// Create a representation of the vertices in these coordinates
Representation&R = (*Vertices)[ myCartesian ];
// Access a field object representing the positions
RefPtr<Field> Coords = R[ FIBER_POSITIONS ];
// Set coordinates on this grid
RefPtr<ProcArray_t> PCrds = new ProcArray_t();
{
int X = 63, Y = 61, Z = 79;
double B = 1.0;
PCrds->Components[0] = new LinearArray<double>(-B, 2*B/(X-1), X);
PCrds->Components[1] = new LinearArray<double>(-B, 2*B/(Y-1), Y);
PCrds->Components[2] = new LinearArray<double>(-B, 2*B/(Z-1), Z);
}
// Set data without memory management
Coords->setPersistentData( PCrds );
// Set additional data on the grid
RefPtr<Field>&myField = G[ "ScalarField" ];
typedef MemArray<3, double> ScalarData3D_t;
RefPtr<ScalarData3D_t> ScalarData = new ScalarData3D_t( PCrds->Size() );
MultiArray<3, double>&ScalarArray = *ScalarData;
ProcArray_t&P = *PCrds;
MultiIndex<3> M = MIndex(0,0,0);
do
{
const Eagle::point3&Pt = P[ M ];
double S = Pt.x()*Pt.x()
+
Pt.y()*Pt.y()
+
Pt.z()*Pt.z();
ScalarArray[ M ] = S;
}
while( M.inc( PCrds->Size() ) );
myField->setPersistentData ( ScalarData );
// B.save("MyUnigrid.f5");
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
Convenience class that implements a pointer to a Bundle object but adds some useful member funtions t...
Definition Bundle.hpp:779
Chart object for cartesian coordinates.
Definition CartesianChart.hpp:15
Definition DirectProductArray.hpp:367
A Grid is a set of Skeleton objects, each of them accessed via some unique SkeletonID object.
Definition Grid.hpp:60
RefPtr< Chart > makeChart(const type_info &ChartType, const string &name={}, uint16_t epsg_code=0)
Make a chart on this grid with the given name, ie create one if not yet existent.
Definition Grid.cpp:272
Class for N-dimensional MultiArrays with MemCore memory management.
Definition MemArray.hpp:34
Definition MultiArray.hpp:371
A multidimensional index that is automatically a lower-dimensional index via recursion.
Definition MultiIndex.hpp:449
bool inc(const MultiIndex &Dimens) noexcept
Increment the current index, if it is larger than the extent a given in the Dimensions parameter,...
Definition MultiIndex.hpp:830
A Representation is a set of Field objects, each of them accessed via some FieldID identifier.
Definition Representation.hpp:101
Skeleton & makeVertices(int dims)
Create a Skeleton describing the vertices of a Grid.
Definition SkeletonMap.cpp:290
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
STL namespace.