/usr/include/dolfin/adaptivity/TimeSeries.h is in libdolfin-dev 2017.2.0.post0-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 | // Copyright (C) 2009-2016 Anders Logg
//
// This file is part of DOLFIN.
//
// DOLFIN is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// DOLFIN 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 Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with DOLFIN. If not, see <http://www.gnu.org/licenses/>.
#ifndef __TIME_SERIES_H
#define __TIME_SERIES_H
#ifdef HAS_HDF5
#include <string>
#include <vector>
#include <dolfin/common/MPI.h>
#include <dolfin/common/Variable.h>
namespace dolfin
{
// Forward declarations
class GenericVector;
class Mesh;
/// This class stores a time series of objects to file(s) in a
/// binary format which is efficient for reading and writing.
///
/// When objects are retrieved, the object stored at the time
/// closest to the given time will be used.
///
/// A new time series will check if values have been stored to
/// file before (for a series with the same name) and in that
/// case reuse those values. If new values are stored, old
/// values will be cleared.
class TimeSeries : public Variable
{
public:
/// Create empty time series
///
/// *Arguments*
/// mpi_comm (MPI_Comm)
/// An MPI communicator
/// name (std::string)
/// The time series name
TimeSeries(std::string name)
: TimeSeries(MPI_COMM_WORLD, name) {}
/// Create empty time series
///
/// *Arguments*
/// mpi_comm (MPI_Comm)
/// An MPI communicator
/// name (std::string)
/// The time series name
TimeSeries(MPI_Comm mpi_comm, std::string name);
/// Destructor
~TimeSeries();
/// Store vector at given time
///
/// *Arguments*
/// vector (_GenericVector_)
/// The vector to be stored.
/// t (double)
/// The time.
void store(const GenericVector& vector, double t);
/// Store mesh at given time
///
/// *Arguments*
/// mesh (_Mesh_)
/// The mesh to be stored.
/// t (double)
/// The time.
void store(const Mesh& mesh, double t);
/// Retrieve vector at given time
///
/// *Arguments*
/// vector (_GenericVector_)
/// The vector (values to be retrieved).
/// t (double)
/// The time.
/// interpolate (bool)
/// Optional argument: If true (default), interpolate
/// time samples closest to t if t is not present.
void retrieve(GenericVector& vector, double t,
bool interpolate=true) const;
/// Retrieve mesh at given time
///
/// *Arguments*
/// mesh (_Mesh_)
/// The mesh (values to be retrieved).
/// t (double)
/// The time.
void retrieve(Mesh& mesh, double t) const;
/// Return array of sample times for vectors
///
/// *Returns*
/// std::vector<double>
/// The times.
std::vector<double> vector_times() const;
/// Return array of sample times for meshes
///
/// *Returns*
/// std::vector<double>
/// The times.
std::vector<double> mesh_times() const;
/// Clear time series
void clear();
/// Return informal string representation (pretty-print)
std::string str(bool verbose) const;
/// Default parameter values
static Parameters default_parameters()
{
Parameters p("time_series");
p.add("clear_on_write", true);
return p;
}
private:
template <typename T>
void store_object(MPI_Comm comm, const T& object, double t,
std::vector<double>& times,
std::string series_name,
std::string group_name);
// Check if values are strictly increasing
static bool monotone(const std::vector<double>& times);
// Find index closest to given time
static std::size_t find_closest_index(double t,
const std::vector<double>& times,
std::string series_name,
std::string type_name);
// Find index pair closest to given time
static std::pair<std::size_t, std::size_t>
find_closest_pair(double t, const std::vector<double>& times,
std::string series_name, std::string type_name);
// Name of series
std::string _name;
// List of times
std::vector<double> _vector_times;
std::vector<double> _mesh_times;
// True if series has been cleared
bool _cleared;
};
}
#endif
#endif
|