diff --git a/src/OpenFOAM/db/regIOobject/regIOobject.C b/src/OpenFOAM/db/regIOobject/regIOobject.C index ac8cf38ad..3a14d5968 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 ab7ad871e..56078ce15 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 b2ba573dd..bdffc3559 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::DimensionedField {} +template +DimensionedField::DimensionedField +( + const IOobject& io, + DimensionedField& df, + bool reUse +) +: + regIOobject(io, df), + Field(df, reUse), + mesh_(df.mesh_), + dimensions_(df.dimensions_) +{} + + template DimensionedField::DimensionedField ( @@ -200,7 +215,7 @@ DimensionedField::DimensionedField const DimensionedField& df ) : - regIOobject(IOobject(newName, df.time().timeName(), df.db())), + regIOobject(newName, df, newName == df.name()), Field(df), mesh_(df.mesh_), dimensions_(df.dimensions_) @@ -215,7 +230,7 @@ DimensionedField::DimensionedField bool reUse ) : - regIOobject(IOobject(newName, df.time().timeName(), df.db())), + regIOobject(newName, df, true), Field(df, reUse), mesh_(df.mesh_), dimensions_(df.dimensions_) @@ -229,7 +244,7 @@ DimensionedField::DimensionedField const Xfer >& df ) : - regIOobject(IOobject(newName, df->time().timeName(), df->db())), + regIOobject(newName, df, true), Field(df), mesh_(df->mesh_), dimensions_(df->dimensions_) @@ -244,7 +259,7 @@ DimensionedField::DimensionedField const tmp >& tdf ) : - regIOobject(IOobject(newName, tdf().time().timeName(), tdf().db())), + regIOobject(newName, tdf(), true), Field ( const_cast&>(tdf()), diff --git a/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.H b/src/OpenFOAM/fields/DimensionedFields/DimensionedField/DimensionedField.H index aba43c194..3472cecf1 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 deleting argument -# ifdef ConstructFromTmp + #ifdef ConstructFromTmp DimensionedField ( const tmp >& ); -# endif + #endif //- Construct as copy resetting IO parameters DimensionedField @@ -182,6 +183,14 @@ public: const DimensionedField& ); + //- Construct as copy resetting IO parameters and re-use as specified. + DimensionedField + ( + const IOobject&, + DimensionedField&, + 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 >& ); -# endif + #endif //- Clone tmp > clone() const; diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.C index 02cd512fd..32b427c04 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::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 PatchField, class GeoMesh> Foam::GeometricField::GeometricField ( @@ -210,10 +204,6 @@ Foam::GeometricField::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 PatchField, class GeoMesh> Foam::GeometricField::GeometricField ( @@ -241,7 +231,6 @@ Foam::GeometricField::GeometricField } -// Constructor given a GeometricField and dimensioned template class PatchField, class GeoMesh> Foam::GeometricField::GeometricField ( @@ -270,7 +259,6 @@ Foam::GeometricField::GeometricField } -// Constructor given a GeometricField and dimensioned template class PatchField, class GeoMesh> Foam::GeometricField::GeometricField ( @@ -300,7 +288,6 @@ Foam::GeometricField::GeometricField } -// construct from components template class PatchField, class GeoMesh> Foam::GeometricField::GeometricField ( @@ -408,7 +395,6 @@ Foam::GeometricField::GeometricField } -// construct as copy template class PatchField, class GeoMesh> Foam::GeometricField::GeometricField ( @@ -439,7 +425,7 @@ Foam::GeometricField::GeometricField this->writeOpt() = IOobject::NO_WRITE; } -// construct as copy of tmp deleting argument + #ifdef ConstructFromTmp template class PatchField, class GeoMesh> Foam::GeometricField::GeometricField @@ -471,7 +457,6 @@ Foam::GeometricField::GeometricField #endif -// construct as copy resetting IO parameters template class PatchField, class GeoMesh> Foam::GeometricField::GeometricField ( @@ -503,7 +488,39 @@ Foam::GeometricField::GeometricField } -// construct as copy resetting name +#ifdef ConstructFromTmp +template class PatchField, class GeoMesh> +Foam::GeometricField::GeometricField +( + const IOobject& io, + const tmp >& tgf +) +: + DimensionedField + ( + io, + const_cast&>(tgf()), + tgf.isTmp() + ), + timeIndex_(tgf().timeIndex()), + field0Ptr_(NULL), + fieldPrevIterPtr_(NULL), + boundaryField_(*this, tgf().boundaryField_) +{ + if (debug) + { + Info<< "GeometricField::GeometricField : " + "constructing from tmp resetting IO params" + << endl << this->info() << endl; + } + + tgf.clear(); + + readIfPresent(); +} +#endif + + template class PatchField, class GeoMesh> Foam::GeometricField::GeometricField ( @@ -535,7 +552,6 @@ Foam::GeometricField::GeometricField } -// construct as copy resetting name #ifdef ConstructFromTmp template class PatchField, class GeoMesh> Foam::GeometricField::GeometricField @@ -566,7 +582,7 @@ Foam::GeometricField::GeometricField } #endif -// construct as copy resetting IO parameters and patch type + template class PatchField, class GeoMesh> Foam::GeometricField::GeometricField ( @@ -601,7 +617,6 @@ Foam::GeometricField::GeometricField } -// construct as copy resetting IO parameters and boundary types template class PatchField, class GeoMesh> Foam::GeometricField::GeometricField ( @@ -627,7 +642,7 @@ Foam::GeometricField::GeometricField if (debug) { Info<< "GeometricField::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::internalField() } -// Return reference to GeometricBoundaryField template class PatchField, class GeoMesh> typename Foam::GeometricField::GeometricBoundaryField& @@ -690,7 +704,6 @@ Foam::GeometricField::boundaryField() } -// Store old-time field template class PatchField, class GeoMesh> void Foam::GeometricField::storeOldTimes() const { @@ -711,7 +724,7 @@ void Foam::GeometricField::storeOldTimes() const timeIndex_ = this->time().timeIndex(); } -// Store old-time field + template class PatchField, class GeoMesh> void Foam::GeometricField::storeOldTime() const { @@ -735,7 +748,7 @@ void Foam::GeometricField::storeOldTime() const } } -// Return the number of old time fields stored + template class PatchField, class GeoMesh> Foam::label Foam::GeometricField::nOldTimes() const { @@ -749,7 +762,7 @@ Foam::label Foam::GeometricField::nOldTimes() const } } -// Return old time internal field + template class PatchField, class GeoMesh> const Foam::GeometricField& Foam::GeometricField::oldTime() const @@ -778,7 +791,7 @@ Foam::GeometricField::oldTime() const return *field0Ptr_; } -// Return old time internal field + template class PatchField, class GeoMesh> Foam::GeometricField& Foam::GeometricField::oldTime() @@ -790,7 +803,6 @@ Foam::GeometricField::oldTime() } -// Store previous iteration field template class PatchField, class GeoMesh> void Foam::GeometricField::storePrevIter() const { @@ -815,7 +827,6 @@ void Foam::GeometricField::storePrevIter() const } -// Return previous iteration field template class PatchField, class GeoMesh> const Foam::GeometricField& Foam::GeometricField::prevIter() const @@ -835,7 +846,6 @@ Foam::GeometricField::prevIter() const } -// Correct the boundary conditions template class PatchField, class GeoMesh> void Foam::GeometricField:: correctBoundaryConditions() @@ -846,7 +856,6 @@ correctBoundaryConditions() } -// Does the field need a reference level for solution template class PatchField, class GeoMesh> bool Foam::GeometricField::needReference() const { @@ -940,7 +949,6 @@ void Foam::GeometricField::writeMinMax } -// writeData member function required by regIOobject template class PatchField, class GeoMesh> bool Foam::GeometricField:: writeData(Ostream& os) const diff --git a/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H b/src/OpenFOAM/fields/GeometricFields/GeometricField/GeometricField.H index e966f6f81..91acb5630 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& ); + //- Construct as copy of tmp resetting IO parameters + #ifdef ConstructFromTmp + GeometricField + ( + const IOobject&, + const tmp >& + ); + #endif + //- Construct as copy resetting name GeometricField (