00001
00002
00003
00004 #ifndef MATRIX_BASE_HH
00005 #define MATRIX_BASE_HH
00006
00007 #include "basics.hh"
00008 #include "toolbox.hh"
00009 #include "geometry.hh"
00010 #include "hp2D.hh"
00011 #include "function.hh"
00012 #include "operator.hh"
00013 #include "space.hh"
00014
00015 #include "basis.hh"
00016
00017 namespace graphics {
00018
00019
00020
00025 template<class G = Real>
00026 class MatrixBaseOutputCell: public concepts::CellPostprocess<G> {
00027 public:
00031 MatrixBaseOutputCell(
00032 std::map<std::string, concepts::DenseMatrix<G>*>& dense_ptr,
00033 const enum concepts::ElementGraphicsBase::graphicsType type =
00034 concepts::ElementGraphicsBase::DENSEMATRIX, uint dim = 2) :
00035 dim_(dim), dense_ptr_(dense_ptr), type_(type) {
00036 resetCounter();
00037 counted = false;
00038 }
00039
00041 virtual ~MatrixBaseOutputCell() {
00042 }
00043
00045 virtual void operator()(const concepts::Element<G>& elm) = 0;
00046
00048 virtual void operator()(const concepts::Cell& cell) = 0;
00049
00051 inline std::map<std::string, concepts::DenseMatrix<G>*>& getMapping() {
00052 return dense_ptr_;
00053 }
00054
00056 inline uint dim() const {
00057 return dim_;
00058 }
00059
00061 uint indexOfPoints;
00062
00064 uint indexOfMesh;
00065
00067 uint indexOfEdgeMesh;
00068
00070 uint indexOfVertexMesh;
00071
00073 uint indexOfAttributes;
00074
00076 uint indexOfEdgAttr;
00077
00079 uint indexOfVtxAttr;
00080
00082 uint indexOfPolynomialDegree;
00083
00085 uint counter;
00086
00093 uint dimensionsOfMatrices[4];
00094
00099 bool counted;
00100
00101
00102
00103
00104 inline void resetCounter() {
00105 indexOfPoints = 0;
00106 indexOfMesh = 0;
00107 indexOfEdgeMesh = 0;
00108 indexOfEdgAttr = 0;
00109 indexOfVertexMesh = 0;
00110 indexOfAttributes = 0;
00111 indexOfVtxAttr = 0;
00112 indexOfPolynomialDegree = 0;
00113 counter = 0;
00114 for (uint i = 0; i < 4; ++i)
00115 dimensionsOfMatrices[i] = 0;
00116 }
00117 protected:
00119 uint dim_;
00120
00122 std::map<std::string, concepts::DenseMatrix<G>*>& dense_ptr_;
00123
00127 const enum concepts::ElementGraphicsBase::graphicsType type_;
00128
00129 };
00130
00131
00132
00139 template<class F, class G = typename concepts::Realtype<F>::type>
00140 class MatrixBaseDataCell: public MatrixBaseOutputCell<G> {
00141 public:
00146 MatrixBaseDataCell(
00147 std::map<std::string, concepts::DenseMatrix<G>*>& dense_ptr,
00148 concepts::DenseMatrix<F>*& funValue,
00149 const concepts::Vector<F>& solution, const concepts::ElementFunction<F,
00150 G>* fun = 0, uint dim = 2) :
00151 MatrixBaseOutputCell<G> (dense_ptr,
00152 concepts::ElementGraphicsBase::DENSEMATRIX, dim), fun_(fun),
00153 funValue_(funValue), sol_(solution) {
00154 }
00155
00157 virtual ~MatrixBaseDataCell() {
00158 }
00159
00164 inline virtual void operator()(const concepts::Element<G>& elm) {
00165 elm.T().extract(sol_, coeff_);
00166 elm.graphics()->operator()(elm, this->type_, *this);
00167 }
00168
00170 virtual void operator()(const concepts::Cell& cell) {
00171 throw conceptsException(concepts::MissingFeature("cell not supported"));
00172 }
00173
00175 inline const concepts::ElementFunction<F, G>* elementFunction() {
00176 if (fun_)
00177 return fun_;
00178 else
00179 return 0;
00180 }
00181
00183 inline uint n() {
00184 if (!fun_)
00185 return 1;
00186 return fun_->n();
00187 }
00188
00190 virtual concepts::DenseMatrix<F>* funValue() const {
00191 return funValue_;
00192 }
00193
00197 inline const concepts::Array<F>& coeff() const {
00198 return coeff_;
00199 }
00200
00201 private:
00202
00204
00205 const concepts::ElementFunction<F, G>* fun_;
00206
00208 concepts::Array<F> coeff_;
00209
00211 concepts::DenseMatrix<F>*& funValue_;
00212
00214 const concepts::Vector<F>& sol_;
00215 };
00216
00217
00218
00224 template<class F, class G = typename concepts::Realtype<F>::type>
00225 class MatrixBaseElementFormulaCell: public MatrixBaseOutputCell<G> {
00226 public:
00233 MatrixBaseElementFormulaCell(std::map<std::string,
00234 concepts::DenseMatrix<G>*>& dense_ptr,
00235 concepts::DenseMatrix<F>*& funValue, const uint dim,
00236 const concepts::ElementFormula<F, G>& fun) :
00237 MatrixBaseOutputCell<G> (dense_ptr,
00238 concepts::ElementGraphicsBase::DENSEMATRIX, dim),
00239 funValue_(funValue), fun_(fun) {
00240 }
00241
00242 virtual ~MatrixBaseElementFormulaCell() {
00243 }
00244
00247 virtual void operator()(const concepts::Element<G>& elm) {
00248 elm.graphics()->operator()(elm, this->type_, *this);
00249 }
00250
00252 virtual void operator()(const concepts::Cell& cell)
00253 throw (concepts::MissingFeature) {
00254 throw conceptsException(concepts::MissingFeature("cell not supported"));
00255 }
00256
00258 const concepts::ElementFormula<F, G>& elementFormula() {
00259 return fun_;
00260 }
00261
00263 virtual uint n() const {
00264 return Size<F>::n();
00265 }
00266
00268 virtual concepts::DenseMatrix<F>* funValue() const {
00269 return funValue_;
00270 }
00271 protected:
00272
00274 concepts::DenseMatrix<F>*& funValue_;
00275
00277 const concepts::ElementFormula<F, G>& fun_;
00278 };
00279
00285 template<class F, class G = typename concepts::Realtype<F>::type>
00286 class MatrixSolutionEvaluationCell: public MatrixBaseOutputCell<G> {
00287 public:
00292 MatrixSolutionEvaluationCell(std::map<std::string,
00293 concepts::DenseMatrix<G>*>& dense_ptr,
00294 concepts::DenseMatrix<F>* funValue,
00295 const concepts::Vector<F>* solution, const concepts::ElementFunction<F,
00296 G>* fun = 0, uint dim = 2) :
00297 MatrixBaseOutputCell<G> (dense_ptr,
00298 concepts::ElementGraphicsBase::DENSEMATRIX, dim), fun_(fun),
00299 funValue_(funValue), sol_(solution) {
00300 writeMesh = true;
00301 }
00302
00304 virtual ~MatrixSolutionEvaluationCell() {
00305 }
00306
00311 inline virtual void operator()(const concepts::Element<G>& elm) {
00312 elm.T().extract(*sol_, coeff_);
00313 elm.graphics()->operator()(elm, this->type_, *this);
00314 }
00315
00317 virtual void operator()(const concepts::Cell& cell) {
00318 throw conceptsException(concepts::MissingFeature("cell not supported"));
00319 }
00320
00322 inline const concepts::ElementFunction<F, G>* elementFunction() {
00323 if (fun_)
00324 return fun_;
00325 else
00326 return 0;
00327 }
00328
00329
00330
00332 inline uint n() {
00333 if (!fun_)
00334 return 1;
00335 return fun_->n();
00336 }
00337
00339 virtual concepts::DenseMatrix<F>* funValue() const {
00340 return funValue_;
00341 }
00342
00344 virtual void setSolVec(const concepts::Vector<F>* newsol) {
00345 sol_ = newsol;
00346 }
00348 virtual void setFunValue(concepts::DenseMatrix<F>* newFunVal) {
00349 funValue_ = newFunVal;
00350 }
00351
00355 inline const concepts::Array<F>& coeff() const {
00356 return coeff_;
00357 }
00358
00359 bool writeMesh;
00360
00361 private:
00362
00364 const concepts::ElementFunction<F, G>* fun_;
00365
00367 concepts::Array<F> coeff_;
00368
00370 concepts::DenseMatrix<F>* funValue_;
00371
00373 const concepts::Vector<F>* sol_;
00374 };
00375
00376
00377
00378 class MatrixBaseMeshCell: public MatrixBaseOutputCell<concepts::Real> {
00379 public:
00380
00388 MatrixBaseMeshCell(std::map<std::string, concepts::DenseMatrix<
00389 concepts::Real>*>& dense_ptr, const uint dim = 2,
00390 const uint points = 5,
00391 const enum concepts::ElementGraphicsBase::graphicsType type =
00392 concepts::ElementGraphicsBase::MESH_DENSEMATRIX) :
00393 graphics::MatrixBaseOutputCell<concepts::Real>(dense_ptr, type, dim),
00394 points_(2, points) {
00395 }
00396
00397 virtual ~MatrixBaseMeshCell() {
00398 }
00399
00402 virtual void operator()(const concepts::Element<Real>& elm) {
00403
00404 elm.graphics()->operator()(elm, this->type_, *this);
00405 }
00406
00409 virtual void operator()(const concepts::Cell& cell);
00410
00411 private:
00412
00414 const concepts::Array<uint> points_;
00415 };
00416
00417 }
00418
00419 #endif //MATRIX_BASE_HH