Salome HOME
Adding Multinode method for smesh parallelism + cleanup and doc
[modules/smesh.git] / src / SMESH_I / SMESH_ParallelMesh_i.cxx
1 // Copyright (C) 2007-2023  CEA, EDF, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
10 //
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // Lesser General Public License for more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22 //  File   : SMESH_ParallelMesh_i.cxx
23 //  Author : Yoann AUDOUIN, EDF
24 //  Module : SMESH
25
26 #include "SMESH_ParallelMesh_i.hxx"
27 #include "SMESH_Mesh_i.hxx"
28
29 #include "SMESH_Gen_i.hxx"
30
31
32 //=============================================================================
33 namespace
34 {
35   //!< implementation of struct used to call methods of SMESH_Mesh_i from SMESH_Mesh
36   // issue 0020918: groups removal is caused by hyp modification
37   // issue 0021208: to forget not loaded mesh data at hyp modification
38   struct TCallUp_i : public SMESH_ParallelMesh::TCallUp
39   {
40     SMESH_ParallelMesh_i* _mesh;
41     TCallUp_i(SMESH_ParallelMesh_i* mesh):_mesh(mesh) {}
42     void RemoveGroup (const int theGroupID) override { _mesh->removeGroup( theGroupID ); }
43     void HypothesisModified( int hypID,
44                              bool updIcons) override { _mesh->onHypothesisModified( hypID,
45                                                                                     updIcons ); }
46     void Load ()                            override { _mesh->Load(); }
47     bool IsLoaded()                         override { return _mesh->IsLoaded(); }
48     TopoDS_Shape GetShapeByEntry(const std::string& entry) override
49     {
50       GEOM::GEOM_Object_var go = SMESH_Gen_i::GetGeomObjectByEntry( entry );
51       return SMESH_Gen_i::GeomObjectToShape( go );
52     }
53   };
54 }
55
56 ::SMESH_ParallelMesh* SMESH_ParallelMesh_i::DownCast()
57 {
58   ::SMESH_ParallelMesh* myImpl = dynamic_cast<::SMESH_ParallelMesh*>(_impl);
59   if (myImpl == NULL)
60     THROW_SALOME_CORBA_EXCEPTION("Could not cast as ParallelMesh", SALOME::INTERNAL_ERROR);
61
62   return myImpl;
63 }
64
65 //=============================================================================
66 /*!
67  * \brief Get the parallellism method
68  */
69 //=============================================================================
70
71 CORBA::Long SMESH_ParallelMesh_i::GetParallelismMethod(){
72   return DownCast()->GetParallelismMethod();
73 }
74
75 //=============================================================================
76 /*!
77  * \brief Set the parallellism method
78  */
79 //=============================================================================
80 void SMESH_ParallelMesh_i::SetParallelismMethod(CORBA::Long aMethod){
81   DownCast()->SetParallelismMethod(aMethod);
82 }
83
84 //=============================================================================
85 /*!
86  * \brief Get the number of threads for a parallel computation
87  */
88 //=============================================================================
89 CORBA::Long SMESH_ParallelMesh_i::GetNbThreads(){
90   return DownCast()->GetNbThreads();
91 }
92
93 //=============================================================================
94 /*!
95  * \brief Set the number of threads for a parallel computation
96  */
97 //=============================================================================
98 void SMESH_ParallelMesh_i::SetNbThreads(CORBA::Long nbThreads){
99   DownCast()->SetNbThreads(nbThreads);
100 }
101
102 //=============================================================================
103 /*!
104  * \brief Get the ressource to connect to
105  */
106 //=============================================================================
107 char* SMESH_ParallelMesh_i::GetResource(){
108   return CORBA::string_dup(DownCast()->GetResource().c_str());
109 }
110
111 //=============================================================================
112 /*!
113  * \brief Set the ressource to connect to
114  */
115 //=============================================================================
116 void SMESH_ParallelMesh_i::SetResource(const char* aResource){
117   DownCast()->SetResource(std::string(aResource));
118 }
119
120 //=============================================================================
121 /*!
122  * \brief Get the number of processor to use on ressource
123  */
124 //=============================================================================
125 CORBA::Long SMESH_ParallelMesh_i::GetNbProc(){
126   return DownCast()->GetNbProc();
127 }
128
129 //=============================================================================
130 /*!
131  * \brief Set the number of processor to use on ressource
132  */
133 //=============================================================================
134 void SMESH_ParallelMesh_i::SetNbProc(CORBA::Long nbProcs){
135   DownCast()->SetNbProc(nbProcs);
136 }
137
138 //=============================================================================
139 /*!
140  * \brief Get the number of processor per node to use on ressource
141  */
142 //=============================================================================
143 CORBA::Long SMESH_ParallelMesh_i::GetNbProcPerNode(){
144   return DownCast()->GetNbProcPerNode();
145 }
146
147 //=============================================================================
148 /*!
149  * \brief Set the number of processor per node to use on ressource
150  */
151 //=============================================================================
152 void SMESH_ParallelMesh_i::SetNbProcPerNode(CORBA::Long nbProcPerNodes){
153   DownCast()->SetNbProcPerNode(nbProcPerNodes);
154 }
155
156 //=============================================================================
157 /*!
158  * \brief Get the number of node to use on ressource
159  */
160 //=============================================================================
161 CORBA::Long SMESH_ParallelMesh_i::GetNbNode(){
162   return DownCast()->GetNbNode();
163 }
164
165 //=============================================================================
166 /*!
167  * \brief Set the number of node to use on ressource
168  */
169 //=============================================================================
170 void SMESH_ParallelMesh_i::SetNbNode(CORBA::Long nbNodes){
171   DownCast()->SetNbNode(nbNodes);
172 }
173
174 //=============================================================================
175 /*!
176  * \brief Get the wckey to use on ressource
177  */
178 //=============================================================================
179 char* SMESH_ParallelMesh_i::GetWcKey(){
180   return CORBA::string_dup(DownCast()->GetWcKey().c_str());
181 }
182
183 //=============================================================================
184 /*!
185  * \brief Set the wckey to use on ressource
186  */
187 //=============================================================================
188 void SMESH_ParallelMesh_i::SetWcKey(const char* wcKey){
189   DownCast()->SetWcKey(std::string(wcKey));
190 }