This commit is contained in:
mattijs
2019-12-16 13:40:35 +00:00
12 changed files with 94 additions and 97 deletions

View File

@ -324,7 +324,7 @@ void verification_QRMatrix
// QRMatrix Constructors // QRMatrix Constructors
#if (0 | RUNALL) #if (0 | RUNALL)
{ {
QRMatrix<MatrixType> QRNull(); QRMatrix<MatrixType> QRNull;
} }
#endif #endif
@ -967,14 +967,14 @@ void verification_tsqr
typedef RectangularMatrix<Type> RMatrix; typedef RectangularMatrix<Type> RMatrix;
// Size of the full matrix and its partitions // Size of the full matrix and its partitions
const label nColsSum = rndGen.position(1, 100); const label nColsSum = rndGen.position<label>(1, 100);
const label qParts = rndGen.position(10, 30); const label qParts = rndGen.position<label>(10, 30);
List<label> mRowsList(qParts, Zero); List<label> mRowsList(qParts, Zero);
label mRowsSum = 0; label mRowsSum = 0;
for (label i = 0; i < qParts; ++i) for (label i = 0; i < qParts; ++i)
{ {
const label mRows = rndGen.position(nColsSum, 10*nColsSum); const label mRows = rndGen.position<label>(nColsSum, 10*nColsSum);
mRowsList[i] = mRows; mRowsList[i] = mRows;
mRowsSum += mRows; mRowsSum += mRows;
} }
@ -1084,7 +1084,7 @@ void verification_backSubstitution
{ {
Info<< nl << "# A*X = b:" << nl; Info<< nl << "# A*X = b:" << nl;
const RMatrix AX(A*X); const RMatrix AX(A*X);
equal(AX, b, verbose, 1e-3, 1e-3); equal(AX, b, verbose, 10, 1e-3, 1e-3);
} }
#endif #endif
} }
@ -1170,7 +1170,7 @@ int main(int argc, char *argv[])
for (label i = 0; i < numberOfTests; ++i) for (label i = 0; i < numberOfTests; ++i)
{ {
const label mRows = rndGen.position(1, 50); const label mRows = rndGen.position<label>(1, 50);
Info<< nl << nl << "# Random A with random mRows = " << mRows << nl; Info<< nl << nl << "# Random A with random mRows = " << mRows << nl;
SMatrix A(makeRandomMatrix<SMatrix>({mRows, mRows}, rndGen)); SMatrix A(makeRandomMatrix<SMatrix>({mRows, mRows}, rndGen));
@ -1199,8 +1199,8 @@ int main(int argc, char *argv[])
for (label i = 0; i < numberOfTests; ++i) for (label i = 0; i < numberOfTests; ++i)
{ {
const label mRows = rndGen.position(1, 50); const label mRows = rndGen.position<label>(1, 50);
const label nCols = rndGen.position(1, 50); const label nCols = rndGen.position<label>(1, 50);
Info<< nl << nl << "# Random matrix A with" Info<< nl << nl << "# Random matrix A with"
<< " random mRows = " << mRows << " random mRows = " << mRows
<< " random nCols = " << nCols << nl; << " random nCols = " << nCols << nl;
@ -1231,7 +1231,7 @@ int main(int argc, char *argv[])
for (label i = 0; i < numberOfTests; ++i) for (label i = 0; i < numberOfTests; ++i)
{ {
const label mRows = rndGen.position(1, 50); const label mRows = rndGen.position<label>(1, 50);
Info<< nl << nl << "# Random A with random mRows = " << mRows << nl; Info<< nl << nl << "# Random A with random mRows = " << mRows << nl;
SCMatrix A({mRows, mRows}, complex(0, 0)); SCMatrix A({mRows, mRows}, complex(0, 0));
@ -1258,7 +1258,7 @@ int main(int argc, char *argv[])
for (label i = 0; i < numberOfTests; ++i) for (label i = 0; i < numberOfTests; ++i)
{ {
const label mRows = rndGen.position(1, 50); const label mRows = rndGen.position<label>(1, 50);
Info<< nl << nl << "# Random A with random mRows = " << mRows << nl; Info<< nl << nl << "# Random A with random mRows = " << mRows << nl;
SCMatrix A(makeRandomMatrix<SCMatrix>({mRows, mRows}, rndGen)); SCMatrix A(makeRandomMatrix<SCMatrix>({mRows, mRows}, rndGen));
@ -1287,8 +1287,8 @@ int main(int argc, char *argv[])
for (label i = 0; i < numberOfTests; ++i) for (label i = 0; i < numberOfTests; ++i)
{ {
const label mRows = rndGen.position(1, 50); const label mRows = rndGen.position<label>(1, 50);
const label nCols = rndGen.position(1, 50); const label nCols = rndGen.position<label>(1, 50);
Info<< nl << nl << "# Random matrix A with" Info<< nl << nl << "# Random matrix A with"
<< " random mRows = " << mRows << " random mRows = " << mRows
<< " random nCols = " << nCols << nl; << " random nCols = " << nCols << nl;
@ -1363,8 +1363,8 @@ int main(int argc, char *argv[])
for (label i = 0; i < numberOfTests; ++i) for (label i = 0; i < numberOfTests; ++i)
{ {
const label mRows = rndGen.position(20, 50); const label mRows = rndGen.position<label>(20, 50);
const label pCols = rndGen.position(20, 50); const label pCols = rndGen.position<label>(20, 50);
Info<< nl << nl << "# Random square matrix A with" Info<< nl << nl << "# Random square matrix A with"
<< " random mRows = " << mRows << " random mRows = " << mRows
<< " random nCols = " << mRows << nl; << " random nCols = " << mRows << nl;
@ -1422,8 +1422,8 @@ int main(int argc, char *argv[])
for (label i = 0; i < numberOfTests; ++i) for (label i = 0; i < numberOfTests; ++i)
{ {
const label mRows = rndGen.position(20, 50); const label mRows = rndGen.position<label>(20, 50);
const label pCols = rndGen.position(20, 50); const label pCols = rndGen.position<label>(20, 50);
Info<< nl << nl << "# Random square matrix A with" Info<< nl << nl << "# Random square matrix A with"
<< " random mRows = " << mRows << " random mRows = " << mRows
<< " random nCols = " << mRows << nl; << " random nCols = " << mRows << nl;

View File

@ -39,11 +39,12 @@
# - local site-specific directory, uses WM_PROJECT_DIR/site if unset # - local site-specific directory, uses WM_PROJECT_DIR/site if unset
# #
# Note # Note
# Changes made to this bashrc file may be lost with the next upgrade. # Changes made to this file will be lost with the next upgrade.
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
export WM_PROJECT=OpenFOAM # [WM_PROJECT_VERSION] - A human-readable version name
# A development version is often named 'com' - as in www.openfoam.com
export WM_PROJECT_VERSION=com export WM_PROJECT_VERSION=com
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
@ -67,7 +68,7 @@ export WM_PRECISION_OPTION=DP
# = 32 | 64 # = 32 | 64
export WM_LABEL_SIZE=32 export WM_LABEL_SIZE=32
# [WM_COMPILE_OPTION] - Optimised, debug, profiling, other: # [WM_COMPILE_OPTION] - Optimised(default), debug, profiling, other:
# = Opt | Debug | Prof # = Opt | Debug | Prof
# Other is processor or packaging specific (eg, OptKNL) # Other is processor or packaging specific (eg, OptKNL)
export WM_COMPILE_OPTION=Opt export WM_COMPILE_OPTION=Opt
@ -82,6 +83,9 @@ export WM_MPLIB=SYSTEMOPENMPI
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# (advanced / legacy) # (advanced / legacy)
# [WM_PROJECT] - This project is "OpenFOAM" - do not change
export WM_PROJECT=OpenFOAM
# [projectDir] - directory containing this OpenFOAM version. # [projectDir] - directory containing this OpenFOAM version.
# \- When this file is located as $WM_PROJECT_DIR/etc/bashrc, the next lines # \- When this file is located as $WM_PROJECT_DIR/etc/bashrc, the next lines
# should work when sourced by BASH or ZSH shells. If this however fails, # should work when sourced by BASH or ZSH shells. If this however fails,

View File

@ -39,11 +39,12 @@
# - local site-specific directory, uses WM_PROJECT_DIR/site if unset # - local site-specific directory, uses WM_PROJECT_DIR/site if unset
# #
# Note # Note
# Changes made to this cshrc file may be lost with the next upgrade. # Changes made to this file will be lost with the next upgrade.
# #
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
setenv WM_PROJECT OpenFOAM # [WM_PROJECT_VERSION] - A human-readable version name
# A development version is often named 'com' - as in www.openfoam.com
setenv WM_PROJECT_VERSION com setenv WM_PROJECT_VERSION com
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
@ -67,7 +68,7 @@ setenv WM_PRECISION_OPTION DP
# = 32 | 64 # = 32 | 64
setenv WM_LABEL_SIZE 32 setenv WM_LABEL_SIZE 32
# [WM_COMPILE_OPTION] - Optimised, debug, profiling, other: # [WM_COMPILE_OPTION] - Optimised(default), debug, profiling, other:
# = Opt | Debug | Prof # = Opt | Debug | Prof
# Other is processor or packaging specific (eg, OptKNL) # Other is processor or packaging specific (eg, OptKNL)
setenv WM_COMPILE_OPTION Opt setenv WM_COMPILE_OPTION Opt
@ -82,6 +83,9 @@ setenv WM_MPLIB SYSTEMOPENMPI
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
# (advanced / legacy) # (advanced / legacy)
# [WM_PROJECT] - This project is "OpenFOAM" - do not change
setenv WM_PROJECT OpenFOAM
# [projectDir] - directory containing this OpenFOAM version. # [projectDir] - directory containing this OpenFOAM version.
# \- When this file is located as $WM_PROJECT_DIR/etc/cshrc, the next lines # \- When this file is located as $WM_PROJECT_DIR/etc/cshrc, the next lines
# should work when sourced by CSH or TCSH shells. If this however fails, # should work when sourced by CSH or TCSH shells. If this however fails,

View File

@ -35,7 +35,7 @@ bool Foam::MatrixTools::equal
const Matrix<Form1, Type>& A, const Matrix<Form1, Type>& A,
const Matrix<Form2, Type>& B, const Matrix<Form2, Type>& B,
const bool verbose, const bool verbose,
const label lenDiffs, const label maxDiffs,
const scalar relTol, const scalar relTol,
const scalar absTol const scalar absTol
) )
@ -55,24 +55,24 @@ bool Foam::MatrixTools::equal
auto iter1 = A.cbegin(); auto iter1 = A.cbegin();
auto iter2 = B.cbegin(); auto iter2 = B.cbegin();
label j = 0; label nDiffs = 0;
for (label i = 0; i < len; ++i) for (label i = 0; i < len; ++i)
{ {
if ((absTol + relTol*mag(*iter2)) < Foam::mag(*iter1 - *iter2)) if ((absTol + relTol*mag(*iter2)) < Foam::mag(*iter1 - *iter2))
{ {
++nDiffs;
if (verbose) if (verbose)
{ {
Info<< "Matrix element " << i Info<< "Matrix element " << i
<< " differs beyond tolerance: " << " differs beyond tolerance: "
<< *iter1 << " vs " << *iter2 << nl; << *iter1 << " vs " << *iter2 << nl;
++j;
} }
if (lenDiffs < j) if (maxDiffs && maxDiffs < nDiffs)
{ {
Info<< "Number of different elements exceeds = " << lenDiffs Info<< "More than " << maxDiffs << " elements differ."
<< " Ceasing comparisons for the remaining of elements." << " Skipping further comparisons." << nl;
<< nl;
return false; return false;
} }
} }
@ -83,10 +83,17 @@ bool Foam::MatrixTools::equal
if (verbose) if (verbose)
{ {
Info<< "All elements equal within the tolerances" << nl; if (nDiffs)
{
Info<< "Some elements differed" << nl;
}
else
{
Info<< "All elements equal within the tolerances" << nl;
}
} }
return true; return !nDiffs;
} }

View File

@ -27,7 +27,7 @@ Namespace
Foam::MatrixTools Foam::MatrixTools
Description Description
Collection of static functions for matrix-related verifications. Collection of functions for matrix-related verifications.
SourceFiles SourceFiles
MatrixTools.C MatrixTools.C
@ -47,7 +47,6 @@ namespace Foam
// Forward declarations // Forward declarations
class Ostream; class Ostream;
/*---------------------------------------------------------------------------*\ /*---------------------------------------------------------------------------*\
Namespace MatrixTools Declaration Namespace MatrixTools Declaration
\*---------------------------------------------------------------------------*/ \*---------------------------------------------------------------------------*/
@ -56,13 +55,14 @@ namespace MatrixTools
{ {
//- Compare matrix elements for absolute or relative equality //- Compare matrix elements for absolute or relative equality
//
template<class Form1, class Form2, class Type> template<class Form1, class Form2, class Type>
bool equal bool equal
( (
const Matrix<Form1, Type>& A, const Matrix<Form1, Type>& A,
const Matrix<Form2, Type>& B, const Matrix<Form2, Type>& B,
const bool verbose = false, const bool verbose = false,
const label lenDiffs = 10, const label maxDiffs = 10, //!< Stop reporting after maxDiffs (0 to disable)
const scalar relTol = 1e-5, const scalar relTol = 1e-5,
const scalar absTol = 1e-8 const scalar absTol = 1e-8
); );

View File

@ -81,39 +81,6 @@ addNamedToRunTimeSelectionTable
} // End namespace Foam } // End namespace Foam
// * * * * * * * * * * * * * * * Local Functions * * * * * * * * * * * * * * //
namespace Foam
{
static label getPatchID(const fvMesh& mesh, const word& patchName)
{
const auto& bMesh = mesh.boundaryMesh();
const label patchId = bMesh.findPatchID(patchName);
if (patchId < 0)
{
FatalErrorInFunction
<< "No patch " << patchName << " found in "
<< flatOutput(bMesh.names()) << nl
<< exit(FatalError);
}
return patchId;
}
static inline const polyPatch& findPolyPatch
(
const fvMesh& mesh,
const word& patchName
)
{
return mesh.boundaryMesh()[getPatchID(mesh, patchName)];
}
} // End namespace Foam
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * // // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::expressions::volumeExpr::parseDriver::parseDriver Foam::expressions::volumeExpr::parseDriver::parseDriver

View File

@ -77,10 +77,10 @@ class parProfiling
{ {
// Private Member Functions // Private Member Functions
//- Disallow default bitwise copy construct //- No copy construct
parProfiling(const parProfiling&) = delete; parProfiling(const parProfiling&) = delete;
//- Disallow default bitwise assignment //- No copy assignment
void operator=(const parProfiling&) = delete; void operator=(const parProfiling&) = delete;

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com \\ / A nd | www.openfoam.com
\\/ M anipulation | \\/ M anipulation |
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
Copyright (C) 2018 OpenCFD Ltd. Copyright (C) 2018-2019 OpenCFD Ltd.
------------------------------------------------------------------------------- -------------------------------------------------------------------------------
License License
This file is part of OpenFOAM. This file is part of OpenFOAM.
@ -72,11 +72,11 @@ class exact
const distributedTriSurfaceMesh& patchSurface() const; const distributedTriSurfaceMesh& patchSurface() const;
//- Disallow default bitwise copy construct //- No copy construct
exact(const exact&); exact(const exact&) = delete;
//- Disallow default bitwise assignment //- No copy assignment
void operator=(const exact&); void operator=(const exact&) = delete;
public: public:

View File

@ -14,11 +14,16 @@ GLIBS = -lm
GLIB_LIBS = GLIB_LIBS =
COMPILER_TYPE = $(shell echo "$(WM_COMPILER)" | sed -e 's/[0-9].*//') COMPILER_FAMILY = $(shell echo "$(WM_COMPILER)" | sed -e 's/[0-9].*//')
DEFAULT_RULES = $(WM_DIR)/rules/$(WM_ARCH)$(COMPILER_TYPE) DEFAULT_RULES = $(WM_DIR)/rules/$(WM_ARCH)$(COMPILER_FAMILY)
RULES = $(WM_DIR)/rules/$(WM_ARCH)$(WM_COMPILER) RULES = $(WM_DIR)/rules/$(WM_ARCH)$(WM_COMPILER)
WMAKE_BIN = $(WM_DIR)/platforms/$(WM_ARCH)$(WM_COMPILER) WMAKE_BIN = $(WM_DIR)/platforms/$(WM_ARCH)$(WM_COMPILER)
# Default compilation is 'Opt' - never permit an empty value
ifeq ($(WM_COMPILE_OPTION),)
WM_COMPILE_OPTION = Opt
endif
ifeq ($(WM_SCHEDULER),) ifeq ($(WM_SCHEDULER),)
AND = && AND = &&
else else
@ -26,7 +31,6 @@ else
endif endif
include $(DEFAULT_RULES)/general include $(DEFAULT_RULES)/general
include $(DEFAULT_RULES)/c++
sinclude $(RULES)/general sinclude $(RULES)/general
sinclude $(RULES)/c++ sinclude $(RULES)/c++
include $(GENERAL_RULES)/transform include $(GENERAL_RULES)/transform

View File

@ -63,10 +63,13 @@ archTarget := $(shell basename $(WMAKE_BIN))
# Targets # Targets
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------
.PHONY: all clean message .PHONY: all clean message old
all: $(WMAKE_BIN)/lemon$(EXT_EXE) $(WMAKE_BIN)/wmkdepend$(EXT_EXE) message all: $(WMAKE_BIN)/lemon$(EXT_EXE) $(WMAKE_BIN)/wmkdepend$(EXT_EXE) message
# Flex-based processing
old: $(WMAKE_BIN)/wmkdep$(EXT_EXE)
message: message:
ifneq ($(archHost),$(archTarget)) ifneq ($(archHost),$(archTarget))
@echo "built wmake-bin ($(archTarget)) for $(archHost) host" @echo "built wmake-bin ($(archTarget)) for $(archHost) host"
@ -76,7 +79,7 @@ endif
clean: clean:
@echo "clean wmake-bin ($(archTarget))" @echo "clean wmake-bin ($(archTarget))"
@rm -rf $(WMAKE_BIN) 2>/dev/null @rm -rf $(WMAKE_BIN)
@rmdir $(shell dirname $(WMAKE_BIN)) 2>/dev/null || true @rmdir $(shell dirname $(WMAKE_BIN)) 2>/dev/null || true
$(WMAKE_BIN)/lemon$(EXT_EXE): lemon.c $(WMAKE_BIN)/lemon$(EXT_EXE): lemon.c
@ -88,17 +91,17 @@ $(WMAKE_BIN)/wmkdep$(EXT_EXE): wmkdep.l
@mkdir -p $(WMAKE_BIN) @mkdir -p $(WMAKE_BIN)
$(call QUIET_MESSAGE,flex,$(<F)) $(call QUIET_MESSAGE,flex,$(<F))
$E flex -o $@.c $(<F) && $(cc) $(cFLAGS) $@.c -o $@ $E flex -o $@.c $(<F) && $(cc) $(cFLAGS) $@.c -o $@
@rm -f $@.c 2>/dev/null @rm -f $@.c
$(WMAKE_BIN)/wmkdepend$(EXT_EXE): wmkdepend.cc $(WMAKE_BIN)/wmkdepend$(EXT_EXE): wmkdepend.cc
@mkdir -p $(WMAKE_BIN) @mkdir -p $(WMAKE_BIN)
$(call QUIET_MESSAGE,wmkdepend,$(<F)) $(call QUIET_MESSAGE,wmkdepend,$(<F))
$E $(CC) $(c++FLAGS) $(c++LESSWARN) $(<F) -o $@ $E $(CC) $(c++FLAGS) $(<F) -o $@
# $(WMAKE_BIN)/wmkdepend$(EXT_EXE): wmkdepend.rl #$(WMAKE_BIN)/wmkdepend$(EXT_EXE): wmkdepend.rl
# @mkdir -p $(WMAKE_BIN) # @mkdir -p $(WMAKE_BIN)
# $(call QUIET_MESSAGE,ragel,$(<F)) # $(call QUIET_MESSAGE,ragel,$(<F))
# $E ragel -G2 -o $@.cc $(<F) && $(CC) $(c++FLAGS) $(c++LESSWARN) $@.cc -o $@ # $E ragel -G2 -o $@.cc $(<F) && $(CC) $(c++FLAGS) $@.cc -o $@
# @rm -f $@.cc 2>/dev/null # @rm -f $@.cc
#------------------------------------------------------------------------------ #------------------------------------------------------------------------------

View File

@ -46,7 +46,6 @@ usage() {
Usage: $Script [OPTION] [dir] Usage: $Script [OPTION] [dir]
$Script [OPTION] target [dir [MakeDir]] $Script [OPTION] target [dir [MakeDir]]
options: options:
-a | -all Same as the 'all' target -a | -all Same as the 'all' target
-s | -silent Ignored - for compatibility with wmake -s | -silent Ignored - for compatibility with wmake

View File

@ -59,15 +59,12 @@
Script="${0##*/}" # Use 'Script' for error messages in wmakeFunctions Script="${0##*/}" # Use 'Script' for error messages in wmakeFunctions
. "${0%/*}/scripts/wmakeFunctions" # Source wmake functions . "${0%/*}/scripts/wmakeFunctions" # Source wmake functions
unset optHelpFull # Print help to stdout so that it can be captured
usage() { printHelp() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<HELP_HEAD cat<<HELP_HEAD
Usage: $Script [OPTION] [dir] Usage: $Script [OPTION] [dir]
$Script [OPTION] target [dir [MakeDir]] $Script [OPTION] target [dir [MakeDir]]
options: options:
-s | -silent Quiet mode (does not echo commands) -s | -silent Quiet mode (does not echo commands)
-a | -all wmake all sub-directories, running Allwmake if present -a | -all wmake all sub-directories, running Allwmake if present
@ -77,7 +74,7 @@ options:
-update Update lnInclude dirs, dep files, remove deprecated files/dirs -update Update lnInclude dirs, dep files, remove deprecated files/dirs
HELP_HEAD HELP_HEAD
if [ "$optHelpFull" = true ] if [ -n "$1" ]
then then
cat<<HELP_FULL cat<<HELP_FULL
-debug Define c++DBUG='-DFULLDEBUG -g -O0' as override -debug Define c++DBUG='-DFULLDEBUG -g -O0' as override
@ -123,6 +120,19 @@ HELP_TAIL
exit 1 exit 1
} }
# Report error and exit
die()
{
exec 1>&2
echo
echo "Error encountered:"
while [ "$#" -ge 1 ]; do echo " $1"; shift; done
echo
echo "See '${0##*/} -help' for usage"
echo
exit 1
}
# Default make is the "make" in the path # Default make is the "make" in the path
make="make" make="make"
@ -149,11 +159,10 @@ while [ "$#" -gt 0 ]
do do
case "$1" in case "$1" in
-help-f*) # Full help -help-f*) # Full help
optHelpFull=true printHelp -full
usage
;; ;;
-h | -help*) # Short help -h | -help*) # Short help
usage printHelp
;; ;;
-s | -silent) -s | -silent)
export WM_QUIET=true export WM_QUIET=true
@ -224,7 +233,7 @@ do
break break
;; ;;
-*) -*)
usage "unknown option: '$1'" die "unknown option: '$1'"
;; ;;
*) *)
break break