generalised_newtonian_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-2025 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>
42 void GeneralisedNewtonianTCrouzeixRaviartElement<
43 DIM>::unpin_all_internal_pressure_dofs()
44 {
45 unsigned n_pres = this->npres_nst();
46 // loop over pressure dofs
47 for (unsigned l = 0; l < n_pres; l++)
48 {
49 // unpin internal pressure
50 this->internal_data_pt(P_nst_internal_index)->unpin(l);
51 }
52 }
53
54
55 //=========================================================================
56 /// Add to the set \c paired_load_data pairs containing
57 /// - the pointer to a Data object
58 /// and
59 /// - the index of the value in that Data object
60 /// .
61 /// for all values (pressures, velocities) that affect the
62 /// load computed in the \c get_load(...) function.
63 //=========================================================================
64 template<unsigned DIM>
66 std::set<std::pair<Data*, unsigned>>& paired_load_data)
67 {
68 // Find the index at which the velocity is stored
69 unsigned u_index[DIM];
70 for (unsigned i = 0; i < DIM; i++)
71 {
72 u_index[i] = this->u_index_nst(i);
73 }
74
75 // Loop over the nodes
76 unsigned n_node = this->nnode();
77 for (unsigned n = 0; n < n_node; n++)
78 {
79 // Loop over the velocity components and add pointer to their data
80 // and indices to the vectors
81 for (unsigned i = 0; i < DIM; i++)
82 {
83 paired_load_data.insert(std::make_pair(this->node_pt(n), u_index[i]));
84 }
85 }
86
87 // Identify the pressure data
88 identify_pressure_data(paired_load_data);
89 }
90
91
92 //=========================================================================
93 /// Add to the set \c paired_pressue_data pairs containing
94 /// - the pointer to a Data object
95 /// and
96 /// - the index of the value in that Data object
97 /// .
98 /// for all pressures values that affect the
99 /// load computed in the \c get_load(...) function.
100 //=========================================================================
101 template<unsigned DIM>
103 std::set<std::pair<Data*, unsigned>>& paired_pressure_data)
104 {
105 // Loop over the internal data
106 unsigned n_internal = this->ninternal_data();
107 for (unsigned l = 0; l < n_internal; l++)
108 {
109 unsigned nval = this->internal_data_pt(l)->nvalue();
110 // Add internal data
111 for (unsigned j = 0; j < nval; j++)
112 {
114 std::make_pair(this->internal_data_pt(l), j));
115 }
116 }
117 }
118
119
120 ///////////////////////////////////////////////////////////////////////////
121 ///////////////////////////////////////////////////////////////////////////
122 ///////////////////////////////////////////////////////////////////////////
123
124 // 2D Taylor--Hood
125
126 // Set the data for the number of Variables at each node
127 template<>
129 {3, 3, 3, 2, 2, 2};
130
131 // Set the data for the pressure conversion array
132 template<>
134 0, 1, 2};
135
136 // 3D Taylor--Hood
137 // Set the data for the number of Variables at each node
138 template<>
140 {4, 4, 4, 4, 3, 3, 3, 3, 3, 3};
141
142 // Set the data for the pressure conversion array
143 template<>
145 0, 1, 2, 3};
146
147
148 //========================================================================
149 /// Unpin all pressure dofs, incl the mid-face/side ones where
150 /// they have been allocated (e.g. in the refineable version of this
151 /// element).
152 //========================================================================
153 template<unsigned DIM>
155 DIM>::unpin_all_nodal_pressure_dofs()
156 {
157 unsigned n_node = this->nnode();
158 // loop over nodes
159 for (unsigned l = 0; l < n_node; l++)
160 {
161 if (this->node_pt(l)->nvalue() == DIM + 1)
162 {
163 // unpin pressure dof
164 this->node_pt(l)->unpin(DIM);
165 }
166 }
167 }
168
169 //========================================================================
170 /// Pin all nodal pressure dofs, incl the mid-face/side ones where
171 /// they have been allocated (e.g. in the refineable version of this
172 /// element).
173 //========================================================================
174 template<unsigned DIM>
176 DIM>::pin_all_nodal_pressure_dofs()
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() == DIM + 1)
183 {
184 this->node_pt(n)->pin(DIM);
185 }
186 }
187 }
188
189 //========================================================================
190 /// Unpin the proper nodal pressure dofs which are not hanging.
191 //========================================================================
192 template<unsigned DIM>
194 DIM>::unpin_proper_nodal_pressure_dofs()
195 {
196 // Loop over all pressure nodes and unpin if they're not hanging
197 unsigned n_pres = npres_nst();
198 for (unsigned l = 0; l < n_pres; l++)
199 {
200 Node* nod_pt = this->node_pt(Pconv[l]);
201 if (!nod_pt->is_hanging(DIM))
202 {
203 nod_pt->unpin(DIM);
204 }
205 }
206 }
207
208
209 //=========================================================================
210 /// Add to the set \c paired_load_data pairs containing
211 /// - the pointer to a Data object
212 /// and
213 /// - the index of the value in that Data object
214 /// .
215 /// for all values (pressures, velocities) that affect the
216 /// load computed in the \c get_load(...) function.
217 //=========================================================================
218 template<unsigned DIM>
220 std::set<std::pair<Data*, unsigned>>& paired_load_data)
221 {
222 // Loop over the nodes
223 unsigned n_node = this->nnode();
224 for (unsigned n = 0; n < n_node; n++)
225 {
226 // Loop over the velocity components and add pointer to their data
227 // and indices to the vectors
228 for (unsigned i = 0; i < DIM; i++)
229 {
230 paired_load_data.insert(std::make_pair(this->node_pt(n), i));
231 }
232 }
233
234 // Add the pressure data
235 identify_pressure_data(paired_load_data);
236 }
237
238 //=========================================================================
239 /// Add to the set \c paired_load_data pairs containing
240 /// - the pointer to a Data object
241 /// and
242 /// - the index of the value in that Data object
243 /// .
244 /// for all values (pressures, velocities) that affect the
245 /// load computed in the \c get_load(...) function.
246 //=========================================================================
247 template<unsigned DIM>
249 std::set<std::pair<Data*, unsigned>>& paired_load_data)
250 {
251 // Loop over the pressure data
252 unsigned n_pres = npres_nst();
253 for (unsigned l = 0; l < n_pres; l++)
254 {
255 // The DIMth entry in each nodal data is the pressure, which
256 // affects the traction
257 paired_load_data.insert(std::make_pair(this->node_pt(Pconv[l]), DIM));
258 }
259 }
260
261 //====================================================================
262 /// / Force build of templates
263 //====================================================================
266
269
270} // namespace oomph
cstr elem_len * i
Definition cfortran.h:603
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
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.
Taylor–Hood elements are Navier–Stokes elements with quadratic interpolation for velocities and posit...
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.
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.
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).