Ignore:
Timestamp:
10/07/10 16:17:04 (14 years ago)
Author:
hozdoba
Message:

suite du précédent commit

File:
1 edited

Legend:

Unmodified
Added
Removed
  • XMLIO_V2/dev/dev_rv/src/XMLIO/grid.hpp

    r125 r127  
    1111      public: 
    1212 
    13          CGrid(void) : ObjectTemplate<CGrid>(), GridAttribut(), hasAxis(false), axis(NULL), domain(NULL) 
     13         CGrid(void) 
     14            : ObjectTemplate<CGrid>(), GridAttribut(), 
     15              hasAxis(false), axis(NULL), domain(NULL) 
    1416         { /* Ne rien faire de plus */ } 
    1517 
    16          CGrid(const string& _id) : ObjectTemplate<CGrid>(_id), GridAttribut(), hasAxis(false), axis(NULL), domain(NULL) 
     18         CGrid(const string& _id) 
     19            : ObjectTemplate<CGrid>(_id), GridAttribut(), 
     20              hasAxis(false), axis(NULL), domain(NULL) 
    1721         { /* Ne rien faire de plus */ } 
    1822 
    19          static string GetName(void) { return ("grid"); } 
    20          static string GetDefName(void)  { return (CGrid::GetName()); } 
    21  
    22          const CAxis* getRelAxis(void) const { return (axis); } 
     23         const CAxis*   getRelAxis  (void) const { return (axis); } 
    2324         const CDomain* getRelDomain(void) const { return (domain); } 
    2425 
    25          const Array<int, 1>& getStoreIndex(void) { return (storeIndex); } 
    26          const Array<int, 1>& getOutIIndex(void) { return (out_i_index); } 
    27          const Array<int, 1>& getOutJIndex(void) { return (out_j_index); } 
    28          const Array<int, 1>& getOutLIndex(void) { return (out_l_index); } 
    29  
    30          inline void solveReference(void) ; 
    31          inline void solveDomainRef(void) ; 
    32          inline void solveAxisRef(void) ; 
     26         const Array<int, 1>& getStoreIndex(void) const { return (storeIndex); } 
     27         const Array<int, 1>& getOutIIndex(void)  const { return (out_i_index); } 
     28         const Array<int, 1>& getOutJIndex(void)  const { return (out_j_index); } 
     29         const Array<int, 1>& getOutLIndex(void)  const { return (out_l_index); } 
     30 
     31         void solveReference(void) 
     32         { this->solveDomainRef() ; this->solveAxisRef() ; this->computeIndex() ; } 
     33 
     34         void solveDomainRef(void) 
     35         { 
     36            if (domain_ref.hasValue()) 
     37            { 
     38               if (CDomain::HasObject(domain_ref)) 
     39               { 
     40                 domain = CDomain::GetObject(domain_ref) ; 
     41                 domain->check() ; 
     42               } 
     43               else ERROR("Référence au domaine incorrecte") ; 
     44            } 
     45            else ERROR("Domaine non défini") ; 
     46         } 
     47 
     48         void solveAxisRef(void) 
     49         { 
     50            if (axis_ref.hasValue()) 
     51            { 
     52               hasAxis = true ; 
     53               if (CAxis::HasObject(axis_ref)) axis = CAxis::GetObject(axis_ref) ; 
     54               else ERROR("Référence a l'axe incorrecte") ; 
     55            } 
     56            else hasAxis = false ; // hasAxis est normalement déjà à false(?). 
     57         } 
    3358 
    3459         inline void computeIndex(void); 
     
    3661         bool _hasAxis(void) const { return (hasAxis); } 
    3762 
    38          inline void storeField(const Array<double, 1>& field, Array<double, 1>& stored) const; 
    39          inline void storeField(const Array<double, 2>& field, Array<double, 1>& stored) const; 
    40          inline void storeField(const Array<double, 3>& field, Array<double, 1>& stored) const; 
    41          inline void storeField(const double* const data, Array<double, 1>& stored) const; 
    42  
    43          inline void outputField(const Array<double,1>& stored, Array<double, 2>& outField) const; 
    44          inline void outputField(const Array<double,1>& stored, Array<double, 3>& outField) const; 
    45  
    46          inline static CGrid* CreateObject(const CDomain* const a_domain, const CAxis* const a_axis); 
    47          inline static CGrid* CreateObject(const CDomain* const a_domain); 
     63         template <class T> 
     64            void storeField(const T& field, Array<double, 1>& stored) const 
     65         { this->storeField_arr(field.dataFirst(), stored) ; } 
     66 
     67         template <class T> 
     68            inline void outputField(const Array<double, 1>& stored, T&) const; 
     69 
     70      public : /* virtual */ 
    4871 
    4972         virtual ~CGrid(void) 
    5073         { /* Ne rien faire de plus */ } 
    5174 
     75      public : /* static */ 
     76 
     77         static string GetName   (void) { return ("grid"); } 
     78         static string GetDefName(void) { return (CGrid::GetName()); } 
     79 
     80         static CGrid* CreateObject(const CDomain* const a_domain, const CAxis* const a_axis) 
     81         { 
     82            string new_id = string("___") + a_domain->getId() + string("_") + a_axis->getId() + string("__") ; 
     83            CGrid* const grid = ObjectTemplate<CGrid>::CreateObject(new_id) ; 
     84 
     85            grid->domain_ref = a_domain->getId() ; 
     86            grid->axis_ref   = a_axis  ->getId() ; 
     87 
     88            return (grid); 
     89         } 
     90 
     91         static CGrid* CreateObject(const CDomain* const a_domain) 
     92         { 
     93            string new_id = string("___") + a_domain->getId() + string("__") ; 
     94            CGrid* const grid = ObjectTemplate<CGrid>::CreateObject(new_id) ; 
     95            grid->domain_ref = a_domain->getId() ; 
     96 
     97            return (grid); 
     98         } 
     99 
     100      protected : 
     101 
     102         void storeField_arr(const double* const data, Array<double, 1>& stored) const 
     103         { 
     104            const int size = storeIndex.size() ; 
     105            stored.resize(shape(size)) ; 
     106            for(int i = 0; i < size; i++) 
     107               stored(i) = data[storeIndex(i)] ; 
     108         } 
     109 
    52110      private: 
    53111 
    54112         bool hasAxis ; 
    55113 
    56          CAxis* axis ; 
    57          CDomain* domain ; 
     114         CAxis   * axis ; 
     115         CDomain * domain ; 
    58116 
    59117         Array<int, 1> storeIndex ; 
     
    64122   }; // class CGrid 
    65123 
    66    CGrid* CGrid::CreateObject(const CDomain* const a_domain, const CAxis* const a_axis) 
    67    { 
    68       string new_id = string("___") + a_domain->getId() + string("_") + a_axis->getId() + string("__") ; 
    69       CGrid* const grid = ObjectTemplate<CGrid>::CreateObject(new_id) ; 
    70  
    71       grid->domain_ref = a_domain->getId() ; 
    72       grid->axis_ref   = a_axis  ->getId() ; 
    73  
    74       return (grid); 
    75    } 
    76  
    77    CGrid* CGrid::CreateObject(const CDomain* const a_domain) 
    78    { 
    79       string new_id = string("___") + a_domain->getId() + string("__") ; 
    80       CGrid* const grid = ObjectTemplate<CGrid>::CreateObject(new_id) ; 
    81  
    82       grid->domain_ref = a_domain->getId() ; 
    83  
    84       return (grid); 
    85    } 
    86  
    87    void CGrid::solveReference(void) 
    88    { 
    89  
    90       /**static bool isReferenceSolved = false; 
    91       if (isReferenceSolved) 
    92       { 
    93          std::cout << "C'est n'importe quoi, A modifierrrrrrrrrrr!!!!!!!!!!!!!!!!!!!!!" << std::endl; 
    94          return; 
    95       }*/ 
    96  
    97       // Résolution de chacune des références et indexation. 
    98       solveDomainRef() ; 
    99       solveAxisRef() ; 
    100       computeIndex() ; 
    101  
    102       //isReferenceSolved = true ; 
    103    } 
    104  
    105    void CGrid::solveDomainRef(void) 
    106    { 
    107       if (domain_ref.hasValue()) 
    108       { 
    109          if (CDomain::HasObject(domain_ref)) 
    110          { 
    111            domain = CDomain::GetObject(domain_ref) ; 
    112            domain->check() ; 
    113          } 
    114          else ERROR("Référence au domaine incorrecte") ; 
    115       } 
    116       else ERROR("Domaine non défini") ; 
    117    } 
    118  
    119    void CGrid::solveAxisRef(void) 
    120    { 
    121       if (axis_ref.hasValue()) 
    122       { 
    123          hasAxis = true ; 
    124          if (CAxis::HasObject(axis_ref)) axis = CAxis::GetObject(axis_ref) ; 
    125          else ERROR("Référence a l'axe incorrecte") ; 
    126       } 
    127       else hasAxis = false ; // hasAxis est normalement déjà à false(?). 
    128    } 
    129  
    130124   void CGrid::computeIndex(void) 
    131125   { 
    132  
    133126      int ni = domain->ni ; 
    134127      int nj = domain->nj ; 
     
    196189         } 
    197190      } 
    198  
    199       /** Pour tests 
    200  
    201       cout << "Out of CGrid::ComputeIndex" << endl ; 
    202  
    203       cout << "storeIndex : " << endl ; 
    204       cout << storeIndex << endl ; 
    205  
    206       cout << "out_i_index : " << endl ; 
    207       cout << out_i_index << endl ; 
    208  
    209       cout << "out_j_index : " << endl ; 
    210       cout << out_j_index << endl ; 
    211  
    212       cout << "out_l_index : " << endl ; 
    213       cout << out_l_index << endl ; 
    214  
    215       **/ 
    216  
    217191   } 
    218192 
    219    void CGrid::storeField(const Array<double, 1>& field, Array<double, 1>& stored) const 
    220    { 
    221       storeField(field.dataFirst(), stored) ; 
    222       //cout<<"Stored 1"<<stored<<endl ; 
    223    } 
    224  
    225    void CGrid::storeField(const Array<double, 2>& field, Array<double, 1>& stored) const 
    226    { 
    227       storeField(field.dataFirst(), stored) ; 
    228       //cout<<"Stored 2"<<stored<<endl ; 
    229    } 
    230  
    231    void CGrid::storeField(const Array<double, 3>& field, Array<double, 1>& stored) const 
    232    { 
    233       storeField(field.dataFirst(), stored) ; 
    234       //cout<<"Stored 3"<<stored<<endl ; 
    235    } 
    236  
    237    void CGrid::storeField(const double* const data, Array<double, 1>& stored) const 
    238    { 
    239       int size = storeIndex.size() ; 
    240       //cout << "size " << size << endl ; 
    241  
    242       stored.resize(shape(size)) ; 
    243       //cout << "Stored " << stored << endl ; 
    244  
    245       for(int i = 0; i < size; i++) stored(i) = data[storeIndex(i)] ; 
    246       //cout << "Stored " << stored << endl ; 
    247    } 
    248  
    249    void CGrid::outputField(const Array<double, 1>& stored, Array<double, 2>& outField) const 
     193   template<> 
     194      void CGrid::outputField(const Array<double, 1>& stored, Array<double, 2>& outField) const 
    250195   { 
    251196      for(int n = 0; n < storeIndex.size(); n++) 
     
    253198   } 
    254199 
    255    void CGrid::outputField(const Array<double, 1>& stored, Array<double, 3>& outField) const 
     200   template<> 
     201      void CGrid::outputField(const Array<double, 1>& stored, Array<double, 3>& outField) const 
    256202   { 
    257203      for(int n = 0; n < storeIndex.size(); n++) 
Note: See TracChangeset for help on using the changeset viewer.