~ubuntu-branches/ubuntu/raring/rheolef/raring-proposed

« back to all changes in this revision

Viewing changes to nfem/plib/geo.h

  • Committer: Package Import Robot
  • Author(s): Pierre Saramito, Pierre Saramito, Sylvestre Ledru
  • Date: 2012-05-14 14:02:09 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20120514140209-dzbdlidkotyflf9e
Tags: 6.1-1
[ Pierre Saramito ]
* New upstream release 6.1 (minor changes):
  - support arbitrarily polynomial order Pk
  - source code supports g++-4.7 (closes: #671996)

[ Sylvestre Ledru ]
* update of the watch file

Show diffs side-by-side

added added

removed removed

Lines of Context:
161
161
    virtual size_type serial_number() const = 0;
162
162
    virtual size_type map_dimension() const = 0;
163
163
    virtual coordinate_type coordinate_system() const = 0;
164
 
    virtual const basis& get_piola_basis() const = 0;
 
164
    virtual const basis_basic<T>& get_piola_basis() const = 0;
165
165
    virtual const node_type& xmin() const = 0;
166
166
    virtual const node_type& xmax() const = 0;
167
167
    virtual const geo_size&  sizes() const = 0;
269
269
// allocators:
270
270
 
271
271
    geo_abstract_rep () {}
 
272
    virtual geo_abstract_rep<T,sequential>* clone() const = 0;
272
273
    virtual ~geo_abstract_rep () {}
273
274
 
274
275
// abstract accessors:
314
315
// allocators:
315
316
 
316
317
    geo_abstract_rep () {}
 
318
    virtual geo_abstract_rep<T,distributed>* clone() const = 0;
317
319
    virtual ~geo_abstract_rep () {}
318
320
 
319
321
// abstract accessors:
382
384
 
383
385
    geo_base_rep ();
384
386
    geo_base_rep (const geo_base_rep<T,M>&);
 
387
 
 
388
    void build_from_list (
 
389
      const geo_basic<T,M>&                               lambda,
 
390
      const array<point_basic<T>,M>&                      node_list,
 
391
      const boost::array<array<geo_element_auto<heap_allocator<size_type> >,M>,
 
392
                         reference_element::max_variant>& elt_list);
 
393
 
385
394
    ~geo_base_rep ();
386
395
 
387
396
// abstract accessors defined:
397
406
    void set_name (std::string name) { _name = name; }
398
407
    void set_dimension (size_type dim) { _dimension = dim; }
399
408
    void set_serial_number(size_type i) { _serial_number = i; }
400
 
    const basis& get_piola_basis() const { return _numbering.get_basis(); }
 
409
    const basis_basic<T>& get_piola_basis() const { return _numbering.get_basis(); }
401
410
    const node_type&      xmin() const { return _xmin; }
402
411
    const node_type&      xmax() const { return _xmax; }
403
412
    const geo_size&      sizes() const { return _gs; }
639
648
// allocators:
640
649
 
641
650
    geo_rep();
 
651
    geo_rep (const geo_rep<T,sequential>&);
 
652
    geo_abstract_rep<T,sequential>* clone() const;
 
653
 
 
654
    // build from_list (for level set)
 
655
    geo_rep (
 
656
      const geo_basic<T,sequential>&                      lambda,
 
657
      const array<point_basic<T>,sequential>&             node_list,
 
658
      const boost::array<array<geo_element_auto<heap_allocator<size_type> >,sequential>,
 
659
                         reference_element::max_variant>& elt_list);
 
660
 
642
661
    void build_from_domain (const domain_indirect_rep<sequential>& indirect, const geo_abstract_rep<T,sequential>& omega);
643
662
 
644
663
// abstract accessors redefined:
738
757
 : geo_base_rep<T,sequential>()
739
758
{
740
759
}
 
760
template <class T>
 
761
inline
 
762
geo_rep<T,sequential>::geo_rep (const geo_rep<T,sequential>& omega)
 
763
 : geo_base_rep<T,sequential>(omega)
 
764
{
 
765
}
 
766
template <class T>
 
767
inline
 
768
geo_abstract_rep<T,sequential>*
 
769
geo_rep<T,sequential>::clone() const 
 
770
{
 
771
  typedef geo_rep<T,sequential> rep;
 
772
  return new_macro (rep(*this));
 
773
}
741
774
 
742
775
#ifdef _RHEOLEF_HAVE_MPI
743
776
// =========================================================================
765
798
 
766
799
    geo_rep ();
767
800
    geo_rep (const geo_rep<T,distributed>&);
 
801
    geo_abstract_rep<T,distributed>* clone() const;
 
802
 
768
803
    void build_from_domain (const domain_indirect_rep<distributed>& indirect, const geo_abstract_rep<T,distributed>& omega);
769
804
 
 
805
    // build from_list (for level set)
 
806
    geo_rep (
 
807
      const geo_basic<T,distributed>&                     lambda,
 
808
      const array<point_basic<T>,distributed>&            node_list,
 
809
      const boost::array<array<geo_element_auto<heap_allocator<size_type> >,distributed>,
 
810
                         reference_element::max_variant>& elt_list);
 
811
 
770
812
// abstract accessors defined:
771
813
 
772
814
    distributor geo_element_ios_ownership (size_type dim) const;
893
935
   _ios_igev2dis_igev(o._ios_igev2dis_igev)
894
936
{
895
937
}
 
938
template <class T>
 
939
inline
 
940
geo_abstract_rep<T,distributed>*
 
941
geo_rep<T,distributed>::clone() const 
 
942
{
 
943
  typedef geo_rep<T,distributed> rep;
 
944
  return new_macro (rep(*this));
 
945
}
896
946
#endif // _RHEOLEF_HAVE_MPI
897
947
 
898
948
// =========================================================================
917
967
// =========================================================================
918
968
//<verbatim:
919
969
template <class T>
920
 
class geo_basic<T,sequential> : public smart_pointer<geo_abstract_rep<T,sequential> > {
 
970
class geo_basic<T,sequential> : public smart_pointer_clone<geo_abstract_rep<T,sequential> > {
921
971
public:
922
972
 
923
973
// typedefs:
924
974
 
925
 
    typedef sequential                     memory_type;
 
975
    typedef sequential                              memory_type;
926
976
    typedef geo_abstract_rep<T,sequential>          rep;
927
 
    typedef smart_pointer<rep>                      base;
 
977
    typedef geo_rep<T,sequential>                   rep_geo_rep;
 
978
    typedef smart_pointer_clone<rep>                base;
928
979
    typedef typename rep::size_type                 size_type;
929
980
    typedef typename rep::node_type                 node_type;
930
981
    typedef typename rep::variant_type              variant_type;
943
994
    void load (std::string name, const communicator& comm = communicator());
944
995
    geo_basic (const domain_indirect_basic<sequential>& dom, const geo_basic<T,sequential>& omega);
945
996
 
 
997
    // build from_list (for level set)
 
998
    geo_basic (
 
999
      const geo_basic<T,sequential>&                      lambda,
 
1000
      const array<point_basic<T>,sequential>&             node_list,
 
1001
      const boost::array<array<geo_element_auto<heap_allocator<size_type> >,sequential>,
 
1002
                         reference_element::max_variant>& elt_list)
 
1003
    : base (new_macro(rep_geo_rep(lambda,node_list,elt_list))) {}
 
1004
 
946
1005
// accessors:
947
1006
 
948
1007
    std::string                    name() const { return base::data().name(); }
952
1011
    size_type             serial_number() const { return base::data().serial_number(); }
953
1012
    coordinate_type   coordinate_system() const { return base::data().coordinate_system(); }
954
1013
    std::string  coordinate_system_name() const { return space_constant::coordinate_system_name(coordinate_system()); }
955
 
    const basis&        get_piola_basis() const { return base::data().get_piola_basis(); }
 
1014
    const basis_basic<T>& get_piola_basis() const { return base::data().get_piola_basis(); }
956
1015
    size_type                     order() const { return base::data().get_piola_basis().degree(); }
957
1016
    const node_type&               xmin() const { return base::data().xmin(); }
958
1017
    const node_type&               xmax() const { return base::data().xmax(); }
1055
1114
    const_iterator_by_variant   end_by_variant (variant_type variant) const
1056
1115
        { return base::data().  end_by_variant (variant); }
1057
1116
 
1058
 
    size_type dis_ige2ios_dis_ige (size_type dim, size_type dis_ige) const { return dis_ige; }
1059
 
 
1060
1117
    const geo_basic<T,sequential>& get_background_geo() const; // code in geo_domain.h
1061
1118
          geo_basic<T,sequential>  get_background_domain() const;
1062
1119
 
 
1120
// for compatibility with distributed interface:
 
1121
 
 
1122
    size_type ige2ios_dis_ige (size_type dim, size_type ige) const { return ige; }
 
1123
    size_type dis_ige2ios_dis_ige (size_type dim, size_type dis_ige) const { return dis_ige; }
 
1124
    size_type ios_ige2dis_ige (size_type dim, size_type ios_ige) const { return ios_ige; }
 
1125
 
1063
1126
// comparator:
1064
1127
 
1065
1128
    bool operator== (const geo_basic<T,sequential>& omega2) const { return base::data().operator== (omega2.data()); }
1068
1131
 
1069
1132
    idiststream& get (idiststream& ips);
1070
1133
    odiststream& put (odiststream& ops) const;
1071
 
    void dump (std::string name)        const {        base::data().dump (name); }
 
1134
    void save (std::string filename = "") const;
 
1135
    void dump (std::string name) const {        base::data().dump (name); }
1072
1136
    bool check (bool verbose = true) const { return base::data().check(verbose); }
1073
1137
};
1074
1138
//>verbatim:
1117
1181
// =========================================================================
1118
1182
//<verbatim:
1119
1183
template <class T>
1120
 
class geo_basic<T,distributed> : public smart_pointer<geo_abstract_rep<T,distributed> > {
 
1184
class geo_basic<T,distributed> : public smart_pointer_clone<geo_abstract_rep<T,distributed> > {
1121
1185
public:
1122
1186
 
1123
1187
// typedefs:
1124
1188
 
1125
1189
    typedef distributed                             memory_type;
1126
1190
    typedef geo_abstract_rep<T,distributed>         rep;
1127
 
    typedef smart_pointer<rep>                      base;
 
1191
    typedef geo_rep<T,distributed>                  rep_geo_rep;
 
1192
    typedef smart_pointer_clone<rep>                base;
1128
1193
    typedef typename rep::size_type                 size_type;
1129
1194
    typedef typename rep::node_type                 node_type;
1130
1195
    typedef typename rep::variant_type              variant_type;
1144
1209
    void load (std::string name, const communicator& comm = communicator());
1145
1210
    geo_basic (const domain_indirect_basic<distributed>& dom, const geo_basic<T,distributed>& omega);
1146
1211
 
 
1212
    // build from_list (for level set)
 
1213
    geo_basic (
 
1214
      const geo_basic<T,distributed>&                     lambda,
 
1215
      const array<point_basic<T>,distributed>&                   node_list,
 
1216
      const boost::array<array<geo_element_auto<heap_allocator<size_type> >,distributed>,
 
1217
                         reference_element::max_variant>& elt_list)
 
1218
    : base (new_macro(rep_geo_rep(lambda,node_list,elt_list))) {}
 
1219
 
1147
1220
// accessors:
1148
1221
 
1149
1222
    std::string                    name() const { return base::data().name(); }
1153
1226
    size_type             serial_number() const { return base::data().serial_number(); }
1154
1227
    coordinate_type   coordinate_system() const { return base::data().coordinate_system(); }
1155
1228
    std::string  coordinate_system_name() const { return space_constant::coordinate_system_name(coordinate_system()); }
1156
 
    const basis&        get_piola_basis() const { return base::data().get_piola_basis(); }
 
1229
    const basis_basic<T>& get_piola_basis() const { return base::data().get_piola_basis(); }
1157
1230
    size_type                     order() const { return base::data().get_piola_basis().degree(); }
1158
1231
    const node_type&               xmin() const { return base::data().xmin(); }
1159
1232
    const node_type&               xmax() const { return base::data().xmax(); }
1267
1340
 
1268
1341
    odiststream& put (odiststream& ops) const { return base::data().put (ops); }
1269
1342
    idiststream& get (idiststream& ips);
 
1343
    void save (std::string filename = "") const;
1270
1344
    bool check (bool verbose = true) const { return base::data().check(verbose); }
1271
1345
 
1272
1346
// utilities:
1326
1400
#endif // _RHEOLEF_HAVE_MPI
1327
1401
 
1328
1402
// ==============================================================================
1329
 
// hack : modifier members of smart_pointers on pure virtual base class
 
1403
// geo fat interface: members are specific to geo_rep
 
1404
// => check that pointer to geo_abstract_rep points to a geo_rep
1330
1405
// ==============================================================================
1331
 
// TODO: do it better with a smart_pointer_clone<T>
 
1406
#define _RHEOLEF_save(M)                                                        \
 
1407
template <class T>                                                              \
 
1408
void                                                                            \
 
1409
geo_basic<T,M>::save (std::string filename) const                               \
 
1410
{                                                                               \
 
1411
  if (filename == "") filename = name();                                        \
 
1412
  odiststream out (filename, "geo");                                            \
 
1413
  put (out);                                                                    \
 
1414
}
1332
1415
#define _RHEOLEF_set_nodes(M)                                                   \
1333
1416
template <class T>                                                              \
1334
1417
void                                                                            \
1335
1418
geo_basic<T,M>::set_nodes (const array<node_type,M>& x)                         \
1336
1419
{                                                                               \
1337
 
   const geo_basic<T,M>& const_self = *this;                                    \
1338
 
    check_macro (const_self.data().variant() == geo_abstract_base_rep<T>::geo,  \
1339
 
        "cannot set_nodes on geo_domains");                                     \
1340
 
   const geo_rep<T,M>& geo_data = dynamic_cast<const geo_rep<T,M>&>(const_self.data()); \
1341
 
   typedef geo_rep<T,M> georep;                                                 \
1342
 
   geo_rep<T,M>* ptr = new_macro(georep(geo_data));                             \
1343
 
   ptr->set_nodes(x);                                                           \
1344
 
   base::operator= (ptr);                                                       \
 
1420
  geo_rep<T,M>* ptr = dynamic_cast<geo_rep<T,M>*>(base::pointer());             \
 
1421
  check_macro (ptr != 0, "cannot set_name on geo_domains");                     \
 
1422
  ptr->set_nodes(x);                                                            \
1345
1423
}
1346
1424
#define _RHEOLEF_reset_order(M)                                                 \
1347
1425
template <class T>                                                              \
1348
1426
void                                                                            \
1349
1427
geo_basic<T,M>::reset_order (size_type order)                                   \
1350
1428
{                                                                               \
1351
 
   const geo_basic<T,M>& const_self = *this;                                    \
1352
 
    check_macro (const_self.data().variant() == geo_abstract_base_rep<T>::geo,  \
1353
 
        "cannot set_nodes on geo_domains");                                     \
1354
 
   const geo_rep<T,M>& geo_data = dynamic_cast<const geo_rep<T,M>&>(const_self.data()); \
1355
 
   typedef geo_rep<T,M> georep;                                                 \
1356
 
   geo_rep<T,M>* ptr = new_macro(georep(geo_data));                             \
1357
 
   ptr->reset_order(order);                                                     \
1358
 
   base::operator= (ptr);                                                       \
 
1429
  geo_rep<T,M>* ptr = dynamic_cast<geo_rep<T,M>*>(base::pointer());             \
 
1430
  check_macro (ptr != 0, "cannot set_name on geo_domains");                     \
 
1431
  ptr->reset_order(order);                                                      \
1359
1432
}
1360
1433
#define _RHEOLEF_set_coordinate_system(M)                                       \
1361
1434
template <class T>                                                              \
1362
1435
void                                                                            \
1363
1436
geo_basic<T,M>::set_coordinate_system (coordinate_type sys_coord)               \
1364
1437
{                                                                               \
1365
 
   const geo_basic<T,M>& const_self = *this;                                    \
1366
 
    check_macro (const_self.data().variant() == geo_abstract_base_rep<T>::geo,  \
1367
 
        "cannot set_coordinate_system on geo_domains");                                 \
1368
 
   const geo_rep<T,M>& geo_data = dynamic_cast<const geo_rep<T,M>&>(const_self.data()); \
1369
 
   typedef geo_rep<T,M> georep;                                                 \
1370
 
   geo_rep<T,M>* ptr = new_macro(georep(geo_data));                             \
1371
 
   ptr->set_coordinate_system(sys_coord);                                       \
1372
 
   base::operator= (ptr);                                                       \
 
1438
  geo_rep<T,M>* ptr = dynamic_cast<geo_rep<T,M>*>(base::pointer());             \
 
1439
  check_macro (ptr != 0, "cannot set_name on geo_domains");                     \
 
1440
  ptr->set_coordinate_system(sys_coord);                                        \
1373
1441
}
1374
1442
#define _RHEOLEF_set_dimension(M)                                               \
1375
1443
template <class T>                                                              \
1376
1444
void                                                                            \
1377
1445
geo_basic<T,M>::set_dimension (size_type dim)                                   \
1378
1446
{                                                                               \
1379
 
   const geo_basic<T,M>& const_self = *this;                                    \
1380
 
    check_macro (const_self.data().variant() == geo_abstract_base_rep<T>::geo,  \
1381
 
        "cannot set_dimension on geo_domains");                                 \
1382
 
   const geo_rep<T,M>& geo_data = dynamic_cast<const geo_rep<T,M>&>(const_self.data()); \
1383
 
   typedef geo_rep<T,M> georep;                                                 \
1384
 
   geo_rep<T,M>* ptr = new_macro(georep(geo_data));                             \
1385
 
   ptr->set_dimension(dim);                                                     \
1386
 
   base::operator= (ptr);                                                       \
 
1447
  geo_rep<T,M>* ptr = dynamic_cast<geo_rep<T,M>*>(base::pointer());             \
 
1448
  check_macro (ptr != 0, "cannot set_name on geo_domains");                     \
 
1449
  ptr->set_dimension(dim);                                                      \
1387
1450
}
1388
1451
#define _RHEOLEF_set_serial_number(M)                                           \
1389
1452
template <class T>                                                              \
1390
1453
void                                                                            \
1391
1454
geo_basic<T,M>::set_serial_number (size_type i)                                 \
1392
1455
{                                                                               \
1393
 
   const geo_basic<T,M>& const_self = *this;                                    \
1394
 
    check_macro (const_self.data().variant() == geo_abstract_base_rep<T>::geo,  \
1395
 
        "cannot set_serial_number on geo_domains");                                     \
1396
 
   const geo_rep<T,M>& geo_data = dynamic_cast<const geo_rep<T,M>&>(const_self.data()); \
1397
 
   typedef geo_rep<T,M> georep;                                                 \
1398
 
   geo_rep<T,M>* ptr = new_macro(georep(geo_data));                             \
1399
 
   ptr->set_serial_number(i);                                                   \
1400
 
   base::operator= (ptr);                                                       \
 
1456
  geo_rep<T,M>* ptr = dynamic_cast<geo_rep<T,M>*>(base::pointer());             \
 
1457
  check_macro (ptr != 0, "cannot set_name on geo_domains");                     \
 
1458
  ptr->set_serial_number(i);                                                    \
1401
1459
}
1402
1460
#define _RHEOLEF_set_name(M)                                                    \
1403
1461
template <class T>                                                              \
1404
1462
void                                                                            \
1405
1463
geo_basic<T,M>::set_name (std::string name)                                     \
1406
1464
{                                                                               \
1407
 
   const geo_basic<T,M>& const_self = *this;                                    \
1408
 
    check_macro (const_self.data().variant() == geo_abstract_base_rep<T>::geo,  \
1409
 
        "cannot set_name on geo_domains");                                      \
1410
 
   const geo_rep<T,M>& geo_data = dynamic_cast<const geo_rep<T,M>&>(const_self.data()); \
1411
 
   typedef geo_rep<T,M> georep;                                                 \
1412
 
   geo_rep<T,M>* ptr = new_macro(georep(geo_data));                             \
1413
 
   ptr->set_name(name);                                                         \
1414
 
   base::operator= (ptr);                                                       \
 
1465
  geo_rep<T,M>* ptr = dynamic_cast<geo_rep<T,M>*>(base::pointer());             \
 
1466
  check_macro (ptr != 0, "cannot set_name on geo_domains");                     \
 
1467
  ptr->set_name(name);                                                          \
1415
1468
}
1416
1469
#define _RHEOLEF_build_from_data(M)                                             \
1417
1470
template <class T>                                                              \
1422
1475
        boost::array<array<geo_element_auto<heap_allocator<size_type> >,sequential, heap_allocator<size_type> >, reference_element::max_variant>& tmp_geo_element, \
1423
1476
  bool do_upgrade)                                                              \
1424
1477
{                                                                               \
1425
 
   const geo_basic<T,M>& const_self = *this;                                    \
1426
 
    check_macro (const_self.data().variant() == geo_abstract_base_rep<T>::geo,  \
1427
 
        "cannot build_from_data on geo_domains");                                       \
1428
 
   const geo_rep<T,M>& geo_data = dynamic_cast<const geo_rep<T,M>&>(const_self.data()); \
1429
 
   typedef geo_rep<T,M> georep;                                                 \
1430
 
   geo_rep<T,M>* ptr = new_macro(georep(geo_data));                             \
1431
 
   ptr->build_from_data (hdr, node, tmp_geo_element, do_upgrade);               \
1432
 
   base::operator= (ptr);                                                       \
 
1478
  geo_rep<T,M>* ptr = dynamic_cast<geo_rep<T,M>*>(base::pointer());             \
 
1479
  check_macro (ptr != 0, "cannot set_name on geo_domains");                     \
 
1480
  ptr->build_from_data (hdr, node, tmp_geo_element, do_upgrade);                \
1433
1481
}
1434
1482
 
 
1483
_RHEOLEF_save(sequential)
1435
1484
_RHEOLEF_set_nodes(sequential)
1436
1485
_RHEOLEF_reset_order(sequential)
1437
1486
_RHEOLEF_set_coordinate_system(sequential)
1440
1489
_RHEOLEF_set_name(sequential)
1441
1490
_RHEOLEF_build_from_data(sequential)
1442
1491
#ifdef _RHEOLEF_HAVE_MPI
 
1492
_RHEOLEF_save(distributed)
1443
1493
_RHEOLEF_set_nodes(distributed)
1444
1494
_RHEOLEF_reset_order(distributed)
1445
1495
_RHEOLEF_set_coordinate_system(distributed)