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 SuTermVector} class}
18
19The {\class SuTermVector} class carries numerical representation of a single linear form and more generally any vector attached to an approximation space.
20\vspace{.1cm}
21\begin{lstlisting}[]{}
22class SuTermVector : public Term
23{
24protected :
25    SuLinearForm* sulf_p;
26    const Unknown* u_p;
27    mutable Space* space_p;
28    std::vector<Space*> subspaces;
29    VectorEntry* entries_p;
30    VectorEntry* scalar_entries_p;
31    std::vector<DofComponent> cdofs_;
32    }
33\end{lstlisting}
34\vspace{.3cm}
35The \verb?sulf_p? contains a pointer to a {\class SuLinearForm} (single unknown linear form). It may be null, that means there is no explicit linear form attached to the {\class SuTermVector}. \\
36The \verb?space_p? pointer points to the largest subspace involved in {\class SuTermVector}. This pointer should not be null because it carries the dofs numbering of vector. For this reason too, the largest subspace has to be correctly updated during any operation on {\class SuTermVector}. The {\class Space* } vector \verb?subspaces? contains the subspaces (as subspace of largest space) attached to basic linear forms defined in the {\class SuLinearForm} pointer (if defined), see {\cmd buildSubspaces} function.\\
37
38\begin{remark} Do not confused the \verb?space_p? pointer and \verb?u_p->space_p? pointer that specifies the whole space. They may be same!\end{remark}
39\\
40
41The numerical representation of vector is defined in the \verb?entries_p? {\class VectorEntry } pointer as a real/complex vector or a real/complex vector of vectors, regarding the value type (real or complex) and the structure of the unknown (scalar or vector). If required, vector of vectors representation may be expanded to a vector of scalars stored in the  \verb?scalar_entries_p? {\class VectorEntry} pointer. In that case the \verb?cdofs_? vector of {\class DofComponent } gives the numbering (in {\class DofComponent }) of entries. Note that if {\class SuTermVector} is of scalar type, \verb?scalar_entries_p = entries_p?.\\
42
43The {\class SuTermVector} class provides one constructor from linear form, some constructors from constant value, functions or symbolic functions, one constructor from linear combination and some copy constructors:
44\vspace{.1cm}
45\begin{lstlisting}[]{}
46//constructor from linear form
47SuTermVector(SuLinearForm* sulf = 0, const String& na = "", bool noass = false);
48//constructors from constant value or function (no linear form)
49SuTermVector(const String&, const Unknown*, Space*, ValueType vt = _real, Number n = 0, Dimen nv = 0, bool noass = false); //vector of zeros
50template <typename T>
51SuTermVector(const Unknown&, const GeomDomain&, const Vector<T>&,
52             const String&, bool);
53template <typename T>
54SuTermVector(const Unknown&, const GeomDomain&, const T&,
55             const String&, bool);
56SuTermVector(const Unknown&, const GeomDomain&, funSR_t&,
57             const String& na="", bool noass=false);
58SuTermVector(const Unknown&, const GeomDomain&, funSC_t&,
59             const String& na="", bool noass =false);
60SuTermVector(const Unknown&, const GeomDomain&, funVR_t&,
61             const String& na="", bool noass =false);
62SuTermVector(const Unknown&, const GeomDomain&, funVC_t&,
63             const String& na="", bool noass =false);
64//constructor from explicit function of SuTermVector's
65SuTermVector(const SuTermVector&, funSR1_t& f, const string_t& na="");
66SuTermVector(const SuTermVector&, const SuTermVector&, funSR2_t& f, const string_t& na="");
67SuTermVector(const SuTermVector&, funSC1_t& f, const string_t& na="");
68SuTermVector(const SuTermVector&, const SuTermVector&, funSC2_t& f, const string_t& na="");
69//constructor from symbolic function of SuTermVector's
70SuTermVector(const SuTermVector&, const SymbolicFunction& , const string_t& na="");
71SuTermVector(const SuTermVector&, const SuTermVector&, const SymbolicFunction&,
72             const string_t& na="");
73SuTermVector(const SuTermVector&, const SuTermVector&, const SuTermVector&,
74             const SymbolicFunction&, const string_t& na="");
75//constructor of a vector SuTermVector from scalar SutermVector's
76SuTermVector(const Unknown&, const SuTermVector&, const SuTermVector&, const string_t& ="");
77SuTermVector(const Unknown&, const std::list<const SuTermVector*>&, const string_t& ="");
78//constructor from linear combination (no linear form)
79SuTermVector(const LcTerm&);
80//copy constructors and assign operator
81SuTermVector(const SuTermVector&);
82template<typename T>
83SuTermVector(const SuTermVector&, const T&);
84SuTermVector& operator=(const SuTermVector&);
85//other useful stuff
86virtual ~SuTermVector();
87void copy(const SuTermVector&);    //full copy
88void initFromFunction(const Unknown&, const GeomDomain&, const Function&,
89                      const String& na="", bool noass=false);
90void clear();
91\end{lstlisting}
92\vspace{.2cm}
93A lot of useful accessors and shortcuts to some properties are proposed:
94\vspace{.1cm}
95\begin{lstlisting}[]{}
96string_t name();
97void name(const string_t&);
98SuLinearForm* sulfp() const;
99SuLinearForm*& sulfp();
100VectorEntry*& entries();
101const VectorEntry* entries() const;
102TermType termType() const;
103ValueType valueType() const;
104StrucType strucType() const;
105const Unknown* up() const;
106const Unknown*& up();
107number_t nbOfComponents() const;
108const Space* spacep() const;
109Space*& spacep();
110set<const Space*> unknownSpaces() const;
111number_t nbDofs() const;
112number_t size() const;
113VectorEntry*& scalar_entries();
114const VectorEntry* scalar_entries() const;
115VectorEntry* actual_entries() const;
116const vector<DofComponent>& cdofs() const;
117vector<DofComponent>& cdofs();
118const Dof& dof(number_t n) const;
119const GeomDomain* domain() const;
120\end{lstlisting}
121\vspace{.2cm}
122{\class SuTermVector} may be modified by the following operators and functions:
123\vspace{.1cm}
124\begin{lstlisting}[]{}
125SuTermVector& operator+=(const SuTermVector&);
126SuTermVector& operator-=(const SuTermVector&);
127template<typename T>
128 SuTermVector& operator*=(const T&);
129template<typename T>
130 SuTermVector& operator/=(const T&);
131SuTermVector& merge(const SuTermVector&);
132SuTermVector& toAbs();
133SuTermVector& toReal();
134SuTermVector& toImag();
135SuTermVector operator()(const ComponentOfUnknown&) const;
136SuTermVector& toComplex();
137complex_t maxValAbs() const;
138void setValue(number_t, const Value&);
139void setValue(const Value&, const GeomDomain&);
140void setValue(const Function&, const GeomDomain&);
141void setValue(const SuTermVector&, const GeomDomain&);
142void setValue(const SuTermVector&);
143\end{lstlisting}
144\vspace{.2cm}
145The operator \verb?()? extracts unknown component term vector as a {\class SuTermVector} when \verb?Unknown? is a vector unknown. For instance if \verb?u?  is a vector unknown, \verb?T(u[2])? returns a {\class SuTermVector} containing the elements of \verb?T? corresponding to second component.\\
146\vspace{.2cm}
147Some values can be extracted or computed from:
148\vspace{.1cm}
149\begin{lstlisting}[]{}
150Value getValue(number_t) const;
151SuTermVector* onDomain(const GeomDomain& dom) const;
152template<typename T>
153 T& operator()(const vector<real_t>&, T&) const;
154SuTermVector* interpolate(const Unknown&, const GeomDomain&);
155Value evaluate(const Point&) const;
156template<typename T>
157 Vector<T>& asVector(Vector<T>&) const;
158\end{lstlisting}
159\vspace{.2cm}
160{\class SuTermVector} provides real computation algorithms, in particular FE computation ones:
161\vspace{.1cm}
162\begin{lstlisting}[]{}
163void buildSubspaces();
164void compute();                 //!< compute from linear form
165void compute(const LcTerm&);
166template<typename T, typename K>
167void computeFE(const SuLinearForm&, Vector<T>&, K&);
168template<typename T, typename K>
169void computeIR(const SuLinearForm&, Vector<T>&, K& vt, const vector<Point>&,
170               const Vector<T>&, const vector<Vector<real_t> >* nxs=0);
171\end{lstlisting}
172\vspace{.2cm}
173Some particular member functions allow to change the internal representation:
174\vspace{.1cm}
175\begin{lstlisting}
176void toScalar(bool keepVector=false);
177void toVector(bool keepEntries=false);
178void extendTo(const SuTermVector&);
179void extendTo(const Space&);
180void extendScalarTo(const vector<DofComponent>&, bool useDual = false);
181SuTermVector* mapTo(const GeomDomain&, const Unknown&, bool =true) const;
182void changeUnknown(const Unknown&, const Vector<number_t>&);
183void adjustScalarEntries(const vector<DofComponent>&);
184\end{lstlisting}
185\vspace{.2cm}
186Some extern function are provided to compute norms, ...
187\vspace{.1cm}
188\begin{lstlisting}[]{}
189Complex innerProduct(const SuTermVector&, const SuTermVector&);
190Complex hermitianProduct(const SuTermVector&, const SuTermVector&);
191Real norm1(const SuTermVector&);
192Real norm2(const SuTermVector&);
193Real norminfty(const SuTermVector&);
194\end{lstlisting}
195\vspace{.2cm}
196Finallys, there are some print and export stuff:
197\vspace{.1cm}
198\begin{lstlisting}[deletekeywords={[3] list, map}]
199void print(ostream&) const;
200void print(ostream&, bool r, bool h) const; // raw and header option
201void saveToFile(const String&, bool encode=false) const;
202
203//extern save functions
204void saveToFile(const string_t&, const Space*, const list<SuTermVector*>&,
205                IOFormat iof=_raw, bool withDomName=true);
206void saveToMsh(ostream&, const Space*, const list<SuTermVector*>&,
207               vector<Point>, splitvec_t, const GeomDomain*);
208void saveToMtlb(ostream&, const Space*, const list<SuTermVector*>&,
209                vector<Point>, splitvec_t, const GeomDomain*);
210void saveToVtk(ostream&, const Space*, const list<SuTermVector*>&,
211               vector<Point>,splitvec_t, const GeomDomain*);
212void saveToVtkVtu(ostream&, const Space*, const list<SuTermVector*>&,
213                  vector<Point>, splitvec_t, const GeomDomain*);
214pair<vector<Point>, map<number_t, number_t> > ioPoints(const Space* sp);
215splitvec_t ioElementsBySplitting(const Space*, map<number_t, number_t>);
216\end{lstlisting}
217\vspace{.2cm}
218
219\displayInfos{
220library=term,
221header=SuTermVector.hpp,
222implementation=SuTermVector.cpp,
223test=test\_TermVector.cpp,
224header dep={Term.hpp, LcTerm.hpp, termUtils.hpp, form.h, config.h, utils.h}
225}
226