one_d_lagrangian_mesh.template.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: 1097 $
7 //LIC//
8 //LIC// $LastChangedDate: 2015-12-17 11:53:17 +0000 (Thu, 17 Dec 2015) $
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 #ifndef OOMPH_ONE_D_LAGRANGIAN_MESH_TEMPLATE_CC
31 #define OOMPH_ONE_D_LAGRANGIAN_MESH_TEMPLATE_CC
32 
33 //The templated member functions of OneDLagrangianMesh
35 
36 //Include the templated member functions of the OneDMesh
37 #include "one_d_mesh.template.cc"
38 
39 
40 
41 namespace oomph
42 {
43 
44 
45 //=======================================================================
46 /// Constructor for 1D mesh:
47 /// n_element : number of elements
48 /// length : length of domain
49 /// undef_eulerian_posn_pt: pointer to geom object that describes
50 /// the initial Eulerian position of the mesh.
51 /// time_stepper_pt : timestepper
52 //=======================================================================
53 template <class ELEMENT>
55 OneDLagrangianMesh(const unsigned &n_element,
56  const double &length,
57  GeomObject* undef_eulerian_posn_pt,
58  TimeStepper* time_stepper_pt) :
59  OneDMesh<ELEMENT>(n_element,length,time_stepper_pt),
60  Undef_eulerian_posn_pt(undef_eulerian_posn_pt)
61 {
62  // Mesh can only be built with 1D Qelements.
63  MeshChecker::assert_geometric_element<QElementGeometricBase,ELEMENT>(1);
64 
65  //Now set the lagrangian coordinates of the nodes
67 
68  //Set the default slopes
70 
71  //Now set up the Eulerian position of the nodal points
73 }
74 
75 //==================================================
76 /// Constructor for 1D mesh:
77 /// n_element : number of elements
78 /// xmin : minimum coordinate value (LH end)
79 /// xmax : maximum coordinate value (RH end)
80 /// undef_eulerian_posn_pt: pointer to geom object that describes
81 /// the initial Eulerian position of the mesh.
82 /// time_stepper_pt : timestepper
83 //==================================================
84 template <class ELEMENT>
86 OneDLagrangianMesh(const unsigned &n_element,
87  const double &xmin,
88  const double &xmax,
89  GeomObject* undef_eulerian_posn_pt,
90  TimeStepper* time_stepper_pt) :
91  OneDMesh<ELEMENT>(n_element,xmin,xmax,time_stepper_pt),
92  Undef_eulerian_posn_pt(undef_eulerian_posn_pt)
93 {
94  // Mesh can only be built with 1D Qelements.
95  MeshChecker::assert_geometric_element<QElementGeometricBase,ELEMENT>(1);
96 
97  //Now set the lagrangian coordinates of the nodes
99 
100  //Set the default slopes
102 
103  //Now set up the Eulerian position of the nodal points
105 
106 }
107 
108 
109 //=====================================================================
110 /// Set the default (initial) gradients within each element, which
111 /// are merely the distances between the nodes, scaled by 0.5 because
112 /// the elements have length 2 in local coordinates.
113 /// N.B. This only works for QHermiteElements at the moment
114 //=====================================================================
115 template<class ELEMENT>
117 {
118  //Find cast pointer to first element
119  ELEMENT* cast_element_pt = dynamic_cast<ELEMENT*>(finite_element_pt(0));
120  //Do we need to worry about the slopes
121  //Read out number of position dofs
122  unsigned n_lagrangian_type = cast_element_pt->nnodal_lagrangian_type();
123 
124  // If this is greater than 1 set the slopes, which are the distances between
125  // nodes
126  if(n_lagrangian_type > 1)
127  {
128  //Read out the number of linear points in the element
129  unsigned n_p = cast_element_pt->nnode_1d();
130  //Set the values of the distance between each node
131  double xstep = OneDMesh<ELEMENT>::Length/
132  double((n_p-1)*OneDMesh<ELEMENT>::N);
133  //Loop over the nodes and set the slopes
134  unsigned long n_node = nnode();
135  for(unsigned long n=0;n<n_node;n++) {node_pt(n)->xi_gen(1,0) = 0.5*xstep;}
136  }
137 }
138 
139 //======================================================================
140 /// Set the initial (2D Eulerian!) positions of the nodes
141 //======================================================================
142 template <class ELEMENT>
144 {
145  // Lagrangian coordinate
146  Vector<double> xi(1);
147 
148  //Find the number Eulerian coordinates, assume same for all nodes
149  unsigned n_dim = node_pt(0)->ndim();
150 
151  //Find cast pointer to first element
152  ELEMENT* cast_element_pt = dynamic_cast<ELEMENT*>(finite_element_pt(0));
153 
154  //Do we need to worry about the slopes
155  //Read out number of position dofs
156  unsigned n_lagrangian_type = cast_element_pt->nnodal_lagrangian_type();
157 
158  // Setup position Vector and derivatives (they *should* dimension themselves
159  // in call to position() etc)
160  Vector<double> R(n_dim);
161  //Derivative wrt Lagrangian coordinate
162  DenseMatrix<double> a(1,n_dim);
163  //Second derivative wrt Lagrangian coordinate
164  RankThreeTensor<double> dadxi(1,1,n_dim);
165 
166  //Find out how many nodes there are
167  unsigned long n_node = nnode();
168 
169  //Loop over all the nodes
170  for(unsigned long n=0;n<n_node;n++)
171  {
172  // Lagrangian coordinate of node
173  xi[0]= node_pt(n)->xi(0);
174 
175  // Get the undeformed midplane
176  Undef_eulerian_posn_pt->d2position(xi,R,a,dadxi);
177 
178  //Loop over coordinate directions
179  for(unsigned i=0;i<n_dim;i++)
180  {
181  //Set the position
182  node_pt(n)->x_gen(0,i) = R[i];
183 
184  if(n_lagrangian_type > 1)
185  {
186  // Set the derivative wrt Lagrangian coordinates
187  // Note that we need to scale by the length of each element here!!
188  // and the 0.5 comes from the fact that our reference element has
189  // length 2.0
190  node_pt(n)->x_gen(1,i) = 0.5*a(0,i)*
192  }
193  }
194  }
195 }
196 
197 
198 }
199 #endif
void assign_undeformed_positions()
Assign the undeformed Eulerian positions to the nodes.
cstr elem_len * i
Definition: cfortran.h:607
OneDLagrangianMesh(const unsigned &n_element, const double &length, GeomObject *undef_eulerian_posn_pt, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Constructor: Pass number of elements, length, pointer to GeomObject that defines the undeformed Euler...
A Rank 3 Tensor class.
Definition: matrices.h:1337
void assign_default_element_gradients()
Set the default gradients of the elements.
Base class for time-stepping schemes. Timestepper provides an approximation of the temporal derivativ...
Definition: timesteppers.h:219
void set_lagrangian_nodal_coordinates()
Make the current configuration the undeformed one by setting the nodal Lagrangian coordinates to thei...
Definition: mesh.cc:9196