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

export element groups for physicals

parent f5f6e709
No related branches found
No related tags found
No related merge requests found
...@@ -175,6 +175,20 @@ int GModel::readUNV(const std::string &name) ...@@ -175,6 +175,20 @@ int GModel::readUNV(const std::string &name)
return 1; return 1;
} }
static std::string physicalName(GModel *m, int dim, int num)
{
std::string name = m->getPhysicalName(dim, num);
if(name.empty()){
char tmp[256];
sprintf(tmp, "%s%d", (dim == 3) ? "PhysicalVolume" :
(dim == 2) ? "PhysicalSurface" : "PhysicalLine", num);
name = tmp;
}
for(unsigned int i = 0; i < name.size(); i++)
if(name[i] == ' ') name[i] = '_';
return name;
}
int GModel::writeUNV(const std::string &name, bool saveAll, bool saveGroupsOfNodes, int GModel::writeUNV(const std::string &name, bool saveAll, bool saveGroupsOfNodes,
double scalingFactor) double scalingFactor)
{ {
...@@ -202,36 +216,30 @@ int GModel::writeUNV(const std::string &name, bool saveAll, bool saveGroupsOfNod ...@@ -202,36 +216,30 @@ int GModel::writeUNV(const std::string &name, bool saveAll, bool saveGroupsOfNod
// elements // elements
fprintf(fp, "%6d\n", -1); fprintf(fp, "%6d\n", -1);
fprintf(fp, "%6d\n", 2412); fprintf(fp, "%6d\n", 2412);
int num = 0;
for(unsigned int i = 0; i < entities.size(); i++){ for(unsigned int i = 0; i < entities.size(); i++){
if(saveAll || entities[i]->physicals.size()){
for(unsigned int j = 0; j < entities[i]->getNumMeshElements(); j++){ for(unsigned int j = 0; j < entities[i]->getNumMeshElements(); j++){
MElement *e = entities[i]->getMeshElement(j); MElement *e = entities[i]->getMeshElement(j);
// FIXME: don't duplicate elements anymore: just save the element with e->writeUNV(fp, e->getNum(), entities[i]->tag(), 0);
// their natural id }
if(saveAll)
e->writeUNV(fp, ++num, entities[i]->tag(), 0);
else
for(unsigned int k = 0; k < entities[i]->physicals.size(); k++)
e->writeUNV(fp, ++num, entities[i]->tag(), entities[i]->physicals[k]);
} }
} }
fprintf(fp, "%6d\n", -1); fprintf(fp, "%6d\n", -1);
// FIXME: save groups of elements for each physical std::map<int, std::vector<GEntity*> > groups[4];
getPhysicalGroups(groups);
// groups of nodes for physical groups // save groups of elements (and groups of nodes if requested) for each
if(saveGroupsOfNodes){ // physical
fprintf(fp, "%6d\n", -1); fprintf(fp, "%6d\n", -1);
fprintf(fp, "%6d\n", 2477); fprintf(fp, "%6d\n", 2477);
std::map<int, std::vector<GEntity*> > groups[4]; for(int dim = 0; dim <= 3; dim++){
getPhysicalGroups(groups);
int gr = 1;
for(int dim = 1; dim <= 3; dim++){
for(std::map<int, std::vector<GEntity*> >::iterator it = groups[dim].begin(); for(std::map<int, std::vector<GEntity*> >::iterator it = groups[dim].begin();
it != groups[dim].end(); it++){ it != groups[dim].end(); it++){
std::set<MVertex*> nodes;
std::vector<GEntity *> &entities = it->second; std::vector<GEntity *> &entities = it->second;
std::set<MVertex*> nodes;
if(saveGroupsOfNodes){
for(unsigned int i = 0; i < entities.size(); i++){ for(unsigned int i = 0; i < entities.size(); i++){
for(unsigned int j = 0; j < entities[i]->getNumMeshElements(); j++){ for(unsigned int j = 0; j < entities[i]->getNumMeshElements(); j++){
MElement *e = entities[i]->getMeshElement(j); MElement *e = entities[i]->getMeshElement(j);
...@@ -239,9 +247,17 @@ int GModel::writeUNV(const std::string &name, bool saveAll, bool saveGroupsOfNod ...@@ -239,9 +247,17 @@ int GModel::writeUNV(const std::string &name, bool saveAll, bool saveGroupsOfNod
nodes.insert(e->getVertex(k)); nodes.insert(e->getVertex(k));
} }
} }
}
int nele = 0;
for(unsigned int i = 0; i < entities.size(); i++)
nele += entities[i]->getNumMeshElements();
fprintf(fp, "%10d%10d%10d%10d%10d%10d%10d%10d\n", fprintf(fp, "%10d%10d%10d%10d%10d%10d%10d%10d\n",
gr, 0, 0, 0, 0, 0, 0, (int)nodes.size()); it->first, 0, 0, 0, 0, 0, 0, (int)nodes.size() + nele);
fprintf(fp, "PERMANENT GROUP%d\n", gr++); fprintf(fp, "%s\n", physicalName(this, dim, it->first).c_str());
if(saveGroupsOfNodes){
int row = 0; int row = 0;
for(std::set<MVertex*>::iterator it2 = nodes.begin(); it2 != nodes.end(); it2++){ for(std::set<MVertex*>::iterator it2 = nodes.begin(); it2 != nodes.end(); it2++){
if(row == 2) { if(row == 2) {
...@@ -253,6 +269,22 @@ int GModel::writeUNV(const std::string &name, bool saveAll, bool saveGroupsOfNod ...@@ -253,6 +269,22 @@ int GModel::writeUNV(const std::string &name, bool saveAll, bool saveGroupsOfNod
} }
fprintf(fp, "\n"); fprintf(fp, "\n");
} }
{
int row = 0;
for(unsigned int i = 0; i < entities.size(); i++){
for(unsigned int j = 0; j < entities[i]->getNumMeshElements(); j++){
MElement *e = entities[i]->getMeshElement(j);
if(row == 2) {
fprintf(fp, "\n");
row = 0;
}
fprintf(fp, "%10d%10d%10d%10d", 8, e->getNum(), 0, 0);
row++;
}
}
fprintf(fp, "\n");
}
} }
fprintf(fp, "%6d\n", -1); fprintf(fp, "%6d\n", -1);
} }
......
2.7.1: updated onelab; better Abaqus and UNV export; small bug and compilation
fixes.
2.7.0 (March 9, 2013): new single-window GUI, with dynamically customizable 2.7.0 (March 9, 2013): new single-window GUI, with dynamically customizable
widget tree; faster STEP/BRep import; arbitrary size image export; faster 2D widget tree; faster STEP/BRep import; arbitrary size image export; faster 2D
Delaunay/Frontal algorithms; full option viewer/editor; many bug fixes. Delaunay/Frontal algorithms; full option viewer/editor; many bug fixes.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment