42 #ifndef OUTPUT_PRECISION
43 #define OUTPUT_PRECISION 6
95 iCurrWidth(iDefaultWidth),
96 iCurrPrecision(iDefaultPrecision),
111 iCurrWidth(iDefaultWidth),
112 iCurrPrecision(iDefaultPrecision),
116 Init(sFName, iExtNum);
278 for (
int iCnt = 0; iCnt <
LASTFILE; iCnt++) {
282 if (m_pBinFile != 0) {
289 OutData[iCnt].pof->exceptions(std::ios::iostate(0));
305 if (!m_pBinFile->is_valid()) {
306 silent_cerr(
"NetCDF file is invalid" << std::endl);
311 m_DimTime = CreateDim(
"time");
312 m_DimV1 = CreateDim(
"vec1", 1);
313 m_DimV3 = CreateDim(
"vec3", 3);
325 silent_cerr(
"Unable to open file "
326 "\"" << fname <<
"\"" << std::endl);
338 OutData[out].pof->setf(std::ios::scientific);
353 std::string sCurrFileName =
sGet();
354 std::stringstream fname_ss;
356 unsigned uExtIdx = sCurrFileName.find_last_of(
EXT_SEP);
358 if (uExtIdx != std::string::npos) {
359 fname_ss << sCurrFileName.substr(0, uExtIdx);
362 fname_ss << sCurrFileName;
365 fname_ss << postfix <<
psExt[out] << std::ends;
367 const std::string fname = fname_ss.str();
370 OutData[out].pof->open(fname.c_str());
373 silent_cerr(
"Unable to open file "
374 "\"" << fname <<
"\"" << std::endl);
385 OutData[out].pof->setf(std::ios::scientific);
408 return m_pBinFile == 0 ?
false : m_pBinFile->is_valid();
412 return OutData[out].pof == 0 ?
false :
OutData[out].pof->is_open();
580 std::cerr <<
"Unable to open file '" <<
_sPutExt(resExt)
581 <<
'\'' << std::endl;
599 char *resXSolExt = NULL;
612 std::cerr <<
"Unable to open file '" <<
_sPutExt(resExt)
613 <<
'\'' << std::endl;
649 ASSERT(iNewWidth > iWidth);
650 if (iNewWidth > iWidth) {
653 for (
int iCnt = 0; iCnt <
LASTFILE; iCnt++) {
665 ASSERT(iNewPrecision > 0);
666 if (iNewPrecision > 0) {
669 for (
int iCnt = 0; iCnt <
LASTFILE; iCnt++) {
680 for (
int iCnt = 0; iCnt <
LASTFILE; iCnt++) {
682 OutData[iCnt].pof->exceptions(flags);
689 OutputHandler::CreateDim(
const std::string& name,
integer size)
695 dim = m_pBinFile->add_dim(name.c_str());
698 dim = m_pBinFile->add_dim(name.c_str(), size);
702 std::ostringstream os;
703 os <<
"OutputHandler::CreateDim(\"" << name <<
"\"";
707 os <<
"): unable to add dimension";
708 silent_cerr(os.str() << std::endl);
716 OutputHandler::GetDim(
const std::string& name)
const
720 return m_pBinFile->get_dim(name.c_str());
724 OutputHandler::CreateVar(
const std::string& name, NcType type,
725 const AttrValVec& attrs,
const NcDimVec& dims)
729 var = m_pBinFile->add_var(name.c_str(), type, dims.size(),
const_cast<const NcDim **
>(&dims[0]));
731 silent_cerr(
"OutputHandler::CreateVar(\"" << name <<
"\") failed" << std::endl);
735 for (AttrValVec::const_iterator i = attrs.begin(); i != attrs.end(); ++i) {
736 if (!var->
add_att(i->attr.c_str(), i->val.c_str())) {
737 silent_cerr(
"OutputHandler::CreateVar(\"" << name <<
"\"): "
738 "add_att(\"" << i->attr <<
"\", \"" << i->val <<
"\") failed" << std::endl);
747 OutputHandler::CreateVar(
const std::string& name,
const std::string& type)
750 attrs[0] = AttrVal(
"type", type);
755 return CreateVar(name, ncChar, attrs, dims);
759 OutputHandler::CreateRotationVar(
const std::string& name_prefix,
760 const std::string& name_postfix,
762 const std::string& description)
766 std::string name(name_prefix);
776 attrs[0] = AttrVal(
"units",
"-");
777 attrs[1] = AttrVal(
"type",
"Mat3x3");
778 attrs[2] = AttrVal(
"description",
779 description +
" orientation matrix "
780 "(R11, R21, R31, R12, R22, R32, R13, R23, R33)");
791 attrs[0] = AttrVal(
"units",
"radian");
792 attrs[1] = AttrVal(
"type",
"Vec3");
793 attrs[2] = AttrVal(
"description",
794 description +
" orientation vector "
795 "(Phi_X, Phi_Y, Phi_Z)");
809 attrs[0] = AttrVal(
"units",
"radian");
810 attrs[1] = AttrVal(
"type",
"Vec3");
830 attrs[2] = AttrVal(
"description",
831 description +
" orientation Euler angles (" + etype +
") "
841 name += name_postfix;
842 return CreateVar(name, ncDouble, attrs, dim);
void OutputHandler_int(void)
std::ofstream ofRestartXSol
void SetWidth(int iNewWidth)
ToBeOutput(flag fOut=fDefaultOut)
void SetNetCDF(const OutputHandler::OutFiles out)
virtual bool bToBeOutput(void) const
#define MBDYN_EXCEPT_ARGS
bool UseNetCDF(int out) const
const char *const _sPutExt(const char *n)
virtual ~OutputHandler(void)
std::ofstream ofAeroModals
bool Close(const OutputHandler::OutFiles out)
void SetText(const OutputHandler::OutFiles out)
#define SAFEDELETEARR(pnt)
std::ofstream ofAerodynamic
std::ofstream ofExternals
std::ofstream ofEigenanalysis
std::ofstream ofPresNodes
std::ofstream ofThermalElements
std::ofstream ofThermalNodes
std::ofstream ofReferenceFrames
bool Open(const OutputHandler::OutFiles out)
const char *const sGet(void) const
void Init(const char *sFName, int iExtNum=-1)
bool UseScientific(int out) const
void SetPrecision(int iNewPrecision)
struct OutputHandler::@34 OutData[LASTFILE]
void SetExceptions(std::ios::iostate flags)
std::ofstream ofParameters
bool IsOpen(int out) const
virtual void OutputPrepare(OutputHandler &OH)
NcBool add_att(NcToken, char)
#define ASSERT(expression)
std::ofstream ofDriveCallers
virtual flag fToBeTraced(void) const
int iInit(const char *n, int i=0)
virtual void SetTraceFlag(flag f=TRACE)
virtual void Output(OutputHandler &OH) const
virtual flag fToBeOutput(void) const
std::ofstream ofHydraulic
bool UseDefaultPrecision(int out) const
#define SAFENEWARR(pnt, item, sz)
virtual void SetOutputFlag(flag f=flag(1))
std::ofstream ofPartition
const int iDefaultPrecision
bool RestartOpen(bool openResXSol=false)
bool UseText(int out) const
virtual ~ToBeOutput(void)