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// 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#ifndef OOMPH_ONE_D_LAGRANGIAN_MESH_TEMPLATE_HEADER
27#define OOMPH_ONE_D_LAGRANGIAN_MESH_TEMPLATE_HEADER
28
29#ifndef OOMPH_ONE_D_LAGRANGIAN_MESH_HEADER
30#error __FILE__ should only be included from one_d_lagrangian_mesh.h.
31#endif // OOMPH_ONE_D_LAGRANGIAN_MESH_HEADER
32
33// The templated member functions of OneDLagrangianMesh
34
35// Include the templated member functions of the OneDMesh
36#include "one_d_mesh.h"
37
38namespace oomph
39{
40 //=======================================================================
41 /// Constructor for 1D mesh:
42 /// n_element : number of elements
43 /// length : length of domain
44 /// undef_eulerian_posn_pt: pointer to geom object that describes
45 /// the initial Eulerian position of the mesh.
46 /// time_stepper_pt : timestepper
47 //=======================================================================
48 template<class ELEMENT>
50 const unsigned& n_element,
51 const double& length,
53 TimeStepper* time_stepper_pt)
54 : OneDMesh<ELEMENT>(n_element, length, time_stepper_pt),
55 Undef_eulerian_posn_pt(undef_eulerian_posn_pt)
56 {
57 // Mesh can only be built with 1D Qelements.
58 MeshChecker::assert_geometric_element<QElementGeometricBase, ELEMENT>(1);
59
60 // Now set the lagrangian coordinates of the nodes
62
63 // Set the default slopes
65
66 // Now set up the Eulerian position of the nodal points
68 }
69
70 //==================================================
71 /// Constructor for 1D mesh:
72 /// n_element : number of elements
73 /// xmin : minimum coordinate value (LH end)
74 /// xmax : maximum coordinate value (RH end)
75 /// undef_eulerian_posn_pt: pointer to geom object that describes
76 /// the initial Eulerian position of the mesh.
77 /// time_stepper_pt : timestepper
78 //==================================================
79 template<class ELEMENT>
81 const unsigned& n_element,
82 const double& xmin,
83 const double& xmax,
85 TimeStepper* time_stepper_pt)
86 : OneDMesh<ELEMENT>(n_element, xmin, xmax, time_stepper_pt),
87 Undef_eulerian_posn_pt(undef_eulerian_posn_pt)
88 {
89 // Mesh can only be built with 1D Qelements.
90 MeshChecker::assert_geometric_element<QElementGeometricBase, ELEMENT>(1);
91
92 // Now set the lagrangian coordinates of the nodes
94
95 // Set the default slopes
97
98 // Now set up the Eulerian position of the nodal points
100 }
101
102 //=====================================================================
103 /// Set the default (initial) gradients within each element, which
104 /// are merely the distances between the nodes, scaled by 0.5 because
105 /// the elements have length 2 in local coordinates.
106 /// N.B. This only works for QHermiteElements at the moment
107 //=====================================================================
108 template<class ELEMENT>
110 {
111 // Find cast pointer to first element
112 ELEMENT* cast_element_pt = dynamic_cast<ELEMENT*>(finite_element_pt(0));
113 // Do we need to worry about the slopes
114 // Read out number of position dofs
115 unsigned n_lagrangian_type = cast_element_pt->nnodal_lagrangian_type();
116
117 // If this is greater than 1 set the slopes, which are the distances between
118 // nodes
119 if (n_lagrangian_type > 1)
120 {
121 // Read out the number of linear points in the element
122 unsigned n_p = cast_element_pt->nnode_1d();
123 // Set the values of the distance between each node
124 double xstep =
126 // Loop over the nodes and set the slopes
127 unsigned long n_node = nnode();
128 for (unsigned long n = 0; n < n_node; n++)
129 {
130 node_pt(n)->xi_gen(1, 0) = 0.5 * xstep;
131 }
132 }
133 }
134
135 //======================================================================
136 /// Set the initial (2D Eulerian!) positions of the nodes
137 //======================================================================
138 template<class ELEMENT>
140 {
141 // Lagrangian coordinate
142 Vector<double> xi(1);
143
144 // Find the number Eulerian coordinates, assume same for all nodes
145 unsigned n_dim = node_pt(0)->ndim();
146
147 // Find cast pointer to first element
148 ELEMENT* cast_element_pt = dynamic_cast<ELEMENT*>(finite_element_pt(0));
149
150 // Do we need to worry about the slopes
151 // Read out number of position dofs
152 unsigned n_lagrangian_type = cast_element_pt->nnodal_lagrangian_type();
153
154 // Setup position Vector and derivatives (they *should* dimension themselves
155 // in call to position() etc)
157 // Derivative wrt Lagrangian coordinate
159 // Second derivative wrt Lagrangian coordinate
161
162 // Find out how many nodes there are
163 unsigned long n_node = nnode();
164
165 // Loop over all the nodes
166 for (unsigned long n = 0; n < n_node; n++)
167 {
168 // Lagrangian coordinate of node
169 xi[0] = node_pt(n)->xi(0);
170
171 // Get the undeformed midplane
172 Undef_eulerian_posn_pt->d2position(xi, R, a, dadxi);
173
174 // Loop over coordinate directions
175 for (unsigned i = 0; i < n_dim; i++)
176 {
177 // Set the position
178 node_pt(n)->x_gen(0, i) = R[i];
179
180 if (n_lagrangian_type > 1)
181 {
182 // Set the derivative wrt Lagrangian coordinates
183 // Note that we need to scale by the length of each element here!!
184 // and the 0.5 comes from the fact that our reference element has
185 // length 2.0
186 node_pt(n)->x_gen(1, i) =
187 0.5 * a(0, i) *
189 }
190 }
191 }
192 }
193
194} // namespace oomph
195#endif
cstr elem_len * i
Definition cfortran.h:603
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
virtual unsigned nnode_1d() const
Return the number of nodes along one edge of the element Default is to return zero — must be overload...
Definition elements.h:2222
A geometric object is an object that provides a parametrised description of its shape via the functio...
unsigned ndim() const
Return (Eulerian) spatial dimension of the node.
Definition nodes.h:1054
double & x_gen(const unsigned &k, const unsigned &i)
Reference to the generalised position x(k,i). ‘Type’: k; Coordinate direction: i.
Definition nodes.h:1126
void assign_undeformed_positions()
Assign the undeformed Eulerian positions to the nodes.
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...
void assign_default_element_gradients()
Set the default gradients of the elements.
1D mesh consisting of N one-dimensional elements from the QElement family.
Definition one_d_mesh.h:52
void set_lagrangian_nodal_coordinates()
Make the current configuration the undeformed one by setting the nodal Lagrangian coordinates to thei...
Definition mesh.cc:9564
TAdvectionDiffusionReactionElement<NREAGENT,DIM,NNODE_1D> elements are isoparametric triangular DIM-d...
TAdvectionDiffusionReactionElement()
Constructor: Call constructors for TElement and AdvectionDiffusionReaction equations.
Base class for time-stepping schemes. Timestepper provides an approximation of the temporal derivativ...
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).