-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Move all print statements to execute() #435
base: issue-432
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -185,20 +185,40 @@ specfem::IO::read_mesh(const std::string filename, | |
|
||
stream.close(); | ||
|
||
// Print material properties | ||
const auto &l_elastic_isotropic = | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of a separate print mesh function, the osstream operator could be overloaded like so: class A {
int val;
public:
A(int v) : val(v) {}
friend ostream& operator<<(ostream& os, const A& obj) {
os << obj.val;
return os;
}
}; then you can just std::cout << mesh << std::endl; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we define std::cout << mesh, it should call mesh.print(), which is already defined and prints different stuff. |
||
mesh.materials.elastic_isotropic.material_properties; | ||
const auto &l_acoustic_isotropic = | ||
mesh.materials.acoustic_isotropic.material_properties; | ||
|
||
const auto &l_elastic_anisotropic = | ||
mesh.materials.elastic_anisotropic.material_properties; | ||
|
||
assert(l_elastic_isotropic.size() + l_acoustic_isotropic.size() + | ||
l_elastic_anisotropic.size() == | ||
mesh.materials.n_materials); | ||
|
||
mesh.tags = specfem::mesh::tags<specfem::dimension::type::dim2>( | ||
mesh.materials, mesh.boundaries); | ||
|
||
return mesh; | ||
} | ||
|
||
void specfem::IO::print_mesh( | ||
const specfem::mesh::mesh<specfem::dimension::type::dim2> &mesh, | ||
const specfem::MPI::MPI *mpi) { | ||
|
||
mpi->cout("Material systems:\n" | ||
"------------------------------"); | ||
|
||
mpi->cout("Number of material systems = " + | ||
std::to_string(mesh.materials.n_materials) + "\n\n"); | ||
|
||
const auto l_elastic_isotropic = | ||
const auto &l_elastic_isotropic = | ||
mesh.materials.elastic_isotropic.material_properties; | ||
const auto l_acoustic_isotropic = | ||
const auto &l_acoustic_isotropic = | ||
mesh.materials.acoustic_isotropic.material_properties; | ||
|
||
const auto l_elastic_anisotropic = | ||
const auto &l_elastic_anisotropic = | ||
mesh.materials.elastic_anisotropic.material_properties; | ||
|
||
for (const auto material : l_elastic_isotropic) { | ||
|
@@ -212,13 +232,4 @@ specfem::IO::read_mesh(const std::string filename, | |
for (const auto material : l_elastic_anisotropic) { | ||
mpi->cout(material.print()); | ||
} | ||
|
||
assert(l_elastic_isotropic.size() + l_acoustic_isotropic.size() + | ||
l_elastic_anisotropic.size() == | ||
mesh.materials.n_materials); | ||
|
||
mesh.tags = specfem::mesh::tags<specfem::dimension::type::dim2>( | ||
mesh.materials, mesh.boundaries); | ||
|
||
return mesh; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,8 +41,15 @@ void execute( | |
// -------------------------------------------------------------- | ||
// Read mesh and materials | ||
// -------------------------------------------------------------- | ||
const auto quadrature = setup.instantiate_quadrature(); | ||
const auto quadratures = setup.instantiate_quadrature(); | ||
if (mpi->main_proc()) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think the options are two, either you check here whether it's the main_proc() and then use the ostream << overload, or you parse mpi check locally if you are on main_proc and return if you aren't. What do you think? Am i forgetting something? Option 3: |
||
std::cout << quadratures << std::endl; | ||
} | ||
|
||
const auto mesh = specfem::IO::read_mesh(database_filename, mpi); | ||
if (mpi->main_proc()) { | ||
specfem::IO::print_mesh(mesh, mpi); | ||
} | ||
// -------------------------------------------------------------- | ||
|
||
// -------------------------------------------------------------- | ||
|
@@ -101,7 +108,7 @@ void execute( | |
mpi->cout("-------------------------------"); | ||
const type_real dt = setup.get_dt(); | ||
specfem::compute::assembly assembly( | ||
mesh, quadrature, sources, receivers, setup.get_seismogram_types(), | ||
mesh, quadratures, sources, receivers, setup.get_seismogram_types(), | ||
setup.get_t0(), dt, nsteps, max_seismogram_time_step, | ||
nstep_between_samples, setup.get_simulation_type(), | ||
setup.instantiate_property_reader()); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similarly here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::cout << gll has already been defined, but at this stage not declared. I could use some help on the import order.