Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 394 src rcv python #397

Open
wants to merge 25 commits into
base: issue-228-anisotropy
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
5b14db7
Added overload to read_sources()
lsawade Jan 14, 2025
485666c
Added test to read moment tensor source.
lsawade Jan 14, 2025
a58f60d
Forgot to add the test to the google_test_discover part
lsawade Jan 15, 2025
1502880
Merge pull request #401 from PrincetonUniversity/issue-395
lsawade Jan 15, 2025
5039c13
Fixed installables for the python installation
lsawade Jan 15, 2025
a87e246
Conflicts resolved..
lsawade Jan 15, 2025
9e22d75
this adds capability to add a source into the yaml tree
lsawade Jan 15, 2025
4ac2762
Merge branch 'issue-228-anisotropy' into issue-394-src-rcv-python
lsawade Jan 15, 2025
3262476
Merge branch 'issue-394-src-rcv-python' of github.com:PrincetonUniver…
lsawade Jan 15, 2025
bda25d2
Merge branch 'issue-394-src-rcv-python' into issue-395
lsawade Jan 15, 2025
be31354
Merge pull request #403 from PrincetonUniversity/issue-395
lsawade Jan 16, 2025
a9e95af
first commit to add receiver reading through YAML
lsawade Jan 16, 2025
2f73146
Merge branch 'issue-394-src-rcv-python' into issue-406
lsawade Jan 16, 2025
cf1c2ca
Merged upstream
lsawade Jan 16, 2025
c85f503
I really do not like the way this is done. receivers can now have a s…
lsawade Jan 16, 2025
e6862aa
Put the onus of deciding what format the stations-file is into the re…
lsawade Jan 16, 2025
57abbcc
Fixed grabbing the stations-file from the stations-node.
lsawade Jan 16, 2025
b232002
merged upstream updates
lsawade Jan 16, 2025
87f5c8f
Complete merge
lsawade Jan 16, 2025
070b27e
Updated wavefield snapshot naming, to zero pad for easier globbing
lsawade Jan 17, 2025
b8da2f7
Updated the docs to only refer to the read function that read from fi…
lsawade Jan 17, 2025
9e3190e
Updated source-file to always be called sources. It can now be define…
lsawade Jan 17, 2025
35f2ecd
Moved sources from databases to its own space in the runtime config
lsawade Jan 17, 2025
7beffb0
Removed the -file from the stations-file descriptor
lsawade Jan 17, 2025
0c96a69
Fixed kernel example
lsawade Jan 17, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ if (NOT HDF5_CXX_BUILD)
mesh
source_class
receiver_class
yaml-cpp
${BOOST_LIBS}
Kokkos::kokkos)
else()
Expand All @@ -224,8 +225,9 @@ else()
mesh
source_class
receiver_class

Kokkos::kokkos
yaml-cpp
${BOOST_LIBS}
${HDF5_LIBRARIES}
)
endif()
Expand Down
4 changes: 2 additions & 2 deletions fortran/meshfem2d/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -207,12 +207,12 @@ add_custom_target(meshfem_mesh ALL
)

set( meshfem2D_PREPROCESSOR_OBJECTS
decompose_mesh.mesh.o
decompose_mesh.mesh.o
metis_partitioning.mesh.o
part_unstruct.mesh.o
read_external_mesh_files.mesh.o
read_mesh_files.mesh.o
scotch_partitioning.mesh.o
scotch_partitioning.mesh.o
meshfem2D.mesh.o
)

Expand Down
44 changes: 42 additions & 2 deletions include/IO/interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "source/interface.hpp"
#include "specfem_mpi/interface.hpp"
#include "specfem_setup.hpp"
#include <yaml-cpp/yaml.h>

namespace specfem {

Expand All @@ -24,10 +25,10 @@ specfem::mesh::mesh<specfem::dimension::type::dim2>
read_mesh(const std::string filename, const specfem::MPI::MPI *mpi);

/**
* @brief Read receiver station file
* @brief Read station file
*
* Parse receiver stations file and create a vector of
* specfem::source::source * object
* specfem::receiver::receiver * object
*
* @param stations_file Stations file describing receiver locations
* @param angle Angle of the receivers
Expand All @@ -37,6 +38,29 @@ read_mesh(const std::string filename, const specfem::MPI::MPI *mpi);
std::vector<std::shared_ptr<specfem::receivers::receiver> >
read_receivers(const std::string stations_file, const type_real angle);

/**
* @brief Read receivers from YAML Node
*
* Parse receiver stations file and create a vector of
* specfem::receiver::receiver * object
*
* The receivers are defined in the YAML file as
*
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add @code and @Endcode doxygen directives here

* receivers:
* stations-dict:
* - network: "network_name"
* station: "station_name"
* x: x_coordinate
* z: z_coordinate
*
* @param stations YAML node containing receiver locations
* @param angle Angle of the receivers
* @return std::vector<specfem::receivers::receiver *> vector of instantiated
* receiver objects
*/
std::vector<std::shared_ptr<specfem::receivers::receiver> >
read_receivers(const YAML::Node &stations, const type_real angle);

/**
* @brief Read sources file written in .yml format
*
Expand All @@ -53,5 +77,21 @@ read_sources(const std::string sources_file, const int nsteps,
const type_real user_t0, const type_real dt,
const specfem::simulation::type simulation_type);

/**
* @brief Read sources file written in .yml format
*
* Parse source specification file written in yaml format and create a vector of
* specfem::source::source * object
*
* @param yaml YAML node containing source information
* @param mpi Pointer to specfem MPI object
* @return std::vector<specfem::sources::source *> vector of instantiated source
* objects
*/
std::tuple<std::vector<std::shared_ptr<specfem::sources::source> >, type_real>
read_sources(const YAML::Node yaml, const int nsteps, const type_real user_t0,
const type_real dt,
const specfem::simulation::type simulation_type);

} // namespace IO
} // namespace specfem
8 changes: 8 additions & 0 deletions include/parameter_parser/database_configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ class database_configuration {
database_configuration(std::string fortran_database,
std::string source_database)
: fortran_database(fortran_database), source_database(source_database){};
/**
* @brief Construct a new database configuration object
*
* @param fortran_database location of fortran database
* @param source_node location of source file
*/
database_configuration(std::string fortran_database, YAML::Node source_node)
: fortran_database(fortran_database), source_database(""){};
/**
* @brief Construct a new run setup object
*
Expand Down
35 changes: 16 additions & 19 deletions include/parameter_parser/receivers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,48 +14,45 @@ namespace runtime_configuration {
*/
class receivers {
public:
receivers(const std::string stations_file, const int angle,
const int nstep_between_samples)
: stations_file(stations_file), angle(angle),
nstep_between_samples(nstep_between_samples){};

receivers(const YAML::Node &Node);
receivers(const YAML::Node &Node) : receivers_node(Node) {
assert(this->receivers_node["stations-file"].IsDefined());
assert(this->receivers_node["angle"].IsDefined());
assert(this->receivers_node["nstep_between_samples"].IsDefined());
assert(this->receivers_node["seismogram-type"].IsDefined());
};

/**
* @brief Get the path of stations file
*
* @return std::string describing the locations of stations file
*/
std::string get_stations_file() const { return this->stations_file; }
YAML::Node get_stations() const { return this->receivers_node; }
/**
* @brief Get the angle of the receiver
*
* @return type_real describing the angle of the receiver
*/
type_real get_angle() const { return this->angle; };
type_real get_angle() const {
return this->receivers_node["angle"].as<type_real>();
};
/**
* @brief Get the number of time steps between seismogram sampling
*
* @return int descibing seismogram sampling frequency
*/
int get_nstep_between_samples() const { return this->nstep_between_samples; }
int get_nstep_between_samples() const {
return this->receivers_node["nstep_between_samples"].as<int>();
}

/**
* @brief Get the types of seismogram requested
*
* @return std::vector<specfem::seismogram::type> vector seismogram types
*/
std::vector<specfem::enums::seismogram::type> get_seismogram_types() const {
return stypes;
}
std::vector<specfem::enums::seismogram::type> get_seismogram_types() const;

private:
std::string stations_file; ///< path to stations file
type_real angle; ///< Angle of the receiver
int nstep_between_samples; ///< Seismogram sampling frequency
std::vector<specfem::enums::seismogram::type> stypes; ///< std::vector
///< containing type of
///< seismograms to be
///< written
YAML::Node receivers_node; /// Node that contains receiver information
};
} // namespace runtime_configuration
} // namespace specfem
Expand Down
28 changes: 18 additions & 10 deletions include/parameter_parser/setup.hpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
#ifndef _PARAMETER_SETUP_HPP
#define _PARAMETER_SETUP_HPP

#include "IO/reader.hpp"
#include "database_configuration.hpp"
#include "header.hpp"
#include "parameter_parser/solver/interface.hpp"
#include "quadrature.hpp"
#include "IO/reader.hpp"
#include "receivers.hpp"
#include "run_setup.hpp"
#include "sources.hpp"
#include "specfem_setup.hpp"
#include "time_scheme/interface.hpp"
#include "writer/kernel.hpp"
Expand Down Expand Up @@ -105,14 +106,19 @@ class setup {
return databases->get_databases();
}

/**
* @brief Get the sources YAML object
*
* @return YAML::Node YAML node describing the sources
*/
YAML::Node get_sources() const { return this->sources->get_sources(); }

/**
* @brief Get the path to stations file
*
* @return std::string path to stations file
*/
std::string get_stations_file() const {
return this->receivers->get_stations_file();
}
YAML::Node get_stations() const { return this->receivers->get_stations(); }

/**
* @brief Get the angle of receivers
Expand Down Expand Up @@ -140,8 +146,7 @@ class setup {
* @return specfem::IO::writer* Pointer to an instantiated writer
object
*/
std::shared_ptr<specfem::IO::writer>
instantiate_seismogram_writer() const {
std::shared_ptr<specfem::IO::writer> instantiate_seismogram_writer() const {
if (this->seismogram) {
return this->seismogram->instantiate_seismogram_writer(
this->time_scheme->get_dt(), this->time_scheme->get_t0(),
Expand All @@ -151,17 +156,15 @@ class setup {
}
}

std::shared_ptr<specfem::IO::writer>
instantiate_wavefield_writer() const {
std::shared_ptr<specfem::IO::writer> instantiate_wavefield_writer() const {
if (this->wavefield) {
return this->wavefield->instantiate_wavefield_writer();
} else {
return nullptr;
}
}

std::shared_ptr<specfem::IO::reader>
instantiate_wavefield_reader() const {
std::shared_ptr<specfem::IO::reader> instantiate_wavefield_reader() const {
if (this->wavefield) {
return this->wavefield->instantiate_wavefield_reader();
} else {
Expand Down Expand Up @@ -234,6 +237,11 @@ class setup {
///< quadrature object
std::unique_ptr<specfem::runtime_configuration::receivers>
receivers; ///< Pointer to receivers object
std::unique_ptr<specfem::runtime_configuration::sources>
sources; ///< Pointer
///< to
///< receivers
///< object
std::unique_ptr<specfem::runtime_configuration::seismogram>
seismogram; ///< Pointer to
///< seismogram object
Expand Down
32 changes: 32 additions & 0 deletions include/parameter_parser/sources.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#pragma once

#include "enumerations/specfem_enums.hpp"
#include "yaml-cpp/yaml.h"
#include <string>

namespace specfem {
namespace runtime_configuration {
/**
* @brief class to read source information
*
*/
class sources {
public:
sources(const std::string sources_file) {
source_node = YAML::LoadFile(sources_file);
};

sources(const YAML::Node &Node) { source_node = Node; };

/**
* @brief Get the sources
*
* @return YAML::Node describing the sources
*/
YAML::Node get_sources() const { return source_node; }

protected:
YAML::Node source_node; /// Node that contains sources information
};
} // namespace runtime_configuration
} // namespace specfem
20 changes: 20 additions & 0 deletions include/source/moment_tensor_source.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,26 @@ class moment_tensor : public source {
*
*/
moment_tensor(){};

/**
* @brief Get the Mxx component of the moment tensor
*
* @return type_real x-coordinate
*/
type_real get_Mxx() const { return Mxx; }
/**
* @brief Get the Mxz component of the moment tensor
*
* @return type_real z-coordinate
*/
type_real get_Mxz() const { return Mxz; }
/**
* @brief Get the Mzz component of the moment tensor
*
* @return type_real z-coordinate
*/
type_real get_Mzz() const { return Mzz; }

/**
* @brief Construct a new moment tensor force object
*
Expand Down
Loading
Loading