-// Copyright (C) 2007-2016 CEA/DEN, EDF R&D
+// Copyright (C) 2007-2020 CEA/DEN, EDF R&D
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
CVWtab *montab;
bool ok;
- if (verbose>=6)std::cout<<"Read file '"<<FileName.toLatin1().constData()<<std::endl;
- if (!Ff.is_open()){
- std::cerr<<"Problem file '"<<FileName.toLatin1().constData()<<"' not open\n"<<std::endl;
+ if (verbose>=6) std::cout<<"Read file '"<<FileName.toLatin1().constData()<<std::endl;
+ if (!Ff.is_open())
+ {
+ std::cerr<<"Problem file '"<<FileName.toLatin1().constData()<<"' not open"<<std::endl;
+ // std::cout<<"Default global numerotation nb verts "<<vert<<" nb edges "<<edge<<" nb trias "<<tria<<" nb tetras "<<tetr<<std::endl;
return false;
}
-
- //Lit les donnees :
- Ff>>vert>>edge>>tria>>tetr;
- std::cout<<"First line "<<vert<<" "<<edge<<" "<<tria<<" "<<tetr<<std::endl;
+ else
+ {
+ //Lit les donnees :
+ Ff>>vert>>edge>>tria>>tetr;
+ std::cout<<"Global numerotation nb verts "<<vert<<" nb edges "<<edge<<" nb trias "<<tria<<" nb tetras "<<tetr<<std::endl;
+ }
if (vert<0)
{
count=vert;
tmint=new med_int[count];
- for (int i=0; i<count; i++) Ff>>tmint[i];
- if (verbose>4) std::cout<<"Vertices ("<<count<<" ) "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<std::endl;
+ for (long i=0; i<count; i++) Ff>>tmint[i];
+ if (verbose>4) std::cout<<"Vertices ("<<count<<") "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<std::endl;
montab=new CVWtab(count,tmint);
tmp=tmp.sprintf("GL%ld VE",this->nofile);
count=edge;
tmint=new med_int[count];
- for (int i=0; i<count; i++) Ff>>tmint[i];
+ for (long i=0; i<count; i++) Ff>>tmint[i];
if (verbose>4) std::cout<<"Edges ("<<count<<") "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<std::endl;
montab=new CVWtab(count,tmint);
count=tria;
tmint=new med_int[count];
- for (int i=0; i<count; i++) Ff>>tmint[i];
+ for (long i=0; i<count; i++) Ff>>tmint[i];
if (verbose>4) std::cout<<"Triangles ("<<count<<") "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<std::endl;
montab=new CVWtab(count,tmint);
count=tetr;
tmint=new med_int[count];
- for (int i=0; i<count; i++) Ff>>tmint[i];
+ for (long i=0; i<count; i++) Ff>>tmint[i];
if (verbose>4) std::cout<<"Tetrahedra ("<<count<<") "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<std::endl;
montab=new CVWtab(count,tmint);
return true;
}
+///************************************
+bool ghs3dprl_mesh_wrap::ReadFileDefaultGLOBAL(long vert, long edge, long tria, long tetr)
+//default like read file .global ascii (no xml) when inexisting when multithread
+{
+ QString tmp;
+ long count=0;
+ med_int *tmint;
+ CVWtab *montab;
+ bool ok;
+
+ //Simule les donnees :
+ std::cout<<"Default Global numerotation nb verts "<<vert<<" nb edges "<<edge<<" nb trias "<<tria<<" nb tetras "<<tetr<<std::endl;
+
+ count=vert;
+ tmint=new med_int[count];
+ for (long i=0; i<count; i++) tmint[i] = i+1;
+ if (verbose>4) std::cout<<"Default Vertices ("<<count<<") "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<std::endl;
+
+ montab=new CVWtab(count,tmint);
+ tmp=tmp.sprintf("GL%ld VE",this->nofile);
+ ok=this->insert_key(tmp,montab);
+
+ count=edge;
+ tmint=new med_int[count];
+ for (long i=0; i<count; i++) tmint[i] = i+1;
+ if (verbose>4) std::cout<<"Default Edges ("<<count<<") "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<std::endl;
+
+ montab=new CVWtab(count,tmint);
+ tmp=tmp.sprintf("GL%ld ED",this->nofile);
+ ok=this->insert_key(tmp,montab);
+
+ count=tria;
+ tmint=new med_int[count];
+ for (long i=0; i<count; i++) tmint[i] = i+1;
+ if (verbose>4) std::cout<<"Default Triangles ("<<count<<") "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<std::endl;
+
+ montab=new CVWtab(count,tmint);
+ tmp=tmp.sprintf("GL%ld FA",this->nofile);
+ ok=this->insert_key(tmp,montab);
+
+ count=tetr;
+ tmint=new med_int[count];
+ for (long i=0; i<count; i++) tmint[i] = i+1;
+ if (verbose>4) std::cout<<"Default Tetrahedra ("<<count<<") "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count-1]<<std::endl;
+
+ montab=new CVWtab(count,tmint);
+ tmp=tmp.sprintf("GL%ld EL",this->nofile);
+ ok=this->insert_key(tmp,montab);
+
+ return true;
+}
+
//************************************
bool ghs3dprl_mesh_wrap::ReadFileFACES(const QString FileName)
//read file .faces (wrap)
getline(Ff,line);
getline(Ff,line);
+
+ getline(Ff,line); // get Edges or Triangle, because sometimes Edges absent
- if (!(getline(Ff,line) && (line.find("Edges")==0)))
- {
- std::cerr<<"Problem on line 'Edges' of file '"<<FileName.toLatin1().constData()<<"' :found '"<<line<<"' instead"<<std::endl;
- return false;
- }
- if (getline(Ff,line))
- {
- tmp=line.c_str();
- Medge=tmp.toLong(&ok);
- }
- else
+ if (!line.find("Edges")==0)
{
- std::cerr<<"Problem on line 'Edges' of file: a positive integer is expected"<<std::endl;
- return false;
+ std::cerr<<"absent line 'Edges' of file '"<<FileName.toLatin1().constData()<<"' :found '"<<line<<"' instead"<<std::endl;
}
- if (Medge<=0)
+ else
{
- std::cerr<<"Problem on line 'Edges' of file: a positive integer is expected"<<std::endl;
- return false;
- }
+ if (getline(Ff,line))
+ {
+ tmp=line.c_str();
+ Medge=tmp.toLong(&ok);
+ }
+ else
+ {
+ std::cerr<<"Problem on line 'Edges' of file: a positive integer is expected"<<std::endl;
+ return false;
+ }
+ if (Medge<=0)
+ {
+ std::cerr<<"Problem on line 'Edges' of file: a positive integer is expected"<<std::endl;
+ return false;
+ }
- count=Medge;
- tmint=new med_int[count*2]; //*3
- for (int i=0; i<count*2; i=i+2) {
- Ff>>tmint[i]>>tmint[i+1]>>garbage;
+ count=Medge;
+ tmint=new med_int[count*2]; //*3
+ for (int i=0; i<count*2; i=i+2) {
+ Ff>>tmint[i]>>tmint[i+1]>>garbage;
+ }
+ if (verbose>4) std::cout<<"Edges ("<<count<<") "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count*2-1]<<std::endl;
+ montab=new CVWtab(count*2,tmint);
+ tmp=tmp.sprintf("NB%ld ED",this->nofile); //TODO see if it could serve
+ ok=this->insert_key(tmp,montab);
+
+ getline(Ff,line);
+ getline(Ff,line);
+ getline(Ff,line);
}
- if (verbose>4) std::cout<<"Edges ("<<count<<") "<<tmint[0]<<" "<<tmint[1]<<"... "<<tmint[count*2-1]<<std::endl;
- montab=new CVWtab(count*2,tmint);
- tmp=tmp.sprintf("NB%ld ED",this->nofile); //TODO see if it could serve
- ok=this->insert_key(tmp,montab);
-
- getline(Ff,line);
- getline(Ff,line);
- if (!(getline(Ff,line) && (line.find("Triangles")==0)))
+ if (!line.find("Triangles")==0)
{
std::cerr<<"Problem on line 'Triangles' of file '"<<FileName.toLatin1().constData()<<"' :found '"<<line<<"' instead"<<std::endl;
return false;
std::cout<<"MeshNumberOfTetrahedra="<<Mtetra<<std::endl;
}
+ this->nbvert=Mvert; // for current idom
+ this->nbedge=Medge;
+ this->nbtria=Mtria;
+ this->nbtetr=Mtetra;
+
count=Mtetra;
tmint=new med_int[count*4];
for (int i=0; i<count*4; i=i+4) Ff>>tmint[i]>>tmint[i+1]>>tmint[i+2]>>tmint[i+3]>>garbage;
//for (int ifile=1; ifile <= this->nbfiles; ifile++)
//for (int ineig=ifile+1; ineig <= this->nbfiles; ineig++)
bool swap=false;
+ if (verbose>4)std::cout<<"test_vertices_wrap on nb files "<<this->nbfiles<<std::endl;
for (int ifile=this->nbfiles; ifile >= 1; ifile--)
for (int ineig=this->nbfiles; ineig >= ifile+1; ineig--)
{
{
QString tmp;
- //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!first call
+ //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!first call create xml doc node
if (idom==1)
{
//define master file (.xml) in memory
med_int majeur,mineur,release;
//Quelle version de MED est utilisee
MEDlibraryNumVersion(&majeur,&mineur,&release);
- if (verbose>0) fprintf(stdout,"Files write with MED V%d.%d.%d\n",majeur,mineur,release);
+ if (verbose>0) fprintf(stdout,"File write %s with MED V%d.%d.%d\n",filemaster.c_str(),majeur,mineur,release);
node = xmlNewChild(root_node, 0, BAD_CAST "version",0);
//xmlNewProp(node, BAD_CAST "maj", BAD_CAST int2string2(majeur).c_str());
xmlNewProp(node, BAD_CAST "maj", BAD_CAST i2a(majeur).c_str());
//Description tag
node = xmlNewChild(root_node,0, BAD_CAST "description",0);
- xmlNewProp(node, BAD_CAST "what", BAD_CAST "tetrahedral mesh by MeshGems-Tetra-hpc (formerly tepal)");
+ // .../INSTALL/MeshGems/include/meshgems/meshgems.h:11:#define MESHGEMS_VERSION_LONG "2.9-6"
+ xmlNewProp(node, BAD_CAST "what", BAD_CAST "tetrahedral mesh by MeshGems-Tetra-hpc 2.9-6 2019");
#ifdef WIN32
SYSTEMTIME present;
GetLocalTime ( &present );
xmlNewProp(mesh_node, BAD_CAST "name", BAD_CAST domainname.c_str());
}
- //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!all calls
+ //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!all calls add xml idom node
{
+ fprintf(stdout,"Xml node write %s idom %d\n",filemaster.c_str(), idom);
char *hostname = getenv("HOSTNAME");
node = xmlNewChild(files_node,0,BAD_CAST "subfile",0);
xmlNewProp(node, BAD_CAST "id", BAD_CAST i2a(idom).c_str());
node2 = xmlNewChild(node, 0, BAD_CAST "name", BAD_CAST distfilename);
+
if (hostname == NULL)
node2 = xmlNewChild(node, 0, BAD_CAST "machine",BAD_CAST "localhost");
else
//xmlNewProp(node2, BAD_CAST "number", BAD_CAST i2a(nbtetra4).c_str());
//tepal2med_info about joints of one subdomain
- xmlAddChild(node,joints_node);
+ fprintf(stdout,"MeshGems 2.9-6 tetra-hpc joints are not implemented\n"); //MeshGems 2.9-6 Salome 9.5.0 jan 2020
+ // not implemented ... empty joints ... does NOT work ... xmlAddChild(node,joints_node);
//tepal2med_info about groups and families of one subdomain
xmlAddChild(node,families.xml_groups());
}
//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!last call
+ fprintf(stdout,"xml node idom %d/%d nb tetras total %d\n", idom, nbfilestot, nbtetrastotal);
if (idom==nbfilestot)
{
+ fprintf(stdout,"File write %s as last idom nb tetras total %d\n",filemaster.c_str(), nbtetrastotal);
node2 = xmlNewChild(info_node, 0, BAD_CAST "global",0);
xmlNewProp(node2, BAD_CAST "tetrahedra_number", BAD_CAST i2a(nbtetrastotal).c_str());
//save masterfile
//for (idom=1; idom<=nbfilestot; idom++) {
if (for_multithread) {
nbfilestot=1;
- std::cout<<"\nset Number0fFiles as multithread="<<nbfilestot<<std::endl;
+ std::cout<<"\nset NumberOfFiles only one domain file as multithread="<<nbfilestot<<std::endl;
}
- if (verbose>6) std::cout<<"\nNumber0fFiles="<<nbfilestot<<std::endl;
+
+ // if (verbose>6)
+ std::cout<<"\nNumberOfFiles="<<nbfilestot<<std::endl;
+
for (idom=1; idom<=nbfilestot; idom++) {
+ this->nbvert=0; // will be set for current loop idom
+ this->nbedge=0;
+ this->nbtria=0;
+ this->nbtetr=0;
+
this->nofile=idom;
//restore initial context of families
if (idom>1) families=intermediatesfamilies;
//std::cout<<"<"<<distfilename<<">"<<std::endl;
fid=MEDfileOpen(distfilename,MED_ACC_CREAT);
if (fid<0) {std::cerr<<"Problem MEDfileOpen "<<distfilename<<std::endl; goto erreur;}
- if (verbose>0){
- if (verbose>2) std::cout<<std::endl;
+ if (verbose>2) {
+ std::cout<<std::endl;
std::cout<<"CreateMEDFile "<<idom<<" <"<<distfilename<<">\n";
}
if (verbose>4) std::cout<<"\nEnd of Faces ***\n"<<std::endl;
if (!idom_tetras()) {std::cerr<<"Problem on tetrahedra"<<std::endl; goto erreur;}
if (verbose>4) std::cout<<"\nEnd of Tetrahedra ***\n"<<std::endl;
+
//non existing files msg mh-tetra_hpc v2.1.11
//if (!idom_joints()) {std::cerr<<"Problem on Joints"<<std::endl; goto erreur;}
- if (!for_multithread) {
+ // if (!for_multithread)
+ {
if (verbose>6){std::cout<<"\nFinalsFamilies\n"; families.write();}
//for nodes families
nb=create_families(fid,1);
- if (verbose>5)std::cout<<"NumberOfFamiliesNodes="<<nb<<std::endl;
+ if (verbose>5)std::cout<<"NumberOfFamiliesNodes="<<nb<<" name "<<nomfinal<<std::endl;
- err=MEDmeshEntityFamilyNumberWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,MED_NODE,MED_UNDEF_GEOMETRY_TYPE,nbnodes,famnodes);
if (verbose>8)
std::cout<<"MEDmeshEntityFamilyNumberWr nodes "<<nbnodes<<":"<<
famnodes[0]<<"..."<<famnodes[nbnodes-1]<<" "<<std::endl;
+
+ err=MEDmeshEntityFamilyNumberWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,MED_NODE,MED_UNDEF_GEOMETRY_TYPE,nbnodes,famnodes);
delete[] famnodes;
+
if (err<0) std::cerr<<"Problem MEDmeshEntityFamilyNumberWr nodes"<<std::endl;
//for others families
MEDfileClose(fid); //no error
//master.xml writings
- //oktmp=Write_masterxmlMEDfile();
+ oktmp=Write_masterxmlMEDfile();
continue; //and loop on others domains
erreur: //error
if (for_tetrahpc) {
tmp=pathini+casename+"_out"+tmp.sprintf(format_tetra.toLatin1().constData(),idom)+".mesh";
ok=this->ReadFileMESH(tmp);
+ if (for_multithread) { // inexisting file GHS3DPRL_out.000001.global
+ this->ReadFileDefaultGLOBAL(this->nbvert, this->nbedge, this->nbtria, this->nbtetr);
+ }
}
tab=this->restore_key(key); //tab1=this->mestab[key1];
if (!tab) return false;
tmp=tmp.sprintf("NB%d SN",idom);
//qt3 xx=this->remove_key_mesh_wrap(QRegExp(tmp,true,true));
xx=this->remove_key_mesh_wrap(QRegExp(tmp,Qt::CaseSensitive,QRegExp::RegExp));
- nbnodes=tab->size/3;
+ nbnodes=this->nbvert; // for current idom
+
err=MEDmeshNodeCoordinateWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,0.,MED_FULL_INTERLACE,nbnodes,tab->tmflo);
if (err<0) {std::cerr<<"Problem MEDmeshNodeCoordinateWr"<<std::endl; return false;}
if (verbose>4) std::cout<<"NumberOfNodes="<<nbnodes<<std::endl;
delete[] arrayi;
if (err<0) {std::cerr<<"Problem MEDmeshEntityNumberWr of nodes"<<std::endl; return false;}
- if (!for_multithread) {
+ // if (!for_multithread)
+ {
key1=key1.sprintf("GL%d VE",idom); //global numerotation
tab1=this->restore_key(key1); //tab1=this->mestab[key1];
if (!tab1) {
bool ok=true;
QString tmp;
nbseg2=0;
+ this->nbedge=0;
return ok;
}
if (!tab1) return false;
}
nbtria3=tab1->size/3;
+ this->nbtria=nbtria3; // for current idom
+
if (verbose>4) std::cout<<"NumberOfTriangles="<<nbtria3<<std::endl;
//arrayi=new med_int[nbtria3*3];
//ii=0,i=0 ;
if (err<0){std::cerr<<"Problem MEDmeshEntityNumberWr of triangles"<<std::endl; return false;}
//GLx FA=files.GLo FAces
- if (!for_multithread) {
+ // if (!for_multithread)
+ {
key1=key1.sprintf("GL%d FA",idom);
tab1=this->restore_key(key1); //tab1=this->mestab[key1];
if (nbtria3!=tab1->size){std::cerr<<"Problem size GLi FA!=nbtria3!"<<std::endl; return false;}
key=key.sprintf("NB%d VC",idom); //files.NoBoite Vertex Coordinates
tab=this->restore_key(key); //tab1=this->mestab[key1];
- //nbnodes=tab->size/3;
+ nbnodes=tab->size/3;
//writing correspondence nodes-nodes
//two indices for one correspondence
key1=key1.sprintf("NB%d EV",idom); //files.NoBoite Elements Vertices (tetra only)
tab1=this->restore_key(key1); //tab1=this->mestab[key1];
nbtetra4=tab1->size/4;
+ this->nbtetr=nbtetra4; // for current idom
+
nbtetrastotal=nbtetrastotal + nbtetra4;
if (verbose>5)std::cout<<"NumberOftetrahedra="<<nbtetra4<<std::endl;
err=MEDmeshElementConnectivityWr(fid,nomfinal,MED_NO_DT,MED_NO_IT,0.,MED_CELL,MED_TETRA4,MED_NODAL,MED_FULL_INTERLACE,nbtetra4,tab1->tmint);
famtetra4=new med_int[nbtetra4];
for (i=0; i<nbtetra4 ; i++) famtetra4[i]=famnewtetra4;
- if (!for_multithread) {
+ // if (!for_multithread)
+ {
//writing tetrahedra global numbering
//GLx EL=files.GLo ELements
key1=key1.sprintf("GL%d EL",idom);