PrincetonUniversity / SPECFEMPP

SPECFEM++ is a complete re-write of SPECFEM suite of packages (SPECFEM2D, SPECFEM3D, SPECFEM3D_GLOBE) using C++
https://specfem2d-kokkos.readthedocs.io/en/latest/
GNU General Public License v3.0
22 stars 9 forks source link

Pitchfork style project directory for a cleaner library. #190

Open lsawade opened 3 days ago

lsawade commented 3 days ago

I think at the moment the library is a little hard to navigate, and I think I finally realized why. It does not really follow the "pitchfork" style:

Pitchfork example lib

Another example is boost. The Pitchfork library keeps include/ and src/ together in the src/ directory whereas Boost follows the classic split of include/ and src/ files:

Boost::Filesystem

See include directory specifically: include/boost

I think it should be looks somewhat like this

include/
  |-- specfem/
        |-- ...
        |-- ...
        |-- IO.hpp
        |-- IO/
        |     |-- ...
        |     |-- sources.hpp
        |     |-- receivers.hpp
        |     |-- mesh.hpp
        |     |-- mesh/
        |     |     |-- impl.hpp
        |     |     |-- impl/
        |     |           |-- fortran.hpp
        |     |           |-- fortran/
        |     |                 |-- read_mesh_database.hpp
        |     |                 |-- ...
        |     |-- operators.hpp
        |     |-- ...
        |-- ...
        |-- 

fortran.hpp #includes all fortran/read_<xxx>.hpp files.

IO.hpp #includes e.g. IO/sources.hpp, IO/receivers.hpp, IO/mesh.hpp, IO/operators.hpp, etc.

Such that, you would write:


#include <specfem/IO.hpp>
#include <specfem/quadrature.hpp>
#include <specfem/mesh.hpp>
#include <specfem/sources.hpp>
#include <specfem/receivers.hpp>
#include <specfem/setup.hpp>

int main() {

   specfem::setup setup= specfem::IO::read_setup(...)
   specfem::quadrature quadrature = specfem::quadrature::get_quadrature(...)
   specfem::sources sources = specfem::IO::read_sources(...)
   specfem::receivers = specfem::IO::read_receivers(...)
   specfem::mesh mesh = specfem::IO::read_mesh(...)
   specfem::assembly = specfem::assembly::create_assembly(
      mesh, quadrature, sources, receivers, setup);

   // ETC. I have been writing this for a bit now and started loosing patience...

}

Let me know if this is unclear, and how you feel about it. I think it would make sense to do this now instead of later, because things are getting quickly more complicated.

icui commented 3 days ago

Maybe ultimately we can migrate to modules? https://en.cppreference.com/w/cpp/language/modules

lsawade commented 2 days ago

Also interesting: