1 // Copyright (C) 2004-2022 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #include "MG_TetraHPC_API.hxx"
22 #include <SMESH_Comment.hxx>
23 #include <SMESH_File.hxx>
24 #include <SMESH_MGLicenseKeyGen.hxx>
25 #include <Utils_SALOME_Exception.hxx>
35 #include <meshgems/meshgems.h>
36 #include <meshgems/tetra_hpc.h>
39 struct MG_TetraHPC_API::LibData
43 tetra_hpc_session_t * _session;
49 std::vector<double> _xyz;
50 std::vector<double> _nodeSize; // required nodes
51 std::vector<int> _edgeNodes;
53 std::vector<int> _triaNodes;
57 volatile bool& _cancelled_flag;
58 std::string _errorStr;
61 LibData( volatile bool & cancelled_flag, double& progress )
62 : _context(0), _session(0), _tria_mesh(0), _sizemap(0), _tetra_mesh(0),
63 _nbRequiredEdges(0), _nbRequiredTria(0),
64 _cancelled_flag( cancelled_flag ), _progress( progress )
67 // methods setting callbacks implemented after callback definitions
69 bool Compute( const std::string& outFile );
74 tetra_hpc_regain_mesh( _session, _tetra_mesh );
76 tetra_hpc_session_delete( _session );
78 mesh_delete( _tria_mesh );
80 sizemap_delete( _sizemap );
82 context_delete( _context );
91 void AddError( const char *txt )
97 const std::string& GetErrors()
102 void MG_Error(const char* txt="")
104 SMESH_Comment msg("\nMeshGems error. ");
106 AddError( msg.c_str() );
109 bool SetParam( const std::string& param, const std::string& value )
111 status_t ret = tetra_hpc_set_param( _session, param.c_str(), value.c_str() );
113 //std::cout << param << " = " << value << std::endl;
115 return ( ret == STATUS_OK );
120 return _cancelled_flag;
123 int ReadNbSubDomains()
126 status_t ret = mesh_get_subdomain_count( _tetra_mesh, & nb );
128 if ( ret != STATUS_OK ) MG_Error("mesh_get_subdomain_count problem");
135 status_t ret = mesh_get_vertex_count( _tetra_mesh, & nb );
137 if ( ret != STATUS_OK ) MG_Error("mesh_get_vertex_count problem");
144 status_t ret = mesh_get_edge_count( _tetra_mesh, & nb );
146 if ( ret != STATUS_OK ) MG_Error("mesh_get_edge_count problem");
153 status_t ret = mesh_get_triangle_count( _tetra_mesh, & nb );
155 if ( ret != STATUS_OK ) MG_Error("mesh_get_triangle_count problem");
162 status_t ret = mesh_get_quadrangle_count( _tetra_mesh, & nb );
164 if ( ret != STATUS_OK ) MG_Error("mesh_get_quadrangle_count problem");
171 status_t ret = mesh_get_tetrahedron_count( _tetra_mesh, & nb );
173 if ( ret != STATUS_OK ) MG_Error("mesh_get_tetrahedron_count problem");
180 status_t ret = mesh_get_hexahedron_count( _tetra_mesh, & nb );
182 if ( ret != STATUS_OK ) MG_Error("mesh_get_hexahedron_count problem");
191 void ReadSubDomain( int* nbNodes, int* faceInd, int* ori, int* domain )
193 integer tag, seed_type, seed_idx, seed_orientation;
194 status_t ret = mesh_get_subdomain_description( _tetra_mesh, _count,
195 &tag, &seed_type, &seed_idx, &seed_orientation);
197 if ( ret != STATUS_OK ) MG_Error( "unable to get a sub-domain description");
202 *ori = seed_orientation;
206 void ReadNodeXYZ( double* x, double* y, double *z, int* /*domain*/ )
209 status_t ret = mesh_get_vertex_coordinates( _tetra_mesh, _count, coo );
210 if ( ret != STATUS_OK ) MG_Error( "unable to get resulting vertices" );
219 void ReadEdgeNodes( int* node1, int* node2, int* domain )
222 status_t ret = mesh_get_edge_vertices( _tetra_mesh, _count, vtx);
223 if (ret != STATUS_OK) MG_Error( "unable to get resulting edge" );
228 ret = mesh_get_edge_tag( _tetra_mesh, _count, &tag );
229 if (ret != STATUS_OK) MG_Error( "unable to get resulting edge tag" );
236 void ReadTriaNodes( int* node1, int* node2, int* node3, int* domain )
239 status_t ret = mesh_get_triangle_vertices( _tetra_mesh, _count, vtx);
240 if (ret != STATUS_OK) MG_Error( "unable to get resulting triangle" );
246 ret = mesh_get_triangle_tag( _tetra_mesh, _count, &tag );
247 if (ret != STATUS_OK) MG_Error( "unable to get resulting triangle tag" );
254 void ReadQuadNodes( int* node1, int* node2, int* node3, int* node4, int* domain )
257 status_t ret = mesh_get_quadrangle_vertices( _tetra_mesh, _count, vtx);
258 if (ret != STATUS_OK) MG_Error( "unable to get resulting quadrangle" );
265 ret = mesh_get_quadrangle_tag( _tetra_mesh, _count, &tag );
266 if (ret != STATUS_OK) MG_Error( "unable to get resulting quadrangle tag" );
273 void ReadTetraNodes( int* node1, int* node2, int* node3, int* node4, int* domain )
276 status_t ret = mesh_get_tetrahedron_vertices( _tetra_mesh, _count, vtx);
277 if (ret != STATUS_OK) MG_Error( "unable to get resulting tetrahedron" );
284 ret = mesh_get_tetrahedron_tag( _tetra_mesh, _count, &tag );
285 if (ret != STATUS_OK) MG_Error( "unable to get resulting tetrahedron tag" );
292 void ReadHexaNodes( int* node1, int* node2, int* node3, int* node4,
293 int* node5, int* node6, int* node7, int* node8, int* domain )
296 status_t ret = mesh_get_hexahedron_vertices( _tetra_mesh, _count, vtx);
297 if (ret != STATUS_OK) MG_Error( "unable to get resulting hexahedron" );
308 ret = mesh_get_hexahedron_tag( _tetra_mesh, _count, &tag );
309 if (ret != STATUS_OK) MG_Error( "unable to get resulting hexahedron tag" );
316 void SetNbVertices( int nb )
318 _xyz.reserve( _xyz.capacity() + nb );
321 void SetNbEdges( int nb )
323 _edgeNodes.reserve( nb * 2 );
326 void SetNbTria( int nb )
328 _triaNodes.reserve( nb * 3 );
331 void SetNbReqVertices( int nb )
333 _nodeSize.reserve( nb );
336 void SetNbReqEdges( int nb )
338 _nbRequiredEdges = nb;
341 void SetNbReqTria( int nb )
343 _nbRequiredTria = nb;
346 void AddNode( double x, double y, double z, int /*domain*/ )
353 void AddSizeAtNode( double size )
355 _nodeSize.push_back( size );
358 void AddEdgeNodes( int node1, int node2, int /*domain*/ )
360 _edgeNodes.push_back( node1 );
361 _edgeNodes.push_back( node2 );
364 void AddTriaNodes( int node1, int node2, int node3, int /*domain*/ )
366 _triaNodes.push_back( node1 );
367 _triaNodes.push_back( node2 );
368 _triaNodes.push_back( node3 );
373 return _xyz.size() / 3;
376 double* NodeCoord( int iNode )
378 return & _xyz[ iNode * 3 ];
383 return _edgeNodes.size() / 2;
386 int* GetEdgeNodes( int iEdge )
388 return & _edgeNodes[ iEdge * 2 ];
393 return _triaNodes.size() / 3;
396 int * GetTriaNodes( int iTria )
398 return & _triaNodes[ iTria * 3 ];
401 int IsVertexRequired( int iNode )
403 return ! ( iNode < int( NbNodes() - _nodeSize.size() ));
406 double GetSizeAtVertex( int iNode )
408 return IsVertexRequired( iNode ) ? _nodeSize[ iNode - NbNodes() + _nodeSize.size() ] : 0.;
412 namespace // functions called by MG library to exchange with the application
414 status_t get_vertex_count(integer * nbvtx, void *user_data)
416 MG_TetraHPC_API::LibData* data = (MG_TetraHPC_API::LibData *) user_data;
417 *nbvtx = data->NbNodes();
422 status_t get_vertex_coordinates(integer ivtx, real * xyz, void *user_data)
424 MG_TetraHPC_API::LibData* data = (MG_TetraHPC_API::LibData *) user_data;
425 double* coord = data->NodeCoord( ivtx-1 );
426 for (int j = 0; j < 3; j++)
431 status_t get_edge_count(integer * nbedge, void *user_data)
433 MG_TetraHPC_API::LibData* data = (MG_TetraHPC_API::LibData *) user_data;
434 *nbedge = data->NbEdges();
439 status_t get_edge_vertices(integer iedge, integer * vedge, void *user_data)
441 MG_TetraHPC_API::LibData* data = (MG_TetraHPC_API::LibData *) user_data;
442 int* nodes = data->GetEdgeNodes( iedge-1 );
449 status_t get_triangle_count(integer * nbtri, void *user_data)
451 MG_TetraHPC_API::LibData* data = (MG_TetraHPC_API::LibData *) user_data;
452 *nbtri = data->NbTriangles();
457 status_t get_triangle_vertices(integer itri, integer * vtri, void *user_data)
459 MG_TetraHPC_API::LibData* data = (MG_TetraHPC_API::LibData *) user_data;
460 int* nodes = data->GetTriaNodes( itri-1 );
468 // status_t get_triangle_extra_vertices(integer itri, integer * typetri,
469 // integer * evtri, void *user_data)
472 // MG_TetraHPC_API::LibData* data = (MG_TetraHPC_API::LibData *) user_data;
475 // /* We want to describe a linear "3 nodes" triangle */
476 // *typetri = MESHGEMS_MESH_ELEMENT_TYPE_TRIA3;
478 // /* We want to describe a quadratic "6 nodes" triangle */
479 // *typetri = MESHGEMS_MESH_ELEMENT_TYPE_TRIA6;
480 // for (j = 0; j < 3; j++)
481 // evtri[j] = 0; /* the j'th quadratic vertex index of the itri'th triangle */
487 // status_t get_tetrahedron_count(integer * nbtetra, void *user_data)
489 // MG_TetraHPC_API::LibData* data = (MG_TetraHPC_API::LibData *) user_data;
491 // *nbtetra = 0; /* the number of tetra in your input mesh (0 if you describe a surface mesh) */
496 // status_t get_tetrahedron_vertices(integer itetra, integer * vtetra,
500 // MG_TetraHPC_API::LibData* data = (MG_TetraHPC_API::LibData *) user_data;
502 // for (j = 0; j < 4; j++)
503 // vtetra[j] = 0; /* the j'th vertex index of the itetra'th tetrahedron */
508 status_t get_vertex_required_property(integer ivtx, integer * rvtx, void *user_data)
510 MG_TetraHPC_API::LibData* data = (MG_TetraHPC_API::LibData *) user_data;
511 *rvtx = data->IsVertexRequired( ivtx - 1 );
516 // status_t get_vertex_weight(integer ivtx, real * wvtx, void *user_data)
518 // MG_TetraHPC_API::LibData* data = (MG_TetraHPC_API::LibData *) user_data;
519 // *wvtx = data->GetSizeAtVertex( ivtx - 1 );
524 status_t my_message_cb(message_t * msg, void *user_data)
527 message_get_description(msg, &desc);
529 MG_TetraHPC_API::LibData* data = (MG_TetraHPC_API::LibData *) user_data;
530 data->AddError( desc );
533 //std::cout << desc << std::endl;
539 status_t my_interrupt_callback(integer *interrupt_status, void *user_data)
541 MG_TetraHPC_API::LibData* data = (MG_TetraHPC_API::LibData *) user_data;
542 *interrupt_status = ( data->Cancelled() ? INTERRUPT_STOP : INTERRUPT_CONTINUE );
544 //std::cout << "INTERRUPT_STOP" << std::endl;
553 void MG_TetraHPC_API::LibData::Init()
557 // Create the meshgems working context
558 _context = context_new();
559 if ( !_context ) MG_Error( "unable to create a new context" );
561 // Set the message callback for the _context.
562 ret = context_set_message_callback( _context, my_message_cb, this );
563 if ( ret != STATUS_OK ) MG_Error("in context_set_message_callback");
565 // Create the structure holding the callbacks giving access to triangle mesh
566 _tria_mesh = mesh_new( _context );
567 if ( !_tria_mesh ) MG_Error("unable to create a new mesh");
569 // Set callbacks to provide triangle mesh data
570 mesh_set_get_vertex_count( _tria_mesh, get_vertex_count, this );
571 mesh_set_get_vertex_coordinates( _tria_mesh, get_vertex_coordinates, this );
572 mesh_set_get_vertex_required_property( _tria_mesh, get_vertex_required_property, this );
573 mesh_set_get_edge_count( _tria_mesh, get_edge_count, this);
574 mesh_set_get_edge_vertices( _tria_mesh, get_edge_vertices, this );
575 mesh_set_get_triangle_count( _tria_mesh, get_triangle_count, this );
576 mesh_set_get_triangle_vertices( _tria_mesh, get_triangle_vertices, this );
578 // Create a tetra session
579 _session = tetra_hpc_session_new( _context );
580 if ( !_session ) MG_Error( "unable to create a new tetra_hpc session");
582 ret = tetra_hpc_set_interrupt_callback( _session, my_interrupt_callback, this );
583 if ( ret != STATUS_OK ) MG_Error("in tetra_set_interrupt_callback");
587 bool MG_TetraHPC_API::LibData::Compute( const std::string& outFile )
590 std::string errorTxt;
591 if ( !SMESHUtils_MGLicenseKeyGen::SignMesh( _tria_mesh, errorTxt ))
593 AddError( SMESH_Comment( "Problem with library SalomeMeshGemsKeyGenerator: ") << errorTxt );
598 status_t ret = tetra_hpc_set_input_mesh( _session, _tria_mesh );
599 if ( ret != STATUS_OK ) MG_Error( "unable to set surface mesh");
602 // if ( !_nodeSize.empty() )
604 // _sizemap = meshgems_sizemap_new( _tria_mesh, meshgems_sizemap_type_iso_mesh_vertex,
605 // (void*) &get_vertex_weight, this );
606 // if ( !_sizemap ) MG_Error("unable to create a new sizemap");
608 // ret = tetra_hpc_set_sizemap( _session, _sizemap );
609 // if ( ret != STATUS_OK ) MG_Error( "unable to set sizemap");
612 //////////////////////////////////////////////////////////////////////////////////////////
613 // const char* file = "/tmp/ghs3d_IN.mesh";
614 // mesh_write_mesh( _tria_mesh,file);
615 // std::cout << std::endl << std::endl << "Write " << file << std::endl << std::endl << std::endl;
617 ret = tetra_hpc_mesh( _session );
618 if ( ret != STATUS_OK ) return false;
620 ret = tetra_hpc_get_mesh( _session, &_tetra_mesh);
621 if (ret != STATUS_OK) MG_Error( "unable to get resulting mesh");
623 mesh_write_mesh( _tetra_mesh, outFile.c_str() );
628 #else // ifdef USE_MG_LIBS
630 struct MG_TetraHPC_API::LibData // to avoid compiler warnings
632 volatile bool& _cancelled_flag;
634 LibData(volatile bool& cancelled_flag, double& progress)
635 : _cancelled_flag{cancelled_flag}, _progress{progress}
639 #endif // ifdef USE_MG_LIBS
642 //================================================================================
646 //================================================================================
648 MG_TetraHPC_API::MG_TetraHPC_API(volatile bool& cancelled_flag, double& progress):
649 _nbNodes(0), _nbEdges(0), _nbFaces(0), _nbVolumes(0)
652 _libData = new LibData( cancelled_flag, progress );
656 if ( getenv("MG_TetraHPC_USE_EXE"))
661 //================================================================================
665 //================================================================================
667 MG_TetraHPC_API::~MG_TetraHPC_API()
673 std::set<int>::iterator id = _openFiles.begin();
674 for ( ; id != _openFiles.end(); ++id )
675 ::GmfCloseMesh( *id );
679 //================================================================================
681 * \brief Return the way of MG usage
683 //================================================================================
685 bool MG_TetraHPC_API::IsLibrary()
690 //================================================================================
692 * \brief Switch to usage of MG-Tetra executable
694 //================================================================================
696 void MG_TetraHPC_API::SetUseExecutable()
701 //================================================================================
703 * \brief Compute the tetra mesh
704 * \param [in] cmdLine - a command to run mg_tetra.exe
705 * \return bool - Ok or not
707 //================================================================================
709 bool MG_TetraHPC_API::Compute( const std::string& cmdLine, std::string& errStr )
715 std::istringstream strm( cmdLine );
716 std::istream_iterator<std::string> sIt( strm ), sEnd;
717 std::vector< std::string > args( sIt, sEnd );
722 std::string arg, param, value;
723 for ( size_t i = 1; i < args.size(); ++i )
725 // look for a param name; it starts from "-"
727 if ( arg.size() < 2 || arg[0] != '-')
729 while ( arg[0] == '-')
730 arg = arg.substr( 1 );
732 size_t eqPos = arg.find('=');
733 if ( eqPos != std::string::npos )
735 param = arg.substr( 0, eqPos );
736 value = arg.substr( eqPos+1 );
743 if ( param == "out" )
748 while ( i+1 < args.size() && args[i+1][0] != '-' )
750 if ( !value.empty() ) value += " ";
753 if ( !_libData->SetParam( param, value ))
754 std::cout << "Warning: wrong param: '" << param <<"' = '" << value << "'" << std::endl;
758 bool ok = _libData->Compute( outFile );
760 GetLog(); // write a log file
761 _logFile = ""; // not to write it again
767 // add MG license key
769 std::string errorTxt, meshIn;
770 std::string key = SMESHUtils_MGLicenseKeyGen::GetKey( meshIn,
771 _nbNodes, _nbEdges, _nbFaces, _nbVolumes,
775 errStr = "Problem with library SalomeMeshGemsKeyGenerator: " + errorTxt;
779 const_cast< std::string& >( cmdLine ) += " --key " + key;
782 std::cout << "Launching: " << cmdLine << std::endl;
784 int err = system( cmdLine.c_str() ); // run
788 errStr = SMESH_Comment("system command failed with error: ")
789 << strerror( errno );
796 //================================================================================
798 * \brief Prepare for reading a mesh data
800 //================================================================================
802 int MG_TetraHPC_API::GmfOpenMesh(const char* theFile, int rdOrWr, int * ver, int * dim)
809 int id = ::GmfOpenMesh(theFile, rdOrWr, ver, dim );
810 _openFiles.insert( id );
814 //================================================================================
816 * \brief Return nb of entities
818 //================================================================================
820 int MG_TetraHPC_API::GmfStatKwd( int iMesh, GmfKwdCod what )
826 case GmfSubDomainFromGeom: return _libData->ReadNbSubDomains();
827 case GmfVertices: return _libData->ReadNbNodes();
828 case GmfEdges: return _libData->ReadNbEdges();
829 case GmfTriangles: return _libData->ReadNbTria();
830 case GmfQuadrilaterals: return _libData->ReadNbQuads();
831 case GmfTetrahedra: return _libData->ReadNbTetra();
832 case GmfHexahedra: return _libData->ReadNbHexa();
838 return ::GmfStatKwd( iMesh, what );
841 //================================================================================
843 * \brief Prepare for reading some data
845 //================================================================================
847 void MG_TetraHPC_API::GmfGotoKwd( int iMesh, GmfKwdCod what )
851 _libData->ResetCounter();
855 ::GmfGotoKwd( iMesh, what );
858 //================================================================================
860 * \brief Return index of a domain identified by a triangle normal
861 * \param [in] iMesh - mesh file index
862 * \param [in] what - must be GmfSubDomainFromGeom
863 * \param [out] nbNodes - nb nodes in a face
864 * \param [out] faceInd - face index
865 * \param [out] ori - face orientation
866 * \param [out] domain - domain index
867 * \param [in] dummy - an artificial param used to discriminate from GmfGetLin() reading
870 //================================================================================
872 void MG_TetraHPC_API::GmfGetLin( int iMesh, GmfKwdCod what, int* nbNodes, int* faceInd, int* ori, int* domain, int /*dummy*/ )
876 _libData->ReadSubDomain( nbNodes, faceInd, ori, domain );
880 ::GmfGetLin( iMesh, what, nbNodes, faceInd, ori, domain );
883 //================================================================================
885 * \brief Return coordinates of a next node
887 //================================================================================
889 void MG_TetraHPC_API::GmfGetLin(int iMesh, GmfKwdCod what,
890 double* x, double* y, double *z, int* domain )
894 _libData->ReadNodeXYZ( x, y, z, domain );
898 ::GmfGetLin(iMesh, what, x, y, z, domain );
901 //================================================================================
903 * \brief Return coordinates of a next node
905 //================================================================================
907 void MG_TetraHPC_API::GmfGetLin(int iMesh, GmfKwdCod what,
908 float* x, float* y, float *z, int* domain )
913 _libData->ReadNodeXYZ( &X, &Y, &Z, domain );
920 ::GmfGetLin(iMesh, what, x, y, z, domain );
923 //================================================================================
925 * \brief Return node index of a next corner
927 //================================================================================
929 void MG_TetraHPC_API::GmfGetLin(int iMesh, GmfKwdCod what, int* node )
937 ::GmfGetLin(iMesh, what, node );
940 //================================================================================
942 * \brief Return node indices of a next edge
944 //================================================================================
946 void MG_TetraHPC_API::GmfGetLin(int iMesh, GmfKwdCod what, int* node1, int* node2, int* domain )
950 _libData->ReadEdgeNodes( node1, node2, domain );
954 ::GmfGetLin( iMesh, what, node1, node2, domain );
957 //================================================================================
959 * \brief Return node indices of a next triangle
961 //================================================================================
963 void MG_TetraHPC_API::GmfGetLin(int iMesh, GmfKwdCod what,
964 int* node1, int* node2, int* node3, int* domain )
968 _libData->ReadTriaNodes( node1, node2, node3, domain );
972 ::GmfGetLin(iMesh, what, node1, node2, node3, domain );
975 //================================================================================
977 * \brief Return node indices of a next tetrahedron or quadrangle
979 //================================================================================
981 void MG_TetraHPC_API::GmfGetLin(int iMesh, GmfKwdCod what,
982 int* node1, int* node2, int* node3, int* node4, int* domain )
986 if ( what == GmfQuadrilaterals )
987 _libData->ReadQuadNodes( node1, node2, node3, node4, domain );
989 _libData->ReadTetraNodes( node1, node2, node3, node4, domain );
993 ::GmfGetLin(iMesh, what, node1, node2, node3, node4, domain );
996 //================================================================================
998 * \brief Return node indices of a next hexahedron
1000 //================================================================================
1002 void MG_TetraHPC_API::GmfGetLin(int iMesh, GmfKwdCod what,
1003 int* node1, int* node2, int* node3, int* node4,
1004 int* node5, int* node6, int* node7, int* node8,
1009 _libData->ReadHexaNodes( node1, node2, node3, node4,
1010 node5, node6, node7, node8, domain );
1014 ::GmfGetLin(iMesh, what, node1, node2, node3, node4, node5, node6, node7, node8, domain );
1017 //================================================================================
1019 * \brief Prepare for passing data to MeshGems
1021 //================================================================================
1023 int MG_TetraHPC_API::GmfOpenMesh(const char* theFile, int rdOrWr, int ver, int dim)
1030 int id = ::GmfOpenMesh(theFile, rdOrWr, ver, dim);
1031 _openFiles.insert( id );
1035 //================================================================================
1037 * \brief Set number of entities
1039 //================================================================================
1041 void MG_TetraHPC_API::GmfSetKwd(int iMesh, GmfKwdCod what, int nb )
1046 case GmfVertices: _nbNodes = nb; break;
1047 case GmfEdges: _nbEdges = nb; break;
1048 case GmfTriangles: _nbFaces = nb; break;
1056 case GmfVertices: _libData->SetNbVertices( nb ); break;
1057 case GmfEdges: _libData->SetNbEdges ( nb ); break;
1058 case GmfRequiredEdges: _libData->SetNbReqEdges( nb ); break;
1059 case GmfTriangles: _libData->SetNbTria ( nb ); break;
1060 case GmfRequiredTriangles: _libData->SetNbReqTria ( nb ); break;
1066 ::GmfSetKwd(iMesh, what, nb );
1069 //================================================================================
1071 * \brief Add coordinates of a node
1073 //================================================================================
1075 void MG_TetraHPC_API::GmfSetLin(int iMesh, GmfKwdCod what, double x, double y, double z, int domain)
1079 _libData->AddNode( x, y, z, domain );
1083 ::GmfSetLin(iMesh, what, x, y, z, domain);
1086 //================================================================================
1088 * \brief Set number of field entities
1089 * \param [in] iMesh - solution file index
1090 * \param [in] what - solution type
1091 * \param [in] nbNodes - nb of entities
1092 * \param [in] nbTypes - nb of data entries in each entity
1093 * \param [in] type - types of the data entries
1095 * Used to prepare to storing size at nodes
1097 //================================================================================
1099 void MG_TetraHPC_API::GmfSetKwd(int iMesh, GmfKwdCod what, int nbNodes, int dummy, int type[] )
1103 if ( what == GmfSolAtVertices ) _libData->SetNbReqVertices( nbNodes );
1107 ::GmfSetKwd(iMesh, what, nbNodes, dummy, type );
1110 //================================================================================
1112 * \brief Add solution data
1114 //================================================================================
1116 void MG_TetraHPC_API::GmfSetLin(int iMesh, GmfKwdCod what, double vals[])
1120 _libData->AddSizeAtNode( vals[0] );
1124 ::GmfSetLin(iMesh, what, vals);
1127 //================================================================================
1129 * \brief Add edge nodes
1131 //================================================================================
1133 void MG_TetraHPC_API::GmfSetLin(int iMesh, GmfKwdCod what, int node1, int node2, int domain )
1137 _libData->AddEdgeNodes( node1, node2, domain );
1141 ::GmfSetLin(iMesh, what, node1, node2, domain );
1144 //================================================================================
1146 * \brief Add a 'required' flag
1148 //================================================================================
1150 void MG_TetraHPC_API::GmfSetLin(int iMesh, GmfKwdCod what, int id )
1157 ::GmfSetLin(iMesh, what, id );
1160 //================================================================================
1162 * \brief Add triangle nodes
1164 //================================================================================
1166 void MG_TetraHPC_API::GmfSetLin(int iMesh, GmfKwdCod what, int node1, int node2, int node3, int domain )
1170 _libData->AddTriaNodes( node1, node2, node3, domain );
1174 ::GmfSetLin(iMesh, what, node1, node2, node3, domain );
1177 //================================================================================
1179 * \brief Close a file
1181 //================================================================================
1183 void MG_TetraHPC_API::GmfCloseMesh( int iMesh )
1190 ::GmfCloseMesh( iMesh );
1191 _openFiles.erase( iMesh );
1194 //================================================================================
1196 * \brief Return true if the log is not empty
1198 //================================================================================
1200 bool MG_TetraHPC_API::HasLog()
1204 return !_libData->GetErrors().empty();
1207 SMESH_File file( _logFile );
1208 return file.size() > 0;
1211 //================================================================================
1213 * \brief Return log contents
1215 //================================================================================
1217 std::string MG_TetraHPC_API::GetLog()
1221 const std::string& err = _libData->GetErrors();
1222 if ( !_logFile.empty() && !err.empty() )
1224 SMESH_File file( _logFile, /*openForReading=*/false );
1225 file.openForWriting();
1226 file.write( err.c_str(), err.size() );
1231 std::cout << "_logFile: " << _logFile << std::endl;
1233 SMESH_File file( _logFile );
1234 if (file.exists() && file.size() > 0)
1235 return file.getPos();