C++ main module for emicrom Package  1.0
EMM_CondensedMassMatrix.h
Go to the documentation of this file.
1 #ifndef EMM_CondensedMassMatrix_H
2 #define EMM_CondensedMassMatrix_H
3 
4 
6 
7 #include "MATH_ArrayVector.h"
8 
9 
23 
25  // ATTRIBUTES
26 public:
27 
28 
29 
30 
31 private:
32 
33  //indicates to use direct solver or iterative solver
35 
36  //indicates if the symmetric dot is applied to the condensed symmetric matrix
38 
39  //diagonal vector of size nPoints
40  SP::MATH_ArrayVector mDiagonal;
41 
42 
43 protected:
44  // METHODS
45 
46  // CONSTRUCTORS
47 
51 
52 
53 
54  // DESTRUCTORS
55 
56 
59  virtual ~EMM_CondensedMassMatrix(void);
60 
61 public:
62 
66  virtual SP::MATH_Matrix NewInstance() const {
67  return New();
68  }
69 
73  inline static SP::EMM_CondensedMassMatrix New() {
74  SP::EMM_CondensedMassMatrix p(new EMM_CondensedMassMatrix(),
76  p->setThis(p);
77  return p;
78  };
79 
80  // SET methods
81 
82 public:
83 
87  inline void setIsSolverExplicit(const tBoolean& b) {
88  mIsSolverExplicit=b;
89  }
90 
91 
92  // GET methods
93 
94 
95 
96 public:
105  virtual tULLInt getMemorySize() const {
106  return EMM_CanonicalMassMatrix::getMemorySize()+mDiagonal->getSize();
107  }
108 
109 
110 
111 public:
112  // OTHERS methods
113 
116  virtual void discretize(const EMM_Grid3D& mesh,SPC::EMM_LimitConditionArray lc);
117 protected:
127  virtual void product(const tUIndex& n,
128  const tReal& beta,
129  const tUCInt& incX,
130  const tReal* x,
131  const tReal& alpha,
132  const tUCInt& incY,tReal* y) const {
133  product(n,incX,beta,x,alpha,y);
134  }
135 
136 private:
137 
146  void product(const tUIndex& n,
147  const tDimension& dim,
148  const tReal& beta,
149  const tReal* x,
150  const tReal& alpha,
151  tReal* y) const;
152 
153 
154 
155 
156 private:
165  tReal symmetricDot(const tUIndex& n,
166  const tDimension& dim,
167  const tReal* x,
168  const tReal* y) const;
169 
179  tReal symmetricDot(const tUIndex& n,
180  const tDimension& dim,
181  const tReal* D,
182  const tReal* x,
183  const tReal* y) const;
184 
185 
186 
187 
188 public:
189 
198  virtual tBoolean solve(MATH_Solver& solver,EMM_RealField& B);
199 
207 
214  virtual void product(const tReal& beta,const MATH_Vector& x,const tReal& alpha, MATH_Vector& y) const {
215  if (alpha==0) {
216  product(beta,x,y);
217  return;
218  }
219 
220  if (beta==0) {
221  y.dot(alpha);
222  return;
223  }
224 
225  //verify the size of X
226  tUIndex nCols=getColumnsNumber();
227  tUIndex nX=x.getSize();
228  tDimension dim=nX/nCols;
229  nX/=dim;
230  if (nX!=getColumnsNumber()) {
231  throw CORE_Exception("emicrom/math/solver",
232  "EMM_CondensedMassMatrix::product(beta,X,alpha,Y)",
233  "error in dimension of vector X : "+CORE_Integer::toString(nX)+" != "+
235  }
236 
237 
238  //verify the size of B = size of X
239  tUIndex nY=y.getSize();
240  nY/=dim;
241  if (nY!=getRowsNumber())
242  throw CORE_Exception("emicrom/math/solver",
243  "EMM_CondensedMassMatrix::product(beta,X,alpha,Y)",
244  "error in dimension of vector Y : "+CORE_Integer::toString(nY)+" != "+
246 
247 
248 
249 
250  //compute the product
251  //y=alpha.alpha+beta.T.x
252  product(nX,dim,beta,&x[0],alpha,&y[0]);
253  }
261  virtual void product(const tReal& alpha,const MATH_Vector& x,MATH_Vector& y) const {
262 
263  //pathological cases
264  if (alpha==0) {
265  y.setSize(getRowsNumber());
266  y.init(0);
267  return;
268  }
269 
270  if (alpha==1) {
271  product(x,y);
272  return;
273  }
274 
275  //set the size of y
276  y.setSize(getRowsNumber());
277 
278  //verify the size of X
279  tUIndex nCols=getColumnsNumber();
280  tUIndex nX=x.getSize();
281  tDimension dim=nX/nCols;
282  nX/=dim;
283 
284  if (nX!=getColumnsNumber()) {
285  throw CORE_Exception("emicrom/math/solver",
286  "EMM_CondensedMassMatrix::product(beta,X,Y)",
287  "error in dimension of vector X :"+CORE_Integer::toString(nX)+" != "+
289 
290  }
291 
292 
293  //compute the product
294  //y=alpha.T.X
295  product(nX,dim,alpha,&x[0],0.,&y[0]);
296 
297  }
298 
303  virtual void product(const MATH_Vector& x,MATH_Vector& y) const {
304 
305  //verify the size of X
306  tUIndex nCols=getColumnsNumber();
307  tUIndex nX=x.getSize();
308  tDimension dim=nX/nCols;
309  nX/=dim;
310  if (nX!=getColumnsNumber())
311  throw CORE_Exception("emicrom/math/solver",
312  "EMM_CondensedMassMatrix::product(X,Y)",
313  "error in dimension of vector X "+CORE_Integer::toString(nX)+" != "+
315  //set the size of y
316  y.setSize(getRowsNumber());
317 
318 
319 
320  //compute the product
321  //y=T.X
322  product(nX,dim,1.,&x[0],0.,&y[0]);
323 
324  }
325 
332  virtual void product(const tReal& alpha,const EMM_RealField& X,
333  const tReal& beta,EMM_RealField& Y) const;
334 
335 
339  virtual tReal symmetricDot(const EMM_RealField& X) const;
344  virtual tReal symmetricDot(const EMM_RealArray& W,const EMM_RealField& X) const;
345 
349  virtual tString toString() const {
351  }
352 
353 
354 
355 
356 };
357 
358 #endif
virtual tUIndex getRowsNumber() const
get the rows number of the matrix
Definition: EMM_CanonicalMassMatrix.h:87
This class describes a grid3d mesh.
Definition: EMM_Grid3D.h:48
virtual void product(const MATH_Vector &x, MATH_Vector &y) const
b=T.x where T is this
Definition: EMM_CondensedMassMatrix.h:303
SP_OBJECT(EMM_CondensedMassMatrix)
static const tDimension Y
Definition: EMM_Object.h:34
virtual tBoolean solve(MATH_Solver &solver, EMM_RealField &B)
solve AX=B thanks to the solver
Definition: EMM_CondensedMassMatrix.cpp:571
static const tDimension X
Definition: EMM_Object.h:33
static SP::EMM_CondensedMassMatrix New()
create a mass matrix
Definition: EMM_CondensedMassMatrix.h:73
virtual tString toString() const
return the string representatio of the class
Definition: EMM_CanonicalMassMatrix.cpp:967
SP::MATH_ArrayVector mDiagonal
Definition: EMM_CondensedMassMatrix.h:40
#define tUCInt
Definition: types.h:21
#define tBoolean
Definition: types.h:139
virtual void product(const tUIndex &n, const tReal &beta, const tUCInt &incX, const tReal *x, const tReal &alpha, const tUCInt &incY, tReal *y) const
y:=alpha.y+beta. T . x where T is this
Definition: EMM_CondensedMassMatrix.h:127
virtual ~EMM_CondensedMassMatrix(void)
destroy
Definition: EMM_CondensedMassMatrix.cpp:26
tString toString() const
return the string associated to the integer
Definition: CORE_Integer.h:106
#define tDimension
Definition: EMM_Types.h:10
DEFINE_SVPTR(EMM_CondensedMassMatrix)
tBoolean mIsSolverExplicit
Definition: EMM_CondensedMassMatrix.h:34
virtual void init(const tReal &alpha)
init the value to alpha
Definition: MATH_Vector.cpp:12
virtual tULLInt getMemorySize() const
return the memory size in byte
Definition: EMM_CanonicalMassMatrix.h:105
this class describes the exceptions raised for CORE package
Definition: CORE_Exception.h:15
virtual tReal dot(const MATH_Vector &x) const
s=x^t.T where T is this
Definition: MATH_Vector.cpp:480
virtual tULLInt getMemorySize() const
return the memory size in byte
Definition: EMM_CondensedMassMatrix.h:105
This class describes a masked vector.
Definition: MATH_Vector.h:16
EMM_CondensedMassMatrix(void)
create
Definition: EMM_CondensedMassMatrix.cpp:11
EMM_Array< tLimitCondition > EMM_LimitConditionArray
Definition: EMM_Array.h:279
virtual tUIndex getSize() const =0
get the utile size of the vector
#define tUIndex
Definition: types.h:126
This class describes a real array.
Definition: EMM_RealArray.h:16
virtual void setSize(const tUIndex &n)=0
set the size of the vector
This class describes a solver of Ax=b.
Definition: MATH_Solver.h:18
virtual tString toString() const
return the string representatio of the class
Definition: EMM_CondensedMassMatrix.h:349
#define tString
Definition: types.h:135
virtual SP::MATH_Matrix NewInstance() const
return a share pointer to a new instance of this
Definition: EMM_CondensedMassMatrix.h:66
void setIsSolverExplicit(const tBoolean &b)
set if the solver used is a explicit
Definition: EMM_CondensedMassMatrix.h:87
virtual void discretize(const EMM_Grid3D &mesh, SPC::EMM_LimitConditionArray lc)
discretize the matrix
Definition: EMM_CondensedMassMatrix.cpp:33
This class describes the mass matrix where is the P1 function with is 1 on the point i and 0 otherw...
Definition: EMM_CanonicalMassMatrix.h:24
virtual tUIndex getColumnsNumber() const
get the columns number of the matrix
Definition: EMM_CanonicalMassMatrix.h:93
virtual void product(const tReal &beta, const MATH_Vector &x, const tReal &alpha, MATH_Vector &y) const
y:=alpha.y+beta. T . x where T is this
Definition: EMM_CondensedMassMatrix.h:214
This class describes the condensed mass matrix where is the P1 function with is 1 on the point i an...
Definition: EMM_CondensedMassMatrix.h:22
tBoolean mIsCondensedSymmetricDot
Definition: EMM_CondensedMassMatrix.h:37
#define tULLInt
Definition: types.h:45
This class describes a real field.
Definition: EMM_RealField.h:21
tReal symmetricDot(const tUIndex &n, const tDimension &dim, const tReal *x, const tReal *y) const
Definition: EMM_CondensedMassMatrix.cpp:277
#define tReal
Definition: types.h:118
DEFINE_SPTR(EMM_CondensedMassMatrix)
virtual void product(const tReal &alpha, const MATH_Vector &x, MATH_Vector &y) const
Y=alpha.T.x where T is this.
Definition: EMM_CondensedMassMatrix.h:261
class Free introduced for deleting a smart pointer
Definition: CORE_Object.h:141