Skip to content
Snippets Groups Projects
Commit fecf9c26 authored by Matti Pellika's avatar Matti Pellika
Browse files

Save mesh elements of homology generators in GModel and MSH file as new physical

entities.
parent 2c925a76
No related branches found
No related tags found
No related merge requests found
...@@ -885,10 +885,24 @@ void Chain::createPView(){ ...@@ -885,10 +885,24 @@ void Chain::createPView(){
data.insert(std::make_pair(e->getNum(), coeffs)); data.insert(std::make_pair(e->getNum(), coeffs));
} }
std::map<int, std::vector<MElement*> > map; int max[4];
map.insert(std::make_pair(0, elements)); for(int i = 0; i < 4; i++) max[i] = _model->getMaxElementaryNumber(i);
_model->storeElementsInEntities(map); int entityNum = *std::max_element(max,max+4) + 1;
for(int i = 0; i < 4; i++) max[i] = _model->getMaxPhysicalNumber(i);
int physicalNum = *std::max_element(max,max+4) + 1;
std::map<int, std::vector<MElement*> > entityMap;
//int entityNum = _model->getMaxElementaryNumber(getDim())+1;
entityMap[entityNum] = elements;
std::map<int, std::map<int, std::string> > physicalMap;
std::map<int, std::string> physicalInfo;
//int physicalNum = _model->getMaxPhysicalNumber(getDim())+1;
physicalInfo[physicalNum]=getName();
physicalMap[entityNum] = physicalInfo;
_model->storeChain(getDim(), entityMap, physicalMap);
_model->setPhysicalName(getName(), getDim(), physicalNum);
if(!data.empty()) PView *chain = new PView(getName(), "ElementData", getGModel(), data, 0, 1); if(!data.empty()) PView *chain = new PView(getName(), "ElementData", getGModel(), data, 0, 1);
return; return;
......
...@@ -443,8 +443,11 @@ class GModel ...@@ -443,8 +443,11 @@ class GModel
static void registerBindings(binding *b); static void registerBindings(binding *b);
void storeElementsInEntities(std::map<int, std::vector<MElement*> > &map){ // Store mesh elements of a chain in a new elementary and physical entity
_storeElementsInEntities(map); void storeChain(int dim, std::map<int, std::vector<MElement*> > &entityMap,
std::map<int, std::map<int, std::string> > &physicalMap){
_storeElementsInEntities(entityMap);
_storePhysicalTagsInEntities(dim, physicalMap);
} }
}; };
......
...@@ -108,7 +108,7 @@ class Homology ...@@ -108,7 +108,7 @@ class Homology
// write the generators to a file // write the generators to a file
bool writeGeneratorsMSH(std::string fileName, bool binary=false){ bool writeGeneratorsMSH(std::string fileName, bool binary=false){
if(!_model->writeMSH(fileName, 2.0, binary, true, false, 1.0, false)) return false; if(!_model->writeMSH(fileName, 2.0, binary, false, false, 1.0, false)) return false;
for(int i = 0; i < 4; i++){ for(int i = 0; i < 4; i++){
for(int j = 0; j < _generators[i].size(); j++){ for(int j = 0; j < _generators[i].size(); j++){
Chain* chain = _generators[i].at(j); Chain* chain = _generators[i].at(j);
......
...@@ -117,7 +117,7 @@ bool PViewDataGModel::writeMSH(std::string fileName, bool binary) ...@@ -117,7 +117,7 @@ bool PViewDataGModel::writeMSH(std::string fileName, bool binary)
GModel *model = _steps[0]->getModel(); GModel *model = _steps[0]->getModel();
if(!model->writeMSH(fileName, 2.0, binary, true, false, 1.0, false)) return false; if(!model->writeMSH(fileName, 2.0, binary, false, false, 1.0, false)) return false;
// append data // append data
FILE *fp = fopen(fileName.c_str(), binary ? "ab" : "a"); FILE *fp = fopen(fileName.c_str(), binary ? "ab" : "a");
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment