Commit 12f4ab37 authored by Christophe Geuzaine's avatar Christophe Geuzaine

meshMaster() -> getMeshMaster() to match the rest of the code

parent 6c68a9b0
......@@ -2300,8 +2300,8 @@ gmsh::model::mesh::getPeriodicNodes(const int dim, const int tag,
Msg::Error("%s does not exist", _getEntityName(dim, tag).c_str());
throw 2;
}
if(ge->meshMaster() != ge) {
tagMaster = ge->meshMaster()->tag();
if(ge->getMeshMaster() != ge) {
tagMaster = ge->getMeshMaster()->tag();
for(std::map<MVertex *, MVertex *>::iterator it =
ge->correspondingVertices.begin();
it != ge->correspondingVertices.end(); ++it)
......
......@@ -140,9 +140,6 @@ void GEntity::setMeshMaster(GEntity *gMaster, const std::vector<double> &tfo)
updateCorrespondingVertices();
}
// gets the entity from which the mesh will be copied
GEntity *GEntity::meshMaster() const { return _meshMaster; }
void GEntity::updateVertices(const std::map<MVertex *, MVertex *> &old2new)
{
// update the list of the vertices
......
......@@ -290,8 +290,8 @@ public:
}
virtual std::vector<int> getPhysicalEntities() { return physicals; }
// returns the master entity (for mesh)
GEntity *meshMaster() const;
// handle the master entity for periodic meshes
GEntity *getMeshMaster() const { return _meshMaster; }
void setMeshMaster(GEntity *);
void setMeshMaster(GEntity *, const std::vector<double> &);
void updateCorrespondingVertices();
......
......@@ -1759,7 +1759,7 @@ void GFace::setMeshMaster(GFace *master, const std::vector<double> &tfo)
}
GEdge *masterEdge = mv2eIter->second;
if(masterEdge->meshMaster() != localEdge) {
if(masterEdge->getMeshMaster() != localEdge) {
localEdge->setMeshMaster(masterEdge, tfo);
Msg::Info("Setting edge master %d - %d", localEdge->tag(),
masterEdge->tag());
......@@ -2123,7 +2123,7 @@ bool GFace::reorder(const int elementType, const std::vector<int> &ordering)
void GFace::alignElementsWithMaster()
{
GEntity *master = meshMaster();
GEntity *master = getMeshMaster();
if(master != this) {
std::set<MFace, Less_Face> srcFaces;
......
......@@ -2363,7 +2363,7 @@ void GModel::alignPeriodicBoundaries()
for(eiter it = firstEdge(); it != lastEdge(); ++it) {
GEdge *tgt = *it;
GEdge *src = dynamic_cast<GEdge *>(tgt->meshMaster());
GEdge *src = dynamic_cast<GEdge *>(tgt->getMeshMaster());
if(src != NULL && src != tgt) {
// compose a search list on master edge
......@@ -2445,7 +2445,7 @@ void GModel::alignPeriodicBoundaries()
for(GModel::fiter it = firstFace(); it != lastFace(); ++it) {
GFace *tgt = *it;
GFace *src = dynamic_cast<GFace *>(tgt->meshMaster());
GFace *src = dynamic_cast<GFace *>(tgt->getMeshMaster());
if(src != NULL && src != tgt) {
std::map<MFace, MElement *, Less_Face> srcElmts;
......
......@@ -667,13 +667,13 @@ void writeMSHPeriodicNodes(FILE *fp, std::vector<GEntity *> &entities,
{
int count = 0;
for(unsigned int i = 0; i < entities.size(); i++)
if(entities[i]->meshMaster() != entities[i]) count++;
if(entities[i]->getMeshMaster() != entities[i]) count++;
if(!count) return;
fprintf(fp, "$Periodic\n");
fprintf(fp, "%d\n", count);
for(unsigned int i = 0; i < entities.size(); i++) {
GEntity *g_slave = entities[i];
GEntity *g_master = g_slave->meshMaster();
GEntity *g_master = g_slave->getMeshMaster();
if(g_slave != g_master) {
fprintf(fp, "%d %d %d\n", g_slave->dim(), g_slave->tag(),
g_master->tag());
......
......@@ -344,7 +344,7 @@ static bool readMSH4Entities(GModel *const model, FILE *fp, bool partition,
default: break;
}
}
if(ghostTags != 0){
delete[] ghostTags;
}
......@@ -2336,7 +2336,7 @@ static void writeMSH4PeriodicNodes(GModel *const model, FILE *fp,
std::vector<GEntity *> entities;
model->getEntities(entities);
for(unsigned int i = 0; i < entities.size(); i++)
if(entities[i]->meshMaster() != entities[i]) count++;
if(entities[i]->getMeshMaster() != entities[i]) count++;
if(!count) return;
......@@ -2351,7 +2351,7 @@ static void writeMSH4PeriodicNodes(GModel *const model, FILE *fp,
for(unsigned int i = 0; i < entities.size(); i++) {
GEntity *g_slave = entities[i];
GEntity *g_master = g_slave->meshMaster();
GEntity *g_master = g_slave->getMeshMaster();
if(g_slave != g_master) {
if(binary) {
......
......@@ -122,7 +122,7 @@ GeomMeshMatcher::matchVertices(GModel* m1, GModel *m2, bool& ok)
num_matched_vertices++;
}
}
if(num_matched_vertices != num_total_vertices) ok = false;
Msg::Info("Matched %i vertices out of %i.", num_matched_vertices,
num_total_vertices);
......@@ -162,12 +162,12 @@ GeomMeshMatcher::matchEdges(GModel* m1, GModel* m2,
GVertex* v3 = e2->getBeginVertex();
GVertex* v4 = e2->getEndVertex();
if (v3 == v4) {
Msg::Debug("Found a loop (%i) in the mesh %i %i",
Msg::Debug("Found a loop (%i) in the mesh %i %i",
e2->tag(), v3->tag(), v3->tag());
common_edges.push_back(e2);
}
}
}
}
else {
bool ok1 = false;
bool ok2 = false;
......@@ -211,11 +211,11 @@ GeomMeshMatcher::matchEdges(GModel* m1, GModel* m2,
e1->tag(),
choice->tag());
coresp_e->push_back(Pair<GEdge*,GEdge*>(e1, choice));
// --- copy topological information
// --- copy topological information
//choice->setTag(e1->tag());
choice->physicals = e1->physicals;
num_matched_edges++;
}
......@@ -293,7 +293,7 @@ GeomMeshMatcher:: matchFaces(GModel* m1, GModel* m2,
if (choice) {
Msg::Debug("Faces %i (geom) and %i (mesh) match.",f1->tag(),choice->tag());
coresp_f->push_back(Pair<GFace*,GFace*>(f1,choice));
// --- copy topological information
// --- copy topological information
choice->setTag(f1->tag());
f1->physicals = choice->physicals;
num_matched_faces++;
......@@ -393,10 +393,10 @@ GeomMeshMatcher::matchRegions(GModel* m1, GModel* m2,
}
}
coresp_r->push_back(Pair<GRegion*,GRegion*>((GRegion*) *entity1,choice));
choice->setTag(((GRegion*) *entity1)->tag());
(*entity1)->physicals = choice->physicals;
num_matched_regions++;
}
}
......@@ -570,7 +570,7 @@ int GeomMeshMatcher::forceTomatch(GModel *geom, GModel *mesh, const double TOL)
MVertex *v2 = geom->getMeshVertexByTag((*it)->quadrangles[i]->getVertex(1)->getNum());
MVertex *v3 = geom->getMeshVertexByTag((*it)->quadrangles[i]->getVertex(2)->getNum());
MVertex *v4 = geom->getMeshVertexByTag((*it)->quadrangles[i]->getVertex(3)->getNum());
if (v1->onWhat()->dim() == 2)
((GFace*)v1->onWhat())->quadrangles.push_back(new MQuadrangle(v1,v2,v3,v4));
else if (v2->onWhat()->dim() == 2)
......@@ -600,7 +600,7 @@ static void copy_periodicity (std::vector<Pair<GEType*, GEType*> >& eCor,
for (;srcIter!=eMap.end();++srcIter) {
GEType* oldTgt = srcIter->first;
GEType* oldSrc = dynamic_cast<GEType*> (oldTgt->meshMaster());
GEType* oldSrc = dynamic_cast<GEType*> (oldTgt->getMeshMaster());
if (oldSrc != NULL && oldSrc != oldTgt) {
......@@ -675,7 +675,7 @@ static bool apply_periodicity (std::vector<Pair<GEType*, GEType*> >& eCor)
static void copy_vertices (GVertex *to, GVertex *from,
static void copy_vertices (GVertex *to, GVertex *from,
std::map<MVertex*,MVertex*> &_mesh_to_geom){
to->deleteMesh();
......@@ -688,7 +688,7 @@ static void copy_vertices (GVertex *to, GVertex *from,
}
}
}
static void copy_vertices (GRegion *to, GRegion *from,
static void copy_vertices (GRegion *to, GRegion *from,
std::map<MVertex*,MVertex*> &_mesh_to_geom){
to->deleteMesh();
......@@ -701,7 +701,7 @@ static void copy_vertices (GRegion *to, GRegion *from,
}
}
}
static void copy_vertices (GEdge* to, GEdge* from,
static void copy_vertices (GEdge* to, GEdge* from,
std::map<MVertex*,MVertex*> &_mesh_to_geom){
to->deleteMesh();
if (!from){
......@@ -723,7 +723,7 @@ static void copy_vertices (GEdge* to, GEdge* from,
}
}
static void copy_vertices (GFace *to, GFace *from,
static void copy_vertices (GFace *to, GFace *from,
std::map<MVertex*,MVertex*> &_mesh_to_geom){
for (unsigned int i=0;i<from->mesh_vertices.size();i++){
......@@ -733,20 +733,20 @@ static void copy_vertices (GFace *to, GFace *from,
double DDD = ( v_from->x() - gp.x()) * ( v_from->x() - gp.x()) +
( v_from->y() - gp.y()) * ( v_from->y() - gp.y()) +
( v_from->z() - gp.z()) * ( v_from->z() - gp.z()) ;
if (sqrt(DDD) > 1.e-1) Msg::Error("Impossible to match point: "
"original point (%f,%f,%f),"
"New point (%f,%f,%f)",
v_from->x(), v_from->y(), v_from->z(),
gp.x(), gp.y(), gp.z());
else if (sqrt(DDD) > 1.e-3) Msg::Warning("One mesh vertex (%f,%f,%f) of GFace %d \n"
"is difficult to match : "
"closest point (%f,%f,%f)",
v_from->x(), v_from->y(), v_from->z(),
to->tag(),gp.x(), gp.y(), gp.z());
MFaceVertex *v_to = new MFaceVertex (v_from->x(),v_from->y(),v_from->z(),
MFaceVertex *v_to = new MFaceVertex (v_from->x(),v_from->y(),v_from->z(),
to, gp.u(),gp.v() );
to->mesh_vertices.push_back(v_to);
//SPoint2 param;
......@@ -766,9 +766,9 @@ static void copy_elements (std::vector<ELEMENT*> &to,
ELEMENT *e = from[i];
std::vector<MVertex*> nodes;
for(std::size_t j=0;j<e->getNumVertices();j++) {
std::map<MVertex*,MVertex*>::iterator vIter = _mesh_to_geom.find(e->getVertex(j));
if (vIter ==_mesh_to_geom.end()) {
Msg::Error("Could not find match for vertex %i during element copy "
"while matching discrete to actual CAD",
......@@ -804,7 +804,7 @@ void copy_elements (GModel *geom, GModel *mesh, std::map<MVertex*,MVertex*> &_me
std::vector<Pair<GEdge* , GEdge* > > *coresp_e,
std::vector<Pair<GFace* , GFace* > > *coresp_f,
std::vector<Pair<GRegion*, GRegion*> > *coresp_r){
// copy all elements
for (unsigned int i=0;i<coresp_v->size();++i) {
......@@ -845,7 +845,7 @@ int GeomMeshMatcher::match(GModel *geom, GModel *mesh)
GModel::setCurrent(geom);
geom->setPhysicalNames(mesh->getPhysicalNames());
bool ok = true;
std::vector<Pair<GVertex*,GVertex*> > *coresp_v(NULL);
......@@ -897,6 +897,6 @@ int GeomMeshMatcher::match(GModel *geom, GModel *mesh)
if (ok) Msg::StatusBar(true,"Matched successfully mesh to CAD in %g s",Cpu()-t1);
else Msg::Error("Failed to match mesh to CAD, please check");
return ok ? 1:0;
}
......@@ -311,9 +311,9 @@ static void Mesh0D(GModel *m)
}
for(GModel::viter it = m->firstVertex(); it != m->lastVertex(); ++it) {
GVertex *gv = *it;
if(gv->meshMaster() != gv) {
if(gv->getMeshMaster() != gv) {
if(gv->correspondingVertices.empty()) {
GVertex *master = dynamic_cast<GVertex *>(gv->meshMaster());
GVertex *master = dynamic_cast<GVertex *>(gv->getMeshMaster());
if(master)
gv->correspondingVertices[gv->mesh_vertices[0]] =
master->mesh_vertices[0];
......
......@@ -1245,7 +1245,7 @@ static void updatePeriodicEdgesAndFaces(GModel *m)
for(GModel::eiter it = m->firstEdge(); it != m->lastEdge(); ++it) {
GEdge *tgt = *it;
GEdge *src = dynamic_cast<GEdge *>(tgt->meshMaster());
GEdge *src = dynamic_cast<GEdge *>(tgt->getMeshMaster());
if(src != NULL && src != tgt) {
std::map<MVertex *, MVertex *> &v2v = tgt->correspondingVertices;
......@@ -1318,7 +1318,7 @@ static void updatePeriodicEdgesAndFaces(GModel *m)
for(GModel::fiter it = m->firstFace(); it != m->lastFace(); ++it) {
GFace *tgt = *it;
GFace *src = dynamic_cast<GFace *>(tgt->meshMaster());
GFace *src = dynamic_cast<GFace *>(tgt->getMeshMaster());
if(src != NULL && src != tgt) {
Msg::Info(
"Constructing high order periodicity for face connection %d - %d",
......
......@@ -556,11 +556,11 @@ void meshGEdge::operator()(GEdge *ge)
if(MeshExtrudedCurve(ge)) return;
if(ge->meshMaster() != ge) {
GEdge *gef = dynamic_cast<GEdge *>(ge->meshMaster());
if(ge->getMeshMaster() != ge) {
GEdge *gef = dynamic_cast<GEdge *>(ge->getMeshMaster());
if(gef->meshStatistics.status == GEdge::PENDING) return;
Msg::Info("Meshing curve %d (%s) as a copy of %d", ge->tag(),
ge->getTypeString().c_str(), ge->meshMaster()->tag());
ge->getTypeString().c_str(), ge->getMeshMaster()->tag());
copyMesh(gef, ge, ge->masterOrientation);
ge->meshStatistics.status = GEdge::DONE;
return;
......
......@@ -2404,7 +2404,7 @@ static bool meshGeneratorPeriodic(GFace *gf, bool repairSelfIntersecting1dMesh,
}
// look for a triangle that has a negative node and recursively tag all
// exterior triangles
{
......@@ -2501,7 +2501,7 @@ static bool meshGeneratorPeriodic(GFace *gf, bool repairSelfIntersecting1dMesh,
sprintf(name, "surface%d-recovered-param.pos", gf->tag());
outputScalarField(m->triangles, name, 1, gf);
}
{
// Call this function to untangle elements in Cartesian space
int nb_swap;
......@@ -2767,21 +2767,21 @@ void meshGFace::operator()(GFace *gf, bool print)
// because meshGenerator never called
if(MeshTransfiniteSurface(gf)) return;
if(MeshExtrudedSurface(gf)) return;
if(gf->meshMaster() != gf) {
GFace *gff = dynamic_cast<GFace *>(gf->meshMaster());
if(gf->getMeshMaster() != gf) {
GFace *gff = dynamic_cast<GFace *>(gf->getMeshMaster());
if(gff) {
if(gff->meshStatistics.status != GFace::DONE) {
gf->meshStatistics.status = GFace::PENDING;
return;
}
Msg::Info("Meshing face %d (%s) as a copy of %d", gf->tag(),
gf->getTypeString().c_str(), gf->meshMaster()->tag());
gf->getTypeString().c_str(), gf->getMeshMaster()->tag());
copyMesh(gff, gf);
gf->meshStatistics.status = GFace::DONE;
return;
}
else
Msg::Warning("Unknown mesh master face %d", gf->meshMaster()->tag());
Msg::Warning("Unknown mesh master face %d", gf->getMeshMaster()->tag());
}
const char *algo = "Unknown";
......
......@@ -37,7 +37,7 @@ OptHomPeriodicity::OptHomPeriodicity(std::vector<GEntity*> &entities)
// MVertex on GVertex cannot move
if (entities[i]->dim() == 0) continue;
GEntity *master = entities[i]->meshMaster();
GEntity *master = entities[i]->getMeshMaster();
if (master != entities[i]) {
_master2slave.insert(std::make_pair(master, entities[i]));
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment