specfem::point::displacement¶
-
template<specfem::dimension::type DimensionTag, specfem::element::medium_tag MediumTag, bool UseSIMD>
class displacement : public specfem::point::impl::field<DimensionTag, MediumTag, specfem::data_access::DataClassType::displacement, UseSIMD>¶ Point displacement field accessor for spectral element computations.
This class provides a specialized interface for accessing and manipulating displacement field data at individual points within spectral elements. It inherits all functionality from the base field implementation while being specifically typed for displacement data.
The displacement class is fundamental in wave propagation simulations, representing the spatial displacement of material points from their reference positions. It is commonly used in both elastic and poroelastic media simulations.
// Example: Creating 3D elastic displacement field accessor using DispField = specfem::point::displacement< specfem::dimension::type::dim3, specfem::element::medium_tag::elastic, true>; // Enable SIMD // Initialize with zero displacement DispField disp(0.0); // Set displacement components disp(0) = 0.001; // x-component displacement (meters) disp(1) = 0.002; // y-component displacement disp(2) = 0.003; // z-component displacement // Use in assembly operations specfem::assembly::store_on_device(point_index, field_container, disp);
’// Example: Computing strain from displacement gradients DispField displacement; specfem::assembly::load_on_device(index, fields, displacement); // Access displacement components for strain computation auto ux = displacement(0); auto uy = displacement(1); auto uz = displacement(2); // Strain components would be computed from spatial derivatives // (implementation depends on quadrature and differentiation operators)
See also
specfem::point::velocity for velocity field accessor
See also
specfem::point::acceleration for acceleration field accessor
See also
specfem::point::mass_inverse for inverse mass matrix field accessor
- Template Parameters:
DimensionTag – The spatial dimension (dim2 or dim3) of the displacement field
MediumTag – The medium type (acoustic, elastic, poroelastic, etc.)
UseSIMD – Whether to enable SIMD vectorization for performance optimization
Public Types
-
using simd = typename base_type::simd¶
SIMD type for vectorized displacement operations.
-
using value_type = typename base_type::value_type¶
Vector type for storing displacement component values.
-
template<typename T>
using scalar_type = typename simd<T>::datatype¶ Scalar field storage for single point.
- Template Parameters:
T – Base data type
-
template<typename T, int dimension>
using vector_type = typename specfem::datatype::VectorPointViewType<T, dimension, UseSIMD>¶ Vector field storage for single point.
- Template Parameters:
T – Base data type
dimension – Vector dimension (2D/3D)
-
template<typename T, int components, int dimension>
using tensor_type = typename specfem::datatype::TensorPointViewType<T, components, dimension, UseSIMD>¶ Tensor field storage for single point.
- Template Parameters:
T – Base data type
components – Number of tensor components
dimension – Spatial dimension
Public Functions
-
inline const value_type &get_data() const¶
Access internal field data storage.
- Returns:
const reference to the internal value_type storing field components
-
inline const value_type::value_type &operator()(const std::size_t icomp) const¶
Access field component by index (const version).
Provides read-only access to individual field components using zero-based indexing. For 2D problems: 0=x, 1=z. For 3D problems: 0=x, 1=y, 2=z.
DisplacementField u_field(1.5, 2.3); auto ux = u_field(0); // x-component = 1.5 auto uz = u_field(1); // z-component = 2.3
- Parameters:
icomp – Component index (0 to components-1)
- Returns:
const reference to the component value
- Pre:
icomp must be less than the number of components
-
inline value_type::value_type &operator()(const std::size_t icomp)¶
Access field component by index (mutable version).
Provides read-write access to individual field components using zero-based indexing. Allows modification of field component values.
DisplacementField u_field; u_field(0) = 1.5; // Set x-component u_field(1) = 2.3; // Set z-component
- Parameters:
icomp – Component index (0 to components-1)
- Returns:
mutable reference to the component value
- Pre:
icomp must be less than the number of components
-
inline bool operator==(const field &other) const¶
Equality comparison operator.
Compares two field objects for exact equality by comparing their internal data storage.
- Parameters:
other – The field object to compare against
- Returns:
true if all components are exactly equal, false otherwise
-
inline bool operator!=(const field &other) const¶
Inequality comparison operator.
Compares two field objects for inequality.
- Parameters:
other – The field object to compare against
- Returns:
true if any component differs, false if all components are equal
-
inline constexpr auto &operator*=(const typename value_type::value_type &other)¶
Multiplication assignment operator with constant value.
Multiply by a constant value and assign the result to this field.
- Parameters:
other – The factor to be multiplied with
- Returns:
reference to this field after multiplication
-
inline std::string print() const¶
Output a string representation of the field components.
Outputs the values of all field components to the specified output stream. Each component is printed in order, enclosed in square brackets. If SIMD the SIMD values are printed in curly brackets.
Public Static Attributes
-
static constexpr int components¶
Number of field components based on dimension and medium type.
-
static constexpr auto medium_tag¶
Medium tag identifying the physical medium type.
-
static constexpr auto accessor_type = specfem::data_access::AccessorType::point¶
Accessor pattern identifier.
-
static constexpr auto data_class = DataClass¶
Data classification type.
-
static constexpr auto dimension_tag = DimensionTag¶
Spatial dimension.
specfem::point::velocity¶
-
template<specfem::dimension::type DimensionTag, specfem::element::medium_tag MediumTag, bool UseSIMD>
class velocity : public specfem::point::impl::field<DimensionTag, MediumTag, specfem::data_access::DataClassType::velocity, UseSIMD>¶ Point velocity field accessor for spectral element computations.
This class provides a specialized interface for accessing and manipulating velocity field data at individual points within spectral elements. It inherits all functionality from the base field implementation while being specifically typed for velocity data.
The velocity class represents the time derivative of displacement and is essential in time-domain wave propagation simulations. It is used in time integration schemes and for computing kinetic energy in the system.
// Example: Creating 2D acoustic velocity field accessor using VelField = specfem::point::velocity< specfem::dimension::type::dim2, specfem::element::medium_tag::acoustic, false>; // No SIMD // Initialize with zero velocity VelField vel(0.0); // Set velocity components vel(0) = 0.1; // x-component velocity (m/s) vel(1) = -0.05; // z-component velocity // Use in assembly operations specfem::assembly::load_on_device(point_index, field_container, vel);
// Example: Velocity in time integration (Newmark scheme) VelField velocity_old, velocity_new; AccelField acceleration; const double dt = 0.001; // time step const double gamma = 0.5; // Newmark parameter // Load current values specfem::assembly::load_on_device(index, fields, velocity_old, acceleration); // Update velocity using Newmark scheme for (int icomp = 0; icomp < VelField::components; ++icomp) { velocity_new(icomp) = velocity_old(icomp) + dt * gamma * acceleration(icomp); } // Store updated velocity specfem::assembly::store_on_device(index, fields, velocity_new);
See also
specfem::point::displacement for displacement field accessor
See also
specfem::point::acceleration for acceleration field accessor
See also
specfem::point::mass_inverse for inverse mass matrix field accessor
- Template Parameters:
DimensionTag – The spatial dimension (dim2 or dim3) of the velocity field
MediumTag – The medium type (acoustic, elastic, poroelastic, etc.)
UseSIMD – Whether to enable SIMD vectorization for performance optimization
Public Types
-
using simd = typename base_type::simd¶
SIMD type for vectorized velocity operations.
-
using value_type = typename base_type::value_type¶
Vector type for storing velocity component values.
-
template<typename T>
using scalar_type = typename simd<T>::datatype¶ Scalar field storage for single point.
- Template Parameters:
T – Base data type
-
template<typename T, int dimension>
using vector_type = typename specfem::datatype::VectorPointViewType<T, dimension, UseSIMD>¶ Vector field storage for single point.
- Template Parameters:
T – Base data type
dimension – Vector dimension (2D/3D)
-
template<typename T, int components, int dimension>
using tensor_type = typename specfem::datatype::TensorPointViewType<T, components, dimension, UseSIMD>¶ Tensor field storage for single point.
- Template Parameters:
T – Base data type
components – Number of tensor components
dimension – Spatial dimension
Public Functions
-
inline const value_type &get_data() const¶
Access internal field data storage.
- Returns:
const reference to the internal value_type storing field components
-
inline const value_type::value_type &operator()(const std::size_t icomp) const¶
Access field component by index (const version).
Provides read-only access to individual field components using zero-based indexing. For 2D problems: 0=x, 1=z. For 3D problems: 0=x, 1=y, 2=z.
DisplacementField u_field(1.5, 2.3); auto ux = u_field(0); // x-component = 1.5 auto uz = u_field(1); // z-component = 2.3
- Parameters:
icomp – Component index (0 to components-1)
- Returns:
const reference to the component value
- Pre:
icomp must be less than the number of components
-
inline value_type::value_type &operator()(const std::size_t icomp)¶
Access field component by index (mutable version).
Provides read-write access to individual field components using zero-based indexing. Allows modification of field component values.
DisplacementField u_field; u_field(0) = 1.5; // Set x-component u_field(1) = 2.3; // Set z-component
- Parameters:
icomp – Component index (0 to components-1)
- Returns:
mutable reference to the component value
- Pre:
icomp must be less than the number of components
-
inline bool operator==(const field &other) const¶
Equality comparison operator.
Compares two field objects for exact equality by comparing their internal data storage.
- Parameters:
other – The field object to compare against
- Returns:
true if all components are exactly equal, false otherwise
-
inline bool operator!=(const field &other) const¶
Inequality comparison operator.
Compares two field objects for inequality.
- Parameters:
other – The field object to compare against
- Returns:
true if any component differs, false if all components are equal
-
inline constexpr auto &operator*=(const typename value_type::value_type &other)¶
Multiplication assignment operator with constant value.
Multiply by a constant value and assign the result to this field.
- Parameters:
other – The factor to be multiplied with
- Returns:
reference to this field after multiplication
-
inline std::string print() const¶
Output a string representation of the field components.
Outputs the values of all field components to the specified output stream. Each component is printed in order, enclosed in square brackets. If SIMD the SIMD values are printed in curly brackets.
Public Static Attributes
-
static constexpr int components¶
Number of field components based on dimension and medium type.
-
static constexpr auto medium_tag¶
Medium tag identifying the physical medium type.
-
static constexpr auto accessor_type = specfem::data_access::AccessorType::point¶
Accessor pattern identifier.
-
static constexpr auto data_class = DataClass¶
Data classification type.
-
static constexpr auto dimension_tag = DimensionTag¶
Spatial dimension.
specfem::point::acceleration¶
-
template<specfem::dimension::type DimensionTag, specfem::element::medium_tag MediumTag, bool UseSIMD>
class acceleration : public specfem::point::impl::field<DimensionTag, MediumTag, specfem::data_access::DataClassType::acceleration, UseSIMD>¶ Point acceleration field accessor for spectral element computations.
This class provides a specialized interface for accessing and manipulating acceleration field data at individual points within spectral elements. It inherits all functionality from the base field implementation while being specifically typed for acceleration data.
The acceleration class is commonly used in time-domain wave propagation simulations where acceleration values need to be computed, stored, and accessed at quadrature points during the assembly process.
// Example: Creating 2D elastic acceleration field accessor using AccelField = specfem::point::acceleration< specfem::dimension::type::dim2, specfem::element::medium_tag::elastic, false>; // No SIMD // Initialize with zero acceleration AccelField accel(0.0); // Set acceleration components accel(0) = 9.81; // x-component acceleration accel(1) = 0.0; // z-component acceleration // Use in assembly operations specfem::assembly::load_on_device(point_index, field_container, accel);
// Example: Using acceleration in time integration scheme AccelField acceleration; VelocityField velocity; DisplacementField displacement; // Load current values specfem::assembly::load_on_device(index, fields, acceleration, velocity, displacement); // Time integration (Newmark scheme) for (int icomp = 0; icomp < AccelField::components; ++icomp) { velocity(icomp) += dt * acceleration(icomp); displacement(icomp) += dt * velocity(icomp) + 0.5 * dt * dt * acceleration(icomp); } // Store updated values specfem::assembly::store_on_device(index, fields, velocity, displacement);
See also
specfem::point::velocity for velocity field accessor
See also
specfem::point::displacement for displacement field accessor
See also
specfem::point::mass_inverse for inverse mass matrix field accessor
- Template Parameters:
DimensionTag – The spatial dimension (dim2 or dim3) of the acceleration field
MediumTag – The medium type (acoustic, elastic, poroelastic, etc.)
UseSIMD – Whether to enable SIMD vectorization for performance optimization
Public Types
-
using simd = typename base_type::simd¶
SIMD type for vectorized acceleration operations.
-
using value_type = typename base_type::value_type¶
Vector type for storing acceleration component values.
-
template<typename T>
using scalar_type = typename simd<T>::datatype¶ Scalar field storage for single point.
- Template Parameters:
T – Base data type
-
template<typename T, int dimension>
using vector_type = typename specfem::datatype::VectorPointViewType<T, dimension, UseSIMD>¶ Vector field storage for single point.
- Template Parameters:
T – Base data type
dimension – Vector dimension (2D/3D)
-
template<typename T, int components, int dimension>
using tensor_type = typename specfem::datatype::TensorPointViewType<T, components, dimension, UseSIMD>¶ Tensor field storage for single point.
- Template Parameters:
T – Base data type
components – Number of tensor components
dimension – Spatial dimension
Public Functions
-
inline const value_type &get_data() const¶
Access internal field data storage.
- Returns:
const reference to the internal value_type storing field components
-
inline const value_type::value_type &operator()(const std::size_t icomp) const¶
Access field component by index (const version).
Provides read-only access to individual field components using zero-based indexing. For 2D problems: 0=x, 1=z. For 3D problems: 0=x, 1=y, 2=z.
DisplacementField u_field(1.5, 2.3); auto ux = u_field(0); // x-component = 1.5 auto uz = u_field(1); // z-component = 2.3
- Parameters:
icomp – Component index (0 to components-1)
- Returns:
const reference to the component value
- Pre:
icomp must be less than the number of components
-
inline value_type::value_type &operator()(const std::size_t icomp)¶
Access field component by index (mutable version).
Provides read-write access to individual field components using zero-based indexing. Allows modification of field component values.
DisplacementField u_field; u_field(0) = 1.5; // Set x-component u_field(1) = 2.3; // Set z-component
- Parameters:
icomp – Component index (0 to components-1)
- Returns:
mutable reference to the component value
- Pre:
icomp must be less than the number of components
-
inline bool operator==(const field &other) const¶
Equality comparison operator.
Compares two field objects for exact equality by comparing their internal data storage.
- Parameters:
other – The field object to compare against
- Returns:
true if all components are exactly equal, false otherwise
-
inline bool operator!=(const field &other) const¶
Inequality comparison operator.
Compares two field objects for inequality.
- Parameters:
other – The field object to compare against
- Returns:
true if any component differs, false if all components are equal
-
inline constexpr auto &operator*=(const typename value_type::value_type &other)¶
Multiplication assignment operator with constant value.
Multiply by a constant value and assign the result to this field.
- Parameters:
other – The factor to be multiplied with
- Returns:
reference to this field after multiplication
-
inline std::string print() const¶
Output a string representation of the field components.
Outputs the values of all field components to the specified output stream. Each component is printed in order, enclosed in square brackets. If SIMD the SIMD values are printed in curly brackets.
Public Static Attributes
-
static constexpr int components¶
Number of field components based on dimension and medium type.
-
static constexpr auto medium_tag¶
Medium tag identifying the physical medium type.
-
static constexpr auto accessor_type = specfem::data_access::AccessorType::point¶
Accessor pattern identifier.
-
static constexpr auto data_class = DataClass¶
Data classification type.
-
static constexpr auto dimension_tag = DimensionTag¶
Spatial dimension.
specfem::point::mass_inverse¶
-
template<specfem::dimension::type DimensionTag, specfem::element::medium_tag MediumTag, bool UseSIMD>
class mass_inverse : public specfem::point::impl::field<DimensionTag, MediumTag, specfem::data_access::DataClassType::mass_matrix, UseSIMD>¶ Point inverse mass matrix accessor for spectral element computations.
This class provides a specialized interface for accessing and manipulating inverse mass matrix data at individual points within spectral elements. It inherits all functionality from the base field implementation while being specifically typed for inverse mass matrix data.
The inverse mass matrix is crucial in explicit time integration schemes for wave propagation simulations. It allows for efficient computation of accelerations from forces without requiring matrix inversions during the time stepping process. The diagonal nature of the mass matrix in spectral element methods makes this particularly efficient.
// Example: Creating 2D elastic inverse mass matrix accessor using MassInvField = specfem::point::mass_inverse< specfem::dimension::type::dim2, specfem::element::medium_tag::elastic, false>; // No SIMD // Initialize with uniform inverse mass MassInvField mass_inv(1.0 / 2700.0); // 1/density for elastic material // Set component-specific inverse mass values mass_inv(0) = 1.0 / mass_x; // x-component inverse mass mass_inv(1) = 1.0 / mass_z; // z-component inverse mass // Use in assembly operations specfem::assembly::load_on_device(point_index, mass_container, mass_inv);
// Example: Using inverse mass matrix in explicit time integration MassInvField mass_inverse; AccelField acceleration; ForceField internal_forces, external_forces; // Load mass matrix and forces specfem::assembly::load_on_device(index, fields, mass_inverse); specfem::assembly::load_on_device(index, forces, internal_forces, external_forces); // Compute acceleration: a = M^(-1) * (F_ext - F_int) for (int icomp = 0; icomp < MassInvField::components; ++icomp) { acceleration(icomp) = mass_inverse(icomp) * (external_forces(icomp) - internal_forces(icomp)); } // Store computed acceleration specfem::assembly::store_on_device(index, fields, acceleration);
See also
specfem::point::displacement for displacement field accessor
See also
specfem::point::velocity for velocity field accessor
See also
specfem::point::acceleration for acceleration field accessor
- Template Parameters:
DimensionTag – The spatial dimension (dim2 or dim3) of the mass matrix field
MediumTag – The medium type (acoustic, elastic, poroelastic, etc.)
UseSIMD – Whether to enable SIMD vectorization for performance optimization
Public Types
-
using simd = typename base_type::simd¶
SIMD type for vectorized inverse mass matrix operations.
-
using value_type = typename base_type::value_type¶
Vector type for storing inverse mass matrix component values.
-
template<typename T>
using scalar_type = typename simd<T>::datatype¶ Scalar field storage for single point.
- Template Parameters:
T – Base data type
-
template<typename T, int dimension>
using vector_type = typename specfem::datatype::VectorPointViewType<T, dimension, UseSIMD>¶ Vector field storage for single point.
- Template Parameters:
T – Base data type
dimension – Vector dimension (2D/3D)
-
template<typename T, int components, int dimension>
using tensor_type = typename specfem::datatype::TensorPointViewType<T, components, dimension, UseSIMD>¶ Tensor field storage for single point.
- Template Parameters:
T – Base data type
components – Number of tensor components
dimension – Spatial dimension
Public Functions
-
inline const value_type &get_data() const¶
Access internal field data storage.
- Returns:
const reference to the internal value_type storing field components
-
inline const value_type::value_type &operator()(const std::size_t icomp) const¶
Access field component by index (const version).
Provides read-only access to individual field components using zero-based indexing. For 2D problems: 0=x, 1=z. For 3D problems: 0=x, 1=y, 2=z.
DisplacementField u_field(1.5, 2.3); auto ux = u_field(0); // x-component = 1.5 auto uz = u_field(1); // z-component = 2.3
- Parameters:
icomp – Component index (0 to components-1)
- Returns:
const reference to the component value
- Pre:
icomp must be less than the number of components
-
inline value_type::value_type &operator()(const std::size_t icomp)¶
Access field component by index (mutable version).
Provides read-write access to individual field components using zero-based indexing. Allows modification of field component values.
DisplacementField u_field; u_field(0) = 1.5; // Set x-component u_field(1) = 2.3; // Set z-component
- Parameters:
icomp – Component index (0 to components-1)
- Returns:
mutable reference to the component value
- Pre:
icomp must be less than the number of components
-
inline bool operator==(const field &other) const¶
Equality comparison operator.
Compares two field objects for exact equality by comparing their internal data storage.
- Parameters:
other – The field object to compare against
- Returns:
true if all components are exactly equal, false otherwise
-
inline bool operator!=(const field &other) const¶
Inequality comparison operator.
Compares two field objects for inequality.
- Parameters:
other – The field object to compare against
- Returns:
true if any component differs, false if all components are equal
-
inline constexpr auto &operator*=(const typename value_type::value_type &other)¶
Multiplication assignment operator with constant value.
Multiply by a constant value and assign the result to this field.
- Parameters:
other – The factor to be multiplied with
- Returns:
reference to this field after multiplication
-
inline std::string print() const¶
Output a string representation of the field components.
Outputs the values of all field components to the specified output stream. Each component is printed in order, enclosed in square brackets. If SIMD the SIMD values are printed in curly brackets.
Public Static Attributes
-
static constexpr int components¶
Number of field components based on dimension and medium type.
-
static constexpr auto medium_tag¶
Medium tag identifying the physical medium type.
-
static constexpr auto accessor_type = specfem::data_access::AccessorType::point¶
Accessor pattern identifier.
-
static constexpr auto data_class = DataClass¶
Data classification type.
-
static constexpr auto dimension_tag = DimensionTag¶
Spatial dimension.