/usr/include/rheolef/branch.h is in librheolef-dev 5.93-2.
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 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 | #ifndef _RHEO_BRANCH_H
#define _RHEO_BRANCH_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
///
/// =========================================================================
#include "rheolef/field.h"
namespace rheolef {
class __obranch;
class __iobranch;
class __branch_header;
class __const_branch_header;
class __const_branch_finalize;
/*Class:branch
@cindex animation
@cindex continuation methods
@cindex time-dependent problems
@clindex field
NAME: @code{branch} - (t,uh(t)) finite element function
DESCRIPTION:
Stores a @code{field} together with its associated parameter
value: a @code{branch} variable represents a pair (t,uh(t)) for
a specific value of the parameter t.
Applications concern time-dependent problems and continuation methods.
This class is convenient for file inputs/outputs
and building graphical animations.
EXAMPLES:
Coming soon...
LIMITATIONS:
This class is under development.
The @code{branch} class store pointers on @code{field} class
without reference counting. Thus, @code{branch} automatic
variables cannot be returned by functions. @code{branch}
variable are limited to local variables.
At each step, meshes are reloaded and spaces are rebuilted, even
when they are identical.
The @code{vtk} render does not support mesh change during
the loop (e.g. when using adaptive mesh process).
AUTHOR:
LMC-IMAG, 38041 Grenoble cedex 9, France.
@url{mailto:Pierre.Saramito@imag.fr}
END:
*/
// =============================================================================
// class definition
// =============================================================================
//<branch:
class branch : public std::vector<std::pair<std::string,field> > {
public :
// allocators:
branch ();
branch (const std::string& parameter_name, const std::string& u_name);
branch (const std::string& parameter_name, const std::string& u_name, const std::string& p_name);
~branch ();
// accessors:
const Float& parameter () const;
const std::string& parameter_name () const;
size_type n_value () const;
size_type n_field () const;
// modifiers:
void set_parameter (const Float& value);
// input/output:
// get/set current value
friend std::istream& operator >> (std::istream&, branch&);
friend std::ostream& operator << (std::ostream&, const branch&);
__branch_header header ();
__const_branch_header header () const;
__const_branch_finalize finalize () const;
__obranch operator() (const Float& t, const field& u);
__obranch operator() (const Float& t, const field& u, const field& p);
__iobranch operator() (Float& t, field& u);
__iobranch operator() (Float& t, field& u, field& p);
//>branch:
// implementation
public:
void put_header (std::ostream&) const;
void get_header (std::istream&);
void put_finalize (std::ostream&) const;
friend class __obranch;
friend class __iobranch;
// file formats
void put_header_rheolef (std::ostream&) const;
void put_event_rheolef (std::ostream&) const;
void put_header_gnuplot (std::ostream&) const;
void put_event_gnuplot (std::ostream&) const;
void put_finalize_gnuplot (std::ostream&) const;
void put_header_vtk (std::ostream&) const;
void put_geometry_vtk (std::ostream&) const;
void put_event_vtk (std::ostream&) const;
void put_finalize_vtk (std::ostream&) const;
void put_header_paraview (std::ostream&) const;
void put_event_paraview (std::ostream&) const;
void put_finalize_paraview (std::ostream&) const;
// data:
protected:
std::string _parameter_name;
Float _parameter_value;
size_type _n_value;
mutable size_type _count_value;
mutable std::ostream* _p_data_out;
mutable bool _header_printed;
};
std::istream& operator >> (std::istream&, branch&);
std::ostream& operator << (std::ostream&, const branch&);
// =============================================================================
// inlined
// =============================================================================
inline
branch::branch ()
: std::vector<std::pair<std::string,field> >(0),
_parameter_name ("unamed"),
_parameter_value(std::numeric_limits<Float>::max()),
_n_value (std::numeric_limits<size_type>::max()),
_count_value (std::numeric_limits<size_type>::max()),
_p_data_out (0),
_header_printed (false)
{
}
inline
branch::branch (const std::string& parameter_name, const std::string& field_name)
: std::vector<std::pair<std::string,field> >(1),
_parameter_name (parameter_name),
_parameter_value(std::numeric_limits<Float>::max()),
_n_value (std::numeric_limits<size_type>::max()),
_count_value (std::numeric_limits<size_type>::max()),
_p_data_out (0),
_header_printed (false)
{
check_macro(parameter_name.length() != 0, "empty parameter name not allowed");
check_macro(field_name.length() != 0, "empty field name not allowed");
operator[](0).first = field_name;
}
inline
branch::branch (const std::string& parameter_name, const std::string& u_name, const std::string& p_name)
: std::vector<std::pair<std::string,field> >(2),
_parameter_name (parameter_name),
_parameter_value(std::numeric_limits<Float>::max()),
_n_value (std::numeric_limits<size_type>::max()),
_count_value (std::numeric_limits<size_type>::max()),
_p_data_out (0),
_header_printed (false)
{
check_macro(parameter_name.length() != 0, "empty parameter name not allowed");
check_macro(u_name.length() != 0, "empty field #1 name not allowed");
check_macro(p_name.length() != 0, "empty field #2 name not allowed");
operator[](0).first = u_name;
operator[](1).first = p_name;
}
// -----------------------------------------------------------------------------
// accessors
// -----------------------------------------------------------------------------
inline
const Float&
branch::parameter () const
{
return _parameter_value;
}
inline
const std::string&
branch::parameter_name () const
{
return _parameter_name;
}
inline
branch::size_type
branch::n_value () const
{
return _n_value;
}
inline
branch::size_type
branch::n_field () const
{
return size();
}
// -----------------------------------------------------------------------------
// modifiers
// -----------------------------------------------------------------------------
inline
void
branch::set_parameter (const Float& x)
{
_parameter_value = x;
}
// -----------------------------------------------------------------------------
// io header wrapper
// -----------------------------------------------------------------------------
class __branch_header {
public:
__branch_header (branch& b) : _b(b) {}
friend std::istream& operator >> (std::istream& in, __branch_header h) {
h._b.get_header(in); return in; }
friend std::ostream& operator << (std::ostream& out, __branch_header h) {
h._b.put_header(out); return out; }
protected:
branch& _b;
friend class __const_branch_header;
};
class __const_branch_header {
public:
__const_branch_header (const branch& b) : _b(b) {}
__const_branch_header (__branch_header h) : _b(h._b) {}
friend std::ostream& operator << (std::ostream& out, __const_branch_header h) {
h._b.put_header(out); return out; }
protected:
const branch& _b;
};
inline
__branch_header
branch::header ()
{
return *this;
}
inline
__const_branch_header
branch::header () const
{
return *this;
}
// -----------------------------------------------------------------------------
// o finalize wrapper
// -----------------------------------------------------------------------------
class __const_branch_finalize {
public:
__const_branch_finalize (const branch& b) : _b(b) {}
friend std::ostream& operator << (std::ostream& out, __const_branch_finalize h) {
h._b.put_finalize(out); return out; }
protected:
const branch& _b;
};
inline
__const_branch_finalize
branch::finalize () const
{
return *this;
}
// -----------------------------------------------------------------------------
// io value wrapper
// -----------------------------------------------------------------------------
class __obranch {
public:
__obranch (std::ostream& (*put)(std::ostream&, const branch&), const branch& x)
: _put(put), _x(x) {}
friend std::ostream& operator << (std::ostream& os, __obranch m)
{ m._put (os, m._x); return os; }
private:
std::ostream& (*_put) (std::ostream&, const branch&);
const branch& _x;
};
class __iobranch {
public:
__iobranch (std::ostream& (*put)(std::ostream&, const branch&),
std::istream& (*get)(std::istream&, branch&),
branch& x,
Float* pt = 0,
field* pu = 0,
field* pp = 0)
: _put(put), _get(get), _px(&x), _pt(pt), _pu(pu), _pp(pp) {}
friend std::ostream& operator << (std::ostream& os, __iobranch m);
friend std::istream& operator >> (std::istream& is, __iobranch m);
private:
std::ostream& (*_put) (std::ostream&, const branch&);
std::istream& (*_get) (std::istream&, branch&);
branch *_px;
Float *_pt;
field *_pu;
field *_pp;
};
inline
std::ostream& operator << (std::ostream& os, __iobranch m) {
m._put (os, *m._px);
return os;
}
inline
std::istream& operator >> (std::istream& is, __iobranch m) {
m._get (is, *m._px);
if (m._pt) { *m._pt = (*m._px).parameter(); }
if (m._pu) { *m._pu = (*m._px)[0].second; }
if (m._pp) { *m._pp = (*m._px)[1].second; }
return is;
}
inline
__obranch
branch::operator() (const Float& t, const field& u)
{
check_macro (size() >= 1, "attempt to output a 1-field branch when a "
<< size() << "-field one was supplied");
_parameter_value = t;
operator[](0).second = u;
return __obranch (operator<<, *this);
}
inline
__iobranch
branch::operator() (Float& t, field& u)
{
check_macro (size() >= 1, "attempt to input/output a 1-field branch when a "
<< size() << "-field one was supplied");
_parameter_value = t;
operator[](0).second = u;
return __iobranch (operator<<, operator>>, *this, &t, &u);
}
inline
__obranch
branch::operator() (const Float& t, const field& u, const field& p)
{
check_macro (size() >= 2, "attempt to output a 2-field branch when a "
<< size() << "-field one was supplied");
_parameter_value = t;
operator[](0).second = u;
operator[](1).second = p;
return __obranch (operator<<, *this);
}
inline
__iobranch
branch::operator() (Float& t, field& u, field& p)
{
check_macro (size() >= 2, "attempt to output a 2-field branch when a "
<< size() << "-field one was supplied");
_parameter_value = t;
operator[](0).second = u;
operator[](1).second = p;
return __iobranch (operator<<, operator>>, *this, &t, &u, &p);
}
}// namespace rheolef
#endif // define_RHEO_BRANCH_H
|