Compare commits

...

70 Commits

Author SHA1 Message Date
f65a95a68e COMP: g++11: suppress optimisation. See #3024 2024-01-19 21:17:08 +01:00
344237b289 BUG: mapFields: incorrect patches. Fixes #2944. 2023-08-31 09:43:29 +02:00
b1d6297976 BUG: UPstream::shutdown misbehaves with external initialisation (fixes #2808)
- freeCommmunicatorComponents needs an additional bounds check.
  When MPI is initialized outside of OpenFOAM, there are no
  UPstream communicator equivalents
2023-06-20 09:42:12 +02:00
008d015689 Revert "BUG: Fixing ray dAve and omega for 1D and 2D cases"
This reverts commit 5848b0afd5.
2023-06-20 09:41:12 +02:00
0fcd1446c5 BUG: VTK write pointSet fails in parallel (fixes #2773)
- de-referenced autoPtr with () instead of ref() will fail on
  non-master ranks.
2023-05-05 15:58:16 +02:00
70451e680c COMP: code adjustments for gcc-13 (#2714) 2023-02-28 16:31:01 +01:00
5768a7e9c8 CONFIG: accept module-prefix 'none' as equivalent to 'false' (ie, disabled) 2023-02-28 16:31:01 +01:00
56de3901e2 BACKPORT: align wmake have_* scripts with v2006
- simplify maintenance
2023-02-28 16:31:01 +01:00
36453aa9af BACKPORT: adjust wmake/scripts/*Functions according to v2006
- simplifies maintenance of detection scripts
2023-02-28 16:31:01 +01:00
dd06e6448c BUG: solitaryWaveModel: avoid reference access to an operand object (Fixes #2178) 2022-08-24 10:04:52 +01:00
74ff53cd88 BUG: incorrect order for output scaling (transformPoints, ...)
- the output write scaling should be applied *after* undoing the
  effects of the specified rotation centre. Fixes #2566

ENH: update option names for transformPoints and surfaceTransformPoints

- prefer  '-auto-centre' and '-centre', but also accept the previous
  options '-auto-origin' and '-origin' as aliases.

  Changing to '-centre' avoids possible confusion with
  coordinate system origin().
2022-08-18 13:56:13 +02:00
173ce8511f CONFIG: bump patch level 2022-06-24 17:28:02 +02:00
e93f3f6812 COMP: Gcc 11+ potential fix - see #2434 2022-06-24 17:28:02 +02:00
1949a31efb COMP: references to temporaries
COMP: include <limits>
2022-06-24 17:28:02 +02:00
eb3f7dfe74 COMP: gcc-12 buffer check bypasses xsputn (#2481, #2496)
- add overflow() method to the SHA1 streambuf. Previously could rely
  on xsputn for adding to sha1 content, but streams now check pptr()
  first to test for the buffering range and thus overflow() is needed.
2022-06-24 17:28:02 +02:00
2a3fd5afb4 BUG: sample/store surface field triggers dimension check (fixes #2361)
- when used for example with wallShearStress, the stress field is
  initially created as incompressible but later updated with the
  correct compressible/incompressible dimensions.

  If this field is sampled as a surface and stored on the registry
  the dimensions should be reset() and not '=' assigned, since that
  causes a dimension check which will obviously fail.
2022-02-11 14:36:58 +01:00
06f14de0cd CONFIG: bump patch level 2021-09-08 15:25:51 +02:00
1ead175957 BUG: error with empty distributed roots specification (fixes #2196) 2021-09-08 10:31:18 +02:00
2fe9481262 BUG: ParticleCollector - corrected and simplified parallel reductions. See #2184 2021-09-08 10:31:18 +02:00
76270c07a0 BUG: noise did not set num of output fields (VTK legacy) [fixes #2133] 2021-06-25 09:45:53 +02:00
9d5585d37a BUG: liquidProperties - corrected read scalar (was label). See #2142 2021-06-25 09:44:26 +02:00
e1201d735f COMP: sign check to avoid warnings about new[] range 2021-04-27 11:12:43 +02:00
9aea491e58 CONFIG: bump patch level 2021-04-14 20:11:44 +02:00
00709429a5 BACKPORT: installation helpers from v2012
BACKPORT: AllwmakeParseArguments prefix handling from v2012
2021-04-14 20:00:00 +02:00
864271b118 BUG: generic point patch fails (fixes #2062)
- the generic constructor could be called twice in pointPatchField::New,
  which results in an attempt to transfer tokens twice.
2021-04-14 19:45:57 +02:00
5790fbe2a4 BUG: AABBTree - corrected addressing. Fixes #2028 2021-04-14 19:44:35 +02:00
10b9467f68 BUG: surfaceFieldValue fails writing legacy VTK format
- number of fields was not set.
- interpolated surfaces incorrectly written for all formats
2021-01-22 16:31:16 +01:00
f89de2b65c BUG: incorrect returned size from surfaceWriter 2021-01-13 18:54:01 +01:00
cd2787d452 BUG: meshToMesh - corrected mapping of internal field for tgt->src mapping. Fixes #1935 2020-11-25 12:44:04 +01:00
625f5f6cbb BUG: typo in solidProperties prevents re-reading of "Hf" (fixes #1927) 2020-11-18 19:40:21 +01:00
d19515bfb8 BUG: extraneous brackets after Fluent cell types (fixes #1872)
ENH: limit output to 25 cell types per line for readability

- makes it easier to trace potential format errors etc

STYLE: downgrade warning about polyhedrals to a simple info message

- can assume that polyhedral support is widespread enough to not
  warrant a warning.
2020-10-29 11:24:21 +01:00
1ea4fc986b BUG: incorrect boundary type for expressions variables (fixes #1889)
- had calculated boundaries (default) for the evaluated variables,
  which meant they retained their initialized values (usually Zero).

  This normally goes unnoticed, since the boundary values are largely
  irrelevant in the volField expressions. However, when applying
  functions that balk at a zero value - eg, log() - this raises a
  floating point exception.

  These boundary should be zeroGradient, since the evaluated variables
  correspond to the internalField only. Could continue to use
  calculated, but then need to set the calculated boundary values from
  the patch internal field manually.
2020-10-23 11:34:13 +02:00
e3ac8fb4f4 BUG: using FatalIOErrorInLookup with incorrect exit type (fixes #1898)
- two occurrences where FatalIOErrorInLookup used exit(FatalError)
  instead of exit(FatalIOError), which caused the error messages
  to be lost.
2020-10-23 11:33:49 +02:00
be6756f322 CONFIG: ptscotch header not found on ArchLinux (fixes #1877)
- on ArchLinux, everything is installed under /usr/include/scotch.

  The detection script uses SCOTCH_ARCH_PATH as an initial guess for
  ptscotch as well. However, on the second pass, it has an absolute
  value ("/usr") instead of a logical one ("scotch-system").
  This resulted in the logic for handling scotch+ptscotch subdirs
  being bypassed.
2020-10-12 10:49:20 +02:00
f85e798532 BUG: parallel foamToEnsight fails depending on lagrangian order (fixes #1873)
- the problem arises when output fields are missing on some
  processors.

  When the information is combined, the resulting HashTables can have
  different insertion orders. This poses an issue when there are hash
  key collisions and thus different chaining.

- Use sorted order.
2020-10-08 18:30:17 +02:00
240342b508 BUG: mapPolyMesh: incorrect addressing. Fixes #1864
Triggered when running e.g. postProcess
2020-09-30 13:17:52 +02:00
4ffea147dc CONFIG: increment patch level 2020-09-24 13:46:55 +02:00
4e884c03d2 BUG: unexpected treatment of missing fractionExpr (fixes #1858)
- specifying gradientExpr without a valueExpr, a missing fractionExpr
  should be treated as 0 (gradient only), not as 1 (value only)

ENH: improve sanity checks + evaluation short-cuts in exprMixedFvPatchField
2020-09-24 13:46:52 +02:00
6c7ae09251 BUG: fractionExpr "0" ignored (fixes #1855)
- incorrect branching logic caused the "0" case to be ignored
2020-09-24 13:10:02 +02:00
7795f32fa6 BUG: gradingDescriptor stream input ignores negative expansion (Fix #1841)
- mostly only tripped when using fractional edge grading, since this
  is where the list reading is used. Overseen in commit 7da0b5bee1.
2020-09-16 09:32:27 +02:00
14410a736a BUG: directory information spoils "wmake -show-cxx" (fixes #1799)
- the various information queries MUST be executed with
  the '--no-print-directory' or risk polluting values
  in the information queries.

  This is mostly seen with the 'canCompile' test for tutorials running
  in parallel.
2020-08-06 17:58:19 +02:00
76137138ae CONFIG: increment patch level 2020-07-27 11:27:21 +02:00
1f83f48f3c BUG: potential memory leaks in HashPtrTable::set (#1787)
- backported fix from develop

COMP: incorrect variable names in PtrListOpsTemplates.C
2020-07-27 11:26:09 +02:00
bc58837658 STYLE: remove incorrect branch condition in setExprFields 2020-07-27 11:25:53 +02:00
51dd8f1c63 CONFIG: increment patch level 2020-06-26 10:35:55 +02:00
6534245359 BUG: incorrect lookup name in ReynoldsAnalogy (fixes #1751)
- used fluidThermo::typeName instead of fluidThermo::dictName
  within the Cp() method.
2020-06-26 10:32:13 +02:00
b6bf3502a3 BUG: Adding phasePropertyName to basicThermo constructor (fixes #1745) 2020-06-26 10:32:13 +02:00
c49d923392 BUG: Correcting htc definition to avoid negative values 2020-06-26 10:32:13 +02:00
4248fdcd96 BUG: windows IOobject::path() incorrect from absolute (fixes #1738)
- only checked if it started with '/' and not 'd:/' (for example).
2020-06-26 10:32:13 +02:00
8f8617a8ca CONFIG: increment patch level 2020-06-04 21:49:35 +02:00
9d2fe2086a BUG: missing compilation for some vtk conversion components (fixes #1720) 2020-06-04 21:07:44 +02:00
be417c9841 COMP: erroneous return from void method (fixes #1716) 2020-05-26 10:40:26 +02:00
dd4b8cf30d BUG: incorrect startLineNumber for primitiveEntry (fixes #1706) 2020-05-14 17:27:56 +02:00
90e21679b3 DOC: Corrected header documentation 2020-05-12 15:27:26 +01:00
8395d69cdb BUG: Pair sort on construct did the opposite (fixes #1701) 2020-05-11 20:23:19 +02:00
d0846edf50 CONFIG: increment patch level 2020-05-06 09:11:55 +02:00
bcd798aa65 SUBMODULES: catalyst module with updated cmake/wmake scripts 2020-05-06 09:11:32 +02:00
c853080d91 COMP: provide makefile fallbacks for FOAM_SOLVERS, FOAM_UTILITIES
- improves build robustness, even with a reduced environment (#517)
2020-05-06 09:11:04 +02:00
cf5928c3b8 Merge branch 'config-improve-cmake-paraview-handling' into 'master'
ENH: improve cmake/ParaView config handling

See merge request Development/openfoam!358
2020-05-05 17:50:48 +01:00
aafe674f5f ENH: improve cmake/ParaView config handling
- improve handling of changes in ParaView/VTK or cmake parameters (#1693)

  * adjust internals to support recording of an unlimited number of
    configuration parameters and use file `cmp` instead of trying
    to check strings ourselves.

ENH: new wmake/scripts/wmake.cmake-args handler

- additional handling of -prefix=... as CMAKE_INSTALL_PREFIX export.

- in some contexts, can use instead of AllwmakeParseArguments
2020-05-05 18:06:09 +02:00
8525d4a2c5 CONFIG: no default verbosity for openfoam shell session
- an otherwise confusing amount of output that may not be expected
2020-04-27 21:24:56 +02:00
5ab04f5745 GIT: remove prebuilt pdf file(s) 2020-04-27 09:45:17 +02:00
aa2f932b75 CONFIG: additional packaging helpers, tutorial test helper
- bin/tools/create-mpi-config to query/write values for system openmpi.
  In some cases this can be used to avoid an mpicc requirement at runtime.

- adjust openfoam session to include -test-tutorial forwarding to the
  tutorials/AutoTest. This helps with writing installation tests.

- adjust foamConfigurePaths to latest version

- removal of gperftools default config, as per develop
2020-04-21 14:59:07 +02:00
6691e6563c COMP: adjust for CGAL-1.14 changes 2020-04-21 14:59:07 +02:00
b2bf82360c COMP: cleanup of surfaceCoarsen/bunnylod
- remove MSWindows components (code and makefiles)

- use cxx, hxx extensions to reduce possible confusion with other
  "list" and "vector" classes

- use C++ versions for C headers
2020-04-16 13:34:56 +02:00
a5b2cf9069 BUG: bad internal coeff for finiteArea zeroGradient BC (closes #1637)
- inadvertently set to zero instead of one (in commit 1d85fecf4d)
2020-04-16 10:11:33 +02:00
06333efd2d CONFIG: improve detection of scotch system include/libraries
- align wmake have_* scripts to support version query as per current
  develop branch

- use config.sh/ fallbacks when the corresponding *_ARCH_PATH is empty
  (eg, BOOST, CGAL, FFTW).
  This aids when building outside of the regular OpenFOAM environment.
2020-04-15 13:35:45 +02:00
4200774d35 CONFIG: improve support for compiler derivatives (#1671)
- add '[-+.~]' to the recognized qualifiers.
  This allows simple readable names such as

      WM_COMPILER=Clang-vendor

  but also opens the FUTURE (not yet supported) possibility of
  combining in additional information. For example,

      WM_COMPILER=Clang~openmp
      WM_COMPILER=Clang+cuda~openmp

  by using '+' (add) and '~' (subtract) notation similar to what
  spack uses.

CONFIG: support 'override' rules

- if present, compiler-family 'override' rules are included after
  compiler-family 'general' rules have been included. This allows a
  central means for including dynamically generated content to
  override some values.

  Some examples:

  To handle different gcc versions (system compiler):

  wmake/rules/...Gcc/override

  ```
  ifneq (,$(findstring 9, $(WM_COMPILER)))
      cc  := gcc-9
      CC  := g++-9 -std=c++11
  endif
  ```

  To handle different openmp on Darwin (#1656):

  wmake/rules/darwin64Clang/override

  ```
  # Use libomp (not libgomp) unless openmp is disabled
  ifeq (,$(findstring "~openmp", "$(WM_COMPILER)"))
      COMP_OPENMP = -DUSE_OMP -Xpreprocessor -fopenmp
      LINK_OPENMP = -lomp
  else
      include $(GENERAL_RULES)/no-openmp
  endif
  ```

  This treatment arguably fits into wmake/rules/darwin64Clang/general,
  but it serves to illustrate a possible use case.
2020-04-15 13:18:31 +02:00
04b5291c55 CONFIG: handle openmp on Darwin (#1656)
- requires -Xpreprocessor
- uses 'libomp' (no 'libgomp' link)
2020-04-15 13:18:19 +02:00
86e78ac3c1 BUG: forces - corrected moment field calculation 2020-04-09 10:00:43 +01:00
137 changed files with 4276 additions and 2184 deletions

View File

@ -63,11 +63,14 @@ echo
applications/Allwmake $targetType $*
# Additional components/modules
if [ -d "$WM_PROJECT_DIR/modules" ]
if [ "$FOAM_MODULE_PREFIX" = false ] || [ "$FOAM_MODULE_PREFIX" = none ]
then
echo "========================================"
echo "Compile OpenFOAM modules"
echo "OpenFOAM modules disabled (prefix=${FOAM_MODULE_PREFIX})"
echo
elif [ -d "$WM_PROJECT_DIR/modules" ]
then
echo "Compile OpenFOAM modules"
(cd "$WM_PROJECT_DIR/modules" 2>/dev/null && wmake -all)
fi
@ -86,8 +89,8 @@ echo " ${WM_PROJECT_DIR##*/}"
echo " $WM_COMPILER ${WM_COMPILER_TYPE:-system} compiler"
echo " ${WM_OPTIONS}, with ${WM_MPLIB} ${FOAM_MPI}"
echo
echo " api = $(foamEtcFile -show-api 2>/dev/null)"
echo " patch = $(foamEtcFile -show-patch 2>/dev/null)"
echo " api = $(etc/openfoam -show-api 2>/dev/null)"
echo " patch = $(etc/openfoam -show-patch 2>/dev/null)"
echo " bin = $(_foamCountDirEntries $FOAM_APPBIN) entries"
echo " lib = $(_foamCountDirEntries $FOAM_LIBBIN) entries"
echo

View File

@ -1,2 +1,2 @@
api=1912
patch=200403
patch=220610

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -62,13 +63,13 @@ void Foam::fluentFvMesh::writeFluentMesh() const
/ time().caseName() + ".msh"
);
Info<< "Writing Header" << endl;
Info<< "Writing Fluent Mesh" << endl;
fluentMeshFile
<< "(0 \"FOAM to Fluent Mesh File\")" << std::endl << std::endl
<< "(0 \"Dimension:\")" << std::endl
<< "(2 3)" << std::endl << std::endl
<< "(0 \"Grid dimensions:\")" << std::endl;
<< "(0 \"OpenFOAM to Fluent Mesh File\")" << nl << nl
<< "(0 \"Dimension:\")" << nl
<< "(2 3)" << nl << nl
<< "(0 \"Grid dimensions:\")" << nl;
// Writing number of points
fluentMeshFile
@ -217,8 +218,8 @@ void Foam::fluentFvMesh::writeFluentMesh() const
// Writing cells
fluentMeshFile
<< "(12 (1 1 "
<< nCells() << " 1 0)(" << std::endl;
<< "(12 (1 1 " << nCells() << " 1 0)" << nl
<< '(';
const cellModel& hex = cellModel::ref(cellModel::HEX);
const cellModel& prism = cellModel::ref(cellModel::PRISM);
@ -227,44 +228,59 @@ void Foam::fluentFvMesh::writeFluentMesh() const
const cellShapeList& cells = cellShapes();
bool hasWarned = false;
label nPolys = 0;
int nElemPerLine = 25; // Start with linebreak and indent
forAll(cells, celli)
{
if (nElemPerLine == 25)
{
// 25 elements per line with initial indent (readability)
fluentMeshFile << "\n ";
nElemPerLine = 0;
}
else if (!(nElemPerLine % 5))
{
// Format in blocks of 5 (readability)
fluentMeshFile << token::SPACE;
}
fluentMeshFile << token::SPACE;
++nElemPerLine;
if (cells[celli].model() == tet)
{
fluentMeshFile << " " << 2;
fluentMeshFile << 2;
}
else if (cells[celli].model() == hex)
{
fluentMeshFile << " " << 4;
fluentMeshFile << 4;
}
else if (cells[celli].model() == pyr)
{
fluentMeshFile << " " << 5;
fluentMeshFile << 5;
}
else if (cells[celli].model() == prism)
{
fluentMeshFile << " " << 6;
fluentMeshFile << 6;
}
else
{
if (!hasWarned)
{
hasWarned = true;
WarningInFunction
<< "foamMeshToFluent: cell shape for cell "
<< celli << " only supported by Fluent polyhedral meshes."
<< nl
<< " Suppressing any further messages for polyhedral"
<< " cells." << endl;
}
fluentMeshFile << " " << 7;
fluentMeshFile << 7;
++nPolys;
}
}
fluentMeshFile << ")())" << std::endl;
fluentMeshFile
<< nl << "))" << nl;
if (nPolys)
{
Info<< "Mesh had " << nPolys << " polyhedrals." << endl;
}
// Return to dec
fluentMeshFile.setf(ios::dec, ios::basefield);

View File

@ -169,14 +169,22 @@ int main(int argc, char *argv[])
(
"translate",
"vector",
"Translate by specified <vector> - eg, '(1 0 0)' before rotations"
"Translate by specified <vector> before rotations"
);
argList::addBoolOption
(
"auto-centre",
"Use bounding box centre as centre for rotations"
);
argList::addOption
(
"origin",
"centre",
"point",
"Use specified <point> as origin for rotations"
"Use specified <point> as centre for rotations"
);
argList::addOptionCompat("auto-centre", {"auto-origin", 2206});
argList::addOptionCompat("centre", {"origin", 2206});
argList::addOption
(
"rotate",
@ -290,18 +298,24 @@ int main(int argc, char *argv[])
if (args.readIfPresent("translate", v))
{
Info<< "Translating points by " << v << endl;
points += v;
}
vector origin;
const bool useOrigin = args.readIfPresent("origin", origin);
if (useOrigin)
vector rotationCentre;
bool useRotationCentre = args.readIfPresent("centre", rotationCentre);
if (args.found("auto-centre") && !useRotationCentre)
{
Info<< "Set origin for rotations to " << origin << endl;
points -= origin;
useRotationCentre = true;
rotationCentre = boundBox(points).centre();
}
if (useRotationCentre)
{
Info<< "Set centre of rotation to " << rotationCentre << endl;
points -= rotationCentre;
}
if (args.found("rotate"))
{
Pair<vector> n1n2
@ -380,6 +394,13 @@ int main(int argc, char *argv[])
}
}
if (useRotationCentre)
{
Info<< "Unset centre of rotation from " << rotationCentre << endl;
points += rotationCentre;
}
List<scalar> scaling;
if (args.readListIfPresent("scale", scaling))
{
@ -410,12 +431,6 @@ int main(int argc, char *argv[])
}
}
if (useOrigin)
{
Info<< "Unset origin for rotations from " << origin << endl;
points += origin;
}
// Set the precision of the points data to 10
IOstream::defaultPrecision(max(10u, IOstream::defaultPrecision()));

View File

@ -73,10 +73,10 @@ if (doLagrangian)
}
}
forAllConstIters(theseCloudFields, fieldIter)
// Field order may differ on individual processors, so sort by name
for (const word& fieldName : theseCloudFields.sortedToc())
{
const word& fieldName = fieldIter.key();
const word& fieldType = fieldIter.val();
const word& fieldType = theseCloudFields[fieldName];
IOobject fieldObject
(
@ -94,9 +94,13 @@ if (doLagrangian)
// but that combination does not work.
// So check the header and sync globally
const bool parRun = Pstream::parRun();
Pstream::parRun() = false;
fieldExists =
fieldObject.typeHeaderOk<IOField<scalar>>(false);
Pstream::parRun() = parRun;
reduce(fieldExists, orOp<bool>());
}

View File

@ -678,7 +678,7 @@ int main(int argc, char *argv[])
{
for
(
const word& opt
const char * const opt
: { "cellSet", "cellZone", "faceSet", "pointSet" }
)
{

View File

@ -898,7 +898,7 @@ int main(int argc, char *argv[])
);
}
}
else if (exprDictPtr.valid())
else
{
FatalErrorInFunction
<< "No command-line or dictionary??" << nl << endl

View File

@ -92,7 +92,7 @@ bool setCellFieldType
fieldType field(fieldHeader, mesh, false);
const Type& value = pTraits<Type>(fieldValueStream);
const Type value = pTraits<Type>(fieldValueStream);
if (selectedCells.size() == field.size())
{
@ -244,7 +244,7 @@ bool setFaceFieldType
fieldType field(fieldHeader, mesh);
const Type& value = pTraits<Type>(fieldValueStream);
const Type value = pTraits<Type>(fieldValueStream);
// Create flat list of selected faces and their value.
Field<Type> allBoundaryValues(mesh.nBoundaryFaces());

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -27,6 +28,7 @@ Typedefs
CGAL3DKernel
Description
A typedef for selecting inexact (faster) or exact (slower) 3D model.
\*---------------------------------------------------------------------------*/
@ -38,13 +40,13 @@ Description
#ifdef CGAL_INEXACT
// Fast kernel using a double as the storage type
#include "CGAL/Exact_predicates_inexact_constructions_kernel.h"
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
#else
// Very robust but expensive kernel
#include "CGAL/Exact_predicates_exact_constructions_kernel.h"
#include <CGAL/Exact_predicates_exact_constructions_kernel.h>
typedef CGAL::Exact_predicates_exact_constructions_kernel K;
#endif

View File

@ -65,6 +65,7 @@ struct IndexedFace
Foam::label index;
Foam::label region;
};
struct My_items
:
public CGAL::Polyhedron_items_3

View File

@ -20,4 +20,5 @@ EXE_INC = \
LIB_LIBS = \
-L$(CGAL_ARCH_PATH)/lib \
-L$(CGAL_ARCH_PATH)/lib$(WM_COMPILER_LIB_ARCH) \
-lsurfMesh \
-lmeshTools

View File

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -27,14 +28,50 @@ License
#include "PolyhedronReader.H"
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
template<class HDS>
void Foam::PolyhedronReader::Build_triangle<HDS>::operator()(HDS& hds)
{
// Postcondition: hds is a valid polyhedral surface.
CGAL::Polyhedron_incremental_builder_3<HDS> B(hds, true);
B.begin_surface(s_.nPoints(), s_.size());
typedef typename HDS::Vertex Vertex;
typedef typename Vertex::Point Point;
for (const auto& pt : s_.points())
{
B.add_vertex(Point(pt.x(), pt.y(), pt.z()));
}
for (const auto& f : s_)
{
B.begin_facet();
for (const label verti : f)
{
B.add_vertex_to_facet(verti);
}
B.end_facet();
}
B.end_surface();
}
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
Foam::PolyhedronReader::PolyhedronReader(const triSurface& s, Polyhedron& p)
{
Build_triangle<HalfedgeDS> triangle(s);
p.delegate(triangle);
// Populate index and region
Foam::label nTris = 0;
for
(
Facet_iterator fi = p.facets_begin();
@ -42,8 +79,10 @@ Foam::PolyhedronReader::PolyhedronReader(const triSurface& s, Polyhedron& p)
++fi
)
{
fi->index = nTris++;
fi->region = s[fi->index].region();
fi->index = nTris;
fi->region = s[nTris].region();
++nTris;
}
}

View File

@ -61,28 +61,21 @@ class PolyhedronReader
public:
Build_triangle(const triSurface& s);
Build_triangle(const triSurface& s)
:
s_(s)
{}
void operator()(HDS& hds);
};
// Private Member Functions
//- No copy construct
PolyhedronReader(const PolyhedronReader&) = delete;
//- No copy assignment
void operator=(const PolyhedronReader&) = delete;
public:
// Constructors
//- Populate polyhedron from surface
PolyhedronReader(const triSurface& s, Polyhedron& p);
};
@ -92,12 +85,6 @@ public:
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#ifdef NoRepository
# include "PolyhedronReaderTemplates.C"
#endif
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
#endif
// ************************************************************************* //

View File

@ -1,74 +0,0 @@
/*---------------------------------------------------------------------------*\
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation
-------------------------------------------------------------------------------
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 "PolyhedronReader.H"
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
template<class HDS>
Foam::PolyhedronReader::Build_triangle<HDS>::Build_triangle
(
const triSurface& s
)
:
s_(s)
{}
// * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * * //
template<class HDS>
void Foam::PolyhedronReader::Build_triangle<HDS>::operator()(HDS& hds)
{
// Postcondition: hds is a valid polyhedral surface.
CGAL::Polyhedron_incremental_builder_3<HDS> B(hds, true);
B.begin_surface(s_.nPoints(), s_.size());
typedef typename HDS::Vertex Vertex;
typedef typename Vertex::Point Point;
const Foam::pointField& pts = s_.points();
forAll(pts, i)
{
const Foam::point& pt = pts[i];
B.add_vertex(Point(pt.x(), pt.y(), pt.z()));
}
forAll(s_, i)
{
const Foam::labelledTri& t = s_[i];
B.begin_facet();
B.add_vertex_to_facet(t[0]);
B.add_vertex_to_facet(t[1]);
B.add_vertex_to_facet(t[2]);
B.end_facet();
}
B.end_surface();
}
// ************************************************************************* //

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2016 OpenCFD Ltd.
Copyright (C) 2016-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -102,8 +102,10 @@ typedef CGAL::AABB_face_graph_triangle_primitive
typedef CGAL::AABB_traits<K, Primitive> Traits;
typedef CGAL::AABB_tree<Traits> Tree;
typedef boost::optional<Tree::Intersection_and_primitive_id<Segment>::Type>
Segment_intersection;
typedef boost::optional
<
Tree::Intersection_and_primitive_id<Segment>::Type
> Segment_intersection;
#endif // NO_CGAL
@ -633,17 +635,14 @@ labelPair edgeIntersectionsCGAL
segments.clear();
tree.all_intersections(segment_query, std::back_inserter(segments));
for
(
std::vector<Segment_intersection>::const_iterator iter =
segments.begin(),
end = segments.end();
iter != end;
++iter
)
for (const Segment_intersection& intersect : segments)
{
// Get intersection object
if (const Point* ptPtr = boost::get<Point>(&((*iter)->first)))
if
(
const Point* ptPtr = boost::get<Point>(&(intersect->first))
)
{
point pt
(
@ -652,7 +651,12 @@ labelPair edgeIntersectionsCGAL
CGAL::to_double(ptPtr->z())
);
Polyhedron::Face_handle f = (*iter)->second;
#if defined (CGAL_VERSION_NR) && (CGAL_VERSION_NR < 1041400000)
Polyhedron::Face_handle f = (intersect->second);
#else
// 1.14 and later
Polyhedron::Face_handle f = (intersect->second).first;
#endif
intersections[edgeI].append
(
@ -665,18 +669,24 @@ labelPair edgeIntersectionsCGAL
);
// Intersection on edge interior
classifications[edgeI].append(-1);
nPoints++;
++nPoints;
}
else if
(
const Segment* sPtr = boost::get<Segment>(&((*iter)->first))
const Segment* sPtr = boost::get<Segment>(&(intersect->first))
)
{
#if defined (CGAL_VERSION_NR) && (CGAL_VERSION_NR < 1041400000)
Polyhedron::Face_handle f = (intersect->second);
#else
// 1.14 and later
Polyhedron::Face_handle f = (intersect->second).first;
#endif
//std::cout
// << "intersection object is a segment:" << sPtr->source()
// << " " << sPtr->target() << std::endl;
Polyhedron::Face_handle f = (*iter)->second;
//std::cout<< "triangle:" << f->index
// << " region:" << f->region << std::endl;
@ -706,7 +716,7 @@ labelPair edgeIntersectionsCGAL
);
// Intersection aligned with face. Tbd: enums
classifications[edgeI].append(2);
nSegments++;
++nSegments;
}
}
}

View File

@ -1,5 +1,5 @@
bunnylod/progmesh.C
bunnylod/vector.C
bunnylod/progmesh.cxx
bunnylod/vector.cxx
surfaceCoarsen.C
EXE = $(FOAM_APPBIN)/surfaceCoarsen

View File

@ -7,3 +7,14 @@ The PC executable bunnylod.exe should run
on a standard PC.
Just run it and enjoy.
Mouse dragging spins the rabbit.
-------------------------------------------------------------------
Changes
2020-04-16 OpenCFD Ltd
- remove MSWindows components (code and makefiles)
- use cxx, hxx extensions to reduce possible confusion with other
"list" and "vector" classes
- use C++ versions for C headers
-------------------------------------------------------------------

View File

@ -1,282 +0,0 @@
/*
* Polygon Reduction Demo by Stan Melax (c) 1998
* Permission to use any of this code wherever you want is granted..
* Although, please do acknowledge authorship if appropriate.
*
* This module initializes the bunny model data and calls
* the polygon reduction routine. At each frame the RenderModel()
* routine is called to draw the model. This module also
* animates the parameters (such as number of vertices to
* use) to show the model at various levels of detail.
*/
#include <windows.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <assert.h>
#include <string.h>
#include <GL/gl.h>
#pragma warning(disable : 4244)
#include "vector.h"
#include "font.h"
#include "progmesh.h"
#include "rabdata.h"
extern float DeltaT; // change in time since last frame
int render_num; // number of vertices to draw with
float lodbase=0.5f; // the fraction of vertices used to morph toward
float morph=1.0f; // where to render between 2 levels of detail
List<Vector> vert; // global list of vertices
List<tridata> tri; // global list of triangles
List<int> collapse_map; // to which neighbor each vertex collapses
int renderpolycount=0; // polygons rendered in the current frame
Vector model_position; // position of bunny
Quaternion model_orientation; // orientation of bunny
// Note that the use of the Map() function and the collapse_map
// list isn't part of the polygon reduction algorithm.
// We just set up this system here in this module
// so that we could retrieve the model at any desired vertex count.
// Therefore if this part of the program confuses you, then
// dont worry about it. It might help to look over the progmesh.cpp
// module first.
// Map()
//
// When the model is rendered using a maximum of mx vertices
// then it is vertices 0 through mx-1 that are used.
// We are able to do this because the vertex list
// gets sorted according to the collapse order.
// The Map() routine takes a vertex number 'a' and the
// maximum number of vertices 'mx' and returns the
// appropriate vertex in the range 0 to mx-1.
// When 'a' is greater than 'mx' the Map() routine
// follows the chain of edge collapses until a vertex
// within the limit is reached.
// An example to make this clear: assume there is
// a triangle with vertices 1, 3 and 12. But when
// rendering the model we limit ourselves to 10 vertices.
// In that case we find out how vertex 12 was removed
// by the polygon reduction algorithm. i.e. which
// edge was collapsed. Lets say that vertex 12 was collapsed
// to vertex number 7. This number would have been stored
// in the collapse_map array (i.e. collapse_map[12]==7).
// Since vertex 7 is in range (less than max of 10) we
// will want to render the triangle 1,3,7.
// Pretend now that we want to limit ourselves to 5 vertices.
// and vertex 7 was collapsed to vertex 3
// (i.e. collapse_map[7]==3). Then triangle 1,3,12 would now be
// triangle 1,3,3. i.e. this polygon was removed by the
// progressive mesh polygon reduction algorithm by the time
// it had gotten down to 5 vertices.
// No need to draw a one dimensional polygon. :-)
int Map(int a,int mx) {
if(mx<=0) return 0;
while(a>=mx) {
a=collapse_map[a];
}
return a;
}
void DrawModelTriangles() {
assert(collapse_map.num);
renderpolycount=0;
int i=0;
for(i=0;i<tri.num;i++) {
int p0= Map(tri[i].v[0],render_num);
int p1= Map(tri[i].v[1],render_num);
int p2= Map(tri[i].v[2],render_num);
// note: serious optimization opportunity here,
// by sorting the triangles the following "continue"
// could have been made into a "break" statement.
if(p0==p1 || p1==p2 || p2==p0) continue;
renderpolycount++;
// if we are not currenly morphing between 2 levels of detail
// (i.e. if morph=1.0) then q0,q1, and q2 are not necessary.
int q0= Map(p0,(int)(render_num*lodbase));
int q1= Map(p1,(int)(render_num*lodbase));
int q2= Map(p2,(int)(render_num*lodbase));
Vector v0,v1,v2;
v0 = vert[p0]*morph + vert[q0]*(1-morph);
v1 = vert[p1]*morph + vert[q1]*(1-morph);
v2 = vert[p2]*morph + vert[q2]*(1-morph);
glBegin(GL_POLYGON);
// the purpose of the demo is to show polygons
// therefore just use 1 face normal (flat shading)
Vector nrml = (v1-v0) * (v2-v1); // cross product
if(0<magnitude(nrml)) {
glNormal3fv(normalize(nrml));
}
glVertex3fv(v0);
glVertex3fv(v1);
glVertex3fv(v2);
glEnd();
}
}
void PermuteVertices(List<int> &permutation) {
// rearrange the vertex list
List<Vector> temp_list;
int i;
assert(permutation.num==vert.num);
for(i=0;i<vert.num;i++) {
temp_list.Add(vert[i]);
}
for(i=0;i<vert.num;i++) {
vert[permutation[i]]=temp_list[i];
}
// update the changes in the entries in the triangle list
for(i=0;i<tri.num;i++) {
for(int j=0;j<3;j++) {
tri[i].v[j] = permutation[tri[i].v[j]];
}
}
}
void GetRabbitData(){
// Copy the geometry from the arrays of data in rabdata.cpp into
// the vert and tri lists which we send to the reduction routine
int i;
for(i=0;i<RABBIT_VERTEX_NUM;i++) {
float *vp=rabbit_vertices[i];
vert.Add(Vector(vp[0],vp[1],vp[2]));
}
for(i=0;i<RABBIT_TRIANGLE_NUM;i++) {
tridata td;
td.v[0]=rabbit_triangles[i][0];
td.v[1]=rabbit_triangles[i][1];
td.v[2]=rabbit_triangles[i][2];
tri.Add(td);
}
render_num=vert.num; // by default lets use all the model to render
}
void InitModel() {
List<int> permutation;
GetRabbitData();
ProgressiveMesh(vert,tri,collapse_map,permutation);
PermuteVertices(permutation);
model_position = Vector(0,0,-3);
Quaternion yaw(Vector(0,1,0),-3.14f/4); // 45 degrees
Quaternion pitch(Vector(1,0,0),3.14f/12); // 15 degrees
model_orientation = pitch*yaw;
}
void StatusDraw() {
// Draw a slider type widget looking thing
// to show portion of vertices being used
float b = (float)render_num/(float)vert.num;
float a = b*(lodbase );
glDisable(GL_LIGHTING);
glMatrixMode( GL_PROJECTION );
glPushMatrix();
glLoadIdentity();
glOrtho(-0.15,15,-0.1,1.1,-0.1,100);
glMatrixMode( GL_MODELVIEW );
glPushMatrix();
glLoadIdentity();
glBegin(GL_POLYGON);
glColor3f(1,0,0);
glVertex2f(0,0);
glVertex2f(1,0);
glVertex2f(1,a);
glVertex2f(0,a);
glEnd();
glBegin(GL_POLYGON);
glColor3f(1,0,0);
glVertex2f(0,a);
glVertex2f(morph,a);
glVertex2f(morph,b);
glVertex2f(0,b);
glEnd();
glBegin(GL_POLYGON);
glColor3f(0,0,1);
glVertex2f(morph,a);
glVertex2f(1,a);
glVertex2f(1,b);
glVertex2f(morph,b);
glEnd();
glBegin(GL_POLYGON);
glColor3f(0,0,1);
glVertex2f(0,b);
glVertex2f(1,b);
glVertex2f(1,1);
glVertex2f(0,1);
glEnd();
glPopMatrix();
glMatrixMode( GL_PROJECTION );
glPopMatrix();
glMatrixMode( GL_MODELVIEW );
}
/*
* The following is just a quick hack to animate
* the object through various polygon reduced versions.
*/
struct keyframethings {
float t; // timestamp
float n; // portion of vertices used to start
float dn; // rate of change in "n"
float m; // morph value
float dm; // rate of change in "m"
} keys[]={
{0 ,1 ,0 ,1, 0},
{2 ,1 ,-1,1, 0},
{10,0 ,1 ,1, 0},
{18,1 ,0 ,1, 0},
{20,1 ,0 ,1,-1},
{24,0.5 ,0 ,1, 0},
{26,0.5 ,0 ,1,-1},
{30,0.25,0 ,1, 0},
{32,0.25,0 ,1,-1},
{36,0.125,0,1, 0},
{38,0.25,0 ,0, 1},
{42,0.5 ,0 ,0, 1},
{46,1 ,0 ,0, 1},
{50,1 ,0 ,1, 0},
};
void AnimateParameters() {
static float time=0; // global time - used for animation
time+=DeltaT;
if(time>=50) time=0; // repeat cycle every so many seconds
int k=0;
while(time>keys[k+1].t) {
k++;
}
float interp = (time-keys[k].t)/(keys[k+1].t-keys[k].t);
render_num = vert.num*(keys[k].n + interp*keys[k].dn);
morph = keys[k].m + interp*keys[k].dm;
morph = (morph>1.0f) ? 1.0f : morph; // clamp value
if(render_num>vert.num) render_num=vert.num;
if(render_num<0 ) render_num=0;
}
void RenderModel() {
AnimateParameters();
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glColor3f(1,1,1);
glPushMatrix();
glTranslatef(model_position.x,model_position.y,model_position.z);
// Rotate by quaternion: model_orientation
Vector axis=model_orientation.axis();
float angle=model_orientation.angle()*180.0f/3.14f;
glRotatef(angle,axis.x,axis.y,axis.z);
DrawModelTriangles();
StatusDraw();
glPopMatrix();
char buf[256];
sprintf(buf,"Polys: %d Vertices: %d ",renderpolycount,render_num);
if(morph<1.0) {
sprintf(buf+strlen(buf),"<-> %d morph: %4.2f ",
(int)(lodbase *render_num),morph);
}
PostString(buf,0,-2,5);
}

View File

@ -1,114 +0,0 @@
# Microsoft Developer Studio Project File - Name="bunnylod" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 5.00
# ** DO NOT EDIT **
# TARGTYPE "Win32 (x86) Application" 0x0101
CFG=bunnylod - Win32 Debug
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
!MESSAGE use the Export Makefile command and run
!MESSAGE
!MESSAGE NMAKE /f "bunnylod.mak".
!MESSAGE
!MESSAGE You can specify a configuration when running NMAKE
!MESSAGE by defining the macro CFG on the command line. For example:
!MESSAGE
!MESSAGE NMAKE /f "bunnylod.mak" CFG="bunnylod - Win32 Debug"
!MESSAGE
!MESSAGE Possible choices for configuration are:
!MESSAGE
!MESSAGE "bunnylod - Win32 Release" (based on "Win32 (x86) Application")
!MESSAGE "bunnylod - Win32 Debug" (based on "Win32 (x86) Application")
!MESSAGE
# Begin Project
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe
!IF "$(CFG)" == "bunnylod - Win32 Release"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32
# ADD BASE RSC /l 0x409 /d "NDEBUG"
# ADD RSC /l 0x409 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib opengl32.lib glu32.lib winmm.lib /nologo /subsystem:windows /machine:I386
!ELSEIF "$(CFG)" == "bunnylod - Win32 Debug"
# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /YX /FD /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32
# ADD BASE RSC /l 0x409 /d "_DEBUG"
# ADD RSC /l 0x409 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib opengl32.lib glu32.lib winmm.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
!ENDIF
# Begin Target
# Name "bunnylod - Win32 Release"
# Name "bunnylod - Win32 Debug"
# Begin Source File
SOURCE=.\bunnygut.cpp
# End Source File
# Begin Source File
SOURCE=.\font.cpp
# End Source File
# Begin Source File
SOURCE=.\progmesh.cpp
# End Source File
# Begin Source File
SOURCE=.\rabdata.cpp
# End Source File
# Begin Source File
SOURCE=.\vector.cpp
# End Source File
# Begin Source File
SOURCE=.\winmain.cpp
# End Source File
# End Target
# End Project

View File

@ -1,29 +0,0 @@
Microsoft Developer Studio Workspace File, Format Version 5.00
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
###############################################################################
Project: "bunnylod"=.\bunnylod.dsp - Package Owner=<4>
Package=<5>
{{{
}}}
Package=<4>
{{{
}}}
###############################################################################
Global:
Package=<5>
{{{
}}}
Package=<3>
{{{
}}}
###############################################################################

View File

@ -1,8 +0,0 @@
#ifndef FONT_H
#define FONT_H
void PrintString(char *s,int x=0,int y=-1);
void PostString(char *_s,int _x,int _y,float _life=5.0);
void RenderStrings();
#endif

View File

@ -1,13 +1,16 @@
/*
* -*- C++ -*-
*
* A generic template list class.
* Fairly typical of the list example you would
* find in any c++ book.
*/
#ifndef GENERIC_LIST_H
#define GENERIC_LIST_H
#include <assert.h>
#include <stdio.h>
#include <cassert>
#include <cstdio>
template<class Type> class List {
public:
@ -123,8 +126,4 @@ void List<Type>::Remove(Type t){
}
}
#endif

View File

@ -1,4 +1,6 @@
/*
* -*- C++ -*-
*
* Progressive Mesh type Polygon Reduction Algorithm
* by Stan Melax (c) 1998
* Permission to use any of this code wherever you want is granted..
@ -7,15 +9,14 @@
* See the header file progmesh.h for a description of this module
*/
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <assert.h>
//#include <windows.h>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#include "vector.h"
#include "list.h"
#include "progmesh.h"
#include "vector.hxx"
#include "list.hxx"
#include "progmesh.hxx"
#define min(x,y) (((x) <= (y)) ? (x) : (y))
#define max(x,y) (((x) >= (y)) ? (x) : (y))

View File

@ -1,4 +1,6 @@
/*
* -*- C++ -*-
*
* Progressive Mesh type Polygon Reduction Algorithm
* by Stan Melax (c) 1998
*
@ -18,8 +20,8 @@
#ifndef PROGRESSIVE_MESH_H
#define PROGRESSIVE_MESH_H
#include "vector.h"
#include "list.h"
#include "vector.hxx"
#include "list.hxx"
class tridata {
public:

View File

@ -1,8 +1,8 @@
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <cstdio>
#include <cmath>
#include <cassert>
#include "vector.h"
#include "vector.hxx"
float sqr(float a) {return a*a;}

View File

@ -1,3 +1,4 @@
// -*- C++ -*-
//
// This module contains a bunch of well understood functions
// I apologise if the conventions used here are slightly
@ -7,8 +8,8 @@
#ifndef GENERIC_VECTOR_H
#define GENERIC_VECTOR_H
#include <stdio.h>
#include <math.h>
#include <cstdio>
#include <cmath>
class Vector {

View File

@ -1,453 +0,0 @@
/*
* Polygon Reduction Demo by Stan Melax (c) 1998
* Permission to use any of this code wherever you want is granted..
* Although, please do acknowledge authorship if appropriate.
*
* This module contains the window setup code, mouse input, timing
* routines, and that sort of stuff. The interesting modules
* to see are bunnygut.cpp and progmesh.cpp.
*
* The windows 95 specific code for this application was taken from
* an example of processing mouse events in an OpenGL program using
* the Win32 API from the www.opengl.org web site.
*
* Under Project->Settings, Link Options, General Category
* Add:
* Opengl32.lib glu32.lib winmm.lib
* to the Object/Library Modules
*
* You will need have OpenGL libs and include files to compile this
* Go to the www.opengl.org web site if you need help with this.
*/
#include <windows.h> /* must include this before GL/gl.h */
#include <GL/gl.h> /* OpenGL header file */
#include <GL/glu.h> /* OpenGL utilities header file */
#include <stdio.h>
#include <sys/types.h>
#include <sys/timeb.h>
#include <time.h>
#include "vector.h"
#include "font.h"
// Functions and Variables from bunny module
extern void InitModel();
extern void RenderModel();
extern Vector model_position; // position of bunny
extern Quaternion model_orientation; // orientation of bunny
// Global Variables
float DeltaT = 0.1f;
float FPS;
int Width = 512;
int Height = 512;
int MouseX = 0;
int MouseY = 0;
Vector MouseVector; // 3D direction mouse points
Vector OldMouseVector;
int MouseState=0; // true iff left button down
float ViewAngle=45.0f;
HDC hDC; /* device context */
HPALETTE hPalette = 0; /* custom palette (if needed) */
void CalcFPSDeltaT(){
static int timeinit=0;
static int start,start2,current,last;
static int frame=0, frame2=0;
if(!timeinit){
frame=0;
start=timeGetTime();
timeinit=1;
}
frame++;
frame2++;
current=timeGetTime(); // found in winmm.lib
double dif=(double)(current-start)/CLOCKS_PER_SEC;
double rv = (dif)? (double)frame/(double)dif:-1.0;
if(dif>2.0 && frame >10) {
start = start2;
frame = frame2;
start2 = timeGetTime();
frame2 = 0;
}
DeltaT = (float)(current-last)/CLOCKS_PER_SEC;
if(current==last) {
DeltaT = 0.1f/CLOCKS_PER_SEC; // it just cant be 0
}
// if(DeltaT>1.0) DeltaT=1.0;
FPS = (float)rv;
last = current;
}
void ComputeMouseVector(){
OldMouseVector=MouseVector;
float spread = (float)tan(ViewAngle/2*3.14/180);
float y = spread * ((Height-MouseY)-Height/2.0f) /(Height/2.0f);
float x = spread * (MouseX-Width/2.0f) /(Height/2.0f);
Vector v(x ,y,-1);
// v=UserOrientation *v;
v=normalize(v);
MouseVector = v;
}
Quaternion VirtualTrackBall(Vector cop,Vector cor,Vector dir1,Vector dir2) {
// Implement track ball functionality to spin stuf on the screen
// cop center of projection
// cor center of rotation
// dir1 old mouse direction
// dir2 new mouse direction
// pretend there is a sphere around cor. Then find the points
// where dir1 and dir2 intersect that sphere. Find the
// rotation that takes the first point to the second.
float m;
// compute plane
Vector nrml = cor - cop;
// since trackball proportional to distance from cop
float fudgefactor = 1.0f/(magnitude(nrml) * 0.25f);
nrml = normalize(nrml);
float dist = -(nrml^cor);
Vector u= planelineintersection(nrml,dist,cop,cop+dir1);
u=u-cor;
u=u*fudgefactor;
m= magnitude(u);
if(m>1) {u=u*1.0f/m;}
else {
u=u - (nrml * (float)sqrt(1-m*m));
}
Vector v= planelineintersection(nrml,dist,cop,cop+dir2);
v=v-cor;
v=v*fudgefactor;
m= magnitude(v);
if(m>1) {v=v*1.0f/m;}
else {
v=v - (nrml * (float)sqrt(1-m*m));
}
Vector axis = u*v;
float angle;
m=magnitude(axis);
if(m>1)m=1; // avoid potential floating point error
Quaternion q(Vector(1.0f,0.0f,0.0f),0.0f);
if(m>0 && (angle=(float)asin(m))>3.14/180) {
axis = normalize(axis);
q=Quaternion(axis,angle);
}
return q;
}
void SpinIt(){
// Change the orientation of the bunny according to mouse drag
Quaternion q=VirtualTrackBall(Vector(0,0,0),model_position,
OldMouseVector,MouseVector);
model_orientation=q*model_orientation;
}
void Reshape(int width, int height){
// called initially and when the window changes size
Width=width;
Height=height;
glViewport(0, 0, width, height);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(ViewAngle, (float)width/height, 0.1, 50.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void PrintStats(){
char buf[1024];buf[0]='\0';
sprintf(buf,"FPS: %5.2f ",FPS);
PostString(buf,0,-1,0);
}
void Display(){
// main drawing routine - called every frame
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glPushMatrix();
glLoadIdentity();
// camera at default (zero) position and orientation
RenderModel();
PrintStats();
glLoadIdentity();
RenderStrings();
glPopMatrix();
glFlush();
SwapBuffers(hDC); /* nop if singlebuffered */
}
LONG WINAPI WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
static PAINTSTRUCT ps;
static GLboolean left = GL_FALSE; /* left button currently down? */
static GLboolean right = GL_FALSE; /* right button currently down? */
static int omx, omy, mx, my;
switch(uMsg) {
case WM_PAINT:
BeginPaint(hWnd, &ps);
EndPaint(hWnd, &ps);
return 0;
case WM_SIZE:
Reshape(LOWORD(lParam), HIWORD(lParam));
PostMessage(hWnd, WM_PAINT, 0, 0);
return 0;
case WM_CHAR:
switch (wParam) {
case 27: /* ESC key */
PostQuitMessage(0);
break;
}
return 0;
case WM_LBUTTONDOWN:
/* if we don't set the capture we won't get mouse move
messages when the mouse moves outside the window. */
SetCapture(hWnd);
MouseX = LOWORD(lParam);
MouseY = HIWORD(lParam);
ComputeMouseVector();
MouseState = 1;
return 0;
case WM_LBUTTONUP:
MouseX = LOWORD(lParam);
MouseY = HIWORD(lParam);
if(MouseX & 1 << 15) MouseX -= (1 << 16);
if(MouseY & 1 << 15) MouseY -= (1 << 16);
ComputeMouseVector();
if(MouseState) SpinIt();
MouseState=0;
/* remember to release the capture when we are finished. */
ReleaseCapture();
return 0;
case WM_MOUSEMOVE:
MouseX = LOWORD(lParam);
MouseY = HIWORD(lParam);
/* Win32 is pretty braindead about the x, y position that
it returns when the mouse is off the left or top edge
of the window (due to them being unsigned). therefore,
roll the Win32's 0..2^16 pointer co-ord range to the
more amenable (and useful) 0..+/-2^15. */
if(MouseX & 1 << 15) MouseX -= (1 << 16);
if(MouseY & 1 << 15) MouseY -= (1 << 16);
ComputeMouseVector();
if(MouseState) SpinIt();
return 0;
case WM_PALETTECHANGED:
if (hWnd == (HWND)wParam) break;
/* fall through to WM_QUERYNEWPALETTE */
case WM_QUERYNEWPALETTE:
if (hPalette) {
UnrealizeObject(hPalette);
SelectPalette(hDC, hPalette, FALSE);
RealizePalette(hDC);
return TRUE;
}
return FALSE;
case WM_CLOSE:
PostQuitMessage(0);
return 0;
}
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
HWND CreateOpenGLWindow(char* title)
{
// make a double-buffered, rgba, opengl window
int n, pf;
HWND hWnd;
WNDCLASS wc;
LOGPALETTE* lpPal;
PIXELFORMATDESCRIPTOR pfd;
static HINSTANCE hInstance = 0;
/* only register the window class once - use hInstance as a flag. */
if (!hInstance) {
hInstance = GetModuleHandle(nullptr);
wc.style = CS_OWNDC;
wc.lpfnWndProc = (WNDPROC)WindowProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hIcon = LoadIcon(nullptr, IDI_WINLOGO);
wc.hCursor = LoadCursor(nullptr, IDC_ARROW);
wc.hbrBackground = nullptr;
wc.lpszMenuName = nullptr;
wc.lpszClassName = "OpenGL";
if (!RegisterClass(&wc)) {
MessageBox(nullptr, "RegisterClass() failed: "
"Cannot register window class.",
"Error", MB_OK);
return nullptr;
}
}
hWnd = CreateWindow("OpenGL", title, WS_OVERLAPPEDWINDOW |
WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
0,0,Width,Height, nullptr, nullptr, hInstance, nullptr);
if (hWnd == nullptr) {
MessageBox(nullptr,
"CreateWindow() failed: Cannot create a window.",
"Error", MB_OK);
return nullptr;
}
hDC = GetDC(hWnd);
/* there is no guarantee that the contents of the stack that become
the pfd are zeroed, therefore _make sure_ to clear these bits. */
memset(&pfd, 0, sizeof(pfd));
pfd.nSize = sizeof(pfd);
pfd.nVersion = 1;
pfd.dwFlags = PFD_DRAW_TO_WINDOW
| PFD_SUPPORT_OPENGL
| PFD_DOUBLEBUFFER;
pfd.iPixelType = PFD_TYPE_RGBA;
pfd.cDepthBits = 32;
pfd.cColorBits = 32;
pf = ChoosePixelFormat(hDC, &pfd);
if (pf == 0) {
MessageBox(nullptr, "ChoosePixelFormat() failed: "
"Cannot find a suitable pixel format.",
"Error", MB_OK);
return 0;
}
if (SetPixelFormat(hDC, pf, &pfd) == FALSE) {
MessageBox(nullptr, "SetPixelFormat() failed: "
"Cannot set format specified.", "Error", MB_OK);
return 0;
}
DescribePixelFormat(hDC, pf, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
if (pfd.dwFlags & PFD_NEED_PALETTE ||
pfd.iPixelType == PFD_TYPE_COLORINDEX) {
n = 1 << pfd.cColorBits;
if (n > 256) n = 256;
lpPal = (LOGPALETTE*)malloc(sizeof(LOGPALETTE) +
sizeof(PALETTEENTRY) * n);
memset(lpPal, 0, sizeof(LOGPALETTE) + sizeof(PALETTEENTRY) * n);
lpPal->palVersion = 0x300;
lpPal->palNumEntries = n;
GetSystemPaletteEntries(hDC, 0, n, &lpPal->palPalEntry[0]);
/* if the pixel type is RGBA, then we want to make an RGB ramp,
otherwise (color index) set individual colors. */
if (pfd.iPixelType == PFD_TYPE_RGBA) {
int redMask = (1 << pfd.cRedBits) - 1;
int greenMask = (1 << pfd.cGreenBits) - 1;
int blueMask = (1 << pfd.cBlueBits) - 1;
int i;
/* fill in the entries with an RGB color ramp. */
for (i = 0; i < n; ++i) {
lpPal->palPalEntry[i].peRed =
(((i >> pfd.cRedShift) & redMask) * 255)
/redMask;
lpPal->palPalEntry[i].peGreen =
(((i >> pfd.cGreenShift) & greenMask) * 255)
/greenMask;
lpPal->palPalEntry[i].peBlue =
(((i >> pfd.cBlueShift) & blueMask) * 255)
/blueMask;
lpPal->palPalEntry[i].peFlags = 0;
}
} else {
lpPal->palPalEntry[0].peRed = 0;
lpPal->palPalEntry[0].peGreen = 0;
lpPal->palPalEntry[0].peBlue = 0;
lpPal->palPalEntry[0].peFlags = PC_NOCOLLAPSE;
lpPal->palPalEntry[1].peRed = 255;
lpPal->palPalEntry[1].peGreen = 0;
lpPal->palPalEntry[1].peBlue = 0;
lpPal->palPalEntry[1].peFlags = PC_NOCOLLAPSE;
lpPal->palPalEntry[2].peRed = 0;
lpPal->palPalEntry[2].peGreen = 255;
lpPal->palPalEntry[2].peBlue = 0;
lpPal->palPalEntry[2].peFlags = PC_NOCOLLAPSE;
lpPal->palPalEntry[3].peRed = 0;
lpPal->palPalEntry[3].peGreen = 0;
lpPal->palPalEntry[3].peBlue = 255;
lpPal->palPalEntry[3].peFlags = PC_NOCOLLAPSE;
}
hPalette = CreatePalette(lpPal);
if (hPalette) {
SelectPalette(hDC, hPalette, FALSE);
RealizePalette(hDC);
}
free(lpPal);
}
ReleaseDC(hDC, hWnd);
return hWnd;
}
int APIENTRY WinMain(HINSTANCE hCurrentInst, HINSTANCE hPreviousInst,
LPSTR lpszCmdLine, int nCmdShow)
{
HGLRC hRC; /* opengl context */
HWND hWnd; /* window */
MSG msg; /* message */
// InitModel() initializes some data structures and
// does the progressive mesh polygon reduction algorithm
// on the model.
CalcFPSDeltaT(); // to time the algorithm
InitModel();
CalcFPSDeltaT();
hWnd = CreateOpenGLWindow("bunnylod by Stan Melax");
if (hWnd == nullptr) exit(1);
hDC = GetDC(hWnd);
hRC = wglCreateContext(hDC);
wglMakeCurrent(hDC, hRC);
ShowWindow(hWnd, nCmdShow);
glEnable(GL_DEPTH_TEST);
PostString("Demo by Stan Melax (c)1998",5,-5,20);
PostString("Model by Viewpoint Datalabs (c)1996",5,-4,20);
char buf[128];
PostString("Mesh Reduction Algorithm (non-optimized)",1,0,5);
sprintf(buf,"was executed in %5.3f seconds",DeltaT);
PostString(buf,2,1,6);
while (1) {
while(PeekMessage(&msg, hWnd, 0, 0, PM_NOREMOVE)) {
if(GetMessage(&msg, hWnd, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
} else {
// This 'goto' was in the sample code
goto quit;
}
}
CalcFPSDeltaT();
Display();
}
quit:
wglMakeCurrent(nullptr, nullptr);
ReleaseDC(hDC, hWnd);
wglDeleteContext(hRC);
DestroyWindow(hWnd);
if (hPalette) DeleteObject(hPalette);
return msg.wParam;
}

View File

@ -50,7 +50,7 @@ Description
#include "triFaceList.H"
// From bunnylod
#include "progmesh.h"
#include "progmesh.hxx"
using namespace Foam;

View File

@ -82,12 +82,20 @@ int main(int argc, char *argv[])
"vector",
"Translate by specified <vector> - eg, '(1 0 0)' before rotations"
);
argList::addBoolOption
(
"auto-centre",
"Use bounding box centre as centre for rotations"
);
argList::addOption
(
"origin",
"centre",
"point",
"Use specified <point> as origin for rotations"
"Use specified <point> as centre for rotations"
);
argList::addOptionCompat("auto-centre", {"auto-origin", 2206});
argList::addOptionCompat("centre", {"origin", 2206});
argList::addOption
(
"rotate",
@ -165,18 +173,24 @@ int main(int argc, char *argv[])
if (args.readIfPresent("translate", v))
{
Info<< "Translating points by " << v << endl;
points += v;
}
vector origin;
const bool useOrigin = args.readIfPresent("origin", origin);
if (useOrigin)
vector rotationCentre;
bool useRotationCentre = args.readIfPresent("centre", rotationCentre);
if (args.found("auto-centre") && !useRotationCentre)
{
Info<< "Set origin for rotations to " << origin << endl;
points -= origin;
useRotationCentre = true;
rotationCentre = boundBox(points).centre();
}
if (useRotationCentre)
{
Info<< "Set centre of rotation to " << rotationCentre << endl;
points -= rotationCentre;
}
if (args.found("rotate"))
{
Pair<vector> n1n2
@ -235,6 +249,13 @@ int main(int argc, char *argv[])
points = transform(rot, points);
}
if (useRotationCentre)
{
Info<< "Unset centre of rotation from " << rotationCentre << endl;
points += rotationCentre;
}
List<scalar> scaling;
if (args.readListIfPresent("scale", scaling))
{
@ -265,11 +286,6 @@ int main(int argc, char *argv[])
}
}
if (useOrigin)
{
Info<< "Unset origin for rotations from " << origin << endl;
points += origin;
}
surf1.movePoints(points);
surf1.write(outFileName);

View File

@ -7,14 +7,13 @@
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2017-2018 OpenCFD Ltd.
# Copyright (C) 2017-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# foamEtcFile
# bin/foamEtcFile
#
# Description
# Locate user/group/other file as per '#includeEtc'.
@ -67,8 +66,8 @@ options:
-config Add config directory prefix for shell type:
with -csh* for a config.csh/ prefix
with -sh* for a config.sh/ prefix
-show-api Print api value from wmake/rules, or meta-info and exit
-show-patch Print patch value from meta-info and exit
-show-api Print META-INFO api value and exit
-show-patch Print META-INFO patch value and exit
-with-api=NUM Specify alternative api value to search with
-quiet (-q) Suppress all normal output
-silent (-s) Suppress stderr, except -csh-verbose, -sh-verbose output
@ -129,54 +128,17 @@ fi
#-------------------------------------------------------------------------------
# The API locations. See wmake/wmakeBuildInfo
rulesFile="$projectDir/wmake/rules/General/general"
metaInfoDir="$projectDir/META-INFO"
# Get api from rules/General/general
#
# Failure modes:
# - No api information (can't find file etc).
# -> Fatal for building, but could be OK for a stripped down version
#
# Fallback. Get from api-info
#
getApi()
# Get a value from META-INFO/api-info
# $1 : keyword
getApiInfo()
{
local value
value="$(sed -ne '/^ *#/!{ /WM_VERSION.*OPENFOAM=/{ s@^.*OPENFOAM= *\([0-9][0-9]*\).*@\1@p; q }}' $rulesFile 2>/dev/null)"
if [ -z "$value" ] && [ -f "$metaInfoDir/api-info" ]
then
# Fallback. Get from api-info
value="$(sed -ne 's@^ *api *= *\([0-9][0-9]*\).*@\1@p' $metaInfoDir/api-info 2>/dev/null)"
fi
if [ -n "$value" ]
then
echo "$value"
else
return 1
fi
}
# Get patch from meta-info / api-info
#
# Failure modes:
# - No patch information (can't find file etc).
#
getPatchLevel()
{
local value
# Fallback. Get from api-info
value="$(sed -ne 's@^ *patch *= *\([0-9][0-9]*\).*@\1@p' $metaInfoDir/api-info 2>/dev/null)"
value="$(sed -ne 's@^'"$1"' *= *\([0-9][0-9]*\).*@\1@p' "$projectDir"/META-INFO/api-info 2>/dev/null)"
if [ -n "$value" ]
then
echo "$value"
else
echo "Could not determine OPENFOAM '$1' value" 1>&2
return 1
fi
}
@ -193,14 +155,12 @@ do
-h | -help*)
printHelp
;;
-show-api)
# Show API and exit
getApi
-show-api) # Show API and exit
getApiInfo api
exit $?
;;
-show-patch)
# Show patch level and exit
getPatchLevel
-show-patch) # Show patch level and exit
getApiInfo patch
exit $?
;;
-with-api=*)
@ -276,7 +236,7 @@ done
#-------------------------------------------------------------------------------
# Establish the API value
[ -n "$projectApi" ] || projectApi=$(getApi)
[ -n "$projectApi" ] || projectApi=$(getApiInfo api)
# Split arguments into filename (for searching) and trailing bits for shell eval
# Silently remove leading ~OpenFOAM/ (as per Foam::findEtcFile)

272
bin/tools/create-mpi-config Executable file
View File

@ -0,0 +1,272 @@
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / 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, distributed under GPL-3.0-or-later.
#
# Script
# bin/tools/create-mpi-config
#
# Description
# Define hard-coded packaging settings for MPI flavours,
# primarily for system openmpi.
# This eliminates a runtime dependency on mpicc, for example.
#
# Instead of querying/parsing 'mpicc --showme:link' each time,
# it is done once during packaging.
#
# Environment
# FOAM_MPI, MPI_ARCH_PATH, DEB_TARGET_MULTIARCH
#
# Possible Dependencies
# - dpkg-architecture
# - mpicc
#
# Notes
# Run from top-level directory when creating config files
#
#------------------------------------------------------------------------------
printHelp() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
usage: ${0##*/} options
options:
-dry-run Report but do not write config files
-no-mpicc Bypass any use of mpicc
-query-openmpi Report installation directory for system openmpi
-write-openmpi Query system openmpi and write config files
-write Write config files using FOAM_MPI, MPI_ARCH_PATH
Define hard-coded packaging settings for MPI flavours.
Equivalent options:
-write-system-openmpi | -write-openmpi
-query-system-openmpi | -query-openmpi
USAGE
exit 0 # A clean exit
}
# 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
}
#------------------------------------------------------------------------------
# Options
unset optDryRun
useMpicc=true
# Get installation directory for system openmpi
# - from "mpicc --showme:link"
# - manual fallback
#
# The mpicc content looks like this:
# ----
# -pthread -L/usr/lib64/mpi/gcc/openmpi/lib64 -lmpi
# ----
query_system_openmpi()
{
unset arch_path
if [ "$useMpicc" = true ]
then
arch_path=$(mpicc --showme:link 2>/dev/null | sed -e 's#^.*-L\([^ ]*\).*#\1#')
arch_path="${arch_path%/*}"
if [ -n "$arch_path" ]
then
echo "$arch_path"
return 0 # Clean exit
fi
echo "No mpicc found. Attempt manually" 1>&2
fi
# Manual discovery
if [ -z "$DEB_TARGET_MULTIARCH" ]
then
DEB_TARGET_MULTIARCH=$(dpkg-architecture -qDEB_TARGET_MULTIARCH 2>/dev/null || true)
fi
# Include is under /usr/lib... (eg, debian, openSUSE)
for testdir in \
/usr/lib/"${DEB_TARGET_MULTIARCH:+${DEB_TARGET_MULTIARCH}/}"openmpi/include \
/usr/lib64/mpi/gcc/openmpi/include \
;
do
if [ -e "$testdir/mpi.h" ]
then
echo "${testdir%/*}"
return 0 # Clean exit
fi
done
# Include is under /usr/include (eg, RedHat)
for testdir in \
/usr/include/openmpi-"$(uname -m)" \
/usr/include/openmpi \
;
do
if [ -e "$testdir/mpi.h" ]
then
echo "/usr"
return 0 # Clean exit
fi
done
# Failed (should not happen)
# - report '/usr', but with error code 2
echo "/usr"
return 2
}
# Generate etc/config.{csh,sh}/MPI-TYPE files
# based on the values for FOAM_MPI and MPI_ARCH_PATH
create_files()
{
[ -n "$FOAM_MPI" ] || die "FOAM_MPI not set"
if [ -d "$MPI_ARCH_PATH" ]
then
echo "Define $FOAM_MPI with $MPI_ARCH_PATH" 1>&2
case "$FOAM_MPI" in
(openmpi-system)
configDir="etc/config.sh"
if [ "$optDryRun" = true ]
then
cat << CONTENT 1>&2
dry-run: $configDir/$FOAM_MPI
#
# Packaging configured value for $FOAM_MPI
export MPI_ARCH_PATH="$MPI_ARCH_PATH"
CONTENT
elif [ -d "$configDir" ]
then
echo "Write $configDir/$FOAM_MPI" 1>&2
cat << CONTENT > "$configDir/$FOAM_MPI"
# $configDir/$FOAM_MPI
#
# Packaging configured value for $FOAM_MPI
export MPI_ARCH_PATH="$MPI_ARCH_PATH"
#----
CONTENT
else
echo "Cannot write $configDir/$FOAM_MPI - no directory" 1>&2
fi
configDir="etc/config.csh"
if [ "$optDryRun" = true ]
then
cat << CONTENT 1>&2
dry-run: $configDir/$FOAM_MPI
#
# Packaging configured value for $FOAM_MPI
setenv MPI_ARCH_PATH "$MPI_ARCH_PATH"
CONTENT
elif [ -d "$configDir" ]
then
echo "Write $configDir/$FOAM_MPI" 1>&2
cat << CONTENT > "$configDir/$FOAM_MPI"
# $configDir/$FOAM_MPI
#
# Packaging configured value for $FOAM_MPI
setenv MPI_ARCH_PATH "$MPI_ARCH_PATH"
#----
CONTENT
else
echo "Cannot write $configDir/$FOAM_MPI - no directory" 1>&2
fi
;;
esac
else
echo "Warning: $FOAM_MPI with bad MPI_ARCH_PATH: $MPI_ARCH_PATH" 1>&2
# TBD - remove old/bad entries?
#
# for file in "etc/config.sh/$FOAM_MPI" "etc/config.csh/$FOAM_MPI"
# do
# [ -f "$file" ] && rm -f "$file"
# done
fi
}
#------------------------------------------------------------------------------
# Parse options
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help* | --help*)
printHelp
;;
'')
# Discard empty arguments
;;
-dry-run)
optDryRun=true
;;
-no-mpicc)
unset useMpicc
;;
-query-openmpi | -query-system-openmpi)
query_system_openmpi
exit $?
;;
-write-openmpi | -write-system-openmpi)
if MPI_ARCH_PATH=$(query_system_openmpi)
then
FOAM_MPI="openmpi-system"
create_files
else
die "Failed query for system openmpi"
fi
;;
-write)
create_files
;;
*)
echo "Ignore unknown option/argument: '$1'" 1>&2
;;
esac
shift
done
exit 0 # A clean exit, if we get this far
# -----------------------------------------------------------------------------

View File

@ -29,18 +29,49 @@
#
#------------------------------------------------------------------------------
printHelp() {
cat<<USAGE
case "$1" in
(*compat*)
cat<<HELP_COMPAT
Obsolete options:
-foamInstall DIR [obsolete]
-projectName NAME [obsolete]
-sigfpe|-no-sigfpe [obsolete - now under etc/controlDict]
-archOption 32|64 [obsolete setting of 'WM_ARCH_OPTION' - edit manually]
Equivalent options:
-version -foamVersion --projectVersion
-archOption --archOption
-third -ThirdParty
-paraview --paraviewVersion | -paraviewVersion
-paraview-path --paraviewInstall | -paraviewInstall
-scotch --scotchVersion | -scotchVersion
-scotch-path --scotchArchPath | -scotchArchPath
-system-compiler -system
-third-compiler -third
HELP_COMPAT
exit 0 # A clean exit
;;
esac
cat<<HELP_HEAD
usage: $0 options
Options
-h | -help Display short help and exit
-help-compat Display compatibility options and exit
-help-full Display full help and exit
Basic
-etc=DIR set FOAM_CONFIG_ETC for alternative project files
-project-path DIR specify 'WM_PROJECT_DIR' (eg, /opt/openfoam1806-patch1)
-version VER specify project version (eg, v1806)
-sp | -SP | -float32 single precision (WM_PRECISION_OPTION)
-dp | -DP | -float64 double precision (WM_PRECISION_OPTION)
-spdp | -SPDP mixed single/double precision
-int32 | -int64 the 'WM_LABEL_SIZE'
-spdp | -SPDP mixed precision (WM_PRECISION_OPTION)
-int32 | -int64 label-size (WM_LABEL_SIZE)
Compiler
-system-compiler NAME The 'system' compiler to use (eg, Gcc, Clang, Icc,...)
@ -57,20 +88,26 @@ MPI
-openmpi-system use system openmpi
-openmpi-third use ThirdParty openmpi (using default version)
ThirdParty versions
Components versions (ThirdParty)
-adios VER specify 'adios2_version'
-boost VER specify 'boost_version'
-cgal ver specify 'cgal_version'
-cgal VER specify 'cgal_version'
-cmake VER specify 'cmake_version'
-fftw VER specify 'fffw_version'
-kahip VER specify 'KAHIP_VERSION'
-metis ver specify 'METIS_VERSION'
-metis VER specify 'METIS_VERSION'
-scotch VER specify 'SCOTCH_VERSION' (eg, scotch_6.0.4)
HELP_HEAD
case "$1" in
(*full*)
cat<<HELP_FULL
Components specified by absolute path
-adios-path DIR Path for 'ADIOS2_ARCH_PATH' (overrides -adios)
-boost-path DIR Path for 'BOOST_ARCH_PATH' (overrides -boost)
-cgal-path DIR Path for 'CGAL_ARCH_PATH' (overrides -cgal)
-cmake-path DIR Path for 'CMAKE_ARCH_PATH' (overrides -cmake)
-fftw-path DIR Path for 'FFTW_ARCH_PATH' (overrides -fftw)
-kahip-path DIR Path for 'KAHIP_ARCH_PATH' (overrides -kahip)
-metis-path DIR Path for 'METIS_ARCH_PATH' (overrides -metis)
@ -80,32 +117,24 @@ Graphics
-paraview VER specify 'ParaView_VERSION' (eg, 5.4.1 or system)
-paraview-qt VER specify 'ParaView_QT' (eg, qt-system)
-paraview-path DIR specify 'ParaView_DIR' (eg, /opt/ParaView-5.4.1)
-vtk VER specify 'vtk_version' (eg, VTK-7.1.0)
-llvm VER specify 'mesa_llvm'
-mesa VER specify 'mesa_version' (eg, mesa-13.0.1)
-vtk VER specify 'vtk_version' (eg, VTK-7.1.0)
-llvm-path DIR Path for 'LLVM_ARCH_PATH' (overrides -llvm)
-mesa-path DIR Path for 'MESA_ARCH_PATH' (overrides -mesa)
-vtk-path DIR Path for 'VTK_DIR' (overrides -vtk)
Misc
-foamInstall DIR [obsolete]
-projectName NAME [obsolete]
-sigfpe|-no-sigfpe [obsolete - now under etc/controlDict]
-archOption 32|64 [obsolete setting of 'WM_ARCH_OPTION' - edit manually]
HELP_FULL
;;
esac
cat<<HELP_TAIL_COMMON
Adjusts hardcoded versions and installation paths (POSIX and C-shell)
for OpenFOAM.
Adjusts hardcoded versions and installation paths (POSIX and C-shell).
HELP_TAIL_COMMON
Equivalent options:
-version -foamVersion --projectVersion
-archOption --archOption
-third -ThirdParty
-paraview --paraviewVersion | -paraviewVersion
-paraview-path --paraviewInstall | -paraviewInstall
-scotch --scotchVersion | -scotchVersion
-scotch-path --scotchArchPath | -scotchArchPath
-system-compiler -system
-third-compiler -third
USAGE
exit 0 # clean exit
exit 0 # A clean exit
}
@ -123,11 +152,12 @@ die()
}
# -----------------------------------------------------------------------------
projectDir="$(\pwd -L)" # Project dir
# Check that it appears to be an OpenFOAM installation
if [ -f etc/bashrc ] && [ -d "META-INFO" ]
then
echo "Configuring OpenFOAM" 1>&2
echo "Configuring OpenFOAM ($projectDir)" 1>&2
else
die "Please run from the OpenFOAM top-level installation directory" \
"No etc/bashrc or META-INFO/ found"
@ -172,18 +202,22 @@ _inlineSed()
local replacement="$3"
local msg="$4"
local cmd='/^[^#]/s@'"$regexp"'@'"$replacement"'@'
local localFile
[ -f "$file" ] || {
echo "Missing file: $file"
exit 2 # Fatal
}
# Local filename (for reporting)
localFile="$(echo "$file" | sed -e "s#^$projectDir/##")"
grep -q "$regexp" "$file" && sed -i -e "$cmd" "$file" || { \
echo "Failed: ${msg:-replacement} in $file"
echo "Failed: ${msg:-replacement} in $localFile"
return 1
}
[ -n "$msg" ] && echo " $msg ($file)"
[ -n "$msg" ] && echo " $msg ($localFile)"
return 0
}
@ -209,7 +243,7 @@ replace()
"$file" \
"$key=.*" \
"$key=$val" \
"Replaced $key setting by '$val'"
"Replaced $key by '$val'"
done
}
@ -232,9 +266,9 @@ replaceCsh()
_inlineSed \
"$file" \
"setenv *$key [^ #]*" \
"setenv [ ]*$key [^ #]*" \
"setenv $key $val" \
"Replaced $key setenv by '$val'"
"Replaced $key by '$val'"
done
}
@ -323,7 +357,13 @@ unset adjusted optMpi
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help* | --help*)
-help-c*) # Compat help
printHelp -compat
;;
-help-f*) # Full help
printHelp -full
;;
-h | -help*) # Short help
printHelp
;;
'')
@ -516,12 +556,12 @@ CONFIG_CSH
_inlineSed $(_foamEtc config.sh/mpi) \
"FOAM_MPI=$expected" \
"FOAM_MPI=$optMpi" \
"Replaced 'FOAM_MPI=$expected' setting by 'FOAM_MPI=$optMpi'"
"Replaced 'FOAM_MPI=$expected' by 'FOAM_MPI=$optMpi'"
_inlineSed $(_foamEtc config.csh/mpi) \
"FOAM_MPI $expected" \
"FOAM_MPI $optMpi" \
"Replaced 'FOAM_MPI $expected' setting by 'FOAM_MPI $optMpi'"
"Replaced 'FOAM_MPI $expected' by 'FOAM_MPI $optMpi'"
replaceEtc bashrc WM_MPLIB OPENMPI
replaceEtcCsh cshrc WM_MPLIB OPENMPI
@ -623,8 +663,15 @@ CONFIG_CSH
-cmake)
# Replace cmake_version=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/paraview cmake_version "$optionValue"
replaceEtc config.csh/paraview cmake_version "$optionValue"
replaceEtc config.sh/cmake cmake_version "$optionValue"
adjusted=true
shift
;;
-cmake-path)
# Replace CMAKE_ARCH_PATH=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/cmake CMAKE_ARCH_PATH "$optionValue"
adjusted=true
shift
;;
@ -711,11 +758,11 @@ CONFIG_CSH
shift
;;
-vtk)
# Replace vtk_version=...
-llvm)
# Replace mesa_llvm=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/vtk vtk_version "$optionValue"
replaceEtc config.csh/vtk vtk_version "$optionValue"
replaceEtc config.sh/vtk mesa_llvm "$optionValue"
replaceEtc config.csh/vtk mesa_llvm "$optionValue"
adjusted=true
shift
;;
@ -729,6 +776,42 @@ CONFIG_CSH
shift
;;
-vtk)
# Replace vtk_version=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/vtk vtk_version "$optionValue"
replaceEtc config.csh/vtk vtk_version "$optionValue"
adjusted=true
shift
;;
-llvm-path)
# Replace LLVM_ARCH_PATH=...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/vtk LLVM_ARCH_PATH \""$optionValue\""
replaceEtcCsh config.csh/vtk LLVM_ARCH_PATH \""$optionValue\""
adjusted=true
shift
;;
-mesa-path)
# Replace MESA_ARCH_PATH...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/vtk MESA_ARCH_PATH \""$optionValue\""
replaceEtcCsh config.csh/vtk MESA_ARCH_PATH \""$optionValue\""
adjusted=true
shift
;;
-vtk-path)
# Replace VTK_DIR...
optionValue=$(getOptionValue "$@")
replaceEtc config.sh/vtk VTK_DIR \""$optionValue\""
replaceEtcCsh config.csh/vtk VTK_DIR \""$optionValue\""
adjusted=true
shift
;;
## Misc ##

430
bin/tools/install-dirs Executable file
View File

@ -0,0 +1,430 @@
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / 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, distributed under GPL-3.0-or-later.
#
# Script
# install-dirs
#
# Example usage
# install-dirs -prefix=/opt/openfoam/openfoamVER -core
#
# Description
# Simple installer to copy architecture-independent directories.
#
#------------------------------------------------------------------------------
printHelp() {
cat<<USAGE
Usage: ${0##*/} [OPTION]
input options:
-source=SOURCE Source directory
[\$WM_PROJECT_DIR ${WM_PROJECT_DIR:-''}]
-platform=PLATFORM OpenFOAM platform name [\$WM_OPTIONS ${WM_OPTIONS:-''}]
-foam-mpi=FOAM_MPI OpenFOAM mpi name [\$FOAM_MPI ${FOAM_MPI:-''}]
target options:
-prefix=PREFIX Top-level installation directory in PREFIX ['']
selections:
-[no-]common [do not] install (bin, etc, META-INFO)
-[no-]devel [do not] install (applications, src, wmake)
-[no-]doc [do not] install (doc)
-[no-]tut [do not] install (tutorials)
-no-app, -no-apps do not install (applications)
-no-src do not install (src)
-no-wmake do not install (wmake)
bundled selections:
-core Select: -common -devel
-default Select: -common -devel -doc -tut
tuning options:
-collate Collate modules (doc, tutorials)
-collate-doc Collate modules (doc) into doc/modules
-collate-tut Collate modules (tutorials) into tutorials/modules
general options:
-dry-run, -n Do not perform any operations
-force, -f Ignored
-verbose, -v Additional verbosity
-help Print the help and exit
Simple installer to copy OpenFOAM non-binary directories.
Example,
${0##*/} -prefix=/opt/openfoamVER
USAGE
exit 0 # A clean exit
}
unset optDryRun hadError
# 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
}
# Report error and exit
warnOrDie()
{
if [ -n "$optDryRun" ]
then
hadError=true
while [ "$#" -ge 1 ]; do echo "Error: $1" 1>&2; shift; done
else
die "$@"
fi
}
# Get the option's value (argument), or die on missing or empty value
# $1 option=value
getOptionValue()
{
local value="${1#*=}"
# Remove any surrounding double quotes
value="${value%\"}"
value="${value#\"}"
[ -n "$value" ] || die "'${1%=}' option requires a value"
echo "$value"
}
# Test for '-no-' or '-without-' prefix. Return "false" or "true"
# $1 option
# [$2] truth value <true>
getBoolOption()
{
case "$1" in
(-no-* | -without-*) echo "false" ;;
(*) echo "${2:-true}" ;;
esac
}
#-------------------------------------------------------------------------------
# Defaults from current OpenFOAM environment
sourceDir="$WM_PROJECT_DIR"
platform="$WM_OPTIONS"
foam_mpi="$FOAM_MPI"
unset install_common install_devel
unset install_app install_src install_wmake
unset install_doc optCollate_doc
unset install_tut optCollate_tut
unset optCollate
unset prefix exec_prefix bindir libdir libdir_mpi optVerbose
# Parse options
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help*) printHelp ;;
-n | -dry-run) optDryRun="(dry-run) " ;;
-v | -verbose) optVerbose=true ;;
-f | -force) echo "Ignored option: ${1%%=*}" 1>&2 ;;
# Inputs
-source=*) sourceDir="$(getOptionValue "$1")" ;;
-platform=*) echo "Ignored option: ${1%%=*}" 1>&2 ;;
-foam-mpi=*) echo "Ignored option: ${1%%=*}" 1>&2 ;;
# Targets
-prefix=*) prefix="$(getOptionValue "$1")" ;;
-exec-prefix=*) echo "Ignored option: ${1%%=*}" 1>&2 ;;
# Selections
-common | -no-common) install_common="$(getBoolOption "$1")" ;;
-devel | -no-devel) install_devel="$(getBoolOption "$1")" ;;
-doc | -no-doc) install_doc="$(getBoolOption "$1")" ;;
-tut | -no-tut) install_tut="$(getBoolOption "$1")" ;;
-no-app | -no-apps) install_app="$(getBoolOption "$1")" ;;
-no-src) install_src="$(getBoolOption "$1")" ;;
-no-wmake) install_wmake="$(getBoolOption "$1")" ;;
-core)
install_common=true
install_devel=true
;;
-default | -all)
[ "$1" = "-all" ] && echo "Compat: treat $1 like -default" 1>&2
install_common=true
install_devel=true
install_doc=true
install_tut=true
;;
-collate | -no-collate)
optCollate="$(getBoolOption "$1")"
if [ "${optCollate:-false}" = false ]
then
unset optCollate optCollate_doc optCollate_tut
fi
;;
-collate-doc) optCollate_doc=true ;;
-collate-tut) optCollate_tut=true ;;
(*) die "Unknown option/argument: $1" ;;
esac
shift
done
#-------------------------------------------------------------------------------
[ "${install_common:-false}" = false ] && unset install_common
if [ "${install_devel:-false}" = false ]
then
unset install_devel install_app install_src install_wmake
fi
if [ "${install_doc:-false}" = false ]
then
unset install_doc
elif [ "$optCollate_doc" = true ] || [ "$optCollate" = true ]
then
install_doc=collate
fi
if [ "${install_tut:-false}" = false ]
then
unset install_tut
elif [ "$optCollate_tut" = true ] || [ "$optCollate" = true ]
then
install_tut=collate
fi
# Input checks
[ -d "$sourceDir" ] || warnOrDie "Invalid -source directory: $sourceDir"
# Installation sanity check
[ -n "$prefix" ] || warnOrDie "Must specify -prefix"
if [ -n "$hadError" ]
then
echo "Errors encounters in dry-run. Stopping" 1>&2
exit 1
fi
if [ -z "${install_common}${install_devel}${install_doc}${install_tut}" ]
then
exec 1>&2
echo "Nothing specified to install"
echo
echo "See '${0##*/} -help' for usage"
echo
exit 0 # Treat as not an error
fi
# Report settings
echo "Preparing install with the following parameters" 1>&2
echo "source:" 1>&2
echo " directory $sourceDir" 1>&2
echo 1>&2
echo "target" 1>&2
echo " prefix ${prefix-[]}" 1>&2
##echo " binary ${install_binary:-[disabled]}" 1>&2
echo " common ${install_common:-[disabled]}" 1>&2
echo -n " devel " 1>&2
if [ -n "$install_devel" ]
then
echo -n "true" 1>&2
[ "$install_app" = false ] && echo -n " [app=disabled]" 1>&2
[ "$install_src" = false ] && echo -n " [src=disabled]" 1>&2
[ "$install_wmake" = false ] && echo -n " [wmake=disabled]" 1>&2
echo 1>&2
else
echo "[disabled]" 1>&2
fi
echo " doc ${install_doc:-[disabled]}" 1>&2
echo " tut ${install_tut:-[disabled]}" 1>&2
echo 1>&2
#------------------------------------------------------------------------------
# Proper umask
umask 022
# The commands
copy_cmd="cp -a ${optVerbose:+-v}"
mkdir_cmd="mkdir -p"
if [ -n "$optDryRun" ]
then
if [ -n "$optVerbose" ]
then
copy_cmd="echo cp -a"
mkdir_cmd="echo mkdir -p"
else
copy_cmd="true"
mkdir_cmd="true"
fi
fi
# Copy file or directory to <prefix>
doCopy()
{
$mkdir_cmd "$prefix" 2>/dev/null
for i in "$@"
do
if [ -e "$sourceDir/$i" ]
then
$copy_cmd "$sourceDir/$i" "$prefix"
nCopied="x$nCopied"
else
echo "Missing? $sourceDir/$i" 1>&2
fi
done
echo "${optDryRun}${#nCopied} items copied" 1>&2
}
# Collate (doc | tutorials)
# Eg,
# modules/{NAME}/tutorials
# => tutorials/modules/{NAME}
collateModuleFiles()
{
local subDir="$1"
local subTarget="$prefix/$subDir/modules"
if [ -d "$sourceDir/modules" ]
then
(
cd "$sourceDir/modules" || exit
$mkdir_cmd "$subTarget"
for i in $(find . -mindepth 2 -maxdepth 2 -name "$subDir" -type d)
do
$mkdir_cmd "$subTarget/${i%/*}"
$copy_cmd "$i"/* "$subTarget/${i%/*}"
done
)
fi
}
#------------------------------------------------------------------------------
# common
# ----
message="${optDryRun}Install common:"
if [ -n "$install_common" ]
then
echo "${message} bin etc META-INFO" 1>&2
doCopy bin etc META-INFO
else
echo "${message} [disabled]" 1>&2
fi
# ----
# develop (or source)
# ----
message="${optDryRun}Install devel:" 1>&2
unset dirNames blockMessage
if [ -n "$install_devel" ]
then
if [ "$install_wmake" = false ]
then
blockMessage="$blockMessage [wmake=disabled]"
else
dirNames="$dirNames wmake"
fi
if [ "$install_src" = false ]
then
blockMessage="$blockMessage [src=disabled]"
else
dirNames="$dirNames src"
fi
if [ "$install_app" = false ]
then
blockMessage="$blockMessage [app=disabled]"
else
dirNames="$dirNames applications"
fi
fi
if [ -n "$dirNames" ]
then
echo "${message}${dirNames}${blockMessage}" 1>&2
doCopy $dirNames # Unquoted - uses word splitting
else
echo "${message} [disabled]" 1>&2
fi
# ----
# doc
# ----
message="${optDryRun}Install doc:" 1>&2
if [ -n "$install_doc" ]
then
echo "${message}" 1>&2
doCopy doc
if [ "$install_doc" = collate ]
then
echo "${optDryRun}Collate module doc:" 1>&2
collateModuleFiles doc
fi
else
echo "${message} [disabled]" 1>&2
fi
# ----
# tutorials
# ----
message="${optDryRun}Install tutorials:" 1>&2
if [ -n "$install_tut" ]
then
echo "${message}" 1>&2
doCopy tutorials
if [ "$install_tut" = collate ]
then
echo "${optDryRun}Collate module tutorials:" 1>&2
collateModuleFiles tutorials
fi
else
echo "${message} [disabled]" 1>&2
fi
# ----
if [ -n "$optDryRun" ]
then
[ -n "$optVerbose" ] && echo 1>&2
echo "${optDryRun}Done" 1>&2
fi
exit 0 # clean exit
#------------------------------------------------------------------------------

375
bin/tools/install-platform Executable file
View File

@ -0,0 +1,375 @@
#!/bin/sh
#------------------------------------------------------------------------------
# ========= |
# \\ / 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, distributed under GPL-3.0-or-later.
#
# Script
# install-platform
#
# Example usage
# install-platform -prefix=/opt/openfoam/openfoamVER
#
# Description
# Simple installer to copy OpenFOAM binary bin/, lib/ (platforms)
# directories.
#
# Note
# The platforms/tools directory still must be handled separately
#
# Layout of OpenFOAM platforms
#
# platforms
# |-- <WM_OPTIONS>
# |-- bin
# | |-- ...
# `-- lib
# |-- ...
# |-- dummy
# | `-- ...
# |-- sys-openmpi
# | |-- libPstream.so
# | `-- libptscotchDecomp.so
# `-- paraview-MAJ.MIN
# `-- ...
#
#------------------------------------------------------------------------------
printHelp() {
cat<<USAGE
Usage: ${0##*/} [OPTION]
input options:
-source=SOURCE Source directory
[\$WM_PROJECT_DIR ${WM_PROJECT_DIR:-''}]
-platform=PLATFORM OpenFOAM platform name [\$WM_OPTIONS ${WM_OPTIONS:-''}]
-foam-mpi=FOAM_MPI OpenFOAM mpi name [\$FOAM_MPI ${FOAM_MPI:-''}]
target options:
-prefix=PREFIX Top-level installation directory in PREFIX ['']
-exec-prefix=EPREFIX Architecture-dependent in EPREFIX
[PREFIX/platforms/PLATFORM]
-bindir=DIR bin directory [EPREFIX/bin]
-libdir=DIR lib directory [EPREFIX/lib]
-mpi-libdir=DIR mpi libdir [<libdir>/FOAM_MPI]
tuning options:
-no-bin Do not install bin directory
-no-lib Do not install lib directory
-no-mpi Do not install mpi lib directory
-mpi-only Only install mpi lib directory
-mpi-mkdir Create foam-mpi directory within libdir
general options:
-dry-run, -n Do not perform any operations
-force, -f Ignored
-verbose, -v Additional verbosity
-help Print the help and exit
Simple installer to copy OpenFOAM binary bin/, lib/ (platforms) directories.
Example,
${0##*/} -prefix=/opt/openfoamVER
USAGE
exit 0 # A clean exit
}
unset optDryRun hadError
# 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
}
# Report error and exit
warnOrDie()
{
if [ -n "$optDryRun" ]
then
hadError=true
while [ "$#" -ge 1 ]; do echo "Error: $1" 1>&2; shift; done
else
die "$@"
fi
}
# Get the option's value (argument), or die on missing or empty value
# $1 option=value
getOptionValue()
{
local value="${1#*=}"
# Remove any surrounding double quotes
value="${value%\"}"
value="${value#\"}"
[ -n "$value" ] || die "'${1%=}' option requires a value"
echo "$value"
}
# Test for '-no-' or '-without-' prefix. Return "false" or "true"
# $1 option
# [$2] truth value <true>
getBoolOption()
{
case "$1" in
(-no-* | -without-*) echo "false" ;;
(*) echo "${2:-true}" ;;
esac
}
#-------------------------------------------------------------------------------
# Defaults from current OpenFOAM environment
sourceDir="$WM_PROJECT_DIR"
platform="$WM_OPTIONS"
foam_mpi="$FOAM_MPI"
unset install_bin install_lib
unset optMkdir_mpi
install_mpi=true
unset prefix exec_prefix bindir libdir libdir_mpi optVerbose
# Parse options
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help*) printHelp ;;
-n | -dry-run) optDryRun="(dry-run) " ;;
-v | -verbose) optVerbose=true ;;
-f | -force) echo "Ignored option: ${1%%=*}" 1>&2 ;;
# Inputs
-source=*) sourceDir="$(getOptionValue "$1")" ;;
-platform=*) platform="$(getOptionValue "$1")" ;;
-foam-mpi=*) foam_mpi="$(getOptionValue "$1")" ;;
# Targets
-prefix=*) prefix="$(getOptionValue "$1")" ;;
-exec-prefix=*) exec_prefix="$(getOptionValue "$1")" ;;
-bindir=*) bindir="$(getOptionValue "$1")" ;;
-libdir=*) libdir="$(getOptionValue "$1")" ;;
-mpi-libdir=*) libdir_mpi="$(getOptionValue "$1")" ;;
-no-bin) install_bin=false ;;
-no-lib) install_lib=false ;;
-no-mpi) install_mpi=false ;;
-mpi-only) install_mpi=exclusive ;;
-mpi-mkdir) optMkdir_mpi=true ;;
(*) die "Unknown option/argument: $1" ;;
esac
shift
done
#-------------------------------------------------------------------------------
# Default <exec_prefix> based on <prefix>
if [ -z "$exec_prefix" ] && [ -n "$prefix" ]
then
exec_prefix="$prefix/platforms/$platform"
fi
# Default <bindir>, <libdir> based on <exec_prefix>
if [ -n "$exec_prefix" ]
then
[ -n "$bindir" ] || bindir="$exec_prefix/bin"
[ -n "$libdir" ] || libdir="$exec_prefix/lib"
fi
# Default <mpi-libdir> based on <libdir> and <foam-mpi>
if [ -z "$libdir_mpi" ] && [ -n "$libdir" ]
then
libdir_mpi="$libdir/$foam_mpi"
fi
# Exclusions
if [ "$install_bin" = false ] || [ "$install_mpi" = exclusive ]
then
unset bindir
fi
if [ "$install_lib" = false ] || [ "$install_mpi" = exclusive ]
then
unset libdir
fi
if [ "$install_mpi" = false ]
then
unset libdir_mpi
fi
# Input checks
sourcePlatform="$sourceDir/platforms/$platform"
[ -d "$sourceDir" ] || warnOrDie "Invalid -source directory: $sourceDir"
[ -n "$platform" ] || warnOrDie "No -platform detected or specified"
[ -n "$foam_mpi" ] || warnOrDie "No -foam-mpi detected or specified"
[ -d "$sourcePlatform" ] || \
warnOrDie "Missing platforms directory for: $platform"
# Installation sanity check
[ -n "$bindir$libdir$libdir_mpi" ] || \
warnOrDie "Must specify at least one of -prefix, -exec-prefix, -bindir, -libdir, -mpi-libdir"
if [ -n "$hadError" ]
then
echo "Errors encounters in dry-run. Stopping" 1>&2
exit 1
fi
# Report settings
echo "Preparing install with the following parameters" 1>&2
echo "source:" 1>&2
echo " directory $sourceDir" 1>&2
echo " platform $platform" 1>&2
echo " foam-mpi $foam_mpi" 1>&2
echo 1>&2
echo "target (mpi-install: $install_mpi)" 1>&2
echo " prefix ${prefix-[]}" 1>&2
echo " exec-prefix ${exec_prefix:-[]}" 1>&2
echo " bindir ${bindir:-[]}" 1>&2
echo " libdir ${libdir:-[]}" 1>&2
echo " libdir(mpi) ${libdir_mpi:-[]}" 1>&2
echo 1>&2
#------------------------------------------------------------------------------
# Proper umask
umask 022
# The commands
copy_cmd="cp -a ${optVerbose:+-v}"
mkdir_cmd="mkdir -p"
if [ -n "$optDryRun" ]
then
if [ -n "$optVerbose" ]
then
copy_cmd="echo cp -a"
mkdir_cmd="echo mkdir -p"
else
copy_cmd="true"
mkdir_cmd="true"
fi
fi
# bin/
# ----
message="${optDryRun}Install bindir:"
if [ -n "$bindir" ]
then
input="$sourcePlatform/bin"
echo "From $input" 1>&2
echo "${message} $bindir" 1>&2
$mkdir_cmd "$bindir" 2>/dev/null
for i in "$input/"*
do
if [ -e "$i" ]
then
$copy_cmd "$i" "$bindir"
fi
done
else
echo "${message} [disabled]" 1>&2
fi
# ----
# lib/ without mpi
# ----
message="${optDryRun}Install libdir(non-mpi):"
if [ -n "$libdir" ]
then
input="$sourcePlatform/lib"
echo "From $input" 1>&2
echo "${message} $libdir" 1>&2
$mkdir_cmd "$libdir" 2>/dev/null
for i in "$input/"*
do
if [ "${i##*/}" = "$foam_mpi" ]
then
if [ "$optMkdir_mpi" = true ]
then
$mkdir_cmd "$libdir/$foam_mpi"
fi
elif [ -e "$i" ]
then
$copy_cmd "$i" "$libdir"
else
echo "bogus lib entry? $i" 1>&2
fi
done
else
echo "${message} [disabled]" 1>&2
fi
# ----
# lib/mpi
# ----
message="${optDryRun}Install libdir(mpi):"
if [ -n "$libdir_mpi" ]
then
input="$sourcePlatform/lib/$foam_mpi"
echo "From $input" 1>&2
echo "${message} $libdir_mpi" 1>&2
$mkdir_cmd "$libdir_mpi" 2>/dev/null
for i in "$input"/*
do
if [ -e "$i" ]
then
# Always verbose (not many files anyhow)
$copy_cmd -v "$i" "$libdir_mpi"
else
echo "bogus mpi-lib entry? $i" 1>&2
fi
done
else
echo "${message} [disabled]" 1>&2
fi
# ----
if [ -n "$optDryRun" ]
then
[ -n "$optVerbose" ] && echo 1>&2
echo "${optDryRun}Done" 1>&2
fi
exit 0 # A clean exit
#------------------------------------------------------------------------------

View File

@ -1,4 +1,5 @@
#!/bin/sh
exec "@PROJECT_DIR@"/etc/openfoam "$@"
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
@ -11,16 +12,8 @@
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# openfoam [options] [args]
#
# Description
# Forwarding to the OpenFOAM etc/openfoam bash session script.
# Forwarding to OpenFOAM etc/openfoam bash session script.
# Uses a hard-code directory path (eg, generated with autoconfig).
#
#------------------------------------------------------------------------------
# Hard-coded directory path (eg, autoconfig)
projectDir="@PROJECT_DIR@"
exec "$projectDir"/etc/openfoam "$@"
#------------------------------------------------------------------------------

View File

@ -0,0 +1,75 @@
#!/bin/sh
FOAM_MPI="@FOAM_MPI@"
FOAM_SYSTEM_MPI_LIBBIN="@FOAM_SYSTEM_MPI_LIBBIN@"
#------------------------------------------------------------------------------
# ========= |
# \\ / 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, distributed under GPL-3.0-or-later.
#
# Description
# Update of links from system mpi lib/ to local lib/mpi-name
#
# Note
# Normally located as a trigger within the platforms/ directory
# Uses hard-coded values (eg, generated with autoconfig).
#
#------------------------------------------------------------------------------
cd "${0%/*}" || exit # Run from this directory
# Local values
FOAM_LIBBIN="$(pwd -P)/lib"
FOAM_MPI_LIBBIN="$FOAM_LIBBIN/$FOAM_MPI"
#------------------------------------------------------------------------------
echo "Link OpenFOAM ($FOAM_MPI) from system locations"
echo "Target: $FOAM_MPI_LIBBIN"
echo "Source: $FOAM_SYSTEM_MPI_LIBBIN"
if [ -z "$FOAM_MPI" ]
then
echo "FOAM_MPI not defined - skipping"
exit 0
fi
if [ -z "$FOAM_SYSTEM_MPI_LIBBIN" ]
then
echo "FOAM_SYSTEM_MPI_LIBBIN not defined - skipping"
exit 0
fi
if [ ! -d "$FOAM_SYSTEM_MPI_LIBBIN" ]
then
echo "No system mpi lib: $FOAM_SYSTEM_MPI_LIBBIN"
echo "... not updating"
exit 0
fi
if [ ! -d "$FOAM_LIBBIN" ]
then
echo "Missing $FOAM_LIBBIN"
exit 0
fi
#------------------------------------------------------------------------------
mkdir -p "$FOAM_MPI_LIBBIN"
# Create symlinks
(
cd "$FOAM_MPI_LIBBIN" || exit
for i in "$FOAM_SYSTEM_MPI_LIBBIN"/*
do
if [ -f "$i" ]
then
ln -svf "$i" "${i##*/}"
fi
done
)
exit 0 # clean exit
#------------------------------------------------------------------------------

View File

@ -78,7 +78,6 @@ example,
ParaView_VERSION=5.6.0
ParaView_QT=qt-system
cmake_version=cmake-system
# END OF (NORMAL) USER EDITABLE PART
#------------------------------------------------------------------------------

1
doc/modules/README Normal file
View File

@ -0,0 +1 @@
Modules-related documents when collated for an installation package.

View File

@ -6,24 +6,22 @@
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2016-2019 OpenCFD Ltd.
# Copyright (C) 2016-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# File
# config.csh/paraview
# - sourced by OpenFOAM-*/etc/cshrc or via foamPV alias
#
# Description
# Setup for PARAVIEW (partially cmake, qt too)
# Setup for PARAVIEW (partially QT too)
#
# To disable use of the PV_PLUGIN_PATH:
# ParaView_VERSION=none
#
# For system-wide installations:
# cmake_version=cmake-system
# ParaView_QT=qt-system
# ParaView_VERSION=system [EXPERIMENTAL]
#
@ -53,7 +51,6 @@
set ParaView_VERSION=5.6.3
set ParaView_QT=qt-system
set cmake_version=cmake-system
# END OF (NORMAL) USER EDITABLE PART
#------------------------------------------------------------------------------
@ -65,14 +62,13 @@ if (! $?WM_COMPILER_LIB_ARCH ) setenv WM_COMPILER_LIB_ARCH
# Compiler-specific location for ThirdParty installations
set archDir="$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER"
# Clean PATH and LD_LIBRARY_PATH
eval `$WM_PROJECT_DIR/bin/foamCleanPath -csh-env=PATH "$ParaView_DIR $archDir/ParaView- $archDir/qt- $archDir/cmake-"`
# Clean path and library path
eval `$WM_PROJECT_DIR/bin/foamCleanPath -csh-env=PATH "$ParaView_DIR $archDir/ParaView- $archDir/qt-"`
eval `$WM_PROJECT_DIR/bin/foamCleanPath -csh-env=LD_LIBRARY_PATH "$ParaView_DIR $archDir/ParaView- $archDir/qt-"`
# Evaluate command-line parameters for ParaView and cmake
# Evaluate command-line parameters for ParaView
while ( $#argv > 0 )
switch ($argv[1])
case cmake*=*:
case ParaView*=*:
# name=value -> set name=value
eval "set $argv[1]"
@ -81,13 +77,6 @@ while ( $#argv > 0 )
shift
end
# ThirdParty cmake
set cmake="$archDir/$cmake_version"
if ( -r "$cmake/bin/cmake" ) then
# _foamAddPath not available when foamPV alias is used
setenv PATH "$cmake/bin:${PATH}"
endif
if ($?ParaView_VERSION) then
switch ("$ParaView_VERSION")
case "":
@ -106,13 +95,12 @@ case "none":
case "system":
# Obtain major.minor from `paraview --version`
set pv_api=`paraview --version | \
sed -ne 's/^[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/p'`
set pv_api=`paraview --version | sed -ne 's/^[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/p'`
if ( "${%pv_api}" ) then
setenv PV_PLUGIN_PATH "$FOAM_LIBBIN/paraview-$pv_api"
else
if ("${pv_api}" == "") then
unsetenv ParaView_DIR PV_PLUGIN_PATH
else
setenv PV_PLUGIN_PATH "$FOAM_LIBBIN/paraview-$pv_api"
endif
if ($?FOAM_VERBOSE && $?prompt) then
@ -138,9 +126,8 @@ default:
breaksw
case [0-9]*:
# Extract API from VERSION
set pv_api=`echo "$ParaView_VERSION" | \
sed -ne 's/^[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/p'`
# Extract API from VERSION.
set pv_api=`echo "$ParaView_VERSION" | sed -ne 's/^[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/p'`
breaksw
endsw
@ -214,7 +201,6 @@ endif
unsetenv ParaView_VERSION ParaView_QT
unset archDir libDir
unset cmake cmake_version
unset pv_api pvLibDir pvPython qtDir
#------------------------------------------------------------------------------

35
etc/config.sh/cmake Normal file
View File

@ -0,0 +1,35 @@
#----------------------------------*-sh-*--------------------------------------
# ========= |
# \\ / 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, distributed under GPL-3.0-or-later.
#
# File
# etc/config.sh/cmake
# - possibly sourced during make process only.
#
# Description
# CMAKE location (ThirdParty or otherwise) when not found via the PATH
# Does not affect the PATH, that is left for the caller
#
# For system-wide installations:
# cmake_version=cmake-system
# define CMAKE_ARCH_PATH
#
# Note
# No csh version. This file is only used during make processes.
#
#------------------------------------------------------------------------------
# USER EDITABLE PART: Changes made here may be lost with the next upgrade
cmake_version=cmake-system
export CMAKE_ARCH_PATH="$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$cmake_version"
# END OF (NORMAL) USER EDITABLE PART
#------------------------------------------------------------------------------

View File

@ -9,12 +9,11 @@
# Copyright (C) 2016-2018 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# File
# etc/config.sh/gperftools
# - sourced by OpenFOAM-*/etc/bashrc
# Not normally sourced by OpenFOAM-*/etc/bashrc
#
# Description
# Setup file for GPERFTOOLS binaries/libraries.

View File

@ -16,7 +16,7 @@
# - sourced by OpenFOAM-*/etc/bashrc or via foamPV alias
#
# Description
# Setup for PARAVIEW (partially cmake, qt too)
# Setup for PARAVIEW (partially QT too)
#
# To disable use of the PV_PLUGIN_PATH:
# ParaView_VERSION=none
@ -55,7 +55,6 @@
ParaView_VERSION=5.6.3
ParaView_QT=qt-system
cmake_version=cmake-system
# END OF (NORMAL) USER EDITABLE PART
#------------------------------------------------------------------------------
@ -64,34 +63,26 @@ pv_api=auto # Either auto or pair of (major.minor) digits
# Compiler-specific location for ThirdParty installations
archDir="$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER"
# Clean PATH and LD_LIBRARY_PATH
# Clean path and library path
eval \
"$($WM_PROJECT_DIR/bin/foamCleanPath -sh-env=PATH \
$ParaView_DIR $archDir/ParaView- $archDir/qt- $archDir/cmake-)"
$ParaView_DIR $archDir/ParaView- $archDir/qt-)"
eval \
"$($WM_PROJECT_DIR/bin/foamCleanPath -sh-env=LD_LIBRARY_PATH \
$ParaView_DIR $archDir/ParaView- $archDir/qt-)"
# Evaluate command-line parameters for ParaView and cmake
# Evaluate command-line parameters for ParaView
for i
do
case "$i" in
(cmake*=* | ParaView*=*)
(ParaView*=*)
# name=value -> export name=value
eval "export $i"
;;
esac
done
# ThirdParty cmake
cmake="$archDir/$cmake_version"
if [ -r "$cmake/bin/cmake" ]
then
# _foamAddPath not available when foamPV function is used
PATH="$cmake/bin:$PATH"
fi
case "$ParaView_VERSION" in
('')
# empty - do nothing
@ -206,7 +197,6 @@ then
fi
unset archDir libDir
unset cmake cmake_version
unset pv_api pvLibDir pvPython qtDir
#------------------------------------------------------------------------------

View File

@ -5,11 +5,10 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2019 OpenCFD Ltd.
# Copyright (C) 2019-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# File
# etc/config.sh/paraview-system
@ -26,7 +25,7 @@
# Compiler-specific location for ThirdParty installations
archDir="$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER"
# Clean PATH and LD_LIBRARY_PATH
# Clean path and library path
eval \
"$($WM_PROJECT_DIR/bin/foamCleanPath -sh-env=PATH \
$ParaView_DIR $archDir/ParaView-)"

View File

@ -147,7 +147,6 @@ _foamEtc -config settings
_foamEtc -config mpi
_foamEtc -config paraview -- "$@" # Pass through for evaluation
_foamEtc -config vtk
_foamEtc -config gperftools
_foamEtc -config adios2
_foamEtc -config CGAL
_foamEtc -config scotch

View File

@ -35,7 +35,7 @@
# etc/openfoam -DWM_COMPILER=Clang
#
#------------------------------------------------------------------------------
# Auto-detect from location
# Auto-detect from location. Do not call from within the etc/directory itself!
projectDir="$(\cd "$(dirname "${0%/*}")" && \pwd -L)"
#------------------------------------------------------------------------------
@ -56,13 +56,19 @@ options:
-show-api | -version Print META-INFO api value and exit
-show-patch Print META-INFO patch value and exit
-show-prefix Print project directory and exit
-test-tutorial Forward arguments to tutorials/AutoTest
-verbose Set FOAM_VERBOSE=true (interactive only)
-help Print the usage
Open an interactive bash session with an OpenFOAM environment,
or run an OpenFOAM application (with arguments) after first sourcing
the OpenFOAM etc/bashrc file from the project directory:
($projectDir)
(${projectDir:-???})
For a persistent OpenFOAM environment, the following can be added to your
~/.bashrc file:
source ${projectDir:-???}/etc/bashrc
For more information: www.openfoam.com
@ -90,9 +96,11 @@ getApiInfo()
#-------------------------------------------------------------------------------
# No inheritance of FOAM_SETTINGS
unset FOAM_SETTINGS
# - No inheritance of FOAM_SETTINGS
# - No default verbosity (only as command-line option)
unset FOAM_CONFIG_ETC FOAM_SETTINGS FOAM_VERBOSE
unset _foamEtcDir _foamSettings _foamScriptCommand
unset optTestTut
# Parse options
while [ "$#" -gt 0 ]
@ -114,6 +122,10 @@ do
exit $?
;;
-test-tutorial) # Run tutorials/AutoTest
optTestTut=true
;;
-c) # Shell command
_foamScriptCommand="$2"
[ -n "$_foamScriptCommand" ] || {
@ -196,7 +208,7 @@ fi
unset interactive
if [ "$#" -eq 0 ] && [ -z "$_foamScriptCommand" ]
if [ "$#" -eq 0 ] && [ -z "$_foamScriptCommand" ] && [ -z "$optTestTut" ]
then
# Interactive shell, chain off via a file
interactive=true
@ -215,8 +227,6 @@ if [ -n "$_foamEtcDir" ] && [ -d "$_foamEtcDir" ]
then
# Additional etc directory
export FOAM_CONFIG_ETC="$_foamEtcDir"
else
unset FOAM_CONFIG_ETC
fi
if [ -n "$interactive" ]
@ -263,6 +273,15 @@ then
fi
if [ -n "$optTestTut" ]
then
sourceBashrc
exec "$WM_PROJECT_DIR/tutorials/AutoTest" "$@"
exit $? # Safety
fi
# An application or a shell script
# It may actually be a script with a '#!/project-path/bin/openfoam',

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2015 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -49,7 +49,7 @@ Foam::autoPtr<Foam::ODESolver> Foam::ODESolver::New
"ODESolver",
solverType,
*dictionaryConstructorTablePtr_
) << exit(FatalError);
) << exit(FatalIOError);
}
return autoPtr<ODESolver>(cstrIter()(odes, dict));

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2018 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -86,7 +86,19 @@ inline bool Foam::HashPtrTable<T, Key, Hash>::set
T* ptr
)
{
return this->parent_type::set(key, ptr);
// Newer: const T* old = this->get(key);
iterator iter(this->find(key));
const T* old = (iter.good() ? iter.val() : nullptr);
const bool ok = this->parent_type::set(key, ptr);
if (ok && old != ptr)
{
delete const_cast<T*>(old);
}
return ok;
}

View File

@ -50,6 +50,7 @@ void Foam::List<T>::doResize(const label newSize)
{
if (newSize > 0)
{
// With sign-check to avoid spurious -Walloc-size-larger-than
T* nv = new T[newSize];
const label overlap = min(this->size_, newSize);

View File

@ -31,8 +31,9 @@ License
template<class T>
inline void Foam::List<T>::doAlloc()
{
if (this->size_)
if (this->size_ > 0)
{
// With sign-check to avoid spurious -Walloc-size-larger-than
this->v_ = new T[this->size_];
}
}

View File

@ -121,21 +121,21 @@ inline void Foam::PtrList<T>::append(T* ptr)
template<class T>
inline void Foam::PtrList<T>::append(autoPtr<T>& aptr)
{
return UPtrList<T>::append(aptr.release());
UPtrList<T>::append(aptr.release());
}
template<class T>
inline void Foam::PtrList<T>::append(autoPtr<T>&& aptr)
{
return UPtrList<T>::append(aptr.release());
UPtrList<T>::append(aptr.release());
}
template<class T>
inline void Foam::PtrList<T>::append(const tmp<T>& tptr)
{
return UPtrList<T>::append(tptr.ptr());
UPtrList<T>::append(tptr.ptr());
}

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -79,7 +79,7 @@ void Foam::sortedOrder
template<class T>
void Foam::sort(UPtrList<T>& list)
{
labelList order(input.size());
labelList order(list.size());
sortedOrder(list, order);
list.sortOrder(order, false); // false = allow nullptr
}
@ -88,7 +88,7 @@ void Foam::sort(UPtrList<T>& list)
template<class T, class Compare>
void Foam::sort(UPtrList<T>& list, const Compare& comp)
{
labelList order(input.size());
labelList order(list.size());
sortedOrder(list, order, comp);
list.sortOrder(order, false); // false = allow nullptr
}

View File

@ -456,10 +456,19 @@ const Foam::fileName& Foam::IOobject::caseName() const
Foam::fileName Foam::IOobject::path() const
{
// A file is 'outside' of the case if it has been specified using an
// absolute path (starts with '/')
// absolute path
if (instance().starts_with('/'))
const auto first = instance().find('/');
if
(
first == 0
#ifdef _WIN32
|| (first == 2 && instance()[1] == ':') // Eg, d:/path
#endif
)
{
// Absolute path (starts with '/' or 'd:/')
return instance();
}

View File

@ -32,8 +32,8 @@ Description
\*---------------------------------------------------------------------------*/
#ifndef OSHA1stream_H
#define OSHA1stream_H
#ifndef Foam_OSHA1stream_H
#define Foam_OSHA1stream_H
#include "OSstream.H"
#include "SHA1.H"
@ -63,10 +63,17 @@ class osha1stream
protected:
//- Handle overflow
virtual int overflow(int c = EOF)
{
if (c != EOF) sha1_.append(c);
return c;
}
//- Put sequence of characters
virtual std::streamsize xsputn(const char* s, std::streamsize n)
{
sha1_.append(s, n);
if (n) sha1_.append(s, n);
return n;
}

View File

@ -158,7 +158,7 @@ Foam::tokenList Foam::functionEntries::evalEntry::evaluate
OTstream toks;
result.writeValue(toks);
return std::move(toks);
return tokenList(std::move(toks.tokens()));
}

View File

@ -151,7 +151,7 @@ Foam::label Foam::primitiveEntry::startLineNumber() const
if (tokens.size())
{
tokens.first().lineNumber();
return tokens.first().lineNumber();
}
return -1;

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -26,7 +26,7 @@ License
\*---------------------------------------------------------------------------*/
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// * * * * * * * * * * * * * * * * Selectors * * * * * * * * * * * * * * * * //
template<class Type>
Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New
@ -55,20 +55,22 @@ Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New
if
(
actualPatchType == word::null
actualPatchType.empty()
|| actualPatchType != p.type()
)
{
if (pfPtr().constraintType() != p.constraintType())
{
// Use default constraint type
// Incompatible (constraint-wise) with the patch type
// - use default constraint type
auto patchTypeCstrIter =
pointPatchConstructorTablePtr_->cfind(p.type());
if (!patchTypeCstrIter.found())
{
FatalErrorInFunction
<< "inconsistent patch and patchField types for \n"
<< "Inconsistent patch and patchField types for\n"
<< " patch type " << p.type()
<< " and patchField type " << patchFieldType
<< exit(FatalError);
@ -138,20 +140,17 @@ Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New
if
(
!dict.found("patchType")
!dict.found("patchType")
|| dict.get<word>("patchType") != p.type()
)
{
if (pfPtr().constraintType() == p.constraintType())
if (pfPtr().constraintType() != p.constraintType())
{
// Compatible (constraint-wise) with the patch type
return pfPtr;
}
else
{
// Use default constraint type
auto patchTypeCstrIter
= dictionaryConstructorTablePtr_->cfind(p.type());
// Incompatible (constraint-wise) with the patch type
// - use default constraint type
auto patchTypeCstrIter =
dictionaryConstructorTablePtr_->cfind(p.type());
if (!patchTypeCstrIter.found())
{
@ -166,7 +165,7 @@ Foam::autoPtr<Foam::pointPatchField<Type>> Foam::pointPatchField<Type>::New
}
}
return cstrIter()(p, iF, dict);
return pfPtr;
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2019 OpenCFD Ltd.
Copyright (C) 2015-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -1184,7 +1184,7 @@ void Foam::argList::parse
{
parRunControl_.distributed(true);
source = "-roots";
if (roots.size() != 1)
if (roots.size() > 1)
{
dictNProcs = roots.size()+1;
}
@ -1193,6 +1193,7 @@ void Foam::argList::parse
{
roots.resize(Pstream::nProcs()-1, fileName::null);
parRunControl_.distributed(true);
source = "-hostRoots";
ITstream is(source, options_["hostRoots"]);
@ -1231,7 +1232,7 @@ void Foam::argList::parse
}
}
if (roots.size() != 1)
if (roots.size() > 1)
{
dictNProcs = roots.size()+1;
}
@ -1259,6 +1260,12 @@ void Foam::argList::parse
{
parRunControl_.distributed(true);
decompDict.readEntry("roots", roots);
if (roots.empty())
{
DetailInfo
<< "WARNING: running distributed"
<< " but did not specify roots!" << nl;
}
}
}
@ -1326,8 +1333,8 @@ void Foam::argList::parse
{
options_.set("case", roots[slave-1]/globalCase_);
OPstream toSlave(Pstream::commsTypes::scheduled, slave);
toSlave << args_ << options_ << roots.size();
OPstream toProc(Pstream::commsTypes::scheduled, slave);
toProc << args_ << options_ << parRunControl_.distributed();
}
options_.erase("case");
@ -1377,24 +1384,24 @@ void Foam::argList::parse
slave++
)
{
OPstream toSlave(Pstream::commsTypes::scheduled, slave);
toSlave << args_ << options_ << roots.size();
OPstream toProc(Pstream::commsTypes::scheduled, slave);
toProc << args_ << options_ << parRunControl_.distributed();
}
}
}
else
{
// Collect the master's argument list
label nroots;
bool isDistributed;
IPstream fromMaster
(
Pstream::commsTypes::scheduled,
Pstream::masterNo()
);
fromMaster >> args_ >> options_ >> nroots;
fromMaster >> args_ >> options_ >> isDistributed;
parRunControl_.distributed(nroots);
parRunControl_.distributed(isDistributed);
// Establish rootPath_/globalCase_/case_ for slave
setCasePaths();

View File

@ -202,7 +202,8 @@ inline Foam::Matrix<Form, Type>::Matrix
)
:
mRows_(Mb.m()),
nCols_(Mb.n())
nCols_(Mb.n()),
v_(nullptr)
{
doAlloc();
@ -224,7 +225,8 @@ inline Foam::Matrix<Form, Type>::Matrix
)
:
mRows_(Mb.m()),
nCols_(Mb.n())
nCols_(Mb.n()),
v_(nullptr)
{
doAlloc();

View File

@ -35,8 +35,9 @@ inline void Foam::Matrix<Form, Type>::doAlloc()
{
const label len = size();
if (len)
if (len > 0)
{
// With sign-check to avoid spurious -Walloc-size-larger-than
v_ = new Type[len];
}
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -86,7 +86,7 @@ Foam::mapPolyMesh::mapPolyMesh(const polyMesh& mesh)
forAll(faceZoneFaceMap_, zonei)
{
pointZoneMap_[zonei] = identity(mesh.faceZones()[zonei].size());
faceZoneFaceMap_[zonei] = identity(mesh.faceZones()[zonei].size());
}
forAll(cellZoneMap_, zonei)

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017-2019 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -89,7 +89,7 @@ inline Foam::Pair<T>::Pair(const FixedList<T, 2>& list)
template<class T>
inline Foam::Pair<T>::Pair(const T& f, const T& s, const bool doSort)
{
if (doSort && f < s)
if (doSort && s < f)
{
first() = s;
second() = f;

View File

@ -45,6 +45,9 @@ Description
\*---------------------------------------------------------------------------*/
#include "mathematicalConstants.H"
#include "error.H"
#include <cmath>
#include <limits>
using namespace Foam::constant::mathematical;

View File

@ -43,6 +43,10 @@ Description
\*---------------------------------------------------------------------------*/
#include "mathematicalConstants.H"
#include "error.H"
#include <cmath>
#include <limits>
using namespace Foam::constant::mathematical;
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -514,6 +514,10 @@ inline Foam::Tensor<Cmpt> Foam::Tensor<Cmpt>::T() const
template<class Cmpt>
#if defined(__GNUC__) && !defined(__clang__)
// Workaround for gcc (11+) that fails to handle tensor dot vector
__attribute__((optimize("no-tree-vectorize")))
#endif
inline Foam::Tensor<Cmpt>
Foam::Tensor<Cmpt>::inner(const Tensor<Cmpt>& t2) const
{
@ -537,6 +541,10 @@ Foam::Tensor<Cmpt>::inner(const Tensor<Cmpt>& t2) const
template<class Cmpt>
#if defined(__GNUC__) && !defined(__clang__)
// Workaround for gcc (11+) that fails to handle tensor dot vector
__attribute__((optimize("no-tree-vectorize")))
#endif
inline Foam::Tensor<Cmpt>
Foam::Tensor<Cmpt>::schur(const Tensor<Cmpt>& t2) const
{
@ -641,7 +649,11 @@ operator&(const Tensor<Cmpt>& t1, const Tensor<Cmpt>& t2)
template<class Cmpt>
inline typename innerProduct<Tensor<Cmpt>, Vector<Cmpt>>::type
#if defined(__GNUC__) && !defined(__clang__)
// Workaround for gcc (11+) that fails to handle tensor dot vector
__attribute__((optimize("no-tree-vectorize")))
#endif
inline Vector<Cmpt>
operator&(const Tensor<Cmpt>& t, const Vector<Cmpt>& v)
{
return Vector<Cmpt>
@ -654,7 +666,11 @@ operator&(const Tensor<Cmpt>& t, const Vector<Cmpt>& v)
template<class Cmpt>
inline typename innerProduct<Vector<Cmpt>, Tensor<Cmpt>>::type
#if defined(__GNUC__) && !defined(__clang__)
// Workaround for gcc (11+) that fails to handle tensor dot vector
__attribute__((optimize("no-tree-vectorize")))
#endif
inline Vector<Cmpt>
operator&(const Vector<Cmpt>& v, const Tensor<Cmpt>& t)
{
return Vector<Cmpt>
@ -922,6 +938,10 @@ operator-(const Tensor<Cmpt>& t1, const SphericalTensor<Cmpt>& st2)
//- Inner-product between a spherical tensor and a tensor
template<class Cmpt>
#if defined(__GNUC__) && !defined(__clang__)
// Workaround for gcc (11+) that fails to handle tensor dot vector
__attribute__((optimize("no-tree-vectorize")))
#endif
inline Tensor<Cmpt>
operator&(const SphericalTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
{
@ -936,6 +956,10 @@ operator&(const SphericalTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
//- Inner-product between a tensor and a spherical tensor
template<class Cmpt>
#if defined(__GNUC__) && !defined(__clang__)
// Workaround for gcc (11+) that fails to handle tensor dot vector
__attribute__((optimize("no-tree-vectorize")))
#endif
inline Tensor<Cmpt>
operator&(const Tensor<Cmpt>& t1, const SphericalTensor<Cmpt>& st2)
{
@ -1058,6 +1082,10 @@ operator-(const Tensor<Cmpt>& t1, const SymmTensor<Cmpt>& st2)
//- Inner-product between a symmetric tensor and a tensor
template<class Cmpt>
#if defined(__GNUC__) && !defined(__clang__)
// Workaround for gcc (11+) that fails to handle tensor dot vector
__attribute__((optimize("no-tree-vectorize")))
#endif
inline Tensor<Cmpt>
operator&(const SymmTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
{
@ -1080,6 +1108,10 @@ operator&(const SymmTensor<Cmpt>& st1, const Tensor<Cmpt>& t2)
//- Inner-product between a tensor and a symmetric tensor
template<class Cmpt>
#if defined(__GNUC__) && !defined(__clang__)
// Workaround for gcc (11+) that fails to handle tensor dot vector
__attribute__((optimize("no-tree-vectorize")))
#endif
inline Tensor<Cmpt>
operator&(const Tensor<Cmpt>& t1, const SymmTensor<Cmpt>& st2)
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -42,8 +42,8 @@ SourceFiles
\*---------------------------------------------------------------------------*/
#ifndef SHA1_H
#define SHA1_H
#ifndef Foam_SHA1_H
#define Foam_SHA1_H
#include <string>
#include <cstdint>
@ -113,6 +113,9 @@ public:
//- Reset the hashed data before appending more
void clear();
//- Append single character
inline void append(char c);
//- Append data for processing
inline SHA1& append(const char* str);

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -53,6 +53,12 @@ inline Foam::SHA1::SHA1(const std::string& str)
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline void Foam::SHA1::append(char c)
{
processBytes(&c, 1);
}
inline Foam::SHA1& Foam::SHA1::append(const char* data, size_t len)
{
processBytes(data, len);

View File

@ -29,6 +29,7 @@ License
#include "word.H"
#include "debug.H"
#include <cctype>
#include <cstdint>
#include <sstream>
// * * * * * * * * * * * * * * Static Data Members * * * * * * * * * * * * * //

View File

@ -969,7 +969,17 @@ void Foam::UPstream::allocatePstreamCommunicator
void Foam::UPstream::freePstreamCommunicator(const label communicator)
{
if (communicator != UPstream::worldComm)
// Not touching the first communicator (WORLD)
// or anything out-of bounds.
//
// No UPstream communicator indices when MPI is initialized outside
// of OpenFOAM - thus needs a bounds check too!
if
(
communicator > 0
&& (communicator < PstreamGlobals::MPICommunicators_.size())
)
{
if (PstreamGlobals::MPICommunicators_[communicator] != MPI_COMM_NULL)
{

View File

@ -20,8 +20,8 @@ starcd/STARCDMeshWriter.C
polyDualMesh/polyDualMesh.C
vtk/output/foamVtkInternalWriter.H
vtk/output/foamVtkPatchWriter.H
vtk/output/foamVtkInternalWriter.C
vtk/output/foamVtkPatchWriter.C
vtk/output/foamVtkSurfaceFieldWriter.C
LIB = $(FOAM_LIBBIN)/libconversion

View File

@ -111,10 +111,7 @@ Foam::zeroGradientFaPatchField<Type>::valueInternalCoeffs
const tmp<scalarField>&
) const
{
return tmp<Field<Type>>
(
new Field<Type>(this->size(), Zero)
);
return tmp<Field<Type>>::New(this->size(), pTraits<Type>::one);
}
@ -125,10 +122,7 @@ Foam::zeroGradientFaPatchField<Type>::valueBoundaryCoeffs
const tmp<scalarField>&
) const
{
return tmp<Field<Type>>
(
new Field<Type>(this->size(), Zero)
);
return tmp<Field<Type>>::New(this->size(), Zero);
}
@ -136,10 +130,7 @@ template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::zeroGradientFaPatchField<Type>::gradientInternalCoeffs() const
{
return tmp<Field<Type>>
(
new Field<Type>(this->size(), Zero)
);
return tmp<Field<Type>>::New(this->size(), Zero);
}
@ -147,10 +138,7 @@ template<class Type>
Foam::tmp<Foam::Field<Type>>
Foam::zeroGradientFaPatchField<Type>::gradientBoundaryCoeffs() const
{
return tmp<Field<Type>>
(
new Field<Type>(this->size(), Zero)
);
return tmp<Field<Type>>::New(this->size(), Zero);
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2010-2018 Bernhard Gschaider <bgschaid@hfd-research.com>
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -261,7 +261,14 @@ Foam::tmp<GeomField> Foam::expressions::fvExprDriver::getOrReadFieldImpl
tfield.reset
(
GeomField::New(name, meshRef, dimensioned<Type>(Zero))
GeomField::New
(
name,
meshRef,
dimensioned<Type>(Zero),
// Patch is zeroGradient (volFields) or calculated (other)
defaultBoundaryType(GeomField::null())
)
);
GeomField& fld = tfield.ref();

View File

@ -5,8 +5,8 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Original code Copyright (C) 2011-2018 Bernhard Gschaider
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2011-2018 Bernhard Gschaider
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -31,6 +31,7 @@ License
#include "fvMesh.H"
#include "fvPatch.H"
#include "pointMesh.H"
#include "stringOps.H"
// * * * * * * * * * * * * * Static Member Functions * * * * * * * * * * * * //
@ -118,7 +119,6 @@ Foam::expressions::patchExprFieldBase::patchExprFieldBase
else
{
// No gradient expression - same as Zero
if (debug_)
{
Info<< "No gradientExpr" << nl;
@ -127,7 +127,14 @@ Foam::expressions::patchExprFieldBase::patchExprFieldBase
if (dict.readIfPresent("fractionExpr", expr))
{
if (!expr.empty() && expr != "0")
stringOps::inplaceTrim(expr);
if (expr == "0" || expr == "1")
{
// Special cases, handled with more efficiency
fracExpr_ = expr;
}
else if (!expr.empty())
{
if (isPointVal)
{
@ -137,11 +144,9 @@ Foam::expressions::patchExprFieldBase::patchExprFieldBase
fracExpr_ = expressions::exprString(expr, dict);
}
}
else
{
// No fraction expression - same as 1 (one)
// Mixed BC may elect to simply ignore gradient expression
}
// No fraction expression? - defer treatment to inherited BC
// Mixed BC may elect to simply ignore gradient expression
}
}

View File

@ -5,8 +5,8 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Original code Copyright (C) 2009-2018 Bernhard Gschaider
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2009-2018 Bernhard Gschaider
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -89,7 +89,7 @@ Foam::exprFixedValueFvPatchField<Type>::exprFixedValueFvPatchField
setDebug();
DebugInFunction << nl;
// Basic sanity
// Require valueExpr
if (this->valueExpr_.empty())
{
FatalIOErrorInFunction(dict)
@ -97,6 +97,7 @@ Foam::exprFixedValueFvPatchField<Type>::exprFixedValueFvPatchField
<< exit(FatalIOError);
}
driver_.readDict(dict);
if (dict.found("value"))
@ -110,11 +111,12 @@ Foam::exprFixedValueFvPatchField<Type>::exprFixedValueFvPatchField
{
(*this) == this->patchInternalField();
#ifdef FULLDEBUG
WarningInFunction
<< "No value defined for "
<< this->internalField().name() << " on "
<< this->patch().name() << " - setting to internalField value "
<< nl;
<< this->patch().name() << " - using patch internal field" << endl;
#endif
}
if (this->evalOnConstruct_)
@ -161,31 +163,29 @@ Foam::exprFixedValueFvPatchField<Type>::exprFixedValueFvPatchField
template<class Type>
void Foam::exprFixedValueFvPatchField<Type>::updateCoeffs()
{
if (debug)
{
InfoInFunction
<< "Value: " << this->valueExpr_ << nl
<< "Variables: ";
driver_.writeVariableStrings(Info) << endl;
}
if (this->updated())
{
return;
}
DebugInFunction
<< "updating" << nl;
if (debug)
{
InfoInFunction
<< "Value: " << this->valueExpr_ << nl
<< "Variables: ";
driver_.writeVariableStrings(Info) << nl;
Info<< "... updating" << endl;
}
// Expression evaluation
{
bool evalValue = (!this->valueExpr_.empty() && this->valueExpr_ != "0");
driver_.clearVariables();
if (this->valueExpr_.empty())
{
(*this) == Zero;
}
else
if (evalValue)
{
tmp<Field<Type>> tresult(driver_.evaluate<Type>(this->valueExpr_));
@ -196,6 +196,10 @@ void Foam::exprFixedValueFvPatchField<Type>::updateCoeffs()
(*this) == tresult;
}
else
{
(*this) == Zero;
}
}
fixedValueFvPatchField<Type>::updateCoeffs();

View File

@ -5,8 +5,8 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Original code Copyright (C) 2009-2018 Bernhard Gschaider
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2009-2018 Bernhard Gschaider
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -91,20 +91,51 @@ Foam::exprMixedFvPatchField<Type>::exprMixedFvPatchField
setDebug();
DebugInFunction << nl;
// Basic sanity checks
// Require one or both of valueExpr, gradientExpr
if (this->valueExpr_.empty() && this->gradExpr_.empty())
{
if (this->valueExpr_.empty())
FatalIOErrorInFunction(dict)
<< "For " << this->internalField().name() << " on "
<< this->patch().name() << nl
<< "Require either or both: valueExpr and gradientExpr" << nl
<< exit(FatalIOError);
}
if (this->fracExpr_.empty())
{
// No fractionExpr. Expect only one of valueExpr or gradientExpr
if (!this->valueExpr_.empty() && !this->gradExpr_.empty())
{
FatalIOErrorInFunction(dict)
<< "The valueExpr was not defined!" << nl
<< exit(FatalIOError);
IOWarningInFunction(dict)
<< "For " << this->internalField().name() << " on "
<< this->patch().name() << nl
<< "Recommend using fractionExpr when specifying both"
<< " valueExpr and gradientExpr. Assuming a value of 1."
<< nl << endl;
}
}
else if (this->fracExpr_ == "0")
{
// Gradient only. Expect gradientExpr
if (this->gradExpr_.empty())
{
FatalIOErrorInFunction(dict)
<< "The gradientExpr was not defined!" << nl
<< exit(FatalIOError);
IOWarningInFunction(dict)
<< "For " << this->internalField().name() << " on "
<< this->patch().name() << nl
<< "Gradient only, but did not specify gradientExpr."
<< nl << endl;
}
}
else if (this->fracExpr_ == "1")
{
// Value only. Expect valueExpr
if (this->valueExpr_.empty())
{
IOWarningInFunction(dict)
<< "For " << this->internalField().name() << " on "
<< this->patch().name() << nl
<< "Value only, but did not specify valueExpr."
<< nl << endl;
}
}
@ -114,14 +145,12 @@ Foam::exprMixedFvPatchField<Type>::exprMixedFvPatchField
// Similar to fvPatchField constructor, which we have bypassed
dict.readIfPresent("patchType", this->patchType());
bool needsRefValue = true;
if (dict.found("refValue"))
{
needsRefValue = false;
this->refValue() = Field<Type>("refValue", dict, p.size());
}
else
{
this->refValue() = this->patchInternalField();
}
if (dict.found("value"))
{
@ -130,22 +159,27 @@ Foam::exprMixedFvPatchField<Type>::exprMixedFvPatchField
Field<Type>("value", dict, p.size())
);
if (!dict.found("refValue"))
if (needsRefValue)
{
// Ensure refValue has a sensible value for the "update" below
this->refValue() = Field<Type>("value", dict, p.size());
this->refValue() = static_cast<const Field<Type>&>(*this);
}
}
else
{
if (needsRefValue)
{
this->refValue() = this->patchInternalField();
}
fvPatchField<Type>::operator=(this->refValue());
#ifdef FULLDEBUG
WarningInFunction
<< "No value defined for "
<< this->internalField().name()
<< " on " << this->patch().name() << " therefore using "
<< "the internal field next to the patch"
<< endl;
<< this->internalField().name() << " on "
<< this->patch().name() << " - using patch internal field" << endl;
#endif
}
@ -164,7 +198,7 @@ Foam::exprMixedFvPatchField<Type>::exprMixedFvPatchField
}
else
{
this->valueFraction() = 1;
this->valueFraction() = scalar(1);
}
@ -234,6 +268,11 @@ Foam::exprMixedFvPatchField<Type>::exprMixedFvPatchField
template<class Type>
void Foam::exprMixedFvPatchField<Type>::updateCoeffs()
{
if (this->updated())
{
return;
}
if (debug)
{
InfoInFunction
@ -241,45 +280,67 @@ void Foam::exprMixedFvPatchField<Type>::updateCoeffs()
<< "Gradient: " << this->gradExpr_ << nl
<< "Fraction: " << this->fracExpr_ << nl
<< "Variables: ";
driver_.writeVariableStrings(Info) << endl;
driver_.writeVariableStrings(Info) << nl;
Info<< "... updating" << endl;
}
if (this->updated())
{
return;
}
DebugInFunction << " - updating" << nl;
// Expression evaluation
{
driver_.clearVariables();
bool evalValue = (!this->valueExpr_.empty() && this->valueExpr_ != "0");
bool evalGrad = (!this->gradExpr_.empty() && this->gradExpr_ != "0");
bool evalFrac = (!this->fracExpr_.empty());
scalar fraction = 1;
// Have one or both of valueExpr, gradientExpr (checked in constructor)
if (this->valueExpr_.empty())
{
this->refValue() = Zero;
// No value expression -> gradient only
fraction = 0;
evalValue = false;
evalFrac = false;
}
else
{
this->refValue() = driver_.evaluate<Type>(this->valueExpr_);
}
bool evalGrad = !this->gradExpr_.empty();
if (this->fracExpr_.empty() || this->fracExpr_ == "1")
else if (this->gradExpr_.empty())
{
// No gradient expression -> value only
fraction = 1;
evalGrad = false;
this->valueFraction() = scalar(1);
evalFrac = false;
}
else if (this->fracExpr_.empty())
{
// No fractionExpr, but has both valueExpr and gradientExpr
// -> treat as value only (warning in constructor)
fraction = 1;
evalGrad = false;
evalFrac = false;
}
else if (this->fracExpr_ == "0")
{
this->valueFraction() = Zero;
// Gradient only
fraction = 0;
evalValue = false;
evalFrac = false;
}
else if (this->fracExpr_ == "1")
{
// Value only
fraction = 1;
evalGrad = false;
evalFrac = false;
}
driver_.clearVariables();
if (evalValue)
{
this->refValue() = driver_.evaluate<Type>(this->valueExpr_);
}
else
{
this->valueFraction() = driver_.evaluate<scalar>(this->fracExpr_);
this->refValue() = Zero;
}
if (evalGrad)
@ -290,6 +351,15 @@ void Foam::exprMixedFvPatchField<Type>::updateCoeffs()
{
this->refGrad() = Zero;
}
if (evalFrac)
{
this->valueFraction() = driver_.evaluate<scalar>(this->fracExpr_);
}
else
{
this->valueFraction() = fraction;
}
}
mixedFvPatchField<Type>::updateCoeffs();

View File

@ -55,7 +55,7 @@ Usage
(100.0 1.0)
);
patch
refValue
{
type fixedValue;
value uniform (15 0 0);

View File

@ -166,35 +166,38 @@ Foam::turbulentDigitalFilterInletFvPatchVectorField::patchIndexPairs()
void Foam::turbulentDigitalFilterInletFvPatchVectorField::
checkRTensorRealisable() const
{
const vectorField& faceCentres = this->patch().patch().faceCentres();
label badFacei = -1;
forAll(R_, facei)
{
if (R_[facei].xx() <= 0)
{
badFacei = facei;
FatalErrorInFunction
<< "Reynolds stress tensor component Rxx cannot be negative"
"or zero, where Rxx = " << R_[facei].xx() << " at the face "
"centre = " << faceCentres[facei] << exit(FatalError);
<< " or zero, where Rxx = " << R_[facei].xx();
break;
}
if (R_[facei].yy() < 0 || R_[facei].zz() < 0)
{
badFacei = facei;
FatalErrorInFunction
<< "Reynolds stress tensor components Ryy or Rzz cannot be"
<< "negative where Ryy = " << R_[facei].yy() << ", and Rzz = "
<< R_[facei].zz() << " at the face centre = "
<< faceCentres[facei] << exit(FatalError);
<< " negative where Ryy = " << R_[facei].yy()
<< ", and Rzz = " << R_[facei].zz();
break;
}
scalar term0 = R_[facei].xx()*R_[facei].yy() - sqr(R_[facei].xy());
if (term0 <= 0)
{
badFacei = facei;
FatalErrorInFunction
<< "Reynolds stress tensor component group, Rxx*Ryy - Rxy^2"
<< "cannot be negative or zero at the face centre = "
<< faceCentres[facei] << exit(FatalError);
<< " cannot be negative or zero";
break;
}
scalar term1 = R_[facei].zz() - sqr(R_[facei].xz())/R_[facei].xx();
@ -205,18 +208,24 @@ checkRTensorRealisable() const
if (term3 < 0)
{
badFacei = facei;
FatalErrorInFunction
<< "Reynolds stress tensor component group,"
<< "Reynolds stress tensor component group, "
<< "Rzz - Rxz^2/Rxx - (Ryz - Rxy*Rxz/(Rxx*(Rxx*Ryy - Rxy^2)))^2"
<< "cannot be negative at the face centre = "
<< faceCentres[facei] << exit(FatalError);
<< " cannot be negative";
break;
}
}
#ifdef FULLDEBUG
Info<< "Ends: checkRTensorRealisable()."
<< " Reynolds tensor (on patch) is consistent." << nl;
#endif
if (badFacei >= 0)
{
FatalError
<< " at the face centre = "
<< this->patch().patch().faceCentres()[badFacei]
<< exit(FatalError);
}
Info<< " # Reynolds stress tensor on patch is consistent #" << endl;
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -68,7 +68,7 @@ Foam::surfaceInterpolationScheme<Type>::New
"discretisation",
schemeName,
*MeshConstructorTablePtr_
) << exit(FatalError);
) << exit(FatalIOError);
}
return cstrIter()(mesh, schemeData);

View File

@ -280,9 +280,18 @@ void Foam::externalCoupledTemperatureMixedFvPatchScalarField::writeData
const scalarField Tfluid(tfluid);
// Heat transfer coefficient [W/m2/K]
const scalarField htc(qDot/(max(Twall - Tfluid), 1e-3));
// This htc needs to be always larger or equal to zero
//const scalarField htc(qDot/max(Twall - Tfluid, 1e-3));
scalarField htc(qDot.size(), 0);
forAll (qDot, i)
{
scalar deltaT = mag(Twall[i] - Tfluid[i]);
if (deltaT > 1e-3)
{
htc[i] = sign(qDot[i])*qDot[i]/deltaT;
}
}
const Field<scalar>& magSf = this->patch().magSf();

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2017-2019 OpenCFD Ltd.
Copyright (C) 2017-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -892,6 +892,16 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::read
mesh_,
dict.subDict("sampledSurfaceDict")
);
if (sampledPtr_->interpolate())
{
// Should probably ignore interpolate entirely,
// but the oldest isoSurface algorithm requires it!
WarningInFunction
<< type() << ' ' << name() << ": "
<< "sampledSurface with interpolate = true "
<< "is likely incorrect" << nl << nl;
}
}
Info<< type() << " " << name() << ":" << nl

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2015-2019 OpenCFD Ltd.
Copyright (C) 2015-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -388,6 +388,15 @@ bool Foam::functionObjects::fieldValues::surfaceFieldValue::writeValues
false // serial - already merged
);
// Point data? Should probably disallow
if (sampledPtr_)
{
surfaceWriterPtr_->isPointData() =
sampledPtr_->interpolate();
}
surfaceWriterPtr_->nFields() = 1; // Needed for VTK legacy
surfaceWriterPtr_->write(fieldName, allValues);
surfaceWriterPtr_->clear();

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2017 OpenCFD Ltd.
Copyright (C) 2017-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -81,10 +81,10 @@ Foam::heatTransferCoeffModels::ReynoldsAnalogy::Cp(const label patchi) const
const label n = mesh_.boundary()[patchi].size();
return tmp<Field<scalar>>::New(n, CpRef_);
}
else if (mesh_.foundObject<fluidThermo>(fluidThermo::typeName))
else if (mesh_.foundObject<fluidThermo>(fluidThermo::dictName))
{
const fluidThermo& thermo =
mesh_.lookupObject<fluidThermo>(fluidThermo::typeName);
mesh_.lookupObject<fluidThermo>(fluidThermo::dictName);
const scalarField& pp = thermo.p().boundaryField()[patchi];
const scalarField& Tp = thermo.T().boundaryField()[patchi];

View File

@ -79,7 +79,7 @@ void Foam::functionObjects::nearWallFields::calcAddressing()
const vectorField nf(patch.nf());
const vectorField faceCellCentres(patch.patch().faceCellCentres());
const labelUList& faceCells = patch.patch().faceCells();
const vectorField::subField& faceCentres = patch.patch().faceCentres();
const vectorField::subField faceCentres = patch.patch().faceCentres();
forAll(patch, patchFacei)
{

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2015-2019 OpenCFD Ltd.
Copyright (C) 2015-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -530,17 +530,13 @@ void Foam::functionObjects::forces::addToFields
return;
}
volVectorField& force =
lookupObjectRef<volVectorField>(fieldName("force"));
auto& force = lookupObjectRef<volVectorField>(fieldName("force"));
vectorField& pf = force.boundaryFieldRef()[patchi];
pf += fN + fT + fP;
volVectorField& moment =
lookupObjectRef<volVectorField>(fieldName("moment"));
auto& moment = lookupObjectRef<volVectorField>(fieldName("moment"));
vectorField& pm = moment.boundaryFieldRef()[patchi];
pm += Md;
pm = Md^pf;
}
@ -558,17 +554,14 @@ void Foam::functionObjects::forces::addToFields
return;
}
volVectorField& force =
lookupObjectRef<volVectorField>(fieldName("force"));
volVectorField& moment =
lookupObjectRef<volVectorField>(fieldName("moment"));
auto& force = lookupObjectRef<volVectorField>(fieldName("force"));
auto& moment = lookupObjectRef<volVectorField>(fieldName("moment"));
forAll(cellIDs, i)
{
label celli = cellIDs[i];
force[celli] += fN[i] + fT[i] + fP[i];
moment[celli] += Md[i];
moment[celli] = Md[i]^force[celli];
}
}

View File

@ -419,8 +419,6 @@ void Foam::ParticleCollector<CloudType>::write()
massTotal_[facei] += mass_[facei];
}
const label proci = Pstream::myProcNo();
Info<< type() << " output:" << nl;
Field<scalar> faceMassTotal(mass_.size(), Zero);
@ -434,15 +432,11 @@ void Foam::ParticleCollector<CloudType>::write()
scalar sumAverageMFR = 0.0;
forAll(faces_, facei)
{
scalarList allProcMass(Pstream::nProcs());
allProcMass[proci] = massTotal_[facei];
Pstream::gatherList(allProcMass);
faceMassTotal[facei] += sum(allProcMass);
faceMassTotal[facei] +=
returnReduce(massTotal_[facei], sumOp<scalar>());
scalarList allProcMassFlowRate(Pstream::nProcs());
allProcMassFlowRate[proci] = massFlowRate_[facei];
Pstream::gatherList(allProcMassFlowRate);
faceMassFlowRate[facei] += sum(allProcMassFlowRate);
faceMassFlowRate[facei] +=
returnReduce(massFlowRate_[facei], sumOp<scalar>());
sumTotalMass += faceMassTotal[facei];
sumAverageMFR += faceMassFlowRate[facei];

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -129,6 +129,11 @@ Foam::Istream& Foam::operator>>(Istream& is, gradingDescriptor& gd)
is.readEnd("gradingDescriptor");
}
if (gd.expansionRatio_ < 0)
{
gd.expansionRatio_ = 1.0/(-gd.expansionRatio_);
}
is.check(FUNCTION_NAME);
return is;
}

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015 OpenFOAM Foundation
Copyright (C) 2016-2017 OpenCFD Ltd.
Copyright (C) 2016-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -396,22 +396,43 @@ Foam::AABBTree<Type>::AABBTree
// transfer flattened tree to persistent storage
DynamicList<treeBoundBox> boundBoxes(2*bbs.size());
DynamicList<labelList> addressing(2*addr.size());
forAll(nodes, nodeI)
{
if (nodes[nodeI].first() < 0)
{
boundBoxes.append(bbs[nodeI].first());
addressing.append(addr[nodeI + 1]);
addressing.append(addr[-(nodes[nodeI].first() + 1)]);
}
if (nodes[nodeI].second() < 0)
{
boundBoxes.append(bbs[nodeI].second());
addressing.append(addr[nodeI + 1]);
addressing.append(addr[-(nodes[nodeI].second() + 1)]);
}
}
boundBoxes_.transfer(boundBoxes);
addressing_.transfer(addressing);
if (0)
{
bitSet checked(objects.size());
for (const auto& box : addressing_)
{
for (const auto& id : box)
{
checked.set(id);
}
}
const label unsetSize = checked.count(false);
if (unsetSize)
{
Info<< "*** Problem: IDs not set: " << unsetSize << endl;
}
}
}

View File

@ -142,8 +142,7 @@ public:
AABBTree();
//- Construct from components
// equalBinSize: divide into equal number of elements or
// equal span
// equalBinSize: divide into equal number of elements or equal span
AABBTree
(
const UList<Type>& objects,
@ -171,7 +170,7 @@ public:
bool pointInside(const point& pt) const;
//- Determine whether a bounding box overlaps the tree bounding
// boxes
//- boxes
bool overlaps(const boundBox& bbIn) const;

View File

@ -155,7 +155,7 @@ bool Foam::vtk::writePointSet
if (parallel)
{
vtk::writeListParallel(format(), mesh.points(), pointLabels);
vtk::writeListParallel(format.ref(), mesh.points(), pointLabels);
}
else
{

View File

@ -290,6 +290,7 @@ Foam::scalar surfaceNoise::writeSurfaceData
false // serial - already merged
);
writerPtr_->nFields() = 1; // Legacy VTK
writerPtr_->write(title, allData);
writerPtr_->endTime();
@ -321,6 +322,7 @@ Foam::scalar surfaceNoise::writeSurfaceData
false // serial - already merged
);
writerPtr_->nFields() = 1; // Legacy VTK
writerPtr_->write(title, data);
writerPtr_->endTime();

View File

@ -155,7 +155,7 @@ void Foam::meshToMesh::mapInternalTgtToSrc
const bool secondOrder
) const
{
mapSrcToTgt(field, cop, result.primitiveFieldRef());
mapTgtToSrc(field, cop, result.primitiveFieldRef());
}
@ -168,7 +168,7 @@ void Foam::meshToMesh::mapInternalTgtToSrc
const bool secondOrder
) const
{
mapSrcToTgt(field, cop, result.primitiveFieldRef());
mapTgtToSrc(field, cop, result.primitiveFieldRef());
}
@ -181,7 +181,7 @@ void Foam::meshToMesh::mapInternalTgtToSrc
const bool secondOrder
) const
{
mapSrcToTgt(field, cop, result.primitiveFieldRef());
mapTgtToSrc(field, cop, result.primitiveFieldRef());
}
@ -194,7 +194,7 @@ void Foam::meshToMesh::mapInternalTgtToSrc
const bool secondOrder
) const
{
mapSrcToTgt(field, cop, result.primitiveFieldRef());
mapTgtToSrc(field, cop, result.primitiveFieldRef());
}
@ -207,7 +207,7 @@ void Foam::meshToMesh::mapInternalTgtToSrc
const bool secondOrder
) const
{
mapSrcToTgt(field, cop, result.primitiveFieldRef());
mapTgtToSrc(field, cop, result.primitiveFieldRef());
}
@ -220,7 +220,7 @@ void Foam::meshToMesh::mapInternalTgtToSrc
const bool secondOrder
) const
{
mapSrcToTgt(field, cop, result.primitiveFieldRef());
mapTgtToSrc(field, cop, result.primitiveFieldRef());
}

View File

@ -875,15 +875,15 @@ Foam::meshToMesh::mapTgtToSrc
label srcPatchi = srcPatchID_[i];
label tgtPatchi = tgtPatchID_[i];
if (!srcPatchFields.set(tgtPatchi))
if (!srcPatchFields.set(srcPatchi))
{
srcPatchFields.set
(
srcPatchi,
fvPatchField<Type>::New
(
tgtBfld[srcPatchi],
srcMesh.boundary()[tgtPatchi],
tgtBfld[tgtPatchi],
srcMesh.boundary()[srcPatchi],
DimensionedField<Type, volMesh>::null(),
directFvPatchFieldMapper
(

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -107,7 +107,7 @@ void Foam::polySurface::storeField
if (dimfield)
{
dimfield->dimensions() = dims;
dimfield->dimensions().reset(dims); // Dimensions may have changed
dimfield->field() = values;
}
else
@ -148,7 +148,7 @@ void Foam::polySurface::storeField
if (dimfield)
{
dimfield->dimensions() = dims;
dimfield->dimensions().reset(dims); // Dimensions may have changed
dimfield->field() = std::move(values);
}
else

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2022 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -45,7 +45,7 @@ void Foam::surfMesh::storeField
if (dimfield)
{
dimfield->dimensions() = dims;
dimfield->dimensions().reset(dims); // Dimensions may have changed
dimfield->field() = values;
}
else
@ -85,7 +85,7 @@ void Foam::surfMesh::storeField
if (dimfield)
{
dimfield->dimensions() = dims;
dimfield->dimensions().reset(dims); // Dimensions may have changed
dimfield->field() = std::move(values);
}
else

View File

@ -5,7 +5,7 @@
\\ / A nd | www.openfoam.com
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2021 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -416,11 +416,11 @@ bool Foam::surfaceWriter::empty() const
Foam::label Foam::surfaceWriter::size() const
{
const bool value =
const label value =
(
useComponents_
? surfComp_.faces().empty()
: surf_.get().faces().empty()
? surfComp_.faces().size()
: surf_.get().faces().size()
);
return (parallel_ ? returnReduce(value, sumOp<label>()) : value);

View File

@ -275,7 +275,7 @@ Foam::basicThermo::basicThermo
(
IOobject
(
"thermo:alpha",
phasePropertyName("thermo:alpha"),
mesh.time().timeName(),
mesh,
IOobject::READ_IF_PRESENT,

View File

@ -140,17 +140,6 @@ Foam::radiation::radiativeIntensityRay::radiativeIntensityRay
if (mesh_.nSolutionD() == 2)
{
// Omega for 2D
omega_ = deltaPhi;
// dAve for 2D
dAve_ = vector
(
2*sinPhi*Foam::sin(0.5*deltaPhi),
2*cosPhi*Foam::sin(0.5*deltaPhi),
0
);
vector meshDir(Zero);
if (dom_.meshOrientation() != vector::zero)
{
@ -172,7 +161,6 @@ Foam::radiation::radiativeIntensityRay::radiativeIntensityRay
dAve_ = coordRot & dAve_;
d_ = coordRot & d_;
}
else if (mesh_.nSolutionD() == 1)
{
@ -195,9 +183,6 @@ Foam::radiation::radiativeIntensityRay::radiativeIntensityRay
dAve_ = (dAve_ & normal)*meshDir;
d_ = (d_ & normal)*meshDir;
// Omega normalization for 1D
omega_ /= 2;
}
autoPtr<volScalarField> IDefaultPtr;

View File

@ -136,7 +136,7 @@ void Foam::faceReflecting::initialise(const dictionary& coeffs)
forAll(patches, patchI)
{
const polyPatch& pp = patches[patchI];
const pointField& cf = pp.faceCentres();
const vectorField::subField cf = pp.faceCentres();
if (!pp.coupled() && !isA<cyclicAMIPolyPatch>(pp))
{

View File

@ -155,7 +155,7 @@ void Foam::faceShading::calculate()
forAll(patches, patchI)
{
const polyPatch& pp = patches[patchI];
const pointField& cf = pp.faceCentres();
const vectorField::subField cf = pp.faceCentres();
if (!pp.coupled() && !isA<cyclicAMIPolyPatch>(pp))
{

Some files were not shown because too many files have changed in this diff Show More