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-2022 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 {
112 paired_pressure_data.insert(
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 unsigned n_node = this->nnode();
153 // loop over nodes
154 for (unsigned l = 0; l < n_node; l++)
155 {
156 if (this->node_pt(l)->nvalue() == DIM + 1)
157 {
158 // unpin pressure dof
159 this->node_pt(l)->unpin(DIM);
160 }
161 }
162 }
163
164 //========================================================================
165 /// Pin all nodal pressure dofs, incl the mid-face/side ones where
166 /// they have been allocated (e.g. in the refineable version of this
167 /// element).
168 //========================================================================
169 template<unsigned DIM>
171 {
172 // Loop over all nodes and pin pressure
173 unsigned n_node = this->nnode();
174 for (unsigned n = 0; n < n_node; n++)
175 {
176 if (this->node_pt(n)->nvalue() == DIM + 1)
177 {
178 this->node_pt(n)->pin(DIM);
179 }
180 }
181 }
182
183 //========================================================================
184 /// Unpin the proper nodal pressure dofs which are not hanging.
185 //========================================================================
186 template<unsigned DIM>
188 {
189 // Loop over all pressure nodes and unpin if they're not hanging
190 unsigned n_pres = npres_nst();
191 for (unsigned l = 0; l < n_pres; l++)
192 {
193 Node* nod_pt = this->node_pt(Pconv[l]);
194 if (!nod_pt->is_hanging(DIM))
195 {
196 nod_pt->unpin(DIM);
197 }
198 }
199 }
200
201
202 //=========================================================================
203 /// Add to the set \c paired_load_data pairs containing
204 /// - the pointer to a Data object
205 /// and
206 /// - the index of the value in that Data object
207 /// .
208 /// for all values (pressures, velocities) that affect the
209 /// load computed in the \c get_load(...) function.
210 //=========================================================================
211 template<unsigned DIM>
213 std::set<std::pair<Data*, unsigned>>& paired_load_data)
214 {
215 // Loop over the nodes
216 unsigned n_node = this->nnode();
217 for (unsigned n = 0; n < n_node; n++)
218 {
219 // Loop over the velocity components and add pointer to their data
220 // and indices to the vectors
221 for (unsigned i = 0; i < DIM; i++)
222 {
223 paired_load_data.insert(std::make_pair(this->node_pt(n), i));
224 }
225 }
226
227 // Add the pressure data
228 identify_pressure_data(paired_load_data);
229 }
230
231 //=========================================================================
232 /// Add to the set \c paired_load_data pairs containing
233 /// - the pointer to a Data object
234 /// and
235 /// - the index of the value in that Data object
236 /// .
237 /// for all values (pressures, velocities) that affect the
238 /// load computed in the \c get_load(...) function.
239 //=========================================================================
240 template<unsigned DIM>
242 std::set<std::pair<Data*, unsigned>>& paired_load_data)
243 {
244 // Loop over the pressure data
245 unsigned n_pres = npres_nst();
246 for (unsigned l = 0; l < n_pres; l++)
247 {
248 // The DIMth entry in each nodal data is the pressure, which
249 // affects the traction
250 paired_load_data.insert(std::make_pair(this->node_pt(Pconv[l]), DIM));
251 }
252 }
253
254 //====================================================================
255 /// / Force build of templates
256 //====================================================================
257 template class TCrouzeixRaviartElement<2>;
258 template class TTaylorHoodElement<2>;
259
260 template class TCrouzeixRaviartElement<3>;
261 template class TTaylorHoodElement<3>;
262
263} // namespace oomph
cstr elem_len * i
Definition: cfortran.h:603
void unpin(const unsigned &i)
Unpin the i-th stored variable.
Definition: nodes.h:391
Nodes are derived from Data, but, in addition, have a definite (Eulerian) position in a space of a gi...
Definition: nodes.h:906
bool is_hanging() const
Test whether the node is geometrically hanging.
Definition: nodes.h:1285
///////////////////////////////////////////////////////////////////////////
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.
///////////////////////////////////////////////////////////////////////// ///////////////////////////...
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.
//////////////////////////////////////////////////////////////////// ////////////////////////////////...