Skip to content

Commit

Permalink
USe spdlog
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisrichardson committed May 16, 2024
1 parent 3ab6938 commit d85d720
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
5 changes: 3 additions & 2 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,9 +254,10 @@ int main(int argc, char* argv[])
// rank 0 (add more here if desired)
const int mpi_rank = dolfinx::MPI::rank(MPI_COMM_WORLD);
std::string thread_name = "RANK: " + std::to_string(mpi_rank);
loguru::set_thread_name(thread_name.c_str());
std::string fmt = "[%Y-%m-%d %H:%M:%S.%e] [" + thread_name + "] [%l] %v";
spdlog::set_pattern(fmt);
if (mpi_rank == 0)
loguru::g_stderr_verbosity = loguru::Verbosity_INFO;
spdlog::set_level(spdlog::level::info);

solve(argc, argv);

Expand Down
25 changes: 13 additions & 12 deletions src/mem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,25 @@
//
// SPDX-License-Identifier: MIT

#include <vector>
#include <unistd.h>
#include <ios>
#include <iostream>
#include <thread>
#include <chrono>
#include <dolfinx/common/log.h>
#include <fstream>
#include <string>
#include <ios>
#include <iostream>
#include <iterator>
#include <dolfinx/common/log.h>
#include <string>
#include <thread>
#include <unistd.h>
#include <vector>

void process_mem_usage(bool& quit)
{
loguru::set_thread_name("MEMORY");
std::string fmt = "[%Y-%m-%d %H:%M:%S.%e] [MEM] [%l] %v";
spdlog::set_pattern(fmt);

const int page_size_bytes = sysconf(_SC_PAGE_SIZE);

while(!quit)
while (!quit)
{
std::ifstream f("/proc/self/stat", std::ios_base::in);
std::istream_iterator<std::string> it(f);
Expand All @@ -29,9 +31,8 @@ void process_mem_usage(bool& quit)
std::size_t vsize, rss;
f >> vsize >> rss;
f.close();
LOG(WARNING) << "VSIZE=" << vsize/1024 << " RSS=" << rss*page_size_bytes/1024 ;
spdlog::warn("VSIZE={}, RSS={}", vsize / 1024,
rss * page_size_bytes / 1024);
std::this_thread::sleep_for(std::chrono::milliseconds(100));
}
}


10 changes: 4 additions & 6 deletions src/mesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,19 +346,17 @@ create_spoke_mesh(MPI_Comm comm, std::size_t target_dofs,
std::transform(x.begin(), x.end(), x.begin(),
[scale = 0.9 * x0max](auto x) { return x / scale; });

LOG(INFO) << "x range = " << x0min << " - " << x0max << std::endl;
LOG(INFO) << "y range = " << x1min << " - " << x1max << std::endl;
LOG(INFO) << "z range = " << x2min << " - " << x2max << std::endl;
spdlog::info("x range = {} - {}", x0min, x0max);
spdlog::info("y range = {} - {}", x1min, x1max);
spdlog::info("z range = {} - {}", x2min, x2max);
}

// New Mesh
dolfinx::fem::CoordinateElement<double> element(
dolfinx::mesh::CellType::tetrahedron, 1);

auto mesh = std::make_shared<dolfinx::mesh::Mesh<double>>(
dolfinx::mesh::create_mesh(comm,
topo,
element, x, {x.size() / 3, 3},
dolfinx::mesh::create_mesh(comm, topo, element, x, {x.size() / 3, 3},
dolfinx::mesh::GhostMode::none));

mesh->topology_mutable()->create_entities(1);
Expand Down

0 comments on commit d85d720

Please sign in to comment.