/usr/include/rheolef/field_concat.h is in librheolef-dev 6.5-1+b1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | #ifndef _RHEOLEF_FIELD_CONCAT_H
#define _RHEOLEF_FIELD_CONCAT_H
///
/// This file is part of Rheolef.
///
/// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
///
/// Rheolef is free software; you can redistribute it and/or modify
/// it under the terms of the GNU General Public License as published by
/// the Free Software Foundation; either version 2 of the License, or
/// (at your option) any later version.
///
/// Rheolef is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
/// GNU General Public License for more details.
///
/// You should have received a copy of the GNU General Public License
/// along with Rheolef; if not, write to the Free Software
/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
///
/// =========================================================================
// build field from initializer lists
//
#include "rheolef/field.h"
#include "rheolef/field_component.h"
#include "rheolef/space_mult.h"
namespace rheolef {
template <class T, class M>
struct field_concat_value {
// typedef:
typedef enum { scalar, field} variant_type;
// allocators:
field_concat_value (const T& x) : s(x), f(), variant(scalar) {}
field_concat_value (const field_basic<T,M>& x) : s(), f(x), variant(field) {}
// io/debug:
friend std::ostream& operator<< (std::ostream& o, const field_concat_value<T,M>& x) {
if (x.variant == scalar) return o << "s"; else return o << "f";
}
// data:
public:
T s;
field_basic<T,M> f;
variant_type variant;
};
template <class T, class M>
struct field_concat {
// typedef:
typedef typename field_basic<T,M>::size_type size_type;
typedef field_concat_value<T,M> value_type;
// allocators:
field_concat () : _l() {}
#ifdef _RHEOLEF_HAVE_STD_INITIALIZER_LIST
field_concat (const std::initializer_list<value_type>& il) : _l() {
#ifdef _RHEOLEF_HAVE_STD_INITIALIZER_ITERATOR
typedef typename std::initializer_list<value_type>::const_iterator const_iterator;
#else // _RHEOLEF_HAVE_STD_INITIALIZER_ITERATOR
typedef const value_type* const_iterator;
#endif // _RHEOLEF_HAVE_STD_INITIALIZER_ITERATOR
for(const_iterator iter = il.begin(); iter != il.end(); ++iter) {
_l.push_back(*iter);
}
}
#endif // _RHEOLEF_HAVE_STD_INITIALIZER_LIST
friend std::ostream& operator<< (std::ostream& o, const field_concat<T,M>& x) {
std::cout << "{";
for(typename std::list<value_type>::const_iterator iter = x._l.begin(); iter != x._l.end(); ++iter) {
std::cout << *iter << " ";
}
return std::cout << "}";
}
field_basic<T,M> build_field() const;
// data:
protected:
std::list<value_type> _l;
};
template <class T, class M>
field_basic<T,M>
field_concat<T,M>::build_field() const
{
// ------------------------------------
// first pass: compute the field size
// ------------------------------------
space_mult_list<T,M> sml;
for(typename std::list<value_type>::const_iterator iter = _l.begin(); iter != _l.end(); ++iter) {
const field_concat_value<T,M>& x = *iter;
if (x.variant == value_type::field) {
sml *= x.f.get_space();
} else {
// TODO: IR space as 0d mesh and P1 ?
fatal_macro("field initializer list: constant not yet supported");
}
}
space_basic<T,M> Yh (sml);
// ------------------------
// second pass: copy values
// ------------------------
field_basic<T,M> yh (Yh);
size_type i_comp = 0;
for(typename std::list<value_type>::const_iterator iter = _l.begin(); iter != _l.end(); ++iter, i_comp++) {
const field_concat_value<T,M>& x = *iter;
if (x.variant == value_type::field) {
yh [i_comp] = x.f;
} else {
fatal_macro("field initializer list: constant not yet supported");
}
}
#ifdef TODO
#endif // TODO
return yh;
}
#ifdef _RHEOLEF_HAVE_STD_INITIALIZER_LIST
template <class T, class M>
inline
field_basic<T,M>::field_basic (const std::initializer_list<field_concat_value<T,M> >& init_list)
{
field_concat<T,M> vc (init_list);
field_basic<T,M>::operator= (vc.build_field());
}
template <class T, class M>
inline
field_basic<T,M>&
field_basic<T,M>::operator= (const std::initializer_list<field_concat_value<T,M> >& init_list)
{
field_concat<T,M> vc (init_list);
field_basic<T,M>::operator= (vc.build_field());
return *this;
}
#endif // _RHEOLEF_HAVE_STD_INITIALIZER_LIST
} // namespace rheolef
#endif // _RHEOLEF_FIELD_CONCAT_H
|