From 7fe6fca4dfce4e94b7ec9c96cfca67c8da00c057 Mon Sep 17 00:00:00 2001 From: andy Date: Wed, 21 Jan 2009 16:55:25 +0000 Subject: [PATCH] added helper function for writing entries if not default --- .../fvPatchFields/fvPatchField/fvPatchField.C | 17 +++++++++++++++++ .../fvPatchFields/fvPatchField/fvPatchField.H | 17 +++++++++++++++-- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C index 4e01c64d74..637cf8037a 100644 --- a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.C @@ -244,6 +244,23 @@ void Foam::fvPatchField::write(Ostream& os) const } +template +template +void Foam::fvPatchField::writeEntryIfDifferent +( + Ostream& os, + const word& entryName, + const EntryType& value1, + const EntryType& value2 +) const +{ + if (value1 != value2) + { + os.writeKeyword(entryName) << value2 << token::END_STATEMENT << nl; + } +} + + // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * // template diff --git a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H index 701dd9fb4e..851d9d33ae 100644 --- a/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/fvPatchField/fvPatchField.H @@ -414,8 +414,21 @@ public: virtual void manipulateMatrix(fvMatrix& matrix); - //- Write - virtual void write(Ostream&) const; + // I-O + + //- Write + virtual void write(Ostream&) const; + + //- Helper function to write the keyword and entry only if the + // values are not equal. The value is then output as value2 + template + void writeEntryIfDifferent + ( + Ostream& os, + const word& entryName, + const EntryType& value1, + const EntryType& value2 + ) const; // Check