BubbleProfiler  0.3.0
by Peter Athron, Csaba Balazs, Michael Bardsley, Andrew Fowlie, Dylan Harries & Graham White
instream_profile_guesser.hpp
Go to the documentation of this file.
1 /*
2  * This file is part of BubbleProfiler.
3  *
4  * BubbleProfiler is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 3 of the License, or
7  * (at your option) any later version.
8  *
9  * BubbleProfiler is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with BubbleProfiler. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef BUBBLEPROFILER_INSTREAM_PROFILE_GUESSER_HPP_INCLUDED
19 #define BUBBLEPROFILER_INSTREAM_PROFILE_GUESSER_HPP_INCLUDED
20 
26 #include "basic_logger.hpp"
27 #include "profile_guesser.hpp"
28 
29 #include <Eigen/Core>
30 
31 #include <istream>
32 #include <string>
33 #include <vector>
34 
35 namespace BubbleProfiler {
36 
42 public:
47  explicit Instream_profile_guesser(std::istream&);
48 
54  Instream_profile_guesser(std::istream&, const std::string&);
55 
62  Instream_profile_guesser(std::istream&, const std::string&,
63  const std::string&);
64  virtual ~Instream_profile_guesser() = default;
69 
71  const Potential&, const Eigen::VectorXd&, int,
72  double, double, double, double) override;
73 
78  std::size_t get_number_of_grid_points() const { return spatial_grid.size(); }
79 
84  std::size_t get_number_of_fields() const { return field_values.size(); }
85 
90  Eigen::VectorXd get_spatial_grid() const;
91 
96  Eigen::MatrixXd get_field_values() const;
97 
109  void set_spatial_tolerance(double t) { tolerance = t; }
110 
115  void set_delimiters(const std::string& d) { delimiters = d; };
116 
127  void set_line_comment(const std::string& c) { line_comment_start = c; };
128 
133  void read_profiles(std::istream&);
134 
135 private:
136  std::string delimiters{" \t"};
137  std::string line_comment_start{"#"};
138  bool has_n_fields{false};
139  std::size_t n_fields{0};
140  double tolerance{1.e-6};
141  std::vector<double> spatial_grid{};
142  std::vector<std::vector<double> > field_values{};
144 
145  void reset();
146  void strip_comments(std::string&) const;
147  void process_line(const std::string&);
148 };
149 
150 } // namespace BubbleProfiler
151 
152 #endif
void set_spatial_tolerance(double t)
sets the spatial tolerance used when comparing grid points
Abstract class to represent ansatz generators.
Eigen::MatrixXd get_field_values() const
returns the values of the fields read from the stream
void set_delimiters(const std::string &d)
set the characters to use as delimiters between fields
Eigen::VectorXd get_spatial_grid() const
returns the values of the spacetime coordinate read from the stream
Provides guess for field profiles read from an input stream.
std::vector< std::vector< double > > field_values
std::size_t get_number_of_grid_points() const
returns the number of grid points read from the stream
Instream_profile_guesser & operator=(const Instream_profile_guesser &)=default
void read_profiles(std::istream &)
read a profile guess from the given stream
virtual Field_profiles get_profile_guess(const Potential &, const Eigen::VectorXd &, int, double, double, double, double) override
Calculate an initial guess for the bubble profile.
void set_line_comment(const std::string &c)
sets the character sequence used to indicate a comment
Abstract base class for a generic potential.
Definition: potential.hpp:36
Discretized set of field profiles.
Instream_profile_guesser(std::istream &)
reads a profile guess from the given input stream