Skip to content

Commit

Permalink
Added a first working preset
Browse files Browse the repository at this point in the history
  • Loading branch information
lsawade committed Feb 10, 2025
1 parent 685a001 commit fc4687e
Show file tree
Hide file tree
Showing 13 changed files with 405 additions and 26 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,15 @@ add_library(
src/IO/sources.cpp
src/IO/receivers.cpp
src/IO/mesh.cpp
# Fortran 2D part
src/IO/mesh/impl/fortran/dim2/read_boundaries.cpp
src/IO/mesh/impl/fortran/dim2/read_elements.cpp
src/IO/mesh/impl/fortran/dim2/read_material_properties.cpp
src/IO/mesh/impl/fortran/dim2/read_mesh_database.cpp
src/IO/mesh/impl/fortran/dim2/read_interfaces.cpp
src/IO/mesh/impl/fortran/dim2/read_parameters.cpp
# Fortran 3D part
src/IO/mesh/impl/fortran/dim3/read_parameters.cpp
)

if (NOT HDF5_CXX_BUILD)
Expand Down
26 changes: 26 additions & 0 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"version": 6,
"configurePresets": [
{
"name": "debug",
"displayName": "Debug (Serial)",
"binaryDir": "build/debug",
"cacheVariables": {
"CMAKE_BUILD_TYPE": "Debug",
"BUILD_TESTS": "ON",
"ENABLE_SIMD": "OFF",
"Kokkos_ARCH_NATIVE": "ON",
"Kokkos_ENABLE_AGGRESSIVE_VECTORIZATION": "ON",
"Kokkos_ENABLE_ATOMICS_BYPASS": "ON"
}
}
],
"buildPresets": [
{
"name": "debug",
"configurePreset": "debug",
"targets": ["all"],
"jobs": 8
}
]
}
1 change: 1 addition & 0 deletions examples/dim3/homogeneous_halfspace/specfem_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ parameters:
## databases
databases:
mesh-database: "OUTPUT_FILES/DATABASES_MPI/proc000000_external_mesh.bin"
mesh-parameters: "OUTPUT_FILES/DATABASES_MPI/mesh_parameters.bin"

## sources
sources: "/Users/lsawade/SPECFEMPP/examples/homogeneous-medium-flat-topography/source.yaml"
12 changes: 6 additions & 6 deletions fortran/meshfem3d/generate_databases/save_parameters.f90
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,17 @@ subroutine save_parameters()
WRITE(IOUT) NGLLSQUARE

! Write test parameter
WRITE(IOUT) itest
itest = 9997
WRITE(IOUT) itest

WRITE(IOUT) NSPEC_AB ! nspec
WRITE(IOUT) NSPEC_PORO ! nspec_poro == nspec, if POROELASTIC_SIMULATION
WRITE(IOUT) NGLOB_AB ! nglob
WRITE(IOUT) NGLOB_OCEAN

! Write test parameter
WRITE(IOUT) itest
itest = 9996
WRITE(IOUT) itest

WRITE(IOUT) NSPEC2D_BOTTOM
WRITE(IOUT) NSPEC2D_TOP
Expand All @@ -92,8 +92,8 @@ subroutine save_parameters()
WRITE(IOUT) nspec_irregular

! Write test parameter
WRITE(IOUT) itest
itest = 9995
WRITE(IOUT) itest

WRITE(IOUT) num_neighbors_all
WRITE(IOUT) nfaces_surface
Expand All @@ -107,8 +107,8 @@ subroutine save_parameters()
WRITE(IOUT) max_nibool_interfaces_ext_mesh

! Write test parameter
WRITE(IOUT) itest
itest = 9994
WRITE(IOUT) itest

WRITE(IOUT) nspec_inner_acoustic
WRITE(IOUT) nspec_outer_acoustic
Expand All @@ -118,8 +118,8 @@ subroutine save_parameters()
WRITE(IOUT) nspec_outer_poroelastic

! Write test parameter
WRITE(IOUT) itest
itest = 9993
WRITE(IOUT) itest

WRITE(IOUT) num_phase_ispec_acoustic
WRITE(IOUT) num_phase_ispec_elastic
Expand All @@ -130,8 +130,8 @@ subroutine save_parameters()
WRITE(IOUT) num_colors_outer_elastic

! Write test parameter
WRITE(IOUT) itest
itest = 9992
WRITE(IOUT) itest
endif

end subroutine save_parameters
4 changes: 3 additions & 1 deletion include/IO/interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ specfem::mesh::mesh<specfem::dimension::type::dim2>
read_2d_mesh(const std::string filename, const specfem::MPI::MPI *mpi);

specfem::mesh::mesh<specfem::dimension::type::dim3>
read_3d_mesh(const std::string filename, const specfem::MPI::MPI *mpi);
read_3d_mesh(const std::string mesh_parameters_file,
const std::string mesh_databases_file,
const specfem::MPI::MPI *mpi);
/**
* @brief Read station file
*
Expand Down
1 change: 1 addition & 0 deletions include/mesh/mesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "coupled_interfaces/coupled_interfaces.hpp"
#include "elements/axial_elements.hpp"
#include "elements/tangential_elements.hpp"
#include "enumerations/dimension.hpp"
#include "enumerations/interface.hpp"
#include "materials/materials.hpp"
#include "mesh/tags/tags.hpp"
Expand Down
11 changes: 10 additions & 1 deletion include/mesh/parameters/parameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ template <> struct parameters<specfem::dimension::type::dim3> {
bool approximate_ocean_load; ///< Flag for approx. ocean load
bool use_mesh_coloring; ///< Flag for mesh coloring

// Integer Parameters: Dimensions and GLL layouts
int ndim; ///< Number of dimensions
int ngllx; ///< Number of GLL points in x
int nglly; ///< Number of GLL points in y
int ngllz; ///< Number of GLL points in z
int ngllsquare; ///< Number of GLL points in square

// Integer Parameters: Elements/Nodes
int nspec; ///< Number of spectral elements (SEs)
int nspec_poro; ///< Number of poroelastic SEs
Expand Down Expand Up @@ -153,6 +160,8 @@ template <> struct parameters<specfem::dimension::type::dim3> {
* @param approximate_ocean_load Flag for approx. ocean load
* @param use_mesh_coloring Flag for mesh coloring
*
*
*
* @param nspec Number of spectral elements (SEs)
* @param nspec_poro Number of poroelastic SEs
* @param nglob Number of global nodes
Expand Down Expand Up @@ -246,7 +255,7 @@ template <> struct parameters<specfem::dimension::type::dim3> {
num_colors_outer_acoustic(num_colors_outer_acoustic),
num_colors_inner_elastic(num_colors_inner_elastic),
num_colors_outer_elastic(num_colors_outer_elastic){};

};
} // namespace mesh
} // namespace specfem

Expand Down
7 changes: 7 additions & 0 deletions include/parameter_parser/database_configuration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ class database_configuration {
database_configuration(std::string fortran_database)
: fortran_database(fortran_database){};

database_configuration(std::string fortran_database,
std::string mesh_parameters)
: fortran_database(fortran_database), mesh_parameters(mesh_parameters){};

/**
* @brief Construct a new run setup object
*
Expand All @@ -32,8 +36,11 @@ class database_configuration {

std::string get_databases() const { return this->fortran_database; }

std::string get_mesh_parameters() const { return this->mesh_parameters; };

private:
std::string fortran_database; ///< location of fortran binary database
std::string mesh_parameters; ///< location of mesh parameter file
};

} // namespace runtime_configuration
Expand Down
3 changes: 3 additions & 0 deletions include/parameter_parser/setup.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ class setup {
* to mesh database and source yaml file
*/
std::string get_databases() const { return databases->get_databases(); }
std::string get_mesh_parameters() const {
return databases->get_mesh_parameters();
}

/**
* @brief Get the sources YAML object
Expand Down
20 changes: 17 additions & 3 deletions src/IO/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#include "IO/mesh/impl/fortran/dim2/read_material_properties.hpp"
#include "IO/mesh/impl/fortran/dim2/read_mesh_database.hpp"
#include "IO/mesh/impl/fortran/dim2/read_parameters.hpp"
#include "IO/mesh/impl/fortran/dim3/read_parameters.hpp"
#include "enumerations/interface.hpp"
#include "kokkos_abstractions.h"
#include "medium/material.hpp"
Expand Down Expand Up @@ -227,18 +228,19 @@ specfem::IO::read_2d_mesh(const std::string filename,
}

specfem::mesh::mesh<specfem::dimension::type::dim3>
specfem::IO::read_3d_mesh(const std::string filename,
specfem::IO::read_3d_mesh(const std::string mesh_parameters_file,
const std::string mesh_databases_file,
const specfem::MPI::MPI *mpi) {

// Declaring empty mesh objects
specfem::mesh::mesh<specfem::dimension::type::dim3> mesh;

// Open the database file
std::ifstream stream;
stream.open(filename);
stream.open(mesh_parameters_file);

if (!stream.is_open()) {
throw std::runtime_error("Could not open database file");
throw std::runtime_error("Could not open mesh parameter file");
}

try {
Expand All @@ -249,6 +251,18 @@ specfem::IO::read_3d_mesh(const std::string filename,
throw;
}

// Mesh Parameters are populated, closing the parameters file.
stream.close();

// Open the database file
stream.open(mesh_databases_file);

if (!stream.is_open()) {
throw std::runtime_error("Could not open mesh database file");
}

stream.close();

// // Mesh class to be populated from the database file.
// try {
// mesh.control_nodes.coord =
Expand Down
Loading

0 comments on commit fc4687e

Please sign in to comment.