meshes in 1D, visualization

This commit is contained in:
Joachim Schoeberl 2013-05-27 13:01:58 +00:00
parent f9f8d5481b
commit f86bbbc827
6 changed files with 133 additions and 43 deletions

View File

@ -727,10 +727,19 @@ int Ng_FindSurfaceElementOfPoint (double * p, double * lami, int build_searchtre
int Ng_IsElementCurved (int ei)
{
switch (mesh->GetDimension())
{
case 1: return mesh->GetCurvedElements().IsSegmentCurved (ei-1);
case 2: return mesh->GetCurvedElements().IsSurfaceElementCurved (ei-1);
case 3: return mesh->GetCurvedElements().IsElementCurved (ei-1);
}
return 0;
/*
if (mesh->GetDimension() == 2)
return mesh->GetCurvedElements().IsSurfaceElementCurved (ei-1);
else
return mesh->GetCurvedElements().IsElementCurved (ei-1);
*/
}
@ -1604,25 +1613,46 @@ void Ng_GetEdge_Vertices (int ednr, int * vert)
int Ng_GetNVertexElements (int vnr)
{
if (mesh->GetDimension() == 3)
switch (mesh->GetDimension())
{
case 3:
return mesh->GetTopology().GetVertexElements(vnr).Size();
else
case 2:
return mesh->GetTopology().GetVertexSurfaceElements(vnr).Size();
case 1:
{
int cnt = 0;
for (SegmentIndex i = 0; i < mesh->GetNSeg(); i++)
if ( ((*mesh)[i][0] == vnr) || ((*mesh)[i][1] == vnr) ) cnt++;
return cnt;
}
}
}
void Ng_GetVertexElements (int vnr, int * els)
{
if (mesh->GetDimension() == 3)
switch (mesh->GetDimension())
{
case 3:
{
FlatArray<ElementIndex> ia = mesh->GetTopology().GetVertexElements(vnr);
for (int i = 0; i < ia.Size(); i++)
els[i] = ia[i]+1;
for (int i = 0; i < ia.Size(); i++) els[i] = ia[i]+1;
break;
}
else
case 2:
{
FlatArray<int> ia = mesh->GetTopology().GetVertexSurfaceElements(vnr);
for (int i = 0; i < ia.Size(); i++)
els[i] = ia[i];
for (int i = 0; i < ia.Size(); i++) els[i] = ia[i];
break;
}
case 1:
{
int cnt = 0;
for (SegmentIndex i = 0; i < mesh->GetNSeg(); i++)
if ( ((*mesh)[i][0] == vnr) || ((*mesh)[i][1] == vnr) )
els[cnt++] = i+1;
break;
}
}
}

View File

@ -51,7 +51,7 @@ namespace netgen
{
switch (dim)
{
case 0: return mesh -> GetNV();
case 0: return 0; // mesh -> GetNV();
case 1: return mesh -> GetNSeg();
case 2: return mesh -> GetNSE();
case 3: return mesh -> GetNE();
@ -421,7 +421,13 @@ namespace netgen
double * x,
double * dxdxi) const
{
cout << "1D not supported" << endl;
Point<3> xg;
Vec<3> dx;
mesh->GetCurvedElements().CalcSegmentTransformation (xi[0], elnr, xg, dx);
if (x) x[0] = xg(0);
if (dxdxi) dxdxi[0] = dx(0);
}
@ -486,7 +492,8 @@ namespace netgen
double * x, size_t sx,
double * dxdxi, size_t sdxdxi) const
{
cout << "1D not supported" << endl;
for (int i = 0; i < npts; i++)
ElementTransformation<1,1> (elnr, xi + i*sxi, x+i*sx, dxdxi+i*sdxdxi);
}

View File

@ -1618,6 +1618,7 @@ namespace netgen
}
}
}
}
for (int i = 0; i < segments.Size(); i++)
{
@ -1625,17 +1626,14 @@ namespace netgen
for (int j = 1; j <= 2; j++)
{
PointIndex hi = (j == 1) ? seg[0] : seg[1];
if (points[hi].Type() == INNERPOINT ||
points[hi].Type() == SURFACEPOINT)
points[hi].SetType(EDGEPOINT);
}
}
for (int i = 0; i < lockedpoints.Size(); i++)
points[lockedpoints[i]].SetType(FIXEDPOINT);
}
/*
@ -3214,13 +3212,6 @@ namespace netgen
// FindOpenElements();
timestamp = NextTimeStamp();
/*
(*testout) << "compress, done" << endl
<< "np = " << points.Size()
<< "ne = " << volelements.Size() << ", type.size = " << eltyps.Size()
<< "volelements = " << volelements << endl;
*/
}

View File

@ -92,6 +92,9 @@ namespace netgen
return res;
}
virtual bool GetSegmentValue (int segnr, double xref, double * values)
{ return false; }
virtual int GetNumMultiDimComponents ()
{

View File

@ -37,6 +37,7 @@ namespace netgen
{
surfellist = 0;
linelist = 0;
element1dlist = 0;
clipplanelist_scal = 0;
clipplanelist_vec = 0;
isolinelist = 0;
@ -554,10 +555,13 @@ namespace netgen
glColor3f (0.0f, 0.0f, 0.0f);
glDisable (GL_LINE_SMOOTH);
if (vispar.drawedges)
{
glCallList (element1dlist);
}
if (vispar.drawoutline && !numisolines)
{
// change for Martin
SetClippingPlane ();
glDepthMask(GL_FALSE);
glCallList (linelist);
@ -764,6 +768,10 @@ namespace netgen
}
if (vispar.drawedges)
Draw1DElements();
if (mesh->GetTimeStamp() > surface_vector_timestamp ||
solutiontimestamp > surface_vector_timestamp ||
@ -1078,7 +1086,55 @@ namespace netgen
clipplanetimestamp = max2 (vispar.clipping.timestamp, solutiontimestamp);
}
void VisualSceneSolution :: Draw1DElements ()
{
if (element1dlist)
glDeleteLists (element1dlist, 1);
element1dlist = glGenLists (1);
glNewList (element1dlist, GL_COMPILE);
int npt = (1 << subdivisions) + 1;
Array<double> pref(npt), values(npt);
Array<Point<3> > points(npt);
const SolData * sol = NULL;
if (scalfunction != -1) sol = soldata[scalfunction];
int ncomp = 0;
if (sol) ncomp = sol->components;
Array<double> mvalues(ncomp);
for (int i = 0; i < npt; i++)
pref[i] = double(i) / (npt-1);
for (SegmentIndex i = 0; i < mesh -> GetNSeg(); i++)
{
// mesh->GetCurvedElements().
// CalcMultiPointSegmentTransformation (&pref, i, &points, NULL);
// const Segment & seg = mesh -> LineSegment(i);
for (int j = 0; j < npt; j++)
mesh->GetCurvedElements().
CalcSegmentTransformation (pref[j], i, points[j]);
if (sol)
{
for (int j = 0; j < npt; j++)
{
sol->solclass->GetSegmentValue (i, pref[j], &mvalues[0]);
values[j] = ExtractValue (sol, scalcomp, &mvalues[0]);
points[j](1) += scaledeform * values[j];
}
}
glBegin (GL_LINE_STRIP);
for (int i = 0; i < npt; i++)
glVertex3dv (points[i]);
glEnd();
}
glEndList ();
}
void VisualSceneSolution :: DrawSurfaceElements ()
{

View File

@ -43,6 +43,7 @@ class VisualSceneSolution : public VisualScene
int surfellist;
int linelist;
int element1dlist;
int clipplanelist_scal;
int clipplanelist_vec;
int isolinelist;
@ -285,6 +286,8 @@ public:
/// draw elements (build lists)
void DrawSurfaceElements ();
void DrawSurfaceElementLines ();
void Draw1DElements();
void DrawSurfaceVectors ();
void DrawTrigSurfaceVectors(const Array< Point<3> > & lp, const Point<3> & pmin, const Point<3> & pmax,
const int sei, const SolData * vsol);