diff --git a/CMakeLists.txt b/CMakeLists.txt index 78b7a213a260ca2ab2c4ce3c64dea7f5eca28d2d..c100ed5845098bce27c98c525e086042daa9fc81 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -129,7 +129,7 @@ set(GMSH_API Solver/linearSystemFull.h Solver/elasticitySolver.h Solver/sparsityPattern.h Solver/groupOfElements.h Solver/linearSystemPETSc.h Solver/linearSystemMUMPS.h Post/PView.h Post/PViewData.h Plugin/PluginManager.h Post/OctreePost.h - Post/PViewDataGModel.h Post/PViewOptions.h Post/ColorTable.h + Post/PViewDataList.h Post/PViewDataGModel.h Post/PViewOptions.h Post/ColorTable.h Numeric/nodalBasis.h Graphics/drawContext.h contrib/kbipack/gmp_normal_form.h contrib/kbipack/gmp_matrix.h diff --git a/Common/CreateFile.cpp b/Common/CreateFile.cpp index 2b6958056f3d352562f147dea04fb2a196a7362d..8a6ac5464f8d70b43b4b6d15b3609702ee16c7f6 100644 --- a/Common/CreateFile.cpp +++ b/Common/CreateFile.cpp @@ -6,6 +6,7 @@ #include "GmshConfig.h" #include "GmshMessage.h" #include "GModel.h" +#include "PView.h" #include "GmshDefines.h" #include "StringUtils.h" #include "Context.h" @@ -634,3 +635,4 @@ void CreateOutputFile(const std::string &fileName, int format, if(redraw) drawContext::global()->draw(); #endif } + diff --git a/Geo/boundaryLayersData.cpp b/Geo/boundaryLayersData.cpp index 3059c4519645002317e0db27ca81fce44c8c094a..1b44b02c97a4a8ed3daf47b2412435f2f34b4930 100644 --- a/Geo/boundaryLayersData.cpp +++ b/Geo/boundaryLayersData.cpp @@ -831,10 +831,10 @@ static bool createWedgeBetweenTwoFaces(MVertex *myV, /* - a "fanned" edge is one that opens a fan of element between the 2 faces + a "fanned" edge is one that opens a fan of element between the 2 faces it connects in the volume. - fan start (end) + fan start (end) --> at a symmetry plane or at an inflow/outflow bdry. This implies that the fan has a trace on this boundary --> at a corner where at least 3 incident model edges are "fanned" @@ -848,7 +848,7 @@ static bool createWedgeBetweenTwoFaces(MVertex *myV, The algo that allows to build the topology of fans - 1) Compute fanned edges : use threshold angle between adjacent faces as + 1) Compute fanned edges : use threshold angle between adjacent faces as user parameter 2) If one model vertex is connected to one single fanned edge -) If the model vertex is in the symmetry plane --> OK @@ -867,7 +867,7 @@ struct fanTopology { std::set<GEdge*> fans; std::vector< std::set<GFace *> > groups; bool isFan (GEdge* ge) const {return fans.find(ge) != fans.end();} - int getGroupNum (GFace *gf) const + int getGroupNum (GFace *gf) const { for (unsigned int i=0; i< groups.size(); i++){ if (std::find(groups[i].begin(),groups[i].end(),gf) != groups[i].end())return i; @@ -896,7 +896,7 @@ static GFace *otherSideOfEdge (GRegion * gr, GFace *gf, GEdge *ge) if ((*it) != gf && std::find(fr.begin(), fr.end(), *it) != fr.end()) return *it; } - // printf("ouille autre cote de face %d par arerte %d dans region %d foireux\n",gf->tag(),ge->tag(),gr->tag()); + // printf("ouille autre cote de face %d par arerte %d dans region %d foireux\n",gf->tag(),ge->tag(),gr->tag()); return 0; } @@ -929,9 +929,9 @@ fanTopology :: fanTopology (GRegion * gr, const std::set<GEdge*> &detectedFans, for (std::list<GEdge*>::iterator ite = e.begin() ; ite !=e.end() ; ite++) if (isFan(*ite))fe.push_back(*ite); // printf("%d fans connected to vert %d\n",fe.size(),gv->tag(), e.size()); - if (fe.size() > 2)corners.insert(gv); + if (fe.size() > 2)corners.insert(gv); } - + std::list<GFace*> fs = gr->faces(); while (!fs.empty()) { @@ -981,7 +981,7 @@ static int createColumnsBetweenFaces(GRegion *gr, GFace *gfs[256]; // we compute normals per face using the surface mesh (we could try to use the - // model but I doubt it'd be better, especially if the mesh is coarse + // model but I doubt it'd be better, especially if the mesh is coarse for( std::set<GFace*> ::iterator it = _gfaces.begin() ; it != _gfaces.end(); ++it){ for (std::multimap<GFace*,MTriangle*>::iterator itm = _faces.lower_bound(*it); @@ -996,11 +996,11 @@ static int createColumnsBetweenFaces(GRegion *gr, } // the topology of the fans is known - // we look over all faces and look in which + // we look over all faces and look in which // group it lies in std::vector< std::vector<GFace*> > joints; - + std::multimap<int, GFace*> lGroup; std::map<GFace*, int> inv; std::set<int> gs; @@ -1026,7 +1026,7 @@ static int createColumnsBetweenFaces(GRegion *gr, std::vector<SMetric3> _metrics; avg.normalize(); createBLPointsInDir (gr,myV,blf,avg,_column,_metrics); - _columns->addColumn(avg,myV, _column, _metrics, joint); + _columns->addColumn(avg,myV, _column, _metrics, joint); } // // DEBUG STUFF @@ -1056,15 +1056,15 @@ static int createColumnsBetweenFaces(GRegion *gr, // in the average direction if (joints.size() > 2){ } - - return joints.size(); + + return joints.size(); } -static int createColumnsOnSymmetryPlane(MVertex *myV, - BoundaryLayerColumns *_columns, - std::set<GFace*> &_allGFaces, - std::list<GFace*> &faces, - fanTopology &ft) +static void createColumnsOnSymmetryPlane(MVertex *myV, + BoundaryLayerColumns *_columns, + std::set<GFace*> &_allGFaces, + std::list<GFace*> &faces, + fanTopology &ft) { // get all model faces for that vertex that have boundary layer columns attached for ( std::list<GFace*>::iterator itf = faces.begin(); itf!= faces.end() ; ++itf){ @@ -1085,9 +1085,9 @@ static int createColumnsOnSymmetryPlane(MVertex *myV, GFace *g1 = *itff ; ++itff; GFace *g2 = *itff; int sense = 1; std::vector<GFace*> _joint; - + const BoundaryLayerFan *fan = _face_columns->getFan(myV); - + if (fan){ MVertex *v11 = fan->_e1.getVertex(0); MVertex *v12 = fan->_e1.getVertex(1); @@ -1139,10 +1139,10 @@ static int createColumnsOnSymmetryPlane(MVertex *myV, } } -static bool preprocessVertex (MVertex *v, +static bool preprocessVertex (MVertex *v, std::map<MTriangle*,GFace*> &_gfaces, BoundaryLayerColumns * _columns, - std::list<GFace*> &faces, + std::list<GFace*> &faces, std::multimap<GFace*,MTriangle*> &_faces, std::set<GFace*> &_allGFaces){ faces = v->onWhat()->faces(); @@ -1153,7 +1153,7 @@ static bool preprocessVertex (MVertex *v, _faces.insert(std::make_pair(gf,itm->second)); _allGFaces.insert(gf); } - + bool onSymmetryPlane = false; if (v->onWhat()->dim() != 2) if (faces.size() != _allGFaces.size()) @@ -1233,11 +1233,11 @@ BoundaryLayerColumns *buildAdditionalPoints3D(GRegion *gr) } } - // look for all the wedges + // look for all the wedges std::set<GEdge*> fans; std::set<GVertex*> fanNodes; for (std::set<MVertex*>::iterator it = _vertices.begin(); it != _vertices.end() ; ++it){ - std::list<GFace*> faces; + std::list<GFace*> faces; std::multimap<GFace*,MTriangle*> _faces; std::set<GFace*> _allGFaces; preprocessVertex (*it, _gfaces, _columns, faces, _faces, _allGFaces); @@ -1264,11 +1264,11 @@ BoundaryLayerColumns *buildAdditionalPoints3D(GRegion *gr) // for all boundry points for (std::set<MVertex*>::iterator it = _vertices.begin(); it != _vertices.end() ; ++it){ - std::list<GFace*> faces; + std::list<GFace*> faces; std::multimap<GFace*,MTriangle*> _faces; std::set<GFace*> _allGFaces; bool onSymmetryPlane = preprocessVertex (*it, _gfaces, _columns, faces, _faces, _allGFaces); - + if (onSymmetryPlane){ // we have a 3D boundary layer that connects a 2D boundary layer // this is the tricky case diff --git a/Mesh/Field.h b/Mesh/Field.h index 23f66a6906ac31e702309563ecd65995674f3be2..fee3dd81f4e90152a88cdb44f537a22be39a62f2 100644 --- a/Mesh/Field.h +++ b/Mesh/Field.h @@ -24,13 +24,13 @@ class PView; class Field; class GEntity; -typedef enum { +typedef enum { FIELD_OPTION_DOUBLE = 0, FIELD_OPTION_INT, - FIELD_OPTION_STRING, + FIELD_OPTION_STRING, FIELD_OPTION_PATH, - FIELD_OPTION_BOOL, - FIELD_OPTION_LIST + FIELD_OPTION_BOOL, + FIELD_OPTION_LIST } FieldOptionType; class FieldCallback { @@ -86,10 +86,10 @@ class Field { virtual double operator() (double x, double y, double z, GEntity *ge=0) = 0; // anisotropic virtual void operator() (double x, double y, double z, SMetric3 &, GEntity *ge=0){} - + //temporary virtual void operator()(double x,double y,double z,SVector3& v1,SVector3& v2,SVector3& v3,GEntity* ge=0){} - + bool update_needed; //void update(){ printf("up f \n"); return;} virtual const char *getName() = 0; @@ -145,7 +145,7 @@ class BoundaryLayerField : public Field { void operator() (AttractorField *cc, double dist, double x, double y, double z, SMetric3 &metr, GEntity *ge); public: - double hwall_n,hwall_t,ratio,hfar,thickness,fan_angle; + double hwall_n,hwall_t,ratio,hfar,thickness,fan_angle; double current_distance, tgt_aniso_ratio; SPoint3 _closest_point; int iRecombine, iIntersect; @@ -157,48 +157,61 @@ class BoundaryLayerField : public Field { ~BoundaryLayerField() {removeAttractors();} virtual double operator() (double x, double y, double z, GEntity *ge=0); virtual void operator() (double x, double y, double z, SMetric3 &metr, GEntity *ge=0); - bool isFaceBL (int iF) const {return std::find(faces_id.begin(),faces_id.end(),iF) != faces_id.end();} - bool isEdgeBL (int iE) const {return std::find(edges_id.begin(),edges_id.end(),iE) != edges_id.end();} - bool isEdgeBLSaved (int iE) const {return std::find(edges_id_saved.begin(),edges_id_saved.end(),iE) != edges_id_saved.end();} - bool isFan (int iE) const {return std::find(fans_id.begin(),fans_id.end(),iE) != fans_id.end();} - bool isFanNode (int iV) const {return std::find(fan_nodes_id.begin(),fan_nodes_id.end(),iV) != fan_nodes_id.end();} - bool isVertexBL (int iV) const {return std::find(nodes_id.begin(),nodes_id.end(),iV) != nodes_id.end();} + bool isFaceBL (int iF) const + { + return std::find(faces_id.begin(),faces_id.end(),iF) != faces_id.end(); + } + bool isEdgeBL (int iE) const + { + return std::find(edges_id.begin(),edges_id.end(),iE) != edges_id.end(); + } + bool isEdgeBLSaved (int iE) const + { + return std::find(edges_id_saved.begin(),edges_id_saved.end(),iE) + != edges_id_saved.end(); + } + bool isFan (int iE) const + { + return std::find(fans_id.begin(),fans_id.end(),iE) != fans_id.end(); + } + bool isFanNode (int iV) const + { + return std::find(fan_nodes_id.begin(),fan_nodes_id.end(),iV) != fan_nodes_id.end(); + } + bool isVertexBL (int iV) const + { + return std::find(nodes_id.begin(),nodes_id.end(),iV) != nodes_id.end(); + } void computeFor1dMesh(double x, double y, double z, SMetric3 &metr); void setupFor2d(int iF); void setupFor3d(); void removeAttractors(); }; + #else + class BoundaryLayerField : public Field { public: - double hwall_n,hwall_t,ratio,hfar,thickness;//,fan_angle; - double current_distance, tgt_aniso_ratio; - SPoint3 _closest_point; - int iRecombine, iIntersect; - //AttractorField *current_closest; - virtual bool isotropic () const {return false;} - virtual const char *getName(){return "";} - virtual std::string getDescription(){return "";} - BoundaryLayerField() : hwall_n(0.), hwall_t(0.), ratio(0.), - hfar(0.), thickness(0.), fan_angle(0.), - current_distance(0.), tgt_aniso_ratio(0.), - _closest_point(0.,0.,0.), iRecombine(0), iIntersect(0) - //current_closest(NULL) + virtual bool isotropic() const { return false; } + virtual const char *getName(){ return ""; } + virtual std::string getDescription(){ return ""; } + BoundaryLayerField() { Msg::Error("You must compile with ANN to use BoundaryLayerField"); } ~BoundaryLayerField() {} - virtual double operator() (double x, double y, double z, GEntity *ge=0){return 0.;} + virtual double operator() (double x, double y, double z, GEntity *ge=0){ return 0.; } virtual void operator() (double x, double y, double z, SMetric3 &metr, GEntity *ge=0){} bool isFaceBL (int iF) const {return false;} bool isEdgeBL (int iE) const {return false;} bool isFan (int iE) const {return false;} bool isVertexBL (int iV) const {return false;} - void computeFor1dMesh(double x, double y, double z, SMetric3 &metr){return;} - void setupFor2d(int iF){return;} - void setupFor3d(){return;} - void removeAttractors(){return;} + void computeFor1dMesh(double x, double y, double z, SMetric3 &metr){} + void setupFor2d(int iF){} + void setupFor3d(){} + void removeAttractors(){} }; + #endif class FieldOptionString : public FieldOption @@ -218,7 +231,6 @@ class FieldOptionString : public FieldOption } }; - class FieldOptionDouble : public FieldOption { public: @@ -242,7 +254,7 @@ class FieldOptionInt : public FieldOption public: int &val; FieldOptionType getType(){ return FIELD_OPTION_INT; } - FieldOptionInt(int &_val, std::string _help, bool *_status=0) + FieldOptionInt(int &_val, std::string _help, bool *_status=0) : FieldOption(_help, _status), val(_val){} double numericalValue() const { return val; } void numericalValue(double v){ modified(); val = (int)v; } @@ -259,7 +271,7 @@ class FieldOptionList : public FieldOption public: std::list<int> &val; FieldOptionType getType(){ return FIELD_OPTION_LIST; } - FieldOptionList(std::list<int> &_val, std::string _help, bool *_status=0) + FieldOptionList(std::list<int> &_val, std::string _help, bool *_status=0) : FieldOption(_help, _status), val(_val) {} void list(std::list<int> value){ modified(); val = value; } const std::list<int>& list() const { return val; } @@ -311,7 +323,8 @@ class FieldCallbackGeneric : public FieldCallback { { (_field->*_callback)(); } - FieldCallbackGeneric( t *field, void (t::*callback)(), const std::string description) : FieldCallback(description) + FieldCallbackGeneric( t *field, void (t::*callback)(), const std::string description) + : FieldCallback(description) { _field = field; _callback = callback; diff --git a/Post/PViewDataGModel.h b/Post/PViewDataGModel.h index e1d94fdfe8e23150a3968fb6dbf81892edacae6c..bbcb92fe14ac297191c631522562e62082da49e9 100644 --- a/Post/PViewDataGModel.h +++ b/Post/PViewDataGModel.h @@ -255,6 +255,7 @@ class PViewDataGModel : public PViewData { bool forceNodeData=false); bool readMED(const std::string &fileName, int fileIndex); bool writeMED(const std::string &fileName); + void importLists(int N[24], std::vector<double> *V[24]); }; #endif diff --git a/Post/PViewDataGModelIO.cpp b/Post/PViewDataGModelIO.cpp index acfc0df79f2545d17c00c5a71b685a914f1a3ccc..317a872e0e1bc23a07f0538de01760a75312f93d 100644 --- a/Post/PViewDataGModelIO.cpp +++ b/Post/PViewDataGModelIO.cpp @@ -298,6 +298,65 @@ bool PViewDataGModel::writeMSH(const std::string &fileName, double version, bool return true; } +void PViewDataGModel::importLists(int N[24], std::vector<double> *V[24]) +{ + for(int idxtype = 0; idxtype < 24; idxtype++){ + int nbe = N[idxtype]; + if(!nbe) continue; + std::vector<double> *list = V[idxtype]; + int nc = 0, nn = 0; + switch(idxtype){ + case 0 : nc = 1; nn = 1; break; // SP + case 1 : nc = 3; nn = 1; break; // VP + case 2 : nc = 9; nn = 1; break; // TP + case 3 : nc = 1; nn = 2; break; // SL + case 4 : nc = 3; nn = 2; break; // VL + case 5 : nc = 9; nn = 2; break; // TL + case 6 : nc = 1; nn = 3; break; // ST + case 7 : nc = 3; nn = 3; break; // VT + case 8 : nc = 9; nn = 3; break; // TT + case 9 : nc = 1; nn = 4; break; // SQ + case 10: nc = 3; nn = 4; break; // VQ + case 11: nc = 9; nn = 4; break; // TQ + case 12: nc = 1; nn = 4; break; // SS + case 13: nc = 3; nn = 4; break; // VS + case 14: nc = 9; nn = 4; break; // TS + case 15: nc = 1; nn = 8; break; // SH + case 16: nc = 3; nn = 8; break; // VH + case 17: nc = 9; nn = 8; break; // TH + case 18: nc = 1; nn = 6; break; // SI + case 19: nc = 3; nn = 6; break; // VI + case 20: nc = 9; nn = 6; break; // TI + case 21: nc = 1; nn = 5; break; // SY + case 22: nc = 3; nn = 5; break; // VY + case 23: nc = 9; nn = 5; break; // TY + } + int stride = list->size() / nbe; + int numSteps = (stride - 1) / nc / nn; + for(int step = 0; step < numSteps; step++){ + printf("creating step %d\n", step); + _steps.push_back(new stepData<double>(GModel::current(), nc)); + _steps[step]->fillEntities(); + _steps[step]->computeBoundingBox(); + _steps[step]->setTime(step); + _steps[step]->resizeData(nbe); + for(unsigned int j = 0; j < list->size(); j += stride){ + double *tmp = &(*list)[j]; + int num = (int)tmp[0]; + printf("importing ele %d\n", num); + double *d = _steps[step]->getData(num, true, nn); + for(int k = 0; k < nc * nn; k++){ + d[k] = tmp[1 + nc * nn * step + k]; + printf(" val[%d]=%g\n", k, d[k]); + } + } + } + } + + finalize(); +} + + #if defined(HAVE_MED) extern "C" {