displacement_based_foeppl_von_karman_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 FoepplvonKarman displacement elements
31 
33 
34 #include <iostream>
35 
36 namespace oomph
37 {
38 
39  // Foeppl von Karman displacement equations static data
40 
41  /// Default value for Poisson's ratio
43 
44  /// Default value physical constants
45  double DisplacementBasedFoepplvonKarmanEquations::
46  Default_Physical_Constant_Value = 0.0;
47 
48 
49 //======================================================================
50 /// Self-test: Return 0 for OK
51 //======================================================================
53 {
54 
55  bool passed=true;
56 
57  // Check lower-level stuff
58  if (FiniteElement::self_test()!=0)
59  {
60  passed=false;
61  }
62 
63  // Return verdict
64  if (passed)
65  {
66  return 0;
67  }
68  else
69  {
70  return 1;
71  }
72 
73 }
74 
75 //======================================================================
76 /// Output function:
77 ///
78 /// x,y,w
79 ///
80 /// nplot points in each coordinate direction
81 //======================================================================
83  const unsigned &nplot)
84 {
85 
86  // Vector of local coordinates
87  Vector<double> s(2);
88  // Vector of Eulerian coordinates
89  Vector<double> x(2);
90 
91  // Sigma_{\alpha \beta}
92  DenseMatrix<double> sigma(2,2);
93 
94  // E_{\alpha \beta}
95  DenseMatrix<double> strain(2,2);
96 
97  // Tecplot header info
98  outfile << tecplot_zone_string(nplot);
99 
100  // Loop over plot points
101  unsigned num_plot_points=nplot_points(nplot);
102  for (unsigned iplot=0;iplot<num_plot_points;iplot++)
103  {
104 
105  // Get local coordinates of plot point
106  get_s_plot(iplot,nplot,s);
107 
108  // Get the Eulerian coordinates
109  for(unsigned i=0;i<2;i++)
110  {
111  x[i] = interpolated_x(s,i);
112  outfile << x[i] << " ";
113  }
114 
115  outfile << interpolated_w_fvk(s,0) << " "; // w
116  outfile << interpolated_w_fvk(s,1) << " "; // Laplacian W
117  outfile << interpolated_w_fvk(s,2) << " "; // Ux
118  outfile << interpolated_w_fvk(s,3) << " "; // Uy
119  // outfile << std::endl; // New line
120 
121  // Get the stresses at local coordinate s
122  this->get_stress_and_strain_for_output(s,sigma,strain);
123 
124  // Output stress
125  outfile << sigma(0,0) << " "; // sigma_xx
126  outfile << sigma(0,1) << " "; // sigma_xy
127  outfile << sigma(1,1) << " "; // sigma_yy
128 
129  // Output strain
130  outfile << strain(0,0) << " "; // E_xx
131  outfile << strain(0,1) << " "; // E_xy
132  outfile << strain(1,1) << " "; // E_yy
133  outfile << std::endl;
134 
135  }
136 
137  // Write tecplot footer (e.g. FE connectivity lists)
138  write_tecplot_zone_footer(outfile,nplot);
139 
140 }
141 
142 
143 //======================================================================
144 /// C-style output function:
145 ///
146 /// x,y,w
147 ///
148 /// nplot points in each coordinate direction
149 //======================================================================
151  const unsigned &nplot)
152 {
153  //Vector of local coordinates
154  Vector<double> s(2);
155 
156  // Tecplot header info
157  fprintf(file_pt,"%s",tecplot_zone_string(nplot).c_str());
158 
159  // Loop over plot points
160  unsigned num_plot_points=nplot_points(nplot);
161  for (unsigned iplot=0;iplot<num_plot_points;iplot++)
162  {
163  // Get local coordinates of plot point
164  get_s_plot(iplot,nplot,s);
165 
166  for(unsigned i=0;i<2;i++)
167  {
168  fprintf(file_pt,"%g ",interpolated_x(s,i));
169  }
170  fprintf(file_pt,"%g \n",interpolated_w_fvk(s));
171  }
172 
173  // Write tecplot footer (e.g. FE connectivity lists)
174  write_tecplot_zone_footer(file_pt,nplot);
175 }
176 
177 
178 
179 //======================================================================
180  /// Output exact solution
181  ///
182  /// Solution is provided via function pointer.
183  /// Plot at a given number of plot points.
184  ///
185  /// x,y,w_exact
186 //======================================================================
188  const unsigned &nplot,
190  {
191  //Vector of local coordinates
192  Vector<double> s(2);
193 
194  // Vector for coordintes
195  Vector<double> x(2);
196 
197  // Tecplot header info
198  outfile << tecplot_zone_string(nplot);
199 
200  // Exact solution Vector (here a scalar)
201  //Vector<double> exact_soln(1);
202  Vector<double> exact_soln(3);
203 
204  // Loop over plot points
205  unsigned num_plot_points=nplot_points(nplot);
206  for (unsigned iplot=0;iplot<num_plot_points;iplot++)
207  {
208 
209  // Get local coordinates of plot point
210  get_s_plot(iplot,nplot,s);
211 
212  // Get x position as Vector
213  interpolated_x(s,x);
214 
215  // Get exact solution at this point
216  (*exact_soln_pt)(x,exact_soln);
217 
218  //Output x,y,w_exact
219  for(unsigned i=0;i<2;i++)
220  {
221  outfile << x[i] << " ";
222  }
223  outfile << exact_soln[0] << " ";
224  outfile << exact_soln[1] << " ";
225  outfile << exact_soln[2] << std::endl;
226  }
227 
228  // Write tecplot footer (e.g. FE connectivity lists)
229  write_tecplot_zone_footer(outfile,nplot);
230  }
231 
232 
233 
234 
235 //======================================================================
236 /// Validate against exact solution
237 ///
238 /// Solution is provided via function pointer.
239 /// Plot error at a given number of plot points.
240 ///
241 //======================================================================
244  double& error, double& norm)
245  {
246  // Initialise
247  error=0.0;
248  norm=0.0;
249 
250  //Vector of local coordinates
251  Vector<double> s(2);
252 
253  // Vector for coordintes
254  Vector<double> x(2);
255 
256  //Find out how many nodes there are in the element
257  unsigned n_node = nnode();
258 
259  Shape psi(n_node);
260 
261  //Set the value of n_intpt
262  unsigned n_intpt = integral_pt()->nweight();
263 
264  // Tecplot
265  outfile << "ZONE" << std::endl;
266 
267  // Exact solution vector
268  Vector<double> exact_soln(3);
269 
270  //Loop over the integration points
271  for(unsigned ipt=0;ipt<n_intpt;ipt++)
272  {
273 
274  //Assign values of s
275  for(unsigned i=0;i<2;i++)
276  {
277  s[i] = integral_pt()->knot(ipt,i);
278  }
279 
280  //Get the integral weight
281  double w = integral_pt()->weight(ipt);
282 
283  // Get jacobian of mapping
284  double J=J_eulerian(s);
285 
286  //Premultiply the weights and the Jacobian
287  double W = w*J;
288 
289  // Get x position as Vector
290  interpolated_x(s,x);
291 
292  // Get FE function value
293  double w_fe=interpolated_w_fvk(s);
294 
295  // Get exact solution at this point
296  (*exact_soln_pt)(x,exact_soln);
297 
298  //Output x,y,error
299  for(unsigned i=0;i<2;i++)
300  {
301  outfile << x[i] << " ";
302  }
303  outfile << exact_soln[0] << " " << exact_soln[0]-w_fe << std::endl;
304 
305  // Add to error and norm
306  norm+=exact_soln[0]*exact_soln[0]*W;
307  error+=(exact_soln[0]-w_fe)*(exact_soln[0]-w_fe)*W;
308 
309  }
310 
311  }
312 
313 } // namespace oomph
virtual std::string tecplot_zone_string(const unsigned &nplot) const
Return string for tecplot zone header (when plotting nplot points in each "coordinate direction") ...
Definition: elements.h:2990
void output(std::ostream &outfile)
Output with default number of plot points.
static double Default_Nu_Value
Default value for Poisson&#39;s ratio.
virtual void get_s_plot(const unsigned &i, const unsigned &nplot, Vector< double > &s, const bool &shifted_to_interior=false) const
Get cector of local coordinates of plot point i (when plotting nplot points in each "coordinate direc...
Definition: elements.h:2978
cstr elem_len * i
Definition: cfortran.h:607
virtual unsigned self_test()
Self-test: Check inversion of element & do self-test for GeneralisedElement. Return 0 if OK...
Definition: elements.cc:4333
virtual double weight(const unsigned &i) const =0
Return weight of i-th integration point.
virtual unsigned nplot_points(const unsigned &nplot) const
Return total number of plot points (when plotting nplot points in each "coordinate direction") ...
Definition: elements.h:3017
void(* SteadyExactSolutionFctPt)(const Vector< double > &, Vector< double > &)
Function pointer for function that computes vector-valued steady "exact solution" as ...
Definition: elements.h:1723
virtual double interpolated_x(const Vector< double > &s, const unsigned &i) const
Return FE interpolated coordinate x[i] at local coordinate s.
Definition: elements.cc:3881
Integral *const & integral_pt() const
Return the pointer to the integration scheme (const version)
Definition: elements.h:1908
static char t char * s
Definition: cfortran.h:572
virtual double knot(const unsigned &i, const unsigned &j) const =0
Return local coordinate s[j] of i-th integration point.
virtual void write_tecplot_zone_footer(std::ostream &outfile, const unsigned &nplot) const
Add tecplot zone "footer" to output stream (when plotting nplot points in each "coordinate direction"...
Definition: elements.h:3003
double interpolated_w_fvk(const Vector< double > &s, unsigned index=0) const
Return FE representation of function value w_fvk(s) at local coordinate s (by default - if index > 0...
void output_fct(std::ostream &outfile, const unsigned &n_plot, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt)
Output exact soln: x,y,w_exact at n_plot^DIM plot points.
virtual unsigned nweight() const =0
Return the number of integration points of the scheme.
unsigned nnode() const
Return the number of nodes.
Definition: elements.h:2146
void get_stress_and_strain_for_output(const Vector< double > &s, DenseMatrix< double > &sigma, DenseMatrix< double > &strain)
virtual double J_eulerian(const Vector< double > &s) const
Return the Jacobian of mapping from local to global coordinates at local position s...
Definition: elements.cc:4022
void compute_error(std::ostream &outfile, FiniteElement::SteadyExactSolutionFctPt exact_soln_pt, double &error, double &norm)
Get error against and norm of exact solution.