oomph_utilities.h
Go to the documentation of this file.
1 // LIC// ====================================================================
2 // LIC// This file forms part of oomph-lib, the object-oriented,
3 // LIC// multi-physics finite-element library, available
4 // LIC// at http://www.oomph-lib.org.
5 // LIC//
6 // LIC// Copyright (C) 2006-2022 Matthias Heil and Andrew Hazel
7 // LIC//
8 // LIC// This library is free software; you can redistribute it and/or
9 // LIC// modify it under the terms of the GNU Lesser General Public
10 // LIC// License as published by the Free Software Foundation; either
11 // LIC// version 2.1 of the License, or (at your option) any later version.
12 // LIC//
13 // LIC// This library is distributed in the hope that it will be useful,
14 // LIC// but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // LIC// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // LIC// Lesser General Public License for more details.
17 // LIC//
18 // LIC// You should have received a copy of the GNU Lesser General Public
19 // LIC// License along with this library; if not, write to the Free Software
20 // LIC// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21 // LIC// 02110-1301 USA.
22 // LIC//
23 // LIC// The authors may be contacted at oomph-lib@maths.man.ac.uk.
24 // LIC//
25 // LIC//====================================================================
26 // A header containing useful utility classes, functions and constants
27 
28 // Include guard to prevent multiple inclusions of the header
29 #ifndef OOMPH_UTILITIES_HEADER
30 #define OOMPH_UTILITIES_HEADER
31 
32 // Config header generated by autoconfig
33 #ifdef HAVE_CONFIG_H
34 #include <oomph-lib-config.h>
35 #endif
36 
37 
38 #ifdef OOMPH_HAS_MPI
39 // mpi headers
40 #include "mpi.h"
41 #endif
42 
43 // Standard libray headers
44 #include <string>
45 #include <sstream>
46 #include <fstream>
47 #include <cmath>
48 #include <map>
49 #include <ctime>
50 #include <complex>
51 
52 // oomph-lib headers
53 #include "Vector.h"
54 #include "oomph_definitions.h"
55 #include "communicator.h"
56 
57 /* // Header for cxx-prettyprint: A C++ Container Pretty-Printer. If the */
58 /* // standard in use is older than C++11 then use a special older version of */
59 /* // the header. Header is from here: */
60 /* // http://louisdx.github.io/cxx-prettyprint/ */
61 /* #if __cplusplus <= 199711L */
62 /* #include "prettyprint98.h" */
63 /* #else */
64 /* #include "prettyprint.h" */
65 /* #endif */
66 
67 // Header for name demangling
68 #include <cxxabi.h>
69 
70 namespace oomph
71 {
72  //======start_of_ANSIEscapeCode_namespace=================
83  //====================================================================
84  namespace ANSIEscapeCode
85  {
88  extern void set_text_effect(std::string text_effect);
89 
91  extern std::string Text_effect;
92 
94  extern std::string Black;
95  extern std::string Red;
96  extern std::string Green;
97  extern std::string Yellow;
98  extern std::string Blue;
99  extern std::string Magenta;
100  extern std::string Cyan;
101  extern std::string Reset;
102  } // namespace ANSIEscapeCode
103 
104  //=====================================================================
109  //=====================================================================
110  namespace DebugHelpers
111  {
116  const int& line,
117  const bool& make_new_line = false);
118  } // namespace DebugHelpers
119 
120  // Forward declaration needed for second invariant helper
121  template<class TYPE>
122  class DenseMatrix;
123 
124  //=====================================================================
127  //=====================================================================
128  namespace SecondInvariantHelper
129  {
131  extern double second_invariant(const DenseMatrix<double>& tensor);
132 
133  } // namespace SecondInvariantHelper
134 
135 
136  //==============================================
139  //==============================================
140  namespace BrokenCopy
141  {
143  extern void broken_assign(const std::string& class_name);
144 
146  extern void broken_copy(const std::string& class_name);
147 
148  } // namespace BrokenCopy
149 
150  //========================================
153  //=======================================
154  namespace MathematicalConstants
155  {
157  const double Pi = 3.1415926535897932384626433832795028841971693993751;
158 
160  const std::complex<double> I(0.0, 1.0);
161  } // namespace MathematicalConstants
162 
163 
164  //================================================================
167  //================================================================
168  template<class T>
169  class AbsCmp
170  {
171  public:
173  bool operator()(const T& x, const T& y) const
174  {
175  return std::abs(x) < std::abs(y);
176  }
177  };
178 
179 
180  // =================================================================
183  // =================================================================
184  namespace StringConversion
185  {
188  template<class T>
189  std::string to_string(T object, unsigned float_precision = 8)
190  {
191  std::stringstream ss;
192  ss.precision(float_precision);
193  ss << object;
194  return ss.str();
195  }
196 
198  std::string to_lower(const std::string& input);
199 
201  std::string to_upper(const std::string& input);
202 
207  void split_string(const std::string& s,
208  char delim,
209  Vector<std::string>& elems);
210 
215  Vector<std::string> split_string(const std::string& s, char delim);
216 
217  } // namespace StringConversion
218 
219 
220  namespace TypeNames
221  {
225  template<class T>
227  {
228  using namespace StringConversion;
229 
230  int status;
231  std::string typestr =
232  to_string(abi::__cxa_demangle(typeid(obj).name(), 0, 0, &status));
233 
234  // Throw if there was an error
235  if (status != 0)
236  {
237  std::string err = "Error code " + to_string(status) +
238  " in demangler, see documentation of "
239  "abi::__cxa_demangle for the meaning";
240  throw OomphLibError(
242  }
243 
244  return typestr;
245  }
246 
252  template<class T>
254  {
255  return get_type_name(*obj);
256  }
257 
258  } // namespace TypeNames
259 
263 
264 
265  //====================================================================
267  //====================================================================
268  namespace CumulativeTimings
269  {
271  extern void start(const unsigned& i);
272 
274  extern void halt(const unsigned& i);
275 
277  extern void reset(const unsigned& i);
278 
280  extern void reset();
281 
283  extern double cumulative_time(const unsigned& i);
284 
286  extern void set_ntimers(const unsigned& ntimers);
287 
289  extern Vector<clock_t> Timing;
290 
292  extern Vector<clock_t> Start_time;
293 
294  } // namespace CumulativeTimings
295 
296 
297  // ============================================================
298  // Automatically checked casting functions (from boost)
299  // ============================================================
300 
312  template<class Target, class Source>
314  {
315  Target tmp = dynamic_cast<Target>(x);
316 #ifdef PARANOID
317  if (tmp == 0)
318  {
319  throw OomphLibError(
321  }
322 #endif
323  return tmp;
324  }
325 
334  template<class Target, class Source>
336  {
337 #ifdef PARANOID
338  // Check that the cast will work as expected.
339  if (dynamic_cast<Target>(x) != x)
340  {
341  throw OomphLibError(
343  }
344 #endif
345  return static_cast<Target>(x);
346  }
347 
351 
352  //====================================================================
354  //====================================================================
355  class Timer
356  {
357  public:
359  Timer(const unsigned& n_timer)
360  {
361  set_ntimers(n_timer);
362  }
363 
365  void start(const unsigned& i)
366  {
367  Start_time[i] = clock();
368  }
369 
371  void halt(const unsigned& i)
372  {
373  Timing[i] += clock() - Start_time[i];
374  }
375 
377  double cumulative_time(const unsigned& i)
378  {
379  return double(Timing[i]) / CLOCKS_PER_SEC;
380  }
381 
383  void reset(const unsigned& i)
384  {
385  Timing[i] = clock_t(0.0);
386  }
387 
389  void reset()
390  {
391  unsigned n = Timing.size();
392  for (unsigned i = 0; i < n; i++)
393  {
394  Timing[i] = clock_t(0.0);
395  }
396  }
397 
399  void set_ntimers(const unsigned& ntimers)
400  {
401  Timing.resize(ntimers, clock_t(0.0));
402  Start_time.resize(ntimers, clock_t(0.0));
403  }
404 
405  private:
408 
411  };
412 
413 
414  //====================================================================
418  //====================================================================
420  {
421  public:
424  DocLinearSolverInfo() : Iterations_and_times() {}
425 
428  {
429  // For each new time step, we have a new vector consisting of pairs of
430  // unsigned (for the iteration) and double (for the timing results).
431  Iterations_and_times.push_back(Vector<Vector<double>>());
432  }
433 
435  {
436  Iterations_and_times.pop_back();
437  setup_new_time_step();
438  }
439 
441  void add_iteration_and_time(unsigned iter,
442  double prec_setup_time,
443  double linear_solver_time)
444  {
445 #ifdef PARANOID
446  if (Iterations_and_times.size() == 0)
447  {
448  std::ostringstream error_message;
449  error_message << "Iterations_and_times is empty. "
450  << "Call setup_new_time_step()\n";
451  throw OomphLibError(error_message.str(),
454  }
455 #endif
456  Vector<double> tmp_iter_time_vec(3, 0);
457  tmp_iter_time_vec[0] = (double)iter;
458  tmp_iter_time_vec[1] = prec_setup_time;
459  tmp_iter_time_vec[2] = linear_solver_time;
460  Iterations_and_times.back().push_back(tmp_iter_time_vec);
461  }
462 
464  unsigned current_ntime_step() const
465  {
466  return Iterations_and_times.size();
467  }
468 
470  unsigned current_nnewton_step() const
471  {
472  return Iterations_and_times.back().size();
473  }
474 
477  {
478  return Iterations_and_times;
479  }
480 
483  {
484  return Iterations_and_times;
485  }
486 
487  private:
490  };
491 
492  //====================================================================
497  //====================================================================
498  class DocInfo
499  {
500  public:
505  : Directory("."),
506  Doc_flag(true),
507  Number(0),
508  Label(""),
509  Directory_must_exist(true)
510  {
511  }
512 
514  DocInfo(const std::string& directory)
515  : Directory(directory),
516  Doc_flag(true),
517  Number(0),
518  Label(""),
519  Directory_must_exist(true)
520  {
521  }
522 
525  {
526  return Directory;
527  }
528 
533  void set_directory(const std::string& directory);
534 
536  void enable_doc()
537  {
538  Doc_flag = true;
539  }
540 
542  void disable_doc()
543  {
544  Doc_flag = false;
545  }
546 
548  bool is_doc_enabled() const
549  {
550  return Doc_flag;
551  }
552 
554  unsigned& number()
555  {
556  return Number;
557  }
558 
560  unsigned number() const
561  {
562  return Number;
563  }
564 
567  {
569  }
570 
573  {
574  return Label;
575  }
576 
579  {
580  return Label;
581  }
582 
585  {
586  Directory_must_exist = true;
587  }
588 
591  {
592  Directory_must_exist = false;
593  }
594 
595  private:
598 
600  bool Doc_flag;
601 
603  unsigned Number;
604 
607 
613  };
614 
615 
616  //====================================================================
617  // Namespace for command line arguments
618  //====================================================================
619  namespace CommandLineArgs
620  {
622  template<class T>
623  struct ArgInfo
624  {
626  ArgInfo(const bool& is_set, T* arg_pt, const std::string& doc)
627  {
628  this->is_set = is_set;
629  this->arg_pt = arg_pt;
630  this->doc = doc;
631  }
632 
636  {
637  this->is_set = false;
638  this->arg_pt = 0;
639  this->doc = "";
640  }
641 
642  // /// Assignment operator. We need this to be able to store these things
643  // in
644  // /// maps.
645  // void operator=(const ArgInfo& that)
646  // {
647  // this->is_set = that.is_set;
648  // this->arg_pt = that.arg_pt;
649  // this->doc = that.doc;
650  // }
651 
653  bool is_set;
654 
657 
660  };
661 
662  // Number of arguments + 1
663  extern int Argc;
664 
665  // Arguments themselves
666  extern char** Argv;
667 
669  extern std::map<std::string, ArgInfo<bool>> Specified_command_line_flag;
670 
672  extern std::map<std::string, ArgInfo<double>>
674 
676  extern std::map<std::string, ArgInfo<int>> Specified_command_line_int_pt;
677 
679  extern std::map<std::string, ArgInfo<unsigned>>
681 
683  extern std::map<std::string, ArgInfo<std::string>>
685 
686  // Set values
687  extern void setup(int argc, char** argv);
688 
689  // Doc the command line arguments
690  extern void output();
691 
693  extern void specify_command_line_flag(
694  const std::string& command_line_flag,
695  const std::string& documentation = "Undocumented");
696 
699  extern void specify_command_line_flag(
700  const std::string& command_line_flag,
701  double* arg_pt,
702  const std::string& documentation = "Undocumented");
703 
706  extern void specify_command_line_flag(
707  const std::string& command_line_flag,
708  int* arg_pt,
709  const std::string& documentation = "Undocumented");
710 
713  extern void specify_command_line_flag(
714  const std::string& command_line_flag,
715  unsigned* arg_pt,
716  const std::string& documentation = "Undocumented");
717 
720  extern void specify_command_line_flag(
721  const std::string& command_line_flag,
722  std::string* arg_pt,
723  const std::string& documentation = "Undocumented");
724 
727  extern bool command_line_flag_has_been_set(const std::string& flag);
728 
730  extern void doc_all_flags(
731  std::ostream& outstream = *oomph_info.stream_pt());
732 
734  extern void doc_specified_flags();
735 
737  extern void doc_available_flags();
738 
740  extern void check_arg_index(const int& argc, const int& arg_index);
741 
744  extern void parse_and_assign(
745  int argc, char* argv[], const bool& throw_on_unrecognised_args = false);
746 
749  extern void parse_and_assign(
750  const bool& throw_on_unrecognised_args = false);
751 
752  } // namespace CommandLineArgs
753 
754  // forward declaration of OomphCommunicator class
755  class OomphCommunicator;
756 
757 #ifdef OOMPH_HAS_MPI
758  //========================================================================
762  //========================================================================
763  class MPIOutputModifier : public OutputModifier
764  {
765  private:
768  unsigned Output_rank;
769 
772  bool Output_from_single_processor;
773 
775  OomphCommunicator* Communicator_pt;
776 
777  public:
779  MPIOutputModifier() : Output_rank(0), Output_from_single_processor(false) {}
780 
782  OomphCommunicator*& communicator_pt()
783  {
784  return Communicator_pt;
785  }
786 
788  virtual bool operator()(std::ostream& stream);
789 
792  void restrict_output_to_single_processor(const unsigned& output_rank = 0)
793  {
794  Output_from_single_processor = true;
795  Output_rank = output_rank;
796  }
797 
798 
801  void allow_output_from_all_processors()
802  {
803  Output_from_single_processor = false;
804  }
805  };
806 
807 
808  //========================================================================
810  //========================================================================
811  extern MPIOutputModifier oomph_mpi_output;
812 
813  //=== Forward DenseMatrix class
814  template<class T>
815  class DenseMatrix;
816 
817  // forward declaration of oomph-communicator class
818  // class OomphCommunicator;
819 
820 #endif
821 
822 
823  //======================================================================
830  //=====================================================================
832  {
833  public:
838  static void init(int argc,
839  char** argv,
840  const bool& make_duplicate_of_mpi_comm_world = true);
841 
844  static void finalize();
845 
848  static OomphCommunicator* communicator_pt();
849 
852  {
853  return MPI_has_been_initialised;
854  }
855 
856  private:
860 
864 
867 
870  };
871 
872 
873  //====================================================================
874  // Namespace for flagging up obsolete parts of the code
875  //====================================================================
876  namespace ObsoleteCode
877  {
878  // Flag up obsolete parts of the code
879  extern bool FlagObsoleteCode;
880 
881  // Output warning message
882  extern void obsolete();
883 
884  // Output specified warning message
885  extern void obsolete(const std::string& message);
886 
887  } // namespace ObsoleteCode
888 
889  //====================================================================
890  // Namespace for tecplot stuff
891  //====================================================================
892  namespace TecplotNames
893  {
894  // Tecplot colours
895  extern Vector<std::string> colour;
896 
897  // Setup tecplot colours namespace
898  extern void setup();
899 
900  } // namespace TecplotNames
901 
902 
903 #ifdef LEAK_CHECK
904 
905  //====================================================================
906  // Namespace for leak check: Keep a running count of all instantiated
907  // objects -- add your own if you want to...
908  //====================================================================
909  namespace LeakCheckNames
910  {
911  extern long QuadTree_build;
912  extern long OcTree_build;
913  extern long QuadTreeForest_build;
914  extern long OcTreeForest_build;
915  extern long RefineableQElement<2> _build;
916  extern long RefineableQElement<3> _build;
917  extern long MacroElement_build;
918  extern long HangInfo_build;
919  extern long Node_build;
920  extern long GeomReference_build;
921  extern long AlgebraicNodeNodeUpdateInfo_build;
922  extern long AlgebraicNode_build;
923 
924  // Reset counters
925  extern void reset();
926 
927  // Doc counters
928  extern void doc();
929  } // namespace LeakCheckNames
930 
931 #endif
932 
933  //====================================================================
934  // Namespace for pause() command
935  //====================================================================
936  namespace PauseFlags
937  {
938  // Flag to enable pausing code
939  extern bool PauseFlag;
940 
941  } // namespace PauseFlags
942 
944  void pause(std::string message);
945 
946 
947  //=============================================================================
949  //=============================================================================
950  namespace TimingHelpers
951  {
953  double timer();
954 
961  std::string convert_secs_to_formatted_string(const double& time_in_sec);
962 
963  } // end of namespace TimingHelpers
964 
965 
969 
970 
971  //===============================================================
980  //===============================================================
981  namespace MemoryUsage
982  {
988  extern bool Suppress_mpi_synchronisation;
989 
995 
1001 
1009 
1013 
1014 #ifdef OOMPH_HAS_UNISTDH
1015 
1023  void doc_my_memory_usage(const std::string& prefix_string = 0);
1024 
1025 #endif
1026 
1031 
1039 
1043 
1049  void doc_total_memory_usage(const std::string& prefix_string = "");
1050 
1053  void empty_memory_usage_files();
1054 
1057  void doc_memory_usage(const std::string& prefix_string = "");
1058 
1064 
1072 
1075  void empty_top_file();
1076 
1082  void run_continous_top(const std::string& comment = "");
1083 
1088  void stop_continous_top(const std::string& comment = "");
1089 
1091  void insert_comment_to_continous_top(const std::string& comment);
1092 
1093  } // end of namespace MemoryUsage
1094 
1095 
1099 
1100  // Forward decl.
1101  class Problem;
1102  template<class T>
1103  class DenseMatrix;
1104 
1109  {
1110  public:
1111  // Some typedefs first:
1112 
1114  typedef double (*TimeSpaceToDoubleFctPt)(const double& t,
1115  const Vector<double>& x);
1116 
1118  typedef Vector<double> (*TimeSpaceToDoubleVectFctPt)(
1119  const double& t, const Vector<double>& x);
1120 
1123  typedef Vector<double> (*TimeSpaceValueToDoubleVectFctPt)(
1124  const double& t, const Vector<double>& x, const Vector<double>& u);
1125 
1128 
1130  virtual Vector<double> operator()(const double& t,
1131  const Vector<double>& x) const = 0;
1132 
1134  virtual Vector<double> derivative(const double& t,
1135  const Vector<double>& x,
1136  const Vector<double>& u) const = 0;
1137 
1142  virtual void jacobian(const double& t,
1143  const Vector<double>& x,
1144  const Vector<double>& u,
1145  DenseMatrix<double>& jacobian) const
1146  {
1147  std::string err = "No Jacobian function implemented";
1148  throw OomphLibError(
1150  }
1151 
1153  virtual bool have_jacobian() const
1154  {
1155  return false;
1156  }
1157 
1159  virtual void initialise_from_problem(const Problem* problem_pt) {}
1160  };
1161 
1162 
1166  {
1167  // This could easily be extended to take
1168  // FiniteElement::UnsteadyExactSolutionFctPt function (i.e. functions
1169  // where the output is placed into a given vector rather than returned)
1170  // as well--just add the appropriate storage pointers and constructors.
1171 
1172  public:
1173  // Constructors:
1174 
1176  {
1177  Solution_fpt = 0;
1178  Derivative_fpt = 0;
1179  }
1180 
1181  SolutionFunctor(TimeSpaceToDoubleVectFctPt solution_fpt)
1182  {
1183  Solution_fpt = solution_fpt;
1184  Derivative_fpt = 0;
1185  }
1186 
1187  SolutionFunctor(TimeSpaceToDoubleVectFctPt solution_fpt,
1188  TimeSpaceValueToDoubleVectFctPt derivative_fpt)
1189  {
1190  Solution_fpt = solution_fpt;
1191  Derivative_fpt = derivative_fpt;
1192  }
1193 
1194  virtual ~SolutionFunctor() {}
1195 
1197  {
1198  Solution_fpt = that.Solution_fpt;
1199  Derivative_fpt = that.Derivative_fpt;
1200  }
1201 
1202  void operator=(const SolutionFunctor& that)
1203  {
1204  this->Solution_fpt = that.Solution_fpt;
1205  this->Derivative_fpt = that.Derivative_fpt;
1206  }
1207 
1209  virtual Vector<double> operator()(const double& t,
1210  const Vector<double>& x) const
1211  {
1212 #ifdef PARANOID
1213  if (Solution_fpt == 0)
1214  {
1215  std::string err = "Solution_fpt is null!";
1216  throw OomphLibError(
1218  }
1219 #endif
1220  return Solution_fpt(t, x);
1221  }
1222 
1224  virtual Vector<double> derivative(const double& t,
1225  const Vector<double>& x,
1226  const Vector<double>& u) const
1227  {
1228 #ifdef PARANOID
1229  if (Derivative_fpt == 0)
1230  {
1231  std::string err = "Derivative_fpt is null!";
1232  throw OomphLibError(
1234  }
1235 #endif
1236  return Derivative_fpt(t, x, u);
1237  }
1238 
1240  TimeSpaceToDoubleVectFctPt Solution_fpt;
1241 
1243  TimeSpaceValueToDoubleVectFctPt Derivative_fpt;
1244  };
1245 
1246 
1247 } // namespace oomph
1248 #endif
AnnoyingScalar abs(const AnnoyingScalar &x)
Definition: AnnoyingScalar.h:135
Matrix< Scalar, Dynamic, Dynamic > DenseMatrix
Definition: BenchSparseUtil.h:23
int i
Definition: BiCGSTAB_step_by_step.cpp:9
const unsigned n
Definition: CG3DPackingUnitTest.cpp:11
Definition: Source.h:14
Definition: oomph_utilities.h:170
bool operator()(const T &x, const T &y) const
Comparison. Are the values identical or not?
Definition: oomph_utilities.h:173
Definition: oomph_utilities.h:499
std::string label() const
String used (e.g.) for labeling output files. Const version.
Definition: oomph_utilities.h:578
unsigned Number
Number to label output file, say.
Definition: oomph_utilities.h:603
void enable_doc()
Enable documentation.
Definition: oomph_utilities.h:536
bool Doc_flag
Doc or don't?
Definition: oomph_utilities.h:600
unsigned number() const
Number used (e.g.) for labeling output files. Const version.
Definition: oomph_utilities.h:560
bool is_doc_enabled() const
Are we documenting?
Definition: oomph_utilities.h:548
bool Directory_must_exist
Definition: oomph_utilities.h:612
void disable_doc()
Disable documentation.
Definition: oomph_utilities.h:542
std::string & label()
String used (e.g.) for labeling output files.
Definition: oomph_utilities.h:572
void disable_error_if_directory_does_not_exist()
Call to issue a warning if the directory does not exists.
Definition: oomph_utilities.h:590
std::string directory() const
Output directory.
Definition: oomph_utilities.h:524
std::string Directory
Directory name.
Definition: oomph_utilities.h:597
void enable_error_if_directory_does_not_exist()
Call to throw an error if directory does not exist.
Definition: oomph_utilities.h:584
DocInfo(const std::string &directory)
Constructor with specific directory.
Definition: oomph_utilities.h:514
std::string number_as_string() const
Get number as a string (useful to completely avoid C-strings).
Definition: oomph_utilities.h:566
std::string Label
String to label output file, say.
Definition: oomph_utilities.h:606
DocInfo()
Definition: oomph_utilities.h:504
unsigned & number()
Number used (e.g.) for labeling output files.
Definition: oomph_utilities.h:554
Definition: oomph_utilities.h:420
void setup_new_time_step()
Set up a new vector of pairs for a new time step.
Definition: oomph_utilities.h:427
Vector< Vector< Vector< double > > > & iterations_and_times()
Accessor function for the iteration and times.
Definition: oomph_utilities.h:476
Vector< Vector< Vector< double > > > Iterations_and_times
Storage for number of iterations during Newton steps.
Definition: oomph_utilities.h:489
unsigned current_nnewton_step() const
The number of Newton steps.
Definition: oomph_utilities.h:470
DocLinearSolverInfo()
Definition: oomph_utilities.h:424
void add_iteration_and_time(unsigned iter, double prec_setup_time, double linear_solver_time)
Add a new iteration and time pair.
Definition: oomph_utilities.h:441
void clear_current_time_step()
Definition: oomph_utilities.h:434
unsigned current_ntime_step() const
The number of time steps.
Definition: oomph_utilities.h:464
Vector< Vector< Vector< double > > > iterations_and_times() const
Accessor function for the iteration and times (const version).
Definition: oomph_utilities.h:482
Definition: oomph_utilities.h:832
static OomphCommunicator * Communicator_pt
the global communicator
Definition: oomph_utilities.h:869
static bool mpi_has_been_initialised()
return true if MPI has been initialised
Definition: oomph_utilities.h:851
static bool MPI_has_been_initialised
Bool set to true if MPI has been initialised.
Definition: oomph_utilities.h:866
MPI_Helpers(const MPI_Helpers &)
Definition: communicator.h:54
std::ostream *& stream_pt()
Access function for the stream pointer.
Definition: oomph_definitions.h:464
Definition: oomph_definitions.h:222
Definition: oomph_definitions.h:339
Definition: problem.h:151
Definition: oomph_utilities.h:1109
virtual void initialise_from_problem(const Problem *problem_pt)
Overload to grab data from the problem.
Definition: oomph_utilities.h:1159
virtual void jacobian(const double &t, const Vector< double > &x, const Vector< double > &u, DenseMatrix< double > &jacobian) const
Definition: oomph_utilities.h:1142
virtual ~SolutionFunctorBase()
Virtual destructor.
Definition: oomph_utilities.h:1127
virtual Vector< double > derivative(const double &t, const Vector< double > &x, const Vector< double > &u) const =0
Call the derivative function.
virtual Vector< double > operator()(const double &t, const Vector< double > &x) const =0
Call the function.
virtual bool have_jacobian() const
Is a jacobian function implemented?
Definition: oomph_utilities.h:1153
Definition: oomph_utilities.h:1166
virtual ~SolutionFunctor()
Definition: oomph_utilities.h:1194
SolutionFunctor()
Definition: oomph_utilities.h:1175
virtual Vector< double > derivative(const double &t, const Vector< double > &x, const Vector< double > &u) const
Call the derivative function.
Definition: oomph_utilities.h:1224
void operator=(const SolutionFunctor &that)
Definition: oomph_utilities.h:1202
TimeSpaceValueToDoubleVectFctPt Derivative_fpt
Storage for derivative.
Definition: oomph_utilities.h:1243
SolutionFunctor(TimeSpaceToDoubleVectFctPt solution_fpt, TimeSpaceValueToDoubleVectFctPt derivative_fpt)
Definition: oomph_utilities.h:1187
TimeSpaceToDoubleVectFctPt Solution_fpt
Storage for solution.
Definition: oomph_utilities.h:1240
SolutionFunctor(const SolutionFunctor &that)
Definition: oomph_utilities.h:1196
virtual Vector< double > operator()(const double &t, const Vector< double > &x) const
Call the function.
Definition: oomph_utilities.h:1209
SolutionFunctor(TimeSpaceToDoubleVectFctPt solution_fpt)
Definition: oomph_utilities.h:1181
Timer.
Definition: oomph_utilities.h:356
Vector< clock_t > Timing
Cumulative timings.
Definition: oomph_utilities.h:407
double cumulative_time(const unsigned &i)
Report time accumulated by i-th timer.
Definition: oomph_utilities.h:377
void set_ntimers(const unsigned &ntimers)
Set number of timings that can be recorded in parallel.
Definition: oomph_utilities.h:399
Timer(const unsigned &n_timer)
Constructor: Specify number of timers.
Definition: oomph_utilities.h:359
Vector< clock_t > Start_time
Start times of active timers.
Definition: oomph_utilities.h:410
void reset(const unsigned &i)
Reset i-th timer.
Definition: oomph_utilities.h:383
void reset()
Reset all timers.
Definition: oomph_utilities.h:389
void start(const unsigned &i)
(Re-)start i-th timer
Definition: oomph_utilities.h:365
void halt(const unsigned &i)
Halt i-th timer.
Definition: oomph_utilities.h:371
Scalar * y
Definition: level1_cplx_impl.h:128
RealScalar s
Definition: level1_cplx_impl.h:130
Eigen::Matrix< Scalar, Dynamic, Dynamic, ColMajor > tmp
Definition: level3_impl.h:365
string Directory
Directory.
Definition: all_foeppl_von_karman/axisym_displ_based_fvk.cc:70
@ Target
Definition: Constants.h:495
void setup(Time *time_pt)
Create all GeomObjects needed to define the cylinder and the flag.
Definition: turek_flag_non_fsi.cc:277
void reset(Vector< double > &unknowns)
Reset unknowns to some nontrivial garbage.
Definition: spring_contact.cc:53
string filename
Definition: MergeRestartFiles.py:39
line
Definition: calibrate.py:103
std::string Green
Definition: oomph_utilities.cc:72
std::string Yellow
Definition: oomph_utilities.cc:73
std::string Red
Definition: oomph_utilities.cc:71
std::string Magenta
Definition: oomph_utilities.cc:75
std::string Cyan
Definition: oomph_utilities.cc:76
void set_text_effect(std::string text_effect)
Definition: oomph_utilities.cc:60
std::string Text_effect
Variable to decide on effects.
Definition: oomph_utilities.cc:67
std::string Blue
Definition: oomph_utilities.cc:74
std::string Black
The code for each type of colour.
Definition: oomph_utilities.cc:70
std::string Reset
Definition: oomph_utilities.cc:77
void broken_assign(const std::string &class_name)
Issue error message and terminate execution.
Definition: oomph_utilities.cc:195
void broken_copy(const std::string &class_name)
Issue error message and terminate execution.
Definition: oomph_utilities.cc:212
void doc_available_flags()
Document available command line flags.
Definition: oomph_utilities.cc:676
std::map< std::string, ArgInfo< bool > > Specified_command_line_flag
Map to indicate an input flag as having been set.
Definition: oomph_utilities.cc:413
char ** Argv
Arguments themselves.
Definition: oomph_utilities.cc:410
bool command_line_flag_has_been_set(const std::string &flag)
Definition: oomph_utilities.cc:501
void specify_command_line_flag(const std::string &command_line_flag, const std::string &doc)
Specify possible argument-free command line flag.
Definition: oomph_utilities.cc:451
void check_arg_index(const int &argc, const int &arg_index)
Helper function to check if command line index is legal.
Definition: oomph_utilities.cc:737
void doc_all_flags(std::ostream &outstream)
Document the values of all flags (specified or not).
Definition: oomph_utilities.cc:562
std::map< std::string, ArgInfo< std::string > > Specified_command_line_string_pt
Map to associate an input flag with a string – specified via pointer.
Definition: oomph_utilities.cc:426
std::map< std::string, ArgInfo< int > > Specified_command_line_int_pt
Map to associate an input flag with an int – specified via pointer.
Definition: oomph_utilities.cc:419
void parse_and_assign(int argc, char *argv[], const bool &throw_on_unrecognised_args)
Definition: oomph_utilities.cc:760
std::map< std::string, ArgInfo< double > > Specified_command_line_double_pt
Map to associate an input flag with a double – specified via pointer.
Definition: oomph_utilities.cc:416
int Argc
Number of arguments + 1.
Definition: oomph_utilities.cc:407
std::map< std::string, ArgInfo< unsigned > > Specified_command_line_unsigned_pt
Map to associate an input flag with an unsigned – specified via pointer.
Definition: oomph_utilities.cc:422
void doc_specified_flags()
Document specified command line flags.
Definition: oomph_utilities.cc:610
double cumulative_time(const unsigned &i)
Report time accumulated by i-th timer.
Definition: oomph_utilities.cc:255
void set_ntimers(const unsigned &ntimers)
Set number of timings that can be recorded in parallel.
Definition: oomph_utilities.cc:277
Vector< clock_t > Timing
Cumulative timings.
Definition: oomph_utilities.cc:284
void halt(const unsigned &i)
Halt i-th timer.
Definition: oomph_utilities.cc:249
Vector< clock_t > Start_time
Start times of active timers.
Definition: oomph_utilities.cc:287
void start(const unsigned &i)
(Re-)start i-th timer
Definition: oomph_utilities.cc:243
std::string debug_string(const std::string &filename, const int &line, const bool &make_new_line)
Definition: oomph_utilities.cc:92
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
unsigned Number
The unsigned.
Definition: oomph_definitions.cc:269
const double Pi
50 digits from maple
Definition: oomph_utilities.h:157
const std::complex< double > I(0.0, 1.0)
The imaginary unit.
void empty_top_file()
Definition: oomph_utilities.cc:1564
std::string Top_output_filename
Definition: oomph_utilities.cc:1560
bool Bypass_all_memory_usage_monitoring
Definition: oomph_utilities.cc:1390
void doc_total_memory_usage(const std::string &prefix_string)
Definition: oomph_utilities.cc:1489
void insert_comment_to_continous_top(const std::string &comment)
Insert comment into running continuous top output.
Definition: oomph_utilities.cc:1680
void empty_memory_usage_files()
Definition: oomph_utilities.cc:1522
void run_continous_top(const std::string &comment)
Definition: oomph_utilities.cc:1583
std::string Top_system_string
Definition: oomph_utilities.cc:1552
void stop_continous_top(const std::string &comment)
Definition: oomph_utilities.cc:1641
bool Suppress_mpi_synchronisation
Definition: oomph_utilities.cc:1378
void empty_total_memory_usage_file()
Definition: oomph_utilities.cc:1472
std::string Total_memory_usage_system_string
Definition: oomph_utilities.cc:1459
void doc_memory_usage(const std::string &prefix_string)
Definition: oomph_utilities.cc:1535
std::string My_memory_usage_filename
Definition: oomph_utilities.cc:1398
void empty_my_memory_usage_file()
Definition: oomph_utilities.cc:1402
std::string My_memory_usage_system_string
Definition: oomph_utilities.cc:1384
std::string Total_memory_usage_filename
Definition: oomph_utilities.cc:1468
void obsolete()
Output warning message.
Definition: oomph_utilities.cc:1102
bool FlagObsoleteCode
Flag up obsolete parts of the code.
Definition: oomph_utilities.cc:1099
bool PauseFlag
Flag to enable pausing code – pause the code by default.
Definition: oomph_utilities.cc:1258
double second_invariant(const DenseMatrix< double > &tensor)
Compute second invariant of tensor.
Definition: oomph_utilities.cc:163
void split_string(const std::string &s, char delim, Vector< std::string > &elems)
Definition: oomph_utilities.cc:373
std::string to_string(T object, unsigned float_precision=8)
Definition: oomph_utilities.h:189
std::string to_lower(const std::string &input)
Convert a string to lower case (outputs a copy).
Definition: oomph_utilities.cc:345
std::string to_upper(const std::string &input)
Convert a string to upper case (outputs a copy).
Definition: oomph_utilities.cc:358
Vector< std::string > colour
Tecplot colours.
Definition: oomph_utilities.cc:1159
std::string convert_secs_to_formatted_string(const double &time_in_sec)
Definition: oomph_utilities.cc:1316
std::string get_type_name(T &obj)
Definition: oomph_utilities.h:226
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
Definition: AnisotropicHookean.h:10
void output(std::ostream &outfile)
Output with default number of plot points.
Definition: gen_axisym_advection_diffusion_elements.h:161
Target checked_static_cast(Source *x)
Definition: oomph_utilities.h:335
void pause(std::string message)
Pause and display message.
Definition: oomph_utilities.cc:1265
Target checked_dynamic_cast(Source *x)
Definition: oomph_utilities.h:313
OomphInfo oomph_info
Definition: oomph_definitions.cc:319
list x
Definition: plotDoE.py:28
string name
Definition: plotDoE.py:33
t
Definition: plotPSD.py:36
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86
double timer
Definition: oomph_metis_from_parmetis_3.1.1/struct.h:210
Definition: TutorialInplaceLU.cpp:2
Structure to store information on a command line argument.
Definition: oomph_utilities.h:624
ArgInfo()
Definition: oomph_utilities.h:635
T * arg_pt
The place to put the argument's value when it is set.
Definition: oomph_utilities.h:656
std::string doc
Information about what the argument does.
Definition: oomph_utilities.h:659
ArgInfo(const bool &is_set, T *arg_pt, const std::string &doc)
Proper constructor.
Definition: oomph_utilities.h:626
bool is_set
Has this argument been set?
Definition: oomph_utilities.h:653