Commit ea1b531a authored by Andrew Heather's avatar Andrew Heather
Browse files

Merge branch 'adjointOptimisation-fixes' into 'develop'

ENH: Adjoint optimisation fixes

See merge request !314
parents 4e4c681c e591cf13
......@@ -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_,
......
......@@ -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
......
......@@ -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();
......
......@@ -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
......
......@@ -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());
......
......@@ -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;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment