#include <ocean/shrimp/TimeDependent.hpp>
#include <bundle/Bundle.hpp>
#include <bone/BundleInput.hpp>
#include <grid/CartesianChart.hpp>
#include <eagle/PhysicalSpace.hpp>
#include <bone/GridObject.hpp>
#include <grid/types/LineSet.hpp>
#include <bone/FishSaver.hpp>
#include <field/ArrayRef.hpp>
#include <eagle/rotor3.hpp>
namespace
{
{
public:
void makeGrid(
Grid&G,
double time, index_t NumberOfLines)
{
index_t VerticesPerLine = 512;
index_t TotalVertices = VerticesPerLine*NumberOfLines;
int nVariant = 128;
{for(index_t j=0; j<NumberOfLines; j++)
for(index_t i=0; i<VerticesPerLine; i++)
{
index_t n( i + j*VerticesPerLine );
VertexEnumeration[n] = double(n)/ TotalVertices;
double omega = 1.0/40.0*(j+0.5);
double si =
sin(i*omega),
C = 0.04/(time*time+.2);
double Scale = 1.0 / 20.0;
z = C*(i+j) *Scale - 0.5;
Crds[ n ] = {x, y, z};
Vz = C;
double Nx = -
A*si*omega*omega,
Nz = 0;
Normals[ n ] = {Nx, Ny, Nz};
tvector Cross( Vy*Nz - Ny*Vz, -(Vx*Nz-Nx*Vz), Vx*Ny-Nx*Vy );
CurvatureCross[ n ] =
norm(Cross)/(s*s*s);
omega2 = omega*omega,
omega3 = omega2*omega;
double D = A2*co*co*omega2 + B2*si*si*omega2 + C*C;
double E = -2*A2*co*omega3*si + 2*B2*si*omega3*co;
double dTUx = -
A*si*omega2 /
sqrt(D) -
A*co*omega*E / (2*
pow(D, 3./2)),
dTUy = -
B*co*omega2 /
sqrt(D) +
B*si*omega*E / (2*
pow(D, 3./2)),
dTUz = -C*E / (2*
pow(D, 3./2));
tvector dTU(dTUx, dTUy, dTUz );
dT_ds[ n ] = dTU;
CurvatureGA[ n ] =
norm( dTU );
double omega4 = omega3*omega;
double F = 2*A2*si*si*omega4-2*A2*co*co*omega4+2*B2*co*co*omega4-2*B2*si*si*omega4;
double ddTUx = -
A*co*omega3/
sqrt(D) +
A*si*omega2*E /
pow(D, 3./2) + 3./4 *
A*co*omega*E*E /
pow(D, 5./2) - 1./2 *
A*co*omega*F /
pow(D, 3./2),
ddTUy = -
B*si*omega3/
sqrt(D) +
B*co*omega2*E /
pow(D, 3./2) - 3./4 *
B*si*omega*E*E /
pow(D, 5./2) + 1./2 *
B*si*omega*F /
pow(D, 3./2),
ddTUz = 3./4 * C *E*E /
pow(D, 5./2) - 1./2 * C * F /
pow(D, 3./2);
tvector ddTU(ddTUx, ddTUy, ddTUz );
tvector U;
U ={ (.1+time)*-18*
cos(i*omega)*omega*omega*omega,
(.1+time)*16*
sin(i*omega)*omega*omega*omega,
0};
TorsionCross[ n ] =
dot(Cross, U) /
norm2(Cross);
TorsionGA[ n ] = tau;
for(int vidx = 0; vidx < nVariant; vidx++)
{
double V = 1.0*vidx / nVariant,
N = 1.0 * i/ VerticesPerLine;
V = 0.5+0.5*(
sin(V*3.141592*(1+4*N) ));
VariantData[ MIndex( n, vidx) ] = static_cast<unsigned char>(255.0*V);
}
}}
{for(index_t j=0; j<NumberOfLines; j++)
{
for(index_t i=0; i<VerticesPerLine; i++)
{
E[i] = i + j*VerticesPerLine;
}
}}
LineSet theLines(G.self(), CoordsArray, LinesetArray );
(*theLines.CartesianVertices)[ "Analytic CrossCurvature" ]->setPersistentData( CurvatureCross );
(*theLines.CartesianVertices)[ "Analytic GACurvature" ]->setPersistentData( CurvatureGA );
(*theLines.CartesianVertices)[ "Analytic Normals" ]->setPersistentData( Normals );
(*theLines.CartesianVertices)[ "Analytic CrossTorsion" ]->setPersistentData( TorsionCross );
(*theLines.CartesianVertices)[ "Analytic GATorsion" ]->setPersistentData( TorsionGA );
(*theLines.CartesianVertices)[ "Analytic dT_ds" ]->setPersistentData( dT_ds );
(*theLines.CartesianVertices)[ "Variant Data" ]->setPersistentData( VariantData );
(*theLines.CartesianVertices)[ "LocalVertexNumber" ]->setPersistentData( VertexEnumeration );
}
HelicalLines(const string&name, int p, const RefPtr<VCreationPreferences>&VP)
: VObject(name, p, VP)
, LineGrid( this, "grid")
, tsNumberOfLines(this, "NumberOfLines", 4, 0)
, TimeSteps( this, "timesteps", 30,2)
, TMax(this, "tmax", 2.0, 1)
{
}
{
double t_min = 0.0,
t_max = 1.0;
int nTimeSteps = 10;
TimeSteps << Context >> nTimeSteps;
TMax << Context >> t_max;
#define gridname "helicalgrid"
int NumberOfLines = 4;
tsNumberOfLines << Context >> NumberOfLines;
for(int t = 0; t<nTimeSteps; t++)
{
double time = t*(t_max - t_min) / nTimeSteps + t_min;
Grid&G =
B[ time ][ gridname ];
makeGrid( G, time, NumberOfLines);
}
return true;
}
};
}
namespace
{
MyCreator(
Category(
"CreateGrid" ) + VIdentifier(
"HelicalLines" ) +
Application(
"General;HydroVish" ) +
Url(
"http://ahm.co.at/wiki/en" ),
}
complex< _Tp > sin(const complex< _Tp > &)
complex< _Tp > pow(const _Tp &, const complex< _Tp > &)
complex< _Tp > cos(const complex< _Tp > &)
complex< _Tp > sqrt(const complex< _Tp > &)
constexpr void resize(size_type __new_size)
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
Context information to select a grid from within a bundle.
Definition GridSelector.hpp:26
A Grid is a set of Skeleton objects, each of them accessed via some unique SkeletonID object.
Definition Grid.hpp:60
A set of lines stored on a Grid.
Definition LineSet.hpp:55
bool setupStandardFields(const RefPtr< Grid > &theGrid)
Setup some standard fields suitable for lines on this Grid.
Definition LineSet.cpp:663
std::vector< LineSet::LineIndex_t > LineIndices_t
A vector of line indices.
Definition LineSet.hpp:72
Definition MultiArray.hpp:371
Convenience class for objects that provide a Grid that may be saved.
Definition FishSaver.hpp:127
bool setProperty(const string &theName, const Type &theValue) const
vector dot(const bivector &a, const vector &b)
double norm2(const PhysicalSpace::bivector &v)
double norm(const PhysicalSpace::bivector &v)
Given a fragmented field of curvilinear coordinates, (3D array of coordinates), build a uniform Grid ...
Definition FAQ.dox:2
Wizt::VCreatorProperty< Wizt::VCreatorProperties::URL > Url
Wizt::VCreatorProperty< Wizt::VCreatorProperties::APPLICATION > Application
Wizt::VCreatorProperty< Wizt::VCreatorProperties::DESCRIPTION > Description
Wizt::VCreatorProperty< Wizt::VCreatorProperties::SHORTHELP > Help
Wizt::VCreatorProperty< Wizt::VCreatorProperties::CATEGORY > Category
note: cannot derive from FloatingSkeletonRenderer as long as independent base class TriangleRenderer ...
Store the velocity of curve, which determines its parameterization.
Definition CurveOperators.hpp:140
static const char Velocity[]
The velocity with which particles pass through this line.
Definition LineSet.hpp:163