From 6129a9350a6bcdaee10d321b2eaac208ac054ba6 Mon Sep 17 00:00:00 2001 From: andy <andy> Date: Wed, 30 Jan 2013 17:05:37 +0000 Subject: [PATCH] ENH: Code tidying --- .../externalCoupledMixedFvPatchField.C | 22 +++++++++++-------- .../externalCoupledMixedFvPatchField.H | 3 +++ 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/finiteVolume/fields/fvPatchFields/derived/externalCoupledMixed/externalCoupledMixedFvPatchField.C b/src/finiteVolume/fields/fvPatchFields/derived/externalCoupledMixed/externalCoupledMixedFvPatchField.C index d207981fca2..5da9b8a19de 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/externalCoupledMixed/externalCoupledMixedFvPatchField.C +++ b/src/finiteVolume/fields/fvPatchFields/derived/externalCoupledMixed/externalCoupledMixedFvPatchField.C @@ -52,6 +52,13 @@ Foam::fileName Foam::externalCoupledMixedFvPatchField<Type>::baseDir() const } +template<class Type> +Foam::fileName Foam::externalCoupledMixedFvPatchField<Type>::lockFile() const +{ + return fileName(baseDir()/(lockName + ".lock")); +} + + template<class Type> void Foam::externalCoupledMixedFvPatchField<Type>::createLockFile() const { @@ -65,7 +72,7 @@ void Foam::externalCoupledMixedFvPatchField<Type>::createLockFile() const Info<< type() << ": creating lock file" << endl; } - OFstream os(baseDir()/(lockName + ".lock")); + OFstream os(lockFile()); os << "waiting"; os.flush(); } @@ -84,7 +91,7 @@ void Foam::externalCoupledMixedFvPatchField<Type>::removeLockFile() const Info<< type() << ": removing lock file" << endl; } - rm(baseDir()/(lockName + ".lock")); + rm(lockFile()); } @@ -153,15 +160,13 @@ void Foam::externalCoupledMixedFvPatchField<Type>::writeAndWait os.flush(); } - const fileName lockFile(baseDir()/(lockName + ".lock")); - // remove lock file, signalling external source to execute removeLockFile(); if (log_) { - Info<< type() << ": beginning wait for lock file " << lockFile + Info<< type() << ": beginning wait for lock file " << lockFile() << endl; } @@ -189,13 +194,13 @@ void Foam::externalCoupledMixedFvPatchField<Type>::writeAndWait << " s" << abort(FatalError); } - IFstream is(lockFile); + IFstream is(lockFile()); if (is.good()) { if (log_) { - Info<< type() << ": found lock file " << lockFile << endl; + Info<< type() << ": found lock file " << lockFile() << endl; } found = true; @@ -438,8 +443,7 @@ void Foam::externalCoupledMixedFvPatchField<Type>::write(Ostream& os) const os.writeKeyword("fileName") << fName_ << token::END_STATEMENT << nl; os.writeKeyword("waitInterval") << waitInterval_ << token::END_STATEMENT << nl; - os.writeKeyword("timeOut") << timeOut_ << token::END_STATEMENT - << nl; + os.writeKeyword("timeOut") << timeOut_ << token::END_STATEMENT << nl; os.writeKeyword("calcFrequency") << calcFrequency_ << token::END_STATEMENT << nl; os.writeKeyword("log") << log_ << token::END_STATEMENT << nl; diff --git a/src/finiteVolume/fields/fvPatchFields/derived/externalCoupledMixed/externalCoupledMixedFvPatchField.H b/src/finiteVolume/fields/fvPatchFields/derived/externalCoupledMixed/externalCoupledMixedFvPatchField.H index 229d9bad6c3..4b32cde06ce 100644 --- a/src/finiteVolume/fields/fvPatchFields/derived/externalCoupledMixed/externalCoupledMixedFvPatchField.H +++ b/src/finiteVolume/fields/fvPatchFields/derived/externalCoupledMixed/externalCoupledMixedFvPatchField.H @@ -137,6 +137,9 @@ protected: //- Return the file path to the base communications folder fileName baseDir() const; + //- Return the file path to the lock file + fileName lockFile() const; + //- Create lock file void createLockFile() const; -- GitLab