ENH: use boolVector for NURBS3DVolume constraints

- same as FixedList<bool,3> for I/O
This commit is contained in:
Mark Olesen
2020-07-15 14:34:52 +02:00
parent 5e954d2881
commit 53eda1c4f1
2 changed files with 33 additions and 32 deletions

View File

@ -499,7 +499,7 @@ void Foam::NURBS3DVolume::continuityRealatedConfinement()
// preserve continuity at the boundary of the parameterized space // preserve continuity at the boundary of the parameterized space
forAll(confineUMinCPs_, iCPu) forAll(confineUMinCPs_, iCPu)
{ {
const FixedList<bool, 3>& confineSlice = confineUMinCPs_[iCPu]; const boolVector& confineSlice = confineUMinCPs_[iCPu];
// Control points at the start of the parameterized space // Control points at the start of the parameterized space
for (label iCPw = 0; iCPw < nCPsW; iCPw++) for (label iCPw = 0; iCPw < nCPsW; iCPw++)
{ {
@ -512,7 +512,7 @@ void Foam::NURBS3DVolume::continuityRealatedConfinement()
forAll(confineUMaxCPs_, sliceI) forAll(confineUMaxCPs_, sliceI)
{ {
const FixedList<bool, 3>& confineSlice = confineUMaxCPs_[sliceI]; const boolVector& confineSlice = confineUMaxCPs_[sliceI];
label iCPu = nCPsU - 1 - sliceI; label iCPu = nCPsU - 1 - sliceI;
// Control points at the end of the parameterized space // Control points at the end of the parameterized space
for (label iCPw = 0; iCPw < nCPsW; iCPw++) for (label iCPw = 0; iCPw < nCPsW; iCPw++)
@ -528,7 +528,7 @@ void Foam::NURBS3DVolume::continuityRealatedConfinement()
// preserve continuity at the boundary of the parameterized space // preserve continuity at the boundary of the parameterized space
forAll(confineVMinCPs_, iCPv) forAll(confineVMinCPs_, iCPv)
{ {
const FixedList<bool, 3>& confineSlice = confineVMinCPs_[iCPv]; const boolVector& confineSlice = confineVMinCPs_[iCPv];
// Control points at the start of the parameterized space // Control points at the start of the parameterized space
for (label iCPw = 0; iCPw < nCPsW; iCPw++) for (label iCPw = 0; iCPw < nCPsW; iCPw++)
{ {
@ -541,7 +541,7 @@ void Foam::NURBS3DVolume::continuityRealatedConfinement()
forAll(confineVMaxCPs_, sliceI) forAll(confineVMaxCPs_, sliceI)
{ {
const FixedList<bool, 3>& confineSlice = confineVMaxCPs_[sliceI]; const boolVector& confineSlice = confineVMaxCPs_[sliceI];
label iCPv = nCPsV - 1 - sliceI; label iCPv = nCPsV - 1 - sliceI;
// Control points at the end of the parameterized space // Control points at the end of the parameterized space
for (label iCPw = 0; iCPw < nCPsW; iCPw++) for (label iCPw = 0; iCPw < nCPsW; iCPw++)
@ -557,7 +557,7 @@ void Foam::NURBS3DVolume::continuityRealatedConfinement()
// preserve continuity at the boundary of the parameterized space // preserve continuity at the boundary of the parameterized space
forAll(confineWMinCPs_, iCPw) forAll(confineWMinCPs_, iCPw)
{ {
const FixedList<bool, 3>& confineSlice = confineWMinCPs_[iCPw]; const boolVector& confineSlice = confineWMinCPs_[iCPw];
// Control points at the start of the parameterized space // Control points at the start of the parameterized space
for (label iCPv = 0; iCPv < nCPsV; iCPv++) for (label iCPv = 0; iCPv < nCPsV; iCPv++)
{ {
@ -570,7 +570,7 @@ void Foam::NURBS3DVolume::continuityRealatedConfinement()
forAll(confineWMaxCPs_, sliceI) forAll(confineWMaxCPs_, sliceI)
{ {
const FixedList<bool, 3>& confineSlice = confineWMaxCPs_[sliceI]; const boolVector& confineSlice = confineWMaxCPs_[sliceI];
label iCPw = nCPsW - 1 - sliceI; label iCPw = nCPsW - 1 - sliceI;
// Control points at the end of the parameterized space // Control points at the end of the parameterized space
for (label iCPv = 0; iCPv < nCPsV; iCPv++) for (label iCPv = 0; iCPv < nCPsV; iCPv++)
@ -616,7 +616,7 @@ void Foam::NURBS3DVolume::confineControlPoint(const label cpI)
void Foam::NURBS3DVolume::confineControlPoint void Foam::NURBS3DVolume::confineControlPoint
( (
const label cpI, const label cpI,
const FixedList<bool, 3>& confineDirections const boolVector& confineDirections
) )
{ {
if (cpI < 0 || cpI > cps_.size() -1) if (cpI < 0 || cpI > cps_.size() -1)
@ -628,9 +628,9 @@ void Foam::NURBS3DVolume::confineControlPoint
} }
else else
{ {
if (confineDirections[0]) activeDesignVariables_[3*cpI] = false; if (confineDirections.x()) activeDesignVariables_[3*cpI] = false;
if (confineDirections[1]) activeDesignVariables_[3*cpI + 1] = false; if (confineDirections.y()) activeDesignVariables_[3*cpI + 1] = false;
if (confineDirections[2]) activeDesignVariables_[3*cpI + 2] = false; if (confineDirections.z()) activeDesignVariables_[3*cpI + 2] = false;
} }
} }
@ -684,44 +684,44 @@ Foam::NURBS3DVolume::NURBS3DVolume
), ),
confineUMinCPs_ confineUMinCPs_
( (
dict.getOrDefaultCompat<boolListList3> dict.getOrDefaultCompat<boolVectorList>
( (
"confineUMinCPs", {{"boundUMinCPs", 1912}}, boolListList3(0) "confineUMinCPs", {{"boundUMinCPs", 1912}}, boolVectorList()
) )
), ),
confineUMaxCPs_ confineUMaxCPs_
( (
dict.getOrDefaultCompat<boolListList3> dict.getOrDefaultCompat<boolVectorList>
( (
"confineUMaxCPs", {{"boundUMaxCPs", 1912}}, boolListList3(0) "confineUMaxCPs", {{"boundUMaxCPs", 1912}}, boolVectorList()
) )
), ),
confineVMinCPs_ confineVMinCPs_
( (
dict.getOrDefaultCompat<boolListList3> dict.getOrDefaultCompat<boolVectorList>
( (
"confineVMinCPs", {{"boundVMinCPs", 1912}}, boolListList3(0) "confineVMinCPs", {{"boundVMinCPs", 1912}}, boolVectorList()
) )
), ),
confineVMaxCPs_ confineVMaxCPs_
( (
dict.getOrDefaultCompat<boolListList3> dict.getOrDefaultCompat<boolVectorList>
( (
"confineVMaxCPs", {{"boundVMaxCPs", 1912}}, boolListList3(0) "confineVMaxCPs", {{"boundVMaxCPs", 1912}}, boolVectorList()
) )
), ),
confineWMinCPs_ confineWMinCPs_
( (
dict.getOrDefaultCompat<boolListList3> dict.getOrDefaultCompat<boolVectorList>
( (
"confineWMinCPs", {{"boundWMinCPs", 1912}}, boolListList3(0) "confineWMinCPs", {{"boundWMinCPs", 1912}}, boolVectorList()
) )
), ),
confineWMaxCPs_ confineWMaxCPs_
( (
dict.getOrDefaultCompat<boolListList3> dict.getOrDefaultCompat<boolVectorList>
( (
"confineWMaxCPs", {{"boundWMaxCPs", 1912}}, boolListList3(0) "confineWMaxCPs", {{"boundWMaxCPs", 1912}}, boolVectorList()
) )
), ),
activeControlPoints_(0), //zero here, execute sanity checks first activeControlPoints_(0), //zero here, execute sanity checks first

View File

@ -7,7 +7,7 @@
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2007-2019 PCOpt/NTUA Copyright (C) 2007-2019 PCOpt/NTUA
Copyright (C) 2013-2019 FOSS GP Copyright (C) 2013-2019 FOSS GP
Copyright (C) 2019 OpenCFD Ltd. Copyright (C) 2019-2020 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -55,6 +55,7 @@ SourceFiles
#define NURBS3DVolume_H #define NURBS3DVolume_H
#include "NURBSbasis.H" #include "NURBSbasis.H"
#include "boolVector.H"
#include "pointMesh.H" #include "pointMesh.H"
#include "pointPatchField.H" #include "pointPatchField.H"
#include "pointPatchFieldsFwd.H" #include "pointPatchFieldsFwd.H"
@ -73,9 +74,9 @@ class NURBS3DVolume
{ {
protected: protected:
// Protected data // Protected Data
typedef List<FixedList<bool, 3>> boolListList3; typedef List<boolVector> boolVectorList;
//- NURBS basis functions //- NURBS basis functions
const fvMesh& mesh_; const fvMesh& mesh_;
@ -121,17 +122,17 @@ protected:
label confineBoundaryControlPoints_; label confineBoundaryControlPoints_;
//- Which movement components to freeze in each plane //- Which movement components to freeze in each plane
boolListList3 confineUMinCPs_; boolVectorList confineUMinCPs_;
boolListList3 confineUMaxCPs_; boolVectorList confineUMaxCPs_;
boolListList3 confineVMinCPs_; boolVectorList confineVMinCPs_;
boolListList3 confineVMaxCPs_; boolVectorList confineVMaxCPs_;
boolListList3 confineWMinCPs_; boolVectorList confineWMinCPs_;
boolListList3 confineWMaxCPs_; boolVectorList confineWMaxCPs_;
//- Which of the cps are moved in an optimisation //- Which of the cps are moved in an optimisation
boolList activeControlPoints_; boolList activeControlPoints_;
@ -186,7 +187,7 @@ protected:
void confineControlPoint(const label cpI); void confineControlPoint(const label cpI);
//- Confine specific movements for a prescribed control point //- Confine specific movements for a prescribed control point
void confineControlPoint(const label cpI, const FixedList<bool, 3>&); void confineControlPoint(const label cpI, const boolVector&);
//- Create folders to store cps and derivatives //- Create folders to store cps and derivatives
void makeFolders(); void makeFolders();