libMesh
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | Private Member Functions | List of all members
libMesh::QTrap Class Reference

This class implements trapezoidal quadrature. More...

#include <quadrature_trap.h>

Inheritance diagram for libMesh::QTrap:
[legend]

Public Member Functions

 QTrap (const unsigned int _dim, const Order o=FIRST)
 Constructor. More...
 
 ~QTrap ()
 Destructor. More...
 
virtual QuadratureType type () const libmesh_override
 
ElemType get_elem_type () const
 
unsigned int get_p_level () const
 
unsigned int n_points () const
 
unsigned int get_dim () const
 
const std::vector< Point > & get_points () const
 
std::vector< Point > & get_points ()
 
const std::vector< Real > & get_weights () const
 
std::vector< Real > & get_weights ()
 
Point qp (const unsigned int i) const
 
Real w (const unsigned int i) const
 
virtual void init (const ElemType type=INVALID_ELEM, unsigned int p_level=0)
 Initializes the data structures for a quadrature rule for an element of type type. More...
 
virtual void init (const Elem &elem, const std::vector< Real > &vertex_distance_func, unsigned int p_level=0)
 Initializes the data structures for an element potentially "cut" by a signed distance function. More...
 
Order get_order () const
 
void print_info (std::ostream &os=libMesh::out) const
 Prints information relevant to the quadrature rule, by default to libMesh::out. More...
 
void scale (std::pair< Real, Real > old_range, std::pair< Real, Real > new_range)
 Maps the points of a 1D quadrature rule defined by "old_range" to another 1D interval defined by "new_range" and scales the weights accordingly. More...
 
virtual bool shapes_need_reinit ()
 

Static Public Member Functions

static UniquePtr< QBasebuild (const std::string &name, const unsigned int dim, const Order order=INVALID_ORDER)
 Builds a specific quadrature rule based on the name string. More...
 
static UniquePtr< QBasebuild (const QuadratureType qt, const unsigned int dim, const Order order=INVALID_ORDER)
 Builds a specific quadrature rule based on the QuadratureType. More...
 
static void print_info (std::ostream &out=libMesh::out)
 Prints the reference information, by default to libMesh::out. More...
 
static std::string get_info ()
 Gets a string containing the reference information. More...
 
static unsigned int n_objects ()
 Prints the number of outstanding (created, but not yet destroyed) objects. More...
 
static void enable_print_counter_info ()
 Methods to enable/disable the reference counter output from print_info() More...
 
static void disable_print_counter_info ()
 

Public Attributes

bool allow_rules_with_negative_weights
 Flag (default true) controlling the use of quadrature rules with negative weights. More...
 

Protected Types

typedef std::map< std::string, std::pair< unsigned int, unsigned int > > Counts
 Data structure to log the information. More...
 

Protected Member Functions

virtual void init_0D (const ElemType type=INVALID_ELEM, unsigned int p_level=0)
 Initializes the 0D quadrature rule by filling the points and weights vectors with the appropriate values. More...
 
void tensor_product_quad (const QBase &q1D)
 Constructs a 2D rule from the tensor product of q1D with itself. More...
 
void tensor_product_hex (const QBase &q1D)
 Computes the tensor product quadrature rule [q1D x q1D x q1D] from the 1D rule q1D. More...
 
void tensor_product_prism (const QBase &q1D, const QBase &q2D)
 Computes the tensor product of a 1D quadrature rule and a 2D quadrature rule. More...
 
void increment_constructor_count (const std::string &name)
 Increments the construction counter. More...
 
void increment_destructor_count (const std::string &name)
 Increments the destruction counter. More...
 

Protected Attributes

const unsigned int _dim
 The spatial dimension of the quadrature rule. More...
 
const Order _order
 The polynomial order which the quadrature rule is capable of integrating exactly. More...
 
ElemType _type
 The type of element for which the current values have been computed. More...
 
unsigned int _p_level
 The p-level of the element for which the current values have been computed. More...
 
std::vector< Point_points
 The locations of the quadrature points in reference element space. More...
 
std::vector< Real_weights
 The quadrature weights. More...
 

Static Protected Attributes

static Counts _counts
 Actually holds the data. More...
 
static Threads::atomic< unsigned int_n_objects
 The number of objects. More...
 
static Threads::spin_mutex _mutex
 Mutual exclusion object to enable thread-safe reference counting. More...
 
static bool _enable_print_counter = true
 Flag to control whether reference count information is printed when print_info is called. More...
 

Private Member Functions

virtual void init_1D (const ElemType _type=INVALID_ELEM, unsigned int p_level=0) libmesh_override
 Initializes the 1D quadrature rule by filling the points and weights vectors with the appropriate values. More...
 
virtual void init_2D (const ElemType _type=INVALID_ELEM, unsigned int p_level=0) libmesh_override
 Initializes the 2D quadrature rule by filling the points and weights vectors with the appropriate values. More...
 
virtual void init_3D (const ElemType _type=INVALID_ELEM, unsigned int p_level=0) libmesh_override
 Initializes the 3D quadrature rule by filling the points and weights vectors with the appropriate values. More...
 

Detailed Description

This class implements trapezoidal quadrature.

Sometimes also known as Newton-Cotes quadrature with two points. These rules sample at the corners and will integrate linears exactly.

Author
Benjamin Kirk
Date
2003 Implements trapezoidal rule, i.e. nodal quadrature for linear elements.

Definition at line 38 of file quadrature_trap.h.

Member Typedef Documentation

typedef std::map<std::string, std::pair<unsigned int, unsigned int> > libMesh::ReferenceCounter::Counts
protectedinherited

Data structure to log the information.

The log is identified by the class name.

Definition at line 119 of file reference_counter.h.

Constructor & Destructor Documentation

libMesh::QTrap::QTrap ( const unsigned int  _dim,
const Order  o = FIRST 
)
explicit

Constructor.

Declares the order of the quadrature rule. We explicitly call the init function in 1D since the other tensor-product rules require this one.

Note
The element type, EDGE2, will not be used internally, however if we called the function with INVALID_ELEM it would try to be smart and return, thinking it had already done the work.

Definition at line 52 of file quadrature_trap.h.

References libMesh::EDGE2, and libMesh::QBase::init().

53  :
54  QBase(_dim,o)
55  {
56  if (_dim == 1)
57  init(EDGE2);
58  }
virtual void init(const ElemType type=INVALID_ELEM, unsigned int p_level=0)
Initializes the data structures for a quadrature rule for an element of type type.
Definition: quadrature.C:28
const unsigned int _dim
The spatial dimension of the quadrature rule.
Definition: quadrature.h:311
QBase(const unsigned int _dim, const Order _order=INVALID_ORDER)
Constructor.
Definition: quadrature.h:350
libMesh::QTrap::~QTrap ( )

Destructor.

Empty.

Definition at line 63 of file quadrature_trap.h.

63 {}

Member Function Documentation

UniquePtr< QBase > libMesh::QBase::build ( const std::string &  name,
const unsigned int  dim,
const Order  order = INVALID_ORDER 
)
staticinherited

Builds a specific quadrature rule based on the name string.

This enables selection of the quadrature rule at run-time. The input parameter name must be mappable through the Utility::string_to_enum<>() function.

This function allocates memory, therefore a UniquePtr<QBase> is returned so that the user does not accidentally leak it.

Definition at line 42 of file quadrature_build.C.

Referenced by assemble_poisson(), libMesh::InfFE< Dim, T_radial, T_map >::attach_quadrature_rule(), libMesh::RBEIMAssembly::evaluate_basis_function(), QuadratureTest::test1DWeights(), QuadratureTest::test2DWeights(), QuadratureTest::test3DWeights(), QuadratureTest::testBuild(), QuadratureTest::testJacobi(), QuadratureTest::testMonomialQuadrature(), QuadratureTest::testTetQuadrature(), QuadratureTest::testTriQuadrature(), and libMesh::QBase::~QBase().

45 {
46  return QBase::build (Utility::string_to_enum<QuadratureType> (type),
47  _dim,
48  _order);
49 }
const unsigned int _dim
The spatial dimension of the quadrature rule.
Definition: quadrature.h:311
virtual QuadratureType type() const =0
static UniquePtr< QBase > build(const std::string &name, const unsigned int dim, const Order order=INVALID_ORDER)
Builds a specific quadrature rule based on the name string.
const Order _order
The polynomial order which the quadrature rule is capable of integrating exactly. ...
Definition: quadrature.h:317
UniquePtr< QBase > libMesh::QBase::build ( const QuadratureType  qt,
const unsigned int  dim,
const Order  order = INVALID_ORDER 
)
staticinherited

Builds a specific quadrature rule based on the QuadratureType.

This enables selection of the quadrature rule at run-time.

This function allocates memory, therefore a UniquePtr<QBase> is returned so that the user does not accidentally leak it.

Definition at line 53 of file quadrature_build.C.

References libMesh::FIRST, libMesh::FORTYTHIRD, libMesh::out, libMesh::QCLOUGH, libMesh::QCONICAL, libMesh::QGAUSS, libMesh::QGAUSS_LOBATTO, libMesh::QGRID, libMesh::QGRUNDMANN_MOLLER, libMesh::QJACOBI_1_0, libMesh::QJACOBI_2_0, libMesh::QMONOMIAL, libMesh::QSIMPSON, libMesh::QTRAP, libMesh::THIRD, and libMesh::TWENTYTHIRD.

56 {
57  switch (_qt)
58  {
59 
60  case QCLOUGH:
61  {
62 #ifdef DEBUG
63  if (_order > TWENTYTHIRD)
64  {
65  libMesh::out << "WARNING: Clough quadrature implemented" << std::endl
66  << " up to TWENTYTHIRD order." << std::endl;
67  }
68 #endif
69 
70  return UniquePtr<QBase>(new QClough(_dim, _order));
71  }
72 
73  case QGAUSS:
74  {
75 
76 #ifdef DEBUG
77  if (_order > FORTYTHIRD)
78  {
79  libMesh::out << "WARNING: Gauss quadrature implemented" << std::endl
80  << " up to FORTYTHIRD order." << std::endl;
81  }
82 #endif
83 
84  return UniquePtr<QBase>(new QGauss(_dim, _order));
85  }
86 
87  case QJACOBI_1_0:
88  {
89 
90 #ifdef DEBUG
91  if (_order > FORTYTHIRD)
92  {
93  libMesh::out << "WARNING: Jacobi(1,0) quadrature implemented" << std::endl
94  << " up to FORTYTHIRD order." << std::endl;
95  }
96 
97  if (_dim > 1)
98  {
99  libMesh::out << "WARNING: Jacobi(1,0) quadrature implemented" << std::endl
100  << " in 1D only." << std::endl;
101  }
102 #endif
103 
104  return UniquePtr<QBase>(new QJacobi(_dim, _order, 1, 0));
105  }
106 
107  case QJACOBI_2_0:
108  {
109 
110 #ifdef DEBUG
111  if (_order > FORTYTHIRD)
112  {
113  libMesh::out << "WARNING: Jacobi(2,0) quadrature implemented" << std::endl
114  << " up to FORTYTHIRD order." << std::endl;
115  }
116 
117  if (_dim > 1)
118  {
119  libMesh::out << "WARNING: Jacobi(2,0) quadrature implemented" << std::endl
120  << " in 1D only." << std::endl;
121  }
122 #endif
123 
124  return UniquePtr<QBase>(new QJacobi(_dim, _order, 2, 0));
125  }
126 
127  case QSIMPSON:
128  {
129 
130 #ifdef DEBUG
131  if (_order > THIRD)
132  {
133  libMesh::out << "WARNING: Simpson rule provides only" << std::endl
134  << " THIRD order!" << std::endl;
135  }
136 #endif
137 
138  return UniquePtr<QBase>(new QSimpson(_dim));
139  }
140 
141  case QTRAP:
142  {
143 
144 #ifdef DEBUG
145  if (_order > FIRST)
146  {
147  libMesh::out << "WARNING: Trapezoidal rule provides only" << std::endl
148  << " FIRST order!" << std::endl;
149  }
150 #endif
151 
152  return UniquePtr<QBase>(new QTrap(_dim));
153  }
154 
155  case QGRID:
156  return UniquePtr<QBase>(new QGrid(_dim, _order));
157 
158  case QGRUNDMANN_MOLLER:
159  return UniquePtr<QBase>(new QGrundmann_Moller(_dim, _order));
160 
161  case QMONOMIAL:
162  return UniquePtr<QBase>(new QMonomial(_dim, _order));
163 
164  case QGAUSS_LOBATTO:
165  return UniquePtr<QBase>(new QGaussLobatto(_dim, _order));
166 
167  case QCONICAL:
168  return UniquePtr<QBase>(new QConical(_dim, _order));
169 
170  default:
171  libmesh_error_msg("ERROR: Bad qt=" << _qt);
172  }
173 
174 
175  libmesh_error_msg("We'll never get here!");
176  return UniquePtr<QBase>();
177 }
const unsigned int _dim
The spatial dimension of the quadrature rule.
Definition: quadrature.h:311
OStreamProxy out
const Order _order
The polynomial order which the quadrature rule is capable of integrating exactly. ...
Definition: quadrature.h:317
void libMesh::ReferenceCounter::disable_print_counter_info ( )
staticinherited

Definition at line 107 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

Referenced by libMesh::LibMeshInit::LibMeshInit(), and libMesh::ReferenceCounter::n_objects().

108 {
109  _enable_print_counter = false;
110  return;
111 }
static bool _enable_print_counter
Flag to control whether reference count information is printed when print_info is called...
void libMesh::ReferenceCounter::enable_print_counter_info ( )
staticinherited

Methods to enable/disable the reference counter output from print_info()

Definition at line 101 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter.

Referenced by libMesh::ReferenceCounter::n_objects().

102 {
103  _enable_print_counter = true;
104  return;
105 }
static bool _enable_print_counter
Flag to control whether reference count information is printed when print_info is called...
unsigned int libMesh::QBase::get_dim ( ) const
inherited
Returns
The spatial dimension of the quadrature rule.

Definition at line 122 of file quadrature.h.

References libMesh::QBase::_dim.

Referenced by libMesh::InfFE< Dim, T_radial, T_map >::attach_quadrature_rule(), and libMesh::RBEIMAssembly::evaluate_basis_function().

122 { return _dim; }
const unsigned int _dim
The spatial dimension of the quadrature rule.
Definition: quadrature.h:311
ElemType libMesh::QBase::get_elem_type ( ) const
inherited
Returns
The element type we're currently using.

Definition at line 103 of file quadrature.h.

References libMesh::QBase::_type.

103 { return _type; }
ElemType _type
The type of element for which the current values have been computed.
Definition: quadrature.h:323
std::string libMesh::ReferenceCounter::get_info ( )
staticinherited

Gets a string containing the reference information.

Definition at line 47 of file reference_counter.C.

References libMesh::ReferenceCounter::_counts, and libMesh::Quality::name().

Referenced by libMesh::ReferenceCounter::print_info().

48 {
49 #if defined(LIBMESH_ENABLE_REFERENCE_COUNTING) && defined(DEBUG)
50 
51  std::ostringstream oss;
52 
53  oss << '\n'
54  << " ---------------------------------------------------------------------------- \n"
55  << "| Reference count information |\n"
56  << " ---------------------------------------------------------------------------- \n";
57 
58  for (Counts::iterator it = _counts.begin();
59  it != _counts.end(); ++it)
60  {
61  const std::string name(it->first);
62  const unsigned int creations = it->second.first;
63  const unsigned int destructions = it->second.second;
64 
65  oss << "| " << name << " reference count information:\n"
66  << "| Creations: " << creations << '\n'
67  << "| Destructions: " << destructions << '\n';
68  }
69 
70  oss << " ---------------------------------------------------------------------------- \n";
71 
72  return oss.str();
73 
74 #else
75 
76  return "";
77 
78 #endif
79 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
static Counts _counts
Actually holds the data.
Order libMesh::QBase::get_order ( ) const
inherited
Returns
The order of the quadrature rule.

Definition at line 189 of file quadrature.h.

References libMesh::QBase::_order, libMesh::QBase::_p_level, libMesh::QBase::operator<<, libMesh::out, libMesh::QBase::print_info(), and libMesh::QBase::scale().

Referenced by libMesh::InfFE< Dim, T_radial, T_map >::attach_quadrature_rule(), and libMesh::RBEIMAssembly::evaluate_basis_function().

189 { return static_cast<Order>(_order + _p_level); }
unsigned int _p_level
The p-level of the element for which the current values have been computed.
Definition: quadrature.h:329
Order
defines an enum for polynomial orders.
Definition: enum_order.h:32
const Order _order
The polynomial order which the quadrature rule is capable of integrating exactly. ...
Definition: quadrature.h:317
unsigned int libMesh::QBase::get_p_level ( ) const
inherited
Returns
The p-refinement level we're currently using.

Definition at line 108 of file quadrature.h.

References libMesh::QBase::_p_level.

108 { return _p_level; }
unsigned int _p_level
The p-level of the element for which the current values have been computed.
Definition: quadrature.h:329
const std::vector<Point>& libMesh::QBase::get_points ( ) const
inherited
Returns
A std::vector containing the quadrature point locations in reference element space.

Definition at line 128 of file quadrature.h.

References libMesh::QBase::_points.

Referenced by assemble_ellipticdg(), and libMesh::FESubdivision::attach_quadrature_rule().

128 { return _points; }
std::vector< Point > _points
The locations of the quadrature points in reference element space.
Definition: quadrature.h:335
std::vector<Point>& libMesh::QBase::get_points ( )
inherited
Returns
A std::vector containing the quadrature point locations in reference element space as a writable reference.

Definition at line 134 of file quadrature.h.

References libMesh::QBase::_points.

134 { return _points; }
std::vector< Point > _points
The locations of the quadrature points in reference element space.
Definition: quadrature.h:335
const std::vector<Real>& libMesh::QBase::get_weights ( ) const
inherited
Returns
A constant reference to a std::vector containing the quadrature weights.

Definition at line 140 of file quadrature.h.

References libMesh::QBase::_weights.

Referenced by libMesh::FESubdivision::attach_quadrature_rule().

140 { return _weights; }
std::vector< Real > _weights
The quadrature weights.
Definition: quadrature.h:341
std::vector<Real>& libMesh::QBase::get_weights ( )
inherited
Returns
A writable references to a std::vector containing the quadrature weights.

Definition at line 146 of file quadrature.h.

References libMesh::QBase::_weights.

146 { return _weights; }
std::vector< Real > _weights
The quadrature weights.
Definition: quadrature.h:341
void libMesh::ReferenceCounter::increment_constructor_count ( const std::string &  name)
protectedinherited

Increments the construction counter.

Should be called in the constructor of any derived class that will be reference counted.

Definition at line 185 of file reference_counter.h.

References libMesh::ReferenceCounter::_counts, libMesh::Quality::name(), and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCounter::n_objects(), and libMesh::ReferenceCountedObject< RBParametrized >::ReferenceCountedObject().

186 {
187  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
188  std::pair<unsigned int, unsigned int> & p = _counts[name];
189 
190  p.first++;
191 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
spin_mutex spin_mtx
A convenient spin mutex object which can be used for obtaining locks.
Definition: threads.C:29
static Counts _counts
Actually holds the data.
void libMesh::ReferenceCounter::increment_destructor_count ( const std::string &  name)
protectedinherited

Increments the destruction counter.

Should be called in the destructor of any derived class that will be reference counted.

Definition at line 198 of file reference_counter.h.

References libMesh::ReferenceCounter::_counts, libMesh::Quality::name(), and libMesh::Threads::spin_mtx.

Referenced by libMesh::ReferenceCounter::n_objects(), and libMesh::ReferenceCountedObject< RBParametrized >::~ReferenceCountedObject().

199 {
200  Threads::spin_mutex::scoped_lock lock(Threads::spin_mtx);
201  std::pair<unsigned int, unsigned int> & p = _counts[name];
202 
203  p.second++;
204 }
std::string name(const ElemQuality q)
This function returns a string containing some name for q.
Definition: elem_quality.C:39
spin_mutex spin_mtx
A convenient spin mutex object which can be used for obtaining locks.
Definition: threads.C:29
static Counts _counts
Actually holds the data.
void libMesh::QBase::init ( const ElemType  type = INVALID_ELEM,
unsigned int  p_level = 0 
)
virtualinherited

Initializes the data structures for a quadrature rule for an element of type type.

Definition at line 28 of file quadrature.C.

References libMesh::QBase::_dim, libMesh::QBase::_p_level, libMesh::QBase::_type, libMesh::QBase::init_0D(), libMesh::QBase::init_1D(), libMesh::QBase::init_2D(), and libMesh::QBase::init_3D().

Referenced by libMesh::FESubdivision::attach_quadrature_rule(), libMesh::QBase::init(), init_2D(), libMesh::QSimpson::init_2D(), libMesh::QGauss::init_2D(), init_3D(), libMesh::QGauss::init_3D(), libMesh::QSimpson::init_3D(), libMesh::QGauss::QGauss(), libMesh::QSimpson::QSimpson(), QTrap(), and libMesh::QBase::w().

30 {
31  // check to see if we have already
32  // done the work for this quadrature rule
33  if (t == _type && p == _p_level)
34  return;
35  else
36  {
37  _type = t;
38  _p_level = p;
39  }
40 
41 
42 
43  switch(_dim)
44  {
45  case 0:
46  this->init_0D(_type,_p_level);
47 
48  return;
49 
50  case 1:
51  this->init_1D(_type,_p_level);
52 
53  return;
54 
55  case 2:
56  this->init_2D(_type,_p_level);
57 
58  return;
59 
60  case 3:
61  this->init_3D(_type,_p_level);
62 
63  return;
64 
65  default:
66  libmesh_error_msg("Invalid dimension _dim = " << _dim);
67  }
68 }
const unsigned int _dim
The spatial dimension of the quadrature rule.
Definition: quadrature.h:311
ElemType _type
The type of element for which the current values have been computed.
Definition: quadrature.h:323
unsigned int _p_level
The p-level of the element for which the current values have been computed.
Definition: quadrature.h:329
virtual void init_2D(const ElemType, unsigned int=0)
Initializes the 2D quadrature rule by filling the points and weights vectors with the appropriate val...
Definition: quadrature.h:263
virtual void init_1D(const ElemType type=INVALID_ELEM, unsigned int p_level=0)=0
Initializes the 1D quadrature rule by filling the points and weights vectors with the appropriate val...
virtual void init_0D(const ElemType type=INVALID_ELEM, unsigned int p_level=0)
Initializes the 0D quadrature rule by filling the points and weights vectors with the appropriate val...
Definition: quadrature.C:82
virtual void init_3D(const ElemType, unsigned int=0)
Initializes the 3D quadrature rule by filling the points and weights vectors with the appropriate val...
Definition: quadrature.h:279
void libMesh::QBase::init ( const Elem elem,
const std::vector< Real > &  vertex_distance_func,
unsigned int  p_level = 0 
)
virtualinherited

Initializes the data structures for an element potentially "cut" by a signed distance function.

The array vertex_distance_func contains vertex values of the signed distance function. If the signed distance function changes sign on the vertices, then the element is considered to be cut.) This interface can be extended by derived classes in order to subdivide the element and construct a composite quadrature rule.

Reimplemented in libMesh::libmesh_final< T >.

Definition at line 72 of file quadrature.C.

References libMesh::QBase::init(), and libMesh::Elem::type().

75 {
76  // dispatch generic implementation
77  this->init(elem.type(), p_level);
78 }
virtual void init(const ElemType type=INVALID_ELEM, unsigned int p_level=0)
Initializes the data structures for a quadrature rule for an element of type type.
Definition: quadrature.C:28
void libMesh::QBase::init_0D ( const ElemType  type = INVALID_ELEM,
unsigned int  p_level = 0 
)
protectedvirtualinherited

Initializes the 0D quadrature rule by filling the points and weights vectors with the appropriate values.

Generally this is just one point with weight 1.

Definition at line 82 of file quadrature.C.

References libMesh::QBase::_points, and libMesh::QBase::_weights.

Referenced by libMesh::QBase::init().

84 {
85  _points.resize(1);
86  _weights.resize(1);
87  _points[0] = Point(0.);
88  _weights[0] = 1.0;
89 }
std::vector< Point > _points
The locations of the quadrature points in reference element space.
Definition: quadrature.h:335
std::vector< Real > _weights
The quadrature weights.
Definition: quadrature.h:341
void libMesh::QTrap::init_1D ( const ElemType  type = INVALID_ELEM,
unsigned int  p_level = 0 
)
privatevirtual

Initializes the 1D quadrature rule by filling the points and weights vectors with the appropriate values.

The order of the rule will be defined by the implementing class. It is assumed that derived quadrature rules will at least define the init_1D function, therefore it is pure virtual.

Implements libMesh::QBase.

Definition at line 28 of file quadrature_trap_1D.C.

References libMesh::QBase::_points, and libMesh::QBase::_weights.

Referenced by type().

30 {
31  //----------------------------------------------------------------------
32  // 1D quadrature rules
33  _points.resize(2);
34  _weights.resize(2);
35 
36  _points[0](0) = -1.;
37  _points[1](0) = 1.;
38 
39  _weights[0] = 1.;
40  _weights[1] = 1.;
41 
42  return;
43 }
std::vector< Point > _points
The locations of the quadrature points in reference element space.
Definition: quadrature.h:335
std::vector< Real > _weights
The quadrature weights.
Definition: quadrature.h:341
void libMesh::QTrap::init_2D ( const ElemType  = INVALID_ELEM,
unsigned int  = 0 
)
privatevirtual

Initializes the 2D quadrature rule by filling the points and weights vectors with the appropriate values.

The order of the rule will be defined by the implementing class. Should not be pure virtual since a derived quadrature rule may only be defined in 1D. If not redefined, gives an error (when DEBUG is defined) when called.

Reimplemented from libMesh::QBase.

Definition at line 28 of file quadrature_trap_2D.C.

References libMesh::QBase::_points, libMesh::QBase::_weights, libMesh::EDGE2, libMesh::QBase::init(), libMesh::QUAD4, libMesh::QUAD8, libMesh::QUAD9, libMesh::QUADSHELL4, libMesh::QUADSHELL8, libMesh::QBase::tensor_product_quad(), libMesh::TRI3, libMesh::TRI6, and libMesh::TRISHELL3.

Referenced by type().

30 {
31 #if LIBMESH_DIM > 1
32 
33  //-----------------------------------------------------------------------
34  // 2D quadrature rules
35  switch (type_in)
36  {
37 
38 
39  //---------------------------------------------
40  // Quadrilateral quadrature rules
41  case QUAD4:
42  case QUADSHELL4:
43  case QUAD8:
44  case QUADSHELL8:
45  case QUAD9:
46  {
47 
48  // We compute the 2D quadrature rule as a tensor
49  // product of the 1D quadrature rule.
50  QTrap q1D(1);
51  q1D.init(EDGE2);
52 
53  tensor_product_quad( q1D );
54 
55  return;
56  }
57 
58 
59  //---------------------------------------------
60  // Triangle quadrature rules
61  case TRI3:
62  case TRISHELL3:
63  case TRI6:
64  {
65  _points.resize(3);
66  _weights.resize(3);
67 
68  _points[0](0) = 0.;
69  _points[0](1) = 0.;
70 
71  _points[1](0) = 1.;
72  _points[1](1) = 0.;
73 
74  _points[2](0) = 0.;
75  _points[2](1) = 1.;
76 
77 
78  _weights[0] = 1./6.;
79  _weights[1] = 1./6.;
80  _weights[2] = 1./6.;
81 
82  return;
83  }
84 
85 
86  //---------------------------------------------
87  // Unsupported type
88  default:
89  libmesh_error_msg("Element type not supported!:" << type_in);
90  }
91 #endif
92 }
QTrap(const unsigned int _dim, const Order o=FIRST)
Constructor.
std::vector< Point > _points
The locations of the quadrature points in reference element space.
Definition: quadrature.h:335
std::vector< Real > _weights
The quadrature weights.
Definition: quadrature.h:341
void tensor_product_quad(const QBase &q1D)
Constructs a 2D rule from the tensor product of q1D with itself.
Definition: quadrature.C:127
void libMesh::QTrap::init_3D ( const ElemType  = INVALID_ELEM,
unsigned int  = 0 
)
privatevirtual

Initializes the 3D quadrature rule by filling the points and weights vectors with the appropriate values.

The order of the rule will be defined by the implementing class. Should not be pure virtual since a derived quadrature rule may only be defined in 1D. If not redefined, gives an error (when DEBUG is defined) when called.

Reimplemented from libMesh::QBase.

Definition at line 30 of file quadrature_trap_3D.C.

References libMesh::QBase::_points, libMesh::QBase::_weights, libMesh::EDGE2, libMesh::HEX20, libMesh::HEX27, libMesh::HEX8, libMesh::QBase::init(), libMesh::PRISM15, libMesh::PRISM18, libMesh::PRISM6, libMesh::QBase::tensor_product_hex(), libMesh::QBase::tensor_product_prism(), libMesh::TET10, libMesh::TET4, and libMesh::TRI3.

Referenced by type().

32 {
33 #if LIBMESH_DIM == 3
34 
35  //-----------------------------------------------------------------------
36  // 3D quadrature rules
37  switch (type_in)
38  {
39  //---------------------------------------------
40  // Hex quadrature rules
41  case HEX8:
42  case HEX20:
43  case HEX27:
44  {
45  // We compute the 3D quadrature rule as a tensor
46  // product of the 1D quadrature rule.
47  QTrap q1D(1);
48  q1D.init(EDGE2);
49 
50  tensor_product_hex( q1D );
51 
52  return;
53  }
54 
55 
56 
57  //---------------------------------------------
58  // Tetrahedral quadrature rules
59  case TET4:
60  case TET10:
61  {
62  _points.resize(4);
63  _weights.resize(4);
64 
65  _points[0](0) = 0.;
66  _points[0](1) = 0.;
67  _points[0](2) = 0.;
68 
69  _points[1](0) = 1.;
70  _points[1](1) = 0.;
71  _points[1](2) = 0.;
72 
73  _points[2](0) = 0.;
74  _points[2](1) = 1.;
75  _points[2](2) = 0.;
76 
77  _points[3](0) = 0.;
78  _points[3](1) = 0.;
79  _points[3](2) = 1.;
80 
81 
82 
83  _weights[0] = .0416666666666666666666666666666666666666666667;
84  _weights[1] = _weights[0];
85  _weights[2] = _weights[0];
86  _weights[3] = _weights[0];
87 
88  return;
89  }
90 
91 
92 
93  //---------------------------------------------
94  // Prism quadrature rules
95  case PRISM6:
96  case PRISM15:
97  case PRISM18:
98  {
99  // We compute the 3D quadrature rule as a tensor
100  // product of the 1D quadrature rule and a 2D
101  // triangle quadrature rule
102 
103  QTrap q1D(1);
104  QTrap q2D(2);
105 
106  // Initialize
107  q1D.init(EDGE2);
108  q2D.init(TRI3);
109 
110  tensor_product_prism(q1D, q2D);
111 
112  return;
113  }
114 
115 
116  //---------------------------------------------
117  // Unsupported type
118  default:
119  libmesh_error_msg("ERROR: Unsupported type: " << type_in);
120  }
121 #endif
122 }
QTrap(const unsigned int _dim, const Order o=FIRST)
Constructor.
std::vector< Point > _points
The locations of the quadrature points in reference element space.
Definition: quadrature.h:335
std::vector< Real > _weights
The quadrature weights.
Definition: quadrature.h:341
void tensor_product_prism(const QBase &q1D, const QBase &q2D)
Computes the tensor product of a 1D quadrature rule and a 2D quadrature rule.
Definition: quadrature.C:181
void tensor_product_hex(const QBase &q1D)
Computes the tensor product quadrature rule [q1D x q1D x q1D] from the 1D rule q1D.
Definition: quadrature.C:154
static unsigned int libMesh::ReferenceCounter::n_objects ( )
staticinherited
unsigned int libMesh::QBase::n_points ( ) const
inherited
Returns
The number of points associated with the quadrature rule.

Definition at line 113 of file quadrature.h.

References libMesh::QBase::_points, and libMesh::libmesh_assert().

Referenced by libMesh::ExactSolution::_compute_error(), assemble(), assemble_1D(), assemble_ellipticdg(), assemble_helmholtz(), assemble_poisson(), assemble_shell(), assemble_wave(), AssemblyA0::boundary_assembly(), AssemblyF0::boundary_assembly(), AssemblyA1::boundary_assembly(), AssemblyF1::boundary_assembly(), AssemblyF2::boundary_assembly(), A2::boundary_assembly(), AssemblyA2::boundary_assembly(), A3::boundary_assembly(), F0::boundary_assembly(), Output0::boundary_assembly(), libMesh::System::calculate_norm(), libMesh::FirstOrderUnsteadySolver::compute_second_order_eqns(), SecondOrderScalarSystemSecondOrderTimeSolverBase::damping_residual(), SecondOrderScalarSystemFirstOrderTimeSolverBase::damping_residual(), NavierSystem::element_constraint(), CoupledSystem::element_constraint(), PoissonSystem::element_postprocess(), LaplaceSystem::element_postprocess(), LaplaceQoI::element_qoi(), LaplaceQoI::element_qoi_derivative(), LaplaceSystem::element_qoi_derivative(), HeatSystem::element_qoi_derivative(), NavierSystem::element_time_derivative(), SolidSystem::element_time_derivative(), L2System::element_time_derivative(), PoissonSystem::element_time_derivative(), LaplaceSystem::element_time_derivative(), CurlCurlSystem::element_time_derivative(), ElasticitySystem::element_time_derivative(), CoupledSystem::element_time_derivative(), FirstOrderScalarSystemBase::element_time_derivative(), SecondOrderScalarSystemFirstOrderTimeSolverBase::element_time_derivative(), libMesh::RBEIMConstruction::enrich_RB_space(), LaplaceSystem::init_dirichlet_bcs(), B::interior_assembly(), A0::interior_assembly(), M0::interior_assembly(), A1::interior_assembly(), AssemblyA0::interior_assembly(), EIM_IP_assembly::interior_assembly(), AcousticsInnerProduct::interior_assembly(), AssemblyA1::interior_assembly(), A2::interior_assembly(), AssemblyA2::interior_assembly(), EIM_F::interior_assembly(), F0::interior_assembly(), OutputAssembly::interior_assembly(), InnerProductAssembly::interior_assembly(), AssemblyEIM::interior_assembly(), AssemblyF0::interior_assembly(), AssemblyF1::interior_assembly(), Ex6InnerProduct::interior_assembly(), Ex6EIMInnerProduct::interior_assembly(), LaplaceYoung::jacobian(), NavierSystem::mass_residual(), ElasticitySystem::mass_residual(), libMesh::FEMPhysics::mass_residual(), FirstOrderScalarSystemBase::mass_residual(), SecondOrderScalarSystemSecondOrderTimeSolverBase::mass_residual(), SecondOrderScalarSystemFirstOrderTimeSolverBase::mass_residual(), libMesh::QBase::print_info(), LaplaceYoung::residual(), LaplaceSystem::side_constraint(), LaplaceSystem::side_postprocess(), CoupledSystemQoI::side_qoi(), CoupledSystemQoI::side_qoi_derivative(), LaplaceSystem::side_qoi_derivative(), SolidSystem::side_time_derivative(), CurlCurlSystem::side_time_derivative(), ElasticitySystem::side_time_derivative(), libMesh::QBase::tensor_product_hex(), libMesh::QBase::tensor_product_prism(), libMesh::QBase::tensor_product_quad(), and libMesh::RBEIMConstruction::truth_solve().

114  {
115  libmesh_assert (!_points.empty());
116  return cast_int<unsigned int>(_points.size());
117  }
std::vector< Point > _points
The locations of the quadrature points in reference element space.
Definition: quadrature.h:335
libmesh_assert(j)
void libMesh::ReferenceCounter::print_info ( std::ostream &  out = libMesh::out)
staticinherited

Prints the reference information, by default to libMesh::out.

Definition at line 88 of file reference_counter.C.

References libMesh::ReferenceCounter::_enable_print_counter, and libMesh::ReferenceCounter::get_info().

Referenced by libMesh::LibMeshInit::LibMeshInit().

89 {
91  out_stream << ReferenceCounter::get_info();
92 }
static std::string get_info()
Gets a string containing the reference information.
static bool _enable_print_counter
Flag to control whether reference count information is printed when print_info is called...
void libMesh::QBase::print_info ( std::ostream &  os = libMesh::out) const
inherited

Prints information relevant to the quadrature rule, by default to libMesh::out.

Definition at line 364 of file quadrature.h.

References libMesh::QBase::_points, libMesh::QBase::_weights, libMesh::libmesh_assert(), libMesh::QBase::n_points(), and libMesh::Real.

Referenced by libMesh::QBase::get_order(), and libMesh::operator<<().

365 {
366  libmesh_assert(!_points.empty());
367  libmesh_assert(!_weights.empty());
368 
369  Real summed_weights=0;
370  os << "N_Q_Points=" << this->n_points() << std::endl << std::endl;
371  for (unsigned int qpoint=0; qpoint<this->n_points(); qpoint++)
372  {
373  os << " Point " << qpoint << ":\n"
374  << " "
375  << _points[qpoint]
376  << "\n Weight:\n "
377  << " w=" << _weights[qpoint] << "\n" << std::endl;
378 
379  summed_weights += _weights[qpoint];
380  }
381  os << "Summed Weights: " << summed_weights << std::endl;
382 }
std::vector< Point > _points
The locations of the quadrature points in reference element space.
Definition: quadrature.h:335
std::vector< Real > _weights
The quadrature weights.
Definition: quadrature.h:341
libmesh_assert(j)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
unsigned int n_points() const
Definition: quadrature.h:113
Point libMesh::QBase::qp ( const unsigned int  i) const
inherited
Returns
The $ i^{th} $ quadrature point in reference element space.

Definition at line 151 of file quadrature.h.

References libMesh::QBase::_points.

Referenced by libMesh::QBase::tensor_product_hex(), libMesh::QBase::tensor_product_prism(), and libMesh::QBase::tensor_product_quad().

152  {
153  libmesh_assert_less (i, _points.size());
154  return _points[i];
155  }
std::vector< Point > _points
The locations of the quadrature points in reference element space.
Definition: quadrature.h:335
void libMesh::QBase::scale ( std::pair< Real, Real old_range,
std::pair< Real, Real new_range 
)
inherited

Maps the points of a 1D quadrature rule defined by "old_range" to another 1D interval defined by "new_range" and scales the weights accordingly.

Definition at line 93 of file quadrature.C.

References libMesh::QBase::_dim, libMesh::QBase::_points, libMesh::QBase::_weights, and libMesh::Real.

Referenced by libMesh::QBase::get_order().

95 {
96  // Make sure we are in 1D
97  libmesh_assert_equal_to (_dim, 1);
98 
99  Real
100  h_new = new_range.second - new_range.first,
101  h_old = old_range.second - old_range.first;
102 
103  // Make sure that we have sane ranges
104  libmesh_assert_greater (h_new, 0.);
105  libmesh_assert_greater (h_old, 0.);
106 
107  // Make sure there are some points
108  libmesh_assert_greater (_points.size(), 0);
109 
110  // Compute the scale factor
111  Real scfact = h_new/h_old;
112 
113  // We're mapping from old_range -> new_range
114  for (std::size_t i=0; i<_points.size(); i++)
115  {
116  _points[i](0) = new_range.first +
117  (_points[i](0) - old_range.first) * scfact;
118 
119  // Scale the weights
120  _weights[i] *= scfact;
121  }
122 }
const unsigned int _dim
The spatial dimension of the quadrature rule.
Definition: quadrature.h:311
std::vector< Point > _points
The locations of the quadrature points in reference element space.
Definition: quadrature.h:335
std::vector< Real > _weights
The quadrature weights.
Definition: quadrature.h:341
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual bool libMesh::QBase::shapes_need_reinit ( )
virtualinherited
Returns
true if the shape functions need to be recalculated, false otherwise.

This may be required if the number of quadrature points or their position changes.

Definition at line 217 of file quadrature.h.

217 { return false; }
void libMesh::QBase::tensor_product_hex ( const QBase q1D)
protectedinherited

Computes the tensor product quadrature rule [q1D x q1D x q1D] from the 1D rule q1D.

Used in the init_3D routines for hexahedral element types.

Definition at line 154 of file quadrature.C.

References libMesh::QBase::_points, libMesh::QBase::_weights, libMesh::QBase::n_points(), libMesh::QBase::qp(), and libMesh::QBase::w().

Referenced by init_3D(), libMesh::QGauss::init_3D(), libMesh::QSimpson::init_3D(), and libMesh::QBase::init_3D().

155 {
156  const unsigned int np = q1D.n_points();
157 
158  _points.resize(np * np * np);
159 
160  _weights.resize(np * np * np);
161 
162  unsigned int q=0;
163 
164  for (unsigned int k=0; k<np; k++)
165  for (unsigned int j=0; j<np; j++)
166  for (unsigned int i=0; i<np; i++)
167  {
168  _points[q](0) = q1D.qp(i)(0);
169  _points[q](1) = q1D.qp(j)(0);
170  _points[q](2) = q1D.qp(k)(0);
171 
172  _weights[q] = q1D.w(i) * q1D.w(j) * q1D.w(k);
173 
174  q++;
175  }
176 }
std::vector< Point > _points
The locations of the quadrature points in reference element space.
Definition: quadrature.h:335
std::vector< Real > _weights
The quadrature weights.
Definition: quadrature.h:341
void libMesh::QBase::tensor_product_prism ( const QBase q1D,
const QBase q2D 
)
protectedinherited

Computes the tensor product of a 1D quadrature rule and a 2D quadrature rule.

Used in the init_3D routines for prismatic element types.

Definition at line 181 of file quadrature.C.

References libMesh::QBase::_points, libMesh::QBase::_weights, libMesh::QBase::n_points(), libMesh::QBase::qp(), and libMesh::QBase::w().

Referenced by init_3D(), libMesh::QGauss::init_3D(), libMesh::QSimpson::init_3D(), and libMesh::QBase::init_3D().

182 {
183  const unsigned int n_points1D = q1D.n_points();
184  const unsigned int n_points2D = q2D.n_points();
185 
186  _points.resize (n_points1D * n_points2D);
187  _weights.resize (n_points1D * n_points2D);
188 
189  unsigned int q=0;
190 
191  for (unsigned int j=0; j<n_points1D; j++)
192  for (unsigned int i=0; i<n_points2D; i++)
193  {
194  _points[q](0) = q2D.qp(i)(0);
195  _points[q](1) = q2D.qp(i)(1);
196  _points[q](2) = q1D.qp(j)(0);
197 
198  _weights[q] = q2D.w(i) * q1D.w(j);
199 
200  q++;
201  }
202 
203 }
std::vector< Point > _points
The locations of the quadrature points in reference element space.
Definition: quadrature.h:335
std::vector< Real > _weights
The quadrature weights.
Definition: quadrature.h:341
void libMesh::QBase::tensor_product_quad ( const QBase q1D)
protectedinherited

Constructs a 2D rule from the tensor product of q1D with itself.

Used in the init_2D() routines for quadrilateral element types.

Definition at line 127 of file quadrature.C.

References libMesh::QBase::_points, libMesh::QBase::_weights, libMesh::QBase::n_points(), libMesh::QBase::qp(), and libMesh::QBase::w().

Referenced by init_2D(), libMesh::QGauss::init_2D(), libMesh::QSimpson::init_2D(), and libMesh::QBase::init_3D().

128 {
129 
130  const unsigned int np = q1D.n_points();
131 
132  _points.resize(np * np);
133 
134  _weights.resize(np * np);
135 
136  unsigned int q=0;
137 
138  for (unsigned int j=0; j<np; j++)
139  for (unsigned int i=0; i<np; i++)
140  {
141  _points[q](0) = q1D.qp(i)(0);
142  _points[q](1) = q1D.qp(j)(0);
143 
144  _weights[q] = q1D.w(i)*q1D.w(j);
145 
146  q++;
147  }
148 }
std::vector< Point > _points
The locations of the quadrature points in reference element space.
Definition: quadrature.h:335
std::vector< Real > _weights
The quadrature weights.
Definition: quadrature.h:341
virtual QuadratureType libMesh::QTrap::type ( ) const
virtual
Returns
QTRAP.

Implements libMesh::QBase.

Definition at line 68 of file quadrature_trap.h.

References libMesh::QBase::_type, init_1D(), init_2D(), init_3D(), libMesh::INVALID_ELEM, and libMesh::QTRAP.

68 { return QTRAP; }
Real libMesh::QBase::w ( const unsigned int  i) const
inherited
Returns
The $ i^{th} $ quadrature weight.

Definition at line 160 of file quadrature.h.

References libMesh::QBase::_weights, libMesh::QBase::init(), libMesh::INVALID_ELEM, and libMesh::QBase::type().

Referenced by libMesh::QBase::tensor_product_hex(), libMesh::QBase::tensor_product_prism(), and libMesh::QBase::tensor_product_quad().

161  {
162  libmesh_assert_less (i, _weights.size());
163  return _weights[i];
164  }
std::vector< Real > _weights
The quadrature weights.
Definition: quadrature.h:341

Member Data Documentation

ReferenceCounter::Counts libMesh::ReferenceCounter::_counts
staticprotectedinherited
const unsigned int libMesh::QBase::_dim
protectedinherited

The spatial dimension of the quadrature rule.

Definition at line 311 of file quadrature.h.

Referenced by libMesh::QBase::get_dim(), libMesh::QBase::init(), and libMesh::QBase::scale().

bool libMesh::ReferenceCounter::_enable_print_counter = true
staticprotectedinherited

Flag to control whether reference count information is printed when print_info is called.

Definition at line 143 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::disable_print_counter_info(), libMesh::ReferenceCounter::enable_print_counter_info(), and libMesh::ReferenceCounter::print_info().

Threads::spin_mutex libMesh::ReferenceCounter::_mutex
staticprotectedinherited

Mutual exclusion object to enable thread-safe reference counting.

Definition at line 137 of file reference_counter.h.

Threads::atomic< unsigned int > libMesh::ReferenceCounter::_n_objects
staticprotectedinherited

The number of objects.

Print the reference count information when the number returns to 0.

Definition at line 132 of file reference_counter.h.

Referenced by libMesh::ReferenceCounter::n_objects(), libMesh::ReferenceCounter::ReferenceCounter(), and libMesh::ReferenceCounter::~ReferenceCounter().

const Order libMesh::QBase::_order
protectedinherited

The polynomial order which the quadrature rule is capable of integrating exactly.

Definition at line 317 of file quadrature.h.

Referenced by libMesh::QBase::get_order(), libMesh::QGauss::init_1D(), libMesh::QGauss::init_2D(), and libMesh::QGauss::init_3D().

unsigned int libMesh::QBase::_p_level
protectedinherited

The p-level of the element for which the current values have been computed.

Definition at line 329 of file quadrature.h.

Referenced by libMesh::QBase::get_order(), libMesh::QBase::get_p_level(), and libMesh::QBase::init().

std::vector<Point> libMesh::QBase::_points
protectedinherited
ElemType libMesh::QBase::_type
protectedinherited

The type of element for which the current values have been computed.

Definition at line 323 of file quadrature.h.

Referenced by libMesh::QBase::get_elem_type(), libMesh::QBase::init(), type(), libMesh::QSimpson::type(), and libMesh::QGauss::type().

std::vector<Real> libMesh::QBase::_weights
protectedinherited
bool libMesh::QBase::allow_rules_with_negative_weights
inherited

Flag (default true) controlling the use of quadrature rules with negative weights.

Set this to false to require rules with all positive weights.

Rules with negative weights can be unsuitable for some problems. For example, it is possible for a rule with negative weights to obtain a negative result when integrating a positive function.

A particular example: if rules with negative weights are not allowed, a request for TET,THIRD (5 points) will return the TET,FIFTH (14 points) rule instead, nearly tripling the computational effort required!

Definition at line 232 of file quadrature.h.

Referenced by libMesh::QGauss::init_3D().


The documentation for this class was generated from the following files: