2D specfem::sources::external¶
External source implementation for 2D simulations
-
template<>
class external<specfem::dimension::type::dim2> : public specfem::sources::vector_source<specfem::dimension::type::dim2>¶ External source.
This class implements an external source in 2D, which is used for coupling with external data or boundary conditions. External sources provide a flexible interface for incorporating external forcing terms.
- Usage Example
// Create a Ricker wavelet source time function auto stf = std::make_unique<specfem::source_time_functions::Ricker>( 25.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 2D external source at boundary location (0.0, 5.0) auto ext_source = specfem::sources::external<specfem::dimension::type::dim2>( 0.0, // x-coordinate (at boundary) 5.0, // z-coordinate std::move(stf), specfem::wavefield::simulation_field::forward ); // Set the medium type where the external source is located ext_source.set_medium_tag(specfem::element::medium_tag::acoustic); // Get the force vector (unit vector components based on medium) auto force_vector = ext_source.get_force_vector();
Public Functions
-
virtual std::string print() const override¶
User output.
-
virtual specfem::kokkos::HostView1d<type_real> get_force_vector() const override¶
Get the force vector.
Returns a unit force vector for external boundary sources:
\[\begin{split} \mathbf{f}_{external} = \begin{cases} [1.0] & \text{acoustic: unit pressure amplitude} \\ [1.0] & \text{elastic SH: unit force out-of-plane} \\ [1.0, 1.0] & \text{elastic PSV: unit forces in x,z directions} \\ [1.0, 1.0, 1.0, 1.0] & \text{poroelastic: solid/fluid phases} \\ [1.0, 1.0] & \text{electromagnetic TE} \\ [1.0, 1.0, 1.0] & \text{elastic PSV-T: including rotation} \end{cases} \end{split}\]Where the unit components provide a normalized basis for external coupling or boundary condition enforcement. The actual amplitudes are scaled by the source time function during simulation.
- Returns:
Kokkos::View<type_real *, Kokkos::LayoutLeft, Kokkos::HostSpace> Unit force vector with size depending on medium type
-
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