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