Skip to content

Commit

Permalink
Fixed and updated mesh print
Browse files Browse the repository at this point in the history
  • Loading branch information
lsawade committed Feb 26, 2025
1 parent 3ba3e47 commit afd53c0
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 25 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,7 @@ add_library(

target_link_libraries(
mesh
enumerations
Kokkos::kokkos
specfem_mpi
# material_class
Expand Down
3 changes: 3 additions & 0 deletions src/IO/mesh/impl/fortran/dim3/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,9 @@ specfem::IO::read_3d_mesh(const std::string mesh_parameters_file,
// Read test value 9997
check_read_test_value(stream, 9997);

// Final print with basic information
mpi->cout(mesh.print());

stream.close();

return mesh;
Expand Down
52 changes: 27 additions & 25 deletions src/mesh/dim3/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,37 @@
#include <memory>
#include <vector>

std::string specfem::mesh::mesh<specfem::dimension::type::dim2>::print() const {
std::string specfem::mesh::mesh<specfem::dimension::type::dim3>::print() const {

int n_elastic;
int n_acoustic;
std::ostringstream message;

Kokkos::parallel_reduce(
"specfem::mesh::mesh::print", specfem::kokkos::HostRange(0, this->nspec),
KOKKOS_CLASS_LAMBDA(const int ispec, int &n_elastic, int &n_acoustic) {
if (this->materials.material_index_mapping(ispec).type ==
specfem::element::medium_tag::elastic) {
n_elastic++;
} else if (this->materials.material_index_mapping(ispec).type ==
specfem::element::medium_tag::acoustic) {
n_acoustic++;
}
},
n_elastic, n_acoustic);
int nspec = this->parameters.nspec;
int nglob = this->parameters.nglob;
int nspec_irregular = this->parameters.nspec_irregular;
int ngllx = this->parameters.ngllx;
int nglly = this->parameters.nglly;
int ngllz = this->parameters.ngllz;

std::ostringstream message;
int nacoustic = this->elements_types.nacoustic;
int nelastic = this->elements_types.nelastic;
int nporoelastic = this->elements_types.nporoelastic;

message
<< "Spectral element information:\n"
<< "------------------------------\n"
<< "Total number of spectral elements : " << this->nspec << "\n"
<< "Total number of spectral elements assigned to elastic material : "
<< n_elastic << "\n"
<< "Total number of spectral elements assigned to acoustic material : "
<< n_acoustic << "\n"
<< "Total number of geometric points : " << this->npgeo << "\n";
// Print Mapping parameters
message << "3D Mesh information :\n"
<< "------------------------------\n"
<< "Total number of spectral elements: " << nspec << "\n"
<< "Total number of global nodes: " << nglob << "\n"
<< "Total number of irregular spectral elements: " << nspec_irregular
<< "\n"
<< "Total number of GLLX: " << ngllx << "\n"
<< "Total number of GLLY: " << nglly << "\n"
<< "Total number of GLLZ: " << ngllz << "\n"
<< "\n"
<< "Total number of acoustic spectral elements: " << nacoustic << "\n"
<< "Total number of elastic spectral elements: " << nelastic << "\n"
<< "Total number of poroelastic spectral elements: " << nporoelastic
<< "\n"
<< "------------------------------\n";

return message.str();
}

0 comments on commit afd53c0

Please sign in to comment.