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 395 - Adds support for reading the sources as a yaml-node #403

Open
wants to merge 4 commits into
base: issue-394-src-rcv-python
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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: 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
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
24 changes: 17 additions & 7 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,6 +106,13 @@ 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
*
Expand Down Expand Up @@ -140,8 +148,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 +158,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 +239,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
Loading
Loading