MFEM  v4.5.2
Finite element discretization library
fe_nurbs.hpp
Go to the documentation of this file.
1 // Copyright (c) 2010-2023, Lawrence Livermore National Security, LLC. Produced
2 // at the Lawrence Livermore National Laboratory. All Rights reserved. See files
3 // LICENSE and NOTICE for details. LLNL-CODE-806117.
4 //
5 // This file is part of the MFEM library. For more information and source code
6 // availability visit https://mfem.org.
7 //
8 // MFEM is free software; you can redistribute it and/or modify it under the
9 // terms of the BSD-3 license. We welcome feedback and contributions, see file
10 // CONTRIBUTING.md for details.
11 
12 #ifndef MFEM_FE_NURBS
13 #define MFEM_FE_NURBS
14 
15 #include "fe_base.hpp"
16 
17 namespace mfem
18 {
19 
20 class KnotVector;
21 
22 /// An arbitrary order and dimension NURBS element
24 {
25 protected:
27  mutable const int *ijk;
28  mutable int patch, elem;
29  mutable Vector weights;
30 
31 public:
32  /** @brief Construct NURBSFiniteElement with given
33  @param D Reference space dimension
34  @param G Geometry type (of type Geometry::Type)
35  @param Do Number of degrees of freedom in the FiniteElement
36  @param O Order/degree of the FiniteElement
37  @param F FunctionSpace type of the FiniteElement
38  */
39  NURBSFiniteElement(int D, Geometry::Type G, int Do, int O, int F)
40  : ScalarFiniteElement(D, G, Do, O, F)
41  {
42  ijk = NULL;
43  patch = elem = -1;
44  kv.SetSize(dim);
46  weights = 1.0;
47  }
48 
49  void Reset () const { patch = elem = -1; }
50  void SetIJK (const int *IJK) const { ijk = IJK; }
51  int GetPatch () const { return patch; }
52  void SetPatch (int p) const { patch = p; }
53  int GetElement () const { return elem; }
54  void SetElement (int e) const { elem = e; }
56  Vector &Weights () const { return weights; }
57  /// Update the NURBSFiniteElement according to the currently set knot vectors
58  virtual void SetOrder () const { }
59 };
60 
61 
62 /// An arbitrary order 1D NURBS element on a segment
64 {
65 protected:
66  mutable Vector shape_x;
67 
68 public:
69  /// Construct the NURBS1DFiniteElement of order @a p
71  : NURBSFiniteElement(1, Geometry::SEGMENT, p + 1, p, FunctionSpace::Qk),
72  shape_x(p + 1) { }
73 
74  virtual void SetOrder() const;
75  virtual void CalcShape(const IntegrationPoint &ip, Vector &shape) const;
76  virtual void CalcDShape(const IntegrationPoint &ip,
77  DenseMatrix &dshape) const;
78  virtual void CalcHessian (const IntegrationPoint &ip,
79  DenseMatrix &hessian) const;
80 };
81 
82 /// An arbitrary order 2D NURBS element on a square
84 {
85 protected:
87  mutable DenseMatrix du;
88 
89 public:
90  /// Construct the NURBS2DFiniteElement of order @a p
92  : NURBSFiniteElement(2, Geometry::SQUARE, (p + 1)*(p + 1), p,
93  FunctionSpace::Qk),
94  u(dof), shape_x(p + 1), shape_y(p + 1), dshape_x(p + 1),
95  dshape_y(p + 1), d2shape_x(p + 1), d2shape_y(p + 1), du(dof,2)
96  { orders[0] = orders[1] = p; }
97 
98  /// Construct the NURBS2DFiniteElement with x-order @a px and y-order @a py
99  NURBS2DFiniteElement(int px, int py)
100  : NURBSFiniteElement(2, Geometry::SQUARE, (px + 1)*(py + 1),
101  std::max(px, py), FunctionSpace::Qk),
102  u(dof), shape_x(px + 1), shape_y(py + 1), dshape_x(px + 1),
103  dshape_y(py + 1), d2shape_x(px + 1), d2shape_y(py + 1), du(dof,2)
104  { orders[0] = px; orders[1] = py; }
105 
106  virtual void SetOrder() const;
107  virtual void CalcShape(const IntegrationPoint &ip, Vector &shape) const;
108  virtual void CalcDShape(const IntegrationPoint &ip,
109  DenseMatrix &dshape) const;
110  virtual void CalcHessian (const IntegrationPoint &ip,
111  DenseMatrix &hessian) const;
112 };
113 
114 /// An arbitrary order 3D NURBS element on a cube
116 {
117 protected:
121  mutable DenseMatrix du;
122 
123 public:
124  /// Construct the NURBS3DFiniteElement of order @a p
126  : NURBSFiniteElement(3, Geometry::CUBE, (p + 1)*(p + 1)*(p + 1), p,
127  FunctionSpace::Qk),
128  u(dof), shape_x(p + 1), shape_y(p + 1), shape_z(p + 1),
129  dshape_x(p + 1), dshape_y(p + 1), dshape_z(p + 1),
130  d2shape_x(p + 1), d2shape_y(p + 1), d2shape_z(p + 1), du(dof,3)
131  { orders[0] = orders[1] = orders[2] = p; }
132 
133  /// Construct the NURBS3DFiniteElement with x-order @a px and y-order @a py
134  /// and z-order @a pz
135  NURBS3DFiniteElement(int px, int py, int pz)
136  : NURBSFiniteElement(3, Geometry::CUBE, (px + 1)*(py + 1)*(pz + 1),
137  std::max(std::max(px,py),pz), FunctionSpace::Qk),
138  u(dof), shape_x(px + 1), shape_y(py + 1), shape_z(pz + 1),
139  dshape_x(px + 1), dshape_y(py + 1), dshape_z(pz + 1),
140  d2shape_x(px + 1), d2shape_y(py + 1), d2shape_z(pz + 1), du(dof,3)
141  { orders[0] = px; orders[1] = py; orders[2] = pz; }
142 
143  virtual void SetOrder() const;
144  virtual void CalcShape(const IntegrationPoint &ip, Vector &shape) const;
145  virtual void CalcDShape(const IntegrationPoint &ip,
146  DenseMatrix &dshape) const;
147  virtual void CalcHessian (const IntegrationPoint &ip,
148  DenseMatrix &hessian) const;
149 };
150 
151 } // namespace mfem
152 
153 #endif
virtual void CalcShape(const IntegrationPoint &ip, Vector &shape) const
Evaluate the values of all shape functions of a scalar finite element in reference space at the given...
Definition: fe_nurbs.cpp:31
Array< const KnotVector * > kv
Definition: fe_nurbs.hpp:26
NURBS2DFiniteElement(int px, int py)
Construct the NURBS2DFiniteElement with x-order px and y-order py.
Definition: fe_nurbs.hpp:99
virtual void CalcHessian(const IntegrationPoint &ip, DenseMatrix &hessian) const
Evaluate the Hessians of all shape functions of a scalar finite element in reference space at the giv...
Definition: fe_nurbs.cpp:160
void SetSize(int s)
Resize the vector to size s.
Definition: vector.hpp:512
virtual void SetOrder() const
Update the NURBSFiniteElement according to the currently set knot vectors.
Definition: fe_nurbs.cpp:219
virtual void CalcShape(const IntegrationPoint &ip, Vector &shape) const
Evaluate the values of all shape functions of a scalar finite element in reference space at the given...
Definition: fe_nurbs.cpp:243
int dim
Dimension of reference space.
Definition: fe_base.hpp:235
Data type dense matrix using column-major storage.
Definition: densemat.hpp:23
virtual void SetOrder() const
Update the NURBSFiniteElement according to the currently set knot vectors.
Definition: fe_nurbs.cpp:22
An arbitrary order and dimension NURBS element.
Definition: fe_nurbs.hpp:23
virtual void CalcDShape(const IntegrationPoint &ip, DenseMatrix &dshape) const
Evaluate the gradients of all shape functions of a scalar finite element in reference space at the gi...
Definition: fe_nurbs.cpp:267
void SetIJK(const int *IJK) const
Definition: fe_nurbs.hpp:50
virtual void CalcDShape(const IntegrationPoint &ip, DenseMatrix &dshape) const
Evaluate the gradients of all shape functions of a scalar finite element in reference space at the gi...
Definition: fe_nurbs.cpp:45
NURBS3DFiniteElement(int px, int py, int pz)
Definition: fe_nurbs.hpp:135
STL namespace.
virtual void SetOrder() const
Update the NURBSFiniteElement according to the currently set knot vectors.
Definition: fe_nurbs.hpp:58
virtual void CalcShape(const IntegrationPoint &ip, Vector &shape) const
Evaluate the values of all shape functions of a scalar finite element in reference space at the given...
Definition: fe_nurbs.cpp:106
NURBS1DFiniteElement(int p)
Construct the NURBS1DFiniteElement of order p.
Definition: fe_nurbs.hpp:70
Class for finite elements with basis functions that return scalar values.
Definition: fe_base.hpp:627
virtual void CalcDShape(const IntegrationPoint &ip, DenseMatrix &dshape) const
Evaluate the gradients of all shape functions of a scalar finite element in reference space at the gi...
Definition: fe_nurbs.cpp:125
virtual void SetOrder() const
Update the NURBSFiniteElement according to the currently set knot vectors.
Definition: fe_nurbs.cpp:88
int orders[Geometry::MaxDim]
Anisotropic orders.
Definition: fe_base.hpp:244
Array< const KnotVector * > & KnotVectors() const
Definition: fe_nurbs.hpp:55
NURBSFiniteElement(int D, Geometry::Type G, int Do, int O, int F)
Construct NURBSFiniteElement with given.
Definition: fe_nurbs.hpp:39
int GetElement() const
Definition: fe_nurbs.hpp:53
void SetElement(int e) const
Definition: fe_nurbs.hpp:54
NURBS3DFiniteElement(int p)
Construct the NURBS3DFiniteElement of order p.
Definition: fe_nurbs.hpp:125
virtual void CalcHessian(const IntegrationPoint &ip, DenseMatrix &hessian) const
Evaluate the Hessians of all shape functions of a scalar finite element in reference space at the giv...
Definition: fe_nurbs.cpp:313
Class for integration point with weight.
Definition: intrules.hpp:25
NURBS2DFiniteElement(int p)
Construct the NURBS2DFiniteElement of order p.
Definition: fe_nurbs.hpp:91
int dof
Number of degrees of freedom.
Definition: fe_base.hpp:242
Vector data type.
Definition: vector.hpp:60
Describes the function space on each element.
Definition: fe_base.hpp:215
virtual void CalcHessian(const IntegrationPoint &ip, DenseMatrix &hessian) const
Evaluate the Hessians of all shape functions of a scalar finite element in reference space at the giv...
Definition: fe_nurbs.cpp:64
Vector & Weights() const
Definition: fe_nurbs.hpp:56
void SetPatch(int p) const
Definition: fe_nurbs.hpp:52
An arbitrary order 3D NURBS element on a cube.
Definition: fe_nurbs.hpp:115
An arbitrary order 1D NURBS element on a segment.
Definition: fe_nurbs.hpp:63
An arbitrary order 2D NURBS element on a square.
Definition: fe_nurbs.hpp:83