User Tools

Site Tools


libnum:classes:gear

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
libnum:classes:gear [2026/03/04 15:41] abclibnum:classes:gear [2026/03/29 13:53] (current) abc
Line 3: Line 3:
  
 ===== class Gear; ===== ===== class Gear; =====
-Namespace NumericMethods\\ +Namespace //NumericMethods// 
-See: ''gear.h'' and ''gear.asst.h'' files.+ 
 +See: ''gear.h''''gear.asst.h'', ''gear.proc.h'' and ''gear.output.h'' files.
  
 class [[#GearUserProc|GearUserProc]]; \\ class [[#GearUserProc|GearUserProc]]; \\
Line 20: Line 21:
    ~Gear();    ~Gear();
     void set(int n, GearUserProc* derFunc, GearUserProc* jacFunc);     void set(int n, GearUserProc* derFunc, GearUserProc* jacFunc);
-    void setCallback(GearEngineCallback& f) { callback = &f;}+    void setCallback(GearEngineCallback& f);
     Message solve(const double t_begin, const double t_end, const double* y0);     Message solve(const double t_begin, const double t_end, const double* y0);
     GearEngineContext engineContext;     GearEngineContext engineContext;
Line 115: Line 116:
   RHMAX = 1;   RHMAX = 1;
 See Gear Algorithm for details. See Gear Algorithm for details.
 +
 +===== Gear Output =====
 +The Output is implemented via //GearEngineCallback// interface. The most GearEngine data are available via //GearEngineContext// object, passed to its method ''call(const GearEngineContext& context)''.
 +
 +The //libnum// library includes the following two classes for general useage: //GearPrintToStream// and //GearPrintTable//. Both interfaces use user-declared output stream for their target (see [[https://en.cppreference.com/w/cpp/io/basic_ostream.html|STL manual]]). It can be:
 +  * standard C output stream stdout (//std::cout//)
 +  * string buffer (//std::stringstream//)
 +  * file (//std::ofstream//)
 +  * and the like
 +
 +The //GearPrintToStream// interface enables us to output //time/values// data of each integration point into the output stream, //GearPrintTable// outputs tabulated data (it uses interpolation to calculate variables' values for user declared output time-step). One can set a format of double value presentation, ''std::format'' syntax being supposed, for example "{:8.5f}\t".
 +
 +  class GearPrintToStream : public GearEngineCallback
 +  {
 +  public:
 +    GearPrintToStream(std::ostream& target, const char* format = "{} ");
 +    virtual bool call(const GearEngineContext&) override;
 +    void setFormat(const char* format);
 +  };
 +
 +  class GearPrintTable : public GearPrintToStream
 +  {
 +  public:
 +    GearPrintTable(std::ostream& target, double output_step, const char* format = "{} ");
 +    virtual bool call(const GearEngineContext&) override;
 +    void reset();
 +  };
 +
  
 ---- ----
-[ [[.:|Libnum classes]] ] [ [[..:examples:gear|Example of usage]] ]+[ [[.:|Libnum classes]] ] [ [[..:examples:gear|Examples of usage]] ]
  
libnum/classes/gear.1772628083.txt.gz · Last modified: by abc