netgen/libsrc/visualization/vssolution.hpp

451 lines
11 KiB
C++
Raw Normal View History

2009-01-13 04:40:13 +05:00
#ifndef FILE_VSSOLUTION
#define FILE_VSSOLUTION
2014-10-08 18:46:25 +06:00
typedef void * ClientData;
struct Tcl_Interp;
2014-10-06 15:57:44 +06:00
namespace netgen
{
2009-01-13 04:40:13 +05:00
2015-10-19 13:08:30 +05:00
DLL_HEADER extern void ImportSolution (const char * filename);
2009-01-18 19:47:12 +05:00
2009-01-13 04:40:13 +05:00
class FieldLineCalc;
2014-10-08 18:46:25 +06:00
extern int Ng_Vis_Set (ClientData clientData,
Tcl_Interp * interp,
int argc, const char *argv[]);
2009-01-13 04:40:13 +05:00
2015-10-19 13:08:30 +05:00
class DLL_HEADER VisualSceneSolution : public VisualScene
2009-01-13 04:40:13 +05:00
{
friend class FieldLineCalc;
class ClipPlaneTrig
{
public:
struct ps
{
int pnr, locpnr;
};
ps points[3];
ElementIndex elnr;
};
class ClipPlanePoint
{
public:
ElementIndex elnr;
Point<3> lami;
Point<3> p;
};
#define USE_BUFFERS
#ifdef USE_BUFFERS
2016-11-01 15:47:49 +05:00
bool has_surfel_vbo = false;
GLuint surfel_vbo[4]; //
size_t surfel_vbo_size;
#endif
2009-01-13 04:40:13 +05:00
int surfellist;
int linelist;
2013-05-27 19:01:58 +06:00
int element1dlist;
2011-02-15 21:22:05 +05:00
int clipplanelist_scal;
int clipplanelist_vec;
2009-01-13 04:40:13 +05:00
int isolinelist;
int clipplane_isolinelist;
int surface_vector_list;
2009-08-05 20:20:30 +06:00
// int cone_list;
2009-01-13 04:40:13 +05:00
int isosurface_list;
int pointcurvelist;
bool draw_fieldlines;
bool drawpointcurves;
bool draw_isosurface;
int num_fieldlines;
bool fieldlines_randomstart;
int fieldlineslist;
int num_fieldlineslists;
int fieldlines_startarea;
2009-01-25 17:35:25 +05:00
Array<double> fieldlines_startarea_parameter;
2009-01-13 04:40:13 +05:00
int fieldlines_startface;
string fieldlines_filename;
double fieldlines_reltolerance;
int fieldlines_rktype;
double fieldlines_rellength;
double fieldlines_relthickness;
int fieldlines_vecfunction;
bool fieldlines_fixedphase;
float fieldlines_phase;
int fieldlines_maxpoints;
int surfeltimestamp, clipplanetimestamp, solutiontimestamp;
int surfellinetimestamp;
int fieldlinestimestamp, surface_vector_timestamp;
int pointcurve_timestamp;
int isosurface_timestamp;
int subdivision_timestamp;
int timetimestamp;
double minval, maxval;
NgLock *lock;
2014-02-24 01:31:40 +06:00
2009-01-13 04:40:13 +05:00
#ifdef PARALLELGL
2009-01-25 17:35:25 +05:00
Array<int> par_linelists;
Array<int> par_surfellists;
2009-01-13 04:40:13 +05:00
#endif
2014-02-24 01:31:40 +06:00
Array<UserVisualizationObject*> user_vis;
2009-01-13 04:40:13 +05:00
public:
enum EvalFunc {
FUNC_ABS = 1,
FUNC_ABS_TENSOR = 2,
FUNC_MISES = 3,
FUNC_MAIN = 4
};
2011-07-23 05:06:25 +06:00
int evalfunc;
2009-01-13 04:40:13 +05:00
enum SolType
{
SOL_NODAL = 1,
SOL_ELEMENT = 2,
SOL_SURFACE_ELEMENT = 3,
SOL_NONCONTINUOUS = 4,
SOL_SURFACE_NONCONTINUOUS = 5,
SOL_VIRTUALFUNCTION = 6,
SOL_MARKED_ELEMENTS = 10,
SOL_ELEMENT_ORDER = 11,
};
class SolData
{
public:
SolData ();
~SolData ();
char * name;
double * data;
int components;
int dist;
int order;
bool iscomplex;
bool draw_volume;
bool draw_surface;
SolType soltype;
SolutionData * solclass;
// internal variables:
int size;
};
2009-01-25 17:35:25 +05:00
Array<SolData*> soldata;
2009-01-13 04:40:13 +05:00
int usetexture; // 0..no, 1..1D texture (standard), 2..2D-texture (complex)
int clipsolution; // 0..no, 1..scal, 2..vec
int scalfunction, scalcomp, vecfunction;
int gridsize;
double xoffset, yoffset;
int autoscale, logscale;
double mminval, mmaxval;
int numisolines;
int subdivisions;
bool showclipsolution;
bool showsurfacesolution;
bool lineartexture;
int numtexturecols;
int multidimcomponent;
// bool fieldlineplot;
double time;
int deform;
double scaledeform;
bool imag_part;
private:
2009-01-25 17:35:25 +05:00
void BuildFieldLinesFromFile(Array<Point3d> & startpoints);
void BuildFieldLinesFromFace(Array<Point3d> & startpoints);
void BuildFieldLinesFromBox(Array<Point3d> & startpoints);
void BuildFieldLinesFromLine(Array<Point3d> & startpoints);
2015-01-09 02:18:33 +05:00
// weak_ptr<Mesh> wp_mesh;
2009-01-13 04:40:13 +05:00
public:
VisualSceneSolution ();
virtual ~VisualSceneSolution ();
virtual void BuildScene (int zoomall = 0);
virtual void DrawScene ();
virtual void MouseDblClick (int px, int py);
2015-01-09 02:18:33 +05:00
// void SetMesh (shared_ptr<Mesh> amesh);
// shared_ptr<Mesh> GetMesh () { return shared_ptr<Mesh>(wp_mesh); }
shared_ptr<Mesh> GetMesh () const { return shared_ptr<Mesh>(global_mesh); }
2014-10-06 15:57:44 +06:00
2009-01-13 04:40:13 +05:00
void BuildFieldLinesPlot ();
void AddSolutionData (SolData * soldata);
void ClearSolutionData ();
void UpdateSolutionTimeStamp ();
SolData * GetSolData (int i);
int GetNSolData () { return soldata.Size(); }
void SaveSolutionData (const char * filename);
2013-02-27 23:30:38 +06:00
/*
2009-01-13 04:40:13 +05:00
static void RealVec3d (const double * values, Vec3d & v,
bool iscomplex, bool imag);
2013-02-27 23:30:38 +06:00
*/
static Vec<3> RealVec3d (const double * values,
bool iscomplex, bool imag);
2009-01-13 04:40:13 +05:00
static void RealVec3d (const double * values, Vec3d & v,
bool iscomplex, double phaser, double phasei);
void SetSubdivision (int sd)
{
subdivisions = sd;
subdivision_timestamp = solutiontimestamp = NextTimeStamp();
}
void GetMinMax (int funcnr, int comp, double & minv, double & maxv) const;
2014-02-24 01:31:40 +06:00
void AddUserVisualizationObject (UserVisualizationObject * vis)
{
user_vis.Append (vis);
}
2011-07-15 22:26:32 +06:00
private:
2009-01-25 17:35:25 +05:00
void GetClippingPlaneTrigs (Array<ClipPlaneTrig> & trigs, Array<ClipPlanePoint> & pts);
void GetClippingPlaneGrid (Array<ClipPlanePoint> & pts);
2009-01-13 04:40:13 +05:00
void DrawCone (const Point<3> & p1, const Point<3> & p2, double r);
void DrawCylinder (const Point<3> & p1, const Point<3> & p2, double r);
// Get Function Value, local coordinates lam1, lam2, lam3,
bool GetValue (const SolData * data, ElementIndex elnr,
double lam1, double lam2, double lam3,
int comp, double & val) const;
bool GetValue (const SolData * data, ElementIndex elnr,
const double xref[], const double x[], const double dxdxref[],
int comp, double & val) const;
bool GetValueComplex (const SolData * data, ElementIndex elnr,
double lam1, double lam2, double lam3,
2009-08-29 15:29:09 +06:00
int comp, complex<double> & val) const;
2009-01-13 04:40:13 +05:00
bool GetValues (const SolData * data, ElementIndex elnr,
double lam1, double lam2, double lam3,
double * values) const;
bool GetValues (const SolData * data, ElementIndex elnr,
const double xref[], const double x[], const double dxdxref[],
double * values) const;
2012-04-27 00:22:49 +06:00
bool GetMultiValues (const SolData * data, ElementIndex elnr, int facetnr, int npt,
const double * xref, int sxref,
const double * x, int sx,
const double * dxdxref, int sdxdxref,
double * val, int sval) const;
2012-04-27 00:22:49 +06:00
bool GetSurfValue (const SolData * data, SurfaceElementIndex elnr, int facetnr,
2009-01-13 04:40:13 +05:00
double lam1, double lam2,
int comp, double & val) const;
2012-04-27 00:22:49 +06:00
bool GetSurfValue (const SolData * data, SurfaceElementIndex elnr, int facetnr,
2009-01-13 04:40:13 +05:00
const double xref[], const double x[], const double dxdxref[],
int comp, double & val) const;
2009-07-20 14:36:36 +06:00
2012-04-27 00:22:49 +06:00
bool GetSurfValueComplex (const SolData * data, SurfaceElementIndex elnr, int facetnr,
2009-01-13 04:40:13 +05:00
double lam1, double lam2,
2009-08-29 15:29:09 +06:00
int comp, complex<double> & val) const;
2009-01-13 04:40:13 +05:00
2012-04-27 00:22:49 +06:00
bool GetSurfValues (const SolData * data, SurfaceElementIndex elnr, int facetnr,
2009-01-13 04:40:13 +05:00
double lam1, double lam2,
double * values) const;
2012-04-27 00:22:49 +06:00
bool GetSurfValues (const SolData * data, SurfaceElementIndex elnr, int facetnr,
2009-01-13 04:40:13 +05:00
const double xref[], const double x[], const double dxdxref[],
double * values) const;
2012-04-27 00:22:49 +06:00
bool GetMultiSurfValues (const SolData * data, SurfaceElementIndex elnr, int facetnr,
int npt,
2009-07-20 14:36:36 +06:00
const double * xref, int sxref,
const double * x, int sx,
const double * dxdxref, int sdxdxref,
double * val, int sval) const;
double ExtractValue (const SolData * data, int comp, double * values) const;
2009-08-24 06:03:40 +06:00
complex<double> ExtractValueComplex (const SolData * data, int comp, double * values) const;
2009-01-13 04:40:13 +05:00
Vec<3> GetDeformation (ElementIndex elnr, const Point<3> & p) const;
2012-04-27 00:22:49 +06:00
Vec<3> GetSurfDeformation (SurfaceElementIndex selnr, int facetnr, double lam1, double lam2) const;
2009-01-13 04:40:13 +05:00
void GetPointDeformation (int pnum, Point<3> & p, SurfaceElementIndex elnr = -1) const;
public:
/// draw elements (build lists)
void DrawSurfaceElements ();
void DrawSurfaceElementLines ();
2013-05-27 19:01:58 +06:00
void Draw1DElements();
2009-01-13 04:40:13 +05:00
void DrawSurfaceVectors ();
2009-01-25 17:35:25 +05:00
void DrawTrigSurfaceVectors(const Array< Point<3> > & lp, const Point<3> & pmin, const Point<3> & pmax,
2009-01-13 04:40:13 +05:00
const int sei, const SolData * vsol);
void DrawIsoSurface(const SolData * sol, const SolData * grad, int comp);
void DrawIsoLines (const Point<3> & p1,
const Point<3> & p2,
const Point<3> & p3,
double val1, double val2, double val3);
// draw isolines between lines (p1,p2) and (p3,p4)
void DrawIsoLines2 (const Point<3> & p1,
const Point<3> & p2,
const Point<3> & p3,
const Point<3> & p4,
double val1, double val2, double val3, double val4);
2011-02-15 21:22:05 +05:00
void DrawClipPlaneTrigs (); // const SolData * sol, int comp);
2009-01-13 04:40:13 +05:00
void SetOpenGlColor(double val);
2009-08-05 20:20:30 +06:00
// 0 .. non, 1 .. scalar, 2 .. complex
void SetTextureMode (int texturemode) const;
2009-01-13 04:40:13 +05:00
friend int Ng_Vis_Set (ClientData clientData,
2014-10-08 18:46:25 +06:00
Tcl_Interp * interp,
int argc, const char *argv[]);
2009-01-13 04:40:13 +05:00
#ifdef PARALLELGL
void Broadcast ();
#endif
};
class RKStepper
{
private:
2009-01-25 17:35:25 +05:00
Array<double> c,b;
2009-01-13 04:40:13 +05:00
TABLE<double> *a;
int steps;
int order;
double tolerance;
2009-01-25 17:35:25 +05:00
Array<Vec3d> K;
2009-01-13 04:40:13 +05:00
int stepcount;
double h;
double startt;
double startt_bak;
Point3d startval;
Point3d startval_bak;
bool adaptive;
int adrun;
Point3d valh;
int notrestarted;
public:
~RKStepper();
RKStepper(int type = 0);
void SetTolerance(const double tol){tolerance = tol;}
void StartNextValCalc(const Point3d & astartval, const double astartt, const double ah, const bool aadaptive = false);
bool GetNextData(Point3d & val, double & t, double & ah);
bool FeedNextF(const Vec3d & f);
};
class FieldLineCalc
{
private:
const Mesh & mesh;
VisualSceneSolution & vss;
const VisualSceneSolution::SolData * vsol;
RKStepper stepper;
double maxlength;
int maxpoints;
int direction;
Point3d pmin, pmax;
double rad;
double phaser, phasei;
double critical_value;
bool randomized;
double thickness;
public:
FieldLineCalc(const Mesh & amesh, VisualSceneSolution & avss, const VisualSceneSolution::SolData * solution,
const double rel_length, const int amaxpoints = -1,
const double rel_thickness = -1, const double rel_tolerance = -1, const int rk_type = 0, const int adirection = 0);
void SetPhase(const double real, const double imag) { phaser = real; phasei = imag; }
void SetCriticalValue(const double val) { critical_value = val; }
void Randomized(void) { randomized = true; }
void NotRandomized(void) { randomized = false; }
2009-01-25 17:35:25 +05:00
void Calc(const Point3d & startpoint, Array<Point3d> & points, Array<double> & vals, Array<bool> & drawelems, Array<int> & dirstart);
2009-01-13 04:40:13 +05:00
2009-01-25 17:35:25 +05:00
void GenerateFieldLines(Array<Point3d> & potential_startpoints, const int numlines, const int gllist,
2009-01-13 04:40:13 +05:00
const double minval, const double maxval, const int logscale, double phaser, double phasei);
};
2015-10-19 13:08:30 +05:00
DLL_HEADER extern VisualSceneSolution vssolution;
2009-01-13 04:40:13 +05:00
2014-10-06 15:57:44 +06:00
}
2009-01-13 04:40:13 +05:00
#endif