denseMatrixGraphics.hh

Go to the documentation of this file.
1 
6 #ifndef densematrixgraphics_hh_
7 #define densematrixgraphics_hh_
8 
10 #include "matrixBasis.hh"
11 #include <map>
12 
13 using concepts::Real;
14 
15 namespace graphics {
16 
17  // ************************************************* DenseMatrixCollection **
18 
25  template<class G>
26  class DenseMatrixCollection: public std::map<std::string,
27  concepts::ElementMatrix<G>* const > {
28  public:
29 
42  DenseMatrixCollection(MatrixCounterCell& counter, bool data = true);
43 
46 
47  protected:
48 
50  int dim_;
51 
53  bool data_;
54 
56  void createMatrix_(const std::string name, uint nrows, uint ncols);
57 
60  };
61 
62  // ************************************************** DenseMatrixGraphics **
63 
70  public:
71 
74 
77 
78  static uint noPoints;
79 
80  protected:
90  template<class F, class G>
92  getSolution(const concepts::Space<G>& spc, const concepts::Vector<F>& sol,
93  const concepts::ElementFunction<F, G>* fun = 0);
94 
102  template<class F, class G>
104  getFunction(const concepts::Space<G>& spc,
105  const concepts::ElementFormula<F, G>& frm);
106 
113  template<class G>
115  getSpace(const concepts::Space<G>& spc);
116 
124  getMesh(concepts::Mesh& msh, const uint points = 5);
125  };
126 
127  // Extract the solution (depends on function fun), corresponding to
128  // the space and the solution vector and returns it.
129  template<class F, class G>
131  const concepts::Space<G>& spc, const concepts::Vector<F>& sol,
132  const concepts::ElementFunction<F, G>* fun) {
133 
134  // Post processor (global)
135  concepts::GlobalPostprocess<G> postProcess(spc);
136 
137  // output dimension for ex. n = 1 if fun = Value or n = 2 if fun = Grad
138  int functionOutputDimension;
139  if (fun)
140  functionOutputDimension = fun->n();
141  else
142  {
143  // We retrieve the default space dimension
144  functionOutputDimension = spc.getOutputDimension();
145  // We multiply by the components of the vector solution
146  if(std::is_same<F, concepts::Real2d>::value || std::is_same<F, concepts::Cmplx2d>::value)
147  functionOutputDimension *=2u;
148  if(std::is_same<F, concepts::Real3d>::value || std::is_same<F, concepts::Cmplx3d>::value)
149  functionOutputDimension *=3u;
150  }
151 
152 
153  // Calculate dimensions of the matrix
154  MatrixCounterCell counter;
155  postProcess(counter);
156 
157  // Build solution vector Matrix
159  functionOutputDimension, counter.getDimensionsOfMatrices(0));
160 
161  //declare cell postprocessor that extract the graphical solution vector
162  MatrixSolutionEvaluationCell<F, G> sec(functionValue, sol, fun, counter.getDim());
163 
164  //store data
165  postProcess(sec);
166 
167  return concepts::RCP<concepts::ElementMatrix<F> >(functionValue);
168  }
169 
170  template<class G>
172  const concepts::Space<G>& spc) {
173 
174  // Post processor (global)
175  concepts::GlobalPostprocess<G> postProcess(spc);
176 
177  // Calculate dimensions of the matrix
178  MatrixCounterCell counter;
179 
180  postProcess(counter);
181 
182  DenseMatrixCollection<G> dmc(counter, true);
183 
184  // Write informations in the matrices
185  MatrixSpaceOutputCell<G> mbdc(dmc, counter.getDim());
186  postProcess(mbdc);
187 
188  return dmc;
189  }
190 
191  // Extract the solution (depends on function fun), corresponding to
192  // the space and the solution vector and returns it.
193  template<class F, class G>
195  const concepts::Space<G>& spc, const concepts::ElementFormula<F, G>& frm) {
196 
197  // Post processor (global)
198  concepts::GlobalPostprocess<G> postProcess(spc);
199 
200  //output dimension for ex. n = 1 if fun = Value or n = 2 if fun = Grad
201  int functionOutputDimension = Size<F>::n();
202 
203  //Calculate dimensions of the matrix
204  MatrixCounterCell counter;
205  postProcess(counter);
206 
207  //Build solution vector Matrix
208  typedef typename concepts::Datatype<F>::type dataType;
209  concepts::ElementMatrix<dataType>* functionValue =
210  new concepts::ElementMatrix<dataType>(functionOutputDimension,
211  counter.getDimensionsOfMatrices(0));
212 
213  // Write informations in the matrices
214  MatrixBaseElementFormulaCell<F, G> bdc(functionValue, counter.getDim(), frm);
215 
216  //calculate size of the matrices / size of data
217  postProcess(bdc);
218 
219  return concepts::makeRCP(functionValue);
220  }
221 
222 } // namespace graphics
223 
224 #endif // densematrixgraphics_hh_
Class for writing the values of the solution of a PDE on the quadrature points of the space in a Dens...
Definition: matrixBasis.hh:331
An abstract class for a function in a FE space.
void createMatrix_(const std::string name, uint nrows, uint ncols)
Creates one dense matrix.
concepts::RCP< concepts::ElementMatrix< F > > getSolution(const concepts::Space< G > &spc, const concepts::Vector< F > &sol, const concepts::ElementFunction< F, G > *fun=0)
Returns a vector with the value of the solution on the quadrature-points of a given space using a giv...
Global Postprocessing.
Definition: postProcess.hh:70
Class that collects information about the mesh/space it iterates over, that are used for MatrixBasisO...
Definition: matrixBasis.hh:33
void createMatrices_(MatrixCounterCell &counter)
Creates the matrices.
virtual ~DenseMatrixCollection()
Destructor: deltes the pointers in the mapping.
virtual uint n() const =0
Number of components.
Graphics.
Definition: basis.hh:33
virtual ~DenseMatrixGraphics()
Destructor.
Class that collects graphical informations about a given space in a set of ElementMatrices.
Definition: matrixBasis.hh:160
Interface for a formula defined element by element.
DenseMatrixCollection< Real > getMesh(concepts::Mesh &msh, const uint points=5)
Returns a graphics::DenseMatrixCollection<G> that contains informations for graphical output of the g...
int dim_
The physical space dimension.
RCP< T > makeRCP(T *x)
Function to create a RCP which deletes the object when no RCP points on it anymore.
Reference-counting pointer.
Definition: bf_iddiv.hh:15
DenseMatrixCollection< G > getSpace(const concepts::Space< G > &spc)
Returns a graphics::DenseMatrixCollection<G> that contains informations for graphical output of the g...
virtual uint getOutputDimension() const
Returns the default output dimension, when we consider plotting a real-valued operator on this space.
Definition: space.hh:50
Element matrix.
Definition: linearForm.hh:18
Class for writing the graphical output of an element formula to ElementMatrices.
Definition: matrixBasis.hh:259
Class that collects data for graphical output and stores it in concepts::ElementMatrices and graphics...
An abstract class for meshes.
Definition: mesh.hh:76
DenseMatrixCollection(MatrixCounterCell &counter, bool data=true)
Constructor: Creates a DenseMatrixCollection holding matrices for graphical output with graphics::Den...
const uint n()=0
int getDimensionsOfMatrices(uint i)
returns the dimension og
Definition: matrixBasis.hh:49
bool data_
Information which values are stored in the mapping.
concepts::RCP< concepts::ElementMatrix< typename concepts::Datatype< F >::type > > getFunction(const concepts::Space< G > &spc, const concepts::ElementFormula< F, G > &frm)
Returns a vector with the value of the function on the quadrature-points of a given space using the g...
Class that hold and manage a std::map with concepts::ElementMatrices for graphical output,...
double Real
Type normally used for a floating point number.
Definition: typedefs.hh:36
Page URL: http://wiki.math.ethz.ch/bin/view/Concepts/WebHome
21 August 2020
© 2020 Eidgenössische Technische Hochschule Zürich