diff --git a/src/optimisation/adjointOptimisation/adjoint/objectives/objective/objective.C b/src/optimisation/adjointOptimisation/adjoint/objectives/objective/objective.C index 669999ec4abd8c581a8a110ca6447fb4aee34761..a9a910d6a7a9fc7674477ec39ffee449df7adc10 100644 --- a/src/optimisation/adjointOptimisation/adjoint/objectives/objective/objective.C +++ b/src/optimisation/adjointOptimisation/adjoint/objectives/objective/objective.C @@ -162,7 +162,7 @@ objective::objective // Read JMean from dictionary, if present IOobject headObjectiveIODict ( - "objectiveDict", + "objectiveDict" + objectiveName_, mesh_.time().timeName(), "uniform", mesh_, @@ -654,7 +654,7 @@ void objective::writeMeanValue() const ( IOobject ( - "objectiveDict", + "objectiveDict" + objectiveName_, mesh_.time().timeName(), "uniform", mesh_, diff --git a/src/optimisation/adjointOptimisation/adjoint/optimisation/updateMethod/SQP/SQP.C b/src/optimisation/adjointOptimisation/adjoint/optimisation/updateMethod/SQP/SQP.C index 155fc5726bb01eeb7925ca2d4320b928170e43b9..8f91c5e2272f8d71e2a3170935086e6858b825e7 100644 --- a/src/optimisation/adjointOptimisation/adjoint/optimisation/updateMethod/SQP/SQP.C +++ b/src/optimisation/adjointOptimisation/adjoint/optimisation/updateMethod/SQP/SQP.C @@ -300,7 +300,11 @@ Foam::SQP::SQP(const fvMesh& mesh, const dictionary& dict) correctionOld_(0), lamdas_(0), counter_(0), - objFunctionFolder_("objective"), + objFunctionFolder_ + ( + mesh_.time().globalPath()/"optimisation"/"objective"/ + mesh_.time().timeName() + ), meritFunctionFile_(nullptr), mu_(Zero), delta_ @@ -322,7 +326,7 @@ Foam::SQP::SQP(const fvMesh& mesh, const dictionary& dict) // Create folder to merit function if (Pstream::master()) { - mkDir(mesh_.time().globalPath()/"optimisation"/objFunctionFolder_); + mkDir(objFunctionFolder_); } // Read old hessian, correction and derivatives, if present diff --git a/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DVolume/NURBS3DVolume/NURBS3DVolume.C b/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DVolume/NURBS3DVolume/NURBS3DVolume.C index 5b03aa37fc70855634056ac408221b0ce5e18fb6..94bd1e871643b79c27a7220b1f7f16518688ed5c 100644 --- a/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DVolume/NURBS3DVolume/NURBS3DVolume.C +++ b/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DVolume/NURBS3DVolume/NURBS3DVolume.C @@ -1625,7 +1625,10 @@ Foam::tmp<Foam::vectorField> Foam::NURBS3DVolume::getPointsInBox() { findPointsInBox(localSystemCoordinates_); } - tmp<vectorField> pointsInBox(new vectorField(mesh_.points(), mapPtr_())); + tmp<vectorField> pointsInBox + ( + new vectorField(localSystemCoordinates_, mapPtr_()) + ); return pointsInBox; } @@ -1783,6 +1786,51 @@ Foam::tmp<Foam::volTensorField> Foam::NURBS3DVolume::getDxCellsDb } +Foam::label Foam::NURBS3DVolume::nUSymmetry() const +{ + label nU(basisU_.nCPs()); + if (nU % 2 == 0) + { + nU /=2; + } + else + { + nU = (nU - 1)/2 + 1; + } + return nU; +} + + +Foam::label Foam::NURBS3DVolume::nVSymmetry() const +{ + label nV(basisV_.nCPs()); + if (nV % 2 == 0) + { + nV /=2; + } + else + { + nV = (nV - 1)/2 + 1; + } + return nV; +} + + +Foam::label Foam::NURBS3DVolume::nWSymmetry() const +{ + label nW(basisW_.nCPs()); + if (nW % 2 == 0) + { + nW /=2; + } + else + { + nW = (nW - 1)/2 + 1; + } + return nW; +} + + void Foam::NURBS3DVolume::writeCps(const string fileName) const { const label nCPsU = basisU_.nCPs(); diff --git a/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DVolume/NURBS3DVolume/NURBS3DVolume.H b/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DVolume/NURBS3DVolume/NURBS3DVolume.H index 1ced58cde7549b0e3a67473c749e1c012a1148f7..2a59d834e756d04a8427b58a62390591b556939a 100644 --- a/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DVolume/NURBS3DVolume/NURBS3DVolume.H +++ b/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DVolume/NURBS3DVolume/NURBS3DVolume.H @@ -423,6 +423,15 @@ public: //- Get dxCartesiandb for a certain control point on cells tmp<volTensorField> getDxCellsDb(const label cpI); + //- Get number of variables if CPs are moved symmetrically in U + label nUSymmetry() const; + + //- Get number of variables if CPs are moved symmetrically in V + label nVSymmetry() const; + + //- Get number of variables if CPs are moved symmetrically in W + label nWSymmetry() const; + // Inline access functions diff --git a/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DVolume/cylindrical/NURBS3DVolumeCylindrical.C b/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DVolume/cylindrical/NURBS3DVolumeCylindrical.C index f87ea8c195fdd488347cbd28ee3956ffcdb0e0fe..c132d15c3e6386a5d6d05c1a5663eadb4a756a22 100644 --- a/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DVolume/cylindrical/NURBS3DVolumeCylindrical.C +++ b/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DVolume/cylindrical/NURBS3DVolumeCylindrical.C @@ -61,6 +61,7 @@ Foam::vector Foam::NURBS3DVolumeCylindrical::transformPointToCartesian localSystemCoordinates.x()*sin(localSystemCoordinates.y()), localSystemCoordinates.z() ); + cartesianCoors += origin_; return cartesianCoors; } @@ -90,11 +91,11 @@ void Foam::NURBS3DVolumeCylindrical::updateLocalCoordinateSystem { forAll(cartesianPoints, pI) { - const vector& point = cartesianPoints[pI]; + const vector point(cartesianPoints[pI] - origin_); vector cylindricalCoors(Zero); - scalar R = Foam::sqrt(sqr(point.x()) + sqr(point.y())); - scalar theta = atan2(point.y(), point.x()); + const scalar R(Foam::sqrt(sqr(point.x()) + sqr(point.y()))); + const scalar theta(atan2(point.y(), point.x())); cylindricalCoors.x() = R; cylindricalCoors.y() = theta; cylindricalCoors.z() = cartesianPoints[pI].z(); @@ -105,7 +106,7 @@ void Foam::NURBS3DVolumeCylindrical::updateLocalCoordinateSystem ( IOobject ( - "cylindricalCoors", + "cylindricalCoors" + name_, mesh_.time().timeName(), mesh_, IOobject::NO_READ, @@ -128,7 +129,8 @@ Foam::NURBS3DVolumeCylindrical::NURBS3DVolumeCylindrical bool computeParamCoors ) : - NURBS3DVolume(dict, mesh, computeParamCoors) + NURBS3DVolume(dict, mesh, computeParamCoors), + origin_(dict.get<vector>("origin")) { updateLocalCoordinateSystem(mesh.points()); writeCps("cpsBsplines" + mesh_.time().timeName()); diff --git a/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DVolume/cylindrical/NURBS3DVolumeCylindrical.H b/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DVolume/cylindrical/NURBS3DVolumeCylindrical.H index dd59428032049cfb77ab1c8c33ce078547fc203e..7996c655840ffb721240668e88de9e01b10def92 100644 --- a/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DVolume/cylindrical/NURBS3DVolumeCylindrical.H +++ b/src/optimisation/adjointOptimisation/adjoint/parameterization/NURBS/NURBS3DVolume/cylindrical/NURBS3DVolumeCylindrical.H @@ -57,7 +57,13 @@ class NURBS3DVolumeCylindrical { protected: - // Protected data + // Protected Data + + //- Translation vector + vector origin_; + + + // Protected Member Functions //- Transform a point from its coordinate system to a cartesian system vector transformPointToCartesian(const vector& localCoordinates) const;