Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ set(Omega_h_SOURCES
Omega_h_fail.cpp
Omega_h_fence.cpp
Omega_h_file.cpp
Omega_h_filesystem.cpp
Omega_h_finite_automaton.cpp
Omega_h_fix.cpp
Omega_h_future.cpp
Expand Down Expand Up @@ -726,7 +725,6 @@ set(Omega_h_HEADERS
Omega_h_fence.hpp
Omega_h_few.hpp
Omega_h_file.hpp
Omega_h_filesystem.hpp
Omega_h_finite_automaton.hpp
Omega_h_for.hpp
Omega_h_functors.hpp
Expand Down
8 changes: 4 additions & 4 deletions src/Omega_h_adios2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@
#define OMEGA_H_ADIOS2_HPP
#include <adios2.h>
#include <Omega_h_mesh.hpp>
#include "Omega_h_filesystem.hpp" // filesystem
#include <filesystem>
#include "Omega_h_library.hpp"
#include "Omega_h_simplex.hpp"

namespace Omega_h {

namespace adios {
void write(filesystem::path const& path,
void write(std::filesystem::path const& path,
std::map<Mesh*, std::string>& mesh_map);
void write(filesystem::path const& path, Mesh *mesh, std::string pref="");
void write(std::filesystem::path const& path, Mesh *mesh, std::string pref="");

void write_mesh(adios2::IO &io, adios2::Engine & writer,
Mesh* mesh, std::string pref);

Mesh read(filesystem::path const& path, Library* lib, std::string pref="");
Mesh read(std::filesystem::path const& path, Library* lib, std::string pref="");

} // namespace adios

Expand Down
4 changes: 2 additions & 2 deletions src/Omega_h_compare.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

#include <Omega_h_cmdline.hpp>
#include <Omega_h_comm.hpp>
#include <Omega_h_filesystem.hpp>
#include <filesystem>

namespace Omega_h {

Expand Down Expand Up @@ -39,7 +39,7 @@ Omega_h_Comparison compare_meshes(Mesh* a, Mesh* b, MeshCompareOpts const& opts,

bool check_same(Mesh* a, Mesh* b);

bool check_regression(filesystem::path const& prefix, Mesh* mesh);
bool check_regression(std::filesystem::path const& prefix, Mesh* mesh);

void get_diff_program_cmdline(
std::string const& a_name, std::string const& b_name, CmdLine* p_cmdline);
Expand Down
28 changes: 14 additions & 14 deletions src/Omega_h_file.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -487,23 +487,23 @@ void read(std::istream& stream, Mesh* mesh, I32 version) {
}

static void write_int_file(
filesystem::path const& filepath, Mesh* mesh, I32 value) {
std::filesystem::path const& filepath, Mesh* mesh, I32 value) {
if (mesh->comm()->rank() == 0) {
std::ofstream file(filepath.c_str());
OMEGA_H_CHECK(file.is_open());
file << value << '\n';
}
}

static void write_nparts(filesystem::path const& path, Mesh* mesh) {
static void write_nparts(std::filesystem::path const& path, Mesh* mesh) {
write_int_file(path / "nparts", mesh, mesh->comm()->size());
}

static void write_version(filesystem::path const& path, Mesh* mesh) {
static void write_version(std::filesystem::path const& path, Mesh* mesh) {
write_int_file(path / "version", mesh, latest_version);
}

I32 read_nparts(filesystem::path const& path, CommPtr comm) {
I32 read_nparts(std::filesystem::path const& path, CommPtr comm) {
I32 nparts;
if (comm->rank() == 0) {
auto const filepath = path / "nparts";
Expand All @@ -520,7 +520,7 @@ I32 read_nparts(filesystem::path const& path, CommPtr comm) {
return nparts;
}

I32 read_version(filesystem::path const& path, CommPtr comm) {
I32 read_version(std::filesystem::path const& path, CommPtr comm) {
I32 version;
if (comm->rank() == 0) {
auto const filepath = path / "version";
Expand All @@ -538,14 +538,14 @@ I32 read_version(filesystem::path const& path, CommPtr comm) {
return version;
}

void write(filesystem::path const& path, Mesh* mesh) {
void write(std::filesystem::path const& path, Mesh* mesh) {
begin_code("binary::write(path,Mesh)");
if (path.extension().string() != ".osh" && can_print(mesh)) {
std::cout
<< "it is strongly recommended to end Omega_h paths in \".osh\",\n";
std::cout << "instead of just \"" << path << "\"\n";
}
filesystem::create_directory(path);
std::filesystem::create_directory(path);
mesh->comm()->barrier();
auto filepath = path;
filepath /= std::to_string(mesh->comm()->rank());
Expand All @@ -560,7 +560,7 @@ void write(filesystem::path const& path, Mesh* mesh) {
}

void read_in_comm(
filesystem::path const& path, CommPtr comm, Mesh* mesh, I32 version) {
std::filesystem::path const& path, CommPtr comm, Mesh* mesh, I32 version) {
ScopedTimer timer("binary::read_in_comm(path, comm, mesh, version)");
mesh->set_comm(comm);
auto filepath = path;
Expand All @@ -571,7 +571,7 @@ void read_in_comm(
read(file, mesh, version);
}

I32 read(filesystem::path const& path, CommPtr comm, Mesh* mesh, bool strict) {
I32 read(std::filesystem::path const& path, CommPtr comm, Mesh* mesh, bool strict) {
ScopedTimer timer("binary::read(path, comm, mesh, strict)");
auto const nparts = read_nparts(path, comm);
auto const version = read_version(path, comm);
Expand Down Expand Up @@ -600,12 +600,12 @@ I32 read(filesystem::path const& path, CommPtr comm, Mesh* mesh, bool strict) {
return nparts;
}

Mesh read(filesystem::path const& path, Library* lib, bool strict) {
Mesh read(std::filesystem::path const& path, Library* lib, bool strict) {
ScopedTimer timer("binary::read(path, lib, strict)");
return binary::read(path, lib->world(), strict);
}

Mesh read(filesystem::path const& path, CommPtr comm, bool strict) {
Mesh read(std::filesystem::path const& path, CommPtr comm, bool strict) {
ScopedTimer timer("binary::read(path, comm, strict)");
auto mesh = Mesh(comm->library());
binary::read(path, comm, &mesh, strict);
Expand All @@ -631,7 +631,7 @@ template void swap_bytes(std::uint64_t&);

} // end namespace binary

void write_reals_txt(filesystem::path const& filename, Reals a, Int ncomps) {
void write_reals_txt(std::filesystem::path const& filename, Reals a, Int ncomps) {
std::ofstream stream(filename.c_str());
write_reals_txt(stream, a, ncomps);
}
Expand All @@ -649,7 +649,7 @@ void write_reals_txt(std::ostream& stream, Reals a, Int ncomps) {
}
}

Reals read_reals_txt(filesystem::path const& filename, LO n, Int ncomps) {
Reals read_reals_txt(std::filesystem::path const& filename, LO n, Int ncomps) {
std::ifstream stream(filename.c_str());
return read_reals_txt(stream, n, ncomps);
}
Expand All @@ -664,7 +664,7 @@ Reals read_reals_txt(std::istream& stream, LO n, Int ncomps) {
return h_a.write();
}

OMEGA_H_DLL Mesh read_mesh_file(filesystem::path const& path, CommPtr comm) {
OMEGA_H_DLL Mesh read_mesh_file(std::filesystem::path const& path, CommPtr comm) {
auto const extension = path.extension().string();
if (extension == ".osh") {
return binary::read(path, comm);
Expand Down
41 changes: 20 additions & 21 deletions src/Omega_h_file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,17 @@
#include <Omega_h_array.hpp>
#include <Omega_h_comm.hpp>
#include <Omega_h_defines.hpp>
#include <Omega_h_filesystem.hpp>
#include <Omega_h_mesh.hpp>
#include <Omega_h_mixedMesh.hpp>
#include <Omega_h_tag.hpp>

#include <filesystem>
#ifdef OMEGA_H_USE_SIMMODSUITE
#include "MeshSim.h"
#endif

namespace Omega_h {

OMEGA_H_DLL Mesh read_mesh_file(filesystem::path const& path, CommPtr comm);
OMEGA_H_DLL Mesh read_mesh_file(std::filesystem::path const& path, CommPtr comm);

bool is_little_endian_cpu();

Expand Down Expand Up @@ -115,9 +114,9 @@ Mesh read_sliced(filesystem::path const& path, CommPtr comm,

namespace gmsh {
Mesh read(std::istream& stream, CommPtr comm);
Mesh read(filesystem::path const& filename, CommPtr comm);
Mesh read(std::filesystem::path const& filename, CommPtr comm);
void write(std::ostream& stream, Mesh* mesh);
void write(filesystem::path const& filepath, Mesh* mesh);
void write(std::filesystem::path const& filepath, Mesh* mesh);

#ifdef OMEGA_H_USE_GMSH

Expand Down Expand Up @@ -154,29 +153,29 @@ TagSet get_all_vtk_tags(Mesh* mesh, Int cell_dim);
TagSet get_all_vtk_tags_mix(Mesh* mesh, Int cell_dim);
void write_vtu(std::ostream& stream, Mesh* mesh, Int cell_dim,
TagSet const& tags, bool compress = OMEGA_H_DEFAULT_COMPRESS);
void write_vtu(filesystem::path const& filename, Mesh* mesh, Int cell_dim,
void write_vtu(std::filesystem::path const& filename, Mesh* mesh, Int cell_dim,
TagSet const& tags, bool compress = OMEGA_H_DEFAULT_COMPRESS);
void write_vtu(std::string const& filename, Mesh* mesh, Int cell_dim,
bool compress = OMEGA_H_DEFAULT_COMPRESS);
void write_vtu(std::string const& filename, Mesh* mesh,
bool compress = OMEGA_H_DEFAULT_COMPRESS);

void write_vtu(filesystem::path const& filename, MixedMesh* mesh, Topo_type max_type,
void write_vtu(std::filesystem::path const& filename, MixedMesh* mesh, Topo_type max_type,
bool compress = OMEGA_H_DEFAULT_COMPRESS);

void write_parallel(filesystem::path const& path, Mesh* mesh, Int cell_dim,
void write_parallel(std::filesystem::path const& path, Mesh* mesh, Int cell_dim,
TagSet const& tags, bool compress = OMEGA_H_DEFAULT_COMPRESS);
void write_parallel(std::string const& path, Mesh* mesh, Int cell_dim,
bool compress = OMEGA_H_DEFAULT_COMPRESS);
void write_parallel(std::string const& path, Mesh* mesh,
bool compress = OMEGA_H_DEFAULT_COMPRESS);

void read_parallel(filesystem::path const& pvtupath, CommPtr comm, Mesh* mesh);
void read_parallel(std::filesystem::path const& pvtupath, CommPtr comm, Mesh* mesh);
void read_vtu(std::istream& stream, CommPtr comm, Mesh* mesh);

class Writer {
Mesh* mesh_;
filesystem::path root_path_;
std::filesystem::path root_path_;
Int cell_dim_;
bool compress_;
I64 step_;
Expand All @@ -187,7 +186,7 @@ class Writer {
Writer(Writer const&) = default;
Writer& operator=(Writer const&) = default;
~Writer() = default;
Writer(filesystem::path const& root_path, Mesh* mesh, Int cell_dim = -1,
Writer(std::filesystem::path const& root_path, Mesh* mesh, Int cell_dim = -1,
Real restart_time = 0.0, bool compress = OMEGA_H_DEFAULT_COMPRESS);
void write();
void write(Real time);
Expand All @@ -199,7 +198,7 @@ class FullWriter {

public:
FullWriter() = default;
FullWriter(filesystem::path const& root_path, Mesh* mesh,
FullWriter(std::filesystem::path const& root_path, Mesh* mesh,
Real restart_time = 0.0, bool compress = OMEGA_H_DEFAULT_COMPRESS);
void write(Real time);
void write();
Expand All @@ -208,15 +207,15 @@ class FullWriter {

namespace binary {

void write(filesystem::path const& path, Mesh* mesh);
Mesh read(filesystem::path const& path, Library* lib, bool strict = false);
Mesh read(filesystem::path const& path, CommPtr comm, bool strict = false);
I32 read(filesystem::path const& path, CommPtr comm, Mesh* mesh,
void write(std::filesystem::path const& path, Mesh* mesh);
Mesh read(std::filesystem::path const& path, Library* lib, bool strict = false);
Mesh read(std::filesystem::path const& path, CommPtr comm, bool strict = false);
I32 read(std::filesystem::path const& path, CommPtr comm, Mesh* mesh,
bool strict = false);
I32 read_nparts(filesystem::path const& path, CommPtr comm);
I32 read_version(filesystem::path const& path, CommPtr comm);
I32 read_nparts(std::filesystem::path const& path, CommPtr comm);
I32 read_version(std::filesystem::path const& path, CommPtr comm);
void read_in_comm(
filesystem::path const& path, CommPtr comm, Mesh* mesh, I32 version);
std::filesystem::path const& path, CommPtr comm, Mesh* mesh, I32 version);

constexpr I32 latest_version = 10;

Expand Down Expand Up @@ -263,9 +262,9 @@ extern template void swap_bytes(std::uint64_t&);

} // namespace binary

void write_reals_txt(filesystem::path const& filename, Reals a, Int ncomps);
void write_reals_txt(std::filesystem::path const& filename, Reals a, Int ncomps);
void write_reals_txt(std::ostream& stream, Reals a, Int ncomps);
Reals read_reals_txt(filesystem::path const& filename, LO n, Int ncomps);
Reals read_reals_txt(std::filesystem::path const& filename, LO n, Int ncomps);
Reals read_reals_txt(std::istream& stream, LO n, Int ncomps);

} // namespace Omega_h
Expand Down
Loading