Read the Cap'n'Proto buffer from disk.
252{
253 LOG_SCOPE("read_from_file()", "RBSCMEvaluationDeserialization");
254
255 int fd = open(path.c_str(), O_RDONLY);
256 libmesh_error_msg_if(!fd, "Couldn't open the buffer file: " + path);
257
258
259 capnp::ReaderOptions reader_options;
260 reader_options.traversalLimitInWords = std::numeric_limits<uint64_t>::max();
261
262 std::unique_ptr<capnp::InputStreamMessageReader> message;
263 libmesh_try
264 {
265 if(use_packing)
266 message = std::make_unique<capnp::PackedFdMessageReader>(fd, reader_options);
267 else
268 message = std::make_unique<capnp::StreamFdMessageReader>(fd, reader_options);
269 }
270 libmesh_catch(...)
271 {
272 libmesh_error_msg("Failed to open capnp buffer");
273 }
274
275 RBData::RBSCMEvaluation::Reader rb_scm_eval_reader =
276 message->getRoot<RBData::RBSCMEvaluation>();
277
279 rb_scm_eval_reader);
280
281 int error = close(fd);
282 libmesh_error_msg_if(error, "Error closing a read-only file descriptor: " + path);
283}
void load_rb_scm_evaluation_data(RBSCMEvaluation &rb_scm_eval, RBData::RBSCMEvaluation::Reader &rb_scm_eval_reader)
Load an SCM RB evaluation from a corresponding reader structure in the buffer.