one_d_mesh.h
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_MESH_HEADER
27#define OOMPH_ONE_D_MESH_HEADER
28
29// Config header
30#ifdef HAVE_CONFIG_H
31#include <oomph-lib-config.h>
32#endif
33
34// oomph-lib headers
35#include "generic/line_mesh.h"
36#include "generic/refineable_line_mesh.h"
37
38namespace oomph
39{
40 //====================================================================
41 /// 1D mesh consisting of N one-dimensional elements from the
42 /// QElement family.
43 /// \f[ x \in [Xmin,Xmax] \f]
44 /// The mesh has two boundaries:
45 /// - Boundary 0 is at \f$x=Xmin\f$.
46 /// - Boundary 1 is at \f$x=Xmax\f$.
47 /// .
48 /// There is one node on each of these boundaries.
49 //====================================================================
50 template<class ELEMENT>
51 class OneDMesh : public virtual LineMeshBase
52 {
53 public:
54 /// Constructor: Pass number of elements, n_element, length of
55 /// domain, length, and pointer to timestepper (defaults to a Steady
56 /// timestepper so we don't need to specify one in problems without
57 /// time-dependence).
58 OneDMesh(const unsigned& n_element,
59 const double& length,
60 TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
61 : Xmin(0.0), Xmax(length), N(n_element)
62 {
63 check_1d();
64
66 }
67
68 /// Constructor: Pass number of elements, n_element, minimum
69 /// coordinate, xmin, maximum coordinate, xmax, and a pointer to a
70 /// timestepper.
71 OneDMesh(const unsigned& n_element,
72 const double& xmin,
73 const double& xmax,
74 TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
76 {
77 check_1d();
78
80 }
81
82 protected:
83 /// Mesh can only be built with 1D elements (but can be either T or Q so
84 /// can't use the normal assert_geometric_element function.
85 void check_1d() const
86 {
87#ifdef PARANOID
89 if (el_pt->dim() != 1)
90 {
91 std::string err = "OneDMesh is only for 1D elements";
92 throw OomphLibError(
94 }
95 delete el_pt;
96 el_pt = 0;
97#endif
98 }
99
100 /// Minimum coordinate
101 double Xmin;
102
103 /// Maximum coordinate
104 double Xmax;
105
106 /// Length of the domain
107 double Length;
108
109 /// Number of elements
110 unsigned N;
111
112 /// Generic mesh constuction routine, called by all constructors
113 void build_mesh(TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper);
114 };
115
116 //====================================================================
117 /// Refineable version of the OneDMesh
118 //====================================================================
119 template<class ELEMENT>
120 class RefineableOneDMesh : public virtual OneDMesh<ELEMENT>,
121 public RefineableLineMesh<ELEMENT>
122 {
123 public:
124 /// Constructor: Pass number of elements, n_element, length of
125 /// domain, length, and pointer to timestepper (defaults to Steady)
127 const unsigned& n_element,
128 const double& length,
129 TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
131 {
132 // Nodal positions etc. were created in constructor for OneDMesh<...>
133 // so only need to set up binary tree forest
135 }
136
137 /// Constructor that allows the specification of minimum and
138 /// maximum values of x coordinates. Also pass pointer to timestepper
139 /// (defaults to Steady).
141 const unsigned& n_element,
142 const double& xmin,
143 const double& xmax,
144 TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
146 {
147 // Nodal positions etc. were created in constructor for OneDMesh<...>
148 // so only need to set up binary tree forest
150 }
151 };
152
153} // namespace oomph
154
155#include "one_d_mesh.template.cc"
156#endif
Collapsible channel mesh with MacroElement-based node update. The collapsible segment is represented ...
1D mesh consisting of N one-dimensional elements from the QElement family.
Definition one_d_mesh.h:52
OneDMesh(const unsigned &n_element, const double &xmin, const double &xmax, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Constructor: Pass number of elements, n_element, minimum coordinate, xmin, maximum coordinate,...
Definition one_d_mesh.h:71
void build_mesh(TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Generic mesh constuction routine, called by all constructors.
unsigned N
Number of elements.
Definition one_d_mesh.h:110
void check_1d() const
Mesh can only be built with 1D elements (but can be either T or Q so can't use the normal assert_geom...
Definition one_d_mesh.h:85
double Length
Length of the domain.
Definition one_d_mesh.h:107
double Xmin
Minimum coordinate.
Definition one_d_mesh.h:101
double Xmax
Maximum coordinate.
Definition one_d_mesh.h:104
OneDMesh(const unsigned &n_element, const double &length, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Constructor: Pass number of elements, n_element, length of domain, length, and pointer to timestepper...
Definition one_d_mesh.h:58
Refineable version of the OneDMesh.
Definition one_d_mesh.h:122
RefineableOneDMesh(const unsigned &n_element, const double &xmin, const double &xmax, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Constructor that allows the specification of minimum and maximum values of x coordinates....
Definition one_d_mesh.h:140
RefineableOneDMesh(const unsigned &n_element, const double &length, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Constructor: Pass number of elements, n_element, length of domain, length, and pointer to timestepper...
Definition one_d_mesh.h:126