1%%%%%%%%%%%%%%%%%%%
2% XLiFE++ is an extended library of finite elements written in C++
3%     Copyright (C) 2014  Lunéville, Eric; Kielbasiewicz, Nicolas; Lafranche, Yvon; Nguyen, Manh-Ha; Chambeyron, Colin
4%
5%     This program is free software: you can redistribute it and/or modify
6%     it under the terms of the GNU General Public License as published by
7%     the Free Software Foundation, either version 3 of the License, or
8%     (at your option) any later version.
9%     This program is distributed in the hope that it will be useful,
10%     but WITHOUT ANY WARRANTY; without even the implied warranty of
11%     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12%     GNU General Public License for more details.
13%     You should have received a copy of the GNU General Public License
14%     along with this program.  If not, see <http://www.gnu.org/licenses/>.
15%%%%%%%%%%%%%%%%%%%
16
17\section{The {\classtitle SuTermMatrix} class}
18
19The {\class SuTermMatrix} class carries numerical representation of a single unknown pair bilinear form and more generally any matrix attached to a pair of unknowns (row unknown and row column).\\
20\textdbend\ \ By convention, 'u' refers to column (unknown of bilinear form) and 'v' to row (test function in bilinear form).
21\vspace{.1cm}
22\begin{lstlisting}[]{}
23class SuTermMatrix : public Term
24{protected :
25 SuBilinearForm* sublf_p;            //bilinear form through pointer
26 const Unknown* u_p;                 //column unknown
27 const TestFunction* v_p;            //row unknown
28 mutable Space* space_u_p;           //pointer to u-space
29 mutable Space* space_v_p;           //pointer to v-space
30 std::vector<Space *> subspaces_u;   //u-subspaces involved
31 std::vector<Space *> subspaces_v;   //v-subspaces involved
32 MatrixEntry* entries_p;             //matrix as LargeMatrix
33 MatrixEntry* scalar_entries_p;      //scalar matrix as LargeMatrix
34 std::vector<DofComponent> cdofs_u;  //component u-dof list
35 std::vector<DofComponent> cdofs_v;  //component v-dof list
36 MatrixEntry* rhs_matrix_p;          //correction matrix when essential cond.
37}
38\end{lstlisting}
39\vspace{.3cm}
40The \verb?sublf_p? contains a pointer to a {\class SuBiLinearForm} (single unknown pair bilinear form). It may be null, that means there is no explicit bilinear form attached to the {\class SuTermMatrix}. \\
41The \verb?space_u_p? (resp. \verb?space_u_p?) pointer points to the largest subspace involved in {\class SuTermMatrix} columns (resp. rows). These pointer should never be null because they carry the rom and column dofs numbering. For this reason too, the largest subspaces have to be correctly updated during any operation on {\class SuTermMatrix}. The {\class Space* } vector \verb?subspaces_u? (resp. \verb?subspaces_v?) contains the subspaces (\underline{as subspace of largest space}) attached to basic bilinear forms defined in the {\class SuBiLinearForm} pointer (if defined), see \verb?buildSubspaces? function.\\
42
43\begin{remark}
44Do not confused the \verb?space_u_p? pointer and \verb?u_p->space_p? pointer that specifies the whole space. They may be same!
45\end{remark}
46
47\vspace{.2cm}
48The numerical representation of matrix is defined in the \verb?entries_p? {\class MatrixEntry } pointer as a real/complex matrix or a real/complex matrix of matrices, regarding the value type (real or complex) and the structure of the unknowns (scalar or vector). If required, matrix of matrices representation may be expanded to a matrix of scalars stored in the  \verb?scalar_entries_p? {\class MatrixEntry} pointer. In that case, the \verb?cdofs_u? and \verb?cdofs_v? vectors of {\class DofComponent } give the row and column numbering (in {\class DofComponent }) of entries. Note that if {\class SuTermMatrix} is of scalar type, \verb?scalar_entries_p = entries_p?.\\
49In case of essential conditions applied to, \verb?rhs_matrix_p? {\class MatrixEntry} pointer may be allocated to store the eliminated part of {\class SuTermMatrix}. Note that, {\class SuTermMatrix} class does not manage {\class SetOfConstraints} objects, the treatment of essential condition being driven by  {\class TermMatrix}!\\
50
51The {\class SuTermMatrix} class also handles HMatrix (hierarchical matrix):
52\vspace{.1cm}
53\begin{lstlisting}[]{}
54HMatrixEntry<FeDof>* hm_entries_p; //hierarchical matrix
55HMatrixEntry<FeDof>* hm_scalar_entries_p; //scalar hierarchical matrix
56ClusterTree<FeDof>*  cluster_u;    //column cluster tree
57ClusterTree<FeDof>*  cluster_v;    //row cluster tree
58\end{lstlisting}
59\vspace{.2cm}
60HMatrix stuff is described in chapter \ref{chap_hmatrix}. Let's remember that the hierarchical matrix are built from the clustering of row and column indices ({\tt cluster\_u, cluster\_v}). There are two HMatrixEntry pointers, one to handle any matrix (scalar or matrix), the other one to handle the scalar representation of a matrix of matrices if it is required. When HMatrix is a scalar one, both the pointers are the same.\\
61
62The {\class SuTermMatrix} class provides some constructors from bilinear form, a constructor from SuTermVector (diagonal matrix), a constructor from linear combination and a copy constructor:
63\vspace{.1cm}
64\begin{lstlisting}[]{}
65// basic constructor
66SuTermMatrix(const Unknown*, Space*, const Unknown*, Space*, MatrixEntry*, const String& na="");
67//constructor from bilinear form
68SuTermMatrix(SuBilinearForm* sublf = 0, const String& na="", bool noass=false);
69SuTermMatrix(SuBilinearForm* sublf = 0, const String& na="",
70             ComputingInfo cp= ComputingInfo());
71SuTermMatrix(SuBilinearForm*, const Unknown*, const Unknown*, Space*, Space*,
72             const std::vector<Space *>&, const std::vector<Space *>&,
73             const String&, MatrixEntry* =0);
74//constructor of diagonal matrix
75SuTermMatrix(SuTermVector &, const String& na="");
76SuTermMatrix(const Unknown*, Space*, const Unknown*, Space*, SuTermVector&,
77              StorageType=_noStorage, AccessType=_noAccess, const String& na="");
78void diagFromSuTermVector(const Unknown*, Space*, const Unknown*,Space*, SuTermVector&,
79                          StorageType=_noStorage, AccessType=_noAccess,
80                          const String& na="");
81//constructor from linear cobination
82SuTermMatrix(const LcTerm&,const String& na="");
83//copy constructor and assign operator
84SuTermMatrix(const SuTermMatrix&,const String& na="");
85void copy(const SuTermMatrix&);
86SuTermMatrix& operator=(const SuTermMatrix&);
87//destructor, clear
88virtual ~SuTermMatrix();
89void clear();
90\end{lstlisting}
91\vspace{.2cm}
92There is no specific constructor for SuTermMatrix of type Hmatrix. It is induced by some properties of the bilinear form; more precisely by a particular choice of integration method.\\
93
94It provides a lot of accessors and property functions:
95\vspace{.1cm}
96\begin{lstlisting}[]{}
97TermType termType() const;
98ValueType valueType() const;
99StrucType strucType() const;
100Space& space_u() const;
101Space& space_v() const;
102Space* space_up() const;
103Space* space_vp() const;
104Space*& space_up();
105Space*& space_vp();
106const Unknown* up() const;
107const Unknown* vp() const;
108const Unknown*& up();
109const Unknown*& vp();
110MatrixEntry*& entries();
111const MatrixEntry* entries() cons;
112MatrixEntry*& scalar_entries();
113const MatrixEntry* scalar_entries() const;
114MatrixEntry*& rhs_matrix();
115const MatrixEntry* rhs_matrix() const;
116const std::vector<DofComponent>& cdofsu() const;
117const std::vector<DofComponent>& cdofsv() cons;
118std::vector<DofComponent>& cdofsu();
119std::vector<DofComponent>& cdofsv();
120SymType symmetry() const;
121StorageType storageType() const;
122MatrixStorage* storagep() const;
123void setStorage(StorageType, AccessType);
124void toStorage(StorageType, AccessType);
125\end{lstlisting}
126\vspace{.2cm}
127The main computation functions and related stuff follow:
128\vspace{.1cm}
129\begin{lstlisting}[deletekeywords={[3] set}]
130void compute();
131void compute(const LcTerm&,const String& na="");
132template<unsigned int CM>
133void compute(const std::vector<SuBilinearForm>&, ValueType, StrucType);
134template<typename T, typename K>
135void computeIR(const SuLinearForm&f, T*, K&, const std::vector<Point>&);
136
137void buildSubspaces();
138void setStorage(StorageType, AccessType);
139void toStorage(StorageType, AccessType);
140void addDenseToStorage(const std::vector<SuBilinearForm>&,MatrixStorage*) const;
141void toScalar(bool keepEntries=false);
142std::vector<SuBilinearForm> getSublfs(ComputationType, ValueType&) const;
143void updateStorageType(const std::vector<SuBilinearForm>&,std::set<Number>&,
144                       std::set<Number>&,StorageType&) const;
145\end{lstlisting}
146\vspace{.2cm}
147{\class SuTermMatrix} may be modified by the following algebraic operators:
148\vspace{.1cm}
149\begin{lstlisting}[]{}
150template<typename T>
151SuTermMatrix& operator*=(const T&);
152template<typename T>
153SuTermMatrix& operator/=(const T&);
154SuTermMatrix& operator+=(const SuTermMatrix&);
155SuTermMatrix& operator-=(const SuTermMatrix&);
156friend SuTermVector operator*(const SuTermMatrix&, const SuTermVector&);
157friend SuTermMatrix operator*(const SuTermMatrix&, const SuTermMatrix&);
158\end{lstlisting}
159\vspace{.2cm}
160Finallys, there are some print and export stuff:
161\vspace{.1cm}
162\begin{lstlisting}[]{}
163void print(std::ostream&) const;
164void print(std::ostream&, bool) const;
165void viewStorage(std::ostream&) const;
166void saveToFile(const String&, StorageType, bool=false) const;
167\end{lstlisting}
168\vspace{.2cm}
169Most of the previous functions works when SuTermMatrix handles a HMatrix, but some not. As there is no check, be cautious! Besides, there are some specific functions related to Hmatrix representation:
170\vspace{.1cm}
171\begin{lstlisting}[]{}
172bool hasHierarchicalMatrix() const;
173HMatrix<T,FeDof>& getHMatrix(StrucType str=_undefStrucType) const;
174\end{lstlisting}
175
176\displayInfos{
177library=term,
178header=SuTermMatrix.hpp,
179implementation=SuTermMatrix.cpp,
180test=test\_TermMatrix.cpp,
181header dep={Term.hpp, LcTerm.hpp, termUtils.hpp, form.h, config.h, utils.h}
182}
183