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

moved read_mesh/sources/receivers to the IO/interface.hpp #196

Merged
merged 6 commits into from
Dec 2, 2024
Merged
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
14 changes: 3 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,15 @@ add_library(
src/IO/fortranio/fortran_io.cpp
src/IO/HDF5/native_type.cpp
# src/IO/ASCII/native_type.cpp
src/IO/mesh/read_mesh.cpp
src/IO/sources.cpp
src/IO/receivers.cpp
src/IO/mesh.cpp
src/IO/mesh/impl/fortran/read_boundaries.cpp
src/IO/mesh/impl/fortran/read_elements.cpp
src/IO/mesh/impl/fortran/read_material_properties.cpp
src/IO/mesh/impl/fortran/read_mesh_database.cpp
src/IO/mesh/impl/fortran/read_interfaces.cpp
src/IO/mesh/impl/fortran/read_properties.cpp
src/IO/sources/read_sources.cpp
src/IO/receivers/read_receivers.cpp
)

if (NOT HDF5_CXX_BUILD)
Expand All @@ -163,15 +163,7 @@ endif()
target_link_libraries(
IO
mesh
)

target_link_libraries(
IO
source_class
)

target_link_libraries(
IO
receiver_class
)

Expand Down
56 changes: 56 additions & 0 deletions include/IO/interface.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
#pragma once

#include "enumerations/simulation.hpp"
#include "mesh/mesh.hpp"
#include "receiver/interface.hpp"
#include "source/interface.hpp"
#include "specfem_mpi/interface.hpp"
#include "specfem_setup.hpp"

namespace specfem {

namespace IO {

/**
* @brief Construct a mesh object from a Fortran binary database file
*
* @param filename Fortran binary database filename
* @param mpi pointer to MPI object to manage communication
* @return specfem::mesh::mesh Specfem mesh object
*
*/
specfem::mesh::mesh read_mesh(const std::string filename,
const specfem::MPI::MPI *mpi);

/**
* @brief Read receiver station file
*
* Parse receiver stations file and create a vector of
* specfem::source::source * object
*
* @param stations_file Stations file describing 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 std::string stations_file, const type_real angle);

/**
* @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 sources_file Name of the yml file
* @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 std::string sources_file, const int nsteps,
const type_real user_t0, const type_real dt,
const specfem::simulation::type simulation_type);

} // namespace IO
} // namespace specfem
23 changes: 0 additions & 23 deletions include/IO/mesh/read_mesh.hpp

This file was deleted.

26 changes: 0 additions & 26 deletions include/IO/receivers/read_receivers.hpp

This file was deleted.

29 changes: 0 additions & 29 deletions include/IO/sources/read_sources.hpp

This file was deleted.

7 changes: 5 additions & 2 deletions src/IO/mesh/read_mesh.cpp → src/IO/mesh.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#include "IO/mesh/read_mesh.hpp"
// Internal Includes
#include "mesh/mesh.hpp"
#include "IO/fortranio/interface.hpp"
#include "IO/interface.hpp"
#include "IO/mesh/impl/fortran/read_boundaries.hpp"
#include "IO/mesh/impl/fortran/read_elements.hpp"
#include "IO/mesh/impl/fortran/read_interfaces.hpp"
Expand All @@ -9,10 +11,11 @@
#include "enumerations/specfem_enums.hpp"
#include "kokkos_abstractions.h"
#include "material/material.hpp"
#include "mesh/mesh.hpp"
#include "mesh/tags/tags.hpp"
#include "specfem_mpi/interface.hpp"
#include "specfem_setup.hpp"

// External/Standard Libraries
#include <Kokkos_Core.hpp>
#include <algorithm>
#include <limits>
Expand Down
5 changes: 4 additions & 1 deletion src/IO/receivers/read_receivers.cpp → src/IO/receivers.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#include "IO/receivers/read_receivers.hpp"
// Internal Includes
#include "IO/interface.hpp"
#include "receiver/interface.hpp"
#include "specfem_setup.hpp"
#include "utilities/interface.hpp"
#include "yaml-cpp/yaml.h"

// External Includes
#include <boost/tokenizer.hpp>
#include <fstream>
#include <string>
Expand Down
5 changes: 4 additions & 1 deletion src/IO/sources/read_sources.cpp → src/IO/sources.cpp
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
#include "IO/sources/read_sources.hpp"
// Internal Includes
#include "IO/interface.hpp"
#include "source/interface.hpp"
#include "specfem_setup.hpp"
#include "utilities/interface.hpp"
#include "yaml-cpp/yaml.h"

// External Includes
#include <boost/tokenizer.hpp>
#include <fstream>
#include <memory>
Expand Down
4 changes: 1 addition & 3 deletions src/specfem2d.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#include "compute/interface.hpp"
// #include "coupled_interface/interface.hpp"
// #include "domain/interface.hpp"
#include "IO/mesh/read_mesh.hpp"
#include "IO/receivers/read_receivers.hpp"
#include "IO/sources/read_sources.hpp"
#include "IO/interface.hpp"
#include "kokkos_abstractions.h"
#include "mesh/mesh.hpp"
#include "parameter_parser/interface.hpp"
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-tests/algorithms/interpolate_function.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "IO/mesh/read_mesh.hpp"
#include "IO/interface.hpp"
#include "Kokkos_Environment.hpp"
#include "MPI_environment.hpp"
#include "algorithms/interpolate.hpp"
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-tests/algorithms/locate.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "IO/mesh/read_mesh.hpp"
#include "IO/interface.hpp"
#include "Kokkos_Environment.hpp"
#include "MPI_environment.hpp"
#include "algorithms/locate_point.hpp"
Expand Down
4 changes: 1 addition & 3 deletions tests/unit-tests/assembly/test_fixture/test_fixture.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
#include "test_fixture.hpp"
#include "IO/mesh/read_mesh.hpp"
#include "IO/receivers/read_receivers.hpp"
#include "IO/sources/read_sources.hpp"
#include "IO/interface.hpp"
#include "test_fixture.tpp"

// ------------------------------------------------------------------------
Expand Down
1 change: 1 addition & 0 deletions tests/unit-tests/assembly/test_fixture/test_fixture.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include "../../MPI_environment.hpp"
#include "IO/interface.hpp"
#include "compute/assembly/assembly.hpp"
#include "enumerations/specfem_enums.hpp"
#include "mesh/mesh.hpp"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "../../Kokkos_Environment.hpp"
#include "../../MPI_environment.hpp"
#include "../../utilities/include/interface.hpp"
#include "IO/mesh/read_mesh.hpp"
#include "IO/interface.hpp"
#include "compute/interface.hpp"
#include "material/interface.hpp"
#include "mesh/mesh.hpp"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "../../Kokkos_Environment.hpp"
#include "../../MPI_environment.hpp"
#include "../../utilities/include/interface.hpp"
#include "IO/mesh/read_mesh.hpp"
#include "IO/interface.hpp"
#include "compute/interface.hpp"
#include "edge/interface.hpp"
#include "material/interface.hpp"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "../../Kokkos_Environment.hpp"
#include "../../MPI_environment.hpp"
#include "../../utilities/include/interface.hpp"
#include "IO/mesh/read_mesh.hpp"
#include "IO/interface.hpp"
#include "compute/interface.hpp"
#include "mesh/mesh.hpp"
#include "quadrature/interface.hpp"
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-tests/compute/index/compute_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "../../Kokkos_Environment.hpp"
#include "../../MPI_environment.hpp"
#include "../../utilities/include/interface.hpp"
#include "IO/mesh/read_mesh.hpp"
#include "IO/interface.hpp"
#include "compute/interface.hpp"
#include "mesh/mesh.hpp"
#include "quadrature/interface.hpp"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "../../Kokkos_Environment.hpp"
#include "../../MPI_environment.hpp"
#include "../../utilities/include/interface.hpp"
#include "IO/mesh/read_mesh.hpp"
#include "IO/interface.hpp"
#include "compute/interface.hpp"
#include "quadrature/interface.hpp"
#include "yaml-cpp/yaml.h"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "../../../Kokkos_Environment.hpp"
#include "../../../MPI_environment.hpp"
#include "../../../utilities/include/compare_array.h"
#include "IO/mesh/read_mesh.hpp"
#include "IO/interface.hpp"
#include "compute/interface.hpp"
#include "constants.hpp"
#include "domain/interface.hpp"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "../../../Kokkos_Environment.hpp"
#include "../../../MPI_environment.hpp"
#include "../../../utilities/include/compare_array.h"
#include "IO/mesh/read_mesh.hpp"
#include "IO/interface.hpp"
#include "compute/interface.hpp"
#include "constants.hpp"
#include "domain/interface.hpp"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#include "../../Kokkos_Environment.hpp"
#include "../../MPI_environment.hpp"
#include "../../utilities/include/interface.hpp"
#include "IO/mesh/read_mesh.hpp"
#include "IO/receivers/read_receivers.hpp"
#include "IO/sources/read_sources.hpp"
#include "IO/interface.hpp"
#include "compute/interface.hpp"
#include "constants.hpp"
#include "domain/domain.hpp"
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-tests/domain/acoustic/rmass_inverse_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "../../Kokkos_Environment.hpp"
#include "../../MPI_environment.hpp"
#include "../../utilities/include/compare_array.h"
#include "IO/mesh/read_mesh.hpp"
#include "IO/interface.hpp"
#include "compute/interface.hpp"
#include "constants.hpp"
#include "domain/interface.hpp"
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-tests/domain/elastic/rmass_inverse_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "../../Kokkos_Environment.hpp"
#include "../../MPI_environment.hpp"
#include "../../utilities/include/compare_array.h"
#include "IO/mesh/read_mesh.hpp"
#include "IO/interface.hpp"
#include "compute/interface.hpp"
#include "constants.hpp"
#include "domain/interface.hpp"
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-tests/domain/rmass_inverse_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "../Kokkos_Environment.hpp"
#include "../MPI_environment.hpp"
#include "../utilities/include/interface.hpp"
#include "IO/mesh/read_mesh.hpp"
#include "IO/interface.hpp"
#include "compute/interface.hpp"
#include "constants.hpp"
#include "domain/domain.hpp"
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-tests/mesh/mesh_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include "../Kokkos_Environment.hpp"
#include "../MPI_environment.hpp"
#include "IO/interface.hpp"
#include "IO/mesh/impl/fortran/read_mesh_database.hpp"
#include "IO/mesh/read_mesh.hpp"
#include "mesh/mesh.hpp"
#include "yaml-cpp/yaml.h"
#include <fstream>
Expand Down
3 changes: 1 addition & 2 deletions tests/unit-tests/seismogram/acoustic/seismogram_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
#include "../../MPI_environment.hpp"
// #include "../../utilities/include/compare_array.h"
#include "IO/fortranio/interface.hpp"
#include "IO/mesh/read_mesh.hpp"
#include "IO/receivers/read_receivers.hpp"
#include "IO/interface.hpp"
#include "compute/interface.hpp"
#include "constants.hpp"
#include "domain/domain.hpp"
Expand Down
3 changes: 1 addition & 2 deletions tests/unit-tests/seismogram/elastic/seismogram_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
#include "../../MPI_environment.hpp"
// #include "../../utilities/include/compare_array.h"
#include "IO/fortranio/interface.hpp"
#include "IO/mesh/read_mesh.hpp"
#include "IO/receivers/read_receivers.hpp"
#include "IO/interface.hpp"
#include "compute/interface.hpp"
#include "constants.hpp"
#include "domain/domain.hpp"
Expand Down
2 changes: 1 addition & 1 deletion tests/unit-tests/source/source_location_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "../Kokkos_Environment.hpp"
#include "../MPI_environment.hpp"
#include "IO/mesh/read_mesh.hpp"
#include "IO/interface.hpp"
#include "compute/interface.hpp"
#include "material/interface.hpp"
#include "mesh/mesh.hpp"
Expand Down