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

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

#include <rb_data_serialization.h>

Public Member Functions

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

Private Attributes

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

Detailed Description

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

Definition at line 124 of file rb_data_serialization.h.

Constructor & Destructor Documentation

libMesh::RBDataSerialization::RBEIMEvaluationSerialization::RBEIMEvaluationSerialization ( RBEIMEvaluation rb_eval)

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

Definition at line 167 of file rb_data_serialization.C.

168  :
169  _rb_eim_eval(rb_eim_eval)
170 {
171 }
RBEIMEvaluation & _rb_eim_eval
The RBEvaluation object that will be written to disk.
libMesh::RBDataSerialization::RBEIMEvaluationSerialization::~RBEIMEvaluationSerialization ( )
virtual

Destructor.

Definition at line 173 of file rb_data_serialization.C.

174 {
175 }

Member Function Documentation

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

Write the Cap'n'Proto buffer to disk.

Definition at line 177 of file rb_data_serialization.C.

References _rb_eim_eval, libMesh::RBDataSerialization::add_rb_eim_evaluation_data_to_builder(), libMesh::ParallelObject::comm(), and libMesh::Parallel::Communicator::rank().

Referenced by main().

178 {
179  LOG_SCOPE("write_to_file()", "RBEIMEvaluationSerialization");
180 
181  if (_rb_eim_eval.comm().rank() == 0)
182  {
183  capnp::MallocMessageBuilder message;
184 
185 #ifndef LIBMESH_USE_COMPLEX_NUMBERS
186  RBData::RBEIMEvaluationReal::Builder rb_eim_eval_builder =
187  message.initRoot<RBData::RBEIMEvaluationReal>();
188  RBData::RBEvaluationReal::Builder rb_eval_builder =
189  rb_eim_eval_builder.initRbEvaluation();
190 #else
191  RBData::RBEIMEvaluationComplex::Builder rb_eim_eval_builder =
192  message.initRoot<RBData::RBEIMEvaluationComplex>();
193  RBData::RBEvaluationComplex::Builder rb_eval_builder =
194  rb_eim_eval_builder.initRbEvaluation();
195 #endif
196 
198  rb_eval_builder,
199  rb_eim_eval_builder);
200 
201  int fd = open(path.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0664);
202  if (!fd)
203  libmesh_error_msg("Error opening a write-only file descriptor to " + path);
204 
205  capnp::writeMessageToFd(fd, message);
206 
207  int error = close(fd);
208  if (error)
209  libmesh_error_msg("Error closing a write-only file descriptor to " + path);
210  }
211 }
RBEIMEvaluation & _rb_eim_eval
The RBEvaluation object that will be written to disk.
void add_rb_eim_evaluation_data_to_builder(RBEIMEvaluation &rb_eim_eval, RBEvaluationBuilderNumber &rb_eval_builder, RBEIMEvaluationBuilderNumber &rb_eim_eval_builder)
Add data for an RBEIMEvaluation to the builder.
const Parallel::Communicator & comm() const
unsigned int rank() const
Definition: parallel.h:724

Member Data Documentation

RBEIMEvaluation& libMesh::RBDataSerialization::RBEIMEvaluationSerialization::_rb_eim_eval
private

The RBEvaluation object that will be written to disk.

Definition at line 149 of file rb_data_serialization.h.

Referenced by write_to_file().


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