BELFEM 0.9.0
Berkeley Lab Finite Element Framework
Loading...
Searching...
No Matches
fn_rho_database_is_current.hpp
Go to the documentation of this file.
1/*
2 * BELFEM -- The Berkeley Lab Finite Element Framework
3 * Copyright (c) 2026, The Regents of the University of California, through
4 * Lawrence Berkeley National Laboratory (subject to receipt of any required
5 * approvals from the U.S. Dept. of Energy). All rights reserved.
6 *
7 * Developers: Christian Messe, Gregory Giard
8 *
9 * See the top-level LICENSE file for the complete license and disclaimer.
10 */
11
12#ifndef BELFEM_FN_RHO_DATABASE_IS_CURRENT_HPP
13#define BELFEM_FN_RHO_DATABASE_IS_CURRENT_HPP
14
15#include "typedefs.hpp"
16#include "hdf5_tools.hpp"
17
18namespace belfem
19{
33 inline bool
34 rho_database_is_current( const string & aPath )
35 {
36#ifdef BELFEM_HDF5
37 hid_t tFile = H5Fopen( aPath.c_str(), H5F_ACC_RDONLY, H5P_DEFAULT );
38
39 if ( tFile < 0 )
40 {
41 return false;
42 }
43
44 // H5Lexists returns a tri-state: > 0 exists, 0 absent, < 0 error.
45 // Only a definite hit counts as current -- a probe ERROR must land
46 // on the rebuild side, not be swallowed by a bool conversion
47 htri_t tExists = H5Lexists( tFile, "RRR", H5P_DEFAULT );
48
49 H5Fclose( tFile );
50
51 return tExists > 0;
52#else
53 // without HDF5 the database path cannot work at all; keep the
54 // pre-existing behavior rather than forcing a rebuild here
55 return true;
56#endif
57 }
58}
59#endif //BELFEM_FN_RHO_DATABASE_IS_CURRENT_HPP
USER GUIDES:
Definition cl_Capacitor.cpp:16
int hid_t
Definition hdf5_types.hpp:20
bool rho_database_is_current(const string &aPath)
Test whether a cached rho database was written by the current format.
Definition fn_rho_database_is_current.hpp:34