diff --git a/src/OpenFOAM/db/regIOobject/regIOobject.C b/src/OpenFOAM/db/regIOobject/regIOobject.C index ac8cf38adff7622efc4b022794ca24920c16702c..3a14d5968ecc56d5f0a1e1010f7ca56ec21e059b 100644 --- a/src/OpenFOAM/db/regIOobject/regIOobject.C +++ b/src/OpenFOAM/db/regIOobject/regIOobject.C @@ -173,6 +173,47 @@ Foam::regIOobject::regIOobject(const regIOobject& rio, bool registerCopy) } +Foam::regIOobject::regIOobject +( + const word& newName, + const regIOobject& rio, + bool registerCopy +) +: + IOobject(newName, rio.instance(), rio.local(), rio.db()), + registered_(false), + ownedByRegistry_(false), + watchIndex_(-1), + eventNo_(db().getEvent()), + isPtr_(NULL) +{ + if (registerCopy) + { + checkIn(); + } +} + + +Foam::regIOobject::regIOobject +( + const IOobject& io, + const regIOobject& rio +) +: + IOobject(io), + registered_(false), + ownedByRegistry_(false), + watchIndex_(-1), + eventNo_(db().getEvent()), + isPtr_(NULL) +{ + if (registerObject()) + { + checkIn(); + } +} + + // * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * // // Delete read stream, checkout from objectRegistry and destroy diff --git a/src/OpenFOAM/db/regIOobject/regIOobject.H b/src/OpenFOAM/db/regIOobject/regIOobject.H index ab7ad871e52db0e81f32dc54a7ee5f45f594e827..56078ce15d33cd9576edc5414d098c5a505ae16c 100644 --- a/src/OpenFOAM/db/regIOobject/regIOobject.H +++ b/src/OpenFOAM/db/regIOobject/regIOobject.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -138,10 +138,17 @@ public: //- Construct as copy regIOobject(const regIOobject&); - //- Construct as copy, and transferring registry registration to copy + //- Construct as copy, transferring registry registration to copy // if registerCopy is true regIOobject(const regIOobject&, bool registerCopy); + //- Construct as copy with new name, transfering registry registration + // to copy as specified + regIOobject(const word& newName, const regIOobject&, bool registerCopy); + + //- Construct as copy with new IO parameters + regIOobject(const IOobject&, const regIOobject&); + //- Destructor virtual ~regIOobject(); diff --git a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.C b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.C index b2ba573dde9ca0fb0e5851e483136b98c7c156b9..bdffc35596a4fe60d11001286919e219e790fcfb 100644 --- a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.C +++ b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -193,6 +193,21 @@ DimensionedField<Type, GeoMesh>::DimensionedField {} +template<class Type, class GeoMesh> +DimensionedField<Type, GeoMesh>::DimensionedField +( + const IOobject& io, + DimensionedField<Type, GeoMesh>& df, + bool reUse +) +: + regIOobject(io, df), + Field<Type>(df, reUse), + mesh_(df.mesh_), + dimensions_(df.dimensions_) +{} + + template<class Type, class GeoMesh> DimensionedField<Type, GeoMesh>::DimensionedField ( @@ -200,7 +215,7 @@ DimensionedField<Type, GeoMesh>::DimensionedField const DimensionedField<Type, GeoMesh>& df ) : - regIOobject(IOobject(newName, df.time().timeName(), df.db())), + regIOobject(newName, df, newName == df.name()), Field<Type>(df), mesh_(df.mesh_), dimensions_(df.dimensions_) @@ -215,7 +230,7 @@ DimensionedField<Type, GeoMesh>::DimensionedField bool reUse ) : - regIOobject(IOobject(newName, df.time().timeName(), df.db())), + regIOobject(newName, df, true), Field<Type>(df, reUse), mesh_(df.mesh_), dimensions_(df.dimensions_) @@ -229,7 +244,7 @@ DimensionedField<Type, GeoMesh>::DimensionedField const Xfer<DimensionedField<Type, GeoMesh> >& df ) : - regIOobject(IOobject(newName, df->time().timeName(), df->db())), + regIOobject(newName, df, true), Field<Type>(df), mesh_(df->mesh_), dimensions_(df->dimensions_) @@ -244,7 +259,7 @@ DimensionedField<Type, GeoMesh>::DimensionedField const tmp<DimensionedField<Type, GeoMesh> >& tdf ) : - regIOobject(IOobject(newName, tdf().time().timeName(), tdf().db())), + regIOobject(newName, tdf(), true), Field<Type> ( const_cast<DimensionedField<Type, GeoMesh>&>(tdf()), diff --git a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.H b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.H index aba43c194f8e887584dbbe845b5a89efa4600c1c..3472cecf11500c250fd3dd072e8706cca7095070 100644 --- a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.H +++ b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -104,6 +104,7 @@ public: //- Runtime type information TypeName("DimensionedField"); + // Static Member Functions //- Return a null DimensionedField @@ -168,12 +169,12 @@ public: ); //- Construct as copy of tmp<DimensionedField> deleting argument -# ifdef ConstructFromTmp + #ifdef ConstructFromTmp DimensionedField ( const tmp<DimensionedField<Type, GeoMesh> >& ); -# endif + #endif //- Construct as copy resetting IO parameters DimensionedField @@ -182,6 +183,14 @@ public: const DimensionedField<Type, GeoMesh>& ); + //- Construct as copy resetting IO parameters and re-use as specified. + DimensionedField + ( + const IOobject&, + DimensionedField<Type, GeoMesh>&, + bool reUse + ); + //- Construct as copy resetting name DimensionedField ( @@ -205,13 +214,13 @@ public: ); //- Construct as copy resetting name -# ifdef ConstructFromTmp + #ifdef ConstructFromTmp DimensionedField ( const word& newName, const tmp<DimensionedField<Type, GeoMesh> >& ); -# endif + #endif //- Clone tmp<DimensionedField<Type, GeoMesh> > clone() const; diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C index 02cd512fd658af0495014b58c158750a6e858ac7..32b427c04c63b3fd65d76c95dad097679a83fe84 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -31,8 +31,6 @@ License // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * // -// check mesh for two fields - #define checkField(gf1, gf2, op) \ if ((gf1).mesh() != (gf2).mesh()) \ { \ @@ -180,10 +178,6 @@ bool Foam::GeometricField<Type, PatchField, GeoMesh>::readOldTimeIfPresent() // * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * * // -// Constructor given a GeometricField and dimensionSet -// This allocates storage for the field but not values. -// Note : This constructor should only be used to -// construct TEMPORARY variables template<class Type, template<class> class PatchField, class GeoMesh> Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField ( @@ -210,10 +204,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField } -// Constructor given a GeometricField and dimensionSet -// This allocates storage for the field but not values. -// Note : This constructor should only be used to -// construct TEMPORARY variables template<class Type, template<class> class PatchField, class GeoMesh> Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField ( @@ -241,7 +231,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField } -// Constructor given a GeometricField and dimensioned<Type> template<class Type, template<class> class PatchField, class GeoMesh> Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField ( @@ -270,7 +259,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField } -// Constructor given a GeometricField and dimensioned<Type> template<class Type, template<class> class PatchField, class GeoMesh> Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField ( @@ -300,7 +288,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField } -// construct from components template<class Type, template<class> class PatchField, class GeoMesh> Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField ( @@ -408,7 +395,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField } -// construct as copy template<class Type, template<class> class PatchField, class GeoMesh> Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField ( @@ -439,7 +425,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField this->writeOpt() = IOobject::NO_WRITE; } -// construct as copy of tmp<GeometricField> deleting argument + #ifdef ConstructFromTmp template<class Type, template<class> class PatchField, class GeoMesh> Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField @@ -471,7 +457,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField #endif -// construct as copy resetting IO parameters template<class Type, template<class> class PatchField, class GeoMesh> Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField ( @@ -503,7 +488,39 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField } -// construct as copy resetting name +#ifdef ConstructFromTmp +template<class Type, template<class> class PatchField, class GeoMesh> +Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField +( + const IOobject& io, + const tmp<GeometricField<Type, PatchField, GeoMesh> >& tgf +) +: + DimensionedField<Type, GeoMesh> + ( + io, + const_cast<GeometricField<Type, PatchField, GeoMesh>&>(tgf()), + tgf.isTmp() + ), + timeIndex_(tgf().timeIndex()), + field0Ptr_(NULL), + fieldPrevIterPtr_(NULL), + boundaryField_(*this, tgf().boundaryField_) +{ + if (debug) + { + Info<< "GeometricField<Type, PatchField, GeoMesh>::GeometricField : " + "constructing from tmp resetting IO params" + << endl << this->info() << endl; + } + + tgf.clear(); + + readIfPresent(); +} +#endif + + template<class Type, template<class> class PatchField, class GeoMesh> Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField ( @@ -535,7 +552,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField } -// construct as copy resetting name #ifdef ConstructFromTmp template<class Type, template<class> class PatchField, class GeoMesh> Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField @@ -566,7 +582,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField } #endif -// construct as copy resetting IO parameters and patch type + template<class Type, template<class> class PatchField, class GeoMesh> Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField ( @@ -601,7 +617,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField } -// construct as copy resetting IO parameters and boundary types template<class Type, template<class> class PatchField, class GeoMesh> Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField ( @@ -627,7 +642,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricField if (debug) { Info<< "GeometricField<Type, PatchField, GeoMesh>::GeometricField : " - "constructing as copy resetting IO params" + "constructing as copy resetting IO params and patch types" << endl << this->info() << endl; } @@ -678,7 +693,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::internalField() } -// Return reference to GeometricBoundaryField template<class Type, template<class> class PatchField, class GeoMesh> typename Foam::GeometricField<Type, PatchField, GeoMesh>::GeometricBoundaryField& @@ -690,7 +704,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::boundaryField() } -// Store old-time field template<class Type, template<class> class PatchField, class GeoMesh> void Foam::GeometricField<Type, PatchField, GeoMesh>::storeOldTimes() const { @@ -711,7 +724,7 @@ void Foam::GeometricField<Type, PatchField, GeoMesh>::storeOldTimes() const timeIndex_ = this->time().timeIndex(); } -// Store old-time field + template<class Type, template<class> class PatchField, class GeoMesh> void Foam::GeometricField<Type, PatchField, GeoMesh>::storeOldTime() const { @@ -735,7 +748,7 @@ void Foam::GeometricField<Type, PatchField, GeoMesh>::storeOldTime() const } } -// Return the number of old time fields stored + template<class Type, template<class> class PatchField, class GeoMesh> Foam::label Foam::GeometricField<Type, PatchField, GeoMesh>::nOldTimes() const { @@ -749,7 +762,7 @@ Foam::label Foam::GeometricField<Type, PatchField, GeoMesh>::nOldTimes() const } } -// Return old time internal field + template<class Type, template<class> class PatchField, class GeoMesh> const Foam::GeometricField<Type, PatchField, GeoMesh>& Foam::GeometricField<Type, PatchField, GeoMesh>::oldTime() const @@ -778,7 +791,7 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::oldTime() const return *field0Ptr_; } -// Return old time internal field + template<class Type, template<class> class PatchField, class GeoMesh> Foam::GeometricField<Type, PatchField, GeoMesh>& Foam::GeometricField<Type, PatchField, GeoMesh>::oldTime() @@ -790,7 +803,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::oldTime() } -// Store previous iteration field template<class Type, template<class> class PatchField, class GeoMesh> void Foam::GeometricField<Type, PatchField, GeoMesh>::storePrevIter() const { @@ -815,7 +827,6 @@ void Foam::GeometricField<Type, PatchField, GeoMesh>::storePrevIter() const } -// Return previous iteration field template<class Type, template<class> class PatchField, class GeoMesh> const Foam::GeometricField<Type, PatchField, GeoMesh>& Foam::GeometricField<Type, PatchField, GeoMesh>::prevIter() const @@ -835,7 +846,6 @@ Foam::GeometricField<Type, PatchField, GeoMesh>::prevIter() const } -// Correct the boundary conditions template<class Type, template<class> class PatchField, class GeoMesh> void Foam::GeometricField<Type, PatchField, GeoMesh>:: correctBoundaryConditions() @@ -846,7 +856,6 @@ correctBoundaryConditions() } -// Does the field need a reference level for solution template<class Type, template<class> class PatchField, class GeoMesh> bool Foam::GeometricField<Type, PatchField, GeoMesh>::needReference() const { @@ -940,7 +949,6 @@ void Foam::GeometricField<Type, PatchField, GeoMesh>::writeMinMax } -// writeData member function required by regIOobject template<class Type, template<class> class PatchField, class GeoMesh> bool Foam::GeometricField<Type, PatchField, GeoMesh>:: writeData(Ostream& os) const diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H index e966f6f81b91509fcd9de880282af95e503a49de..91acb5630afb61a540d24e2ca4e4c3eb4a276b32 100644 --- a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H +++ b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H @@ -2,7 +2,7 @@ ========= | \\ / F ield | OpenFOAM: The Open Source CFD Toolbox \\ / O peration | - \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation + \\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation \\/ M anipulation | ------------------------------------------------------------------------------- License @@ -369,6 +369,15 @@ public: const GeometricField<Type, PatchField, GeoMesh>& ); + //- Construct as copy of tmp<GeometricField> resetting IO parameters + #ifdef ConstructFromTmp + GeometricField + ( + const IOobject&, + const tmp<GeometricField<Type, PatchField, GeoMesh> >& + ); + #endif + //- Construct as copy resetting name GeometricField (