Skip to content

Commit

Permalink
Added coupled interfaces reader | mesh tests updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Rohit-Kakodkar committed Aug 28, 2023
1 parent 653509a commit 723977c
Show file tree
Hide file tree
Showing 17 changed files with 296 additions and 106 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ add_library(
src/mesh/mpi_interfaces/mpi_interfaces.cpp
src/mesh/material_indic/material_indic.cpp
src/mesh/surfaces/acoustic_free_surface.cpp
src/mesh/coupled_interfaces/elastic_acoustic.cpp
src/mesh/coupled_interfaces/elastic_poroelastic.cpp
src/mesh/coupled_interfaces/acoustic_poroelastic.cpp
src/mesh/mesh.cpp
)

Expand Down
6 changes: 0 additions & 6 deletions include/mesh/IO/fortran/read_mesh_database.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,6 @@ read_coorg_elements(std::ifstream &stream, const int npgeo,
std::tuple<int, type_real, bool>
read_mesh_database_attenuation(std::ifstream &stream,
const specfem::MPI::MPI *mpi);

void read_mesh_database_coupled(std::ifstream &stream,
const int num_fluid_solid_edges,
const int num_fluid_poro_edges,
const int num_solid_poro_edges,
const specfem::MPI::MPI *mpi);
} // namespace fortran
} // namespace IO
} // namespace mesh
Expand Down
23 changes: 23 additions & 0 deletions include/mesh/coupled_interfaces/acoustic_poroelastic.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#ifndef _COUPLED_ACOUSTIC_POORELASTIC_HPP_
#define _COUPLED_ACOUSTIC_POORELASTIC_HPP_

#include "kokkos_abstractions.h"
#include "specfem_mpi/interface.hpp"

namespace specfem {
namespace mesh {
namespace coupled_interfaces {
struct acoustic_poroelastic {
public:
acoustic_poroelastic(){};
acoustic_poroelastic(const int num_interfaces, std::ifstream &stream,
const specfem::MPI::MPI *mpi);
int num_interfaces;
specfem::kokkos::HostView1d<int> acoustic_ispec;
specfem::kokkos::HostView1d<int> poroelastic_ispec;
};
} // namespace coupled_interfaces
} // namespace mesh
} // namespace specfem

#endif /* _COUPLED_ACOUSTIC_POORELASTIC_HPP_ */
33 changes: 33 additions & 0 deletions include/mesh/coupled_interfaces/coupled_interfaces.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#ifndef _COUPLED_INTERFACES_HPP_
#define _COUPLED_INTERFACES_HPP_

#include "acoustic_poroelastic.hpp"
#include "elastic_acoustic.hpp"
#include "elastic_poroelastic.hpp"
#include "specfem_mpi/interface.hpp"

namespace specfem {
namespace mesh {
namespace coupled_interfaces {

struct coupled_interfaces {
public:
coupled_interfaces()
: elastic_acoustic(), acoustic_poroelastic(), elastic_poroelastic(){};
coupled_interfaces(std::ifstream &stream,
const int num_interfaces_elastic_acoustic,
const int num_interfaces_acoustic_poroelastic,
const int num_interfaces_elastic_poroelastic,
const specfem::MPI::MPI *mpi)
: elastic_acoustic(num_interfaces_elastic_acoustic, stream, mpi),
acoustic_poroelastic(num_interfaces_acoustic_poroelastic, stream, mpi),
elastic_poroelastic(num_interfaces_elastic_poroelastic, stream, mpi){};
specfem::mesh::coupled_interfaces::elastic_acoustic elastic_acoustic;
specfem::mesh::coupled_interfaces::elastic_poroelastic elastic_poroelastic;
specfem::mesh::coupled_interfaces::acoustic_poroelastic acoustic_poroelastic;
};

} // namespace coupled_interfaces
} // namespace mesh
} // namespace specfem
#endif /* _COUPLED_INTERFACES_HPP_ */
24 changes: 24 additions & 0 deletions include/mesh/coupled_interfaces/elastic_acoustic.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#ifndef _COUPLED_ELASTIC_ACOUSTIC_HPP_
#define _COUPLED_ELASTIC_ACOUSTIC_HPP_

#include "kokkos_abstractions.h"
#include "specfem_mpi/interface.hpp"

namespace specfem {
namespace mesh {
namespace coupled_interfaces {
struct elastic_acoustic {
public:
elastic_acoustic(){};
elastic_acoustic(const int num_interfaces, std::ifstream &stream,
const specfem::MPI::MPI *mpi);

int num_interfaces;
specfem::kokkos::HostView1d<int> elastic_ispec;
specfem::kokkos::HostView1d<int> acoustic_ispec;
};
} // namespace coupled_interfaces
} // namespace mesh
} // namespace specfem

#endif /* _COUPLED_ELASTIC_ACOUSTIC_HPP_ */
23 changes: 23 additions & 0 deletions include/mesh/coupled_interfaces/elastic_poroelastic.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#ifndef _COUPLED_ELASTIC_POORELASTIC_HPP_
#define _COUPLED_ELASTIC_POORELASTIC_HPP_

#include "kokkos_abstractions.h"
#include "specfem_mpi/interface.hpp"

namespace specfem {
namespace mesh {
namespace coupled_interfaces {
struct elastic_poroelastic {
public:
elastic_poroelastic(){};
elastic_poroelastic(const int num_interfaces, std::ifstream &stream,
const specfem::MPI::MPI *mpi);
int num_interfaces;
specfem::kokkos::HostView1d<int> elastic_ispec;
specfem::kokkos::HostView1d<int> poroelastic_ispec;
};
} // namespace coupled_interfaces
} // namespace mesh
} // namespace specfem

#endif /* _COUPLED_ELASTIC_POORELASTIC_HPP_ */
11 changes: 5 additions & 6 deletions include/mesh/mesh.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "IO/fortran/read_mesh_database.hpp"
#include "boundaries/boundaries.hpp"
#include "compute/interface.hpp"
#include "coupled_interfaces/coupled_interfaces.hpp"
#include "elements/elements.hpp"
#include "kokkos_abstractions.h"
#include "material/interface.hpp"
Expand Down Expand Up @@ -39,12 +40,6 @@ struct mesh {
///< material information for
///< every spectral element

// specfem::mesh::interfaces::interface interface; ///< Struct used to store
// data
// ///< required to implement
// MPI
// ///< interfaces

specfem::mesh::boundaries::absorbing_boundary abs_boundary; ///< Struct used
///< to store data
///< required to
Expand All @@ -55,6 +50,10 @@ struct mesh {
specfem::mesh::properties parameters; ///< Struct to store simulation launch
///< parameters

specfem::mesh::coupled_interfaces::coupled_interfaces
coupled_interfaces; ///< Struct to store
///< coupled interfaces

specfem::mesh::surfaces::acoustic_free_surface
acfree_surface; ///< Struct used to store data required to implement
///< acoustic free surface
Expand Down
29 changes: 0 additions & 29 deletions src/mesh/IO/fortran/read_mesh_database.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,32 +205,3 @@ specfem::mesh::IO::fortran::read_mesh_database_attenuation(
return std::make_tuple(n_sls, attenuation_f0_reference,
read_velocities_at_f0);
}

void specfem::mesh::IO::fortran::read_mesh_database_coupled(
std::ifstream &stream, const int num_fluid_solid_edges,
const int num_fluid_poro_edges, const int num_solid_poro_edges,
const specfem::MPI::MPI *mpi) {

int dummy_i, dummy_i1;

if (num_fluid_solid_edges > 0 || num_fluid_poro_edges > 0 ||
num_solid_poro_edges > 0) {
mpi->cout("\n Warning coupled surfaces haven't been implemented yet \n");
}

if (num_fluid_solid_edges > 0) {
for (int inum = 0; inum < num_fluid_solid_edges; inum++)
specfem::fortran_IO::fortran_read_line(stream, &dummy_i, &dummy_i1);
}

if (num_fluid_poro_edges > 0) {
for (int inum = 0; inum < num_fluid_poro_edges; inum++)
specfem::fortran_IO::fortran_read_line(stream, &dummy_i, &dummy_i1);
}

if (num_solid_poro_edges > 0) {
for (int inum = 0; inum < num_solid_poro_edges; inum++)
specfem::fortran_IO::fortran_read_line(stream, &dummy_i, &dummy_i1);
}
return;
}
24 changes: 24 additions & 0 deletions src/mesh/coupled_interfaces/acoustic_poroelastic.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "mesh/coupled_interfaces/acoustic_poroelastic.hpp"
#include "fortranio/interface.hpp"

specfem::mesh::coupled_interfaces::acoustic_poroelastic::acoustic_poroelastic(
const int num_interfaces, std::ifstream &stream,
const specfem::MPI::MPI *mpi)
: num_interfaces(num_interfaces),
acoustic_ispec("acoustic_ispec", num_interfaces),
poroelastic_ispec("poroelastic_ispec", num_interfaces) {

if (!num_interfaces)
return;

int acoustic_ispec_l, poroelastic_ispec_l;

for (int i = 0; i < num_interfaces; i++) {
specfem::fortran_IO::fortran_read_line(stream, &poroelastic_ispec_l,
&acoustic_ispec_l);
acoustic_ispec(i) = acoustic_ispec_l;
poroelastic_ispec(i) = poroelastic_ispec_l;
}

return;
}
24 changes: 24 additions & 0 deletions src/mesh/coupled_interfaces/elastic_acoustic.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "mesh/coupled_interfaces/elastic_acoustic.hpp"
#include "fortranio/interface.hpp"

specfem::mesh::coupled_interfaces::elastic_acoustic::elastic_acoustic(
const int num_interfaces, std::ifstream &stream,
const specfem::MPI::MPI *mpi)
: num_interfaces(num_interfaces),
elastic_ispec("elastic_ispec", num_interfaces),
acoustic_ispec("acoustic_ispec", num_interfaces) {

if (!num_interfaces)
return;

int elastic_ispec_l, acoustic_ispec_l;

for (int i = 0; i < num_interfaces; i++) {
specfem::fortran_IO::fortran_read_line(stream, &acoustic_ispec_l,
&elastic_ispec_l);
elastic_ispec(i) = elastic_ispec_l;
acoustic_ispec(i) = acoustic_ispec_l;
}

return;
}
24 changes: 24 additions & 0 deletions src/mesh/coupled_interfaces/elastic_poroelastic.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "mesh/coupled_interfaces/elastic_poroelastic.hpp"
#include "fortranio/interface.hpp"

specfem::mesh::coupled_interfaces::elastic_poroelastic::elastic_poroelastic(
const int num_interfaces, std::ifstream &stream,
const specfem::MPI::MPI *mpi)
: num_interfaces(num_interfaces),
elastic_ispec("elastic_ispec", num_interfaces),
poroelastic_ispec("poroelastic_ispec", num_interfaces) {

if (!num_interfaces)
return;

int elastic_ispec_l, poroelastic_ispec_l;

for (int i = 0; i < num_interfaces; i++) {
specfem::fortran_IO::fortran_read_line(stream, &poroelastic_ispec_l,
&elastic_ispec_l);
elastic_ispec(i) = elastic_ispec_l;
poroelastic_ispec(i) = poroelastic_ispec_l;
}

return;
}
9 changes: 5 additions & 4 deletions src/mesh/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,10 +127,11 @@ specfem::mesh::mesh::mesh(const std::string filename,
}

try {
specfem::mesh::IO::fortran::read_mesh_database_coupled(
stream, this->parameters.num_fluid_solid_edges,
this->parameters.num_fluid_poro_edges,
this->parameters.num_solid_poro_edges, mpi);
this->coupled_interfaces =
specfem::mesh::coupled_interfaces::coupled_interfaces(
stream, this->parameters.num_fluid_solid_edges,
this->parameters.num_fluid_poro_edges,
this->parameters.num_solid_poro_edges, mpi);
} catch (std::runtime_error &e) {
throw;
}
Expand Down
Loading

0 comments on commit 723977c

Please sign in to comment.