MFEM v4.7.0
Finite element discretization library
Loading...
Searching...
No Matches
fe_nurbs.hpp
Go to the documentation of this file.
1// Copyright (c) 2010-2024, 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
17namespace mfem
18{
19
20class KnotVector;
21
22/// An arbitrary order and dimension NURBS element
24{
25protected:
26 mutable Array <const KnotVector*> kv;
27 mutable const int *ijk;
28 mutable int patch, elem;
29 mutable Vector weights;
30
31public:
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; }
55 Array <const KnotVector*> &KnotVectors() const { return kv; }
56 Vector &Weights () const { return weights; }
57 /// Update the NURBSFiniteElement according to the currently set knot vectors
58 virtual void SetOrder () const { }
59
60 /// Returns the indices (i,j) in 2D or (i,j,k) in 3D of this element in the
61 /// tensor product ordering of the patch.
62 const int* GetIJK() const { return ijk; }
63};
64
65
66/// An arbitrary order 1D NURBS element on a segment
68{
69protected:
70 mutable Vector shape_x;
71
72public:
73 /// Construct the NURBS1DFiniteElement of order @a p
75 : NURBSFiniteElement(1, Geometry::SEGMENT, p + 1, p, FunctionSpace::Qk),
76 shape_x(p + 1) { }
77
78 virtual void SetOrder() const;
79 virtual void CalcShape(const IntegrationPoint &ip, Vector &shape) const;
80 virtual void CalcDShape(const IntegrationPoint &ip,
81 DenseMatrix &dshape) const;
82 virtual void CalcHessian (const IntegrationPoint &ip,
83 DenseMatrix &hessian) const;
84};
85
86/// An arbitrary order 2D NURBS element on a square
88{
89protected:
91 mutable DenseMatrix du;
92
93public:
94 /// Construct the NURBS2DFiniteElement of order @a p
96 : NURBSFiniteElement(2, Geometry::SQUARE, (p + 1)*(p + 1), p,
97 FunctionSpace::Qk),
98 u(dof), shape_x(p + 1), shape_y(p + 1), dshape_x(p + 1),
99 dshape_y(p + 1), d2shape_x(p + 1), d2shape_y(p + 1), du(dof,2)
100 { orders[0] = orders[1] = p; }
101
102 /// Construct the NURBS2DFiniteElement with x-order @a px and y-order @a py
103 NURBS2DFiniteElement(int px, int py)
104 : NURBSFiniteElement(2, Geometry::SQUARE, (px + 1)*(py + 1),
105 std::max(px, py), FunctionSpace::Qk),
106 u(dof), shape_x(px + 1), shape_y(py + 1), dshape_x(px + 1),
107 dshape_y(py + 1), d2shape_x(px + 1), d2shape_y(py + 1), du(dof,2)
108 { orders[0] = px; orders[1] = py; }
109
110 virtual void SetOrder() const;
111 virtual void CalcShape(const IntegrationPoint &ip, Vector &shape) const;
112 virtual void CalcDShape(const IntegrationPoint &ip,
113 DenseMatrix &dshape) const;
114 virtual void CalcHessian (const IntegrationPoint &ip,
115 DenseMatrix &hessian) const;
116};
117
118/// An arbitrary order 3D NURBS element on a cube
120{
121protected:
126
127public:
128 /// Construct the NURBS3DFiniteElement of order @a p
130 : NURBSFiniteElement(3, Geometry::CUBE, (p + 1)*(p + 1)*(p + 1), p,
131 FunctionSpace::Qk),
132 u(dof), shape_x(p + 1), shape_y(p + 1), shape_z(p + 1),
133 dshape_x(p + 1), dshape_y(p + 1), dshape_z(p + 1),
134 d2shape_x(p + 1), d2shape_y(p + 1), d2shape_z(p + 1), du(dof,3)
135 { orders[0] = orders[1] = orders[2] = p; }
136
137 /// Construct the NURBS3DFiniteElement with x-order @a px and y-order @a py
138 /// and z-order @a pz
139 NURBS3DFiniteElement(int px, int py, int pz)
140 : NURBSFiniteElement(3, Geometry::CUBE, (px + 1)*(py + 1)*(pz + 1),
141 std::max(std::max(px,py),pz), FunctionSpace::Qk),
142 u(dof), shape_x(px + 1), shape_y(py + 1), shape_z(pz + 1),
143 dshape_x(px + 1), dshape_y(py + 1), dshape_z(pz + 1),
144 d2shape_x(px + 1), d2shape_y(py + 1), d2shape_z(pz + 1), du(dof,3)
145 { orders[0] = px; orders[1] = py; orders[2] = pz; }
146
147 virtual void SetOrder() const;
148 virtual void CalcShape(const IntegrationPoint &ip, Vector &shape) const;
149 virtual void CalcDShape(const IntegrationPoint &ip,
150 DenseMatrix &dshape) const;
151 virtual void CalcHessian (const IntegrationPoint &ip,
152 DenseMatrix &hessian) const;
153};
154
155} // namespace mfem
156
157#endif
Data type dense matrix using column-major storage.
Definition: densemat.hpp:24
int dof
Number of degrees of freedom.
Definition: fe_base.hpp:248
int orders[Geometry::MaxDim]
Anisotropic orders.
Definition: fe_base.hpp:250
int dim
Dimension of reference space.
Definition: fe_base.hpp:241
Describes the function space on each element.
Definition: fe_base.hpp:222
Class for integration point with weight.
Definition: intrules.hpp:35
An arbitrary order 1D NURBS element on a segment.
Definition: fe_nurbs.hpp:68
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
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
NURBS1DFiniteElement(int p)
Construct the NURBS1DFiniteElement of order p.
Definition: fe_nurbs.hpp:74
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
virtual void SetOrder() const
Update the NURBSFiniteElement according to the currently set knot vectors.
Definition: fe_nurbs.cpp:22
An arbitrary order 2D NURBS element on a square.
Definition: fe_nurbs.hpp:88
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 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
NURBS2DFiniteElement(int px, int py)
Construct the NURBS2DFiniteElement with x-order px and y-order py.
Definition: fe_nurbs.hpp:103
virtual void SetOrder() const
Update the NURBSFiniteElement according to the currently set knot vectors.
Definition: fe_nurbs.cpp:88
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
NURBS2DFiniteElement(int p)
Construct the NURBS2DFiniteElement of order p.
Definition: fe_nurbs.hpp:95
An arbitrary order 3D NURBS element on a cube.
Definition: fe_nurbs.hpp:120
virtual void SetOrder() const
Update the NURBSFiniteElement according to the currently set knot vectors.
Definition: fe_nurbs.cpp:219
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
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
NURBS3DFiniteElement(int px, int py, int pz)
Definition: fe_nurbs.hpp:139
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
NURBS3DFiniteElement(int p)
Construct the NURBS3DFiniteElement of order p.
Definition: fe_nurbs.hpp:129
An arbitrary order and dimension NURBS element.
Definition: fe_nurbs.hpp:24
Array< const KnotVector * > kv
Definition: fe_nurbs.hpp:26
Array< const KnotVector * > & KnotVectors() const
Definition: fe_nurbs.hpp:55
virtual void SetOrder() const
Update the NURBSFiniteElement according to the currently set knot vectors.
Definition: fe_nurbs.hpp:58
void SetPatch(int p) const
Definition: fe_nurbs.hpp:52
Vector & Weights() const
Definition: fe_nurbs.hpp:56
void SetElement(int e) const
Definition: fe_nurbs.hpp:54
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
const int * GetIJK() const
Definition: fe_nurbs.hpp:62
void SetIJK(const int *IJK) const
Definition: fe_nurbs.hpp:50
Class for finite elements with basis functions that return scalar values.
Definition: fe_base.hpp:656
Vector data type.
Definition: vector.hpp:80
void SetSize(int s)
Resize the vector to size s.
Definition: vector.hpp:538
real_t p(const Vector &x, real_t t)
Definition: navier_mms.cpp:53