IFEM 90A354
AnaSol.h
Go to the documentation of this file.
1// $Id$
2//==============================================================================
12//==============================================================================
13
14#ifndef _ANA_SOL_H
15#define _ANA_SOL_H
16
17#include <iostream>
18#include <vector>
19
20class RealFunc;
21class VecFunc;
22class TensorFunc;
23class STensorFunc;
24namespace tinyxml2 { class XMLElement; }
25
26
31class AnaSol
32{
33public:
43 explicit AnaSol(RealFunc* s1 = nullptr, VecFunc* s2 = nullptr,
44 VecFunc* v1 = nullptr, TensorFunc* v2 = nullptr,
45 STensorFunc* v3 = nullptr);
46
50 AnaSol(RealFunc* s, STensorFunc* sigma);
51
56 : vecSol(v), vecSecSol(nullptr), stressSol(sigma) {}
57
60 explicit AnaSol(STensorFunc* sigma)
61 : vecSol(nullptr), vecSecSol(nullptr), stressSol(sigma) {}
62
67 AnaSol(std::istream& is, const int nlines, bool scalarSol = true);
68
72 explicit AnaSol(const tinyxml2::XMLElement* elem, bool scalarSol = true);
73
75 AnaSol(const AnaSol&) = delete;
76
78 virtual ~AnaSol();
79
81 char hasScalarSol() const
82 {
83 if (stressSol && !vecSecSol && !vecSol)
84 return 3;
85 else if (!scalSecSol.empty())
86 return 2;
87 else if (!scalSol.empty())
88 return 1;
89 else
90 return 0;
91 }
92
94 char hasVectorSol() const
95 {
96 if (stressSol)
97 return 3;
98 else if (vecSecSol)
99 return 2;
100 else if (vecSol)
101 return 1;
102 else
103 return 0;
104 }
105
107 RealFunc* getScalarSol(size_t idx = 0) const
108 { return scalSol.size() <= idx ? nullptr : scalSol[idx]; }
109
111 VecFunc* getScalarSecSol(size_t idx = 0) const
112 { return scalSecSol.size() <= idx ? nullptr : scalSecSol[idx]; }
113
115 VecFunc* getVectorSol() const { return vecSol; }
116
119
121 STensorFunc* getStressSol() const { return stressSol; }
122
124 void initPatch(size_t pIdx);
125
129 virtual void setupSecondarySolutions();
130
131private:
133 template<class Scalar>
134 void parseExpressionFunctions(const tinyxml2::XMLElement* elem, bool scalarSol);
135
137 void parseFieldFunctions(const tinyxml2::XMLElement* elem, bool scalarSol);
138
139protected:
140 bool symmetric = false;
141
142 std::vector<RealFunc*> scalSol;
143 std::vector<VecFunc*> scalSecSol;
144
148
149};
150
151#endif
Class for analytical solution fields (primary and secondary solution).
Definition AnaSol.h:32
VecFunc * vecSol
Primary vector solution field.
Definition AnaSol.h:145
void parseFieldFunctions(const tinyxml2::XMLElement *elem, bool scalarSol)
Parses field functions from XML definition.
Definition AnaSol.C:306
std::vector< RealFunc * > scalSol
Primary scalar solution fields.
Definition AnaSol.h:142
STensorFunc * stressSol
Secondary solution field (stress field)
Definition AnaSol.h:147
VecFunc * getVectorSol() const
Returns the vector solution, if any.
Definition AnaSol.h:115
void initPatch(size_t pIdx)
Sets the patch to use.
Definition AnaSol.C:157
STensorFunc * getStressSol() const
Returns the stress solution, if any.
Definition AnaSol.h:121
virtual void setupSecondarySolutions()
Make sure we have a secondary solution.
Definition AnaSol.C:369
AnaSol(VecFunc *v, STensorFunc *sigma)
Constructor initializing the primary and secondary solution fields.
Definition AnaSol.h:55
void parseExpressionFunctions(const tinyxml2::XMLElement *elem, bool scalarSol)
Parses expression functions from XML definition.
Definition AnaSol.C:177
RealFunc * getScalarSol(size_t idx=0) const
Returns the scalar solution, if any.
Definition AnaSol.h:107
AnaSol(STensorFunc *sigma)
Constructor initializing the symmetric stress tensor field only.
Definition AnaSol.h:60
VecFunc * getScalarSecSol(size_t idx=0) const
Returns the secondary scalar solution, if any.
Definition AnaSol.h:111
TensorFunc * getVectorSecSol() const
Returns the secondary vector solution, if any.
Definition AnaSol.h:118
virtual ~AnaSol()
The destructor frees the analytical solution fields.
Definition AnaSol.C:145
std::vector< VecFunc * > scalSecSol
Secondary scalar solution fields.
Definition AnaSol.h:143
AnaSol(const AnaSol &)=delete
No copying of this class.
char hasVectorSol() const
Checks whether a vector solution is defined.
Definition AnaSol.h:94
TensorFunc * vecSecSol
Secondary solution field (vector gradient field)
Definition AnaSol.h:146
bool symmetric
True to use symmetric secondary solution.
Definition AnaSol.h:140
char hasScalarSol() const
Checks whether a scalar solution is defined.
Definition AnaSol.h:81
Scalar-valued unary function of a spatial point.
Definition Function.h:193
Symmetric tensor-valued unary function of a spatial point.
Definition TensorFunction.h:71
Tensor-valued unary function of a spatial point.
Definition TensorFunction.h:27
Vector-valued unary function of a spatial point.
Definition Function.h:242