libMesh
Public Member Functions | Private Attributes | List of all members
libMesh::RBDataSerialization::RBEvaluationSerialization Class Reference

This class serializes an RBEvaluation object using the Cap'n Proto library. More...

#include <rb_data_serialization.h>

Public Member Functions

 RBEvaluationSerialization (RBEvaluation &rb_eval)
 Initialize a new buffer using the structure from the Cap'n'Proto schema described in rb_data.capnp. More...
 
virtual ~RBEvaluationSerialization ()
 Destructor. More...
 
void write_to_file (const std::string &path)
 Write the Cap'n'Proto buffer to disk. More...
 

Private Attributes

RBEvaluation_rb_eval
 The RBEvaluation object that will be written to disk. More...
 

Detailed Description

This class serializes an RBEvaluation object using the Cap'n Proto library.

Author
David Knezevic
Date
2015 Serializes RBEvaluation objects using Cap'n Proto.

Definition at line 58 of file rb_data_serialization.h.

Constructor & Destructor Documentation

libMesh::RBDataSerialization::RBEvaluationSerialization::RBEvaluationSerialization ( RBEvaluation rb_eval)

Initialize a new buffer using the structure from the Cap'n'Proto schema described in rb_data.capnp.

Definition at line 71 of file rb_data_serialization.C.

72  :
73  _rb_eval(rb_eval)
74 {
75 }
RBEvaluation & _rb_eval
The RBEvaluation object that will be written to disk.
libMesh::RBDataSerialization::RBEvaluationSerialization::~RBEvaluationSerialization ( )
virtual

Destructor.

Definition at line 77 of file rb_data_serialization.C.

78 {
79 }

Member Function Documentation

void libMesh::RBDataSerialization::RBEvaluationSerialization::write_to_file ( const std::string &  path)

Write the Cap'n'Proto buffer to disk.

Definition at line 81 of file rb_data_serialization.C.

References _rb_eval, libMesh::RBDataSerialization::add_rb_evaluation_data_to_builder(), libMesh::ParallelObject::comm(), libMesh::Parallel::Communicator::rank(), and libMesh::RBDataSerialization::TransientRBEvaluationSerialization::TransientRBEvaluationSerialization().

Referenced by main().

82 {
83  LOG_SCOPE("write_to_file()", "RBEvaluationSerialization");
84 
85  if (_rb_eval.comm().rank() == 0)
86  {
87  capnp::MallocMessageBuilder message;
88 
89 #ifndef LIBMESH_USE_COMPLEX_NUMBERS
90  RBData::RBEvaluationReal::Builder rb_eval_builder =
91  message.initRoot<RBData::RBEvaluationReal>();
92 #else
93  RBData::RBEvaluationComplex::Builder rb_eval_builder =
94  message.initRoot<RBData::RBEvaluationComplex>();
95 #endif
96 
98 
99  int fd = open(path.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0664);
100  if (!fd)
101  libmesh_error_msg("Error opening a write-only file descriptor to " + path);
102 
103  capnp::writeMessageToFd(fd, message);
104 
105  int error = close(fd);
106  if (error)
107  libmesh_error_msg("Error closing a write-only file descriptor to " + path);
108  }
109 }
void add_rb_evaluation_data_to_builder(RBEvaluation &rb_eval, RBEvaluationBuilderNumber &rb_eval_builder)
Add data for an RBEvaluation to the builder.
const Parallel::Communicator & comm() const
unsigned int rank() const
Definition: parallel.h:724
RBEvaluation & _rb_eval
The RBEvaluation object that will be written to disk.

Member Data Documentation

RBEvaluation& libMesh::RBDataSerialization::RBEvaluationSerialization::_rb_eval
private

The RBEvaluation object that will be written to disk.

Definition at line 83 of file rb_data_serialization.h.

Referenced by write_to_file().


The documentation for this class was generated from the following files: