Skip to content

Commit

Permalink
Updated printing
Browse files Browse the repository at this point in the history
  • Loading branch information
lsawade committed Feb 26, 2025
1 parent 5ef01db commit 3ba3e47
Show file tree
Hide file tree
Showing 10 changed files with 206 additions and 157 deletions.
2 changes: 1 addition & 1 deletion include/mesh/dim3/boundaries/free_surface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ template <> struct free_surface<specfem::dimension::type::dim3> {
* @endcode
*
*/
void print() const;
std::string print() const;
};

} // namespace mesh
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ template <> struct coupled_interfaces<specfem::dimension::type::dim3> {
* @brief Print basic information about the coupled interfaces to std::cout
*
*/
void print() const;
std::string print() const;
};

} // namespace mesh
Expand Down
2 changes: 1 addition & 1 deletion include/mesh/dim3/materials/materials.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ template <> struct materials<specfem::dimension::type::dim3> {
* @brief Print basic information about the materials
*
*/
void print();
std::string print();
};
} // namespace mesh
} // namespace specfem
4 changes: 2 additions & 2 deletions include/mesh/dim3/partial_derivatives/partial_derivatives.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ template <> struct partial_derivatives<specfem::dimension::type::dim3> {
* @brief Print basic information on the partial derivatives
*
*/
void print() const;
std::string print() const;

/**
* @brief Print the partial derivatives for a given spectral element and
Expand All @@ -81,7 +81,7 @@ template <> struct partial_derivatives<specfem::dimension::type::dim3> {
* @param iglly GLL point index in y
* @param igllz GLL point index in z
*/
void print(int ispec, int igllx, int iglly, int igllz) const;
std::string print(int ispec, int igllx, int iglly, int igllz) const;
};

} // namespace mesh
Expand Down
49 changes: 26 additions & 23 deletions src/IO/mesh/impl/fortran/dim3/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ specfem::IO::read_3d_mesh(const std::string mesh_parameters_file,

#ifndef NDEBUG
// Print Coordinates parameters and the first global node
mesh.coordinates.print();
mesh.coordinates.print(0);
mesh.coordinates.print(mesh.parameters.nglob - 1);
mpi->cout(mesh.coordinates.print());
mpi->cout(mesh.coordinates.print(0));
mpi->cout(mesh.coordinates.print(mesh.parameters.nglob - 1));
#endif

// Initialize the partial derivatives object
Expand All @@ -146,16 +146,17 @@ specfem::IO::read_3d_mesh(const std::string mesh_parameters_file,

#ifndef NDEBUG
// Print the first and last irregular element
std::cout << "First irregular element: " << mesh.irregular_element_number(0)
<< std::endl;
std::cout << "Last irregular element: "
<< mesh.irregular_element_number(mesh.parameters.nspec_irregular -
1)
<< std::endl;
std::ostringstream message;
message << "First irregular element: " << mesh.irregular_element_number(0)
<< "\n";
message << "Last irregular element: "
<< mesh.irregular_element_number(mesh.parameters.nspec_irregular - 1)
<< "\n";

// Print xix and jacobian
std::cout << "xix_regular: " << mesh.xix_regular << std::endl;
std::cout << "jacobian_regular: " << mesh.jacobian_regular << std::endl;
message << "xix_regular: " << mesh.xix_regular << "\n";
message << "jacobian_regular: " << mesh.jacobian_regular << "\n";
mpi->cout(message.str());
#endif

// Create the partial derivatives object
Expand All @@ -178,8 +179,8 @@ specfem::IO::read_3d_mesh(const std::string mesh_parameters_file,

#ifndef NDEBUG
// Print Partial Derivatives parameters and the first spectral element
mesh.partial_derivatives.print();
mesh.partial_derivatives.print(0, 0, 0, 0);
mpi->cout(mesh.partial_derivatives.print());
mpi->cout(mesh.partial_derivatives.print(0, 0, 0, 0));
#endif

// Marker that should be 10000
Expand All @@ -197,7 +198,7 @@ specfem::IO::read_3d_mesh(const std::string mesh_parameters_file,

#ifndef NDEBUG
// Print the materials
mesh.materials.print();
mpi->cout(mesh.materials.print());
#endif

int nacoustic, nelastic, nporoelastic;
Expand Down Expand Up @@ -362,12 +363,14 @@ specfem::IO::read_3d_mesh(const std::string mesh_parameters_file,

#ifndef NDEBUG
// Print the number of boundaries
std::cout << "nspec2D_xmin: " << nspec2D_xmin << std::endl;
std::cout << "nspec2D_xmax: " << nspec2D_xmax << std::endl;
std::cout << "nspec2D_ymin: " << nspec2D_ymin << std::endl;
std::cout << "nspec2D_ymax: " << nspec2D_ymax << std::endl;
std::cout << "nspec2D_bottom: " << nspec2D_bottom << std::endl;
std::cout << "nspec2D_top: " << nspec2D_top << std::endl;
message = std::ostringstream();
message << "nspec2D_xmin: " << nspec2D_xmin << "\n";
message << "nspec2D_xmax: " << nspec2D_xmax << "\n";
message << "nspec2D_ymin: " << nspec2D_ymin << "\n";
message << "nspec2D_ymax: " << nspec2D_ymax << "\n";
message << "nspec2D_bottom: " << nspec2D_bottom << "\n";
message << "nspec2D_top: " << nspec2D_top << "\n";
mpi->cout(message.str());
#endif

// Check values
Expand Down Expand Up @@ -407,7 +410,7 @@ specfem::IO::read_3d_mesh(const std::string mesh_parameters_file,
}
// Print the abosrbing boundaries
#ifndef NDEBUG
mesh.absorbing_boundary.print();
mpi->cout(mesh.absorbing_boundary.print());
#endif
}

Expand All @@ -431,7 +434,7 @@ specfem::IO::read_3d_mesh(const std::string mesh_parameters_file,

#ifndef NDEBUG
// Print the free surface
mesh.free_surface.print();
mpi->cout(mesh.free_surface.print());
#endif

// Create the coupled interfaces object
Expand Down Expand Up @@ -524,7 +527,7 @@ specfem::IO::read_3d_mesh(const std::string mesh_parameters_file,

#ifndef NDEBUG
// Print the interfaces
mesh.coupled_interfaces.print();
mpi->cout(mesh.coupled_interfaces.print());
#endif

// Read test value 9997
Expand Down
42 changes: 25 additions & 17 deletions src/mesh/dim3/boundaries/free_surface.cpp
Original file line number Diff line number Diff line change
@@ -1,25 +1,33 @@
#include "mesh/mesh.hpp"
#include <iostream>
#include <sstream>

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

std::ostringstream message;

// Print variables and metadata
std::cout << "Absorbing Boundary Metadata:" << std::endl;
std::cout << "================================================" << std::endl;
std::cout << " nelements:.............. " << nelements << std::endl;
std::cout << " ngllsquare:............. " << ngllsquare << std::endl;
std::cout << " num_free_surface_faces:. " << num_free_surface_faces
<< std::endl;
message << "Absorbing Boundary Metadata:"
<< "\n";
message << "================================================"
<< "\n";
message << " nelements:.............. " << nelements << "\n";
message << " ngllsquare:............. " << ngllsquare << "\n";
message << " num_free_surface_faces:. " << num_free_surface_faces << "\n";

// Print the absorbing ispec metadata
std::cout << " Array sizes:" << std::endl;
std::cout << " -----------------------------------------------" << std::endl;
std::cout << " ispec:.................. " << ispec.extent(0) << std::endl;
std::cout << " ijk:.................... " << ijk.extent(0) << " "
<< ijk.extent(1) << " " << ijk.extent(2) << std::endl;
std::cout << " jacobian2Dw:............ " << jacobian2Dw.extent(0) << " "
<< jacobian2Dw.extent(1) << std::endl;
std::cout << " normal:................. " << normal.extent(0) << " "
<< normal.extent(1) << " " << normal.extent(2) << std::endl;
message << " Array sizes:"
<< "\n";
message << " -----------------------------------------------"
<< "\n";
message << " ispec:.................. " << ispec.extent(0) << "\n";
message << " ijk:.................... " << ijk.extent(0) << " "
<< ijk.extent(1) << " " << ijk.extent(2) << "\n";
message << " jacobian2Dw:............ " << jacobian2Dw.extent(0) << " "
<< jacobian2Dw.extent(1) << "\n";
message << " normal:................. " << normal.extent(0) << " "
<< normal.extent(1) << " " << normal.extent(2) << "\n";

return message.str();
}
156 changes: 84 additions & 72 deletions src/mesh/dim3/coupled_interfaces/coupled_interfaces.cpp
Original file line number Diff line number Diff line change
@@ -1,98 +1,110 @@
#include "mesh/mesh.hpp"
#include <iostream>

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

std::ostringstream message;

if (acoustic_elastic) {
std::cout << "Acoustic Elastic Interface Metadata:" << std::endl;
std::cout << "================================================"
<< std::endl;
std::cout << " ngllsquare:............... " << ngllsquare << std::endl;
std::cout << " num_coupling_ac_el_faces:. " << num_coupling_ac_el_faces
<< std::endl;
message << "Acoustic Elastic Interface Metadata:"
<< "\n";
message << "================================================"
<< "\n";
message << " ngllsquare:............... " << ngllsquare << "\n";
message << " num_coupling_ac_el_faces:. " << num_coupling_ac_el_faces
<< "\n";

// Print the acoustic elastic interface metadata
std::cout << " Array sizes:" << std::endl;
std::cout << " -----------------------------------------------"
<< std::endl;
std::cout << " ispec:.................. "
<< acoustic_elastic_interface.ispec.extent(0) << std::endl;
std::cout << " ijk:.................... "
<< acoustic_elastic_interface.ijk.extent(0) << " "
<< acoustic_elastic_interface.ijk.extent(1) << " "
<< acoustic_elastic_interface.ijk.extent(2) << std::endl;
std::cout << " jacobian2Dw:............ "
<< acoustic_elastic_interface.jacobian2Dw.extent(0) << " "
<< acoustic_elastic_interface.jacobian2Dw.extent(1) << std::endl;
std::cout << " normal:................. "
<< acoustic_elastic_interface.normal.extent(0) << " "
<< acoustic_elastic_interface.normal.extent(1) << " "
<< acoustic_elastic_interface.normal.extent(2) << std::endl;
message << " Array sizes:"
<< "\n";
message << " -----------------------------------------------"
<< "\n";
message << " ispec:.................. "
<< acoustic_elastic_interface.ispec.extent(0) << "\n";
message << " ijk:.................... "
<< acoustic_elastic_interface.ijk.extent(0) << " "
<< acoustic_elastic_interface.ijk.extent(1) << " "
<< acoustic_elastic_interface.ijk.extent(2) << "\n";
message << " jacobian2Dw:............ "
<< acoustic_elastic_interface.jacobian2Dw.extent(0) << " "
<< acoustic_elastic_interface.jacobian2Dw.extent(1) << "\n";
message << " normal:................. "
<< acoustic_elastic_interface.normal.extent(0) << " "
<< acoustic_elastic_interface.normal.extent(1) << " "
<< acoustic_elastic_interface.normal.extent(2) << "\n";
} else {
std::cout << "No acoustic elastic interfaces" << std::endl;
message << "No acoustic elastic interfaces"
<< "\n";
}

if (acoustic_poroelastic) {

std::cout << "Acoustic Poroelastic Interface Metadata:" << std::endl;
std::cout << "================================================"
<< std::endl;
std::cout << " ngllsquare:............... " << ngllsquare << std::endl;
std::cout << " num_coupling_ac_po_faces:. " << num_coupling_ac_po_faces
<< std::endl;
message << "Acoustic Poroelastic Interface Metadata:"
<< "\n";
message << "================================================"
<< "\n";
message << " ngllsquare:............... " << ngllsquare << "\n";
message << " num_coupling_ac_po_faces:. " << num_coupling_ac_po_faces
<< "\n";

// Print the acoustic poroelastic interface metadata
std::cout << " Array sizes:" << std::endl;
std::cout << " -----------------------------------------------"
<< std::endl;
std::cout << " ispec:.................. "
<< acoustic_poroelastic_interface.ispec.extent(0) << std::endl;
std::cout << " ijk:.................... "
<< acoustic_poroelastic_interface.ijk.extent(0) << " "
<< acoustic_poroelastic_interface.ijk.extent(1) << " "
<< acoustic_poroelastic_interface.ijk.extent(2) << std::endl;
std::cout << " jacobian2Dw:............ "
<< acoustic_poroelastic_interface.jacobian2Dw.extent(0) << " "
<< acoustic_poroelastic_interface.jacobian2Dw.extent(1)
<< std::endl;
std::cout << " normal:................. "
<< acoustic_poroelastic_interface.normal.extent(0) << " "
<< acoustic_poroelastic_interface.normal.extent(1) << " "
<< acoustic_poroelastic_interface.normal.extent(2) << std::endl;
message << " Array sizes:"
<< "\n";
message << " -----------------------------------------------"
<< "\n";
message << " ispec:.................. "
<< acoustic_poroelastic_interface.ispec.extent(0) << "\n";
message << " ijk:.................... "
<< acoustic_poroelastic_interface.ijk.extent(0) << " "
<< acoustic_poroelastic_interface.ijk.extent(1) << " "
<< acoustic_poroelastic_interface.ijk.extent(2) << "\n";
message << " jacobian2Dw:............ "
<< acoustic_poroelastic_interface.jacobian2Dw.extent(0) << " "
<< acoustic_poroelastic_interface.jacobian2Dw.extent(1) << "\n";
message << " normal:................. "
<< acoustic_poroelastic_interface.normal.extent(0) << " "
<< acoustic_poroelastic_interface.normal.extent(1) << " "
<< acoustic_poroelastic_interface.normal.extent(2) << "\n";
} else {
std::cout << "No acoustic poroelastic interfaces" << std::endl;
message << "No acoustic poroelastic interfaces"
<< "\n";
}

if (elastic_poroelastic) {

std::cout << "Elastic Poroelastic Interface Metadata:" << std::endl;
std::cout << "================================================"
<< std::endl;
std::cout << " ngllsquare:............... " << ngllsquare << std::endl;
std::cout << " num_coupling_el_po_faces:. " << num_coupling_el_po_faces
<< std::endl;
message << "Elastic Poroelastic Interface Metadata:"
<< "\n";
message << "================================================"
<< "\n";
message << " ngllsquare:............... " << ngllsquare << "\n";
message << " num_coupling_el_po_faces:. " << num_coupling_el_po_faces
<< "\n";

// Print the elastic poroelastic interface metadata
std::cout << " Array sizes:" << std::endl;
std::cout << " -----------------------------------------------"
<< std::endl;
std::cout << " ispec:.................. "
<< elastic_poroelastic_interface.ispec.extent(0) << std::endl;
std::cout << " ijk:.................... "
<< elastic_poroelastic_interface.ijk.extent(0) << " "
<< elastic_poroelastic_interface.ijk.extent(1) << " "
<< elastic_poroelastic_interface.ijk.extent(2) << std::endl;
std::cout << " jacobian2Dw:............ "
<< elastic_poroelastic_interface.jacobian2Dw.extent(0) << " "
<< elastic_poroelastic_interface.jacobian2Dw.extent(1)
<< std::endl;
std::cout << " normal:................. "
<< elastic_poroelastic_interface.normal.extent(0) << " "
<< elastic_poroelastic_interface.normal.extent(1) << " "
<< elastic_poroelastic_interface.normal.extent(2) << std::endl;
message << " Array sizes:"
<< "\n";
message << " -----------------------------------------------"
<< "\n";
message << " ispec:.................. "
<< elastic_poroelastic_interface.ispec.extent(0) << "\n";
message << " ijk:.................... "
<< elastic_poroelastic_interface.ijk.extent(0) << " "
<< elastic_poroelastic_interface.ijk.extent(1) << " "
<< elastic_poroelastic_interface.ijk.extent(2) << "\n";
message << " jacobian2Dw:............ "
<< elastic_poroelastic_interface.jacobian2Dw.extent(0) << " "
<< elastic_poroelastic_interface.jacobian2Dw.extent(1) << "\n";
message << " normal:................. "
<< elastic_poroelastic_interface.normal.extent(0) << " "
<< elastic_poroelastic_interface.normal.extent(1) << " "
<< elastic_poroelastic_interface.normal.extent(2) << "\n";

} else {
std::cout << "No elastic poroelastic interfaces" << std::endl;
message << "No elastic poroelastic interfaces"
<< "\n";
}

return message.str();
}
Loading

0 comments on commit 3ba3e47

Please sign in to comment.