Serac  0.1
Serac is an implicit thermal strucural mechanics simulation code.
quadrature.hpp
Go to the documentation of this file.
1 // Copyright (c) 2019-2024, Lawrence Livermore National Security, LLC and
2 // other Serac Project Developers. See the top-level LICENSE file for
3 // details.
4 //
5 // SPDX-License-Identifier: (BSD-3-Clause)
6 
13 #pragma once
14 
15 #include "tensor.hpp"
16 #include "polynomials.hpp"
17 #include "finite_element.hpp"
18 
19 namespace serac {
20 
27 template <int n, int dim>
31 
34 
36  SERAC_HOST_DEVICE constexpr std::size_t size() const { return n; }
37 };
38 
44 template <mfem::Geometry::Type g, int Q>
46 {
47  auto x = GaussLegendreNodes<Q, mfem::Geometry::SEGMENT>();
48  auto w = GaussLegendreWeights<Q, mfem::Geometry::SEGMENT>();
49 
50  if constexpr (g == mfem::Geometry::SEGMENT) {
51  return QuadratureRule<Q, 1>{w, make_tensor<Q, 1>([&x](int i, int /*j*/) { return x[i]; })};
52  }
53 
54  if constexpr (g == mfem::Geometry::SQUARE) {
56  int count = 0;
57  for (int j = 0; j < Q; j++) {
58  for (int i = 0; i < Q; i++) {
59  rule.points[count] = {x[i], x[j]};
60  rule.weights[count++] = w[i] * w[j];
61  }
62  }
63  return rule;
64  }
65 
66  if constexpr (g == mfem::Geometry::CUBE) {
68  int count = 0;
69  for (int k = 0; k < Q; k++) {
70  for (int j = 0; j < Q; j++) {
71  for (int i = 0; i < Q; i++) {
72  rule.points[count] = {x[i], x[j], x[k]};
73  rule.weights[count++] = w[i] * w[j] * w[k];
74  }
75  }
76  }
77  return rule;
78  }
79 }
80 
81 } // namespace serac
#define SERAC_HOST_DEVICE
Macro that evaluates to __host__ __device__ when compiling with nvcc and does nothing on a host compi...
Definition: accelerator.hpp:38
This file contains helper traits and enumerations for classifying finite elements.
Accelerator functionality.
Definition: serac.cpp:38
constexpr SERAC_HOST_DEVICE auto GaussQuadratureRule()
Returns the Gauss-Legendre quadrature rule for an element and order.
Definition: quadrature.hpp:45
Definitions of 1D quadrature weights and node locations and polynomial basis functions.
A rule for numerical quadrature (set of points and weights) Can be thought of as a compile-time analo...
Definition: quadrature.hpp:28
tensor< double, n > weights
The scalar weights of each point.
Definition: quadrature.hpp:30
constexpr SERAC_HOST_DEVICE std::size_t size() const
Returns the number of points in the rule.
Definition: quadrature.hpp:36
tensor< double, n, dim > points
The coordinates in reference space for each quadrature point.
Definition: quadrature.hpp:33
Implementation of the tensor class used by Functional.