Prevent copying of switches: this causes double deletion error
This commit is contained in:
parent
50dc19899e
commit
7f92fbcae4
10 changed files with 89 additions and 84 deletions
|
@ -59,6 +59,15 @@ class constantsSwitch
|
|||
:
|
||||
public controlSwitches<scalar>
|
||||
{
|
||||
// Private member functions
|
||||
|
||||
//- Disallow construct as copy
|
||||
constantsSwitch(const constantsSwitch&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const constantsSwitch&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
|
|
@ -39,20 +39,6 @@ namespace debug
|
|||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
Foam::debug::controlSwitches<Type>::controlSwitches()
|
||||
:
|
||||
switchValue_(Type(0)),
|
||||
switchDescription_("")
|
||||
{}
|
||||
|
||||
template<class T>
|
||||
Foam::debug::controlSwitches<T>::controlSwitches(const T& switchValue)
|
||||
:
|
||||
switchValue_(switchValue)
|
||||
{}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::debug::controlSwitches<T>::controlSwitches
|
||||
(
|
||||
|
@ -101,19 +87,6 @@ Foam::debug::controlSwitches<T>::controlSwitches
|
|||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
Foam::debug::controlSwitches<T>::controlSwitches
|
||||
(
|
||||
const debug::controlSwitches<T>& csw
|
||||
)
|
||||
:
|
||||
switchName_(csw.switchName_),
|
||||
switchValue_(csw.switchValue_),
|
||||
switchDescription_(csw.switchDescription_)
|
||||
{}
|
||||
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
|
@ -137,37 +110,7 @@ Foam::debug::controlSwitches<T>::~controlSwitches()
|
|||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
void Foam::debug::controlSwitches<T>::operator=
|
||||
(
|
||||
const debug::controlSwitches<T>& rhs
|
||||
)
|
||||
{
|
||||
// Check for assignment to self
|
||||
if (this == &rhs)
|
||||
{
|
||||
std::cerr
|
||||
<< "Foam::debug::controlSwitches<T>::operator="
|
||||
<< "(const Foam::controlSwitches<T>&)"
|
||||
<< "--> FOAM FATAL ERROR: "
|
||||
<< "Attempted assignment to self"
|
||||
<< std::endl;
|
||||
|
||||
std::abort();
|
||||
|
||||
exit(-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
switchValue_ = rhs.switchValue_;
|
||||
switchDescription_ = rhs.switchDescription_;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * //
|
||||
// * * * * * * * * * * * * * * * IOstream Operators * * * * * * * * * * * * //
|
||||
|
||||
template<class T>
|
||||
void printControlSwitches
|
||||
|
|
|
@ -231,16 +231,19 @@ class controlSwitches
|
|||
switchValuesTable_;
|
||||
|
||||
|
||||
// Private member functions
|
||||
|
||||
//- Disallow construct as copy
|
||||
controlSwitches(const controlSwitches<T>&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const controlSwitches<T>&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
controlSwitches();
|
||||
|
||||
//- Construct from components
|
||||
explicit controlSwitches(const T& data);
|
||||
|
||||
controlSwitches
|
||||
(
|
||||
const std::string& switchName,
|
||||
|
@ -251,9 +254,6 @@ public:
|
|||
switchesValues
|
||||
);
|
||||
|
||||
//- Construct as copy
|
||||
controlSwitches(const controlSwitches&);
|
||||
|
||||
|
||||
//- Destructor
|
||||
~controlSwitches();
|
||||
|
@ -262,7 +262,7 @@ public:
|
|||
// Member Functions
|
||||
|
||||
// Check
|
||||
bool boolean_test() const
|
||||
bool test() const
|
||||
{
|
||||
// Perform Boolean logic here
|
||||
return switchValue_ != 0;
|
||||
|
@ -274,9 +274,6 @@ public:
|
|||
//- Assignement operator
|
||||
void operator=(const T&);
|
||||
|
||||
//- Assignement operator
|
||||
void operator=(const controlSwitches&);
|
||||
|
||||
//- & operator
|
||||
const T operator&(const T&);
|
||||
|
||||
|
|
|
@ -58,6 +58,15 @@ class debugSwitch
|
|||
:
|
||||
public controlSwitches<int>
|
||||
{
|
||||
// Private member functions
|
||||
|
||||
//- Disallow construct as copy
|
||||
debugSwitch(const debugSwitch&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const debugSwitch&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
|
|
@ -54,8 +54,18 @@ ListInfoControlSwitches;
|
|||
extern ListInfoControlSwitches* infoSwitchValues_;
|
||||
|
||||
class infoSwitch
|
||||
: public controlSwitches<int>
|
||||
:
|
||||
public controlSwitches<int>
|
||||
{
|
||||
// Private member functions
|
||||
|
||||
//- Disallow construct as copy
|
||||
infoSwitch(const infoSwitch&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const infoSwitch&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
|
|
@ -59,6 +59,15 @@ class optimisationSwitch
|
|||
:
|
||||
public controlSwitches<int>
|
||||
{
|
||||
// Private member functions
|
||||
|
||||
//- Disallow construct as copy
|
||||
optimisationSwitch(const optimisationSwitch&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const optimisationSwitch&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
|
|
@ -78,7 +78,7 @@ public:
|
|||
|
||||
operator boolType() const
|
||||
{
|
||||
return (static_cast<const T*>(this))->boolean_test()
|
||||
return (static_cast<const T*>(this))->test()
|
||||
? &safeBoolBase::thisTypeDoesNotSupportComparisons : 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,6 +58,15 @@ class tolerancesSwitch
|
|||
:
|
||||
public controlSwitches<scalar>
|
||||
{
|
||||
// Private member functions
|
||||
|
||||
//- Disallow construct as copy
|
||||
tolerancesSwitch(const tolerancesSwitch&);
|
||||
|
||||
//- Disallow default bitwise assignment
|
||||
void operator=(const tolerancesSwitch&);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
|
|
@ -351,35 +351,54 @@ Foam::Ostream& Foam::operator<<(Ostream& os, const BlockLduMatrix<Type>& ldum)
|
|||
else
|
||||
{
|
||||
// Dummy write for consistency
|
||||
os.writeKeyword("diagonal") << typename BlockLduMatrix<Type>::TypeCoeffField
|
||||
(ldum.lduAddr().size()) << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("diagonal")
|
||||
<< typename BlockLduMatrix<Type>::TypeCoeffField
|
||||
(
|
||||
ldum.lduAddr().size()
|
||||
)
|
||||
<< token::END_STATEMENT << nl;
|
||||
}
|
||||
|
||||
if (ldum.upperPtr_)
|
||||
{
|
||||
os.writeKeyword("upper") << *ldum.upperPtr_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("upper")
|
||||
<< *ldum.upperPtr_
|
||||
<< token::END_STATEMENT << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Dummy write for consistency
|
||||
os.writeKeyword("upper") << typename BlockLduMatrix<Type>::TypeCoeffField
|
||||
(ldum.lduAddr().lowerAddr().size()) << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("upper")
|
||||
<< typename BlockLduMatrix<Type>::TypeCoeffField
|
||||
(
|
||||
ldum.lduAddr().lowerAddr().size()
|
||||
)
|
||||
<< token::END_STATEMENT << nl;
|
||||
}
|
||||
|
||||
if (ldum.lowerPtr_)
|
||||
{
|
||||
os.writeKeyword("lower") << *ldum.lowerPtr_ << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("lower")
|
||||
<< *ldum.lowerPtr_ << token::END_STATEMENT << nl;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Dummy write for consistency
|
||||
os.writeKeyword("lower") << typename BlockLduMatrix<Type>::TypeCoeffField
|
||||
(ldum.lduAddr().lowerAddr().size()) << token::END_STATEMENT << nl;
|
||||
os.writeKeyword("lower")
|
||||
<< typename BlockLduMatrix<Type>::TypeCoeffField
|
||||
(
|
||||
ldum.lduAddr().lowerAddr().size()
|
||||
)
|
||||
<< token::END_STATEMENT << nl;
|
||||
}
|
||||
|
||||
os.writeKeyword("coupleUpper") << ldum.coupleUpper_ << token::END_STATEMENT << endl;
|
||||
os.writeKeyword("coupleUpper")
|
||||
<< ldum.coupleUpper_
|
||||
<< token::END_STATEMENT << endl;
|
||||
|
||||
os.writeKeyword("coupleLower") << ldum.coupleLower_ << token::END_STATEMENT << endl;
|
||||
os.writeKeyword("coupleLower")
|
||||
<< ldum.coupleLower_
|
||||
<< token::END_STATEMENT << endl;
|
||||
|
||||
os.check("Ostream& operator<<(Ostream&, const BlockLduMatrix<Type>&");
|
||||
|
||||
|
|
|
@ -209,7 +209,7 @@ void Foam::coarseAmgLevel::solve
|
|||
}
|
||||
|
||||
// Switch of debug in top-level direct solve
|
||||
debug::debugSwitch oldDebug = lduMatrix::debug;
|
||||
label oldDebug = lduMatrix::debug();
|
||||
|
||||
if (matrixPtr_->matrix().symmetric())
|
||||
{
|
||||
|
|
Reference in a new issue