2D specfem::sources::cosserat_force¶
Cosserat force source implementation for 2D simulations
-
template<>
class cosserat_force<specfem::element::dimension_tag::dim2> : public specfem::sources::vector_source<specfem::element::dimension_tag::dim2>¶ Cosserat force source.
This class implements a Cosserat force source in 2D, which is used for simulations in Cosserat elastic media. It combines both elastic and rotational force components with separate scaling factors.
- 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 2D Cosserat force source at (3.2, 4.8) auto cosserat_source = specfem::sources::cosserat_force<specfem::element::dimension_tag::dim2>( 3.2, // x-coordinate 4.8, // z-coordinate 1.5, // f - elastic force scaling factor 0.8, // fc - rotational force scaling factor 30.0, // angle in degrees std::move(stf), specfem::simulation::field_type::forward ); // Set the medium type (only works with Cosserat elastic media) cosserat_source.set_medium_tag(specfem::element::medium_tag::elastic_psv_t); // Get the force vector (includes elastic and rotational components) auto force_vector = cosserat_source.get_force_vector();
Public Functions
-
inline cosserat_force()¶
Default source constructor.
-
inline cosserat_force(YAML::Node &Node, const int nsteps, const type_real dt, const specfem::simulation::field_type wavefield_type)¶
Construct a new cosserat force object.
- Parameters:
cosserat_source – A YAML node defining cosserat force source
dt – Time increment in the simulation. Used to calculate dominant frequecy of Dirac source.
-
inline cosserat_force(type_real x, type_real z, type_real f, type_real fc, type_real angle, std::unique_ptr<specfem::source_time_functions::stf> source_time_function, const specfem::simulation::field_type wavefield_type)¶
Construct a new cosserat force object.
- Parameters:
x – x-coordinate of source
z – z-coordinate of source
f – Factor to scale the elastic force
fc – Factor to scale the rotational force
angle – Angle of the elastic force source
source_time_function – Pointer to source time function
wavefield_type – Type of wavefield on which the source acts
-
inline virtual std::string source_name() const override¶
User output.
-
virtual std::string print_details() const override¶
Type-specific output (parameters unique to this source type). The default implementation returns an empty string for sources that have no additional parameters beyond location and source time function.
-
virtual Kokkos::View<type_real*, Kokkos::LayoutRight, Kokkos::HostSpace> get_force_vector() const override¶
Get the force vector.
Returns the 2D Cosserat force vector combining elastic and rotational components:
\[\begin{split} \mathbf{f}_{Cosserat} = \begin{pmatrix} f \sin(\theta) \\ -f \cos(\theta) \\ f_c \end{pmatrix} \end{split}\]Where:
\(f \sin(\theta)\): Elastic force component in x-direction
\(-f \cos(\theta)\): Elastic force component in z-direction
\(f_c\): Rotational (Cosserat) force component (couple stress)
\(\theta\) is the force angle
This formulation is specific to Cosserat elastic media which include both translational and rotational degrees of freedom.
- Returns:
Kokkos::View<type_real *, Kokkos::LayoutRight, Kokkos::HostSpace> Force vector with 3 components [fx, fz, fc]
-
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
-
inline std::optional<specfem::datetime::type> get_starttime() const¶
Get the UTC start time of this source (nullopt if not set).
-
inline void set_starttime(std::optional<specfem::datetime::type> t)¶
Set the UTC start time of this source.
-
inline std::string print() const¶
User output — assembles source name, location, type-specific details, source time function, and (when MPI-enabled) the owning rank.
-
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
-
inline void set_read_coordinates(std::unique_ptr<specfem::coordinate_systems::coordinates<dimension_tag>> coordinates)¶
Set the generic coordinates for this source.
- Parameters:
coordinates – Generic coordinate object (ownership transferred)
-
inline const specfem::coordinate_systems::coordinates<dimension_tag> *get_read_coordinates() const¶
Get the generic coordinates (const), or nullptr if not set.
-
inline specfem::coordinate_systems::coordinates<dimension_tag> *get_read_coordinates()¶
Get the generic coordinates (mutable), or nullptr if not set.
Used by resolve_coordinates to set the origin on cartesian coordinates.