specfem::assembly::assembly

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

Data class used to store computational data required for SEM simulations.

Provides classes to transform mesher-supplied element data and compute per-GLL-point values. The per-GLL-point data is stored in Kokkos::Views which provide portability & data management across CPU and GPU architectures. The assembly class is specialized for 2D and 3D problems.

Dimension-Specific Implementations

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

Specialization of the assembly class for 2D SEM simulations.

Provides 2D specializations for containers used to store simulation data required for & computed during 2D SEM simulations

Public Constants

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

Dimension tag.

Data Containers

Data containers used to store computation data required for different terms in the constitutive equations

specfem::assembly::mesh<dimension_tag> mesh

Properties of the assembled mesh.

specfem::assembly::element_types<dimension_tag> element_types

Element types for every spectral element in the mesh.

specfem::assembly::element_intersections<dimension_tag> element_intersections

Element intersections for every element in the mesh.

The element intersections container stores information about the intersections between elements in the mesh (e.g., internal faces, boundary faces).

specfem::assembly::jacobian_matrix<dimension_tag> jacobian_matrix

Partial derivatives of the basis functions at every quadrature point.

specfem::assembly::FieldDerivativeStorage<dimension_tag> field_derivative_storage

Storage for field derivatives at every quadrature point for elements that require it (e.g., attenuating elements).

specfem::assembly::Attenuation<dimension_tag> attenuation

Attenuation properties for the mesh at every quadrature point.

specfem::assembly::properties<dimension_tag> properties

Material properties for the mesh at every quadrature point.

specfem::assembly::kernels<dimension_tag> kernels

Misfit kernels (Frechet derivatives) computed at every quadrature point during adjoint simulations. The container is empty for forward simulations.

specfem::assembly::sources<dimension_tag> sources

Information about sources, locations, source time functions, lagrange interpolation, etc.

specfem::assembly::receivers<dimension_tag> receivers

Information about receivers, locations, seismogram types, lagrange interpolation, etc.

specfem::assembly::boundaries<dimension_tag> boundaries

Information about boundary conditions in the mesh.

The container stores data required to implement different types of boundary conditions (e.g., for stacey boudary conditions, we store normal vectors & weight factors at every quadrature point on the boundary).

specfem::assembly::conforming_interfaces<dimension_tag> conforming_interfaces

Information about conforming interfaces between 2 media in the mesh.

The container stores data required to implement coupling terms between 2 media (e.g., fluid-solid interface).

specfem::assembly::nonconforming_interfaces<dimension_tag> nonconforming_interfaces

Information about non-conforming interfaces between 2 media in the mesh.

The container stores data required to implement coupling terms between 2 media (e.g., fluid-solid interface).

specfem::assembly::fields<dimension_tag> fields

Wavefield values at every distinct quadrature point in the mesh, \((s, \partial s / \partial t, \partial^2 s /\partial t^2)\).

specfem::assembly::boundary_values<dimension_tag> boundary_values

Field values at the boundaries at every time step.

This container stores the wavefield values at the (stacey) boundaries computed during forward simulations. The values are then used during adjoint simulations to impose boundary condition on the adjoint wavefield. The container is empty if wavefield writer is disabled. Field values at the boundaries

specfem::assembly::Info<dimension_tag> info

Info.

type_real t0

Simulation start time.

type_real dt

Time step.

Public Functions

assembly(const specfem::mesh::mesh<dimension_tag> &mesh, const specfem::quadrature::quadratures &quadratures, std::vector<std::shared_ptr<specfem::sources::source<dimension_tag>>> &sources, const std::vector<std::shared_ptr<specfem::receivers::receiver<dimension_tag>>> &receivers, const std::vector<specfem::enums::wavefield> &stypes, const type_real t0, const type_real dt, const int max_timesteps, const int max_sig_step, const int nsteps_between_samples, const specfem::simulation::type simulation, const bool allocate_boundary_values, const std::shared_ptr<specfem::io::reader> &property_reader, const specfem::element_coupling::flux_scheme_configuration &flux_scheme_config = specfem::element_coupling::flux_scheme_configuration())

Generate a finite element assembly.

Parameters:
  • mesh – Finite element mesh as read from mesher

  • quadratures – Quadrature points and weights

  • sources – Source information

  • receivers – Receiver information

  • stypes – Types of seismograms

  • t0 – Start time of simulation

  • dt – Time step

  • max_timesteps – Maximum number of time steps

  • max_sig_step – Maximum number of seismogram time steps

  • nstep_between_samples – Number of time steps between output seismogram samples

  • simulation – Type of simulation (forward, adjoint, etc.)

  • write_wavefield – Whether to write wavefield

  • property_reader – Reader for GLL model (skip material property assignment if exists)

  • flux_scheme_config – Flux scheme rules for nonconforming interfaces

Kokkos::View<type_real****, Kokkos::LayoutLeft, Kokkos::HostSpace> generate_wavefield_on_entire_grid(const specfem::simulation::field_type wavefield, const specfem::enums::wavefield component)

Maps the component of wavefield on the entire spectral element grid.

This field can be used to generate a plot of the wavefield

Parameters:

component – Component of the wavefield to map

Returns:

Kokkos::View<type_real ***, Kokkos::LayoutLeft, Kokkos::HostSpace> Wavefield mapped on the entire grid. Dimensions of the view are nspec, ngllz, ngllx

inline int get_total_number_of_elements() const

Get the total number of spectral elements in the mesh.

Returns:

int Total number of spectral elements

inline int get_total_degrees_of_freedom()

Get the total number of degrees of freedom in the mesh.

Returns:

int Total number of degrees of freedom

std::string print() const

Print assembly information.

Generates a formatted string containing relevant information about the assembly. This information is logged into the output of the simulation.

Returns:

std::string Assembly information as a string

void check_jacobian_matrix() const

Check if Jacobian for any spectral element in the mesh is smaller than some threshold.

This function throws a runtime error if the Jacobian is smaller than 1e-10 If VTK is enabled, it also generates a plot of the spectral elements with small Jacobian

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

Specialization of the assembly class for 3D SEM simulations.

Provides 3D specializations for containers used to store simulation data required for & computed during 3D SEM simulations

Public Constants

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

Dimension tag.

Data Containers

Data containers used to store computation data required for different terms in the constitutive equations

specfem::assembly::mesh<dimension_tag> mesh

Properties of the assembled mesh.

specfem::assembly::element_types<dimension_tag> element_types

Element types for every spectral element in the mesh.

specfem::assembly::element_intersections<dimension_tag> element_intersections

Element intersections for different types of interfaces between two media (e.g., fluid-solid interface).

specfem::assembly::jacobian_matrix<dimension_tag> jacobian_matrix

Partial derivatives of the basis functions at every quadrature point.

specfem::assembly::FieldDerivativeStorage<dimension_tag> field_derivative_storage

Storage for field derivatives at every quadrature point for elements that require it (e.g., attenuating elements).

specfem::assembly::Attenuation<dimension_tag> attenuation

Attenuation properties for the mesh at every quadrature point.

specfem::assembly::properties<dimension_tag> properties

Material properties for the mesh at every quadrature point.

specfem::assembly::kernels<dimension_tag> kernels

Misfit kernels (Frechet derivatives) computed at every quadrature point during adjoint simulations. The container is empty for forward simulations.

specfem::assembly::sources<dimension_tag> sources

Information about sources, locations, source time functions, lagrange interpolation, etc.

specfem::assembly::receivers<dimension_tag> receivers

Information about receivers, locations, seismogram types, lagrange interpolation, etc.

specfem::assembly::fields<dimension_tag> fields

Wavefield values at every distinct quadrature point in the mesh, \((s, \partial s / \partial t, \partial^2 s /\partial t^2)\).

specfem::assembly::boundaries<dimension_tag> boundaries

Boundary conditions

specfem::assembly::conforming_interfaces<dimension_tag> conforming_interfaces

Conforming interfaces between different media (e.g., fluid-solid interface)

specfem::assembly::boundary_values<dimension_tag> boundary_values

Field values at the boundaries

specfem::assembly::Info<dimension_tag> info

Information about the mesh and simulation

specfem::assembly::mpi<dimension_tag> mpi_interfaces

MPI communication groups for face data exchange between partitions

type_real t0

Simulation start time.

type_real dt

Time step.

Public Functions

assembly(const specfem::mesh::mesh<dimension_tag> &mesh, const specfem::quadrature::quadratures &quadratures, std::vector<std::shared_ptr<specfem::sources::source<dimension_tag>>> &sources, const std::vector<std::shared_ptr<specfem::receivers::receiver<dimension_tag>>> &receivers, const std::vector<specfem::enums::wavefield> &stypes, const type_real t0, const type_real dt, const int max_timesteps, const int max_sig_step, const int nsteps_between_samples, const specfem::simulation::type simulation, const bool allocate_boundary_values, const std::shared_ptr<specfem::io::reader> &property_reader, const specfem::element_coupling::flux_scheme_configuration &flux_scheme_config = specfem::element_coupling::flux_scheme_configuration())

Generate a finite element assembly.

Parameters:
  • mesh – Finite element mesh as read from mesher

  • quadratures – Quadrature points and weights

  • sources – Source information

  • receivers – Receiver information

  • stypes – Types of seismograms

  • t0 – Start time of simulation

  • dt – Time step

  • max_timesteps – Maximum number of time steps

  • max_sig_step – Maximum number of seismogram time steps

  • nstep_between_samples – Number of time steps between output seismogram samples

  • simulation – Type of simulation (forward, adjoint, etc.)

  • write_wavefield – Whether to write wavefield

  • property_reader – Reader for GLL model (skip material property assignment if exists)

  • flux_scheme_config – Flux scheme rules for nonconforming interfaces

Kokkos::View<type_real*****, Kokkos::LayoutLeft, Kokkos::HostSpace> generate_wavefield_on_entire_grid(const specfem::simulation::field_type wavefield, const specfem::enums::wavefield component)

Maps the component of wavefield on the entire spectral element grid.

This field can be used to generate a plot of the wavefield

Parameters:

component – Component of the wavefield to map

Returns:

Kokkos::View<type_real *****, Kokkos::LayoutLeft, Kokkos::HostSpace> Wavefield mapped on the entire grid. Dimensions of the view are nspec, ngllz, nglly, ngllx, ncomponents

inline int get_total_number_of_elements() const

Get the total number of spectral elements in the mesh.

Returns:

int Total number of spectral elements

inline int get_total_degrees_of_freedom()

Get the total number of degrees of freedom in the mesh.

Returns:

int Total number of degrees of freedom

std::string print() const

Print assembly information.

Generates a formatted string containing relevant information about the assembly. This information is logged into the output of the simulation.

Returns:

std::string Assembly information as a string

void check_jacobian_matrix() const

Check if Jacobian for any spectral element in the mesh is smaller than some threshold.

This function throws a runtime error if the Jacobian is smaller than 1e-10 If VTK is enabled, it also generates a plot of the spectral elements with small Jacobian