~ubuntu-branches/debian/sid/gmsh/sid

« back to all changes in this revision

Viewing changes to Geo/GModelIO_GEO.cpp

  • Committer: Package Import Robot
  • Author(s): Anton Gladky
  • Date: 2015-08-26 22:45:27 UTC
  • mfrom: (1.3.25)
  • Revision ID: package-import@ubuntu.com-20150826224527-wiqnz3dwz6ap8tty
Tags: 2.10.1+dfsg1-1
* [4c450d1] Update d/watch.
* [90ca918] Imported Upstream version 2.10.1+dfsg1. (Closes: #793245)
* [af26665] Use any-arch instead of list of archs.
* [e94c6d2] Refresh patches.
* [6ab417f] Update d/copyright.

Show diffs side-by-side

added added

removed removed

Lines of Context:
332
332
    }
333
333
  }
334
334
 
335
 
  // create periodic mesh relationships
336
 
  for(std::map<int,int>::iterator it = _geo_internals->periodicEdges.begin();
337
 
      it != _geo_internals->periodicEdges.end(); ++it){
338
 
    GEdge *ge = getEdgeByTag(abs(it->first));
339
 
    if (ge){
340
 
      int MASTER = it->second * (it->first > 0 ? 1 : -1);
341
 
      ge->setMeshMaster(MASTER);
342
 
    }
343
 
  }
344
 
  for(std::map<int,int>::iterator it = _geo_internals->periodicFaces.begin();
345
 
      it != _geo_internals->periodicFaces.end(); ++it){
346
 
    GFace *gf = getFaceByTag(abs(it->first));
347
 
    if (gf)gf->setMeshMaster(it->second * (it->first > 0 ? 1 : -1));
348
 
  }
349
 
  for(eiter it = firstEdge() ; it != lastEdge() ; ++it){
350
 
    int meshMaster = (*it)->meshMaster();
351
 
    if (meshMaster != (*it)->tag()){
352
 
      GEdge *ge_master = getEdgeByTag(abs(meshMaster));
353
 
      if(ge_master)
354
 
        (*it)->getBeginVertex()->setMeshMaster((meshMaster > 0) ? ge_master->getBeginVertex()->tag() :
355
 
                                               ge_master->getEndVertex()->tag());
356
 
      if(ge_master)
357
 
        (*it)->getEndVertex()->setMeshMaster((meshMaster < 0) ? ge_master->getBeginVertex()->tag() :
358
 
                                             ge_master->getEndVertex()->tag());
359
 
    }
 
335
  std::map<int,GEO_Internals::MasterEdge>::iterator peIter =
 
336
    _geo_internals->periodicEdges.begin();
 
337
  for (;peIter!=_geo_internals->periodicEdges.end();++peIter) {
 
338
    int iTarget = peIter->first;
 
339
    GEO_Internals::MasterEdge& me = peIter->second;
 
340
    int iSource = me.tag;
 
341
    GEdge* target = getEdgeByTag(iTarget);
 
342
    GEdge* source = getEdgeByTag(abs(iSource));
 
343
    if (!target)
 
344
      Msg::Error("Unknown target line for periodic connection from %d to %d",
 
345
                 iTarget, iSource);
 
346
    if (!source)
 
347
      Msg::Error("Unknown source line for periodic connection from %d to %d",
 
348
                 iTarget, iSource);
 
349
    if (me.affineTransform.size()==16)
 
350
      target->setMeshMaster(source,me.affineTransform);
 
351
    else
 
352
      target->setMeshMaster(source,me.tag > 0 ? 1 : -1);
 
353
  }
 
354
 
 
355
  std::map<int,GEO_Internals::MasterFace>::iterator pfIter =
 
356
    _geo_internals->periodicFaces.begin();
 
357
  for (;pfIter!=_geo_internals->periodicFaces.end();++pfIter) {
 
358
    int iTarget = pfIter->first;
 
359
    GEO_Internals::MasterFace& mf = pfIter->second;
 
360
    int iSource = mf.tag;
 
361
    GFace* target = getFaceByTag(iTarget);
 
362
    GFace* source = getFaceByTag(iSource);
 
363
    if (!target)
 
364
      Msg::Error("Unknown target surface for periodic connection from %d to %d",
 
365
                 iTarget, iSource);
 
366
    if (!source)
 
367
      Msg::Error("Unknown source surface for periodic connection from %d to %d",
 
368
                 iTarget, iSource);
 
369
    if (mf.affineTransform.size()==16)
 
370
      target->setMeshMaster(source,mf.affineTransform);
 
371
    else
 
372
      target->setMeshMaster(source,mf.edgeCounterparts);
360
373
  }
361
374
 
362
375
  Msg::Debug("Gmsh model (GModel) imported:");
364
377
  Msg::Debug("%d Edges", edges.size());
365
378
  Msg::Debug("%d Faces", faces.size());
366
379
  Msg::Debug("%d Regions", regions.size());
367
 
 
368
380
  return 1;
369
381
}
370
382
 
483
495
int GModel::writeGEO(const std::string &name, bool printLabels, bool onlyPhysicals)
484
496
{
485
497
  FILE *fp = Fopen(name.c_str(), "w");
 
498
  if(!fp){
 
499
    Msg::Error("Could not open file '%s'", name.c_str());
 
500
    return 0;
 
501
  }
486
502
 
487
503
  std::map<double, std::string> meshSizeParameters;
488
504
  int cpt = 0;
533
549
  if(getFields()->getBackgroundField() > 0)
534
550
    fprintf(fp, "Background Field = %i;\n", getFields()->getBackgroundField());
535
551
 
536
 
  if(fp) fclose(fp);
 
552
  fclose(fp);
537
553
  return 1;
538
554
}