Commit 312c97b4 authored by sergio's avatar sergio Committed by Andrew Heather
Browse files

Merge branch 'develop' of develop.openfoam.com:Development/OpenFOAM-plus into develop

parents a57574a8 63a18262
#include "stream.h"
#include <unistd.h>
#include <stdlib.h>
#include <cstdlib>
main()
{
......
#include <stdlib.h>
#include <cstdlib>
class Int
{
......
......@@ -30,6 +30,8 @@ Description
#include "argList.H"
#include "complexFields.H"
#include "ops.H"
#include "ListOps.H"
using namespace Foam;
......@@ -97,9 +99,6 @@ int main(int argc, char *argv[])
}
Info<< "sum = " << sum(fld1) << nl;
// Not yet Info<< "min = " << min(fld1) << nl;
fld1 *= 10;
Info<< "scalar multiply: " << flatOutput(fld1) << nl;
......@@ -120,6 +119,36 @@ int main(int argc, char *argv[])
// Info<< "pow(2) : " << pow(fld1, 2) << nl;
// Make some changes
{
label i = 1;
for (complex& c : fld1)
{
c.Re() += i;
c.Im() -= 10 - i;
++i;
}
}
Info<< nl
<< "field = " << fld1 << nl;
Info<< "magSqr = "
<< ListOps::create<scalar>
(
fld1,
[](const complex& c) { return magSqr(c); }
)
<< nl;
Info
<< "sum = " << sum(fld1) << nl
<< "min = " << min(fld1) << nl
<< "max = " << max(fld1) << nl;
// MinMax fails since there is no less comparison operator
// Info<< "min/max = " << MinMax<complex>(fld1) << nl;
Info<< "\nEnd\n" << endl;
return 0;
}
......
Test-fileNameOS.C
EXE = $(FOAM_USER_APPBIN)/Test-fileNameOS
/* EXE_INC = */
/* EXE_LIBS = */
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2019 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/>.
Application
Test-fileNameOS
Description
Test fileName behaviour, potential OS capabilities etc.
In the distant future could possibly replace parts with C++ filesystem
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "fileName.H"
#include "OSspecific.H"
#include "Switch.H"
#include <csignal>
#include <cstdlib>
#include <iostream>
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
void testDirname(const std::string& rawInput)
{
fileName input(fileName::validate(rawInput));
Info<< nl
<< "input: " << rawInput << nl
<< "fileName:" << input << nl
<< " path:" << input.path()
<< " name:\"" << input.name() << '"'
<< " ext:\"" << input.ext() << '"'
<< " components: " << flatOutput(input.components()) << nl;
if (rawInput.size() != input.size())
{
Info<< " This would be Fatal with debug > 1" << nl;
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
argList::noParallel();
argList::addBoolOption("no-space", "allowSpaceInFileName = false");
argList::addBoolOption("with-space", "set allowSpaceInFileName = true");
#include "setRootCase.H"
if (args.found("with-space"))
{
fileName::allowSpaceInFileName = true;
}
if (args.found("no-space"))
{
fileName::allowSpaceInFileName = false;
}
Info<<"fileName with spaces? : "
<< Switch(bool(fileName::allowSpaceInFileName)) << nl << nl;
{
testDirname("/abc");
testDirname("/abc/with space/name");
testDirname("/abc/with space/more space");
}
Info<< "\nEnd\n" << endl;
return 0;
}
// ************************************************************************* //
#include <iostream>
#include <stdlib.h>
#include <cstdlib>
using namespace std;
int main(int argc, char *argv[])
......
......@@ -32,6 +32,7 @@ Description
#include "HashOps.H"
#include "ListOps.H"
#include "scalarField.H"
#include "complexField.H"
#include "MinMax.H"
#include "dimensionedScalar.H"
......@@ -47,6 +48,19 @@ Ostream& printInfo(const MinMax<T>& range)
}
template<class T>
void testUniformField(const T& val)
{
constexpr label N = 10;
// Field<T> fld(N, val);
List<T> fld(N, val);
Info<< "field: " << fld << nl
<< "min/max: " << minMaxMag(fld) << nl;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
......@@ -225,6 +239,15 @@ int main(int argc, char *argv[])
Info<< "filtered: " << hashed << nl;
}
// Min/max of uniform fields
{
testUniformField<scalar>(100);
// testUniformField<complex>(complex(100, 0));
}
Info<< "\nEnd\n" << nl;
return 0;
}
......
Test-readDir.C
EXE = $(FOAM_USER_APPBIN)/Test-readDir
/* EXE_INC = -I$(LIB_SRC)/finiteVolume/lnInclude */
/* EXE_LIBS = -lfiniteVolume */
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2019 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/>.
Description
Test functionality of Foam::readDir
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "OSspecific.H"
#include "fileNameList.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
argList::noBanner();
argList::noParallel();
argList::addBoolOption("dir", "list directories instead of files");
#include "setRootCase.H"
fileName::Type listType = fileName::FILE;
if (args.found("dir"))
{
Info<< "Listing directories" << nl;
listType = fileName::DIRECTORY;
}
else
{
Info<< "Listing files" << nl;
}
{
Info<< nl;
for (const word& item : readDir(".", listType))
{
Info<< " " << item << nl;
}
}
Info<< "\nEnd\n" << endl;
return 0;
}
// ************************************************************************* //
......@@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2018 OpenCFD Ltd.
\\ / A nd | Copyright (C) 2018-2019 OpenCFD Ltd.
\\/ M anipulation |
-------------------------------------------------------------------------------
License
......@@ -31,6 +31,7 @@ Description
#include "vector.H"
#include "IOstreams.H"
#include <algorithm>
using namespace Foam;
......@@ -74,6 +75,18 @@ void doTest(vector& vec1, vector& vec2)
}
template<class VecSpace>
void testIterator(const VecSpace& vs)
{
Info<< "size: " << vs.size() << " for:";
for (const auto& val : vs)
{
Info<< " " << val;
}
Info<< nl;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
......@@ -89,8 +102,21 @@ int main(int argc, char *argv[])
vector vec2(0.5, 0.51, -0.5);
doTest(vec1, vec2);
testIterator(vec1);
testIterator(vec2);
// Use STL algorithm(s)
std::sort(vec2.begin(), vec2.end());
Info<< "sorted: " << vec2 << nl;
std::random_shuffle(vec2.begin(), vec2.end());
Info<< "shuffled: " << vec2 << nl;
}
Info<< "\nEnd\n" << nl;
return 0;
}
......
Test-wmake1.C
/* #if OPENFOAM == 1812 */
#if OPENFOAM > 1812
newStub.C
#else
oldStub.C
#endif
EXE = $(FOAM_APPBIN)/Test-wmake1
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2019 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/>.
Application
Test-wmake1
Description
Some tests for wmake features.
For example, testing how robust or fragile version-dependent conditional
compilation works.
\*---------------------------------------------------------------------------*/
#include "argList.H"
namespace Foam
{
void printTest();
}
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
printTest();
Info<< "\nEnd\n" << nl;
return 0;
}
// ************************************************************************* //
// Some test code
#include "foamVersion.H"
#include "IOstreams.H"
namespace Foam
{
void printTest()
{
Info<< nl;
foamVersion::printBuildInfo();
}
}
// Some test code
#include "IOstreams.H"
namespace Foam
{
void printTest()
{
Info<< nl << "Using old stub" << nl;
#if OPENFOAM
Info<< "OPENFOAM=" << OPENFOAM << nl;
#else
Info<< "OPENFOAM is undefined" << nl;
#endif
}
}
......@@ -121,14 +121,14 @@ void usage()
std::cout
<< "usage: addr2line [-e filename|--exe=filename]"
" address [address...]\n" << std::endl;
::exit(1);
std::exit(1);
}
void version()
{
std::cout<< "OpenFOAM addr2line emulator\n" << std::endl;
::exit(0);
std::exit(0);
}
......
......@@ -64,6 +64,9 @@ InfoSwitches
// Allow case-supplied C++ code (#codeStream, codedFixedValue)
allowSystemOperations 1;
// Allow space character in fileName (use with caution)
allowSpaceInFileName 0;
}
......
clockTime/clockTime.C
clockValue/clockValue.C
cpuInfo/cpuInfo.C
cpuTime/cpuTime.C
memInfo/memInfo.C
signals/sigFpe.C
signals/sigSegv.C
signals/sigInt.C
signals/sigQuit.C
signals/sigStopAtWriteNow.C
signals/sigWriteNow.C
signals/timer.C
regExpPosix.C
timer.C
fileStat.C
POSIX.C
cpuTime/cpuTime.C
clockTime/clockTime.C
clockValue/clockValue.C
cpuInfo/cpuInfo.C
memInfo/memInfo.C
/*
* Note: fileMonitor assumes inotify by default. Compile with -DFOAM_USE_STAT
......
Supports Markdown
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