mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'develop' of develop.openfoam.com:Development/OpenFOAM-plus into develop
This commit is contained in:
@ -70,6 +70,10 @@ primitives/Tensor/lists/symmTensorList.C
|
||||
primitives/Tensor/lists/tensorList.C
|
||||
|
||||
primitives/Vector/complexVector/complexVector.C
|
||||
#if !defined(WM_DP)
|
||||
primitives/Vector/doubleVector/doubleVector.C
|
||||
primitives/Tensor/doubleTensor/doubleTensor.C
|
||||
#endif
|
||||
#if !defined(WM_SP)
|
||||
primitives/Vector/floatVector/floatVector.C
|
||||
primitives/Tensor/floatTensor/floatTensor.C
|
||||
|
||||
@ -212,13 +212,14 @@ Foam::dimensioned<Type> Foam::dimensioned<Type>::lookupOrDefault
|
||||
const Type& defaultValue
|
||||
)
|
||||
{
|
||||
return
|
||||
dimensioned<Type>
|
||||
(
|
||||
name,
|
||||
dims,
|
||||
dict.lookupOrDefault<Type>(name, defaultValue)
|
||||
);
|
||||
if (dict.found(name))
|
||||
{
|
||||
return dimensioned<Type>(name, dims, dict);
|
||||
}
|
||||
else
|
||||
{
|
||||
return dimensioned<Type>(name, dims, defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -871,8 +871,14 @@ void Foam::argList::parse
|
||||
if (Pstream::master() && bannerEnabled())
|
||||
{
|
||||
IOobject::writeBanner(Info, true)
|
||||
<< "Build : " << foamVersion::build.c_str()
|
||||
<< " (OPENFOAM=" << OPENFOAM;
|
||||
<< "Build : ";
|
||||
|
||||
if (foamVersion::build.size())
|
||||
{
|
||||
Info<< foamVersion::build.c_str() << ' ';
|
||||
}
|
||||
|
||||
Info<< "OPENFOAM=" << foamVersion::api;
|
||||
|
||||
if (foamVersion::patched())
|
||||
{
|
||||
@ -880,7 +886,7 @@ void Foam::argList::parse
|
||||
Info<< " patch=" << foamVersion::patch.c_str();
|
||||
}
|
||||
|
||||
Info<< ')' << nl
|
||||
Info<< nl
|
||||
<< "Arch : " << foamVersion::buildArch << nl
|
||||
<< "Exec : " << commandLine_.c_str() << nl
|
||||
<< "Date : " << dateString.c_str() << nl
|
||||
|
||||
@ -371,12 +371,15 @@ public:
|
||||
const T& deflt
|
||||
) const;
|
||||
|
||||
//- Read a List of values from the named option,
|
||||
//- Get a List of values from the named option,
|
||||
//- treating a single entry like a list of size 1.
|
||||
// \param optName the option name to read from
|
||||
// \param mandatory if the option is non-mandatory, the behaviour
|
||||
// is similar to readListIfPresent().
|
||||
template<class T>
|
||||
inline List<T> getList(const word& optName) const;
|
||||
inline List<T> getList(const word& optName, bool mandatory=true) const;
|
||||
|
||||
//- If named option is present, read a List of values
|
||||
//- If named option is present, get a List of values
|
||||
//- treating a single entry like a list of size 1.
|
||||
// \return true if the named option was found.
|
||||
template<class T>
|
||||
|
||||
@ -322,14 +322,22 @@ inline Foam::List<T> Foam::argList::getList(const label index) const
|
||||
|
||||
|
||||
template<class T>
|
||||
inline Foam::List<T> Foam::argList::getList(const word& optName) const
|
||||
inline Foam::List<T> Foam::argList::getList
|
||||
(
|
||||
const word& optName,
|
||||
bool mandatory
|
||||
) const
|
||||
{
|
||||
ITstream is(optName, options_[optName]);
|
||||
|
||||
List<T> list;
|
||||
readList(is, list);
|
||||
|
||||
checkITstream(is, optName);
|
||||
if (mandatory || found(optName))
|
||||
{
|
||||
ITstream is(optName, options_[optName]);
|
||||
|
||||
readList(is, list);
|
||||
|
||||
checkITstream(is, optName);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
@ -345,6 +353,7 @@ inline bool Foam::argList::readListIfPresent
|
||||
if (found(optName))
|
||||
{
|
||||
ITstream is(optName, options_[optName]);
|
||||
|
||||
readList(is, list);
|
||||
|
||||
checkITstream(is, optName);
|
||||
|
||||
@ -95,6 +95,7 @@ static inline bool groupResourceDir(Foam::fileName& queried)
|
||||
is undefined (was this intentional?)
|
||||
#endif
|
||||
|
||||
queried.clear();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -108,7 +109,13 @@ static inline bool groupResourceDir(Foam::fileName& queried)
|
||||
static inline bool projectResourceDir(Foam::fileName& queried)
|
||||
{
|
||||
queried = Foam::getEnv("WM_PROJECT_DIR")/"etc";
|
||||
return (queried.size() > 3 && Foam::isDir(queried));
|
||||
if (queried.size() > 3)
|
||||
{
|
||||
return Foam::isDir(queried);
|
||||
}
|
||||
|
||||
queried.clear();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@ -119,8 +126,9 @@ Foam::fileNameList searchEtc
|
||||
bool (*accept)(const Foam::fileName&)
|
||||
)
|
||||
{
|
||||
// Could use foamVersion::api, but this more direct.
|
||||
const Foam::fileName version(std::to_string(OPENFOAM));
|
||||
// Use foamVersion::api (instead of the OPENFOAM define) to ensure this
|
||||
// stays properly synchronized with the build information
|
||||
const Foam::fileName version(std::to_string(Foam::foamVersion::api));
|
||||
|
||||
Foam::fileNameList list;
|
||||
Foam::fileName dir, candidate;
|
||||
@ -192,6 +200,42 @@ Foam::fileNameList searchEtc
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::fileNameList Foam::etcDirs(bool test)
|
||||
{
|
||||
// Use foamVersion::api (instead of the OPENFOAM define) to ensure this
|
||||
// stays properly synchronized with the build information
|
||||
const Foam::fileName version(std::to_string(Foam::foamVersion::api));
|
||||
|
||||
Foam::fileNameList list(5);
|
||||
Foam::fileName dir;
|
||||
label nDirs = 0;
|
||||
|
||||
// User resource directories
|
||||
if (userResourceDir(dir) || (!test && dir.size()))
|
||||
{
|
||||
list[nDirs++] = dir/version;
|
||||
list[nDirs++] = dir;
|
||||
}
|
||||
|
||||
// Group (site) resource directories
|
||||
if (groupResourceDir(dir) || (!test && dir.size()))
|
||||
{
|
||||
list[nDirs++] = dir/version;
|
||||
list[nDirs++] = dir;
|
||||
}
|
||||
|
||||
// Other (project) resource directory
|
||||
if (projectResourceDir(dir) || (!test && dir.size()))
|
||||
{
|
||||
list[nDirs++] = dir;
|
||||
}
|
||||
|
||||
list.resize(nDirs);
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
Foam::fileNameList Foam::findEtcDirs
|
||||
(
|
||||
const fileName& name,
|
||||
|
||||
@ -44,6 +44,14 @@ namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
//- The etc search directories in the normal search order.
|
||||
//
|
||||
// \param test false to disable the default test for directory existence.
|
||||
//
|
||||
// \return The list of directories
|
||||
fileNameList etcDirs(bool test=true);
|
||||
|
||||
|
||||
//- Search for directories from user/group/other directories.
|
||||
// Uses search hierarchy as per findEtcFiles().
|
||||
//
|
||||
@ -51,8 +59,8 @@ namespace Foam
|
||||
// an empty list if the name cannot be found.
|
||||
fileNameList findEtcDirs
|
||||
(
|
||||
const fileName& name=fileName::null, //!< the file to search for
|
||||
const bool findFirst=false //!< stop when the first file has been found
|
||||
const fileName& name, //!< The directory to search for
|
||||
const bool findFirst=false //!< Stop after locating the first directory
|
||||
);
|
||||
|
||||
|
||||
@ -76,9 +84,9 @@ fileNameList findEtcDirs
|
||||
// an empty list if the name cannot be found.
|
||||
fileNameList findEtcFiles
|
||||
(
|
||||
const fileName& name, //!< the file to search for
|
||||
const bool mandatory=false, //!< abort if the file cannot be found
|
||||
const bool findFirst=false //!< stop when the first file has been found
|
||||
const fileName& name, //!< The file to search for
|
||||
const bool mandatory=false, //!< Abort if the file cannot be found
|
||||
const bool findFirst=false //!< Stop after locating the first directory
|
||||
);
|
||||
|
||||
|
||||
@ -88,8 +96,8 @@ fileNameList findEtcFiles
|
||||
// search hierarchy or an empty fileName if the name cannot be found.
|
||||
fileName findEtcFile
|
||||
(
|
||||
const fileName& name, //!< the file to search for
|
||||
const bool mandatory=false //!< abort if the file cannot be found
|
||||
const fileName& name, //!< The file to search for
|
||||
const bool mandatory=false //!< Abort if the file cannot be found
|
||||
);
|
||||
|
||||
|
||||
|
||||
86
src/OpenFOAM/primitives/Tensor/doubleTensor/doubleTensor.C
Normal file
86
src/OpenFOAM/primitives/Tensor/doubleTensor/doubleTensor.C
Normal file
@ -0,0 +1,86 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "doubleTensor.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
template<>
|
||||
const char* const Foam::doubleTensor::vsType::typeName = "doubleTensor";
|
||||
|
||||
template<>
|
||||
const char* const Foam::doubleTensor::vsType::componentNames[] =
|
||||
{
|
||||
"xx", "xy", "xz",
|
||||
"yx", "yy", "yz",
|
||||
"zx", "zy", "zz"
|
||||
};
|
||||
|
||||
template<>
|
||||
const Foam::doubleTensor Foam::doubleTensor::vsType::zero
|
||||
(
|
||||
doubleTensor::uniform(0)
|
||||
);
|
||||
|
||||
template<>
|
||||
const Foam::doubleTensor Foam::doubleTensor::vsType::one
|
||||
(
|
||||
doubleTensor::uniform(1)
|
||||
);
|
||||
|
||||
template<>
|
||||
const Foam::doubleTensor Foam::doubleTensor::vsType::max
|
||||
(
|
||||
doubleTensor::uniform(doubleScalarVGREAT)
|
||||
);
|
||||
|
||||
template<>
|
||||
const Foam::doubleTensor Foam::doubleTensor::vsType::min
|
||||
(
|
||||
doubleTensor::uniform(-doubleScalarVGREAT)
|
||||
);
|
||||
|
||||
template<>
|
||||
const Foam::doubleTensor Foam::doubleTensor::vsType::rootMax
|
||||
(
|
||||
doubleTensor::uniform(doubleScalarROOTVGREAT)
|
||||
);
|
||||
|
||||
template<>
|
||||
const Foam::doubleTensor Foam::doubleTensor::vsType::rootMin
|
||||
(
|
||||
doubleTensor::uniform(-doubleScalarROOTVGREAT)
|
||||
);
|
||||
|
||||
template<>
|
||||
const Foam::doubleTensor Foam::doubleTensor::I
|
||||
(
|
||||
1, 0, 0,
|
||||
0, 1, 0,
|
||||
0, 0, 1
|
||||
);
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
64
src/OpenFOAM/primitives/Tensor/doubleTensor/doubleTensor.H
Normal file
64
src/OpenFOAM/primitives/Tensor/doubleTensor/doubleTensor.H
Normal file
@ -0,0 +1,64 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Typedef
|
||||
Foam::doubleTensor
|
||||
|
||||
Description
|
||||
A Tensor of values with double precision
|
||||
|
||||
SourceFiles
|
||||
doubleTensor.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef doubleTensor_H
|
||||
#define doubleTensor_H
|
||||
|
||||
#include "Tensor.H"
|
||||
#include "contiguous.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
typedef Tensor<double> doubleTensor;
|
||||
|
||||
//- Data associated with doubleTensor type are contiguous
|
||||
#if !defined(WM_DP)
|
||||
template<>
|
||||
inline bool contiguous<doubleTensor>() {return true;}
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -25,7 +25,7 @@ Typedef
|
||||
Foam::floatTensor
|
||||
|
||||
Description
|
||||
FloatTensor of scalars.
|
||||
A Tensor of values with float precision
|
||||
|
||||
SourceFiles
|
||||
floatTensor.C
|
||||
@ -48,9 +48,10 @@ namespace Foam
|
||||
typedef Tensor<float> floatTensor;
|
||||
|
||||
//- Data associated with floatTensor type are contiguous
|
||||
#if !defined(WM_SP)
|
||||
template<>
|
||||
inline bool contiguous<floatTensor>() {return true;}
|
||||
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
|
||||
@ -25,7 +25,7 @@ Typedef
|
||||
Foam::labelTensor
|
||||
|
||||
Description
|
||||
3D labelTensor obtained from generic Tensor
|
||||
A Tensor of values using label (integer) representation.
|
||||
|
||||
SourceFiles
|
||||
labelTensor.C
|
||||
|
||||
76
src/OpenFOAM/primitives/Vector/doubleVector/doubleVector.C
Normal file
76
src/OpenFOAM/primitives/Vector/doubleVector/doubleVector.C
Normal file
@ -0,0 +1,76 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "doubleVector.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
template<>
|
||||
const char* const Foam::doubleVector::vsType::typeName = "doubleVector";
|
||||
|
||||
template<>
|
||||
const char* const Foam::doubleVector::vsType::componentNames[] =
|
||||
{
|
||||
"x", "y", "z"
|
||||
};
|
||||
|
||||
template<>
|
||||
const Foam::doubleVector Foam::doubleVector::vsType::zero
|
||||
(
|
||||
doubleVector::uniform(0)
|
||||
);
|
||||
|
||||
template<>
|
||||
const Foam::doubleVector Foam::doubleVector::vsType::one
|
||||
(
|
||||
doubleVector::uniform(1)
|
||||
);
|
||||
|
||||
template<>
|
||||
const Foam::doubleVector Foam::doubleVector::vsType::max
|
||||
(
|
||||
doubleVector::uniform(doubleScalarVGREAT)
|
||||
);
|
||||
|
||||
template<>
|
||||
const Foam::doubleVector Foam::doubleVector::vsType::min
|
||||
(
|
||||
doubleVector::uniform(-doubleScalarVGREAT)
|
||||
);
|
||||
|
||||
template<>
|
||||
const Foam::doubleVector Foam::doubleVector::vsType::rootMax
|
||||
(
|
||||
doubleVector::uniform(doubleScalarROOTVGREAT)
|
||||
);
|
||||
|
||||
template<>
|
||||
const Foam::doubleVector Foam::doubleVector::vsType::rootMin
|
||||
(
|
||||
doubleVector::uniform(-doubleScalarROOTVGREAT)
|
||||
);
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
64
src/OpenFOAM/primitives/Vector/doubleVector/doubleVector.H
Normal file
64
src/OpenFOAM/primitives/Vector/doubleVector/doubleVector.H
Normal file
@ -0,0 +1,64 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Typedef
|
||||
Foam::doubleVector
|
||||
|
||||
Description
|
||||
A Vector of values with double precision.
|
||||
|
||||
SourceFiles
|
||||
doubleVector.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef doubleVector_H
|
||||
#define doubleVector_H
|
||||
|
||||
#include "Vector.H"
|
||||
#include "contiguous.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
typedef Vector<double> doubleVector;
|
||||
|
||||
//- Data associated with doubleVector type are contiguous
|
||||
#if !defined(WM_DP)
|
||||
template<>
|
||||
inline bool contiguous<doubleVector>() {return true;}
|
||||
#endif
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -21,9 +21,6 @@ License
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Vector of floats.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "floatVector.H"
|
||||
|
||||
@ -25,7 +25,7 @@ Typedef
|
||||
Foam::floatVector
|
||||
|
||||
Description
|
||||
A float version of vector
|
||||
A Vector of values with float precision.
|
||||
|
||||
SourceFiles
|
||||
floatVector.C
|
||||
|
||||
@ -187,6 +187,9 @@ bool Foam::UPstream::init(int& argc, char**& argv, const bool needsThread)
|
||||
Pout<< "UPstream::init : mpi-buffer-size " << bufSize << endl;
|
||||
}
|
||||
|
||||
// TBD: could add error handling here.
|
||||
// Delete allocated and leave if we fail to attach the buffer?
|
||||
|
||||
MPI_Buffer_attach(new char[bufSize], bufSize);
|
||||
}
|
||||
#endif
|
||||
@ -225,10 +228,19 @@ void Foam::UPstream::exit(int errnum)
|
||||
|
||||
#ifndef SGIMPI
|
||||
{
|
||||
int size;
|
||||
char* buff;
|
||||
MPI_Buffer_detach(&buff, &size);
|
||||
delete[] buff;
|
||||
// Some MPI notes suggest that the return code is MPI_SUCCESS when
|
||||
// no buffer is attached.
|
||||
// Be extra careful and require a non-zero size as well.
|
||||
|
||||
int bufSize = 0;
|
||||
char* buf = nullptr;
|
||||
|
||||
flag = MPI_Buffer_detach(&buf, &bufSize);
|
||||
|
||||
if (MPI_SUCCESS == flag && bufSize)
|
||||
{
|
||||
delete[] buf;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
396
src/functionObjects/field/AMIWeights/AMIWeights.C
Normal file
396
src/functionObjects/field/AMIWeights/AMIWeights.C
Normal file
@ -0,0 +1,396 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "AMIWeights.H"
|
||||
#include "fvMesh.H"
|
||||
#include "foamVtkSurfaceWriter.H"
|
||||
#include "PatchTools.H"
|
||||
#include "cyclicACMIPolyPatch.H"
|
||||
#include "addToRunTimeSelectionTable.H"
|
||||
|
||||
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
defineTypeNameAndDebug(AMIWeights, 0);
|
||||
addToRunTimeSelectionTable(functionObject, AMIWeights, dictionary);
|
||||
}
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * Protected Member Functions * * * * * * * * * * * //
|
||||
|
||||
void Foam::functionObjects::AMIWeights::writeFileHeader(Ostream& os)
|
||||
{
|
||||
writeHeader(os, "AMI");
|
||||
|
||||
writeCommented(os, "Time");
|
||||
forAll(patchIDs_, patchi)
|
||||
{
|
||||
writeTabbed(os, "Patch");
|
||||
writeTabbed(os, "nbr_patch");
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
writeTabbed(os, "distributed");
|
||||
}
|
||||
|
||||
writeTabbed(os, "src_min_weight");
|
||||
writeTabbed(os, "src_max_weight");
|
||||
writeTabbed(os, "src_average_weight");
|
||||
writeTabbed(os, "src_min_neighbours");
|
||||
writeTabbed(os, "src_max_neighbours");
|
||||
writeTabbed(os, "src_average_neighbours");
|
||||
writeTabbed(os, "tgt_min_weight");
|
||||
writeTabbed(os, "tgt_max_weight");
|
||||
writeTabbed(os, "tgt_average_weight");
|
||||
writeTabbed(os, "tgt_min_neighbours");
|
||||
writeTabbed(os, "tgt_max_neighbours");
|
||||
writeTabbed(os, "tgt_average_neighbours");
|
||||
}
|
||||
|
||||
os << endl;
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::AMIWeights::reportPatch
|
||||
(
|
||||
const cyclicAMIPolyPatch& pp
|
||||
)
|
||||
{
|
||||
const word& nbrPatchName = pp.neighbPatchName();
|
||||
|
||||
const Switch distributed = pp.AMI().singlePatchProc() == -1;
|
||||
|
||||
const scalarField& srcWeightsSum = pp.AMI().srcWeightsSum();
|
||||
const scalar srcMinWeight = gMin(srcWeightsSum);
|
||||
const scalar srcMaxWeight = gMax(srcWeightsSum);
|
||||
const scalar srcAveWeight = gAverage(srcWeightsSum);
|
||||
|
||||
const labelListList& srcAddress = pp.AMI().srcAddress();
|
||||
label srcMinNbr = labelMax;
|
||||
label srcMaxNbr = labelMin;
|
||||
scalar srcAveNbr = 0;
|
||||
for (const labelList& srcFace : srcAddress)
|
||||
{
|
||||
const label n = srcFace.size();
|
||||
srcAveNbr += n;
|
||||
srcMinNbr = min(srcMinNbr, n);
|
||||
srcMaxNbr = max(srcMaxNbr, n);
|
||||
}
|
||||
|
||||
reduce(srcMinNbr, minOp<label>());
|
||||
reduce(srcMaxNbr, maxOp<label>());
|
||||
|
||||
srcAveNbr =
|
||||
returnReduce(srcAveNbr, sumOp<scalar>())
|
||||
/(returnReduce(srcAddress.size(), sumOp<scalar>()) + ROOTVSMALL);
|
||||
|
||||
const scalarField& tgtWeightsSum = pp.AMI().tgtWeightsSum();
|
||||
const scalar tgtMinWeight = gMin(tgtWeightsSum);
|
||||
const scalar tgtMaxWeight = gMax(tgtWeightsSum);
|
||||
const scalar tgtAveWeight = gAverage(tgtWeightsSum);
|
||||
|
||||
const labelListList& tgtAddress = pp.AMI().tgtAddress();
|
||||
label tgtMinNbr = labelMax;
|
||||
label tgtMaxNbr = labelMin;
|
||||
scalar tgtAveNbr = 0;
|
||||
for (const labelList& tgtFace : tgtAddress)
|
||||
{
|
||||
const label n = tgtFace.size();
|
||||
tgtAveNbr += n;
|
||||
tgtMinNbr = min(tgtMinNbr, n);
|
||||
tgtMaxNbr = max(tgtMaxNbr, n);
|
||||
}
|
||||
|
||||
reduce(tgtMinNbr, minOp<label>());
|
||||
reduce(tgtMaxNbr, maxOp<label>());
|
||||
|
||||
tgtAveNbr =
|
||||
returnReduce(tgtAveNbr, sumOp<scalar>())
|
||||
/(returnReduce(tgtAddress.size(), sumOp<scalar>()) + ROOTVSMALL);
|
||||
|
||||
file()
|
||||
<< mesh_.time().timeName() << tab
|
||||
<< pp.name() << tab
|
||||
<< nbrPatchName << tab;
|
||||
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
file() << distributed << tab;
|
||||
}
|
||||
|
||||
file()
|
||||
<< srcMinWeight << tab
|
||||
<< srcMaxWeight << tab
|
||||
<< srcAveWeight << tab
|
||||
<< srcMinNbr << tab
|
||||
<< srcMaxNbr << tab
|
||||
<< srcAveNbr << tab
|
||||
<< tgtMinWeight << tab
|
||||
<< tgtMaxWeight << tab
|
||||
<< tgtAveWeight << tab
|
||||
<< tgtMinNbr << tab
|
||||
<< tgtMaxNbr << tab
|
||||
<< tgtAveNbr << tab
|
||||
<< endl;
|
||||
|
||||
Log << " Patches: " << nl
|
||||
<< " Source: " << pp.name() << nl
|
||||
<< " Target: " << nbrPatchName << nl;
|
||||
|
||||
if (Pstream::parRun())
|
||||
{
|
||||
Log << " Parallel distributed: " << distributed << nl;
|
||||
}
|
||||
|
||||
Log << nl;
|
||||
|
||||
const label w = IOstream::defaultPrecision() + 8;
|
||||
|
||||
Log << " | " << setw(w) << pp.name()
|
||||
<< " | " << setw(w) << nbrPatchName << " | " << nl
|
||||
<< " min(weight) | " << setw(w) << srcMinWeight
|
||||
<< " | " << setw(w) << tgtMinWeight << " | " << nl
|
||||
<< " max(weight) | " << setw(w) << srcMaxWeight
|
||||
<< " | " << setw(w) << tgtMaxWeight << " | " << nl
|
||||
<< " ave(weight) | " << setw(w) << srcAveWeight
|
||||
<< " | " << setw(w) << tgtAveWeight << " | " << nl
|
||||
<< " min(address) | " << setw(w) << srcMinNbr
|
||||
<< " | " << setw(w) << tgtMinNbr << " | " << nl
|
||||
<< " max(address) | " << setw(w) << srcMaxNbr
|
||||
<< " | " << setw(w) << tgtMaxNbr << " | " << nl
|
||||
<< " ave(address) | " << setw(w) << srcAveNbr
|
||||
<< " | " << setw(w) << tgtAveNbr << " | " << nl
|
||||
<< endl;
|
||||
|
||||
setResult(pp.name() + ":src", pp.name());
|
||||
setResult(pp.name() + ":tgt", nbrPatchName);
|
||||
setResult(pp.name() + ":src:min(weight)", srcMinWeight);
|
||||
setResult(pp.name() + ":src:max(weight)", srcMaxWeight);
|
||||
setResult(pp.name() + ":src:ave(weight)", srcAveWeight);
|
||||
setResult(pp.name() + ":src:min(address)", srcMinNbr);
|
||||
setResult(pp.name() + ":src:max(address)", srcMaxNbr);
|
||||
setResult(pp.name() + ":src:ave(address)", srcAveNbr);
|
||||
setResult(pp.name() + ":tgt:min(weight)", tgtMinWeight);
|
||||
setResult(pp.name() + ":tgt:max(weight)", tgtMaxWeight);
|
||||
setResult(pp.name() + ":tgt:ave(weight)", tgtAveWeight);
|
||||
setResult(pp.name() + ":tgt:min(address)", tgtMinNbr);
|
||||
setResult(pp.name() + ":tgt:max(address)", tgtMaxNbr);
|
||||
setResult(pp.name() + ":tgt:ave(address)", tgtAveNbr);
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::AMIWeights::writeWeightField
|
||||
(
|
||||
const cyclicAMIPolyPatch& cpp,
|
||||
const scalarField& weightSum,
|
||||
const word& side
|
||||
) const
|
||||
{
|
||||
// Collect geometry
|
||||
labelList pointToGlobal;
|
||||
labelList uniqueMeshPointLabels;
|
||||
autoPtr<globalIndex> globalPoints;
|
||||
autoPtr<globalIndex> globalFaces;
|
||||
faceList mergedFaces;
|
||||
pointField mergedPoints;
|
||||
Foam::PatchTools::gatherAndMerge
|
||||
(
|
||||
mesh_,
|
||||
cpp.localFaces(),
|
||||
cpp.meshPoints(),
|
||||
cpp.meshPointMap(),
|
||||
|
||||
pointToGlobal,
|
||||
uniqueMeshPointLabels,
|
||||
globalPoints,
|
||||
globalFaces,
|
||||
|
||||
mergedFaces,
|
||||
mergedPoints
|
||||
);
|
||||
|
||||
// Collect field
|
||||
scalarField mergedWeights;
|
||||
globalFaces().gather
|
||||
(
|
||||
UPstream::worldComm,
|
||||
ListOps::create<label>
|
||||
(
|
||||
UPstream::procID(UPstream::worldComm),
|
||||
labelOp<int>() // int -> label
|
||||
),
|
||||
weightSum,
|
||||
mergedWeights
|
||||
);
|
||||
|
||||
const bool isACMI = isA<cyclicACMIPolyPatch>(cpp);
|
||||
|
||||
scalarField mergedMask;
|
||||
if (isACMI)
|
||||
{
|
||||
const cyclicACMIPolyPatch& pp = refCast<const cyclicACMIPolyPatch>(cpp);
|
||||
|
||||
globalFaces().gather
|
||||
(
|
||||
UPstream::worldComm,
|
||||
ListOps::create<label>
|
||||
(
|
||||
UPstream::procID(UPstream::worldComm),
|
||||
labelOp<int>() // int -> label
|
||||
),
|
||||
pp.mask(),
|
||||
mergedMask
|
||||
);
|
||||
}
|
||||
|
||||
if (Pstream::master())
|
||||
{
|
||||
instant inst(mesh_.time().value(), mesh_.time().timeName());
|
||||
|
||||
vtk::surfaceWriter writer
|
||||
(
|
||||
mergedPoints,
|
||||
mergedFaces,
|
||||
(baseTimeDir()/cpp.name() + "_" + side),
|
||||
false // serial: master-only
|
||||
);
|
||||
|
||||
writer.setTime(inst);
|
||||
writer.writeTimeValue();
|
||||
writer.writeGeometry();
|
||||
|
||||
writer.beginCellData(1 + (isACMI ? 1 : 0));
|
||||
writer.write("weightsSum", mergedWeights);
|
||||
|
||||
if (isACMI)
|
||||
{
|
||||
writer.write("mask", mergedMask);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void Foam::functionObjects::AMIWeights::writeWeightFields
|
||||
(
|
||||
const cyclicAMIPolyPatch& cpp
|
||||
) const
|
||||
{
|
||||
if (cpp.owner())
|
||||
{
|
||||
writeWeightField(cpp, cpp.AMI().srcWeightsSum(), "src");
|
||||
writeWeightField(cpp.neighbPatch(), cpp.AMI().tgtWeightsSum(), "tgt");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
|
||||
|
||||
Foam::functionObjects::AMIWeights::AMIWeights
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
)
|
||||
:
|
||||
fvMeshFunctionObject(name, runTime, dict),
|
||||
writeFile(mesh_, name, typeName, dict),
|
||||
writeFields_(false),
|
||||
patchIDs_()
|
||||
{
|
||||
read(dict);
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
|
||||
|
||||
bool Foam::functionObjects::AMIWeights::read(const dictionary& dict)
|
||||
{
|
||||
if (fvMeshFunctionObject::read(dict) && writeFile::read(dict))
|
||||
{
|
||||
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
|
||||
|
||||
patchIDs_.clear();
|
||||
labelHashSet ids;
|
||||
forAll(pbm, patchi)
|
||||
{
|
||||
if (isA<cyclicAMIPolyPatch>(pbm[patchi]))
|
||||
{
|
||||
const auto& ami =
|
||||
static_cast<const cyclicAMIPolyPatch&>(pbm[patchi]);
|
||||
|
||||
if (ami.owner())
|
||||
{
|
||||
ids.insert(patchi);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
patchIDs_ = ids.sortedToc();
|
||||
|
||||
writeFileHeader(file());
|
||||
|
||||
writeFields_ = dict.get<bool>("writeFields");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::AMIWeights::execute()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool Foam::functionObjects::AMIWeights::write()
|
||||
{
|
||||
Log << type() << " " << name() << " write:" << nl;
|
||||
|
||||
const polyBoundaryMesh& pbm = mesh_.boundaryMesh();
|
||||
for (const label patchi : patchIDs_)
|
||||
{
|
||||
const polyPatch& pp = pbm[patchi];
|
||||
const auto& cpp = static_cast<const cyclicAMIPolyPatch&>(pp);
|
||||
|
||||
reportPatch(cpp);
|
||||
|
||||
if (writeFields_)
|
||||
{
|
||||
writeWeightFields(cpp);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
163
src/functionObjects/field/AMIWeights/AMIWeights.H
Normal file
163
src/functionObjects/field/AMIWeights/AMIWeights.H
Normal file
@ -0,0 +1,163 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Class
|
||||
Foam::functionObjects::AMIWeights
|
||||
|
||||
Group
|
||||
grpFieldFunctionObjects
|
||||
|
||||
Description
|
||||
|
||||
Usage
|
||||
Example of function object specification:
|
||||
\verbatim
|
||||
AMIWeights1
|
||||
{
|
||||
type AMIWeights;
|
||||
libs ("libfieldFunctionObjects.so");
|
||||
writeFields yes;
|
||||
}
|
||||
\endverbatim
|
||||
|
||||
Where the entries comprise:
|
||||
\table
|
||||
Property | Description | Required | Default value
|
||||
type | type name: AMIWeights | yes |
|
||||
writeFields | write weights as VTK fields | yes |
|
||||
\endtable
|
||||
|
||||
Output data is written to the file \<timeDir\>/AMIWeights.dat
|
||||
|
||||
See also
|
||||
Foam::functionObjects::fvMeshFunctionObject
|
||||
Foam::functionObjects::writeFile
|
||||
|
||||
SourceFiles
|
||||
AMIWeights.C
|
||||
AMIWeightsTemplates.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef functionObjects_AMIWeights_H
|
||||
#define functionObjects_AMIWeights_H
|
||||
|
||||
#include "fvMeshFunctionObject.H"
|
||||
#include "writeFile.H"
|
||||
#include "cyclicAMIPolyPatch.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
namespace functionObjects
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class AMIWeights Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class AMIWeights
|
||||
:
|
||||
public fvMeshFunctionObject,
|
||||
public writeFile
|
||||
{
|
||||
protected:
|
||||
|
||||
// Protected data
|
||||
|
||||
//- Flag to write AMI fields (as VTK files)
|
||||
bool writeFields_;
|
||||
|
||||
//- List of AMI patch IDs
|
||||
labelList patchIDs_;
|
||||
|
||||
|
||||
// Protected Member Functions
|
||||
|
||||
//- Output file header information
|
||||
virtual void writeFileHeader(Ostream& os);
|
||||
|
||||
//- Helper function to report patch information
|
||||
virtual void reportPatch(const cyclicAMIPolyPatch& pp);
|
||||
|
||||
void writeWeightField
|
||||
(
|
||||
const cyclicAMIPolyPatch& cpp,
|
||||
const scalarField& weightSum,
|
||||
const word& side
|
||||
) const;
|
||||
|
||||
void writeWeightFields(const cyclicAMIPolyPatch& cpp) const;
|
||||
|
||||
//- No copy construct
|
||||
AMIWeights(const AMIWeights&) = delete;
|
||||
|
||||
//- No copy assignment
|
||||
void operator=(const AMIWeights&) = delete;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
//- Runtime type information
|
||||
TypeName("AMIWeights");
|
||||
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from Time and dictionary
|
||||
AMIWeights
|
||||
(
|
||||
const word& name,
|
||||
const Time& runTime,
|
||||
const dictionary& dict
|
||||
);
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~AMIWeights() = default;
|
||||
|
||||
|
||||
// Member Functions
|
||||
|
||||
//- Read the field min/max data
|
||||
virtual bool read(const dictionary&);
|
||||
|
||||
//- Execute, currently does nothing
|
||||
virtual bool execute();
|
||||
|
||||
//- Write the AMIWeights
|
||||
virtual bool write();
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace functionObjects
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -1,3 +1,5 @@
|
||||
AMIWeights/AMIWeights.C
|
||||
|
||||
fieldAverage/fieldAverage.C
|
||||
fieldAverage/fieldAverageItem/fieldAverageItem.C
|
||||
fieldAverage/fieldAverageItem/fieldAverageItemIO.C
|
||||
|
||||
@ -49,7 +49,7 @@ Description
|
||||
{
|
||||
box
|
||||
{
|
||||
action add;
|
||||
action use;
|
||||
source box;
|
||||
box (-0.1 -0.01 -0.1) (0.1 0.30 0.1);
|
||||
}
|
||||
@ -110,7 +110,7 @@ Description
|
||||
|
||||
Note
|
||||
The region of interest is defined by the selection dictionary
|
||||
as a set of actions (add,subtract,subset,invert).
|
||||
as a set of actions (use,add,subtract,subset,invert).
|
||||
Omitting the selection dictionary is the same as specifying the
|
||||
conversion of all cells (in the selected regions).
|
||||
Omitting the patches entry is the same as specifying the conversion of all
|
||||
|
||||
@ -35,6 +35,7 @@ namespace Foam
|
||||
// A limited selection of actions
|
||||
const Enum<topoSetSource::setAction> actionNames
|
||||
({
|
||||
{ topoSetSource::NEW, "use" }, // Reuse NEW for "use" action name
|
||||
{ topoSetSource::ADD, "add" },
|
||||
{ topoSetSource::SUBTRACT, "subtract" },
|
||||
{ topoSetSource::SUBSET, "subset" },
|
||||
@ -92,8 +93,15 @@ bool Foam::functionObjects::ensightWrite::updateSubset
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case topoSetSource::NEW: // "use"
|
||||
case topoSetSource::ADD:
|
||||
case topoSetSource::SUBTRACT:
|
||||
if (topoSetSource::NEW == action)
|
||||
{
|
||||
// "use": only use this selection (clear + ADD)
|
||||
// NEW is handled like ADD in applyToSet()
|
||||
cellsToSelect.reset();
|
||||
}
|
||||
source->applyToSet(action, cellsToSelect);
|
||||
break;
|
||||
|
||||
@ -121,41 +129,6 @@ bool Foam::functionObjects::ensightWrite::updateSubset
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
Foam::labelList Foam::functionObjects::ensightWrite::getSelectedPatches
|
||||
(
|
||||
const polyBoundaryMesh& patches
|
||||
) const
|
||||
{
|
||||
DynamicList<label> patchIDs(patches.size());
|
||||
|
||||
for (const polyPatch& pp : patches)
|
||||
{
|
||||
if (isType<emptyPolyPatch>(pp))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (isType<processorPolyPatch>(pp))
|
||||
{
|
||||
break; // No processor patches
|
||||
}
|
||||
|
||||
if
|
||||
(
|
||||
selectPatches_.size()
|
||||
? selectPatches_.match(pp.name())
|
||||
: true
|
||||
)
|
||||
{
|
||||
patchIDs.append(pp.index());
|
||||
}
|
||||
}
|
||||
|
||||
return patchIDs.shrink();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
bool Foam::functionObjects::ensightWrite::update()
|
||||
{
|
||||
if (meshState_ == polyMesh::UNCHANGED)
|
||||
|
||||
@ -41,6 +41,8 @@ void Foam::functionObjects::residuals::writeFileHeader
|
||||
|
||||
if (foundObject<fieldType>(fieldName))
|
||||
{
|
||||
writeTabbed(os, fieldName + "_solver");
|
||||
|
||||
typename pTraits<Type>::labelType validComponents
|
||||
(
|
||||
mesh_.validComponents<Type>()
|
||||
@ -50,13 +52,16 @@ void Foam::functionObjects::residuals::writeFileHeader
|
||||
{
|
||||
if (component(validComponents, cmpt) != -1)
|
||||
{
|
||||
writeTabbed
|
||||
(
|
||||
os,
|
||||
fieldName + word(pTraits<Type>::componentNames[cmpt])
|
||||
);
|
||||
const word cmptName(pTraits<Type>::componentNames[cmpt]);
|
||||
const word fieldBase(fieldName + cmptName);
|
||||
|
||||
writeTabbed(os, fieldBase + "_initial");
|
||||
writeTabbed(os, fieldBase + "_final");
|
||||
writeTabbed(os, fieldBase + "_iters");
|
||||
}
|
||||
}
|
||||
|
||||
writeTabbed(os, fieldName + "_converged");
|
||||
}
|
||||
}
|
||||
|
||||
@ -81,8 +86,10 @@ void Foam::functionObjects::residuals::initialiseField(const word& fieldName)
|
||||
{
|
||||
if (component(validComponents, cmpt) != -1)
|
||||
{
|
||||
const word resultName =
|
||||
fieldName + word(pTraits<Type>::componentNames[cmpt]);
|
||||
const word resultName
|
||||
(
|
||||
fieldName + word(pTraits<Type>::componentNames[cmpt])
|
||||
);
|
||||
|
||||
createField(resultName);
|
||||
}
|
||||
@ -96,6 +103,7 @@ template<class Type>
|
||||
void Foam::functionObjects::residuals::writeResidual(const word& fieldName)
|
||||
{
|
||||
typedef GeometricField<Type, fvPatchField, volMesh> volFieldType;
|
||||
typedef typename pTraits<Type>::labelType labelType;
|
||||
|
||||
if (foundObject<volFieldType>(fieldName))
|
||||
{
|
||||
@ -108,28 +116,41 @@ void Foam::functionObjects::residuals::writeResidual(const word& fieldName)
|
||||
solverDict.lookup(fieldName)
|
||||
);
|
||||
|
||||
const Type& residual = sp.first().initialResidual();
|
||||
const SolverPerformance<Type>& sp0 = sp.first();
|
||||
const word& solverName = sp0.solverName();
|
||||
const Type& initialResidual = sp0.initialResidual();
|
||||
const Type& finalResidual = sp0.finalResidual();
|
||||
const labelType nIterations = sp0.nIterations();
|
||||
const bool converged = sp0.converged();
|
||||
|
||||
typename pTraits<Type>::labelType validComponents
|
||||
(
|
||||
mesh_.validComponents<Type>()
|
||||
);
|
||||
const labelType validComponents(mesh_.validComponents<Type>());
|
||||
|
||||
file() << token::TAB << solverName;
|
||||
|
||||
for (direction cmpt=0; cmpt<pTraits<Type>::nComponents; ++cmpt)
|
||||
{
|
||||
if (component(validComponents, cmpt) != -1)
|
||||
{
|
||||
const scalar r = component(residual, cmpt);
|
||||
const scalar ri = component(initialResidual, cmpt);
|
||||
const scalar rf = component(finalResidual, cmpt);
|
||||
const label n = component(nIterations, cmpt);
|
||||
|
||||
file() << token::TAB << r;
|
||||
file()
|
||||
<< token::TAB << ri
|
||||
<< token::TAB << rf
|
||||
<< token::TAB << n;
|
||||
|
||||
const word resultName =
|
||||
fieldName + word(pTraits<Type>::componentNames[cmpt]);
|
||||
setResult(resultName, r);
|
||||
const word cmptName(pTraits<Type>::componentNames[cmpt]);
|
||||
const word resultName(fieldName + cmptName);
|
||||
setResult(resultName + "_initial", ri);
|
||||
setResult(resultName + "_final", rf);
|
||||
setResult(resultName + "_iters", n);
|
||||
|
||||
writeField(resultName);
|
||||
}
|
||||
}
|
||||
|
||||
file() << token::TAB << converged;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -49,7 +49,7 @@ Description
|
||||
{
|
||||
box
|
||||
{
|
||||
action add;
|
||||
action use;
|
||||
source box;
|
||||
box (-0.1 -0.01 -0.1) (0.1 0.30 0.1);
|
||||
}
|
||||
@ -112,7 +112,7 @@ Description
|
||||
|
||||
Note
|
||||
The region of interest is defined by the selection dictionary
|
||||
as a set of actions (add,subtract,subset,invert).
|
||||
as a set of actions (use,add,subtract,subset,invert).
|
||||
Omitting the selection dictionary is the same as specifying the
|
||||
conversion of all cells (in the selected regions).
|
||||
Omitting the patches entry is the same as specifying the conversion of all
|
||||
|
||||
@ -34,6 +34,7 @@ namespace Foam
|
||||
// A limited selection of actions
|
||||
const Enum<topoSetSource::setAction> actionNames
|
||||
({
|
||||
{ topoSetSource::NEW, "use" }, // Reuse NEW for "use" action name
|
||||
{ topoSetSource::ADD, "add" },
|
||||
{ topoSetSource::SUBTRACT, "subtract" },
|
||||
{ topoSetSource::SUBSET, "subset" },
|
||||
@ -90,8 +91,15 @@ bool Foam::functionObjects::vtkWrite::updateSubset
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case topoSetSource::NEW: // "use"
|
||||
case topoSetSource::ADD:
|
||||
case topoSetSource::SUBTRACT:
|
||||
if (topoSetSource::NEW == action)
|
||||
{
|
||||
// "use": only use this selection (clear + ADD)
|
||||
// NEW is handled like ADD in applyToSet()
|
||||
cellsToSelect.reset();
|
||||
}
|
||||
source->applyToSet(action, cellsToSelect);
|
||||
break;
|
||||
|
||||
|
||||
@ -28,6 +28,7 @@ Description
|
||||
A topoSetCellSource to select cells belonging to a topological connected
|
||||
region (that contains given points)
|
||||
|
||||
Usage
|
||||
In dictionary input:
|
||||
\verbatim
|
||||
// optional name of cellSet delimiting search
|
||||
@ -41,7 +42,7 @@ Description
|
||||
insidePoints ((1 2 3));
|
||||
\endverbatim
|
||||
|
||||
\heading Dictionary parameters
|
||||
Dictionary parameters:
|
||||
\table
|
||||
Property | Description | Required | Default
|
||||
insidePoints | Points inside regions | yes |
|
||||
@ -68,7 +69,7 @@ namespace Foam
|
||||
class regionSplit;
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class regionToCell Declaration
|
||||
Class regionToCell Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class regionToCell
|
||||
@ -151,7 +152,6 @@ public:
|
||||
const topoSetSource::setAction action,
|
||||
topoSet& set
|
||||
) const;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
@ -82,7 +82,7 @@ public:
|
||||
enum setAction
|
||||
{
|
||||
ADD, //!< Add elements to the set
|
||||
SUBTRACT, //!< Remove elements from the set
|
||||
SUBTRACT, //!< Subtract elements from the set
|
||||
SUBSET, //!< Subset with elements in the set
|
||||
INVERT, //!< Invert the elements in the set
|
||||
CLEAR, //!< Clear the set, possibly creating it
|
||||
|
||||
@ -70,14 +70,14 @@ Description
|
||||
The \c rootdir normally corresponds to something like
|
||||
\c postProcessing/\<name\>
|
||||
|
||||
\subheading Geometry
|
||||
where the geometry is written as:
|
||||
\verbatim
|
||||
rootdir
|
||||
`-- surfaceName
|
||||
`-- "points"
|
||||
\endverbatim
|
||||
|
||||
\subheading Fields
|
||||
and field data:
|
||||
\verbatim
|
||||
rootdir
|
||||
`-- surfaceName
|
||||
|
||||
Reference in New Issue
Block a user