Commit ed63d9b2 authored by Vaggelis Papoutsis's avatar Vaggelis Papoutsis
Browse files

BUG: wrong bounding of sensitivity contituents in case of many control boxes (Fixes #1549)

When more than one volumetric B-Splines control boxes are present, the
sensitivity constituents corresponding to the non-active design
variables were not bounded(zeroed) correctly. The resultant
sensitivities, used in the optimization, were bounded correctly, so this
was more a bug pertaining to the output file of the sensitivities rather
than a functional one.
parent 8e78a278
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2007-2019 PCOpt/NTUA Copyright (C) 2007-2020 PCOpt/NTUA
Copyright (C) 2013-2019 FOSS GP Copyright (C) 2013-2020 FOSS GP
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
...@@ -108,7 +108,7 @@ void displacementMethodvolumetricBSplinesMotionSolver::boundControlField ...@@ -108,7 +108,7 @@ void displacementMethodvolumetricBSplinesMotionSolver::boundControlField
// control points movement. Safe since the motionSolver can only be an // control points movement. Safe since the motionSolver can only be an
// volumetricBSplinesMotionSolver // volumetricBSplinesMotionSolver
refCast<volumetricBSplinesMotionSolver> refCast<volumetricBSplinesMotionSolver>
(motionPtr_()).boundControlPointsMovement(controlField); (motionPtr_()).boundControlPointMovement(controlField);
} }
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2007-2019 PCOpt/NTUA Copyright (C) 2007-2020 PCOpt/NTUA
Copyright (C) 2013-2019 FOSS GP Copyright (C) 2013-2020 FOSS GP
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
...@@ -142,12 +142,12 @@ void Foam::volumetricBSplinesMotionSolver::setControlPointsMovement ...@@ -142,12 +142,12 @@ void Foam::volumetricBSplinesMotionSolver::setControlPointsMovement
} }
void Foam::volumetricBSplinesMotionSolver::boundControlPointsMovement void Foam::volumetricBSplinesMotionSolver::boundControlPointMovement
( (
vectorField& controlPointsMovement vectorField& controlPointsMovement
) )
{ {
volBSplinesBase_.boundControlPointsMovement(controlPointsMovement); volBSplinesBase_.boundControlPointMovement(controlPointsMovement);
} }
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2007-2019 PCOpt/NTUA Copyright (C) 2007-2020 PCOpt/NTUA
Copyright (C) 2013-2019 FOSS GP Copyright (C) 2013-2020 FOSS GP
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
...@@ -130,7 +130,7 @@ public: ...@@ -130,7 +130,7 @@ public:
void setControlPointsMovement(const vectorField& controlPointsMovement); void setControlPointsMovement(const vectorField& controlPointsMovement);
//- Bound control points movement //- Bound control points movement
void boundControlPointsMovement(vectorField& controlPointsMovement); void boundControlPointMovement(vectorField& controlPointsMovement);
}; };
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2007-2019 PCOpt/NTUA Copyright (C) 2007-2020 PCOpt/NTUA
Copyright (C) 2013-2019 FOSS GP Copyright (C) 2013-2020 FOSS GP
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
...@@ -86,10 +86,10 @@ void sensitivityVolBSplines::computeObjectiveContributions() ...@@ -86,10 +86,10 @@ void sensitivityVolBSplines::computeObjectiveContributions()
dSdbSens_[passedCPs + cpI] = dSdbSensCP; dSdbSens_[passedCPs + cpI] = dSdbSensCP;
dndbSens_[passedCPs + cpI] = dndbSensCP; dndbSens_[passedCPs + cpI] = dndbSensCP;
} }
boxes[iNURB].boundControlPointMovement(dSdbSens_);
boxes[iNURB].boundControlPointMovement(dndbSens_);
passedCPs += nb; passedCPs += nb;
} }
volBSplinesBase_.boundControlPointMovement(dSdbSens_);
volBSplinesBase_.boundControlPointMovement(dndbSens_);
passedCPs = 0; passedCPs = 0;
forAll(boxes, iNURB) forAll(boxes, iNURB)
...@@ -106,9 +106,9 @@ void sensitivityVolBSplines::computeObjectiveContributions() ...@@ -106,9 +106,9 @@ void sensitivityVolBSplines::computeObjectiveContributions()
{ {
dxdbDirectSens_[passedCPs + cpI] = sensDxDbDirect[cpI]; dxdbDirectSens_[passedCPs + cpI] = sensDxDbDirect[cpI];
} }
boxes[iNURB].boundControlPointMovement(dxdbDirectSens_);
passedCPs += sensDxDbDirect.size(); passedCPs += sensDxDbDirect.size();
} }
volBSplinesBase_.boundControlPointMovement(dxdbDirectSens_);
} }
} }
...@@ -188,9 +188,8 @@ void sensitivityVolBSplines::assembleSensitivities() ...@@ -188,9 +188,8 @@ void sensitivityVolBSplines::assembleSensitivities()
flowSens_[passedCPs + cpI] = sens[cpI]; flowSens_[passedCPs + cpI] = sens[cpI];
} }
passedCPs += sens.size(); passedCPs += sens.size();
boxes[iNURB].boundControlPointMovement(flowSens_);
} }
volBSplinesBase_.boundControlPointMovement(flowSens_);
// Contribution from objective function // Contribution from objective function
// Note: // Note:
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2007-2019 PCOpt/NTUA Copyright (C) 2007-2020 PCOpt/NTUA
Copyright (C) 2013-2019 FOSS GP Copyright (C) 2013-2020 FOSS GP
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
...@@ -137,7 +137,7 @@ void sensitivityVolBSplinesFI::assembleSensitivities() ...@@ -137,7 +137,7 @@ void sensitivityVolBSplinesFI::assembleSensitivities()
PtrList<NURBS3DVolume>& boxes = volBSplinesBase_.boxesRef(); PtrList<NURBS3DVolume>& boxes = volBSplinesBase_.boxesRef();
forAll(boxes, iNURB) forAll(boxes, iNURB)
{ {
label nb = boxes[iNURB].getControlPoints().size(); const label nb(boxes[iNURB].getControlPoints().size());
vectorField boxSensitivities(nb, Zero); vectorField boxSensitivities(nb, Zero);
vectorField dxdbSens = boxes[iNURB].computeControlPointSensitivities vectorField dxdbSens = boxes[iNURB].computeControlPointSensitivities
...@@ -278,13 +278,6 @@ void sensitivityVolBSplinesFI::assembleSensitivities() ...@@ -278,13 +278,6 @@ void sensitivityVolBSplinesFI::assembleSensitivities()
} }
// Zero sensitivities in non-active design variables // Zero sensitivities in non-active design variables
boxes[iNURB].boundControlPointMovement(flowSens_);
boxes[iNURB].boundControlPointMovement(dSdbSens_);
boxes[iNURB].boundControlPointMovement(dndbSens_);
boxes[iNURB].boundControlPointMovement(dVdbSens_);
boxes[iNURB].boundControlPointMovement(distanceSens_);
boxes[iNURB].boundControlPointMovement(dxdbDirectSens_);
boxes[iNURB].boundControlPointMovement(optionsSens_);
boxes[iNURB].boundControlPointMovement(boxSensitivities); boxes[iNURB].boundControlPointMovement(boxSensitivities);
// Transfer sensitivities to global list // Transfer sensitivities to global list
...@@ -299,6 +292,16 @@ void sensitivityVolBSplinesFI::assembleSensitivities() ...@@ -299,6 +292,16 @@ void sensitivityVolBSplinesFI::assembleSensitivities()
// Increment number of passed sensitivities // Increment number of passed sensitivities
passedCPs += nb; passedCPs += nb;
} }
// Zero non-active sensitivity components.
// For consistent output only, does not affect optimisation
volBSplinesBase_.boundControlPointMovement(flowSens_);
volBSplinesBase_.boundControlPointMovement(dSdbSens_);
volBSplinesBase_.boundControlPointMovement(dndbSens_);
volBSplinesBase_.boundControlPointMovement(dVdbSens_);
volBSplinesBase_.boundControlPointMovement(distanceSens_);
volBSplinesBase_.boundControlPointMovement(dxdbDirectSens_);
volBSplinesBase_.boundControlPointMovement(optionsSens_);
} }
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2007-2019 PCOpt/NTUA Copyright (C) 2007-2020 PCOpt/NTUA
Copyright (C) 2013-2019 FOSS GP Copyright (C) 2013-2020 FOSS GP
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
...@@ -69,7 +69,7 @@ computeBoundaryMovement ...@@ -69,7 +69,7 @@ computeBoundaryMovement
} }
// Bound control point movement for non-active CPs // Bound control point movement for non-active CPs
volBSplinesBase_.boundControlPointsMovement(cpMovement_); volBSplinesBase_.boundControlPointMovement(cpMovement_);
// Compute boundary movement // Compute boundary movement
label passedCPs(0); label passedCPs(0);
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2007-2019 PCOpt/NTUA Copyright (C) 2007-2020 PCOpt/NTUA
Copyright (C) 2013-2019 FOSS GP Copyright (C) 2013-2020 FOSS GP
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
...@@ -203,7 +203,7 @@ Foam::scalar Foam::volBSplinesBase::computeMaxBoundaryDisplacement ...@@ -203,7 +203,7 @@ Foam::scalar Foam::volBSplinesBase::computeMaxBoundaryDisplacement
label pastControlPoints(0); label pastControlPoints(0);
forAll(volume_, iNURB) forAll(volume_, iNURB)
{ {
const label nb = volume_[iNURB].getControlPoints().size(); const label nb(volume_[iNURB].getControlPoints().size());
vectorField localControlPointsMovement(nb, Zero); vectorField localControlPointsMovement(nb, Zero);
// Set localControlPointsMovement // Set localControlPointsMovement
...@@ -230,7 +230,7 @@ Foam::scalar Foam::volBSplinesBase::computeMaxBoundaryDisplacement ...@@ -230,7 +230,7 @@ Foam::scalar Foam::volBSplinesBase::computeMaxBoundaryDisplacement
} }
void Foam::volBSplinesBase::boundControlPointsMovement void Foam::volBSplinesBase::boundControlPointMovement
( (
vectorField& controlPointsMovement vectorField& controlPointsMovement
) )
...@@ -238,10 +238,10 @@ void Foam::volBSplinesBase::boundControlPointsMovement ...@@ -238,10 +238,10 @@ void Foam::volBSplinesBase::boundControlPointsMovement
label pastControlPoints(0); label pastControlPoints(0);
forAll(volume_, iNURB) forAll(volume_, iNURB)
{ {
label nb = volume_[iNURB].getControlPoints().size(); const label nb(volume_[iNURB].getControlPoints().size());
vectorField localControlPointsMovement(nb, Zero); vectorField localControlPointsMovement(nb, Zero);
// set localControlPointsMovement // Set localControlPointsMovement
forAll (localControlPointsMovement, iCPM) forAll (localControlPointsMovement, iCPM)
{ {
localControlPointsMovement[iCPM] = localControlPointsMovement[iCPM] =
...@@ -250,7 +250,7 @@ void Foam::volBSplinesBase::boundControlPointsMovement ...@@ -250,7 +250,7 @@ void Foam::volBSplinesBase::boundControlPointsMovement
volume_[iNURB].boundControlPointMovement(localControlPointsMovement); volume_[iNURB].boundControlPointMovement(localControlPointsMovement);
// transfer bounding back to controlPointMovement // Transfer bounding back to controlPointMovement
forAll(localControlPointsMovement, iCPM) forAll(localControlPointsMovement, iCPM)
{ {
controlPointsMovement[pastControlPoints + iCPM] = controlPointsMovement[pastControlPoints + iCPM] =
...@@ -270,10 +270,10 @@ void Foam::volBSplinesBase::moveControlPoints ...@@ -270,10 +270,10 @@ void Foam::volBSplinesBase::moveControlPoints
label pastControlPoints(0); label pastControlPoints(0);
forAll(volume_, iNURB) forAll(volume_, iNURB)
{ {
const label nb = volume_[iNURB].getControlPoints().size(); const label nb(volume_[iNURB].getControlPoints().size());
vectorField localControlPointsMovement(nb, Zero); vectorField localControlPointsMovement(nb, Zero);
// set localControlPointsMovement // Set localControlPointsMovement
forAll (localControlPointsMovement, iCPM) forAll (localControlPointsMovement, iCPM)
{ {
localControlPointsMovement[iCPM] = localControlPointsMovement[iCPM] =
......
...@@ -5,8 +5,8 @@ ...@@ -5,8 +5,8 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2007-2019 PCOpt/NTUA Copyright (C) 2007-2020 PCOpt/NTUA
Copyright (C) 2013-2019 FOSS GP Copyright (C) 2013-2020 FOSS GP
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
...@@ -141,7 +141,7 @@ public: ...@@ -141,7 +141,7 @@ public:
); );
//- Bound control points movement //- Bound control points movement
void boundControlPointsMovement(vectorField& controlPointsMovement); void boundControlPointMovement(vectorField& controlPointsMovement);
//- Move control points. No effect on mesh //- Move control points. No effect on mesh
void moveControlPoints(const vectorField& controlPointsMovement); void moveControlPoints(const vectorField& controlPointsMovement);
......
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