From 8179509780fd10a72e0cf853f1945a7b6e22efc2 Mon Sep 17 00:00:00 2001 From: sergio <sergio> Date: Fri, 11 Dec 2015 10:24:55 -0800 Subject: [PATCH] Transfering from dev copy constructors and clones for coordinateRotation classes --- .../EulerCoordinateRotation.C | 10 ++++++++++ .../EulerCoordinateRotation.H | 15 +++++++++++++++ .../STARCDCoordinateRotation.C | 10 ++++++++++ .../STARCDCoordinateRotation.H | 18 +++++++++++++++++- .../coordinateRotation/axesRotation.C | 8 ++++++++ .../coordinateRotation/axesRotation.H | 7 +++++-- .../coordinateRotation/coordinateRotation.H | 5 +++++ .../coordinateRotation/cylindrical.C | 9 +++++++++ .../coordinateRotation/cylindrical.H | 7 +++++-- .../coordinateSystems/coordinateSystem.C | 4 ++-- 10 files changed, 86 insertions(+), 7 deletions(-) diff --git a/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.C b/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.C index 0ffe75d2e65..7907c17b8ba 100644 --- a/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.C +++ b/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.C @@ -274,6 +274,16 @@ Foam::EulerCoordinateRotation::EulerCoordinateRotation } +Foam::EulerCoordinateRotation::EulerCoordinateRotation +( + const EulerCoordinateRotation& r +) +: + R_(r.R_), + Rtr_(r.Rtr_) +{} + + void Foam::EulerCoordinateRotation::write(Ostream& os) const { os.writeKeyword("e1") << e1() << token::END_STATEMENT << nl; diff --git a/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.H b/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.H index 362c846fe15..d1694c3d20b 100644 --- a/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.H +++ b/src/meshTools/coordinateSystems/coordinateRotation/EulerCoordinateRotation.H @@ -120,6 +120,21 @@ public: //- Construct from dictionary and mesh EulerCoordinateRotation(const dictionary&, const objectRegistry&); + //- Construct as copy + EulerCoordinateRotation(const EulerCoordinateRotation&); + + //- Return clone + autoPtr<coordinateRotation> clone() const + { + return autoPtr<coordinateRotation> + ( + new EulerCoordinateRotation + ( + *this + ) + ); + } + // Member Functions diff --git a/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.C b/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.C index fde7eb39cc2..06265a721ba 100644 --- a/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.C +++ b/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.C @@ -271,6 +271,16 @@ Foam::STARCDCoordinateRotation::STARCDCoordinateRotation } +Foam::STARCDCoordinateRotation::STARCDCoordinateRotation +( + const STARCDCoordinateRotation& r +) +: + R_(r.R_), + Rtr_(r.Rtr_) +{} + + void Foam::STARCDCoordinateRotation::write(Ostream& os) const { os.writeKeyword("e1") << e1() << token::END_STATEMENT << nl; diff --git a/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.H b/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.H index 1b73f71ee2a..b124f3d4c35 100644 --- a/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.H +++ b/src/meshTools/coordinateSystems/coordinateRotation/STARCDCoordinateRotation.H @@ -117,7 +117,23 @@ public: //- Construct from dictionary and mesh STARCDCoordinateRotation(const dictionary&, const objectRegistry&); - // Member Functions + //- Construct as copy + STARCDCoordinateRotation(const STARCDCoordinateRotation&); + + //- Return clone + autoPtr<coordinateRotation> clone() const + { + return autoPtr<coordinateRotation> + ( + new STARCDCoordinateRotation + ( + *this + ) + ); + } + + + // Member Functions //- Reset rotation to an identity rotation virtual void clear() diff --git a/src/meshTools/coordinateSystems/coordinateRotation/axesRotation.C b/src/meshTools/coordinateSystems/coordinateRotation/axesRotation.C index c28a6fd3b48..70bb54e640e 100644 --- a/src/meshTools/coordinateSystems/coordinateRotation/axesRotation.C +++ b/src/meshTools/coordinateSystems/coordinateRotation/axesRotation.C @@ -157,6 +157,14 @@ Foam::axesRotation::axesRotation(const tensor& R) {} +Foam::axesRotation::axesRotation(const axesRotation& r) +: + R_(r.R_), + Rtr_(r.Rtr_) +{} + + + // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // const Foam::tensorField& Foam::axesRotation::Tr() const diff --git a/src/meshTools/coordinateSystems/coordinateRotation/axesRotation.H b/src/meshTools/coordinateSystems/coordinateRotation/axesRotation.H index 937f28c0419..f0be4d09b7c 100644 --- a/src/meshTools/coordinateSystems/coordinateRotation/axesRotation.H +++ b/src/meshTools/coordinateSystems/coordinateRotation/axesRotation.H @@ -111,10 +111,13 @@ public: //- Construct from dictionary and mesh axesRotation(const dictionary&, const objectRegistry&); + //- Construct as copy + axesRotation(const axesRotation&); + //- Return clone - autoPtr<axesRotation> clone() const + autoPtr<coordinateRotation> clone() const { - return autoPtr<axesRotation>(new axesRotation(*this)); + return autoPtr<coordinateRotation>(new axesRotation(*this)); } diff --git a/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotation.H b/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotation.H index ae37a3764f3..a10485a5c2f 100644 --- a/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotation.H +++ b/src/meshTools/coordinateSystems/coordinateRotation/coordinateRotation.H @@ -110,6 +110,11 @@ public: (dict) ); + // Constructors + + //- Construct and return a clone + virtual autoPtr<coordinateRotation> clone() const = 0; + // Selectors diff --git a/src/meshTools/coordinateSystems/coordinateRotation/cylindrical.C b/src/meshTools/coordinateSystems/coordinateRotation/cylindrical.C index a5427b5fa1e..5dffccac015 100644 --- a/src/meshTools/coordinateSystems/coordinateRotation/cylindrical.C +++ b/src/meshTools/coordinateSystems/coordinateRotation/cylindrical.C @@ -172,6 +172,15 @@ Foam::cylindrical::cylindrical(const tensorField& R) } +Foam::cylindrical::cylindrical(const cylindrical& r) +: + Rptr_(r.Rptr_, false), // clone + origin_(r.origin_), + e3_(r.e3_) +{} + + + // * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * * // void Foam::cylindrical::clear() diff --git a/src/meshTools/coordinateSystems/coordinateRotation/cylindrical.H b/src/meshTools/coordinateSystems/coordinateRotation/cylindrical.H index 50e0450b271..df0bc55b1a3 100644 --- a/src/meshTools/coordinateSystems/coordinateRotation/cylindrical.H +++ b/src/meshTools/coordinateSystems/coordinateRotation/cylindrical.H @@ -120,10 +120,13 @@ public: //- Construct from tensor Field cylindrical(const tensorField&); + //- Construct as copy + cylindrical(const cylindrical&); + //- Return clone - autoPtr<cylindrical> clone() const + autoPtr<coordinateRotation> clone() const { - return autoPtr<cylindrical>(new cylindrical(*this)); + return autoPtr<coordinateRotation>(new cylindrical(*this)); } diff --git a/src/meshTools/coordinateSystems/coordinateSystem.C b/src/meshTools/coordinateSystems/coordinateSystem.C index 68aa5e06f90..751fd36b7e8 100644 --- a/src/meshTools/coordinateSystems/coordinateSystem.C +++ b/src/meshTools/coordinateSystems/coordinateSystem.C @@ -57,7 +57,7 @@ Foam::coordinateSystem::coordinateSystem name_(name), note_(), origin_(cs.origin_), - R_(const_cast<coordinateRotation*>(&cs.R())) + R_(cs.R().clone()) {} @@ -71,7 +71,7 @@ Foam::coordinateSystem::coordinateSystem name_(name), note_(), origin_(origin), - R_(const_cast<coordinateRotation*>(&cr)) + R_(cr.clone()) {} -- GitLab