]> SALOME platform Git repositories - modules/homard.git/blob - src/HOMARD/HOMARD_Cas.cxx
Salome HOME
mise a jour pour la poursuite d'iterations
[modules/homard.git] / src / HOMARD / HOMARD_Cas.cxx
1 //  HOMARD HOMARD : implementation of HOMARD idl descriptions
2 //
3 // Copyright (C) 2011-2013  CEA/DEN, EDF R&D
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2.1 of the License.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
18 //
19 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 //
21 //  File   : HOMARD_Cas.cxx
22 //  Author : Paul RASCLE, EDF
23 //  Module : HOMARD
24 //
25 // Remarques :
26 // L'ordre de description des fonctions est le meme dans tous les fichiers
27 // HOMARD_aaaa.idl, HOMARD_aaaa.hxx, HOMARD_aaaa.cxx, HOMARD_aaaa_i.hxx, HOMARD_aaaa_i.cxx :
28 // 1. Les generalites : Name, Delete, DumpPython, Dump, Restore
29 // 2. Les caracteristiques
30 // 3. Le lien avec les autres structures
31 //
32 // Quand les 2 fonctions Setxxx et Getxxx sont presentes, Setxxx est decrit en premier
33
34 #include "HOMARD_Cas.hxx"
35 #include "utilities.h"
36 #include <iostream>
37 #include <sys/stat.h>
38
39 #ifndef WIN32
40 # include <unistd.h>
41 #endif
42
43 //=============================================================================
44 /*!
45  *  default constructor:
46  *  Par defaut, l'adaptation est conforme, sans suivi de frontiere
47  */
48 //=============================================================================
49 HOMARD_Cas::HOMARD_Cas():
50   _Name(""), _NomDir("/tmp"), _ConfType(1)
51 {
52   MESSAGE("HOMARD_Cas");
53 }
54 //=============================================================================
55 HOMARD_Cas::~HOMARD_Cas()
56 //=============================================================================
57 {
58   MESSAGE("~HOMARD_Cas");
59 }
60 //=============================================================================
61 //=============================================================================
62 // Generalites
63 //=============================================================================
64 //=============================================================================
65 void HOMARD_Cas::SetName( const char* Name )
66 {
67   _Name = std::string( Name );
68 }
69 //=============================================================================
70 std::string HOMARD_Cas::GetName() const
71 {
72   return _Name;
73 }
74 //=============================================================================
75 std::string HOMARD_Cas::GetDumpPython() const
76 {
77   std::ostringstream aScript;
78   aScript << "\t" <<_Name << ".SetDirName(\"";
79   aScript << _NomDir << "\")\n";
80   aScript << "\t" <<_Name << ".SetConfType(";
81   aScript << _ConfType << ")\n";
82 // Suivi de frontieres
83   std::list<std::string>::const_iterator it = _ListBoundaryGroup.begin();
84   while(it != _ListBoundaryGroup.end())
85   {
86     aScript << "\t" <<_Name << ".AddBoundaryGroup(\"";
87     aScript << *it << "\", \"";
88     it++;
89     aScript << *it << "\")\n";
90     it++;
91   }
92   if ( _Pyram > 0 )
93   {
94     aScript << "\t" <<_Name << ".SetPyram(";
95     aScript << _Pyram << ")\n";
96   }
97
98   return aScript.str();
99 }
100 //=============================================================================
101 //=============================================================================
102 // Caracteristiques
103 //=============================================================================
104 //=============================================================================
105 int HOMARD_Cas::SetDirName( const char* NomDir )
106 {
107   MESSAGE("SetDirName,  NomDir : "<<NomDir);
108   MESSAGE("SetDirName, _NomDir : "<<_NomDir);
109   int erreur = 0 ;
110   // On vérifie qu'aucun calcul n'a eu lieu
111   MESSAGE("SetDirName, _ListIter.size() : "<<_ListIter.size());
112   if ( _ListIter.size() > 1 ) { erreur = 1 ; }
113   // Creation
114   if ( chdir(NomDir) == 0 ) { _NomDir = std::string( NomDir ); }
115   else
116   {
117     if ( mkdir(NomDir, S_IRWXU|S_IRGRP|S_IXGRP) == 0 )
118     {
119       if ( chdir(NomDir) == 0 ) { _NomDir = std::string( NomDir ); }
120       else                      { erreur = 2 ; }
121     }
122     else { erreur = 2 ; }
123   };
124   return erreur ;
125 }
126 //=============================================================================
127 std::string HOMARD_Cas::GetDirName() const
128 {
129   return _NomDir;
130 }
131 //=============================================================================
132 int HOMARD_Cas::GetNumberofIter()
133 {
134   return _ListIter.size();
135 }
136 //=============================================================================
137 void HOMARD_Cas::SetConfType( int Conftype )
138 {
139   _ConfType = Conftype;
140 }
141 //=============================================================================
142 const int HOMARD_Cas::GetConfType() const
143 {
144   return _ConfType;
145 }
146 //
147 // La boite englobante
148 //
149 //=============================================================================
150 void HOMARD_Cas::SetBoundingBox( const std::vector<double>& extremas )
151 {
152   _Boite.clear();
153   _Boite.resize( extremas.size() );
154   for ( int i = 0; i < extremas.size(); i++ )
155     _Boite[i] = extremas[i];
156 }
157 //=============================================================================
158 const std::vector<double>& HOMARD_Cas::GetBoundingBox() const
159 {
160   return _Boite;
161 }
162 //
163 // Les groupes
164 //
165 //=============================================================================
166 void HOMARD_Cas::AddGroup( const char* Group )
167 {
168   _ListGroup.push_back(Group);
169 }
170 //=============================================================================
171 void HOMARD_Cas::SetGroups( const std::list<std::string>& ListGroup )
172 {
173   _ListGroup.clear();
174   std::list<std::string>::const_iterator it = ListGroup.begin();
175   while(it != ListGroup.end())
176   {
177     _ListGroup.push_back((*it++));
178   }
179 }
180 //=============================================================================
181 const std::list<std::string>& HOMARD_Cas::GetGroups() const
182 {
183   return _ListGroup;
184 }
185 //=============================================================================
186 void HOMARD_Cas::SupprGroups()
187 {
188   _ListGroup.clear();
189 }
190 //
191 // Les frontieres
192 //
193 //=============================================================================
194 void HOMARD_Cas::AddBoundaryGroup( const char* Boundary, const char* Group )
195 {
196   _ListBoundaryGroup.push_back( Boundary );
197   _ListBoundaryGroup.push_back( Group    );
198 }
199 //=============================================================================
200 const std::list<std::string>& HOMARD_Cas::GetBoundaryGroup() const
201 {
202   return _ListBoundaryGroup;
203 }
204 //=============================================================================
205 void HOMARD_Cas::SupprBoundaryGroup()
206 {
207   _ListBoundaryGroup.clear();
208 }
209 //=============================================================================
210 void HOMARD_Cas::SetPyram( int Pyram )
211 {
212   _Pyram = Pyram;
213 }
214 //=============================================================================
215 const int HOMARD_Cas::GetPyram() const
216 {
217   return _Pyram;
218 }
219 //=============================================================================
220 //=============================================================================
221 // Liens avec les autres structures
222 //=============================================================================
223 //=============================================================================
224 std::string HOMARD_Cas::GetIter0Name() const
225 {
226 // Par construction de la liste, l'iteration a ete mise en tete.
227   return (*(_ListIter.begin()));
228 }
229 //=============================================================================
230 void HOMARD_Cas::AddIteration( const char* NomIteration )
231 {
232   _ListIter.push_back( std::string( NomIteration ) );
233 }
234 //=============================================================================
235 const std::list<std::string>& HOMARD_Cas::GetIterations() const
236 {
237   return _ListIter;
238 }
239 //=============================================================================
240 void HOMARD_Cas::SupprIterations()
241 {
242   _ListIter.clear();
243 }
244
245