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

octree + CutGrid,CutParametric,Probe for model post views
parent 2a7a5cc6
No related branches found
No related tags found
No related merge requests found
// $Id: CutGrid.cpp,v 1.24 2008-02-17 08:48:06 geuzaine Exp $ // $Id: CutGrid.cpp,v 1.25 2008-03-20 10:52:36 geuzaine Exp $
// //
// Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
// //
...@@ -246,7 +246,7 @@ void GMSH_CutGridPlugin::getPoint(int iU, int iV, double *X) ...@@ -246,7 +246,7 @@ void GMSH_CutGridPlugin::getPoint(int iU, int iV, double *X)
v * (CutGridOptions_Number[8].def-CutGridOptions_Number[2].def) ; v * (CutGridOptions_Number[8].def-CutGridOptions_Number[2].def) ;
} }
void GMSH_CutGridPlugin::addInView(PViewDataList *data, int connect, int nbcomp, void GMSH_CutGridPlugin::addInView(int numsteps, int connect, int nbcomp,
double ***pnts, double ***vals, double ***pnts, double ***vals,
List_T *P, int *nP, List_T *P, int *nP,
List_T *L, int *nL, List_T *L, int *nL,
...@@ -260,7 +260,7 @@ void GMSH_CutGridPlugin::addInView(PViewDataList *data, int connect, int nbcomp, ...@@ -260,7 +260,7 @@ void GMSH_CutGridPlugin::addInView(PViewDataList *data, int connect, int nbcomp,
List_Add(P, &pnts[i][j][1]); List_Add(P, &pnts[i][j][1]);
List_Add(P, &pnts[i][j][2]); List_Add(P, &pnts[i][j][2]);
(*nP)++; (*nP)++;
for(int k = 0; k < data->getNumTimeSteps(); ++k){ for(int k = 0; k < numsteps; ++k){
for(int l = 0; l < nbcomp; ++l) for(int l = 0; l < nbcomp; ++l)
List_Add(P, &vals[i][j][nbcomp*k+l]); List_Add(P, &vals[i][j][nbcomp*k+l]);
} }
...@@ -276,7 +276,7 @@ void GMSH_CutGridPlugin::addInView(PViewDataList *data, int connect, int nbcomp, ...@@ -276,7 +276,7 @@ void GMSH_CutGridPlugin::addInView(PViewDataList *data, int connect, int nbcomp,
List_Add(L, &pnts[0][i][1]); List_Add(L, &pnts[0][i+1][1]); List_Add(L, &pnts[0][i][1]); List_Add(L, &pnts[0][i+1][1]);
List_Add(L, &pnts[0][i][2]); List_Add(L, &pnts[0][i+1][2]); List_Add(L, &pnts[0][i][2]); List_Add(L, &pnts[0][i+1][2]);
(*nL)++; (*nL)++;
for(int k = 0; k < data->getNumTimeSteps(); ++k){ for(int k = 0; k < numsteps; ++k){
for(int l = 0; l < nbcomp; ++l) for(int l = 0; l < nbcomp; ++l)
List_Add(L, &vals[0][i ][nbcomp*k+l]); List_Add(L, &vals[0][i ][nbcomp*k+l]);
for(int l = 0; l < nbcomp; ++l) for(int l = 0; l < nbcomp; ++l)
...@@ -290,7 +290,7 @@ void GMSH_CutGridPlugin::addInView(PViewDataList *data, int connect, int nbcomp, ...@@ -290,7 +290,7 @@ void GMSH_CutGridPlugin::addInView(PViewDataList *data, int connect, int nbcomp,
List_Add(L, &pnts[i][0][1]); List_Add(L, &pnts[i+1][0][1]); List_Add(L, &pnts[i][0][1]); List_Add(L, &pnts[i+1][0][1]);
List_Add(L, &pnts[i][0][2]); List_Add(L, &pnts[i+1][0][2]); List_Add(L, &pnts[i][0][2]); List_Add(L, &pnts[i+1][0][2]);
(*nL)++; (*nL)++;
for(int k = 0; k < data->getNumTimeSteps(); ++k){ for(int k = 0; k < numsteps; ++k){
for(int l = 0; l < nbcomp; ++l) for(int l = 0; l < nbcomp; ++l)
List_Add(L, &vals[i ][0][nbcomp*k+l]); List_Add(L, &vals[i ][0][nbcomp*k+l]);
for(int l = 0; l < nbcomp; ++l) for(int l = 0; l < nbcomp; ++l)
...@@ -308,7 +308,7 @@ void GMSH_CutGridPlugin::addInView(PViewDataList *data, int connect, int nbcomp, ...@@ -308,7 +308,7 @@ void GMSH_CutGridPlugin::addInView(PViewDataList *data, int connect, int nbcomp,
List_Add(Q, &pnts[i ][j ][2]); List_Add(Q, &pnts[i+1][j ][2]); List_Add(Q, &pnts[i ][j ][2]); List_Add(Q, &pnts[i+1][j ][2]);
List_Add(Q, &pnts[i+1][j+1][2]); List_Add(Q, &pnts[i ][j+1][2]); List_Add(Q, &pnts[i+1][j+1][2]); List_Add(Q, &pnts[i ][j+1][2]);
(*nQ)++; (*nQ)++;
for(int k = 0; k < data->getNumTimeSteps(); ++k){ for(int k = 0; k < numsteps; ++k){
for(int l = 0; l < nbcomp; ++l) for(int l = 0; l < nbcomp; ++l)
List_Add(Q, &vals[i ][j ][nbcomp*k+l]); List_Add(Q, &vals[i ][j ][nbcomp*k+l]);
for(int l = 0; l < nbcomp; ++l) for(int l = 0; l < nbcomp; ++l)
...@@ -329,29 +329,18 @@ PView *GMSH_CutGridPlugin::GenerateView(PView *v1, int connect) ...@@ -329,29 +329,18 @@ PView *GMSH_CutGridPlugin::GenerateView(PView *v1, int connect)
if(getNbU() <= 0 || getNbV() <= 0) if(getNbU() <= 0 || getNbV() <= 0)
return v1; return v1;
PViewDataList *data1 = getDataList(v1); PViewData *data1 = v1->getData();
if(!data1) return v1;
PView *v2 = new PView(true); PView *v2 = new PView(true);
PViewDataList *data2 = getDataList(v2); PViewDataList *data2 = getDataList(v2);
if(!data2) return v1;
OctreePost o(v1); OctreePost o(v1);
int nbs = 0, nbv = 0, nbt = 0; int nbs = data1->getNumScalars();
int nbv = data1->getNumVectors();
if(data1->NbST || data1->NbSQ || data1->NbSS || int nbt = data1->getNumTensors();
data1->NbSH || data1->NbSI || data1->NbSY)
nbs = 1;
if(data1->NbVT || data1->NbVQ || data1->NbVS ||
data1->NbVH || data1->NbVI || data1->NbVY)
nbv = 1;
if(data1->NbTT || data1->NbTQ || data1->NbTS ||
data1->NbTH || data1->NbTI || data1->NbTY)
nbt = 1;
int maxcomp = nbt ? 9 : (nbv ? 3 : 1); int maxcomp = nbt ? 9 : (nbv ? 3 : 1);
int numsteps = data1->getNumTimeSteps();
double ***pnts = new double** [getNbU()]; double ***pnts = new double** [getNbU()];
double ***vals = new double** [getNbU()]; double ***vals = new double** [getNbU()];
...@@ -360,7 +349,7 @@ PView *GMSH_CutGridPlugin::GenerateView(PView *v1, int connect) ...@@ -360,7 +349,7 @@ PView *GMSH_CutGridPlugin::GenerateView(PView *v1, int connect)
vals[i] = new double* [getNbV()]; vals[i] = new double* [getNbV()];
for(int j = 0; j < getNbV(); j++){ for(int j = 0; j < getNbV(); j++){
pnts[i][j] = new double[3]; pnts[i][j] = new double[3];
vals[i][j] = new double[maxcomp * data1->getNumTimeSteps()]; vals[i][j] = new double[maxcomp * numsteps];
getPoint(i, j, pnts[i][j]); getPoint(i, j, pnts[i][j]);
} }
} }
...@@ -369,24 +358,24 @@ PView *GMSH_CutGridPlugin::GenerateView(PView *v1, int connect) ...@@ -369,24 +358,24 @@ PView *GMSH_CutGridPlugin::GenerateView(PView *v1, int connect)
for(int i = 0; i < getNbU(); i++) for(int i = 0; i < getNbU(); i++)
for(int j = 0; j < getNbV(); j++) for(int j = 0; j < getNbV(); j++)
o.searchScalar(pnts[i][j][0], pnts[i][j][1], pnts[i][j][2], vals[i][j]); o.searchScalar(pnts[i][j][0], pnts[i][j][1], pnts[i][j][2], vals[i][j]);
addInView(data1, connect, 1, pnts, vals, data2->SP, &data2->NbSP, data2->SL, addInView(numsteps, connect, 1, pnts, vals, data2->SP, &data2->NbSP,
&data2->NbSL, data2->SQ, &data2->NbSQ); data2->SL, &data2->NbSL, data2->SQ, &data2->NbSQ);
} }
if(nbv){ if(nbv){
for(int i = 0; i < getNbU(); i++) for(int i = 0; i < getNbU(); i++)
for(int j = 0; j < getNbV(); j++) for(int j = 0; j < getNbV(); j++)
o.searchVector(pnts[i][j][0], pnts[i][j][1], pnts[i][j][2], vals[i][j]); o.searchVector(pnts[i][j][0], pnts[i][j][1], pnts[i][j][2], vals[i][j]);
addInView(data1, connect, 3, pnts, vals, data2->VP, &data2->NbVP, data2->VL, addInView(numsteps, connect, 3, pnts, vals, data2->VP, &data2->NbVP,
&data2->NbVL, data2->VQ, &data2->NbVQ); data2->VL, &data2->NbVL, data2->VQ, &data2->NbVQ);
} }
if(nbt){ if(nbt){
for(int i = 0; i < getNbU(); i++) for(int i = 0; i < getNbU(); i++)
for(int j = 0; j < getNbV(); j++) for(int j = 0; j < getNbV(); j++)
o.searchTensor(pnts[i][j][0], pnts[i][j][1], pnts[i][j][2], vals[i][j]); o.searchTensor(pnts[i][j][0], pnts[i][j][1], pnts[i][j][2], vals[i][j]);
addInView(data1, connect, 9, pnts, vals, data2->TP, &data2->NbTP, data2->TL, addInView(numsteps, connect, 9, pnts, vals, data2->TP, &data2->NbTP,
&data2->NbTL, data2->TQ, &data2->NbTQ); data2->TL, &data2->NbTL, data2->TQ, &data2->NbTQ);
} }
for(int i = 0; i < getNbU(); i++){ for(int i = 0; i < getNbU(); i++){
...@@ -400,7 +389,6 @@ PView *GMSH_CutGridPlugin::GenerateView(PView *v1, int connect) ...@@ -400,7 +389,6 @@ PView *GMSH_CutGridPlugin::GenerateView(PView *v1, int connect)
delete [] pnts; delete [] pnts;
delete [] vals; delete [] vals;
data2->setName(data1->getName() + "_CutGrid"); data2->setName(data1->getName() + "_CutGrid");
data2->setFileName(data1->getName() + "_CutGrid.pos"); data2->setFileName(data1->getName() + "_CutGrid.pos");
data2->finalize(); data2->finalize();
......
...@@ -31,7 +31,7 @@ class GMSH_CutGridPlugin : public GMSH_Post_Plugin ...@@ -31,7 +31,7 @@ class GMSH_CutGridPlugin : public GMSH_Post_Plugin
{ {
static double callback(int num, int action, double value, double *opt, static double callback(int num, int action, double value, double *opt,
double step, double min, double max); double step, double min, double max);
void addInView(PViewDataList *data, int connect, int nbcomp, void addInView(int numsteps, int connect, int nbcomp,
double ***pnts, double ***vals, double ***pnts, double ***vals,
List_T *P, int *nP, List_T *P, int *nP,
List_T *L, int *nL, List_T *L, int *nL,
......
// $Id: CutParametric.cpp,v 1.25 2008-02-23 15:30:10 geuzaine Exp $ // $Id: CutParametric.cpp,v 1.26 2008-03-20 10:52:36 geuzaine Exp $
// //
// Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
// //
...@@ -297,12 +297,11 @@ PView *GMSH_CutParametricPlugin::execute(PView *v) ...@@ -297,12 +297,11 @@ PView *GMSH_CutParametricPlugin::execute(PView *v)
PView *v1 = getView(iView, v); PView *v1 = getView(iView, v);
if(!v1) return v; if(!v1) return v;
PViewDataList *data1 = getDataList(v1); if(!fillXYZ()) return v;
if(!data1) return v;
if(!fillXYZ()) PViewData *data1 = v1->getData();
return v;
int numSteps = data1->getNumTimeSteps();
int nbU = (int)CutParametricOptions_Number[2].def; int nbU = (int)CutParametricOptions_Number[2].def;
int connect = (int)CutParametricOptions_Number[3].def; int connect = (int)CutParametricOptions_Number[3].def;
if(nbU < 2) connect = 0; if(nbU < 2) connect = 0;
...@@ -310,47 +309,39 @@ PView *GMSH_CutParametricPlugin::execute(PView *v) ...@@ -310,47 +309,39 @@ PView *GMSH_CutParametricPlugin::execute(PView *v)
OctreePost o(v1); OctreePost o(v1);
PView *v2 = new PView(true); PView *v2 = new PView(true);
PViewDataList *data2 = getDataList(v2); PViewDataList *data2 = getDataList(v2);
if(!data2) return v;
double *res0 = new double[9 * data1->getNumTimeSteps()]; double *res0 = new double[9 * numSteps];
double *res1 = new double[9 * data1->getNumTimeSteps()]; double *res1 = new double[9 * numSteps];
double x0 = 0., y0 = 0., z0 = 0., x1 = 0., y1 = 0., z1 = 0.; double x0 = 0., y0 = 0., z0 = 0., x1 = 0., y1 = 0., z1 = 0.;
for(int k = 0; k < 9 * data1->getNumTimeSteps(); ++k) res0[k] = res1[k] = 0.; for(int k = 0; k < 9 * numSteps; ++k) res0[k] = res1[k] = 0.;
for(int i = 0; i < nbU; ++i){ for(int i = 0; i < nbU; ++i){
if(i && connect){ if(i && connect){
x0 = x1; x0 = x1;
y0 = y1; y0 = y1;
z0 = z1; z0 = z1;
for(int k = 0; k < 9 * data1->getNumTimeSteps(); ++k) res0[k] = res1[k]; for(int k = 0; k < 9 * numSteps; ++k) res0[k] = res1[k];
} }
x1 = x[i]; x1 = x[i];
y1 = y[i]; y1 = y[i];
z1 = z[i]; z1 = z[i];
if(data1->NbST || data1->NbSQ || data1->NbSS || if(data1->getNumScalars()){
data1->NbSH || data1->NbSI || data1->NbSY){
o.searchScalar(x1, y1, z1, res1); o.searchScalar(x1, y1, z1, res1);
addInView(connect, i, 1, data1->getNumTimeSteps(), addInView(connect, i, 1, numSteps, x0, y0, z0, res0, x1, y1, z1, res1,
x0, y0, z0, res0, x1, y1, z1, res1,
data2->SP, &data2->NbSP, data2->SL, &data2->NbSL); data2->SP, &data2->NbSP, data2->SL, &data2->NbSL);
} }
if(data1->NbVT || data1->NbVQ || data1->NbVS || if(data1->getNumVectors()){
data1->NbVH || data1->NbVI || data1->NbVY){
o.searchVector(x1, y1, z1, res1); o.searchVector(x1, y1, z1, res1);
addInView(connect, i, 3, data1->getNumTimeSteps(), addInView(connect, i, 3, numSteps, x0, y0, z0, res0, x1, y1, z1, res1,
x0, y0, z0, res0, x1, y1, z1, res1,
data2->VP, &data2->NbVP, data2->VL, &data2->NbVL); data2->VP, &data2->NbVP, data2->VL, &data2->NbVL);
} }
if(data1->NbTT || data1->NbTQ || data1->NbTS || if(data1->getNumTensors()){
data1->NbTH || data1->NbTI || data1->NbTY){
o.searchTensor(x1, y1, z1, res1); o.searchTensor(x1, y1, z1, res1);
addInView(connect, i, 9, data1->getNumTimeSteps(), addInView(connect, i, 9, numSteps, x0, y0, z0, res0, x1, y1, z1, res1,
x0, y0, z0, res0, x1, y1, z1, res1,
data2->TP, &data2->NbTP, data2->TL, &data2->NbTL); data2->TP, &data2->NbTP, data2->TL, &data2->NbTL);
} }
} }
......
// $Id: OctreePost.cpp,v 1.5 2008-03-20 07:34:43 geuzaine Exp $ // $Id: OctreePost.cpp,v 1.6 2008-03-20 10:52:36 geuzaine Exp $
// //
// Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
// //
...@@ -406,7 +406,7 @@ bool OctreePost::_getValue(void *in, int dim, int nbNod, int nbComp, ...@@ -406,7 +406,7 @@ bool OctreePost::_getValue(void *in, int dim, int nbNod, int nbComp,
return true; return true;
} }
bool OctreePost::_getValue(void *in, int nbComp, double P[3], int step, double *values, bool OctreePost::_getValue(void *in, int nbComp, double P[3], int timestep, double *values,
double *elementSize) double *elementSize)
{ {
if(!in) return false; if(!in) return false;
...@@ -415,8 +415,6 @@ bool OctreePost::_getValue(void *in, int nbComp, double P[3], int step, double * ...@@ -415,8 +415,6 @@ bool OctreePost::_getValue(void *in, int nbComp, double P[3], int step, double *
MElement *e = (MElement*)in; MElement *e = (MElement*)in;
if(e) printf("found ele %d!!\n", e->getNum());
int dataIndex[8]; int dataIndex[8];
for(int i = 0; i < e->getNumVertices(); i++){ for(int i = 0; i < e->getNumVertices(); i++){
dataIndex[i] = e->getVertex(i)->getDataIndex(); dataIndex[i] = e->getVertex(i)->getDataIndex();
...@@ -425,19 +423,26 @@ bool OctreePost::_getValue(void *in, int nbComp, double P[3], int step, double * ...@@ -425,19 +423,26 @@ bool OctreePost::_getValue(void *in, int nbComp, double P[3], int step, double *
double U[3]; double U[3];
e->xyz2uvw(P, U); e->xyz2uvw(P, U);
/*
if(step < 0){ double nodeval[8 * 9];
for(int i = 0; i < _theViewDataGModel->getNumTimeSteps(); i++) for(int step = 0; step < _theViewDataGModel->getNumTimeSteps(); step++){
for(int j = 0; j < nbComp; j++) if(timestep < 0 || step == timestep){
values[nbComp * i + j] = e->interpolate(&V[nbNod * nbComp * i + j], for(int nod = 0; nod < e->getNumVertices(); nod++){
U[0], U[1], U[2], nbComp); for(int comp = 0; comp < nbComp; comp++){
if(!_theViewDataGModel->getValue(step, dataIndex[nod], comp,
nodeval[nod*nbComp+comp]))
return false;
}
}
for(int comp = 0; comp < nbComp; comp++){
double val = e->interpolate(nodeval, U[0], U[1], U[2], nbComp);
if(timestep < 0)
values[nbComp * step + comp] = val;
else
values[comp] = val;
}
} }
else{
for(int j = 0; j < nbComp; j++)
values[j] = e->interpolate(&V[nbNod * nbComp * step + j],
U[0], U[1], U[2], nbComp);
} }
*/
if(elementSize) *elementSize = e->maxEdge(); if(elementSize) *elementSize = e->maxEdge();
return true; return true;
......
// $Id: PViewDataGModel.cpp,v 1.31 2008-03-20 07:34:43 geuzaine Exp $ // $Id: PViewDataGModel.cpp,v 1.32 2008-03-20 10:52:37 geuzaine Exp $
// //
// Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle // Copyright (C) 1997-2008 C. Geuzaine, J.-F. Remacle
// //
...@@ -79,6 +79,24 @@ SBoundingBox3d PViewDataGModel::getBoundingBox(int step) ...@@ -79,6 +79,24 @@ SBoundingBox3d PViewDataGModel::getBoundingBox(int step)
return _steps[step]->getBoundingBox(); return _steps[step]->getBoundingBox();
} }
int PViewDataGModel::getNumScalars(int step)
{
if(_steps[0]->getNumComp() == 1) return getNumElements(0);
return 0;
}
int PViewDataGModel::getNumVectors(int step)
{
if(_steps[0]->getNumComp() == 3) return getNumElements(0);
return 0;
}
int PViewDataGModel::getNumTensors(int step)
{
if(_steps[0]->getNumComp() == 9) return getNumElements(0);
return 0;
}
int PViewDataGModel::getNumEntities(int step) int PViewDataGModel::getNumEntities(int step)
{ {
if(step < 0){ if(step < 0){
...@@ -184,3 +202,10 @@ GEntity *PViewDataGModel::getEntity(int step, int ent) ...@@ -184,3 +202,10 @@ GEntity *PViewDataGModel::getEntity(int step, int ent)
{ {
return _steps[step]->getEntity(ent); return _steps[step]->getEntity(ent);
} }
bool PViewDataGModel::getValue(int step, int dataIndex, int comp, double &val)
{
if(dataIndex < 0 || dataIndex >= (int)_steps[step]->getNumData()) return false;
val = _steps[step]->getData(dataIndex)[comp];
return true;
}
...@@ -134,6 +134,9 @@ class PViewDataGModel : public PViewData { ...@@ -134,6 +134,9 @@ class PViewDataGModel : public PViewData {
double getMin(int step=-1); double getMin(int step=-1);
double getMax(int step=-1); double getMax(int step=-1);
SBoundingBox3d getBoundingBox(int step=-1); SBoundingBox3d getBoundingBox(int step=-1);
int getNumScalars(int step=-1);
int getNumVectors(int step=-1);
int getNumTensors(int step=-1);
int getNumEntities(int step=-1); int getNumEntities(int step=-1);
int getNumElements(int step=-1, int ent=-1); int getNumElements(int step=-1, int ent=-1);
int getDimension(int step, int ent, int ele); int getDimension(int step, int ent, int ele);
...@@ -151,8 +154,10 @@ class PViewDataGModel : public PViewData { ...@@ -151,8 +154,10 @@ class PViewDataGModel : public PViewData {
// create old-style list-based dataset from this one // create old-style list-based dataset from this one
//PViewDataList *convertToPViewDataList(); //PViewDataList *convertToPViewDataList();
// acces GModel entities directly // direct access to GModel entities and direct access to value by
// dataIndex
GEntity *getEntity(int step, int ent); GEntity *getEntity(int step, int ent);
bool getValue(int step, int dataIndex, int comp, double &val);
// I/O routines // I/O routines
bool readMSH(std::string fileName, int fileIndex, FILE *fp, bool binary, bool readMSH(std::string fileName, int fileIndex, FILE *fp, bool binary,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment