one_d_mesh.template.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-2022 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 generated by autoconfig
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 
38 namespace oomph
39 {
40  //====================================================================
49  //====================================================================
50  template<class ELEMENT>
51  class OneDMesh : public virtual LineMeshBase
52  {
53  public:
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 
65  build_mesh(time_stepper_pt);
66  }
67 
71  OneDMesh(const unsigned& n_element,
72  const double& xmin,
73  const double& xmax,
74  TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
75  : Xmin(xmin), Xmax(xmax), N(n_element)
76  {
77  check_1d();
78 
79  build_mesh(time_stepper_pt);
80  }
81 
82  protected:
85  void check_1d() const
86  {
87 #ifdef PARANOID
88  FiniteElement* el_pt = new ELEMENT;
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 
101  double Xmin;
102 
104  double Xmax;
105 
107  double Length;
108 
110  unsigned N;
111 
113  void build_mesh(TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper);
114  };
115 
116 
117  //====================================================================
119  //====================================================================
120  template<class ELEMENT>
121  class RefineableOneDMesh : public virtual OneDMesh<ELEMENT>,
122  public RefineableLineMesh<ELEMENT>
123  {
124  public:
128  const unsigned& n_element,
129  const double& length,
130  TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
131  : OneDMesh<ELEMENT>(n_element, length, time_stepper_pt)
132  {
133  // Nodal positions etc. were created in constructor for OneDMesh<...>
134  // so only need to set up binary tree forest
135  this->setup_binary_tree_forest();
136  }
137 
142  const unsigned& n_element,
143  const double& xmin,
144  const double& xmax,
145  TimeStepper* time_stepper_pt = &Mesh::Default_TimeStepper)
146  : OneDMesh<ELEMENT>(n_element, xmin, xmax, time_stepper_pt)
147  {
148  // Nodal positions etc. were created in constructor for OneDMesh<...>
149  // so only need to set up binary tree forest
150  this->setup_binary_tree_forest();
151  }
152  };
153 
154 
155 } // namespace oomph
156 
157 #endif
Definition: elements.h:1313
unsigned dim() const
Definition: elements.h:2611
Base class for line meshes (meshes made of 1D line elements)
Definition: line_mesh.h:54
static Steady< 0 > Default_TimeStepper
The Steady Timestepper.
Definition: mesh.h:75
Definition: one_d_mesh.template.h:52
OneDMesh(const unsigned &n_element, const double &xmin, const double &xmax, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Definition: one_d_mesh.template.h:71
void build_mesh(TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Generic mesh constuction routine, called by all constructors.
Definition: one_d_mesh.template.cc:39
unsigned N
Number of elements.
Definition: one_d_mesh.template.h:110
void check_1d() const
Definition: one_d_mesh.template.h:85
double Length
Length of the domain.
Definition: one_d_mesh.template.h:107
double Xmin
Minimum coordinate.
Definition: one_d_mesh.template.h:101
double Xmax
Maximum coordinate.
Definition: one_d_mesh.template.h:104
OneDMesh(const unsigned &n_element, const double &length, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Definition: one_d_mesh.template.h:58
Definition: oomph_definitions.h:222
Definition: refineable_line_mesh.h:50
void setup_binary_tree_forest()
Definition: refineable_line_mesh.h:78
Refineable version of the OneDMesh.
Definition: one_d_mesh.template.h:123
RefineableOneDMesh(const unsigned &n_element, const double &xmin, const double &xmax, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Definition: one_d_mesh.template.h:141
RefineableOneDMesh(const unsigned &n_element, const double &length, TimeStepper *time_stepper_pt=&Mesh::Default_TimeStepper)
Definition: one_d_mesh.template.h:127
Definition: timesteppers.h:231
std::string string(const unsigned &i)
Definition: oomph_definitions.cc:286
DRAIG: Change all instances of (SPATIAL_DIM) to (DIM-1).
Definition: AnisotropicHookean.h:10
#define OOMPH_EXCEPTION_LOCATION
Definition: oomph_definitions.h:61
#define OOMPH_CURRENT_FUNCTION
Definition: oomph_definitions.h:86