Tnavier_stokes_elements.cc
Go to the documentation of this file.
1// LIC// ====================================================================
2// LIC// This file forms part of oomph-lib, the object-oriented,
3// LIC// multi-physics finite-element library, available
4// LIC// at http://www.oomph-lib.org.
5// LIC//
6// LIC// Copyright (C) 2006-2026 Matthias Heil and Andrew Hazel
7// LIC//
8// LIC// This library is free software; you can redistribute it and/or
9// LIC// modify it under the terms of the GNU Lesser General Public
10// LIC// License as published by the Free Software Foundation; either
11// LIC// version 2.1 of the License, or (at your option) any later version.
12// LIC//
13// LIC// This library is distributed in the hope that it will be useful,
14// LIC// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// LIC// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16// LIC// Lesser General Public License for more details.
17// LIC//
18// LIC// You should have received a copy of the GNU Lesser General Public
19// LIC// License along with this library; if not, write to the Free Software
20// LIC// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21// LIC// 02110-1301 USA.
22// LIC//
23// LIC// The authors may be contacted at oomph-lib@maths.man.ac.uk.
24// LIC//
25// LIC//====================================================================
26// Non-inline functions for triangle/tet NS elements
27
29
30
31namespace oomph
32{
33 //////////////////////////////////////////////////////////////////////
34 //////////////////////////////////////////////////////////////////////
35 //////////////////////////////////////////////////////////////////////
36
37
38 //========================================================================
39 /// Unpin all internal pressure dofs.
40 //========================================================================
41 template<unsigned DIM>
43 {
44 unsigned n_pres = this->npres_nst();
45 // loop over pressure dofs
46 for (unsigned l = 0; l < n_pres; l++)
47 {
48 // unpin internal pressure
49 this->internal_data_pt(P_nst_internal_index)->unpin(l);
50 }
51 }
52
53
54 //=========================================================================
55 /// Add to the set \c paired_load_data pairs containing
56 /// - the pointer to a Data object
57 /// and
58 /// - the index of the value in that Data object
59 /// .
60 /// for all values (pressures, velocities) that affect the
61 /// load computed in the \c get_load(...) function.
62 //=========================================================================
63 template<unsigned DIM>
65 std::set<std::pair<Data*, unsigned>>& paired_load_data)
66 {
67 // Find the index at which the velocity is stored
68 unsigned u_index[DIM];
69 for (unsigned i = 0; i < DIM; i++)
70 {
71 u_index[i] = this->u_index_nst(i);
72 }
73
74 // Loop over the nodes
75 unsigned n_node = this->nnode();
76 for (unsigned n = 0; n < n_node; n++)
77 {
78 // Loop over the velocity components and add pointer to their data
79 // and indices to the vectors
80 for (unsigned i = 0; i < DIM; i++)
81 {
82 paired_load_data.insert(std::make_pair(this->node_pt(n), u_index[i]));
83 }
84 }
85
86 // Identify the pressure data
87 identify_pressure_data(paired_load_data);
88 }
89
90
91 //=========================================================================
92 /// Add to the set \c paired_pressue_data pairs containing
93 /// - the pointer to a Data object
94 /// and
95 /// - the index of the value in that Data object
96 /// .
97 /// for all pressures values that affect the
98 /// load computed in the \c get_load(...) function.
99 //=========================================================================
100 template<unsigned DIM>
102 std::set<std::pair<Data*, unsigned>>& paired_pressure_data)
103 {
104 // Loop over the internal data
105 unsigned n_internal = this->ninternal_data();
106 for (unsigned l = 0; l < n_internal; l++)
107 {
108 unsigned nval = this->internal_data_pt(l)->nvalue();
109 // Add internal data
110 for (unsigned j = 0; j < nval; j++)
111 {
113 std::make_pair(this->internal_data_pt(l), j));
114 }
115 }
116 }
117
118
119 ///////////////////////////////////////////////////////////////////////////
120 ///////////////////////////////////////////////////////////////////////////
121 ///////////////////////////////////////////////////////////////////////////
122
123 // 2D Taylor--Hood
124
125 // Set the data for the number of Variables at each node
126 template<>
127 const unsigned TTaylorHoodElement<2>::Initial_Nvalue[6] = {3, 3, 3, 2, 2, 2};
128
129 // Set the data for the pressure conversion array
130 template<>
131 const unsigned TTaylorHoodElement<2>::Pconv[3] = {0, 1, 2};
132
133 // 3D Taylor--Hood
134 // Set the data for the number of Variables at each node
135 template<>
137 4, 4, 4, 4, 3, 3, 3, 3, 3, 3};
138
139 // Set the data for the pressure conversion array
140 template<>
141 const unsigned TTaylorHoodElement<3>::Pconv[4] = {0, 1, 2, 3};
142
143
144 //========================================================================
145 /// Unpin all pressure dofs, incl the mid-face/side ones where
146 /// they have been allocated (e.g. in the refineable version of this
147 /// element).
148 //========================================================================
149 template<unsigned DIM>
151 {
152 // Find the index at which the pressure is stored
153 unsigned p_index = static_cast<unsigned>(this->p_nodal_index_nst());
154
155 unsigned n_node = this->nnode();
156 // loop over nodes
157 for (unsigned l = 0; l < n_node; l++)
158 {
159 if (this->node_pt(l)->nvalue() > p_index)
160 {
161 // unpin pressure dof
162 this->node_pt(l)->unpin(p_index);
163 }
164 }
165 }
166
167 //========================================================================
168 /// Pin all nodal pressure dofs, incl the mid-face/side ones where
169 /// they have been allocated (e.g. in the refineable version of this
170 /// element).
171 //========================================================================
172 template<unsigned DIM>
174 {
175 // Find the index at which the pressure is stored
176 unsigned p_index = static_cast<unsigned>(this->p_nodal_index_nst());
177
178 // Loop over all nodes and pin pressure
179 unsigned n_node = this->nnode();
180 for (unsigned n = 0; n < n_node; n++)
181 {
182 if (this->node_pt(n)->nvalue() > p_index)
183 {
184 this->node_pt(n)->pin(p_index);
185 }
186 }
187 }
188
189 //========================================================================
190 /// Unpin the proper nodal pressure dofs which are not hanging.
191 //========================================================================
192 template<unsigned DIM>
194 {
195 // Find the index at which the pressure is stored
196 unsigned p_index = static_cast<unsigned>(this->p_nodal_index_nst());
197
198 // Loop over all pressure nodes and unpin if they're not hanging
199 unsigned n_pres = npres_nst();
200 for (unsigned l = 0; l < n_pres; l++)
201 {
202 Node* nod_pt = this->node_pt(Pconv[l]);
203 if (!nod_pt->is_hanging(p_index))
204 {
205 nod_pt->unpin(p_index);
206 }
207 }
208 }
209
210
211 //=========================================================================
212 /// Add to the set \c paired_load_data pairs containing
213 /// - the pointer to a Data object
214 /// and
215 /// - the index of the value in that Data object
216 /// .
217 /// for all values (pressures, velocities) that affect the
218 /// load computed in the \c get_load(...) function.
219 //=========================================================================
220 template<unsigned DIM>
222 std::set<std::pair<Data*, unsigned>>& paired_load_data)
223 {
224 // Find the index at which the velocity is stored
225 unsigned u_index[DIM];
226 for (unsigned i = 0; i < DIM; i++)
227 {
228 u_index[i] = this->u_index_nst(i);
229 }
230
231 // Loop over the nodes
232 unsigned n_node = this->nnode();
233 for (unsigned n = 0; n < n_node; n++)
234 {
235 // Loop over the velocity components and add pointer to their data
236 // and indices to the vectors
237 for (unsigned i = 0; i < DIM; i++)
238 {
239 paired_load_data.insert(std::make_pair(this->node_pt(n), u_index[i]));
240 }
241 }
242
243 // Add the pressure data
244 identify_pressure_data(paired_load_data);
245 }
246
247 //=========================================================================
248 /// Add to the set \c paired_load_data pairs containing
249 /// - the pointer to a Data object
250 /// and
251 /// - the index of the value in that Data object
252 /// .
253 /// for all values (pressures, velocities) that affect the
254 /// load computed in the \c get_load(...) function.
255 //=========================================================================
256 template<unsigned DIM>
258 std::set<std::pair<Data*, unsigned>>& paired_load_data)
259 {
260 // Find the index at which the pressure is stored
261 unsigned p_index = static_cast<unsigned>(this->p_nodal_index_nst());
262
263 // Loop over the pressure data
264 unsigned n_pres = npres_nst();
265 for (unsigned l = 0; l < n_pres; l++)
266 {
267 // The DIMth entry in each nodal data is the pressure, which
268 // affects the traction
269 paired_load_data.insert(std::make_pair(this->node_pt(Pconv[l]), p_index));
270 }
271 }
272
273 //====================================================================
274 /// / Force build of templates
275 //====================================================================
276 template class TCrouzeixRaviartElement<2>;
277 template class TTaylorHoodElement<2>;
278
279 template class TCrouzeixRaviartElement<3>;
280 template class TTaylorHoodElement<3>;
281
282} // namespace oomph
cstr elem_len * i
Definition cfortran.h:603
void pin(const unsigned &i)
Pin the i-th stored variable.
Definition nodes.h:385
void unpin(const unsigned &i)
Unpin the i-th stored variable.
Definition nodes.h:391
unsigned nvalue() const
Return number of values stored in data object (incl pinned ones).
Definition nodes.h:483
unsigned nnode() const
Return the number of nodes.
Definition elements.h:2214
Node *& node_pt(const unsigned &n)
Return a pointer to the local node n.
Definition elements.h:2179
Data *& internal_data_pt(const unsigned &i)
Return a pointer to i-th internal data object.
Definition elements.h:605
unsigned ninternal_data() const
Return the number of internal data objects.
Definition elements.h:810
Nodes are derived from Data, but, in addition, have a definite (Eulerian) position in a space of a gi...
Definition nodes.h:906
TAdvectionDiffusionReactionElement<NREAGENT,DIM,NNODE_1D> elements are isoparametric triangular DIM-d...
TAdvectionDiffusionReactionElement()
Constructor: Call constructors for TElement and AdvectionDiffusionReaction equations.
void identify_load_data(std::set< std::pair< Data *, unsigned > > &paired_load_data)
Add to the set paired_load_data pairs of pointers to data objects and unsignedegers that index the va...
void identify_pressure_data(std::set< std::pair< Data *, unsigned > > &paired_pressure_data)
Add to the set paired_pressure_data pairs containing.
void unpin_all_internal_pressure_dofs()
Unpin all internal pressure dofs.
Taylor–Hood elements are Navier–Stokes elements with quadratic interpolation for velocities and posit...
void pin_all_nodal_pressure_dofs()
Pin all nodal pressure dofs.
void unpin_proper_nodal_pressure_dofs()
Unpin the proper nodal pressure dofs.
void unpin_all_nodal_pressure_dofs()
Unpin all pressure dofs.
void identify_pressure_data(std::set< std::pair< Data *, unsigned > > &paired_pressure_data)
Add to the set paired_pressure_data pairs containing.
void identify_load_data(std::set< std::pair< Data *, unsigned > > &paired_load_data)
Add to the set paired_load_data pairs containing.
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).