1 // Copyright (C) 2004-2021 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 <Utils_SALOME_Exception.hxx>
33 #include <meshgems/meshgems.h>
34 #include <meshgems/tetra_hpc.h>
37 struct MG_TetraHPC_API::LibData
41 tetra_hpc_session_t * _session;
47 std::vector<double> _xyz;
48 std::vector<double> _nodeSize; // required nodes
49 std::vector<int> _edgeNodes;
51 std::vector<int> _triaNodes;
55 volatile bool& _cancelled_flag;
56 std::string _errorStr;
59 LibData( volatile bool & cancelled_flag, double& progress )
60 : _context(0), _session(0), _tria_mesh(0), _sizemap(0), _tetra_mesh(0),
61 _nbRequiredEdges(0), _nbRequiredTria(0),
62 _cancelled_flag( cancelled_flag ), _progress( progress )
65 // methods setting callbacks implemented after callback definitions
67 bool Compute( const std::string& outFile );
72 tetra_hpc_regain_mesh( _session, _tetra_mesh );
74 tetra_hpc_session_delete( _session );
76 mesh_delete( _tria_mesh );
78 sizemap_delete( _sizemap );
80 context_delete( _context );
89 void AddError( const char *txt )
95 const std::string& GetErrors()
100 void MG_Error(const char* txt="")
102 SMESH_Comment msg("\nMeshGems error. ");
104 AddError( msg.c_str() );
107 bool SetParam( const std::string& param, const std::string& value )
109 status_t ret = tetra_hpc_set_param( _session, param.c_str(), value.c_str() );
111 //std::cout << param << " = " << value << std::endl;
113 return ( ret == STATUS_OK );
118 return _cancelled_flag;
121 int ReadNbSubDomains()
124 status_t ret = mesh_get_subdomain_count( _tetra_mesh, & nb );
126 if ( ret != STATUS_OK ) MG_Error("mesh_get_subdomain_count problem");
133 status_t ret = mesh_get_vertex_count( _tetra_mesh, & nb );
135 if ( ret != STATUS_OK ) MG_Error("mesh_get_vertex_count problem");
142 status_t ret = mesh_get_edge_count( _tetra_mesh, & nb );
144 if ( ret != STATUS_OK ) MG_Error("mesh_get_edge_count problem");
151 status_t ret = mesh_get_triangle_count( _tetra_mesh, & nb );
153 if ( ret != STATUS_OK ) MG_Error("mesh_get_triangle_count problem");
160 status_t ret = mesh_get_quadrangle_count( _tetra_mesh, & nb );
162 if ( ret != STATUS_OK ) MG_Error("mesh_get_quadrangle_count problem");
169 status_t ret = mesh_get_tetrahedron_count( _tetra_mesh, & nb );
171 if ( ret != STATUS_OK ) MG_Error("mesh_get_tetrahedron_count problem");
178 status_t ret = mesh_get_hexahedron_count( _tetra_mesh, & nb );
180 if ( ret != STATUS_OK ) MG_Error("mesh_get_hexahedron_count problem");
189 void ReadSubDomain( int* nbNodes, int* faceInd, int* ori, int* domain )
191 integer tag, seed_type, seed_idx, seed_orientation;
192 status_t ret = mesh_get_subdomain_description( _tetra_mesh, _count,
193 &tag, &seed_type, &seed_idx, &seed_orientation);
195 if ( ret != STATUS_OK ) MG_Error( "unable to get a sub-domain description");
200 *ori = seed_orientation;
204 void ReadNodeXYZ( double* x, double* y, double *z, int* /*domain*/ )
207 status_t ret = mesh_get_vertex_coordinates( _tetra_mesh, _count, coo );
208 if ( ret != STATUS_OK ) MG_Error( "unable to get resulting vertices" );
217 void ReadEdgeNodes( int* node1, int* node2, int* domain )
220 status_t ret = mesh_get_edge_vertices( _tetra_mesh, _count, vtx);
221 if (ret != STATUS_OK) MG_Error( "unable to get resulting edge" );
226 ret = mesh_get_edge_tag( _tetra_mesh, _count, &tag );
227 if (ret != STATUS_OK) MG_Error( "unable to get resulting edge tag" );
234 void ReadTriaNodes( int* node1, int* node2, int* node3, int* domain )
237 status_t ret = mesh_get_triangle_vertices( _tetra_mesh, _count, vtx);
238 if (ret != STATUS_OK) MG_Error( "unable to get resulting triangle" );
244 ret = mesh_get_triangle_tag( _tetra_mesh, _count, &tag );
245 if (ret != STATUS_OK) MG_Error( "unable to get resulting triangle tag" );
252 void ReadQuadNodes( int* node1, int* node2, int* node3, int* node4, int* domain )
255 status_t ret = mesh_get_quadrangle_vertices( _tetra_mesh, _count, vtx);
256 if (ret != STATUS_OK) MG_Error( "unable to get resulting quadrangle" );
263 ret = mesh_get_quadrangle_tag( _tetra_mesh, _count, &tag );
264 if (ret != STATUS_OK) MG_Error( "unable to get resulting quadrangle tag" );
271 void ReadTetraNodes( int* node1, int* node2, int* node3, int* node4, int* domain )
274 status_t ret = mesh_get_tetrahedron_vertices( _tetra_mesh, _count, vtx);
275 if (ret != STATUS_OK) MG_Error( "unable to get resulting tetrahedron" );
282 ret = mesh_get_tetrahedron_tag( _tetra_mesh, _count, &tag );
283 if (ret != STATUS_OK) MG_Error( "unable to get resulting tetrahedron tag" );
290 void ReadHexaNodes( int* node1, int* node2, int* node3, int* node4,
291 int* node5, int* node6, int* node7, int* node8, int* domain )
294 status_t ret = mesh_get_hexahedron_vertices( _tetra_mesh, _count, vtx);
295 if (ret != STATUS_OK) MG_Error( "unable to get resulting hexahedron" );
306 ret = mesh_get_hexahedron_tag( _tetra_mesh, _count, &tag );
307 if (ret != STATUS_OK) MG_Error( "unable to get resulting hexahedron tag" );
314 void SetNbVertices( int nb )
316 _xyz.reserve( _xyz.capacity() + nb );
319 void SetNbEdges( int nb )
321 _edgeNodes.reserve( nb * 2 );
324 void SetNbTria( int nb )
326 _triaNodes.reserve( nb * 3 );
329 void SetNbReqVertices( int nb )
331 _nodeSize.reserve( nb );
334 void SetNbReqEdges( int nb )
336 _nbRequiredEdges = nb;
339 void SetNbReqTria( int nb )
341 _nbRequiredTria = nb;
344 void AddNode( double x, double y, double z, int /*domain*/ )
351 void AddSizeAtNode( double size )
353 _nodeSize.push_back( size );
356 void AddEdgeNodes( int node1, int node2, int /*domain*/ )
358 _edgeNodes.push_back( node1 );
359 _edgeNodes.push_back( node2 );
362 void AddTriaNodes( int node1, int node2, int node3, int /*domain*/ )
364 _triaNodes.push_back( node1 );
365 _triaNodes.push_back( node2 );
366 _triaNodes.push_back( node3 );
371 return _xyz.size() / 3;
374 double* NodeCoord( int iNode )
376 return & _xyz[ iNode * 3 ];
381 return _edgeNodes.size() / 2;
384 int* GetEdgeNodes( int iEdge )
386 return & _edgeNodes[ iEdge * 2 ];
391 return _triaNodes.size() / 3;
394 int * GetTriaNodes( int iTria )
396 return & _triaNodes[ iTria * 3 ];
399 int IsVertexRequired( int iNode )
401 return ! ( iNode < int( NbNodes() - _nodeSize.size() ));
404 double GetSizeAtVertex( int iNode )
406 return IsVertexRequired( iNode ) ? _nodeSize[ iNode - NbNodes() + _nodeSize.size() ] : 0.;
410 namespace // functions called by MG library to exchange with the application
412 status_t get_vertex_count(integer * nbvtx, void *user_data)
414 MG_TetraHPC_API::LibData* data = (MG_TetraHPC_API::LibData *) user_data;
415 *nbvtx = data->NbNodes();
420 status_t get_vertex_coordinates(integer ivtx, real * xyz, void *user_data)
422 MG_TetraHPC_API::LibData* data = (MG_TetraHPC_API::LibData *) user_data;
423 double* coord = data->NodeCoord( ivtx-1 );
424 for (int j = 0; j < 3; j++)
429 status_t get_edge_count(integer * nbedge, void *user_data)
431 MG_TetraHPC_API::LibData* data = (MG_TetraHPC_API::LibData *) user_data;
432 *nbedge = data->NbEdges();
437 status_t get_edge_vertices(integer iedge, integer * vedge, void *user_data)
439 MG_TetraHPC_API::LibData* data = (MG_TetraHPC_API::LibData *) user_data;
440 int* nodes = data->GetEdgeNodes( iedge-1 );
447 status_t get_triangle_count(integer * nbtri, void *user_data)
449 MG_TetraHPC_API::LibData* data = (MG_TetraHPC_API::LibData *) user_data;
450 *nbtri = data->NbTriangles();
455 status_t get_triangle_vertices(integer itri, integer * vtri, void *user_data)
457 MG_TetraHPC_API::LibData* data = (MG_TetraHPC_API::LibData *) user_data;
458 int* nodes = data->GetTriaNodes( itri-1 );
466 // status_t get_triangle_extra_vertices(integer itri, integer * typetri,
467 // integer * evtri, void *user_data)
470 // MG_TetraHPC_API::LibData* data = (MG_TetraHPC_API::LibData *) user_data;
473 // /* We want to describe a linear "3 nodes" triangle */
474 // *typetri = MESHGEMS_MESH_ELEMENT_TYPE_TRIA3;
476 // /* We want to describe a quadratic "6 nodes" triangle */
477 // *typetri = MESHGEMS_MESH_ELEMENT_TYPE_TRIA6;
478 // for (j = 0; j < 3; j++)
479 // evtri[j] = 0; /* the j'th quadratic vertex index of the itri'th triangle */
485 // status_t get_tetrahedron_count(integer * nbtetra, void *user_data)
487 // MG_TetraHPC_API::LibData* data = (MG_TetraHPC_API::LibData *) user_data;
489 // *nbtetra = 0; /* the number of tetra in your input mesh (0 if you describe a surface mesh) */
494 // status_t get_tetrahedron_vertices(integer itetra, integer * vtetra,
498 // MG_TetraHPC_API::LibData* data = (MG_TetraHPC_API::LibData *) user_data;
500 // for (j = 0; j < 4; j++)
501 // vtetra[j] = 0; /* the j'th vertex index of the itetra'th tetrahedron */
506 status_t get_vertex_required_property(integer ivtx, integer * rvtx, void *user_data)
508 MG_TetraHPC_API::LibData* data = (MG_TetraHPC_API::LibData *) user_data;
509 *rvtx = data->IsVertexRequired( ivtx - 1 );
514 // status_t get_vertex_weight(integer ivtx, real * wvtx, void *user_data)
516 // MG_TetraHPC_API::LibData* data = (MG_TetraHPC_API::LibData *) user_data;
517 // *wvtx = data->GetSizeAtVertex( ivtx - 1 );
522 status_t my_message_cb(message_t * msg, void *user_data)
525 message_get_description(msg, &desc);
527 MG_TetraHPC_API::LibData* data = (MG_TetraHPC_API::LibData *) user_data;
528 data->AddError( desc );
531 //std::cout << desc << std::endl;
537 status_t my_interrupt_callback(integer *interrupt_status, void *user_data)
539 MG_TetraHPC_API::LibData* data = (MG_TetraHPC_API::LibData *) user_data;
540 *interrupt_status = ( data->Cancelled() ? INTERRUPT_STOP : INTERRUPT_CONTINUE );
542 //std::cout << "INTERRUPT_STOP" << std::endl;
551 void MG_TetraHPC_API::LibData::Init()
555 // Create the meshgems working context
556 _context = context_new();
557 if ( !_context ) MG_Error( "unable to create a new context" );
559 // Set the message callback for the _context.
560 ret = context_set_message_callback( _context, my_message_cb, this );
561 if ( ret != STATUS_OK ) MG_Error("in context_set_message_callback");
563 // Create the structure holding the callbacks giving access to triangle mesh
564 _tria_mesh = mesh_new( _context );
565 if ( !_tria_mesh ) MG_Error("unable to create a new mesh");
567 // Set callbacks to provide triangle mesh data
568 mesh_set_get_vertex_count( _tria_mesh, get_vertex_count, this );
569 mesh_set_get_vertex_coordinates( _tria_mesh, get_vertex_coordinates, this );
570 mesh_set_get_vertex_required_property( _tria_mesh, get_vertex_required_property, this );
571 mesh_set_get_edge_count( _tria_mesh, get_edge_count, this);
572 mesh_set_get_edge_vertices( _tria_mesh, get_edge_vertices, this );
573 mesh_set_get_triangle_count( _tria_mesh, get_triangle_count, this );
574 mesh_set_get_triangle_vertices( _tria_mesh, get_triangle_vertices, this );
576 // Create a tetra session
577 _session = tetra_hpc_session_new( _context );
578 if ( !_session ) MG_Error( "unable to create a new tetra_hpc session");
580 ret = tetra_hpc_set_interrupt_callback( _session, my_interrupt_callback, this );
581 if ( ret != STATUS_OK ) MG_Error("in tetra_set_interrupt_callback");
585 bool MG_TetraHPC_API::LibData::Compute( const std::string& outFile )
588 status_t ret = tetra_hpc_set_input_mesh( _session, _tria_mesh );
589 if ( ret != STATUS_OK ) MG_Error( "unable to set surface mesh");
592 // if ( !_nodeSize.empty() )
594 // _sizemap = meshgems_sizemap_new( _tria_mesh, meshgems_sizemap_type_iso_mesh_vertex,
595 // (void*) &get_vertex_weight, this );
596 // if ( !_sizemap ) MG_Error("unable to create a new sizemap");
598 // ret = tetra_hpc_set_sizemap( _session, _sizemap );
599 // if ( ret != STATUS_OK ) MG_Error( "unable to set sizemap");
602 //////////////////////////////////////////////////////////////////////////////////////////
603 // const char* file = "/tmp/ghs3d_IN.mesh";
604 // mesh_write_mesh( _tria_mesh,file);
605 // std::cout << std::endl << std::endl << "Write " << file << std::endl << std::endl << std::endl;
607 ret = tetra_hpc_mesh( _session );
608 if ( ret != STATUS_OK ) return false;
610 ret = tetra_hpc_get_mesh( _session, &_tetra_mesh);
611 if (ret != STATUS_OK) MG_Error( "unable to get resulting mesh");
613 mesh_write_mesh( _tetra_mesh, outFile.c_str() );
618 #else // ifdef USE_MG_LIBS
620 struct MG_TetraHPC_API::LibData // to avoid compiler warnings
622 volatile bool& _cancelled_flag;
624 LibData(volatile bool& cancelled_flag, double& progress)
625 : _cancelled_flag{cancelled_flag}, _progress{progress}
629 #endif // ifdef USE_MG_LIBS
632 //================================================================================
636 //================================================================================
638 MG_TetraHPC_API::MG_TetraHPC_API(volatile bool& cancelled_flag, double& progress)
641 _libData = new LibData( cancelled_flag, progress );
645 if ( getenv("MG_TetraHPC_USE_EXE"))
650 //================================================================================
654 //================================================================================
656 MG_TetraHPC_API::~MG_TetraHPC_API()
662 std::set<int>::iterator id = _openFiles.begin();
663 for ( ; id != _openFiles.end(); ++id )
664 ::GmfCloseMesh( *id );
668 //================================================================================
670 * \brief Return the way of MG usage
672 //================================================================================
674 bool MG_TetraHPC_API::IsLibrary()
679 //================================================================================
681 * \brief Switch to usage of MG-Tetra executable
683 //================================================================================
685 void MG_TetraHPC_API::SetUseExecutable()
690 //================================================================================
692 * \brief Compute the tetra mesh
693 * \param [in] cmdLine - a command to run mg_tetra.exe
694 * \return bool - Ok or not
696 //================================================================================
698 bool MG_TetraHPC_API::Compute( const std::string& cmdLine )
704 std::istringstream strm( cmdLine );
705 std::istream_iterator<std::string> sIt( strm ), sEnd;
706 std::vector< std::string > args( sIt, sEnd );
711 std::string arg, param, value;
712 for ( size_t i = 1; i < args.size(); ++i )
714 // look for a param name; it starts from "-"
716 if ( arg.size() < 2 || arg[0] != '-')
718 while ( arg[0] == '-')
719 arg = arg.substr( 1 );
721 size_t eqPos = arg.find('=');
722 if ( eqPos != std::string::npos )
724 param = arg.substr( 0, eqPos );
725 value = arg.substr( eqPos+1 );
732 if ( param == "out" )
737 while ( i+1 < args.size() && args[i+1][0] != '-' )
739 if ( !value.empty() ) value += " ";
742 if ( !_libData->SetParam( param, value ))
743 std::cout << "Warning: wrong param: '" << param <<"' = '" << value << "'" << std::endl;
747 bool ok = _libData->Compute( outFile );
749 GetLog(); // write a log file
750 _logFile = ""; // not to write it again
756 (void)cmdLine; // unused
759 // int err = system( cmdLine.c_str() ); // run
762 // errStr = SMESH_Comment("system(mg-tetra.exe ...) command failed with error: ")
763 // << strerror( errno );
768 //================================================================================
770 * \brief Prepare for reading a mesh data
772 //================================================================================
774 int MG_TetraHPC_API::GmfOpenMesh(const char* theFile, int rdOrWr, int * ver, int * dim)
781 int id = ::GmfOpenMesh(theFile, rdOrWr, ver, dim );
782 _openFiles.insert( id );
786 //================================================================================
788 * \brief Return nb of entities
790 //================================================================================
792 int MG_TetraHPC_API::GmfStatKwd( int iMesh, GmfKwdCod what )
798 case GmfSubDomainFromGeom: return _libData->ReadNbSubDomains();
799 case GmfVertices: return _libData->ReadNbNodes();
800 case GmfEdges: return _libData->ReadNbEdges();
801 case GmfTriangles: return _libData->ReadNbTria();
802 case GmfQuadrilaterals: return _libData->ReadNbQuads();
803 case GmfTetrahedra: return _libData->ReadNbTetra();
804 case GmfHexahedra: return _libData->ReadNbHexa();
810 return ::GmfStatKwd( iMesh, what );
813 //================================================================================
815 * \brief Prepare for reading some data
817 //================================================================================
819 void MG_TetraHPC_API::GmfGotoKwd( int iMesh, GmfKwdCod what )
823 _libData->ResetCounter();
827 ::GmfGotoKwd( iMesh, what );
830 //================================================================================
832 * \brief Return index of a domain identified by a triangle normal
833 * \param [in] iMesh - mesh file index
834 * \param [in] what - must be GmfSubDomainFromGeom
835 * \param [out] nbNodes - nb nodes in a face
836 * \param [out] faceInd - face index
837 * \param [out] ori - face orientation
838 * \param [out] domain - domain index
839 * \param [in] dummy - an artificial param used to discriminate from GmfGetLin() reading
842 //================================================================================
844 void MG_TetraHPC_API::GmfGetLin( int iMesh, GmfKwdCod what, int* nbNodes, int* faceInd, int* ori, int* domain, int /*dummy*/ )
848 _libData->ReadSubDomain( nbNodes, faceInd, ori, domain );
852 ::GmfGetLin( iMesh, what, nbNodes, faceInd, ori, domain );
855 //================================================================================
857 * \brief Return coordinates of a next node
859 //================================================================================
861 void MG_TetraHPC_API::GmfGetLin(int iMesh, GmfKwdCod what,
862 double* x, double* y, double *z, int* domain )
866 _libData->ReadNodeXYZ( x, y, z, domain );
870 ::GmfGetLin(iMesh, what, x, y, z, domain );
873 //================================================================================
875 * \brief Return coordinates of a next node
877 //================================================================================
879 void MG_TetraHPC_API::GmfGetLin(int iMesh, GmfKwdCod what,
880 float* x, float* y, float *z, int* domain )
885 _libData->ReadNodeXYZ( &X, &Y, &Z, domain );
892 ::GmfGetLin(iMesh, what, x, y, z, domain );
895 //================================================================================
897 * \brief Return node index of a next corner
899 //================================================================================
901 void MG_TetraHPC_API::GmfGetLin(int iMesh, GmfKwdCod what, int* node )
909 ::GmfGetLin(iMesh, what, node );
912 //================================================================================
914 * \brief Return node indices of a next edge
916 //================================================================================
918 void MG_TetraHPC_API::GmfGetLin(int iMesh, GmfKwdCod what, int* node1, int* node2, int* domain )
922 _libData->ReadEdgeNodes( node1, node2, domain );
926 ::GmfGetLin( iMesh, what, node1, node2, domain );
929 //================================================================================
931 * \brief Return node indices of a next triangle
933 //================================================================================
935 void MG_TetraHPC_API::GmfGetLin(int iMesh, GmfKwdCod what,
936 int* node1, int* node2, int* node3, int* domain )
940 _libData->ReadTriaNodes( node1, node2, node3, domain );
944 ::GmfGetLin(iMesh, what, node1, node2, node3, domain );
947 //================================================================================
949 * \brief Return node indices of a next tetrahedron or quadrangle
951 //================================================================================
953 void MG_TetraHPC_API::GmfGetLin(int iMesh, GmfKwdCod what,
954 int* node1, int* node2, int* node3, int* node4, int* domain )
958 if ( what == GmfQuadrilaterals )
959 _libData->ReadQuadNodes( node1, node2, node3, node4, domain );
961 _libData->ReadTetraNodes( node1, node2, node3, node4, domain );
965 ::GmfGetLin(iMesh, what, node1, node2, node3, node4, domain );
968 //================================================================================
970 * \brief Return node indices of a next hexahedron
972 //================================================================================
974 void MG_TetraHPC_API::GmfGetLin(int iMesh, GmfKwdCod what,
975 int* node1, int* node2, int* node3, int* node4,
976 int* node5, int* node6, int* node7, int* node8,
981 _libData->ReadHexaNodes( node1, node2, node3, node4,
982 node5, node6, node7, node8, domain );
986 ::GmfGetLin(iMesh, what, node1, node2, node3, node4, node5, node6, node7, node8, domain );
989 //================================================================================
991 * \brief Prepare for passing data to MeshGems
993 //================================================================================
995 int MG_TetraHPC_API::GmfOpenMesh(const char* theFile, int rdOrWr, int ver, int dim)
1002 int id = ::GmfOpenMesh(theFile, rdOrWr, ver, dim);
1003 _openFiles.insert( id );
1007 //================================================================================
1009 * \brief Set number of entities
1011 //================================================================================
1013 void MG_TetraHPC_API::GmfSetKwd(int iMesh, GmfKwdCod what, int nb )
1018 case GmfVertices: _libData->SetNbVertices( nb ); break;
1019 case GmfEdges: _libData->SetNbEdges ( nb ); break;
1020 case GmfRequiredEdges: _libData->SetNbReqEdges( nb ); break;
1021 case GmfTriangles: _libData->SetNbTria ( nb ); break;
1022 case GmfRequiredTriangles: _libData->SetNbReqTria ( nb ); break;
1028 ::GmfSetKwd(iMesh, what, nb );
1031 //================================================================================
1033 * \brief Add coordinates of a node
1035 //================================================================================
1037 void MG_TetraHPC_API::GmfSetLin(int iMesh, GmfKwdCod what, double x, double y, double z, int domain)
1041 _libData->AddNode( x, y, z, domain );
1045 ::GmfSetLin(iMesh, what, x, y, z, domain);
1048 //================================================================================
1050 * \brief Set number of field entities
1051 * \param [in] iMesh - solution file index
1052 * \param [in] what - solution type
1053 * \param [in] nbNodes - nb of entities
1054 * \param [in] nbTypes - nb of data entries in each entity
1055 * \param [in] type - types of the data entries
1057 * Used to prepare to storing size at nodes
1059 //================================================================================
1061 void MG_TetraHPC_API::GmfSetKwd(int iMesh, GmfKwdCod what, int nbNodes, int dummy, int type[] )
1065 if ( what == GmfSolAtVertices ) _libData->SetNbReqVertices( nbNodes );
1069 ::GmfSetKwd(iMesh, what, nbNodes, dummy, type );
1072 //================================================================================
1074 * \brief Add solution data
1076 //================================================================================
1078 void MG_TetraHPC_API::GmfSetLin(int iMesh, GmfKwdCod what, double vals[])
1082 _libData->AddSizeAtNode( vals[0] );
1086 ::GmfSetLin(iMesh, what, vals);
1089 //================================================================================
1091 * \brief Add edge nodes
1093 //================================================================================
1095 void MG_TetraHPC_API::GmfSetLin(int iMesh, GmfKwdCod what, int node1, int node2, int domain )
1099 _libData->AddEdgeNodes( node1, node2, domain );
1103 ::GmfSetLin(iMesh, what, node1, node2, domain );
1106 //================================================================================
1108 * \brief Add a 'required' flag
1110 //================================================================================
1112 void MG_TetraHPC_API::GmfSetLin(int iMesh, GmfKwdCod what, int id )
1119 ::GmfSetLin(iMesh, what, id );
1122 //================================================================================
1124 * \brief Add triangle nodes
1126 //================================================================================
1128 void MG_TetraHPC_API::GmfSetLin(int iMesh, GmfKwdCod what, int node1, int node2, int node3, int domain )
1132 _libData->AddTriaNodes( node1, node2, node3, domain );
1136 ::GmfSetLin(iMesh, what, node1, node2, node3, domain );
1139 //================================================================================
1141 * \brief Close a file
1143 //================================================================================
1145 void MG_TetraHPC_API::GmfCloseMesh( int iMesh )
1152 ::GmfCloseMesh( iMesh );
1153 _openFiles.erase( iMesh );
1156 //================================================================================
1158 * \brief Return true if the log is not empty
1160 //================================================================================
1162 bool MG_TetraHPC_API::HasLog()
1166 return !_libData->GetErrors().empty();
1169 SMESH_File file( _logFile );
1170 return file.size() > 0;
1173 //================================================================================
1175 * \brief Return log contents
1177 //================================================================================
1179 std::string MG_TetraHPC_API::GetLog()
1183 const std::string& err = _libData->GetErrors();
1184 if ( !_logFile.empty() && !err.empty() )
1186 SMESH_File file( _logFile, /*openForReading=*/false );
1187 file.openForWriting();
1188 file.write( err.c_str(), err.size() );
1193 SMESH_File file( _logFile );
1194 return file.getPos();