Class documentation of Concepts

Loading...
Searching...
No Matches
models.hh
Go to the documentation of this file.
1
7#ifndef models_hh
8#define models_hh
9
10#include <sys/utsname.h>
11#include "basics/exceptions.hh"
14#include "formula/formula.hh"
15#include "geometry/mesh.hh"
16#include "graphics/matlab.hh"
17#include "space/space.hh"
18#include "function/vector.hh"
19
20
21#define ModelControl_formulaOut_D 0
22
23namespace concepts {
24
25 // forward declaration
26 template<class F>
27 class ModelControlBase;
28
29 template<class F>
30 class ModelControl;
31
32 // ********************************************************* ModelNotSolved **
33
38 class ModelNotSolved : public ExceptionBase {};
39
40 // ********************************************************* MatrixNotBuilt **
41
46 class MatrixNotBuilt : public ExceptionBase {};
47
48 // ***************************************************************** Model **
49
54 template<class F>
55 class Model : public OutputOperator {
56 friend class ModelControlBase<Model<F> >;
57 friend class ModelControl<Model<F> >;
58 public:
59 typedef F type;
60
62 Model(const std::string problemName);
63 virtual ~Model() {}
65 virtual Space<Real>& space() const = 0;
68 solve_();
69 return sol_.get();
70 }
71 protected:
72 virtual std::ostream& info(std::ostream& os) const;
74 virtual Mesh& mesh_() = 0;
76 virtual const std::string mshAbbr_() = 0;
78 std::unique_ptr<Vector<F> > sol_;
80 virtual void solve_() = 0;
82 const std::string problemName_;
83 };
84
85 // ****************************************************** ModelControlBase **
86
93 template<class F>
95 public:
98 parameters_.addString("vectorFile", "");
99 }
100 virtual ~ModelControlBase() {}
102 virtual F& model() { return model_; }
103 virtual const F& model() const { return model_; }
105 void loadSolution(const std::string vectorFile);
109 void writeSolution(const std::string vectorFile, bool verbose = true);
113 void basisFunctions(const std::string path = "");
118 const bool store = false,
119 const std::string path = "");
122 return parameters_;
123 }
124 protected:
125 virtual std::ostream& info(std::ostream& os) const;
138 virtual std::string filename_(const std::string varname,
139 const std::string path,
140 const bool flag = false);
149 void newfile_(std::string& name, const std::string varname,
150 const std::string ending);
152 template<class G>
154 const std::string frmstr, const std::string name);
155
156 };
157
158 template<class F>
159 template<class G>
162 const std::string frmstr, const std::string name)
163 {
164 DEBUGL(ModelControl_formulaOut_D,
165 "Writing formula " << frmstr << " into " << name << ".m");
166 graphics::MatlabGraphics(model_.space(), name.c_str(), frm);
167 parameters_.addString((std::string("grafik_") + frmstr).c_str(),
168 (name + ".m").c_str());
169 }
170
171 // ********************************************************** ModelControl **
172
173 template<class F>
174 class ModelControl : public ModelControlBase<F> {
175 public:
178 };
179
180} // namespace concepts
181
182#endif // models_hh
void addString(const char *name, const char *value)
Adds a string to the hash of strings.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
void formulaOut_(const concepts::PiecewiseFormulaBase< G > &frm, const std::string frmstr, const std::string name)
graphical output of formulas
Definition models.hh:161
void newfile_(std::string &name, const std::string varname, const std::string ending)
ModelControlBase(F &model)
Constructor.
Definition models.hh:97
virtual void dataOut(concepts::InOutParameters &parameters, const bool store=false, const std::string path="")
virtual std::string filename_(const std::string varname, const std::string path, const bool flag=false)
concepts::InOutParameters parameters_
Parameters of the calculation.
Definition models.hh:129
const concepts::InOutParameters & parameters() const
Return parameters of the calculation.
Definition models.hh:121
virtual F & model()
Returns the model.
Definition models.hh:102
void loadSolution(const std::string vectorFile)
Loads solution vector from vectorFile.
void basisFunctions(const std::string path="")
void writeSolution(const std::string vectorFile, bool verbose=true)
ModelControl(F &model)
Constructor.
Definition models.hh:177
Model(const std::string problemName)
Constructor.
virtual const std::string mshAbbr_()=0
Mesh abbreviation string.
virtual std::ostream & info(std::ostream &os) const
Returns information in an output stream.
std::unique_ptr< Vector< F > > sol_
Solution vector.
Definition models.hh:78
virtual void solve_()=0
Method for solving.
virtual Space< Real > & space() const =0
Returns the space.
const Vector< F > * solution()
Returns solution vector.
Definition models.hh:67
const std::string problemName_
Name of the problem.
Definition models.hh:82
virtual Mesh & mesh_()=0
Mesh.
#define DEBUGL(doit, msg)
Definition debug.hh:40
Set< F > makeSet(uint n, const F &first,...)
Definition set.hh:320