38#include "jacobianBaseReaderWriter.hpp"
56 template<
typename T_Type>
59 using Tape =
typename Type::Tape;
61 using Real =
typename Type::Real;
67 std::vector<Identifier>
const& out)
114 template<
typename T_Type>
117 using Tape =
typename Type::Tape;
119 using Real =
typename Type::Real;
125 FILE* fileHandleReadBin =
nullptr;
127 bool isFirstIdentifier =
true;
142 while (fread(&lhsIdentifier,
sizeof(
Identifier), 1, fileHandleReadBin) == 1) {
149 fread(rhsIdentifiers.data(),
sizeof(
Identifier), nArgs, fileHandleReadBin);
150 fread(rhsJacobians.data(),
sizeof(
Real), nArgs, fileHandleReadBin);
152 this->
registerStatement(lhsIdentifier, nArgs, rhsIdentifiers, rhsJacobians, lowestIndex, isFirstIdentifier);
159 fclose(fileHandleReadBin);
#define CODI_Unlikely
Declare unlikely evaluation of an execution path.
Definition config.h:399
#define CODI_Likely
Declare likely evaluation of an execution path.
Definition config.h:397
#define CODI_DD(Type, Default)
Abbreviation for CODI_DECLARE_DEFAULT.
Definition macros.hpp:94
size_t constexpr StatementLowLevelFunctionTag
Statement tag for low level functions.
Definition config.h:126
size_t constexpr MaxArgumentSize
Maximum number of arguments in a statement.
Definition config.h:120
uint8_t ArgumentSize
Type for the number of arguments in statements.
Definition config.h:117
size_t constexpr StatementInputTag
Tag for statements that are inputs. Used in linear index management context.
Definition config.h:123
CoDiPack - Code Differentiation Package.
Definition codi.hpp:91
void updateUserIO(Identifier const &linearOffset)
This method is used to remove any offset and to update the largest created index.
Definition commonReaderWriterBase.hpp:209
Tape tape
The newly resorted tape.
Definition commonReaderWriterBase.hpp:153
Identifier largestIndex
The largest index on the stored tape.
Definition commonReaderWriterBase.hpp:155
void restoreIoBinary()
Restore the IO for the binary readers.
Definition commonReaderWriterBase.hpp:180
This class is a common base for all the writers and produces a IO file that contains the input and ou...
Definition commonReaderWriterBase.hpp:84
void printIoBinary(Tape &tape)
Generate the IO file in a binary format.
Definition commonReaderWriterBase.hpp:117
std::string fileName
The base file name provided by the user.
Definition commonReaderWriterBase.hpp:51
void openFile(FILE *&fileHandle, std::string const &name, std::string const &mode)
Definition commonReaderWriterBase.hpp:67
Used to register a statement for a Jacobian tape.
Definition jacobianBaseReaderWriter.hpp:48
void registerStatement(Identifier const &lhsIdentifier, Config::ArgumentSize const &nArgs, std::vector< Identifier > const &rhsIdentifiers, std::vector< Real > const &rhsJacobians, Identifier &lowestIndex, bool &isFirstIdentifier)
Constructor.
Definition jacobianBaseReaderWriter.hpp:57
Reads and restores a binary file for a Jacobian tape.
Definition jacobianBinaryReaderWriter.hpp:115
typename Type::Identifier Identifier
See TapeReaderInterface.
Definition jacobianBinaryReaderWriter.hpp:118
typename Type::Real Real
See TapeReaderInterface.
Definition jacobianBinaryReaderWriter.hpp:119
typename Type::Tape Tape
See TapeReaderInterface.
Definition jacobianBinaryReaderWriter.hpp:117
void readFile(std::string const &name)
This method uses the the fileName to reproduce a valid tape.
Definition jacobianBinaryReaderWriter.hpp:124
T_Type Type
See TapeReaderInterface.
Definition jacobianBinaryReaderWriter.hpp:116
JacobianBinaryTapeReader()
Constructor.
Definition jacobianBinaryReaderWriter.hpp:121
Writes a Jacobian tape in a binary format.
Definition jacobianBinaryReaderWriter.hpp:57
typename Type::Real Real
See TapeWriterInterface.
Definition jacobianBinaryReaderWriter.hpp:61
typename Type::Identifier Identifier
See TapeWriterInterface.
Definition jacobianBinaryReaderWriter.hpp:60
T_Type Type
See TapeWriterInterface.
Definition jacobianBinaryReaderWriter.hpp:58
FILE * fileHandleBin
File handle.
Definition jacobianBinaryReaderWriter.hpp:63
JacobianBinaryTapeWriter(std::string const &name, std::vector< Identifier > const &in, std::vector< Identifier > const &out)
Constructor.
Definition jacobianBinaryReaderWriter.hpp:66
void start(Tape &tape)
Destructor.
Definition jacobianBinaryReaderWriter.hpp:71
void finish()
After all the statements have been written, the finish method finalizes the writing process.
Definition jacobianBinaryReaderWriter.hpp:94
void writeStatement(Identifier const &curLhsIdentifier, size_t &curJacobianPos, Real const *const rhsJacobians, Identifier const *const rhsIdentifiers, Config::ArgumentSize const &nJacobians)
Called for each statement. The method writes the current statement to the file. This overload is used...
Definition jacobianBinaryReaderWriter.hpp:81
typename Type::Tape Tape
See TapeWriterInterface.
Definition jacobianBinaryReaderWriter.hpp:59