Class documentation of Concepts

Loading...
Searching...
No Matches
matlabElasticityGraphics.hh
Go to the documentation of this file.
1
5#ifndef MATLAB_ELASTICITY_HH_
6#define MATLAB_ELASTICITY_HH_
7
8#include "graphics.hh"
9#include <iostream>
10
11using concepts::Real;
12
13namespace graphics {
14
16
17public:
18
19 template<class G, class F>
21 const std::string& filename, const concepts::Vector<F>& sol_u1,
22 const concepts::Vector<F>& sol_u2, F lambda, F mu,
23 bool plain_stress);
24
26 }
27 ;
28
29};
30
31template<class G, class F>
32MatlabElasticityGraphics::MatlabElasticityGraphics(
33 const concepts::Space<G>& spc,
34 const std::string& filename,
35 const concepts::Vector<F>& sol_u1,
36 const concepts::Vector<F>& sol_u2,
37 F lambda, F mu,
38 bool plain_stress) :
39 MatlabBinaryGraphics(filename) {
40
41 //read necessary informations
42 hp2D::Grad<F> grad;
43 DenseMatrixCollection<G> dmc = this->getSpace(spc);
44 //std::map<std::string, concepts::ElementMatrix<G>*> map = dmc.getMapping();
45
48 concepts::RCP<concepts::ElementMatrix<F> > grad_u1 = this->getSolution(spc, sol_u1, &grad);
49 concepts::RCP<concepts::ElementMatrix<F> > grad_u2 = this->getSolution(spc, sol_u2, &grad);
50
51// concepts::ElementMatrix<F> u1 = *getSolution(spc, sol_u1);
52// concepts::ElementMatrix<F> u2 = *getSolution(spc, sol_u2);
53//
54// concepts::ElementMatrix<F> grad_u1 = this->getSolution(spc, sol_u1, &grad);
55// concepts::ElementMatrix<F> grad_u2 = this->getSolution(spc, sol_u2, &grad);
56
57 uint n = grad_u1->n();
58
59 // compute strains and stresses
60 concepts::Vector<F> strain11_(n);
61 concepts::Vector<F> strain22_(n);
62 concepts::Vector<F> strain12_(n);
63 concepts::Vector<F> stress11_(n);
64 concepts::Vector<F> stress22_(n);
65 concepts::Vector<F> stress12_(n);
66 concepts::Vector<F> stress33_(n);
67
68 for (uint i = 0; i < n; i++) {
69 strain11_(i) = grad_u1->operator ()(0, i);
70 strain22_(i) = grad_u2->operator ()(1, i);
71 strain12_(i) = 0.5
72 * (grad_u2->operator ()(0, i) + grad_u1->operator ()(1, i));
73 }
74 if (plain_stress)
75 for(uint i = 0; i < n; i++) {
76 stress11_(i) = 2*mu*(lambda/(lambda+2*mu) + 1) * strain11_(i)
77 + 2*mu*lambda/(lambda+2*mu) * strain22_(i);
78 stress22_(i) = 2*mu*lambda/(lambda+2*mu) * strain11_(i)
79 + 2*mu*(lambda/(lambda+2*mu) + 1) * strain22_(i);
80 stress12_(i) = 2 * mu * strain12_(i);
81 }
82 else
83 for (uint i = 0; i < n; i++) {
84 stress11_(i) = (lambda + 2 * mu) * strain11_(i) + lambda * strain22_(i);
85 stress22_(i) = lambda * strain11_(i) + (lambda + 2 * mu) * strain22_(i);
86 stress12_(i) = 2 * mu * strain12_(i);
87 stress33_(i) = lambda * (strain11_(i) + strain22_(i) );
88 }
89
90
91 // convert u1, u2 to vectors
92 concepts::Vector<F> u1_(n), u2_(n);
93 for (uint i = 0; i < n; i++){
94 u1_(i) = u1->operator()(0,i);
95 u2_(i) = u2->operator()(0,i);
96 }
97
98
99 // compute the deformed mesh
100// concepts::ElementMatrix<F> x_new = *map["x"];
101// x_new.add(u1);
102// concepts::ElementMatrix<F> y_new = *map["y"];
103// y_new.add(u1);
104
105
106
107 // write data to output
108// this->storeData_(true, dmc->getMapping());
109 this->storeData_(dmc);
110
111// this->add(x_new, "x_new");
112// this->add(y_new, "y_new");
113 this->add(stress11_, "stress11");
114 this->add(stress22_, "stress22");
115 this->add(stress12_, "stress12");
116 if (!plain_stress){
117 this->add(stress33_, "stress33");
118 }
119 this->add(u1_, "displacement_u1");
120 this->add(u2_, "displacement_u2");
121
122}
123
124} // namespace graphics
125
126#endif
void add(const T &u, const std::string varName, enum matio_compression compress=MAT_COMPRESSION_NONE)
Definition matfileIO.hh:160
std::string filename() const
Definition matfileIO.hh:306
concepts::RCP< concepts::ElementMatrix< F > > getSolution(const concepts::Space< G > &spc, const concepts::Vector< F > &sol, const concepts::ElementFunction< F, G > *fun=0)
DenseMatrixCollection< G > getSpace(const concepts::Space< G > &spc)
void storeData_(DenseMatrixCollection< G > &dense_ptr_)
Stores data hold by dense_ptr.
double Real
Definition typedefs.hh:39