FiberVISH 0.2
Fish - The Fiber Bundle API for the Vish Visualization Shell
AnalyticCreator.hpp
1#ifndef __ANALYTIC_CREATOR_HPP
2#define __ANALYTIC_CREATOR_HPP
3
4#include <grid/CartesianChart.hpp>
5#include <field/DirectProductArray.hpp>
6
7#include <field/AsynchronCreator.hpp>
8#include <bone/FishField.hpp>
9
10#include <eagle/PhysicalSpace.hpp>
11#include <bundle/FieldSelector.hpp>
12
13using namespace MemCore;
14using namespace Fiber;
15
19template <class Formula>
21{
22 typedef typename Formula::value_type value_type;
23 enum { FieldDims = Formula::Dims };
24 typedef typename Formula::point_type point_type;
25
26 typedef typename Formula::Parameters Param_t;
27
29
31
32
33 double time;
34 Param_t Params;
35
36// RefPtr<Array_t> myArray;
38
40 {}
41
42#if 0
43 bool hasData() const override
44 {
45 if (result)
46 return true;
47
48 return false;
49 }
50#endif
51
52 const type_info&getType()
53 {
54 return typeid(value_type);
55 }
56
58 {
59 assert( myCoords );
60 RefPtr<ProcArray_t> Coords = myCoords->create();
61 assert(Coords);
62 ProcArray_t&P = *Coords;
63
64 RefPtr<Array_t> A = new Array_t( Coords->Size(), self() );
65// A->setCreator( self() );
66 A->CacheInfoString = "AnalyticCreator for T=" +String( time );
67
68 Array_t&MyField = *A;
69
70 Wizt::VActionNotifier::Progress vProgress("Computing Analytic field...",1);
71 for(MultiIndex<FieldDims> M : Coords->Size() )
72 {
73 const Eagle::point3&Pt = P[ M ];
74
75 Formula::eval( MyField[M], Pt, time, Params);
76 }
77
78 return A;
79 }
80
81 AnalyticCreator(double t, const RefPtr<CreativeArrayBase>&Coords, const Param_t&P)
83 {
84 return this->compute(Stop);
85 }
86 )
87 , time(t)
88 , Params(P)
89 , myCoords(Coords)
90 {
91 Assert( myCoords );
92
94 }
95
96
97static void setFieldType(Fiber::FieldSelector&FS)
98 {
99 FS.accept<value_type>();
100 }
101
102
103static bool set(double time, const Param_t&P,
104 Grid&G, const string&fieldname)
105 {
106 Assert( G.CartesianPositions() ); // need coordinates!
107 Assert( G.CartesianPositions()->getCreator() ); // need coordinates!
108 if (!G.CartesianPositions()) return false;
109 if (!G.CartesianPositions()->getCreator()) return false;
110
111 RefPtr<Field> myField = G[ fieldname ];
112// if (!myField)
113// myField = new Field(); //ugh! Need to get FragmentCollection from grid here
114
115 RefPtr<AnalyticCreator> AC = myField->getCreator();
116 if (AC)
117 {
118 if (AC->Params == P)
119 {
120 if (AC->isUnderCreation() )
121 return false;
122
123 return true;
124 }
125 }
126
127 {
128 Ref<AnalyticCreator> theAC(time, G.CartesianPositions()->getCreator(), P);
129 myField->setCreator( theAC );
130 }
131 return true;
132 }
133
134};
135
136#endif
A Creator object that generates its content on demand.
Definition AsynchronCreator.hpp:20
An iterator with an optional DataCreator, which is just a class to intercept creation of data along a...
Definition CreativeIterator.hpp:34
Description of types, which is meta-information like what is the number of elements of some array-lik...
Definition FiberType.hpp:61
An internal class that stores a couple of textual names.
Definition FieldSelector.hpp:18
A Grid is a set of Skeleton objects, each of them accessed via some unique SkeletonID object.
Definition Grid.hpp:60
RefPtr< Field > CartesianPositions() const
Shortcut function: get the coordinates of the vertices in the default cartesian chart.
Definition Grid.cpp:156
Interface class to provide information about multidimensional arrays without need to create the data ...
Definition MemArrayProperties.hpp:28
bool hasData() const override
void addInterface(const RefPtr< InterfaceBase > &I) const
string String(const T &Val)
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
A Fiber Creator that computes a data array on request in a thread.
Definition AnalyticCreator.hpp:21
Definition fs/init.hpp:20