specfem::mesh::control_nodes

template<specfem::element::dimension_tag DimensionTag>
struct control_nodes

Control node information.

Struct to store control nodes.

Template Parameters:

DimensionTag – Dimension type

Dimension-Specific Specializations

template<>
struct control_nodes<specfem::element::dimension_tag::dim2>

Constructors

control_nodes() = default

Default control_nodes constructor.

inline control_nodes(const int &ndim, const int &nspec, const int &ngnod, const int &npgeo)

Construct a new control_nodes object.

Parameters:
  • ndim – Number of dimensions

  • nspec – Number of spectral elements

  • ngnod – Number of control nodes

  • npgeo – Number of spectral element control nodes

Public Members

int ngnod

Number of control nodes.

int nspec

Number of spectral elements.

Kokkos::View<int**, Kokkos::HostSpace> knods

Control node indices.

ViewType coord

Coordinates for control nodes.

template<>
struct control_nodes<specfem::element::dimension_tag::dim3>

Container for control nodes used in 3D mesh generation with meshfem3D.

The control_nodes class manages coordinate data for control nodes that define the geometric structure of a 3D spectral element mesh generated by meshfem3D.

// Example: Reading control nodes from meshfem3D file
using control_nodes3D =
specfem::mesh::control_nodes<specfem::element::dimension_tag::dim3>;

// Read from binary file using IO routine
// The following code is only used internally by the IO module
auto control_nodes =
specfem::io::mesh::impl::fortran::dim3::meshfem3d::read_control_nodes(stream);

// Access node coordinates
type_real x = control_nodes.coordinates(node_id, 0);  // x-coordinate
type_real y = control_nodes.coordinates(node_id, 1);  // y-coordinate
type_real z = control_nodes.coordinates(node_id, 2);  // z-coordinate

See also

specfem::io::mesh::impl::fortran::dim3::meshfem3d::read_control_nodes

See also

specfem::mesh::control_nodes (for general 2D control nodes)

Template Parameters:

Dimension – Spatial dimension tag (must be dim3 for meshfem3D)

Public Functions

control_nodes() = default

Default constructor.

Creates an uninitialized control_nodes object with no allocated storage. The nnodes count and coordinates view remain in default state.

~control_nodes() = default

Destructor.

Automatically releases Kokkos view resources through RAII.

inline control_nodes(int ngnod_, int nnodes_)

Constructs control_nodes with specified node count for meshfem3D.

Allocates storage for the given number of control nodes read from meshfem3D binary files. Each node stores three coordinate components (x, y, z). This constructor is typically called by IO routines when reading control node data from meshfem3D output files.

The coordinates are populated by reading from the binary file in the format:

  • node_index, x_coord, y_coord, z_coord (repeated for each node)

// Typical usage in IO routine:
int nnodes;
specfem::io::read_fortran_line(stream, &nnodes);  // Read node count from
file control_nodes<specfem::element::dimension_tag::dim3>
control_nodes(nnodes);

// Then populate coordinates from file
for (int inode = 0; inode < nnodes; ++inode) {
  int index;
  type_real x, y, z;
  specfem::io::read_fortran_line(stream, &index, &x, &y, &z);
  control_nodes.coordinates(inode, 0) = x;
  control_nodes.coordinates(inode, 1) = y;
  control_nodes.coordinates(inode, 2) = z;
}

Parameters:

nnodes_ – Number of control nodes to allocate storage for (read from file header)

Public Members

int nnodes

Number of control nodes stored.

Represents the total count of control nodes defining the mesh geometry. This value determines the first dimension of the coordinates view.

int ngnod

Number of control nodes per spectral element.

Indicates how many control nodes define each spectral element in the mesh. Typical values are 8 for hexahedral elements and 27 for trilinear elements. This value determines the second dimension of the control_node_index view.

int nspec

Number of spectral elements in the mesh.

Represents the total count of spectral elements. This value determines the first dimension of the control_node_index view.

type_real xmax

Minimum and maximum x-coordinates of control nodes.

type_real ymax

Minimum and maximum y-coordinates of control nodes.

type_real zmax

Minimum and maximum z-coordinates of control nodes.

CoordinatesViewType coordinates

3D coordinates of all control nodes.

Two-dimensional Kokkos view storing spatial coordinates with layout:

  • coordinates(i, 0): x-coordinate of node i

  • coordinates(i, 1): y-coordinate of node i

  • coordinates(i, 2): z-coordinate of node i

The view uses column-major ordering (LayoutLeft) for optimal memory access patterns during mesh generation algorithms.

// Access coordinates
type_real x = nodes.coordinates(node_id, 0);
type_real y = nodes.coordinates(node_id, 1);
type_real z = nodes.coordinates(node_id, 2);

// Set coordinates
nodes.coordinates(node_id, 0) = 1.5;  // x
nodes.coordinates(node_id, 1) = 2.0;  // y
nodes.coordinates(node_id, 2) = 0.5;  // z
ControlNodeIndexViewType control_node_index

Control node indices for each spectral element.

Two-dimensional Kokkos view storing control node indices for each spectral element with layout:

  • control_node_index(i, j): index of the j-th control node for element i

The view uses column-major ordering (LayoutLeft) for optimal memory access patterns during mesh generation algorithms.

// Access control node index for element and local node
int node_index = nodes.control_node_index(element_id, local_node_id);

// Set control node index
nodes.control_node_index(element_id, local_node_id) = new_node_index;

Public Static Attributes

static constexpr auto dimension_tag = specfem::element::dimension_tag::dim3

Dimension tag identifying the spatial context.

Static constant providing access to the template parameter for compile-time dimension queries and type traits.

Private Types

using CoordinatesViewType = Kokkos::View<type_real*[3], Kokkos::LayoutLeft, Kokkos::HostSpace>

Compile-time dimension value extracted from template parameter.

Kokkos view type for storing node coordinates.

Two-dimensional view with layout [nnodes][3] storing xyz coordinates. Uses LayoutLeft for column-major ordering and HostSpace for CPU memory.

using ControlNodeIndexViewType = Kokkos::View<int**, Kokkos::LayoutLeft, Kokkos::HostSpace>

Kokkos view type for storing control node indices for elements.

Two-dimensional view with layout [nspec][ngnod] storing control node indices for each spectral element.