Skip to content

Commit

Permalink
Updates mesh reader for shear waves
Browse files Browse the repository at this point in the history
- Implements point::properties for shear waves.
	- To do this I create a base class with medium_tag = specfem::element::medium_tag::elastic
- Implements medium::properties for shear waves
	- Again this is implemented with a base class with medium_tag = specfem::element::medium_tag::elastic
- Update specfem::IO::read_mesh signature to include a elastic_wave argument. The elastic_wave would be set up using specfem_config.yaml
- Updates tests for the mesher
  • Loading branch information
Rohit-Kakodkar committed Feb 19, 2025
1 parent b59ead1 commit fe6635e
Show file tree
Hide file tree
Showing 26 changed files with 618 additions and 87 deletions.
3 changes: 2 additions & 1 deletion include/IO/interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ namespace IO {
*
*/
specfem::mesh::mesh<specfem::dimension::type::dim2>
read_mesh(const std::string filename, const specfem::MPI::MPI *mpi);
read_mesh(const std::string filename, const specfem::enums::elastic_wave wave,
const specfem::MPI::MPI *mpi);

/**
* @brief Read station file
Expand Down
1 change: 1 addition & 0 deletions include/IO/mesh/impl/fortran/read_material_properties.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace fortran {

specfem::mesh::materials read_material_properties(
std::ifstream &stream, const int numat, const int nspec,
const specfem::enums::elastic_wave wave,
const specfem::kokkos::HostView2d<int> knods, const specfem::MPI::MPI *mpi);

} // namespace fortran
Expand Down
8 changes: 7 additions & 1 deletion include/enumerations/medium.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ constexpr int ntypes = 3; ///< Number of element types
* @brief Medium tag enumeration
*
*/
enum class medium_tag { elastic_sv, elastic_sh, acoustic, poroelastic };
enum class medium_tag {
elastic_sv,
elastic_sh,
acoustic,
elastic,
poroelastic
};

/**
* @brief Property tag enumeration
Expand Down
2 changes: 2 additions & 0 deletions include/enumerations/specfem_enums.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ namespace specfem {
*/
namespace enums {

enum class elastic_wave { p_sv, sh };

/**
* @brief Cartesian axes enumeration
*
Expand Down
60 changes: 57 additions & 3 deletions include/medium/dim2/elastic/anisotropic/properties.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ namespace medium {
*
*/
template <>
class properties<specfem::element::medium_tag::elastic_sv,
class properties<specfem::element::medium_tag::elastic,
specfem::element::property_tag::anisotropic> {
public:
constexpr static auto dimension =
Expand Down Expand Up @@ -77,7 +77,7 @@ class properties<specfem::element::medium_tag::elastic_sv,
* @param other Material to compare with
* @return true If the materials have the same properties
*/
bool operator==(const properties<specfem::element::medium_tag::elastic_sv,
bool operator==(const properties<specfem::element::medium_tag::elastic,
specfem::element::property_tag::anisotropic>
&other) const {
return (std::abs(this->density - other.density) < 1e-6 &&
Expand All @@ -100,7 +100,7 @@ class properties<specfem::element::medium_tag::elastic_sv,
* @param other Material to compare with
* @return true If the materials have different properties
*/
bool operator!=(const properties<specfem::element::medium_tag::elastic_sv,
bool operator!=(const properties<specfem::element::medium_tag::elastic,
specfem::element::property_tag::anisotropic>
&other) const {
return !(*this == other);
Expand Down Expand Up @@ -151,5 +151,59 @@ class properties<specfem::element::medium_tag::elastic_sv,
type_real Qmu; ///< Attenuation factor for shear modulus
};

template <>
class properties<specfem::element::medium_tag::elastic_sv,
specfem::element::property_tag::anisotropic>
: public properties<specfem::element::medium_tag::elastic,
specfem::element::property_tag::anisotropic> {

public:
constexpr static auto dimension =
specfem::dimension::type::dim2; ///< Dimension of the material
constexpr static auto medium_tag =
specfem::element::medium_tag::elastic_sv; ///< Medium tag
constexpr static auto property_tag =
specfem::element::property_tag::anisotropic; ///< Property tag

properties(const type_real &density, const type_real &c11,
const type_real &c13, const type_real &c15, const type_real &c33,
const type_real &c35, const type_real &c55, const type_real &c12,
const type_real &c23, const type_real &c25,
const type_real &Qkappa, const type_real &Qmu)
: properties<specfem::element::medium_tag::elastic,
specfem::element::property_tag::anisotropic>(
density, c11, c13, c15, c33, c35, c55, c12, c23, c25, Qkappa, Qmu) {
}

properties() = default;
};

template <>
class properties<specfem::element::medium_tag::elastic_sh,
specfem::element::property_tag::anisotropic>
: public properties<specfem::element::medium_tag::elastic,
specfem::element::property_tag::anisotropic> {

public:
constexpr static auto dimension =
specfem::dimension::type::dim2; ///< Dimension of the material
constexpr static auto medium_tag =
specfem::element::medium_tag::elastic_sh; ///< Medium tag
constexpr static auto property_tag =
specfem::element::property_tag::anisotropic; ///< Property tag

properties(const type_real &density, const type_real &c11,
const type_real &c13, const type_real &c15, const type_real &c33,
const type_real &c35, const type_real &c55, const type_real &c12,
const type_real &c23, const type_real &c25,
const type_real &Qkappa, const type_real &Qmu)
: properties<specfem::element::medium_tag::elastic,
specfem::element::property_tag::anisotropic>(
density, c11, c13, c15, c33, c35, c55, c12, c23, c25, Qkappa, Qmu) {
}

properties() = default;
};

} // namespace medium
} // namespace specfem
Original file line number Diff line number Diff line change
Expand Up @@ -265,8 +265,8 @@ struct properties_container<specfem::element::medium_tag::elastic_sv,

static_assert(PointProperties::dimension == dimension,
"Dimension mismatch");
static_assert(PointProperties::medium_tag == value_type,
"Medium tag mismatch");
// static_assert(PointProperties::medium_tag == value_type,
// "Medium tag mismatch");
static_assert(PointProperties::property_tag == property_type,
"Property tag mismatch");

Expand Down Expand Up @@ -294,8 +294,8 @@ struct properties_container<specfem::element::medium_tag::elastic_sv,

static_assert(PointProperties::dimension == dimension,
"Dimension mismatch");
static_assert(PointProperties::medium_tag == value_type,
"Medium tag mismatch");
// static_assert(PointProperties::medium_tag == value_type,
// "Medium tag mismatch");
static_assert(PointProperties::property_tag == property_type,
"Property tag mismatch");

Expand Down
54 changes: 50 additions & 4 deletions include/medium/dim2/elastic/isotropic/properties.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ namespace medium {
*
*/
template <>
class properties<specfem::element::medium_tag::elastic_sv,
class properties<specfem::element::medium_tag::elastic,
specfem::element::property_tag::isotropic> {
public:
constexpr static auto dimension =
specfem::dimension::type::dim2; ///< Dimension of the material
constexpr static auto medium_tag =
specfem::element::medium_tag::elastic_sv; ///< Medium tag
specfem::element::medium_tag::elastic; ///< Medium tag
constexpr static auto property_tag =
specfem::element::property_tag::isotropic; ///< Property tag

Expand Down Expand Up @@ -73,7 +73,7 @@ class properties<specfem::element::medium_tag::elastic_sv,
* @param other Material to compare with
* @return true If the materials have the same properties
*/
bool operator==(const properties<specfem::element::medium_tag::elastic_sv,
bool operator==(const properties<specfem::element::medium_tag::elastic,
specfem::element::property_tag::isotropic>
&other) const {

Expand All @@ -91,7 +91,7 @@ class properties<specfem::element::medium_tag::elastic_sv,
* @param other Material to compare with
* @return true If the materials have different properties
*/
bool operator!=(const properties<specfem::element::medium_tag::elastic_sv,
bool operator!=(const properties<specfem::element::medium_tag::elastic,
specfem::element::property_tag::isotropic>
&other) const {
return !(*this == other);
Expand Down Expand Up @@ -142,5 +142,51 @@ class properties<specfem::element::medium_tag::elastic_sv,
type_real poisson; ///< Poisson's ratio
};

template <>
class properties<specfem::element::medium_tag::elastic_sv,
specfem::element::property_tag::isotropic>
: public properties<specfem::element::medium_tag::elastic,
specfem::element::property_tag::isotropic> {
public:
constexpr static auto dimension =
specfem::dimension::type::dim2; ///< Dimension of the material
constexpr static auto medium_tag =
specfem::element::medium_tag::elastic_sv; ///< Medium tag
constexpr static auto property_tag =
specfem::element::property_tag::isotropic; ///< Property tag

properties(const type_real &density, const type_real &cs, const type_real &cp,
const type_real &Qkappa, const type_real &Qmu,
const type_real &compaction_grad)
: properties<specfem::element::medium_tag::elastic,
specfem::element::property_tag::isotropic>(
density, cs, cp, Qkappa, Qmu, compaction_grad) {}

properties() = default;
};

template <>
class properties<specfem::element::medium_tag::elastic_sh,
specfem::element::property_tag::isotropic>
: public properties<specfem::element::medium_tag::elastic,
specfem::element::property_tag::isotropic> {
public:
constexpr static auto dimension =
specfem::dimension::type::dim2; ///< Dimension of the material
constexpr static auto medium_tag =
specfem::element::medium_tag::elastic_sh; ///< Medium tag
constexpr static auto property_tag =
specfem::element::property_tag::isotropic; ///< Property tag

properties(const type_real &density, const type_real &cs, const type_real &cp,
const type_real &Qkappa, const type_real &Qmu,
const type_real &compaction_grad)
: properties<specfem::element::medium_tag::elastic,
specfem::element::property_tag::isotropic>(
density, cs, cp, Qkappa, Qmu, compaction_grad) {}

properties() = default;
};

} // namespace medium
} // namespace specfem
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ struct properties_container<specfem::element::medium_tag::elastic_sv,

static_assert(PointProperties::dimension == dimension,
"Dimension mismatch");
static_assert(PointProperties::medium_tag == value_type,
"Medium tag mismatch");
// static_assert(PointProperties::medium_tag == value_type,
// "Medium tag mismatch");
static_assert(PointProperties::property_tag == property_type,
"Property tag mismatch");

Expand All @@ -207,8 +207,8 @@ struct properties_container<specfem::element::medium_tag::elastic_sv,

static_assert(PointProperties::dimension == dimension,
"Dimension mismatch");
static_assert(PointProperties::medium_tag == value_type,
"Medium tag mismatch");
// static_assert(PointProperties::medium_tag == value_type,
// "Medium tag mismatch");
static_assert(PointProperties::property_tag == property_type,
"Property tag mismatch");

Expand Down
13 changes: 13 additions & 0 deletions include/mesh/materials/materials.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,15 @@ struct materials {
specfem::element::property_tag::anisotropic>
elastic_sv_anisotropic; ///< Elastic anisotropic material properties

specfem::mesh::materials::material<specfem::element::medium_tag::elastic_sh,
specfem::element::property_tag::isotropic>
elastic_sh_isotropic; ///< Elastic isotropic material properties

specfem::mesh::materials::material<
specfem::element::medium_tag::elastic_sh,
specfem::element::property_tag::anisotropic>
elastic_sh_anisotropic; ///< Elastic anisotropic material properties

specfem::mesh::materials::material<specfem::element::medium_tag::acoustic,
specfem::element::property_tag::isotropic>
acoustic_isotropic; ///< Acoustic isotropic material properties
Expand Down Expand Up @@ -104,6 +113,10 @@ struct materials {
specfem::element::property_tag::isotropic>,
specfem::medium::material<specfem::element::medium_tag::elastic_sv,
specfem::element::property_tag::anisotropic>,
specfem::medium::material<specfem::element::medium_tag::elastic_sh,
specfem::element::property_tag::isotropic>,
specfem::medium::material<specfem::element::medium_tag::elastic_sh,
specfem::element::property_tag::anisotropic>,
specfem::medium::material<specfem::element::medium_tag::acoustic,
specfem::element::property_tag::isotropic> >
operator[](const int index) const;
Expand Down
Loading

0 comments on commit fe6635e

Please sign in to comment.