_NbPart = hyp->GetNbPart();
_KeepFiles = hyp->GetKeepFiles();
_Background = hyp->GetBackground();
- _ToMeshHoles = hyp->GetToMeshHoles();
+ _ToMergeSubdomains = hyp->GetToMergeSubdomains();
+ _ToTagSubdomains = hyp->GetToTagSubdomains();
+ _ToOutputInterfaces = hyp->GetToOutputInterfaces();
+ _ToDiscardSubdomains = hyp->GetToDiscardSubdomains();
}
}
}
//=============================================================================
-// Here we are going to use the GHS3DPRL mesher
+// Here we are going to use the GHS3DPRL mesher for tetra-hpc (formerly tepal in v3 (2014))
bool GHS3DPRLPlugin_GHS3DPRL::Compute(SMESH_Mesh& theMesh,
const TopoDS_Shape& theShape)
+{
+ bool Ok=false;
+ TCollection_AsciiString pluginerror("ghs3dprl: ");
+ SMESHDS_Mesh* meshDS = theMesh.GetMeshDS();
+ //cout<<"GetMeshDS done\n";
+ if (_countSubMesh==0){
+ MESSAGE("GHS3DPRLPlugin_GHS3DPRL::Compute for tetra-hpc");
+ _countTotal=0;
+ TopExp_Explorer expf(meshDS->ShapeToMesh(), TopAbs_SOLID);
+ for ( ; expf.More(); expf.Next() ) _countTotal++;
+ }
+ _countSubMesh++;
+ //cout<<"Compute _countSubMesh "<<_countSubMesh<<endl;
+ //no stuff if multiples submesh, multiple call compute
+ //mesh all in one pass tepal (the last)
+ if (_countSubMesh != _countTotal ) return true;
+
+ //stuff on last call
+ if (_hypothesis==NULL){
+ pluginerror += "No existing parameters/hypothesis for GHS3DPRL";
+ cout <<"\n"<<pluginerror<<"\n\n";
+ error(COMPERR_ALGO_FAILED, pluginerror.ToCString() );
+ return false;
+ }
+ SetParameters(_hypothesis);
+ cout << "\n" << _name << " parameters :\n" << endl;
+ cout << " generic path/name of MED Files = " << _MEDName << endl;
+ cout << " number of partitions = " << _NbPart << endl;
+ cout << " merge subdomains = " << _ToMergeSubdomains << endl;
+ cout << " tag subdomains = " << _ToTagSubdomains << endl;
+ cout << " output interfaces = " << _ToOutputInterfaces << endl;
+ cout << " discard dubdomains = " << _ToDiscardSubdomains << endl;
+ cout << " keep intermediates files (from tetra-hpc) = " << _KeepFiles << endl;
+ cout << " background (from tetra-hpc) = " << _Background << "\n\n";
+
+ //string tmpDir=getTmpDir_new();
+ TCollection_AsciiString
+ tmpDir=getTmpDir(),
+ GHS3DPRL_In,GHS3DPRL_Out,GHS3DPRL_Outxml,
+ run_GHS3DPRL("tetrahpc2med "),rm("rm -f "),run_nokeep_files,
+ NbPart,fileskinmed(""),fileskinmesh(""),path,casenamemed; //_MEDName.c_str());
+
+ casenamemed += (char *)_MEDName.c_str();
+ int n=casenamemed.SearchFromEnd('/');
+ if (n>0) {
+ path=casenamemed.SubString(1,n);
+ casenamemed=casenamemed.SubString(n+1,casenamemed.Length());
+ }
+ else
+ path=tmpDir;
+
+ if (casenamemed.Length()>20){
+ casenamemed=casenamemed.SubString(1,20);
+ cerr<<"MEDName truncated (no more 20 characters) = "<<casenamemed<<endl;
+ }
+ cout<<"path="<<path<<endl;
+ cout<<"casenamemed="<<casenamemed<<endl;
+
+ map <int,int> aSmdsToGHS3DPRLIdMap;
+ map <int,const SMDS_MeshNode*> aGHS3DPRLIdToNodeMap;
+ GHS3DPRL_In = path + "GHS3DPRL";
+ GHS3DPRL_Out = path + casenamemed;
+ GHS3DPRL_Outxml = path + casenamemed + ".xml"; //master file
+ NbPart=_NbPart;
+ //tepal2med --casename=/home/whoami/tmp/GHS3DPRL --number=5 --medname=DOMAIN
+ // --limitswap=1000 --verbose=0 --test=no --menu=no --launchtepal=yes;
+
+ run_GHS3DPRL = run_GHS3DPRL +
+ " --casename=" + GHS3DPRL_In +
+ " --number=" + NbPart +
+ " --medname=" + GHS3DPRL_Out +
+ " --launchtetra=yes";
+ //no more meshhole option
+ //if (_ToMeshHoles) run_GHS3DPRL += " --meshholes=yes"; else run_GHS3DPRL += " --meshholes=no";
+ if (_ToMergeSubdomains) run_GHS3DPRL += " --merge_subdomains=yes"; else run_GHS3DPRL += " --merge_subdomains=no";
+ if (_ToTagSubdomains) run_GHS3DPRL += " --tag_subdomains=yes"; else run_GHS3DPRL += " --tag_subdomains=no";
+ if (_ToOutputInterfaces) run_GHS3DPRL += " --output_interfaces=yes"; else run_GHS3DPRL += " --output_interfaces=no";
+ if (_ToDiscardSubdomains) run_GHS3DPRL += " --discard_subdomains=yes"; else run_GHS3DPRL += " --discard_subdomains=no";
+ if (_Background) run_GHS3DPRL += " --background=yes"; else run_GHS3DPRL += " --background=no";
+ run_nokeep_files = rm +GHS3DPRL_In + "* " + path + "tetrahpc.log";
+ system( run_nokeep_files.ToCString() ); //clean files
+ run_nokeep_files = rm + GHS3DPRL_In + "* ";
+
+ cout<<"GHS3DPRL command : "<<run_GHS3DPRL.ToCString()<<endl;
+ fileskinmesh=path + "GHS3DPRL.mesh";
+ cout<<"Write input file for tetra_hpc.exe "<<fileskinmesh<<"...";
+ GHS3DPRL_Out = path + casenamemed;
+ removeFile( GHS3DPRL_Outxml ); //only the master xml file
+ //Ok=writeGHS3DPRLFiles(GHS3DPRL_In, meshDS, aSmdsToGHS3DPRLIdMap, aGHS3DPRLIdToNodeMap);
+ bool toCreateGroups = false;
+ theMesh.ExportGMF(fileskinmesh.ToCString(), meshDS, toCreateGroups );
+ cout<<" ...done\n";
+ //else {
+ // cout<<" ...NOT done\n";
+ // pluginerror = pluginerror + "problem writing input tepal files " + GHS3DPRL_In + ".mesh";
+
+ //Ecriture dans un fichier MED ?v2.? meme si not Ok
+ //create empty file -> avoid warning message
+ //med_idt fid=MEDouvrir((const char *)fileskinmed.ToCString(),MED_CREATION);
+ //med_err ret=MEDfermer(fid);
+ //fileskinmed=fileskinmed + "cp /home/wambeke/empty.med "+ path + "GHS3DPRL_skin.med";
+ //system( fileskinmed.ToCString() );
+ fileskinmed=path + "GHS3DPRL_skin.med";
+ cout<<"Write file "<<fileskinmed<<"...";
+ theMesh.ExportMED(fileskinmed.ToCString(),"SKIN_INITIAL",true,1);
+ cout<<" ...done\n";
+
+ /*
+ if (!Ok) {
+ error(COMPERR_ALGO_FAILED, pluginerror.ToCString());
+ return false; //pb abandonne
+ }*/
+
+ //sometimes it is better to wait flushing files on slow filesystem...
+ system( "sleep 3" );
+ system( run_GHS3DPRL.ToCString() );
+ system( "sleep 3" );
+
+ //cout<<"!!!reprise plugin!!!"<<endl;
+
+ if (_Background) {
+ pluginerror = pluginerror + "backgrounding... plugin is not waiting for output files "+ casenamemed + "_*.med";
+ cout<<pluginerror<<endl;
+ error(COMPERR_ALGO_FAILED, pluginerror.ToCString());
+ return false; //but it is not a problem but if true my message is overwritten
+ //return true; //but it is not a problem,
+ }
+
+ // read a result, GHS3DPRL_Out is the name of master file (previous xml format)
+ FILE * aResultFile = fopen( GHS3DPRL_Outxml.ToCString(), "r" );
+ if (aResultFile){
+ //Ok = readResult( aResultFile, meshDS, theShape, aGHS3DPRLIdToNodeMap, GHS3DPRL_Out, _nodeRefNumber );
+ Ok = true;
+ Ok = false; //but it is not a problem but if true my message is overwritten
+ fclose(aResultFile);
+ cout<<"GHS3DPRL OK output master file "<<casenamemed<<".xml exist !\n\n";
+ pluginerror = pluginerror + "new tetraedra not in memory, but stored in files "+ casenamemed + "_*.med";
+ cout<<pluginerror<<endl;
+ error(COMPERR_ALGO_FAILED, pluginerror.ToCString());
+ if (!_KeepFiles) system( run_nokeep_files.ToCString() );
+ }
+ else{
+ Ok = false; //it is a problem AND my message is NOT overwritten
+ pluginerror = pluginerror + "output master file " + casenamemed + ".xml do not exist";
+ cout<<pluginerror<<endl;
+ error(COMPERR_ALGO_FAILED, pluginerror.ToCString() );
+ cout<<"GHS3DPRL KO output files "<<GHS3DPRL_Out<<" do not exist ! see intermediates files keeped:\n";
+ TCollection_AsciiString run_list_files("ls -alt ");
+ run_list_files += GHS3DPRL_Out + "* " + GHS3DPRL_In + "* " + path + "tetrahpc.log";
+ system( run_list_files.ToCString() );
+ cout<<endl;
+ }
+ _countSubMesh=0;
+
+
+ return Ok;
+}
+
+//=============================================================================
+// Here we are going to use the GHS3DPRL mesher (old obsolescent version tepal in v1 & v2 (before 2014))
+bool GHS3DPRLPlugin_GHS3DPRL::ComputeForTepal(SMESH_Mesh& theMesh,
+ const TopoDS_Shape& theShape)
{
bool Ok;
TCollection_AsciiString pluginerror("ghs3dprl: ");
cout << "\n" << _name << " parameters :\n" << endl;
cout << " generic path/name of MED Files = " << _MEDName << endl;
cout << " number of partitions = " << _NbPart << endl;
- cout << " mesh holes = " << _ToMeshHoles << endl;
+ //cout << " mesh holes = " << _ToMeshHoles << endl;
+ cout << " mesh holes = " << 1 << endl;
cout << " keep intermediates files (from tepal) = " << _KeepFiles << endl;
cout << " background (from tepal) = " << _Background << "\n\n";
" --number=" + NbPart +
" --medname=" + GHS3DPRL_Out +
" --launchtepal=yes";
- if (_ToMeshHoles) run_GHS3DPRL += " --meshholes=yes"; else run_GHS3DPRL += " --meshholes=no";
+ //if (_ToMeshHoles) run_GHS3DPRL += " --meshholes=yes"; else run_GHS3DPRL += " --meshholes=no";
+ if (1) run_GHS3DPRL += " --meshholes=yes"; else run_GHS3DPRL += " --meshholes=no";
if (_Background) run_GHS3DPRL += " --background=yes"; else run_GHS3DPRL += " --background=no";
run_nokeep_files = rm +GHS3DPRL_In + "* " + path + "tepal.log";
system( run_nokeep_files.ToCString() ); //clean files
Ok = false; //but it is not a problem but if true my message is overwritten
fclose(aResultFile);
cout<<"GHS3DPRL OK output master file "<<casenamemed<<".xml exist !\n\n";
- pluginerror = pluginerror + "new tetaedra not in memory, but stored in files "+ casenamemed + "_*.med";
+ pluginerror = pluginerror + "new tetraedra not in memory, but stored in files "+ casenamemed + "_*.med";
cout<<pluginerror<<endl;
error(COMPERR_ALGO_FAILED, pluginerror.ToCString());
if (!_KeepFiles) system( run_nokeep_files.ToCString() );
return Ok;
/*pid_t pid = fork();
if (pid > 0) {
- //Processus père
+ //Processus pere
cout<<"le pere est la\n";
system("echo le pere > lepere.tmp");
system("sleep 10");
} else if (pid == 0) {
//Processus fils
cout<<"le fils est la\n";
- //On rend le fils indépendant de tout terminal
+ //On rend le fils independant de tout terminal
setsid();
system("sleep 20");
system("echo le fils > lefils.tmp");