Commit 55e5a777 authored by shunbo's avatar shunbo
Browse files

initial commit

parents
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
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
checkDecomposePar
Group
grpParallelUtilities
Description
Check decomposition from kaffpa (KaHIP) output.
foamToMetisGraph was likely used for producing the kaffpa input.
\*---------------------------------------------------------------------------*/
#include "OSspecific.H"
#include "fvCFD.H"
#include "cpuTime.H"
#include "IFstream.H"
#include "regionProperties.H"
#include "decompositionInformation.H"
#include "decompositionModel.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
argList::addNote
(
"Check decomposition from kaffpa (KaHIP) output"
);
argList::noParallel();
argList::noBanner();
#include "addAllRegionOptions.H"
argList::addVerboseOption
(
"more information about decomposition"
);
argList::addArgument("kaffpa-output-file");
// Include explicit constant options, have zero from time range
timeSelector::addOptions(true, false);
#include "setRootCase.H"
const auto decompFile = args.get<fileName>(1);
// Set time from database
#include "createTime.H"
// Allow override of time
instantList times = timeSelector::selectIfPresent(runTime, args);
// Allow override of decomposeParDict location
const fileName decompDictFile =
args.getOrDefault<fileName>("decomposeParDict", "");
// Get region names
#include "getAllRegionOptions.H"
labelList cellToProc;
forAll(regionNames, regioni)
{
const word& regionName = regionNames[regioni];
// const word& regionDir =
// (
// regionName != polyMesh::defaultRegion
// ? regionName
// : word::null
// );
Info<< "\n\nDecomposing mesh " << regionName << nl << endl;
Info<< "Create mesh..." << flush;
fvMesh mesh
(
IOobject
(
regionName,
runTime.timeName(),
runTime,
IOobject::MUST_READ,
IOobject::NO_WRITE,
false
)
);
Info<< " nCells = " << mesh.nCells() << endl;
// Expected format is a simple ASCII list
cellToProc.setSize(mesh.nCells());
{
IFstream is(decompFile);
forAll(cellToProc, celli)
{
cellToProc[celli] = readLabel(is);
}
}
const label nDomains = max(cellToProc) + 1;
CompactListList<label> cellCells;
decompositionMethod::calcCellCells
(
mesh,
identity(mesh.nCells()),
mesh.nCells(),
false,
cellCells
);
decompositionInformation info
(
cellCells,
cellToProc,
nDomains
);
if (args.verbose())
{
info.printDetails(Info);
Info<< nl;
}
info.printSummary(Info);
}
Info<< "\nEnd\n" << endl;
return 0;
}
// ************************************************************************* //
Test-clock.C
EXE = $(FOAM_USER_APPBIN)/Test-clock
/* EXE_INC = -I$(LIB_SRC)/finiteVolume/lnInclude */
/* EXE_LIBS = -lfiniteVolume */
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
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 some clock-related routines
\*---------------------------------------------------------------------------*/
#include "OSspecific.H"
#include "clock.H"
#include "clockTime.H"
#include "clockValue.H"
#include "cpuTime.H"
using namespace Foam;
template<class ClockValue>
void testEpoch()
{
Info<< nl << "Test epoch" << nl;
const auto now = ClockValue::now();
Info<< "epoch = " << now.str() << " # day-hh:mm::ss" << nl
<< "epoch = " << now << nl;
}
template<class ClockValue>
void testElapsed()
{
Info<< nl << "Test elapsed" << nl;
ClockValue a;
Info<< "clockValue() " << a << nl;
a.update();
Info<< "updated " << a << nl;
Info<< "sleep 4..." << endl;
sleep(4);
a.update();
Info<< " = " << a.seconds() << nl;
Info<< "sleep 2..." << endl;
sleep(2);
Info<< "elapsed = " << a.elapsed() << nl
<< "elapsed = " << a.elapsed().seconds() << nl
<< "elapsed = " << a.elapsed().str() << nl;
const ClockValue b(true); // ClockValue::now()
Info<< "clockValue() " << b << nl;
Info<< "(" << b << " - " << a << ") = " << (b - a) << nl;
Info<< "(" << b << " + " << a << ") = " << (b + a) << nl;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
{
Foam::clock sysClock;
Info<< "clock: date " << clock::date() << nl
<< "clock: time " << clock::clockTime() << nl
<< "clock: iso " << clock::dateTime() << nl;
}
testEpoch<clockValue>();
testElapsed<clockValue>();
{
clockTime clk;
Info<< "starting clockTime" << nl;
Info<< "sleep 4..." << endl;
sleep(4);
Info<< "increment = " << clk.timeIncrement() << nl;
Info<< "elapsed = " << clk.elapsedTime() << nl;
Info<< "sleep 4..." << endl;
sleep(4);
Info<< "increment = " << clk.timeIncrement() << nl;
Info<< "elapsed = " << clk.elapsedTime() << nl;
Info<< "sleep 2..." << endl;
sleep(2);
Info<< "increment = " << clk.timeIncrement() << nl;
Info<< "elapsed = " << clk.elapsedTime() << nl;
}
Info<< "End\n" << endl;
return 0;
}
// ************************************************************************* //
Test-codeStream.C
EXE = $(FOAM_USER_APPBIN)/Test-codeStream
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
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-codeStream
Description
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "IOstreams.H"
#include "IOobject.H"
#include "IFstream.H"
#include "dictionary.H"
using namespace Foam;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
argList::noParallel();
argList::addArgument("dict .. dictN");
argList args(argc, argv, false, true);
Info<< nl
<< "FOAM_CASE=" << getEnv("FOAM_CASE") << nl
<< "FOAM_CASENAME=" << getEnv("FOAM_CASENAME") << nl
<< endl;
if (args.size() <= 1)
{
Info<<"specify dictionaries to test\n";
}
else
{
IOobject::writeDivider(Info);
for (label argi=1; argi < args.size(); ++argi)
{
const auto dictFile = args.get<fileName>(argi);
IFstream is(dictFile);
dictionary dict(is);
Info<< dict << endl;
for (const entry& e : dict)
{
if (e.isStream())
{
Info<< e.keyword() << " :: "
<< e.stream().toString() << nl;
}
}
}
}
return 0;
}
// ************************************************************************* //
/*--------------------------------*- C++ -*----------------------------------*\
| ========= | |
| \\ / F ield | OpenFOAM: The Open Source CFD Toolbox |
| \\ / O peration | Version: v2112 |
| \\ / A nd | Website: www.openfoam.com |
| \\/ M anipulation | |
\*---------------------------------------------------------------------------*/
FoamFile
{
version 2.0;
format ascii;
class dictionary;
object testDict;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// values from outer-scope
begIter 0;
endIter 200;
writeInterval #codeStream
{
// values from inner-scope
nDumps 5;
codeInclude
#{
#include "fvCFD.H"
#};
codeOptions
#{
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
#};
localCode
#{
static int someCode()
{
Info<<"called someCode\n";
return 10;
}
#};
code
#{
label interval = ($endIter - $begIter);
// label nDumps = $nDumps;
label nDumps = someCode();
os << (interval / nDumps);
#};
};
// play with cleanup
#remove begIter
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
Test-colourTables.C
EXE = $(FOAM_USER_APPBIN)/Test-colourTables
EXE_INC = \
-I$(LIB_SRC)/fileFormats/lnInclude
EXE_LIBS = \
-lfileFormats
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
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 "colourTable.H"
#include "IOstreams.H"
using namespace Foam;
void dumpTable(const colourTable& tbl, const label n=128)
{
Info<< tbl.table(n) << nl;
}
void dumpTable(const colourTable* tbl, const label n=128)
{
if (tbl)
{
Info<< tbl->table(n) << nl;
}
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main()
{
// dumpTable(colourTable::ptr(colourTable::RAINBOW));
dumpTable(colourTable::ptr(colourTable::COOL_WARM));
// forAllConstIters(colourTable::tables(), iter)
// {
// Info<< nl << iter.key() << nl;
// dumpTable(iter.val());
// }
Info<< "\nDone\n";
return 0;
}
// ************************************************************************* //
Test-complex.C
EXE = $(FOAM_USER_APPBIN)/Test-complex
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
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
Description
Tests for complex numbers
\*---------------------------------------------------------------------------*/
#include "argList.H"
#include "complex.H"
#include "complexFields.H"
#include "scalarField.H"
#include "ListOps.H"
#include "ops.H"
using namespace Foam;
// * * * * * * * * * * * * * * * Main Program * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
Info<< "complex() : " << complex() << nl
<< "complex(zero) : " << complex(Zero) << nl
<< "pTraits<complex>::zero : " << pTraits<complex>::zero << nl
<< "pTraits<complex>::one : " << pTraits<complex>::one << nl
<< "complex(scalar) : " << complex(3.14519) << nl
<< nl;
std::complex<scalar> c1(10, -3);
Info<< "std::complex : " << c1 << nl;
Info<< "sin: " << std::sin(c1) << nl;
Info<< "complexVector::zero : " << complexVector::zero << nl
<< "complexVector::one : " << complexVector::one << nl
<< nl;
for (complex c : { complex{1, 0}, complex{1, 2}} )
{
Info<< nl << "complex : " << c << nl;
Info<< "sin: " << sin(c) << nl
<< "pow(3.0f): " << pow(c, 3.0f) << nl
<< "pow(3): " << pow(c, 3) << nl
<< "pow3: " << pow3(c) << nl
<< "log: " << log(c) << nl
<< "pow025: " << pow025(c) << nl
;
// TDB: allow implicit construct from scalar?
//
// if (c == 1.0)
// {
// Info<< c << " == " << 1 << nl;
// }
}
// Test powers of zero
#if 1
{
const complex complex0{0, 0};
const std::complex<scalar> std0{0, 0};
const label label0{0};
const scalar scalar0{0};
Info<< nl
<< "# std::pow(0, 0)" << nl
<< " (label, label) = " << std::pow(label0, label0) << nl
<< " (scalar, scalar) = " << std::pow(scalar0, scalar0) << nl
<< " (label, scalar) = " << std::pow(label0, scalar0) << nl
<< " (scalar, label) = " << std::pow(scalar0, label0) << nl
<< " (std::complex, label) = " << std::pow(std0, label0) << nl
<< " (std::complex, scalar) = " << std::pow(std0, scalar0) << nl
<< " (label, std::complex) = " << std::pow(label0, std0) << nl
<< " (scalar, std::complex) = " << std::pow(scalar0, std0) << nl
;
Info<< nl
<< "# Foam::pow(0, 0)" << nl
<< " (label, label) = " << Foam::pow(label0, label0) << nl
<< " (scalar, scalar) = " << Foam::pow(scalar0, scalar0) << nl
<< " (label, scalar) = " << Foam::pow(label0, scalar0) << nl
<< " (scalar, label) = " << Foam::pow(scalar0, label0) << nl
<< " (complex, label) = " << Foam::pow(complex0, label0) << nl
<< " (complex, scalar) = " << Foam::pow(complex0, scalar0) << nl
<< " (label, complex) = " << Foam::pow(label0, complex0) << nl
<< " (scalar, complex) = " << Foam::pow(scalar0, complex0) << nl
;
}
#endif
// Test zip/unzip
{
scalarField reals(4);
scalarField imags(4);
forAll(reals, i)
{
reals[i] = i;
}
forAll(imags, i)
{
imags[i] = (i % 2) ? -i : i;
}
complexField cmplx(4);
zip(cmplx, reals, imags);
Info<< nl
<< "zip " << reals << nl
<< " " << imags << nl
<< " => " << cmplx << nl;
reverse(cmplx);
Info<< "reverse order: " << cmplx << nl;
unzip(cmplx, reals, imags);
Info<< "unzip " << cmplx << nl
<< " => " << reals << nl
<< " => " << imags << nl;
}
complexField fld1(3, complex(2.0, 1.0));
complexField fld2(fld1);
for (complex& c : fld2)
{
c = ~c;
}
Info<< nl
<< "Field " << flatOutput(fld1) << nl
<< "Conjugate: " << flatOutput(fld2) << nl;
// Some arbitrary change
for (complex& c : fld2)
{
c.Im() *= 5;
}
Info<< "sumProd: " << sumProd(fld1, fld2) << nl;
fld1 *= 10;
Info<< "scalar multiply: " << flatOutput(fld1) << nl;
fld1 /= 10;
Info<< "scalar divide: " << flatOutput(fld1) << nl;
Info<< "sin: " << sin(fld1) << nl;
Info<< "operator + : " << (fld1 + fld2) << nl;
Info<< "operator + : " << (fld1 + fld2 + complex(1,0)) << nl;
// Some operators are still incomplete
// Info<< "operator * : " << (fld1 * fld2) << nl;
// Info<< "operator / : " << (fld1 / fld2) << nl;
// Info<< "operator / : " << (fld1 / 2) << nl;
// Info<< "operator / : " << (fld1 / fld2) << nl;
// Info<< "sqrt : " << sqrt(fld1) << nl;
// Info<< "pow(2) : " << pow(fld1, 2) << nl;
#if 1
Info<< nl << "## Elementary complex-complex arithmetic operations:" << nl;
{
const complex a(6, 1);
complex b = a;
Info<< "# Compound assignment operations:" << nl;
Info<< "a = " << a << ", b = " << b << nl;
// Addition
b += a;
Info<< "b += a:" << tab << "b =" << b << nl;
// Subtraction
b -= a;
Info<< "b -= a:" << tab << "b =" << b << nl;
// Multiplication
b *= a;
Info<< "b *= a:" << tab << "b =" << b << nl;
// Division
b /= a;
Info<< "b /= a:" << tab << "b =" << b << nl;
}
#endif
#if 1
Info<< nl << "## Elementary complex-scalar arithmetic operations:" << nl;
{
const scalar a = 5;
complex b(6, 1);
Info<< "# Non-assignment operations:" << nl;
Info<< "(scalar) a = " << a << ", b = " << b << nl;
// Addition
b = a + b;
Info<< "b = a + b: " << tab << b << nl;
b = b + a;
Info<< "b = b + a: " << tab << b << nl;
// Subtraction
b = a - b;
Info<< "b = a - b: " << tab << b << nl;
b = b - a;
Info<< "b = b - a: " << tab << b << nl;
// Multiplication
b = a*b;
Info<< "b = a*b: " << tab << b << nl;
b = b*a;
Info<< "b = b*a: " << tab << b << nl;
// Division
b = a/b;
Info<< "b = a/b = scalar(a)/b = complex(a)/b:" << tab << b << nl;
b = b/a;
Info<< "b = b/a: " << tab << b << nl;
Info<< "# Compound assignment operations:" << nl;
Info<< "(scalar) a = " << a << ", b = " << b << nl;
// Addition: complex+scalar
b += a;
Info<< "b += a (only real part):" << tab << b << nl;
// Subtraction: complex-scalar
b -= a;
Info<< "b -= a (only real part):" << tab << b << nl;
// Multiplication: complex*scalar
b *= a;
Info<< "b *= a (real and imag parts):" << tab << b << nl;
// Division: complex/scalar
b /= a;
Info<< "b /= a (real and imag parts):" << tab << b << nl;
}
#endif
#if 1
Info<< nl << "## Other mathematical expressions:" << nl;
{
const complex a(4.3, -3.14);
const complex b(0, -4.3);
const complex c(-4.3, 0);
Info<< "a = " << a << ", b = " << b << ", c = " << c << nl;
// Square-root
Info<< "sqrt(a) = " << Foam::sqrt(a) << ", "
<< "sqrt(b) = " << Foam::sqrt(b) << ", "
<< "sqrt(c) = " << Foam::sqrt(c) << nl;
// Square
Info<< "sqr(a) = " << sqr(a) << ", "
<< "sqr(b) = " << sqr(b) << ", "
<< "sqr(c) = " << sqr(c) << nl;
// n^th power
Info<< "pow(a, -1) = " << pow(a, -1) << ", "
<< "pow(b, -1) = " << pow(b, -1) << ", "
<< "pow(c, -1) = " << pow(c, -1) << nl;
// Exponential
Info<< "exp(a) = " << exp(a) << ", "
<< "exp(b) = " << exp(b) << ", "
<< "exp(c) = " << exp(c) << nl;
// Natural logarithm
Info<< "log(a) = " << log(a) << ", "
<< "log(b) = " << log(b) << ", "
<< "log(c) = " << log(c) << nl;
}
#endif
// 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-constantFields.C
EXE = $(FOAM_USER_APPBIN)/Test-constantFields
EXE_INC = \
-I$(LIB_SRC)/finiteVolume/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude
EXE_LIBS = \
-lfiniteVolume \
-lmeshTools
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
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-constantields
Description
Simple compilation tests for constant fields
\*---------------------------------------------------------------------------*/
#include "fvCFD.H"
#include "geometricOneField.H"
#include "geometricZeroField.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
int main(int argc, char *argv[])
{
#include "setRootCase.H"
{
geometricZeroField fld0;
geometricOneField fld1;
Info<< "dims 0: " << fld0.dimensions() << nl;
Info<< "internal 0: " << scalar(fld0.internalField()[0]) << nl;
Info<< "boundary 0: " << scalar(fld0.boundaryField()[0][0]) << nl;
Info<< "dims 1: " << fld1.dimensions() << nl;
Info<< "internal 1: " << scalar(fld1.internalField()[0]) << nl;
Info<< "boundary 1: " << scalar(fld1.boundaryField()[0][0]) << nl;
}
Info<< "\nDone\n" << endl;
return 0;
}
// ************************************************************************* //
Test-contiguous.C
EXE = $(FOAM_USER_APPBIN)/Test-contiguous
EXE_INC = \
-I$(LIB_SRC)/fileFormats/lnInclude \
-I$(LIB_SRC)/surfMesh/lnInclude \
-I$(LIB_SRC)/meshTools/lnInclude \
-I$(LIB_SRC)/parallel/distributed/lnInclude
/* EXE_LIBS = */
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018-2019 OpenCFD Ltd.
-------------------------------------------------------------------------------
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-contiguous
Description
Simple test of contiguous data
\*---------------------------------------------------------------------------*/
#include "OSspecific.H"
#include "argList.H"
#include "wordRes.H"
#include "contiguous.H"
#include "IOstreams.H"
#include "scalar.H"
#include "vector.H"
#include "Switch.H"
#include "labelRange.H"
#include "scalarList.H"
#include "HashOps.H"
#include "FixedList.H"
#include "Pair.H"
#include "distributedTriSurfaceMesh.H"
namespace Foam
{
// Wrong, but interesting to test
template<> struct is_contiguous<Pair<word>> : std::true_type {};
} // end namespace Foam
using namespace Foam;
template<class T>
void printInfo(const char* const name = nullptr)
{
if (name == nullptr)
{
Info<< typeid(T).name();
}
else
{
Info<< name;
}
Info<< " contiguous=" << Switch(is_contiguous<T>::value);
if (is_contiguous_label<T>::value)
{
Info<< " label";
}
if (is_contiguous_scalar<T>::value)
{
Info<< " scalar";
}
Info<< nl;
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
// Main program:
int main(int argc, char *argv[])
{
argList::noBanner();
argList::noParallel();
argList::noFunctionObjects();
printInfo<label>();
printInfo<double>();
printInfo<FixedList<double, 4>>();
printInfo<Pair<long>>();
printInfo<FixedList<word, 2>>();
printInfo<Pair<word>>();
printInfo<FixedList<FixedList<int, 2>, 2>>();
printInfo<segment>();
return 0;
}
// ************************************************************************* //
Markdown is supported
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