Skip to content
Snippets Groups Projects
Commit 0f05e69e authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

Suppressed Post_Simplex structure

parent d47527ab
No related branches found
No related tags found
No related merge requests found
/* $Id: Views.cpp,v 1.6 2000-11-26 21:34:22 geuzaine Exp $ */ /* $Id: Views.cpp,v 1.7 2000-11-27 10:58:18 geuzaine Exp $ */
#include "Gmsh.h" #include "Gmsh.h"
#include "Views.h" #include "Views.h"
...@@ -10,7 +10,8 @@ Post_View *ActualView; ...@@ -10,7 +10,8 @@ Post_View *ActualView;
extern Context_T CTX ; extern Context_T CTX ;
static int ActualViewNum=0; static int ActualViewNum=0;
static int NbPoints, NbLines, NbTriangles, NbTetrahedra;
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
/* V i e w s */ /* V i e w s */
...@@ -27,6 +28,8 @@ int fcmpPostViewDuplicateOf(const void *v1, const void *v2){ ...@@ -27,6 +28,8 @@ int fcmpPostViewDuplicateOf(const void *v1, const void *v2){
void BeginView(int allocate){ void BeginView(int allocate){
ActualView = (Post_View*)Malloc(sizeof(Post_View)); ActualView = (Post_View*)Malloc(sizeof(Post_View));
NbPoints = NbLines = NbTriangles = NbTetrahedra = 0;
ActualView->NbSP = ActualView->NbVP = ActualView->NbTP = 0; ActualView->NbSP = ActualView->NbVP = ActualView->NbTP = 0;
ActualView->NbSL = ActualView->NbVL = ActualView->NbTL = 0; ActualView->NbSL = ActualView->NbVL = ActualView->NbTL = 0;
ActualView->NbST = ActualView->NbVT = ActualView->NbTT = 0; ActualView->NbST = ActualView->NbVT = ActualView->NbTT = 0;
...@@ -38,33 +41,25 @@ void BeginView(int allocate){ ...@@ -38,33 +41,25 @@ void BeginView(int allocate){
ActualView->SP = List_Create(100,1000,sizeof(double)); ActualView->SP = List_Create(100,1000,sizeof(double));
ActualView->VP = List_Create(100,1000,sizeof(double)); ActualView->VP = List_Create(100,1000,sizeof(double));
ActualView->TP = List_Create(100,1000,sizeof(double)); ActualView->TP = List_Create(100,1000,sizeof(double));
ActualView->Points = List_Create(100,1000,sizeof(Post_Simplex));
ActualView->SL = List_Create(100,1000,sizeof(double)); ActualView->SL = List_Create(100,1000,sizeof(double));
ActualView->VL = List_Create(100,1000,sizeof(double)); ActualView->VL = List_Create(100,1000,sizeof(double));
ActualView->TL = List_Create(100,1000,sizeof(double)); ActualView->TL = List_Create(100,1000,sizeof(double));
ActualView->Lines = List_Create(100,1000,sizeof(Post_Simplex));
ActualView->ST = List_Create(100,1000,sizeof(double)); ActualView->ST = List_Create(100,1000,sizeof(double));
ActualView->VT = List_Create(100,1000,sizeof(double)); ActualView->VT = List_Create(100,1000,sizeof(double));
ActualView->TT = List_Create(100,1000,sizeof(double)); ActualView->TT = List_Create(100,1000,sizeof(double));
ActualView->Triangles = List_Create(100,1000,sizeof(Post_Simplex));
ActualView->SS = List_Create(100,1000,sizeof(double)); ActualView->SS = List_Create(100,1000,sizeof(double));
ActualView->VS = List_Create(100,1000,sizeof(double)); ActualView->VS = List_Create(100,1000,sizeof(double));
ActualView->TS = List_Create(100,1000,sizeof(double)); ActualView->TS = List_Create(100,1000,sizeof(double));
ActualView->Tetrahedra = List_Create(100,1000,sizeof(Post_Simplex));
} }
else{ else{
ActualView->Time = NULL; ActualView->Time = NULL;
ActualView->SP = NULL; ActualView->VP = NULL; ActualView->TP = NULL; ActualView->SP = NULL; ActualView->VP = NULL; ActualView->TP = NULL;
ActualView->Points = NULL;
ActualView->SL = NULL; ActualView->VL = NULL; ActualView->TL = NULL; ActualView->SL = NULL; ActualView->VL = NULL; ActualView->TL = NULL;
ActualView->Lines = NULL;
ActualView->ST = NULL; ActualView->VT = NULL; ActualView->TT = NULL; ActualView->ST = NULL; ActualView->VT = NULL; ActualView->TT = NULL;
ActualView->Triangles = NULL;
ActualView->SS = NULL; ActualView->VS = NULL; ActualView->TS = NULL; ActualView->SS = NULL; ActualView->VS = NULL; ActualView->TS = NULL;
ActualView->Tetrahedra = NULL;
} }
ActualView->Changed = 1; ActualView->Changed = 1;
...@@ -108,20 +103,20 @@ void EndView(int AddInUI, int Number, char *FileName, char *Name, ...@@ -108,20 +103,20 @@ void EndView(int AddInUI, int Number, char *FileName, char *Name,
if(ActualView->NbSP){ if(ActualView->NbSP){
nb = List_Nbr(ActualView->SP) / ActualView->NbSP ; nb = List_Nbr(ActualView->SP) / ActualView->NbSP ;
for(i = 0 ; i < List_Nbr(ActualView->SP) ; i+=nb) for(i = 0 ; i < List_Nbr(ActualView->SP) ; i+=nb)
AddView_ScalarSimplex(0, (double*)List_Pointer(ActualView->SP,i), Stat_ScalarSimplex(0, (double*)List_Pointer(ActualView->SP,i),
nb-3, (double*)List_Pointer(ActualView->SP,i+3)); nb-3, (double*)List_Pointer(ActualView->SP,i+3));
} }
if(ActualView->NbVP){ if(ActualView->NbVP){
nb = List_Nbr(ActualView->VP) / ActualView->NbVP ; nb = List_Nbr(ActualView->VP) / ActualView->NbVP ;
for(i = 0 ; i < List_Nbr(ActualView->VP) ; i+=nb) for(i = 0 ; i < List_Nbr(ActualView->VP) ; i+=nb)
AddView_VectorSimplex(0, (double*)List_Pointer(ActualView->VP,i), Stat_VectorSimplex(0, (double*)List_Pointer(ActualView->VP,i),
nb-3, (double*)List_Pointer(ActualView->VP,i+3)); nb-3, (double*)List_Pointer(ActualView->VP,i+3));
} }
if(ActualView->NbTP){ if(ActualView->NbTP){
nb = List_Nbr(ActualView->TP) / ActualView->NbTP ; nb = List_Nbr(ActualView->TP) / ActualView->NbTP ;
for(i = 0 ; i < List_Nbr(ActualView->TP) ; i+=nb) for(i = 0 ; i < List_Nbr(ActualView->TP) ; i+=nb)
AddView_TensorSimplex(0, (double*)List_Pointer(ActualView->TP,i), Stat_TensorSimplex(0, (double*)List_Pointer(ActualView->TP,i),
nb-3, (double*)List_Pointer(ActualView->TP,i+3)); nb-3, (double*)List_Pointer(ActualView->TP,i+3));
} }
// Lines // Lines
...@@ -129,20 +124,20 @@ void EndView(int AddInUI, int Number, char *FileName, char *Name, ...@@ -129,20 +124,20 @@ void EndView(int AddInUI, int Number, char *FileName, char *Name,
if(ActualView->NbSL){ if(ActualView->NbSL){
nb = List_Nbr(ActualView->SL) / ActualView->NbSL ; nb = List_Nbr(ActualView->SL) / ActualView->NbSL ;
for(i = 0 ; i < List_Nbr(ActualView->SL) ; i+=nb) for(i = 0 ; i < List_Nbr(ActualView->SL) ; i+=nb)
AddView_ScalarSimplex(1, (double*)List_Pointer(ActualView->SL,i), Stat_ScalarSimplex(1, (double*)List_Pointer(ActualView->SL,i),
nb-6, (double*)List_Pointer(ActualView->SL,i+6)); nb-6, (double*)List_Pointer(ActualView->SL,i+6));
} }
if(ActualView->NbVL){ if(ActualView->NbVL){
nb = List_Nbr(ActualView->VL) / ActualView->NbVL ; nb = List_Nbr(ActualView->VL) / ActualView->NbVL ;
for(i = 0 ; i < List_Nbr(ActualView->VL) ; i+=nb) for(i = 0 ; i < List_Nbr(ActualView->VL) ; i+=nb)
AddView_VectorSimplex(1, (double*)List_Pointer(ActualView->VL,i), Stat_VectorSimplex(1, (double*)List_Pointer(ActualView->VL,i),
nb-6, (double*)List_Pointer(ActualView->VL,i+6)); nb-6, (double*)List_Pointer(ActualView->VL,i+6));
} }
if(ActualView->NbTL){ if(ActualView->NbTL){
nb = List_Nbr(ActualView->TL) / ActualView->NbTL ; nb = List_Nbr(ActualView->TL) / ActualView->NbTL ;
for(i = 0 ; i < List_Nbr(ActualView->TL) ; i+=nb) for(i = 0 ; i < List_Nbr(ActualView->TL) ; i+=nb)
AddView_TensorSimplex(1, (double*)List_Pointer(ActualView->TL,i), Stat_TensorSimplex(1, (double*)List_Pointer(ActualView->TL,i),
nb-6, (double*)List_Pointer(ActualView->TL,i+6)); nb-6, (double*)List_Pointer(ActualView->TL,i+6));
} }
// Triangles // Triangles
...@@ -150,20 +145,20 @@ void EndView(int AddInUI, int Number, char *FileName, char *Name, ...@@ -150,20 +145,20 @@ void EndView(int AddInUI, int Number, char *FileName, char *Name,
if(ActualView->NbST){ if(ActualView->NbST){
nb = List_Nbr(ActualView->ST) / ActualView->NbST ; nb = List_Nbr(ActualView->ST) / ActualView->NbST ;
for(i = 0 ; i < List_Nbr(ActualView->ST) ; i+=nb) for(i = 0 ; i < List_Nbr(ActualView->ST) ; i+=nb)
AddView_ScalarSimplex(2, (double*)List_Pointer(ActualView->ST,i), Stat_ScalarSimplex(2, (double*)List_Pointer(ActualView->ST,i),
nb-9, (double*)List_Pointer(ActualView->ST,i+9)); nb-9, (double*)List_Pointer(ActualView->ST,i+9));
} }
if(ActualView->NbVT){ if(ActualView->NbVT){
nb = List_Nbr(ActualView->VT) / ActualView->NbVT ; nb = List_Nbr(ActualView->VT) / ActualView->NbVT ;
for(i = 0 ; i < List_Nbr(ActualView->VT) ; i+=nb) for(i = 0 ; i < List_Nbr(ActualView->VT) ; i+=nb)
AddView_VectorSimplex(2, (double*)List_Pointer(ActualView->VT,i), Stat_VectorSimplex(2, (double*)List_Pointer(ActualView->VT,i),
nb-9, (double*)List_Pointer(ActualView->VT,i+9)); nb-9, (double*)List_Pointer(ActualView->VT,i+9));
} }
if(ActualView->NbTT){ if(ActualView->NbTT){
nb = List_Nbr(ActualView->TT) / ActualView->NbTT ; nb = List_Nbr(ActualView->TT) / ActualView->NbTT ;
for(i = 0 ; i < List_Nbr(ActualView->TT) ; i+=nb) for(i = 0 ; i < List_Nbr(ActualView->TT) ; i+=nb)
AddView_TensorSimplex(2, (double*)List_Pointer(ActualView->TT,i), Stat_TensorSimplex(2, (double*)List_Pointer(ActualView->TT,i),
nb-9, (double*)List_Pointer(ActualView->TT,i+9)); nb-9, (double*)List_Pointer(ActualView->TT,i+9));
} }
// Tetrahedra // Tetrahedra
...@@ -171,20 +166,20 @@ void EndView(int AddInUI, int Number, char *FileName, char *Name, ...@@ -171,20 +166,20 @@ void EndView(int AddInUI, int Number, char *FileName, char *Name,
if(ActualView->NbSS){ if(ActualView->NbSS){
nb = List_Nbr(ActualView->SS) / ActualView->NbSS ; nb = List_Nbr(ActualView->SS) / ActualView->NbSS ;
for(i = 0 ; i < List_Nbr(ActualView->SS) ; i+=nb) for(i = 0 ; i < List_Nbr(ActualView->SS) ; i+=nb)
AddView_ScalarSimplex(3, (double*)List_Pointer(ActualView->SS,i), Stat_ScalarSimplex(3, (double*)List_Pointer(ActualView->SS,i),
nb-12, (double*)List_Pointer(ActualView->SS,i+12)); nb-12, (double*)List_Pointer(ActualView->SS,i+12));
} }
if(ActualView->NbVS){ if(ActualView->NbVS){
nb = List_Nbr(ActualView->VS) / ActualView->NbVS ; nb = List_Nbr(ActualView->VS) / ActualView->NbVS ;
for(i = 0 ; i < List_Nbr(ActualView->VS) ; i+=nb) for(i = 0 ; i < List_Nbr(ActualView->VS) ; i+=nb)
AddView_VectorSimplex(3, (double*)List_Pointer(ActualView->VS,i), Stat_VectorSimplex(3, (double*)List_Pointer(ActualView->VS,i),
nb-12, (double*)List_Pointer(ActualView->VS,i+12)); nb-12, (double*)List_Pointer(ActualView->VS,i+12));
} }
if(ActualView->NbTS){ if(ActualView->NbTS){
nb = List_Nbr(ActualView->TS) / ActualView->NbTS ; nb = List_Nbr(ActualView->TS) / ActualView->NbTS ;
for(i = 0 ; i < List_Nbr(ActualView->TS) ; i+=nb) for(i = 0 ; i < List_Nbr(ActualView->TS) ; i+=nb)
AddView_TensorSimplex(3, (double*)List_Pointer(ActualView->TS,i), Stat_TensorSimplex(3, (double*)List_Pointer(ActualView->TS,i),
nb-12, (double*)List_Pointer(ActualView->TS,i+12)); nb-12, (double*)List_Pointer(ActualView->TS,i+12));
} }
// Dummy time values if using old parsed format... // Dummy time values if using old parsed format...
...@@ -254,20 +249,11 @@ void FreeView(Post_View *v){ ...@@ -254,20 +249,11 @@ void FreeView(Post_View *v){
if(free && !v->Links){ if(free && !v->Links){
Msg(DEBUG, " ->Freeing View"); Msg(DEBUG, " ->Freeing View");
List_Delete(v->Time); List_Delete(v->Time);
List_Delete(v->SP); List_Delete(v->VP); List_Delete(v->TP); List_Delete(v->SP); List_Delete(v->VP); List_Delete(v->TP);
List_Delete(v->Points);
List_Delete(v->SL); List_Delete(v->VL); List_Delete(v->TL); List_Delete(v->SL); List_Delete(v->VL); List_Delete(v->TL);
List_Delete(v->Lines);
List_Delete(v->ST); List_Delete(v->VT); List_Delete(v->TT); List_Delete(v->ST); List_Delete(v->VT); List_Delete(v->TT);
List_Delete(v->Triangles);
List_Delete(v->SS); List_Delete(v->VS); List_Delete(v->TS); List_Delete(v->SS); List_Delete(v->VS); List_Delete(v->TS);
List_Delete(v->Tetrahedra);
} }
} }
...@@ -301,68 +287,52 @@ void CopyViewOptions(Post_View *src, Post_View *dest){ ...@@ -301,68 +287,52 @@ void CopyViewOptions(Post_View *src, Post_View *dest){
} }
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
/* S c a l a r S i m p l e x */ /* S t a t _ X X X S i m p l e x */
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
void AddView_ScalarSimplex(int dim, double *coord, int N, double *v){ void Stat_ScalarSimplex(int dim, double *coord, int N, double *V){
Post_Simplex S;
int i,nbnod; int i,nbnod;
double *X, *Y, *Z;
S.Type = DRAW_POST_SCALAR;
S.Dimension = dim;
switch(dim){ switch(dim){
case 0 : nbnod = 1 ; break; // point case 0 : nbnod = 1 ; NbPoints++; break;
case 1 : nbnod = 2 ; break; // line case 1 : nbnod = 2 ; NbLines++; break;
case 2 : nbnod = 3 ; break; // triangle case 2 : nbnod = 3 ; NbTriangles++; break;
case 3 : nbnod = 4 ; break; // tetrahedron case 3 : nbnod = 4 ; NbTetrahedra++; break;
} }
S.X = &coord[0] ; S.Y = &coord[nbnod] ; S.Z = &coord[2*nbnod] ; S.V = v ; X = &coord[0] ; Y = &coord[nbnod] ; Z = &coord[2*nbnod] ;
if(!List_Nbr(ActualView->Points) && !List_Nbr(ActualView->Lines) && if(NbPoints == 1 && NbLines == 1 && NbTriangles == 1 && NbTetrahedra == 1){
!List_Nbr(ActualView->Triangles) && !List_Nbr(ActualView->Tetrahedra)){ ActualView->Min = V[0];
ActualView->Min = S.V[0]; ActualView->Max = V[0];
ActualView->Max = S.V[0];
ActualView->NbTimeStep = N/nbnod; ActualView->NbTimeStep = N/nbnod;
} }
else if(N/nbnod < ActualView->NbTimeStep) else if(N/nbnod < ActualView->NbTimeStep)
ActualView->NbTimeStep = N/nbnod ; ActualView->NbTimeStep = N/nbnod ;
for(i=0 ; i<N ; i++){ for(i=0 ; i<N ; i++){
if(S.V[i] < ActualView->Min) ActualView->Min = S.V[i] ; if(V[i] < ActualView->Min) ActualView->Min = V[i] ;
if(S.V[i] > ActualView->Max) ActualView->Max = S.V[i] ; if(V[i] > ActualView->Max) ActualView->Max = V[i] ;
} }
switch(dim){
case 0 : List_Add(ActualView->Points,&S); break;
case 1 : List_Add(ActualView->Lines,&S); break;
case 2 : List_Add(ActualView->Triangles,&S); break;
case 3 : List_Add(ActualView->Tetrahedra,&S); break;
}
} }
void AddView_VectorSimplex(int dim, double *coord, int N, double *v){ void Stat_VectorSimplex(int dim, double *coord, int N, double *V){
Post_Simplex S;
double l0; double l0;
int nbnod, i; int nbnod, i;
double *X, *Y, *Z;
S.Type = DRAW_POST_VECTOR;
S.Dimension = dim;
switch(dim){ switch(dim){
case 0 : nbnod = 1 ; break; // point case 0 : nbnod = 1 ; NbPoints++; break;
case 1 : nbnod = 2 ; break; // line case 1 : nbnod = 2 ; NbLines++; break;
case 2 : nbnod = 3 ; break; // triangle case 2 : nbnod = 3 ; NbTriangles++; break;
case 3 : nbnod = 4 ; break; // tetrahedron case 3 : nbnod = 4 ; NbTetrahedra++; break;
} }
S.X = &coord[0] ; S.Y = &coord[nbnod] ; S.Z = &coord[2*nbnod] ; S.V = v ; X = &coord[0] ; Y = &coord[nbnod] ; Z = &coord[2*nbnod] ;
if(!List_Nbr(ActualView->Points) && !List_Nbr(ActualView->Lines) && if(NbPoints == 1 && NbLines == 1 && NbTriangles == 1 && NbTetrahedra == 1){
!List_Nbr(ActualView->Triangles) && !List_Nbr(ActualView->Tetrahedra)){ l0 = sqrt(DSQR(V[0])+DSQR(V[1])+DSQR(V[2]));
l0 = sqrt(DSQR(S.V[0])+DSQR(S.V[1])+DSQR(S.V[2]));
ActualView->Min = l0; ActualView->Min = l0;
ActualView->Max = l0; ActualView->Max = l0;
ActualView->NbTimeStep = N/(3*nbnod) ; ActualView->NbTimeStep = N/(3*nbnod) ;
...@@ -371,22 +341,15 @@ void AddView_VectorSimplex(int dim, double *coord, int N, double *v){ ...@@ -371,22 +341,15 @@ void AddView_VectorSimplex(int dim, double *coord, int N, double *v){
ActualView->NbTimeStep = N/(3*nbnod) ; ActualView->NbTimeStep = N/(3*nbnod) ;
for(i=0 ; i<N ; i+=3){ for(i=0 ; i<N ; i+=3){
l0 = sqrt(DSQR(S.V[i])+DSQR(S.V[i+1])+DSQR(S.V[i+2])); l0 = sqrt(DSQR(V[i])+DSQR(V[i+1])+DSQR(V[i+2]));
if(l0 < ActualView->Min) ActualView->Min = l0 ; if(l0 < ActualView->Min) ActualView->Min = l0 ;
if(l0 > ActualView->Max) ActualView->Max = l0 ; if(l0 > ActualView->Max) ActualView->Max = l0 ;
} }
ActualView->ScalarOnly = 0; ActualView->ScalarOnly = 0;
switch(dim){
case 0 : List_Add(ActualView->Points,&S); break;
case 1 : List_Add(ActualView->Lines,&S); break;
case 2 : List_Add(ActualView->Triangles,&S); break;
case 3 : List_Add(ActualView->Tetrahedra,&S); break;
}
} }
void AddView_TensorSimplex(int dim, double *coord, int N, double *v){ void Stat_TensorSimplex(int dim, double *coord, int N, double *v){
Msg(ERROR, "Tensor Field Views not Implemented Yet"); Msg(ERROR, "Tensor Field Views not Implemented Yet");
} }
...@@ -446,10 +409,6 @@ void Read_View(FILE *file, char *filename){ ...@@ -446,10 +409,6 @@ void Read_View(FILE *file, char *filename){
ActualView->Time = List_CreateFromFile(nbtimestep, sizeof(double), file, format); ActualView->Time = List_CreateFromFile(nbtimestep, sizeof(double), file, format);
if((nb = ActualView->NbSP + ActualView->NbVP + ActualView->NbTP))
ActualView->Points = List_Create(nb,1,sizeof(Post_Simplex));
else
ActualView->Points = NULL ;
nb = ActualView->NbSP ? nb = ActualView->NbSP ?
ActualView->NbSP * nbtimestep + ActualView->NbSP * 3 : 0 ; ActualView->NbSP * nbtimestep + ActualView->NbSP * 3 : 0 ;
ActualView->SP = List_CreateFromFile(nb, sizeof(double), file, format); ActualView->SP = List_CreateFromFile(nb, sizeof(double), file, format);
...@@ -460,10 +419,6 @@ void Read_View(FILE *file, char *filename){ ...@@ -460,10 +419,6 @@ void Read_View(FILE *file, char *filename){
ActualView->NbTP * nbtimestep * 9 + ActualView->NbTP * 3 : 0 ; ActualView->NbTP * nbtimestep * 9 + ActualView->NbTP * 3 : 0 ;
ActualView->TP = List_CreateFromFile(nb, sizeof(double), file, format); ActualView->TP = List_CreateFromFile(nb, sizeof(double), file, format);
if((nb = ActualView->NbSL + ActualView->NbVL + ActualView->NbTL))
ActualView->Lines = List_Create(nb,1,sizeof(Post_Simplex));
else
ActualView->Lines = NULL ;
nb = ActualView->NbSL ? nb = ActualView->NbSL ?
ActualView->NbSL * nbtimestep * 2 + ActualView->NbSL * 6 : 0 ; ActualView->NbSL * nbtimestep * 2 + ActualView->NbSL * 6 : 0 ;
ActualView->SL = List_CreateFromFile(nb, sizeof(double), file, format); ActualView->SL = List_CreateFromFile(nb, sizeof(double), file, format);
...@@ -474,10 +429,6 @@ void Read_View(FILE *file, char *filename){ ...@@ -474,10 +429,6 @@ void Read_View(FILE *file, char *filename){
ActualView->NbTL * nbtimestep * 2 * 9 + ActualView->NbTL * 6 : 0 ; ActualView->NbTL * nbtimestep * 2 * 9 + ActualView->NbTL * 6 : 0 ;
ActualView->TL = List_CreateFromFile(nb, sizeof(double), file, format); ActualView->TL = List_CreateFromFile(nb, sizeof(double), file, format);
if((nb = ActualView->NbST + ActualView->NbVT + ActualView->NbTT))
ActualView->Triangles = List_Create(nb,1,sizeof(Post_Simplex));
else
ActualView->Triangles = NULL ;
nb = ActualView->NbST ? nb = ActualView->NbST ?
ActualView->NbST * nbtimestep * 3 + ActualView->NbST * 9 : 0 ; ActualView->NbST * nbtimestep * 3 + ActualView->NbST * 9 : 0 ;
ActualView->ST = List_CreateFromFile(nb, sizeof(double), file, format); ActualView->ST = List_CreateFromFile(nb, sizeof(double), file, format);
...@@ -488,10 +439,6 @@ void Read_View(FILE *file, char *filename){ ...@@ -488,10 +439,6 @@ void Read_View(FILE *file, char *filename){
ActualView->NbTT * nbtimestep * 3 * 9 + ActualView->NbTT * 9 : 0 ; ActualView->NbTT * nbtimestep * 3 * 9 + ActualView->NbTT * 9 : 0 ;
ActualView->TT = List_CreateFromFile(nb, sizeof(double), file, format); ActualView->TT = List_CreateFromFile(nb, sizeof(double), file, format);
if((nb = ActualView->NbSS + ActualView->NbVS + ActualView->NbTS))
ActualView->Tetrahedra = List_Create(nb,1,sizeof(Post_Simplex));
else
ActualView->Tetrahedra = NULL ;
nb = ActualView->NbSS ? nb = ActualView->NbSS ?
ActualView->NbSS * nbtimestep * 4 + ActualView->NbSS * 12 : 0 ; ActualView->NbSS * nbtimestep * 4 + ActualView->NbSS * 12 : 0 ;
ActualView->SS = List_CreateFromFile(nb, sizeof(double), file, format); ActualView->SS = List_CreateFromFile(nb, sizeof(double), file, format);
......
/* $Id: Views.h,v 1.6 2000-11-26 15:43:45 geuzaine Exp $ */ /* $Id: Views.h,v 1.7 2000-11-27 10:58:18 geuzaine Exp $ */
#ifndef _VIEWS_H_ #ifndef _VIEWS_H_
#define _VIEWS_H_ #define _VIEWS_H_
#include "Const.h" #include "Const.h"
typedef struct{
int Dimension, Type;
double *X, *Y, *Z, *V;
}Post_Simplex;
#include "ColorTable.h" #include "ColorTable.h"
typedef struct{ typedef struct{
...@@ -18,14 +12,14 @@ typedef struct{ ...@@ -18,14 +12,14 @@ typedef struct{
/* the data */ /* the data */
List_T *Time; List_T *Time;
int NbSP, NbVP, NbTP; int NbPoints, NbSP, NbVP, NbTP;
List_T *SP, *VP, *TP, *Points; // points List_T *SP, *VP, *TP; // points
int NbSL, NbVL, NbTL; int NbLines, NbSL, NbVL, NbTL;
List_T *SL, *VL, *TL, *Lines; // lines List_T *SL, *VL, *TL; // lines
int NbST, NbVT, NbTT; int NbTriangles, NbST, NbVT, NbTT;
List_T *ST, *VT, *TT, *Triangles; // triangles List_T *ST, *VT, *TT; // triangles
int NbSS, NbVS, NbTS; int NbTetrahedra, NbSS, NbVS, NbTS;
List_T *SS, *VS, *TS, *Tetrahedra; // tetrahedra List_T *SS, *VS, *TS; // tetrahedra
int NbTimeStep, ScalarOnly; int NbTimeStep, ScalarOnly;
double Min, Max; double Min, Max;
...@@ -45,11 +39,6 @@ typedef struct{ ...@@ -45,11 +39,6 @@ typedef struct{
int (*GIFV) (double min, double max, int nb, double value); int (*GIFV) (double min, double max, int nb, double value);
}Post_View; }Post_View;
/* Type (The keys are important!) */
#define DRAW_POST_SCALAR 1
#define DRAW_POST_VECTOR 3
#define DRAW_POST_TENSOR 9
/* IntervalsType */ /* IntervalsType */
#define DRAW_POST_ISO 1 #define DRAW_POST_ISO 1
#define DRAW_POST_CONTINUOUS 2 #define DRAW_POST_CONTINUOUS 2
...@@ -89,9 +78,9 @@ void FreeView(Post_View *v); ...@@ -89,9 +78,9 @@ void FreeView(Post_View *v);
void Read_View(FILE *file, char *filename); void Read_View(FILE *file, char *filename);
void CopyViewOptions(Post_View *src, Post_View *dest); void CopyViewOptions(Post_View *src, Post_View *dest);
void AddView_ScalarSimplex(int dim, double *coord, int N, double *v); void Stat_ScalarSimplex(int dim, double *coord, int N, double *v);
void AddView_VectorSimplex(int dim, double *coord, int N, double *v); void Stat_VectorSimplex(int dim, double *coord, int N, double *v);
void AddView_TensorSimplex(int dim, double *coord, int N, double *v); void Stat_TensorSimplex(int dim, double *coord, int N, double *v);
int BGMWithView (Post_View *ErrView); int BGMWithView (Post_View *ErrView);
int CreateBGM(Post_View *ErrView, int OptiMethod, double Degree, int CreateBGM(Post_View *ErrView, int OptiMethod, double Degree,
......
/* $Id: Draw.h,v 1.6 2000-11-26 15:43:46 geuzaine Exp $ */ /* $Id: Draw.h,v 1.7 2000-11-27 10:58:54 geuzaine Exp $ */
#ifndef _DRAW_H_ #ifndef _DRAW_H_
#define _DRAW_H_ #define _DRAW_H_
...@@ -73,13 +73,41 @@ void Draw_Simplex_Volume (void *a, void *b); ...@@ -73,13 +73,41 @@ void Draw_Simplex_Volume (void *a, void *b);
void Draw_Hexahedron_Volume (void *a, void *b); void Draw_Hexahedron_Volume (void *a, void *b);
void Draw_Prism_Volume (void *a, void *b); void Draw_Prism_Volume (void *a, void *b);
void Draw_Post_Tetrahedron (Post_View * View, Post_Simplex * s, void Draw_ScalarPoint(Post_View *View,
double ValMin, double ValMax, double Raise[3][5]); double ValMin, double ValMax, double Raise[3][5],
void Draw_Post_Triangle (Post_View * View, Post_Simplex * t, double *X, double *Y, double *Z, double *V);
double ValMin, double ValMax, double Raise[3][5]); void Draw_VectorPoint(Post_View *View,
void Draw_Post_Line (Post_View * View, Post_Simplex * l, double ValMin, double ValMax, double Raise[3][5],
double ValMin, double ValMax, double Raise[3][5]); double *X, double *Y, double *Z, double *V);
void Draw_Post_Point (Post_View * View, Post_Simplex * p, void Draw_TensorPoint(Post_View *View,
double ValMin, double ValMax, double Raise[3][5]); double ValMin, double ValMax, double Raise[3][5],
double *X, double *Y, double *Z, double *V);
void Draw_ScalarLine(Post_View *View,
double ValMin, double ValMax, double Raise[3][5],
double *X, double *Y, double *Z, double *V);
void Draw_VectorLine(Post_View *View,
double ValMin, double ValMax, double Raise[3][5],
double *X, double *Y, double *Z, double *V);
void Draw_TensorLine(Post_View *View,
double ValMin, double ValMax, double Raise[3][5],
double *X, double *Y, double *Z, double *V);
void Draw_ScalarTriangle(Post_View *View,
double ValMin, double ValMax, double Raise[3][5],
double *X, double *Y, double *Z, double *V);
void Draw_VectorTriangle(Post_View *View,
double ValMin, double ValMax, double Raise[3][5],
double *X, double *Y, double *Z, double *V);
void Draw_TensorTriangle(Post_View *View,
double ValMin, double ValMax, double Raise[3][5],
double *X, double *Y, double *Z, double *V);
void Draw_ScalarTetrahedron(Post_View *View,
double ValMin, double ValMax, double Raise[3][5],
double *X, double *Y, double *Z, double *V);
void Draw_VectorTetrahedron(Post_View *View,
double ValMin, double ValMax, double Raise[3][5],
double *X, double *Y, double *Z, double *V);
void Draw_TensorTetrahedron(Post_View *View,
double ValMin, double ValMax, double Raise[3][5],
double *X, double *Y, double *Z, double *V);
#endif #endif
/* $Id: Post.cpp,v 1.5 2000-11-26 15:43:46 geuzaine Exp $ */ /* $Id: Post.cpp,v 1.6 2000-11-27 10:58:54 geuzaine Exp $ */
#include "Gmsh.h" #include "Gmsh.h"
#include "GmshUI.h" #include "GmshUI.h"
...@@ -79,15 +79,15 @@ void RaiseFill(int i, double Val, double ValMin, double Raise[3][5]){ ...@@ -79,15 +79,15 @@ void RaiseFill(int i, double Val, double ValMin, double Raise[3][5]){
------------------------------------------------------------------------ */ ------------------------------------------------------------------------ */
void Draw_Post (void) { void Draw_Post (void) {
int i,j,k,n; int iView,i,j,k,nb;
double ValMin,ValMax,AbsMax; double ValMin,ValMax,AbsMax;
Post_View *v; Post_View *v;
if(!Post_ViewList) return; if(!Post_ViewList) return;
for(i=0 ; i<List_Nbr(Post_ViewList) ; i++){ for(iView=0 ; iView<List_Nbr(Post_ViewList) ; iView++){
v = (Post_View*)List_Pointer(Post_ViewList,i); v = (Post_View*)List_Pointer(Post_ViewList,iView);
if(v->Visible){ if(v->Visible){
...@@ -100,7 +100,7 @@ void Draw_Post (void) { ...@@ -100,7 +100,7 @@ void Draw_Post (void) {
if(CTX.display_lists){ if(CTX.display_lists){
if(glIsList(v->Num)) glDeleteLists(v->Num,1); if(glIsList(v->Num)) glDeleteLists(v->Num,1);
//Msg(INFO, "New Display List"); // Msg(INFO, "New Display List");
glNewList(v->Num, GL_COMPILE_AND_EXECUTE); glNewList(v->Num, GL_COMPILE_AND_EXECUTE);
} }
...@@ -111,7 +111,7 @@ void Draw_Post (void) { ...@@ -111,7 +111,7 @@ void Draw_Post (void) {
InitNoShading(); InitNoShading();
} }
/* force this */ // force this
if(v->IntervalsType == DRAW_POST_CONTINUOUS) if(v->IntervalsType == DRAW_POST_CONTINUOUS)
glShadeModel(GL_SMOOTH); glShadeModel(GL_SMOOTH);
...@@ -138,29 +138,128 @@ void Draw_Post (void) { ...@@ -138,29 +138,128 @@ void Draw_Post (void) {
RaiseFactor[j] = v->Raise[j] / AbsMax ; RaiseFactor[j] = v->Raise[j] / AbsMax ;
for(k=0;k<5;k++) Raise[j][k] = 0. ; for(k=0;k<5;k++) Raise[j][k] = 0. ;
} }
if((n = List_Nbr(v->Tetrahedra)))
for(j=0 ; j<n ; j++)
Draw_Post_Tetrahedron(v, (Post_Simplex*)List_Pointer(v->Tetrahedra,j),
ValMin, ValMax, Raise);
//if(there is alpha)List_Sort(v->Triangles, fcmpTriangle);
if((n = List_Nbr(v->Triangles))) // Points
for(j=0 ; j<n ; j++)
Draw_Post_Triangle(v, (Post_Simplex*)List_Pointer(v->Triangles,j), if(v->NbSP){
ValMin, ValMax, Raise); nb = List_Nbr(v->SP) / v->NbSP ;
for(i = 0 ; i < List_Nbr(v->SP) ; i+=nb)
Draw_ScalarPoint(v, ValMin, ValMax, Raise,
(double*)List_Pointer_Fast(v->SP,i),
(double*)List_Pointer_Fast(v->SP,i+1),
(double*)List_Pointer_Fast(v->SP,i+2),
(double*)List_Pointer_Fast(v->SP,i+3));
}
if(v->NbVP){
nb = List_Nbr(v->VP) / v->NbVP ;
for(i = 0 ; i < List_Nbr(v->VP) ; i+=nb)
Draw_VectorPoint(v, ValMin, ValMax, Raise,
(double*)List_Pointer_Fast(v->VP,i),
(double*)List_Pointer_Fast(v->VP,i+1),
(double*)List_Pointer_Fast(v->VP,i+2),
(double*)List_Pointer_Fast(v->VP,i+3));
}
if(v->NbTP){
nb = List_Nbr(v->TP) / v->NbTP ;
for(i = 0 ; i < List_Nbr(v->TP) ; i+=nb)
Draw_TensorPoint(v, ValMin, ValMax, Raise,
(double*)List_Pointer_Fast(v->TP,i),
(double*)List_Pointer_Fast(v->TP,i+1),
(double*)List_Pointer_Fast(v->TP,i+2),
(double*)List_Pointer_Fast(v->TP,i+3));
}
// Lines
if(v->NbSL){
nb = List_Nbr(v->SL) / v->NbSL ;
for(i = 0 ; i < List_Nbr(v->SL) ; i+=nb)
Draw_ScalarLine(v, ValMin, ValMax, Raise,
(double*)List_Pointer_Fast(v->SL,i),
(double*)List_Pointer_Fast(v->SL,i+2),
(double*)List_Pointer_Fast(v->SL,i+4),
(double*)List_Pointer_Fast(v->SL,i+6));
}
if(v->NbVL){
nb = List_Nbr(v->VL) / v->NbVL ;
for(i = 0 ; i < List_Nbr(v->VL) ; i+=nb)
Draw_VectorLine(v, ValMin, ValMax, Raise,
(double*)List_Pointer_Fast(v->VL,i),
(double*)List_Pointer_Fast(v->VL,i+2),
(double*)List_Pointer_Fast(v->VL,i+4),
(double*)List_Pointer_Fast(v->VL,i+6));
}
if(v->NbTL){
nb = List_Nbr(v->TL) / v->NbTL ;
for(i = 0 ; i < List_Nbr(v->TL) ; i+=nb)
Draw_VectorLine(v, ValMin, ValMax, Raise,
(double*)List_Pointer_Fast(v->TL,i),
(double*)List_Pointer_Fast(v->TL,i+2),
(double*)List_Pointer_Fast(v->TL,i+4),
(double*)List_Pointer_Fast(v->TL,i+6));
}
// Triangles
if(v->NbST){
nb = List_Nbr(v->ST) / v->NbST ;
for(i = 0 ; i < List_Nbr(v->ST) ; i+=nb)
Draw_ScalarTriangle(v, ValMin, ValMax, Raise,
(double*)List_Pointer_Fast(v->ST,i),
(double*)List_Pointer_Fast(v->ST,i+3),
(double*)List_Pointer_Fast(v->ST,i+6),
(double*)List_Pointer_Fast(v->ST,i+9));
}
if(v->NbVT){
nb = List_Nbr(v->VT) / v->NbVT ;
for(i = 0 ; i < List_Nbr(v->VT) ; i+=nb)
Draw_VectorTriangle(v, ValMin, ValMax, Raise,
(double*)List_Pointer_Fast(v->VT,i),
(double*)List_Pointer_Fast(v->VT,i+3),
(double*)List_Pointer_Fast(v->VT,i+6),
(double*)List_Pointer_Fast(v->VT,i+9));
}
if(v->NbTT){
nb = List_Nbr(v->TT) / v->NbTT ;
for(i = 0 ; i < List_Nbr(v->TT) ; i+=nb)
Draw_TensorTriangle(v, ValMin, ValMax, Raise,
(double*)List_Pointer_Fast(v->TT,i),
(double*)List_Pointer_Fast(v->TT,i+3),
(double*)List_Pointer_Fast(v->TT,i+6),
(double*)List_Pointer_Fast(v->TT,i+9));
}
// Tetrahedra
if(v->NbSS){
nb = List_Nbr(v->SS) / v->NbSS ;
for(i = 0 ; i < List_Nbr(v->SS) ; i+=nb)
Draw_ScalarTetrahedron(v, ValMin, ValMax, Raise,
(double*)List_Pointer_Fast(v->SS,i),
(double*)List_Pointer_Fast(v->SS,i+4),
(double*)List_Pointer_Fast(v->SS,i+8),
(double*)List_Pointer_Fast(v->SS,i+12));
}
if(v->NbVS){
nb = List_Nbr(v->VS) / v->NbVS ;
for(i = 0 ; i < List_Nbr(v->VS) ; i+=nb)
Draw_VectorTetrahedron(v, ValMin, ValMax, Raise,
(double*)List_Pointer_Fast(v->VS,i),
(double*)List_Pointer_Fast(v->VS,i+4),
(double*)List_Pointer_Fast(v->VS,i+8),
(double*)List_Pointer_Fast(v->VS,i+12));
}
if(v->NbTS){
nb = List_Nbr(v->TS) / v->NbTS ;
for(i = 0 ; i < List_Nbr(v->TS) ; i+=nb)
Draw_TensorTetrahedron(v, ValMin, ValMax, Raise,
(double*)List_Pointer_Fast(v->TS,i),
(double*)List_Pointer_Fast(v->TS,i+4),
(double*)List_Pointer_Fast(v->TS,i+8),
(double*)List_Pointer_Fast(v->TS,i+12));
}
if((n = List_Nbr(v->Lines)))
for(j=0 ; j<n ; j++)
Draw_Post_Line(v, (Post_Simplex*)List_Pointer(v->Lines,j),
ValMin, ValMax, Raise);
if((n = List_Nbr(v->Points)))
for(j=0 ; j<n ; j++)
Draw_Post_Point(v, (Post_Simplex*)List_Pointer(v->Points,j),
ValMin, ValMax, Raise);
if(CTX.display_lists){ if(CTX.display_lists){
glEndList(); glEndList();
v->Changed=0; v->Changed=0;
......
This diff is collapsed.
/* $Id: 3D_BGMesh.cpp,v 1.9 2000-11-26 15:43:46 geuzaine Exp $ */ /* $Id: 3D_BGMesh.cpp,v 1.10 2000-11-27 10:58:56 geuzaine Exp $ */
#include "Gmsh.h" #include "Gmsh.h"
#include "Mesh.h" #include "Mesh.h"
...@@ -123,10 +123,9 @@ static void AIG (void *a, void *b){ ...@@ -123,10 +123,9 @@ static void AIG (void *a, void *b){
} }
int BGMWithView (Post_View * ErrView){ int BGMWithView (Post_View * ErrView){
static Vertex *VertexUp, *v, V, *ver[4]; static Vertex *VertexUp, *v, V, *ver[4];
int i, j, k; int i, j, k, nb;
Post_Simplex s, t; double *X, *Y, *Z, *Val;
Simplex *si; Simplex *si;
VertexUp = Create_Vertex (-1, 0., 0., 1., 1., -1.0); VertexUp = Create_Vertex (-1, 0., 0., 1., 1., -1.0);
...@@ -138,50 +137,64 @@ int BGMWithView (Post_View * ErrView){ ...@@ -138,50 +137,64 @@ int BGMWithView (Post_View * ErrView){
m.Simplexes = Tree_Create (sizeof (Simplex *), compareSimplex); m.Simplexes = Tree_Create (sizeof (Simplex *), compareSimplex);
Create_BgMesh (ONFILE, .2, THEM); Create_BgMesh (ONFILE, .2, THEM);
k = 1; k = 1;
for (i = 0; i < List_Nbr (ErrView->Triangles); i++){ if(ErrView->NbST){
List_Read (ErrView->Triangles, i, &t); nb = List_Nbr(ErrView->ST) / ErrView->NbST ;
for (j = 0; j < 3; j++){ for(i = 0 ; i < List_Nbr(ErrView->ST) ; i+=nb){
v = &V; X = (double*)List_Pointer_Fast(ErrView->ST,i);
v->Pos.X = t.X[j]; Y = (double*)List_Pointer_Fast(ErrView->ST,i+3);
v->Pos.Y = t.Y[j]; Z = (double*)List_Pointer_Fast(ErrView->ST,i+6);
v->Pos.Z = t.Z[j]; Val = (double*)List_Pointer_Fast(ErrView->ST,i+9);
if (0 /*Tree_Query(Pts,&v) */ ){
/* Corriger la Lc pour lissage */ for (j = 0; j < 3; j++){
//ver[j] = v; v = &V;
} v->Pos.X = X[j];
else{ v->Pos.Y = Y[j];
v = Create_Vertex (k++, t.X[j], t.Y[j], t.Z[j], t.V[j], -1.0); v->Pos.Z = Z[j];
ver[j] = v; if (Tree_Query (Pts, &v)){
Tree_Add (m.Vertices, &v); ver[j] = v;
Tree_Add (Pts, &v); }
else{
v = Create_Vertex (k++, X[j], Y[j], Z[j], Val[j], -1.0);
ver[j] = v;
Tree_Add (m.Vertices, &v);
Tree_Add (Pts, &v);
}
} }
si = Create_Simplex (ver[0], ver[1], ver[2], VertexUp);
Tree_Add (m.Simplexes, &si);
} }
si = Create_Simplex (ver[0], ver[1], ver[2], VertexUp);
Tree_Add (m.Simplexes, &si);
} }
for (i = 0; i < List_Nbr (ErrView->Tetrahedra); i++){ if(ErrView->NbSS){
List_Read (ErrView->Tetrahedra, i, &s); nb = List_Nbr(ErrView->SS) / ErrView->NbSS ;
for (j = 0; j < 4; j++){ for(i = 0 ; i < List_Nbr(ErrView->SS) ; i+=nb){
v = &V; X = (double*)List_Pointer_Fast(ErrView->SS,i);
v->Pos.X = s.X[j]; Y = (double*)List_Pointer_Fast(ErrView->SS,i+4);
v->Pos.Y = s.Y[j]; Z = (double*)List_Pointer_Fast(ErrView->SS,i+8);
v->Pos.Z = s.Z[j]; Val = (double*)List_Pointer_Fast(ErrView->SS,i+12);
if (Tree_Query (Pts, &v)){
ver[j] = v; for (j = 0; j < 4; j++){
} v = &V;
else{ v->Pos.X = X[j];
v = Create_Vertex (k++, s.X[k], s.Y[j], s.Z[j], s.V[0], -1.0); v->Pos.Y = Y[j];
ver[j] = v; v->Pos.Z = Z[j];
Tree_Add (m.Vertices, &v); if (Tree_Query (Pts, &v)){
Tree_Add (Pts, &v); ver[j] = v;
}
else{
v = Create_Vertex (k++, X[j], Y[j], Z[j], Val[j], -1.0);
ver[j] = v;
Tree_Add (m.Vertices, &v);
Tree_Add (Pts, &v);
}
} }
si = Create_Simplex (ver[0], ver[1], ver[2], ver[3]);
Tree_Add (m.Simplexes, &si);
} }
si = Create_Simplex (ver[0], ver[1], ver[2], ver[3]);
Tree_Add (m.Simplexes, &si);
} }
m.Grid.init = 0; m.Grid.init = 0;
m.Grid.Nx = 10; m.Grid.Nx = 10;
m.Grid.Ny = 10; m.Grid.Ny = 10;
...@@ -208,31 +221,42 @@ int BGMWithView (Post_View * ErrView){ ...@@ -208,31 +221,42 @@ int BGMWithView (Post_View * ErrView){
double ErrorInView (Post_View * ErrView, int *n){ double ErrorInView (Post_View * ErrView, int *n){
double e, tot=0.0, *X, *Y, *Z, *Val;
Post_Simplex s, t; int i, j=0, nb;
double e, tot=0.0;
int i, j=0;
if(ErrView == NULL){ if(ErrView == NULL){
Msg(WARNING, "Empty Error View"); Msg(WARNING, "Empty Error View");
return 0.; return 0.;
} }
for (i = 0; i < List_Nbr (ErrView->Triangles); i++){ if(ErrView->NbST){
List_Read (ErrView->Triangles, i, &t); nb = List_Nbr(ErrView->ST) / ErrView->NbST ;
e = (t.V[0] + t.V[1] + t.V[2]) / 3. ; for(i = 0 ; i < List_Nbr(ErrView->ST) ; i+=nb){
tot += e * e; X = (double*)List_Pointer_Fast(ErrView->ST,i);
j++; Y = (double*)List_Pointer_Fast(ErrView->ST,i+3);
Z = (double*)List_Pointer_Fast(ErrView->ST,i+6);
Val = (double*)List_Pointer_Fast(ErrView->ST,i+9);
e = (Val[0] + Val[1] + Val[2]) / 3. ;
tot += e * e;
j++;
}
} }
for (i = 0; i < List_Nbr (ErrView->Tetrahedra); i++){ if(ErrView->NbSS){
List_Read (ErrView->Tetrahedra, i, &s); nb = List_Nbr(ErrView->SS) / ErrView->NbSS ;
e = (t.V[0] + t.V[1] + t.V[2] + t.V[3]) * 0.25; for(i = 0 ; i < List_Nbr(ErrView->SS) ; i+=nb){
tot += e * e; X = (double*)List_Pointer_Fast(ErrView->SS,i);
j++; Y = (double*)List_Pointer_Fast(ErrView->SS,i+3);
Z = (double*)List_Pointer_Fast(ErrView->SS,i+8);
Val = (double*)List_Pointer_Fast(ErrView->SS,i+12);
e = (Val[0] + Val[1] + Val[2] + Val[3]) * 0.25 ;
tot += e * e;
j++;
}
} }
*n = j; *n = j;
return 100 * sqrt (tot); return 100 * sqrt (tot);
} }
...@@ -243,20 +267,17 @@ double ErrorInView (Post_View * ErrView, int *n){ ...@@ -243,20 +267,17 @@ double ErrorInView (Post_View * ErrView, int *n){
int CreateBGM (Post_View * ErrView, int OptiMethod, double Degree, int CreateBGM (Post_View * ErrView, int OptiMethod, double Degree,
double OptiValue, double *ObjFunct, char *OutFile){ double OptiValue, double *ObjFunct, char *OutFile){
double *h, *p, *e, xc, yc, zc, c[3], *X, *Y, *Z, *Val;
Post_Simplex s, t; int N, i, j, dim, nb;
double *h, *p, *e, xc, yc, zc, c[3];
int N, i, j, dim;
Simplex smp; Simplex smp;
FILE *f; FILE *f;
if (List_Nbr (ErrView->Tetrahedra)) if (ErrView->NbSS)
dim = 3; dim = 3;
else else
dim = 2; dim = 2;
N = List_Nbr (ErrView->Tetrahedra) + N = ErrView->NbSS + ErrView->NbST + 2;
List_Nbr (ErrView->Triangles) + 2;
h = (double *) malloc (N * sizeof (double)); h = (double *) malloc (N * sizeof (double));
e = (double *) malloc (N * sizeof (double)); e = (double *) malloc (N * sizeof (double));
...@@ -264,40 +285,50 @@ int CreateBGM (Post_View * ErrView, int OptiMethod, double Degree, ...@@ -264,40 +285,50 @@ int CreateBGM (Post_View * ErrView, int OptiMethod, double Degree,
j = 0; j = 0;
for (i = 0; i < List_Nbr (ErrView->Triangles); i++){ if(ErrView->NbST){
List_Read (ErrView->Triangles, i, &t); nb = List_Nbr(ErrView->ST) / ErrView->NbST ;
for(i = 0 ; i < List_Nbr(ErrView->ST) ; i+=nb){
/* X = (double*)List_Pointer_Fast(ErrView->ST,i);
Attention, cette ligne est seulement valable en Y = (double*)List_Pointer_Fast(ErrView->ST,i+3);
2d x-y. Si plus, calculer le centre du cercle en Z = (double*)List_Pointer_Fast(ErrView->ST,i+6);
3d ou utiliser une autre mesure de taille. Val = (double*)List_Pointer_Fast(ErrView->ST,i+9);
*/ /*
CircumCircle (t.X[0], t.Y[0], Attention, cette ligne est seulement valable en
t.X[1], t.Y[1], 2d x-y. Si plus, calculer le centre du cercle en
t.X[2], t.Y[2], 3d ou utiliser une autre mesure de taille.
&xc, &yc); */
h[j + 1] = sqrt ((xc - t.X[0]) * (xc - t.X[0]) + CircumCircle (X[0], Y[0],
(yc - t.Y[0]) * (yc - t.Y[0])); X[1], Y[1],
p[j + 1] = Degree; X[2], Y[2],
e[j + 1] = (t.V[0] + t.V[1] + t.V[2]) / 3. ; &xc, &yc);
j++; h[j + 1] = sqrt ((xc - X[0]) * (xc - X[0]) +
(yc - Y[0]) * (yc - Y[0]));
p[j + 1] = Degree;
e[j + 1] = (Val[0] + Val[1] + Val[2]) / 3. ;
j++;
}
} }
for (i = 0; i < List_Nbr (ErrView->Tetrahedra); i++){ if(ErrView->NbSS){
List_Read (ErrView->Tetrahedra, i, &s); nb = List_Nbr(ErrView->SS) / ErrView->NbSS ;
for(i = 0 ; i < List_Nbr(ErrView->SS) ; i+=nb){
smp.center_tet (t.X, t.Y, t.Z, c); X = (double*)List_Pointer_Fast(ErrView->SS,i);
Y = (double*)List_Pointer_Fast(ErrView->SS,i+3);
Z = (double*)List_Pointer_Fast(ErrView->SS,i+8);
Val = (double*)List_Pointer_Fast(ErrView->SS,i+12);
xc = c[0]; smp.center_tet (X, Y, Z, c);
yc = c[1]; xc = c[0];
zc = c[2]; yc = c[1];
zc = c[2];
h[j + 1] = sqrt ((xc - t.X[0]) * (xc - t.X[0]) + h[j + 1] = sqrt ((xc - X[0]) * (xc - X[0]) +
(yc - t.X[0]) * (yc - t.X[0]) + (yc - X[0]) * (yc - X[0]) +
(zc - t.Y[0]) * (zc - t.Y[0])); (zc - Y[0]) * (zc - Y[0]));
p[j + 1] = Degree; p[j + 1] = Degree;
e[j + 1] = (t.V[0] + t.V[1] + t.V[2] + t.V[3]) * 0.25; e[j + 1] = (Val[0] + Val[1] + Val[2] + Val[3]) * 0.25;
j++; j++;
}
} }
*ObjFunct = AdaptMesh (j, OptiMethod, dim, e, h, p, OptiValue); *ObjFunct = AdaptMesh (j, OptiMethod, dim, e, h, p, OptiValue);
...@@ -305,25 +336,40 @@ int CreateBGM (Post_View * ErrView, int OptiMethod, double Degree, ...@@ -305,25 +336,40 @@ int CreateBGM (Post_View * ErrView, int OptiMethod, double Degree,
f = fopen (OutFile, "w"); f = fopen (OutFile, "w");
fprintf (f, "View \"Auto_BGMesh\" Offset{0,0,0} {\n"); fprintf (f, "View \"Auto_BGMesh\" Offset{0,0,0} {\n");
j = 0; j = 0;
for (i = 0; i < List_Nbr (ErrView->Triangles); i++){
List_Read (ErrView->Triangles, i, &t); if(ErrView->NbST){
fprintf (f, "ST(%g,%g,%g,%g,%g,%g,%g,%g,%g){%g,%g,%g};\n", nb = List_Nbr(ErrView->ST) / ErrView->NbST ;
t.X[0], t.Y[0], t.Z[0], for(i = 0 ; i < List_Nbr(ErrView->ST) ; i+=nb){
t.X[1], t.Y[1], t.Z[1], X = (double*)List_Pointer_Fast(ErrView->ST,i);
t.X[2], t.Y[2], t.Z[2], Y = (double*)List_Pointer_Fast(ErrView->ST,i+3);
h[j], h[j], h[j]); Z = (double*)List_Pointer_Fast(ErrView->ST,i+6);
j++; Val = (double*)List_Pointer_Fast(ErrView->ST,i+9);
fprintf (f, "ST(%g,%g,%g,%g,%g,%g,%g,%g,%g){%g,%g,%g};\n",
X[0], Y[0], Z[0],
X[1], Y[1], Z[1],
X[2], Y[2], Z[2],
h[j], h[j], h[j]);
j++;
}
} }
for (i = 0; i < List_Nbr (ErrView->Tetrahedra); i++){
List_Read (ErrView->Tetrahedra, i, &s); if(ErrView->NbSS){
fprintf (f, "SS(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g){%g,%g,%g,%g};\n", nb = List_Nbr(ErrView->SS) / ErrView->NbSS ;
s.X[0], s.Y[0], s.Z[0], for(i = 0 ; i < List_Nbr(ErrView->SS) ; i+=nb){
s.X[1], s.Y[1], s.Z[1], X = (double*)List_Pointer_Fast(ErrView->SS,i);
s.X[2], s.Y[2], s.Z[2], Y = (double*)List_Pointer_Fast(ErrView->SS,i+3);
s.X[3], s.Y[3], s.Z[3], Z = (double*)List_Pointer_Fast(ErrView->SS,i+8);
h[j], h[j], h[j], h[j]); Val = (double*)List_Pointer_Fast(ErrView->SS,i+12);
j++; fprintf (f, "SS(%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g,%g){%g,%g,%g,%g};\n",
X[0], Y[0], Z[0],
X[1], Y[1], Z[1],
X[2], Y[2], Z[2],
X[3], Y[3], Z[3],
h[j], h[j], h[j], h[j]);
j++;
}
} }
fprintf (f, "};\n"); fprintf (f, "};\n");
fclose (f); fclose (f);
...@@ -331,5 +377,6 @@ int CreateBGM (Post_View * ErrView, int OptiMethod, double Degree, ...@@ -331,5 +377,6 @@ int CreateBGM (Post_View * ErrView, int OptiMethod, double Degree,
Msg(INFOS, "Background Mesh Wriiten in '%s'", OutFile); Msg(INFOS, "Background Mesh Wriiten in '%s'", OutFile);
return 1; return 1;
} }
/* $Id: CbGeneral.cpp,v 1.4 2000-11-26 15:43:47 geuzaine Exp $ */ /* $Id: CbGeneral.cpp,v 1.5 2000-11-27 10:58:59 geuzaine Exp $ */
#include "Gmsh.h" #include "Gmsh.h"
#include "GmshUI.h" #include "GmshUI.h"
...@@ -107,10 +107,10 @@ void CurrentInfoCb (Widget w, XtPointer client_data, XtPointer call_data){ ...@@ -107,10 +107,10 @@ void CurrentInfoCb (Widget w, XtPointer client_data, XtPointer call_data){
for(i=0 ; i<List_Nbr(Post_ViewList) ; i++){ for(i=0 ; i<List_Nbr(Post_ViewList) ; i++){
v = (Post_View*)List_Pointer(Post_ViewList, i); v = (Post_View*)List_Pointer(Post_ViewList, i);
if(v->Visible){ if(v->Visible){
s[16] += List_Nbr(v->Points); s[16] += v->NbSP + v->NbVP + v->NbTP;
s[17] += List_Nbr(v->Lines); s[17] += v->NbSL + v->NbVL + v->NbTL;
s[18] += List_Nbr(v->Triangles); s[18] += v->NbST + v->NbVT + v->NbTT;
s[19] += List_Nbr(v->Tetrahedra); s[19] += v->NbSS + v->NbVS + v->NbTS;
} }
} }
sprintf(label, "%g", s[16]); XtVaSetValues(VLAB(19)); sprintf(label, "%g", s[16]); XtVaSetValues(VLAB(19));
......
/* $Id: CbPost.cpp,v 1.6 2000-11-26 15:43:48 geuzaine Exp $ */ /* $Id: CbPost.cpp,v 1.7 2000-11-27 10:58:59 geuzaine Exp $ */
#include "Gmsh.h" #include "Gmsh.h"
#include "GmshUI.h" #include "GmshUI.h"
...@@ -129,10 +129,6 @@ void DuplicateViewCb (Widget w, XtPointer client_data, XtPointer call_data){ ...@@ -129,10 +129,6 @@ void DuplicateViewCb (Widget w, XtPointer client_data, XtPointer call_data){
} }
v2->Time = v1->Time; v2->Time = v1->Time;
v2->Points = v1->Points;
v2->Lines = v1->Lines;
v2->Triangles = v1->Triangles;
v2->Tetrahedra = v1->Tetrahedra;
v2->ScalarOnly = v1->ScalarOnly; v2->ScalarOnly = v1->ScalarOnly;
v2->Min = v1->Min; v2->Min = v1->Min;
v2->Max = v1->Max; v2->Max = v1->Max;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment