Merge branch 'feature-iotweaks' into 'develop'

Feature iotweaks

Enhancements for #114 and #115. Tagged as WIP, since there may be some need for discussion/rework prior to merging.

See merge request !35
This commit is contained in:
Mark Olesen
2016-05-13 06:52:11 +01:00
10 changed files with 103 additions and 49 deletions

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -40,7 +40,7 @@ void Foam::Ostream::decrIndent()
} }
else else
{ {
indentLevel_--; --indentLevel_;
} }
} }
@ -79,4 +79,35 @@ Foam::Ostream& Foam::Ostream::writeKeyword(const keyType& kw)
} }
Foam::Ostream& Foam::Ostream::beginBlock(const word& keyword)
{
indent();
write(keyword);
endl();
beginBlock();
return *this;
}
Foam::Ostream& Foam::Ostream::beginBlock()
{
indent();
write(char(token::BEGIN_BLOCK));
incrIndent();
return *this;
}
Foam::Ostream& Foam::Ostream::endBlock()
{
decrIndent();
indent();
write(char(token::END_BLOCK));
return *this;
}
// ************************************************************************* // // ************************************************************************* //

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -109,8 +109,8 @@ public:
virtual Ostream& write(const word&) = 0; virtual Ostream& write(const word&) = 0;
//- Write keyType //- Write keyType
// write regular expression as quoted string // A plain word is written unquoted.
// write plain word as word (unquoted) // A regular expression is written as a quoted string.
virtual Ostream& write(const keyType&); virtual Ostream& write(const keyType&);
//- Write string //- Write string
@ -157,14 +157,29 @@ public:
//- Incrememt the indent level //- Incrememt the indent level
void incrIndent() void incrIndent()
{ {
indentLevel_++; ++indentLevel_;
} }
//- Decrememt the indent level //- Decrememt the indent level
void decrIndent(); void decrIndent();
//- Write the keyword followed by an appropriate indentation //- Write the keyword followed by an appropriate indentation
Ostream& writeKeyword(const keyType&); virtual Ostream& writeKeyword(const keyType&);
//- Write begin block group with the given name
// Uses the appropriate indentation,
// does not include a trailing newline.
virtual Ostream& beginBlock(const word&);
//- Write begin block group without a name
// Uses the appropriate indentation,
// does not include a trailing newline.
virtual Ostream& beginBlock();
//- Write end block group
// Uses the appropriate indentation,
// does not include a trailing newline.
virtual Ostream& endBlock();
// Stream state functions // Stream state functions

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -174,7 +174,8 @@ void Foam::dictionary::write(Ostream& os, bool subDict) const
{ {
if (subDict) if (subDict)
{ {
os << nl << indent << token::BEGIN_BLOCK << incrIndent << nl; os << nl;
os.beginBlock() << nl;
} }
forAllConstIter(IDLList<entry>, *this, iter) forAllConstIter(IDLList<entry>, *this, iter)
@ -202,7 +203,7 @@ void Foam::dictionary::write(Ostream& os, bool subDict) const
if (subDict) if (subDict)
{ {
os << decrIndent << indent << token::END_BLOCK << endl; os.endBlock() << endl;
} }
} }

View File

@ -569,17 +569,16 @@ template<class Type, template<class> class PatchField, class GeoMesh>
void Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricBoundaryField:: void Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricBoundaryField::
writeEntry(const word& keyword, Ostream& os) const writeEntry(const word& keyword, Ostream& os) const
{ {
os << keyword << nl << token::BEGIN_BLOCK << incrIndent << nl; os.beginBlock(keyword) << nl;
forAll(*this, patchi) forAll(*this, patchi)
{ {
os << indent << this->operator[](patchi).patch().name() << nl os.beginBlock(this->operator[](patchi).patch().name()) << nl;
<< indent << token::BEGIN_BLOCK << nl os << this->operator[](patchi);
<< incrIndent << this->operator[](patchi) << decrIndent os.endBlock() << endl;
<< indent << token::END_BLOCK << endl;
} }
os << decrIndent << token::END_BLOCK << endl; os.endBlock() << endl;
// Check state of IOstream // Check state of IOstream
os.check os.check

View File

@ -1116,10 +1116,9 @@ bool Foam::polyBoundaryMesh::writeData(Ostream& os) const
forAll(patches, patchI) forAll(patches, patchI)
{ {
os << indent << patches[patchI].name() << nl os.beginBlock(patches[patchI].name()) << nl;
<< indent << token::BEGIN_BLOCK << nl os << patches[patchI];
<< incrIndent << patches[patchI] << decrIndent os.endBlock() << endl;
<< indent << token::END_BLOCK << endl;
} }
os << decrIndent << token::END_LIST; os << decrIndent << token::END_LIST;

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -437,12 +437,15 @@ void Foam::plane::writeDict(Ostream& os) const
{ {
os.writeKeyword("planeType") << "pointAndNormal" os.writeKeyword("planeType") << "pointAndNormal"
<< token::END_STATEMENT << nl; << token::END_STATEMENT << nl;
os << indent << "pointAndNormalDict" << nl
<< indent << token::BEGIN_BLOCK << incrIndent << nl; os.beginBlock("pointAndNormalDict") << nl;
os.writeKeyword("basePoint") << basePoint_ << token::END_STATEMENT << nl;
os.writeKeyword("normalVector") << unitVector_ << token::END_STATEMENT os.writeKeyword("basePoint") << basePoint_
<< nl; << token::END_STATEMENT << nl;
os << decrIndent << indent << token::END_BLOCK << endl; os.writeKeyword("normalVector") << unitVector_
<< token::END_STATEMENT << nl;
os.endBlock() << endl;
} }

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -264,16 +264,17 @@ void Foam::Function1Types::CSV<Type>::writeData(Ostream& os) const
{ {
Function1<Type>::writeData(os); Function1<Type>::writeData(os);
os << token::END_STATEMENT << nl; os << token::END_STATEMENT << nl;
os << indent << word(this->name() + "Coeffs") << nl;
os << indent << token::BEGIN_BLOCK << incrIndent << nl; os.beginBlock(word(this->name() + "Coeffs")) << nl;
// Note: for TableBase write the dictionary entries it needs but not // Note: for TableBase write the dictionary entries it needs but not
// the values themselves // the values themselves
TableBase<Type>::writeEntries(os); TableBase<Type>::writeEntries(os);
os.writeKeyword("nHeaderLine") << nHeaderLine_ << token::END_STATEMENT os.writeKeyword("nHeaderLine") << nHeaderLine_
<< nl; << token::END_STATEMENT << nl;
os.writeKeyword("refColumn") << refColumn_ << token::END_STATEMENT << nl; os.writeKeyword("refColumn") << refColumn_
<< token::END_STATEMENT << nl;
// Force writing labelList in ascii // Force writing labelList in ascii
os.writeKeyword("componentColumns"); os.writeKeyword("componentColumns");
@ -293,8 +294,10 @@ void Foam::Function1Types::CSV<Type>::writeData(Ostream& os) const
<< token::END_STATEMENT << nl; << token::END_STATEMENT << nl;
os.writeKeyword("mergeSeparators") << mergeSeparators_ os.writeKeyword("mergeSeparators") << mergeSeparators_
<< token::END_STATEMENT << nl; << token::END_STATEMENT << nl;
os.writeKeyword("fileName") << fName_ << token::END_STATEMENT << nl; os.writeKeyword("fileName") << fName_
os << decrIndent << indent << token::END_BLOCK << endl; << token::END_STATEMENT << nl;
os.endBlock() << endl;
} }

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -90,14 +90,16 @@ void Foam::Function1Types::Sine<Type>::writeData(Ostream& os) const
{ {
Function1<Type>::writeData(os); Function1<Type>::writeData(os);
os << token::END_STATEMENT << nl; os << token::END_STATEMENT << nl;
os << indent << word(this->name() + "Coeffs") << nl;
os << indent << token::BEGIN_BLOCK << incrIndent << nl; os.beginBlock(word(this->name() + "Coeffs")) << nl;
os.writeKeyword("t0") << t0_ << token::END_STATEMENT << nl; os.writeKeyword("t0") << t0_ << token::END_STATEMENT << nl;
amplitude_->writeData(os); amplitude_->writeData(os);
frequency_->writeData(os); frequency_->writeData(os);
scale_->writeData(os); scale_->writeData(os);
level_->writeData(os); level_->writeData(os);
os << decrIndent << indent << token::END_BLOCK << endl;
os.endBlock() << endl;
} }

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -103,15 +103,17 @@ void Foam::Function1Types::Square<Type>::writeData(Ostream& os) const
{ {
Function1<Type>::writeData(os); Function1<Type>::writeData(os);
os << token::END_STATEMENT << nl; os << token::END_STATEMENT << nl;
os << indent << word(this->name() + "Coeffs") << nl;
os << indent << token::BEGIN_BLOCK << incrIndent << nl; os.beginBlock(word(this->name() + "Coeffs")) << nl;
os.writeKeyword("t0") << t0_ << token::END_STATEMENT << nl; os.writeKeyword("t0") << t0_ << token::END_STATEMENT << nl;
os.writeKeyword("markSpace") << markSpace_ << token::END_STATEMENT << nl; os.writeKeyword("markSpace") << markSpace_ << token::END_STATEMENT << nl;
amplitude_->writeData(os); amplitude_->writeData(os);
frequency_->writeData(os); frequency_->writeData(os);
scale_->writeData(os); scale_->writeData(os);
level_->writeData(os); level_->writeData(os);
os << decrIndent << indent << token::END_BLOCK << endl;
os.endBlock() << endl;
} }

View File

@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration | \\ / O peration |
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation \\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation | \\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -78,17 +78,16 @@ template<class Type>
void Foam::Function1Types::TableFile<Type>::writeData(Ostream& os) const void Foam::Function1Types::TableFile<Type>::writeData(Ostream& os) const
{ {
Function1<Type>::writeData(os); Function1<Type>::writeData(os);
os << token::END_STATEMENT << nl;
os << token::END_STATEMENT << nl os.beginBlock(word(this->name() + "Coeffs")) << nl;
<< indent << word(this->name() + "Coeffs") << nl
<< indent << token::BEGIN_BLOCK << nl << incrIndent;
// Note: for TableBase write the dictionary entries it needs but not // Note: for TableBase write the dictionary entries it needs but not
// the values themselves // the values themselves
TableBase<Type>::writeEntries(os); TableBase<Type>::writeEntries(os);
os.writeKeyword("fileName")<< fName_ << token::END_STATEMENT << nl; os.writeKeyword("fileName")<< fName_ << token::END_STATEMENT << nl;
os << decrIndent << indent << token::END_BLOCK << endl;
os.endBlock() << endl;
} }