3D specfem::sources::force_source implementation¶
-
template<>
class force<specfem::dimension::type::dim3> : public specfem::sources::vector_source<specfem::dimension::type::dim3>¶ Collocated force source.
This class implements a collocated force source in 3D that applies forces in the x, y, and z directions at a specific location in the simulation domain.
- Usage Example
// Create a Ricker wavelet source time function auto stf = std::make_unique<specfem::source_time_functions::Ricker>( 15.0, // dominant frequency (Hz) 0.01, // time factor 1.0, // amplitude 0.0, // time shift 1.0, // normalization factor false // do not reverse ); // Create a 3D force source at (1.0, 2.0, 3.0) with force components auto force_source = specfem::sources::force<specfem::dimension::type::dim3>( 1.0, // x-coordinate 2.0, // y-coordinate 3.0, // z-coordinate 0.7, // fx - force in x direction 0.0, // fy - force in y direction 0.7, // fz - force in z direction std::move(stf), specfem::wavefield::simulation_field::forward ); // Set the medium type force_source.set_medium_tag(specfem::element::medium_tag::elastic); // Get the force vector auto force_vector = force_source.get_force_vector();
Public Functions
-
inline force()¶
Default source constructor.
-
inline force(YAML::Node &Node, const int nsteps, const type_real dt, const specfem::wavefield::simulation_field wavefield_type)¶
Construct a new collocated force object.
- Parameters:
force_source – A YAML node defining force source
dt – Time increment in the simulation. Used to calculate dominant frequecy of Dirac source.
-
inline force(type_real x, type_real y, type_real z, type_real fx, type_real fy, type_real fz, std::unique_ptr<specfem::source_time_functions::stf> source_time_function, const specfem::wavefield::simulation_field wavefield_type)¶
Construct a new collocated force object.
- Parameters:
x – x-coordinate of source
y – y-coordinate of source
z – z-coordinate of source
source_time_function – pointer to source time function
wavefield_type – type of wavefield
-
virtual std::string print() const override¶
User output.
-
bool operator==(const specfem::sources::source<specfem::dimension::type::dim3> &other) const override¶
Get the forcing function.
-
virtual specfem::kokkos::HostView1d<type_real> get_force_vector() const override¶
Get the force vector.
Returns the 3D force vector for this source:
\[\begin{split} \mathbf{f}_{3D} = \begin{cases} [f_x] & \text{acoustic: pressure amplitude} \\ \begin{pmatrix} f_x \\ f_y \\ f_z \end{pmatrix} & \text{elastic: force components} \end{cases} \end{split}\]Where:
\(f_x, f_y, f_z\) are the user-specified force components
For acoustic media, only the \(f_x\) component is used as pressure source
For elastic media, all three components define the force vector
The force components are applied directly as body forces, representing point sources with user-specified directional amplitudes.
- Returns:
Kokkos::View<type_real *, Kokkos::LayoutLeft, Kokkos::HostSpace> Force vector with 3 components [fx, fy, fz]
-
virtual std::vector<specfem::element::medium_tag> get_supported_media() const override¶
Get the list of supported media for this source type.
- Returns:
std::vector<specfem::element::medium_tag> list of supported media
-
inline virtual source_type get_source_type() const override¶
Get the source type object.
- Returns:
source_type
-
inline type_real get_t0() const¶
Get the value of t0 from the specfem::stf::stf object.
- Returns:
value of t0
-
inline void update_tshift(type_real tshift)¶
Update the value of tshift for specfem::stf::stf object.
- Returns:
new value of tshift
-
void set_source_time_function(YAML::Node &Node, const int nsteps, const type_real dt)¶
Set the forcing function for the source.
This function initializes the source time function based on the configuration provided in the YAML node. It supports various types of source time functions such as Dirac, Gaussian, Ricker, dGaussian, Heaviside, and External. If the specified source time function is not recognized, an exception is thrown.
This method also is responsible for setting up the start time of the source time function depending on dimension (dim2, dim3) and forcing function type.
- Parameters:
Node – YAML node containing source time function configuration
nsteps – number of time steps
dt – time step size
-
inline std::unique_ptr<specfem::source_time_functions::stf> &get_source_time_function()¶
Get the forcing function object.
- Returns:
std::unique_ptr<specfem::source_time_functions::stf>&
-
inline void set_local_coordinates(const specfem::point::local_coordinates<dimension_tag> &local_coordinates)¶
Set the local xi coordinates of the source in the local coordinate system.
- Parameters:
specfem::point::local_coordinates<dimension_tag> – local_coordinates
-
inline specfem::point::local_coordinates<dimension_tag> get_local_coordinates() const¶
Get the local coordinates of the source in the local coordinate system.
- Returns:
specfem::point::local_coordinates<dimension_tag>
-
inline void set_global_coordinates(const specfem::point::global_coordinates<dimension_tag> &global_coordinates)¶
Set the global coordinates of the source in the global coordinate system.
- Parameters:
specfem::point::global_coordinates<dimension_tag> – global_coordinates
-
inline specfem::point::global_coordinates<dimension_tag> get_global_coordinates() const¶
Get the global coordinates of the source in the global coordinate system.
- Returns:
specfem::point::global_coordinates<dimension_tag>
-
void set_medium_tag(specfem::element::medium_tag medium_tag)¶
Set the medium tag for the source.
This needs to be set inside the since each medium requires a separate implementation for each medium and some source do not have implementations for certain media at all. E.g., if you want to assign a moment tensor to an element in the water column (acoustic), it does not make sense, or rather it is unphysical.
- Parameters:
medium_tag – medium tag
-
inline specfem::element::medium_tag get_medium_tag() const¶
Get the medium tag for the source.
- Returns:
specfem::medium::medium_tag medium tag