G+Smo  25.01.0
Geometry + Simulation Modules
 
Loading...
Searching...
No Matches
gsFlowFieldCreator.h
Go to the documentation of this file.
1
12#pragma once
13
14namespace gismo
15{
16
25template<class T>
27{
28
29public: // *** Smart pointers ***
30
31 typedef memory::shared_ptr< gsScaledOuterNormalField > Ptr;
32 typedef memory::unique_ptr< gsScaledOuterNormalField > uPtr;
33
34
35protected: // *** Class members ***
36
37 index_t m_patch;
38 boxSide m_side;
39 const gsField<T>& m_scalarField;
40
41
42public: // *** Constructor/destructor ***
43
48 gsScaledOuterNormalField( index_t patch, boxSide side, const gsField<T>& scalarField):
49 m_patch(patch), m_side(side), m_scalarField(scalarField)
50 { }
51
52 GISMO_CLONE_FUNCTION(gsScaledOuterNormalField)
53
54
55public: // *** Member functions ***
56
57 virtual void eval_into(const gsMatrix<T>& u, gsMatrix<T>& result) const
58 {
59 result.resize(this->targetDim(), u.cols());
60
62 mapData.side = m_side;
63 mapData.points = u;
64 m_scalarField.patches().patch(m_patch).computeMap(mapData);
65
66 gsMatrix<T> scalarVals = getScalarValues(u);
67
68 gsVector<> normal;
69 for (index_t k = 0; k < u.cols(); k++)
70 {
71 outerNormal(mapData, k, m_side, normal);
72 result.col(k) = scalarVals(0, k) * (1. / normal.norm()) * normal;
73 }
74 }
75
76 short_t domainDim() const { return m_scalarField.patches().patch(m_patch).parDim(); }
77 short_t targetDim() const { return m_scalarField.patches().patch(m_patch).geoDim(); }
78
79 virtual std::ostream &print(std::ostream &os) const
80 { os << "gsScaledOuterNormalField"; return os; };
81
82
83protected: // *** Member functions ***
84
85 virtual gsMatrix<T> getScalarValues(const gsMatrix<T>& u) const
86 { return m_scalarField.function(m_patch).eval(u); }
87
88
89}; // gsScaledOuterNormalField
90
91// ----------------------------------------------------------------------------
92
101template<class T>
103{
104
105public:
107
108public: // *** Smart pointers ***
109
110 typedef memory::shared_ptr< gsDiffScaledOuterNormalField > Ptr;
111 typedef memory::unique_ptr< gsDiffScaledOuterNormalField > uPtr;
112
113
114protected: // *** Class members ***
115
116 T m_targetValue;
117
118
119public: // *** Constructor/destructor ***
120
121 gsDiffScaledOuterNormalField( index_t patch, boxSide side, const gsField<T>& scalarField, T targetValue):
122 Base(patch, side, scalarField), m_targetValue(targetValue)
123 { }
124
125 GISMO_CLONE_FUNCTION(gsDiffScaledOuterNormalField)
126
127
128public: // *** Member functions ***
129
130 virtual std::ostream &print(std::ostream &os) const
131 { os << "gsDiffScaledOuterNormalField"; return os; };
132
133
134protected: // *** Member functions ***
135
136 virtual gsMatrix<T> getScalarValues(const gsMatrix<T>& u) const
137 {
138 gsMatrix<T> fieldVals = Base::getScalarValues(u);
139
140 gsMatrix<T> targetVals(fieldVals.rows(), fieldVals.cols());
141 targetVals.setOnes();
142 targetVals *= m_targetValue;
143
144 return (targetVals - fieldVals);
145 }
146
147
148}; // gsDiffScaledOuterNormalField
149
150} // namespace gismo
Struct which represents a certain side of a box.
Definition gsBoundary.h:85
Function returning the (unit) outer normal vector scaled by the difference of a target value and valu...
Definition gsFlowFieldCreator.h:103
virtual std::ostream & print(std::ostream &os) const
Prints the object as a string.
Definition gsFlowFieldCreator.h:130
A scalar of vector field defined on a m_parametric geometry.
Definition gsField.h:55
const gsFunction< T > & function(int i=0) const
Returns the gsFunction of patch i.
Definition gsField.h:231
const gsMultiPatch< T > & patches() const
Returns gsMultiPatch containing the geometric information on the domain.
Definition gsField.h:210
A function from a n-dimensional domain to an m-dimensional image.
Definition gsFunction.h:60
the gsMapData is a cache of pre-computed function (map) values.
Definition gsFuncData.h:349
gsMatrix< T > points
input (parametric) points
Definition gsFuncData.h:372
A matrix with arbitrary coefficient type and fixed or dynamic size.
Definition gsMatrix.h:41
Function returning the (unit) outer normal vector scaled by values of a given scalar field.
Definition gsFlowFieldCreator.h:27
short_t targetDim() const
Dimension of the target space.
Definition gsFlowFieldCreator.h:77
virtual std::ostream & print(std::ostream &os) const
Prints the object as a string.
Definition gsFlowFieldCreator.h:79
short_t domainDim() const
Dimension of the (source) domain.
Definition gsFlowFieldCreator.h:76
virtual void eval_into(const gsMatrix< T > &u, gsMatrix< T > &result) const
Evaluate the function at points u into result.
Definition gsFlowFieldCreator.h:57
gsScaledOuterNormalField(index_t patch, boxSide side, const gsField< T > &scalarField)
Constructor.
Definition gsFlowFieldCreator.h:48
A vector with arbitrary coefficient type and fixed or dynamic size.
Definition gsVector.h:37
#define short_t
Definition gsConfig.h:35
#define index_t
Definition gsConfig.h:32
The G+Smo namespace, containing all definitions for the library.
@ NEED_OUTER_NORMAL
Outward normal on the boundary.
Definition gsForwardDeclarations.h:86