Compare commits

...

40 Commits

Author SHA1 Message Date
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
55b49ac0d0 CONFIG: bump patch level 2020-04-06 08:34:58 +02:00
a8b6d01b87 CONFIG: relocate wmake binaries into project platforms/tools (#1647)
- can aid when creating source-only or binary-only packages
2020-04-06 08:32:42 +02:00
8075804b18 COMP: add -pthread compile/link dependency for std::thread (#614) 2020-04-06 08:30:11 +02:00
a88e67f2e1 BUG: potential divide-by-zero in x3d surface output (#1212)
- eg, for a uniform field and auto range.
2020-04-03 15:38:58 +02:00
b4229841c0 BUG: Extension of commit d16f1312cb 2020-04-03 09:30:43 +01:00
d16f1312cb BUG: P1 model - read qr field if present - see #1659 2020-04-01 10:29:28 +01:00
ba8d45c82d CONFIG: forces.cfg - updated output controls. See #1642 2020-03-18 18:21:32 +00:00
80e4033810 CONFIG: bump patch level 2020-03-16 14:56:50 +01:00
794ab39742 BUG: missing output for foamDictionary -includes (closes #1635)
- log to stdout when explicitly enabled
2020-03-16 14:54:25 +01:00
fe17c8ad5f CONFIG: improve prefix matching for system libraries (#1607)
- missed detection of system libraries when installed with multiarch
  paths like /usr/lib/x86_64-linux-gnu

CONFIG: improve handling of group/user config files (#928)

- changed bashrc handling of FOAM_CONFIG_NOUSER to use
  FOAM_CONFIG_MODE instead. Propagate into foamEtcFile to make this
  a stickier control.

  This change allows better control, but also enables cluster
  installations to define their own value within the OpenFOAM prefs.sh
  file to prevent users accidentally mis-configuring things if
  necessary.

- remove undocumented handling of an (a)ll mode in foamEtcFile to
  avoid potential pitfalls.

- add support for FOAM_CONFIG_ETC handling.
  This allows injection of an extra search layer when finding
  project etc files

ENH: improvements to foamConfigurePaths (#928)

- handle FOAM_CONFIG_ETC implicitly, or explicitly with the new
  -etc option.

STYLE: more explicit wording in foamConfigurePaths usage (#1602)

- document that an absolute path (eg, -scotch-path) overrides/ignores
  the equivalent ThirdParty setting (eg, -scotch)

- longer options -system-compiler and -third-compiler for -system
  and -third, respectively. Clearer as to their purpose.

- adjust the location sanity check to look for META-INFO directory.
2020-03-16 12:03:58 +01:00
ac8b64df46 CONFIG: support FOAM_EXTRA_CXXFLAGS (#1256)
- allows custom tuning of compilation parameters
2020-03-16 12:03:58 +01:00
ba3a31af95 ENH: openfoam shell session - improved and relocated
- '-c' option (as per shell), '-Dkey[=value]' option to provide
  preferences via the command-line. For example,

      etc/openfoam -DWM_COMPILER=Clang -int64  ./Allwmake -j -s -l

  These can also be combined with other options. Eg,

      etc/openfoam -DWM_COMPILER=Clang \
          -c 'wmake -show-path-cxx -show-cxxflags'

- relocated from bin/tools/ => etc/ for easier access

- bin/tools/openfoam.in : for autoconfig-style installation

- Auto-detect if the shell script was executed with openfoam and
  interpret accordingly.

  Simple example,

      --------------
      #!/usr/bin/openfoam
      cd "${0%/*}" || exit   # Run -*-sh-*- from this dir

      blockMesh
      simpleFoam
      --------------

   Note it is NOT currently possible to provide any other parameters
   this way. Eg,

      `#!/usr/bin/openfoam -sp` (NOT)

   This will either fail to run, or result in infinite recursion.
2020-03-16 12:03:57 +01:00
69a61bf835 BUG: objToVTK - corrected for empty lines in obj file. See #1632 2020-03-16 10:21:34 +00:00
989fda3b18 BUG: BSpline - only snap to points at ends and not intermediate knots. See #1628 2020-03-13 10:43:10 +00:00
129 changed files with 3192 additions and 2240 deletions

View File

@ -86,8 +86,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=200312
patch=200626

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.
@ -128,6 +128,8 @@ int main(int argc, char *argv[])
std::ifstream OBJfile(objName);
Info<< "Processing file " << objName << endl;
if (!OBJfile.good())
{
FatalErrorInFunction
@ -145,13 +147,14 @@ int main(int argc, char *argv[])
label lineNo = 0;
while (OBJfile.good())
{
string line = getLine(OBJfile);
const string line = getLine(OBJfile);
lineNo++;
if (line.empty()) continue;
// Read first word
IStringStream lineStream(line);
word cmd;
lineStream >> cmd;
word cmd(lineStream);
if (cmd == "v")
{

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

@ -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'.
@ -33,7 +32,13 @@
# \endcode
#
# Environment
# - WM_PROJECT_SITE (unset defaults to PROJECT/site)
# FOAM_CONFIG_ETC
# Alternative etc directory for shipped files
#
# FOAM_CONFIG_MODE
# Fallback search mode for etc files. Unset is the same as "ugo".
#
# WM_PROJECT_SITE (unset defaults to PROJECT/site)
#
# Note
# This script must exist in the project 'bin' directory
@ -46,8 +51,8 @@
printHelp() {
cat<<USAGE
Usage: foamEtcFile [OPTION] fileName [-- args]
foamEtcFile [OPTION] [-list|-list-test] [fileName]
Usage: ${0##*/} [OPTION] fileName [-- args]
${0##*/} [OPTION] [-list|-list-test] [fileName]
options:
-all (-a) Return all files (otherwise stop after the first match)
@ -61,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
@ -106,64 +111,40 @@ projectDir="$(\cd $(dirname $binDir) && \pwd -L)" # Project dir
userDir="$HOME/.OpenFOAM" # As per foamVersion.H
groupDir="${WM_PROJECT_SITE:-$projectDir/site}" # As per foamVersion.H
optMode=ugo # Default search = 'ugo'
# Environment overrides
case "$FOAM_CONFIG_MODE" in ([ugo]*) optMode="$FOAM_CONFIG_MODE" ;; esac
# Verify validity of FOAM_CONFIG_ETC
if [ -n "$FOAM_CONFIG_ETC" ]
then
if [ ! -d "$FOAM_CONFIG_ETC" ] || [ "$FOAM_CONFIG_ETC" = "$projectDir/etc" ]
then
# Bad directory or redundant value
unset FOAM_CONFIG_ETC
fi
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
}
#-------------------------------------------------------------------------------
optMode=ugo # Default mode is always 'ugo'
unset shellOutput verboseOutput
unset optAll optConfig optList projectApi
@ -174,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=*)
@ -208,7 +187,7 @@ do
-config)
optConfig=true
;;
-mode=[ugoa]*)
-mode=[ugo]*)
optMode="${1#*=}"
;;
-m | -mode)
@ -216,7 +195,7 @@ do
shift
# Sanity check. Handles missing argument too.
case "$optMode" in
([ugoa]*)
([ugo]*)
;;
(*)
die "invalid mode '$optMode'"
@ -257,8 +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)
@ -293,23 +271,23 @@ fi
# Define the various places to be searched:
unset dirList
case "$optMode" in (*[au]*) # (A)ll or (U)ser
case "$optMode" in (*[u]*) # (U)ser
dirList="$dirList $userDir/$projectApi $userDir"
;;
esac
case "$optMode" in (*[ag]*) # (A)ll or (G)roup == site
case "$optMode" in (*[g]*) # (G)roup == site
dirList="$dirList $groupDir/$projectApi/etc $groupDir/etc"
;;
esac
case "$optMode" in (*[ao]*) # (A)ll or (O)ther == shipped
dirList="$dirList $projectDir/etc"
case "$optMode" in (*[o]*) # (O)ther == shipped
dirList="$dirList $FOAM_CONFIG_ETC $projectDir/etc"
;;
esac
set -- $dirList
[ "$#" -ge 1 ] || die "No directories to scan. Programming error?"
[ "$#" -ge 1 ] || die "No directories to scan. Programming or user error?"
exitCode=2 # Fallback is a FileNotFound error
@ -318,7 +296,7 @@ exitCode=2 # Fallback is a FileNotFound error
#
# Special handling of config.sh/ , config.csh/ directories
if [ -n "$optConfig" -a -n "$shellOutput" -a -n "$fileName" ]
if [ -n "$optConfig" ] && [ -n "$shellOutput" ] && [ -n "$fileName" ]
then
case "$shellOutput" in
csh*)

View File

@ -33,7 +33,7 @@
# or {user,site} locations and copy it into the case directory.
#
# Environment
# FOAM_API
# FOAM_CONFIG_ETC
# WM_PROJECT_DIR
# WM_PROJECT_SITE
#
@ -81,9 +81,7 @@ die()
#-------------------------------------------------------------------------------
projectDir="$WM_PROJECT_DIR" # Project dir
userDir="$HOME/.OpenFOAM" # As per foamVersion.H
groupDir="${WM_PROJECT_SITE:-$projectDir/site}" # As per foamVersion.H
projectApi="$FOAM_API"
unset projectApi
#-------------------------------------------------------------------------------
@ -163,20 +161,12 @@ then
fi
# No api specified -with-api= or from environment (FOAM_API)
if [ -z "$projectApi" ]
then
projectApi="$(foamEtcFile -show-api 2>/dev/null)"
fi
# The places to be searched.
# Like foamEtcFile, but "etc/caseDicts/" for the projectDir
# Define the various places to be searched.
# Similar to foamEtcFile, but with etc/caseDicts/ for the projectDir
# Filter out nonexistent directories later
searchDirs="${projectApi:+$userDir/$projectApi} $userDir \
${projectApi:+$groupDir/$projectApi/etc} $groupDir/etc \
$projectDir/etc/caseDicts";
searchDirs="\
$("$projectDir"/bin/foamEtcFile -list-test -mode=ug ${projectApi:+-with-api=$projectApi} 2>/dev/null) \
$("$projectDir"/bin/foamEtcFile -list -mode=o caseDicts 2>/dev/null)";
## echo "Using <$searchDirs>" 1>&2

View File

@ -7,6 +7,7 @@
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# Copyright (C) 2011-2016 OpenFOAM Foundation
# Copyright (C) 2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
@ -38,8 +39,6 @@
#------------------------------------------------------------------------------
Script="${0##*/}"
toolsDir="${0%/*}/tools"
groupDir="${WM_PROJECT_SITE:-${WM_PROJECT_DIR:-<unknown>}/site}"
userDir="$HOME/.OpenFOAM"
usage() {
exec 1>&2
@ -91,13 +90,9 @@ cat <<HELP
The value taken will be the first (non-space)word after this column.
The database ($Script.db) will taken from these locations:
.
$userDir/$FOAM_API/
$userDir/
$groupDir/$FOAM_API/etc/
$groupDir/etc/
$WM_PROJECT_DIR/etc/
$toolsDir
./
$(foamEtcFile -list | sed -e 's#^# #')
$toolsDir
option -quiet : suppresses the default information and only prints the
extracted variables.

View File

@ -7,6 +7,7 @@
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# Copyright (C) 2015-2017 OpenFOAM Foundation
# Copyright (C) 2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
@ -32,7 +33,7 @@
#
#------------------------------------------------------------------------------
Script=${0##*/}
DIR="$FOAM_ETC/codeTemplates/app"
DIR="$WM_PROJECT_DIR/etc/codeTemplates/app"
usage() {
while [ "$#" -ge 1 ]; do echo "$1"; shift; done

View File

@ -7,6 +7,7 @@
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# Copyright (C) 2015-2017 OpenFOAM Foundation
# Copyright (C) 2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
@ -32,7 +33,7 @@
#
#------------------------------------------------------------------------------
Script=${0##*/}
DIR="$FOAM_ETC/codeTemplates/BC"
DIR="$WM_PROJECT_DIR/etc/codeTemplates/BC"
usage() {
while [ "$#" -ge 1 ]; do echo "$1"; shift; done

View File

@ -7,6 +7,7 @@
# \\/ M anipulation |
#-------------------------------------------------------------------------------
# Copyright (C) 2016-2017 OpenFOAM Foundation
# Copyright (C) 2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
@ -33,7 +34,7 @@
#
#------------------------------------------------------------------------------
Script=${0##*/}
DIR="$FOAM_ETC/codeTemplates/functionObject"
DIR="$WM_PROJECT_DIR/etc/codeTemplates/functionObject"
usage() {
while [ "$#" -ge 1 ]; do echo "$1"; shift; done

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

@ -19,71 +19,26 @@
# Adjust hardcoded installation versions and paths
# in etc/{bashrc,cshrc} and etc/config.{sh,csh}/
#
# Requires
# - sed
# - bin/foamEtcFile
#
# Environment
# FOAM_CONFIG_ETC
# Alternative etc directory for shipped files
#
#------------------------------------------------------------------------------
usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
printHelp() {
usage: ${0##*/} options
Basic
-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'
Compiler
-system NAME specify 'system' compiler to use (eg, Gcc, Icc,...)
-third NAME specify 'ThirdParty' compiler to use (eg, Clang40,...)
-gcc VER specify 'default_gcc_version' for ThirdParty Gcc
-clang VER specify 'default_clang_version' for ThirdParty Clang
gmp-VERSION for ThirdParty gcc (gmp-system for system library)
mpfr-VERSION for ThirdParty gcc (mpfr-system for system library)
mpc-VERSION for ThirdParty gcc (mpc-system for system library)
MPI
-mpi NAME specify 'WM_MPLIB' type (eg, INTELMPI, etc)
-openmpi VER use ThirdParty openmpi, with version for 'FOAM_MPI'
-openmpi-system use system openmpi
-openmpi-third use ThirdParty openmpi (using default version)
Components
-adios VER specify 'adios2_version'
-adios-path DIR specify 'ADIOS2_ARCH_PATH'
-boost VER specify 'boost_version'
-boost-path DIR specify 'BOOST_ARCH_PATH'
-cgal ver specify 'cgal_version'
-cgal-path DIR specify 'CGAL_ARCH_PATH'
-cmake VER specify 'cmake_version'
-fftw VER specify 'fffw_version'
-fftw-path DIR specify 'FFTW_ARCH_PATH'
-kahip VER specify 'KAHIP_VERSION'
-kahip-path DIR specify 'KAHIP_ARCH_PATH'
-metis ver specify 'METIS_VERSION'
-metis-path DIR specify 'METIS_ARCH_PATH'
-scotch VER specify 'SCOTCH_VERSION' (eg, scotch_6.0.4)
-scotch-path DIR specify 'SCOTCH_ARCH_PATH' (eg, /opt/scotch_6.0.4)
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)
-mesa VER specify 'mesa_version' (eg, mesa-13.0.1)
Misc
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]
Adjusts hardcoded versions and installation paths (POSIX and C-shell).
Equivalent options:
-version -foamVersion --projectVersion
-archOption --archOption
@ -92,11 +47,97 @@ Equivalent options:
-paraview-path --paraviewInstall | -paraviewInstall
-scotch --scotchVersion | -scotchVersion
-scotch-path --scotchArchPath | -scotchArchPath
-system-compiler -system
-third-compiler -third
USAGE
exit 1
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 precision (WM_PRECISION_OPTION)
-int32 | -int64 label-size (WM_LABEL_SIZE)
Compiler
-system-compiler NAME The 'system' compiler to use (eg, Gcc, Clang, Icc,...)
-third-compiler NAME The 'ThirdParty' compiler to use (eg, Clang40,...)
-gcc VER The 'default_gcc_version' for ThirdParty Gcc
-clang VER The 'default_clang_version' for ThirdParty Clang
gmp-VERSION For ThirdParty gcc (gmp-system for system library)
mpfr-VERSION For ThirdParty gcc (mpfr-system for system library)
mpc-VERSION For ThirdParty gcc (mpc-system for system library)
MPI
-mpi NAME specify 'WM_MPLIB' type (eg, INTELMPI, etc)
-openmpi VER use ThirdParty openmpi, with version for 'FOAM_MPI'
-openmpi-system use system openmpi
-openmpi-third use ThirdParty openmpi (using default version)
Components versions (ThirdParty)
-adios VER specify 'adios2_version'
-boost VER specify 'boost_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'
-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)
-scotch-path DIR Path for 'SCOTCH_ARCH_PATH' (overrides -scotch)
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)
-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)
HELP_FULL
;;
esac
cat<<HELP_TAIL_COMMON
Adjusts hardcoded versions and installation paths (POSIX and C-shell)
for OpenFOAM.
HELP_TAIL_COMMON
exit 0 # A clean exit
}
# Report error and exit
die()
{
@ -105,16 +146,32 @@ die()
echo "Error encountered:"
while [ "$#" -ge 1 ]; do echo " $1"; shift; done
echo
echo "See '${0##*/} -help' for usage"
echo "See '$0 -help' for usage"
echo
exit 1
}
# -----------------------------------------------------------------------------
projectDir="$(\pwd -L)" # Project dir
# Check that it appears to be an OpenFOAM installation
[ -f etc/bashrc -a -d etc/config.sh ] || \
usage "Please run from top-level directory of installation"
if [ -f etc/bashrc ] && [ -d "META-INFO" ]
then
echo "Configuring OpenFOAM ($projectDir)" 1>&2
else
die "Please run from the OpenFOAM top-level installation directory" \
"No etc/bashrc or META-INFO/ found"
fi
# Use foamEtcFile to locate files, but only edit shipped files
if [ -x bin/foamEtcFile ]
then
_foamEtc() {
./bin/foamEtcFile -mode=o "$@"
}
else
die "No bin/foamEtcFile found in installation"
fi
# Check if argument matches the expected input. Respects case.
@ -145,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
}
@ -182,7 +243,7 @@ replace()
"$file" \
"$key=.*" \
"$key=$val" \
"Replaced $key setting by '$val'"
"Replaced $key by '$val'"
done
}
@ -205,12 +266,34 @@ replaceCsh()
_inlineSed \
"$file" \
"setenv *$key [^ #]*" \
"setenv [ ]*$key [^ #]*" \
"setenv $key $val" \
"Replaced $key setenv by '$val'"
"Replaced $key by '$val'"
done
}
# Locate file with foamEtcFile -mode=o and forward to replace()
replaceEtc()
{
local file="$1"
shift
file=$(_foamEtc "$file")
replace $file "$@"
}
# Locate file with foamEtcFile -mode=o and forward to replaceCsh()
replaceEtcCsh()
{
local file="$1"
shift
file=$(_foamEtc "$file")
replaceCsh $file "$@"
}
# Get the option's value (argument), or die on missing or empty argument
# $1 option
# $2 value
@ -274,23 +357,62 @@ unset adjusted optMpi
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help* | --help*)
usage
-help-c*) # Compat help
printHelp -compat
;;
-help-f*) # Full help
printHelp -full
;;
-h | -help*) # Short help
printHelp
;;
'')
# Discard empty arguments
;;
-debug-list)
# Undocumented (experimental)
# TDB: List files that can be edited by this script
cat << CONFIG_SH
etc/bashrc
etc/config.sh/adios2
etc/config.sh/compiler
etc/config.sh/paraview
etc/config.sh/vtk
etc/config.sh/CGAL
etc/config.sh/FFTW
etc/config.sh/metis
etc/config.sh/kahip
etc/config.sh/scotch
CONFIG_SH
cat << CONFIG_CSH
etc/cshrc
etc/config.csh/adios2
etc/config.csh/compiler
etc/config.csh/paraview
etc/config.csh/vtk
etc/config.csh/CGAL
etc/config.csh/FFTW
CONFIG_CSH
exit 0
;;
## Basic ##
-etc=*)
# Define FOAM_CONFIG_ETC for finding files
export FOAM_CONFIG_ETC="${1#*=}"
;;
-project-path)
# Replace WM_PROJECT_DIR=...
optionValue=$(getOptionValue "$@")
replace etc/bashrc WM_PROJECT_DIR "\"$optionValue\""
replaceCsh etc/cshrc WM_PROJECT_DIR "\"$optionValue\""
replaceEtc bashrc WM_PROJECT_DIR "\"$optionValue\""
replaceEtcCsh cshrc WM_PROJECT_DIR "\"$optionValue\""
removeBashMagic etc/bashrc
removeCshMagic etc/cshrc
removeBashMagic $(_foamEtc bashrc)
removeCshMagic $(_foamEtc cshrc)
adjusted=true
shift
@ -299,8 +421,8 @@ do
-version | -foamVersion | --projectVersion)
# Replace WM_PROJECT_VERSION=...
optionValue=$(getOptionValue "$@")
replace etc/bashrc WM_PROJECT_VERSION "$optionValue"
replaceCsh etc/cshrc WM_PROJECT_VERSION "$optionValue"
replaceEtc bashrc WM_PROJECT_VERSION "$optionValue"
replaceEtcCsh cshrc WM_PROJECT_VERSION "$optionValue"
adjusted=true
shift
;;
@ -314,30 +436,30 @@ do
-sp | -SP | -float32)
# Replace WM_PRECISION_OPTION=...
replace etc/bashrc WM_PRECISION_OPTION "SP"
replaceCsh etc/cshrc WM_PRECISION_OPTION "SP"
replaceEtc bashrc WM_PRECISION_OPTION "SP"
replaceEtcCsh cshrc WM_PRECISION_OPTION "SP"
adjusted=true
;;
-dp | -DP | -float64)
# Replace WM_PRECISION_OPTION=...
replace etc/bashrc WM_PRECISION_OPTION "DP"
replaceCsh etc/cshrc WM_PRECISION_OPTION "DP"
replaceEtc bashrc WM_PRECISION_OPTION "DP"
replaceEtcCsh cshrc WM_PRECISION_OPTION "DP"
adjusted=true
;;
-spdp | -SPDP)
# Replace WM_PRECISION_OPTION=...
replace etc/bashrc WM_PRECISION_OPTION "SPDP"
replaceCsh etc/cshrc WM_PRECISION_OPTION "SPDP"
replaceEtc bashrc WM_PRECISION_OPTION "SPDP"
replaceEtcCsh cshrc WM_PRECISION_OPTION "SPDP"
adjusted=true
;;
-int32 | -int64)
# Replace WM_LABEL_SIZE=...
optionValue="${1#-int}"
replace etc/bashrc WM_LABEL_SIZE "$optionValue"
replaceCsh etc/cshrc WM_LABEL_SIZE "$optionValue"
replaceEtc bashrc WM_LABEL_SIZE "$optionValue"
replaceEtcCsh cshrc WM_LABEL_SIZE "$optionValue"
adjusted=true
;;
@ -347,8 +469,8 @@ do
-clang)
# Replace default_clang_version=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/compiler default_clang_version "$optionValue"
replace etc/config.csh/compiler default_clang_version "$optionValue"
replaceEtc config.sh/compiler default_clang_version "$optionValue"
replaceEtc config.csh/compiler default_clang_version "$optionValue"
adjusted=true
shift
;;
@ -356,32 +478,32 @@ do
-gcc)
# Replace default_gcc_version=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/compiler default_gcc_version "$optionValue"
replace etc/config.csh/compiler default_gcc_version "$optionValue"
replaceEtc config.sh/compiler default_gcc_version "$optionValue"
replaceEtc config.csh/compiler default_gcc_version "$optionValue"
adjusted=true
shift
;;
-system)
-system-compiler | -system)
# Replace WM_COMPILER_TYPE=... and WM_COMPILER=...
optionValue=$(getOptionValue "$@")
replace etc/bashrc \
replaceEtc bashrc \
WM_COMPILER_TYPE system \
WM_COMPILER "$optionValue"
replaceCsh etc/cshrc \
replaceEtcCsh cshrc \
WM_COMPILER_TYPE system \
WM_COMPILER "$optionValue"
adjusted=true
shift
;;
-third | -ThirdParty)
-third-compiler | -third | -ThirdParty)
# Replace WM_COMPILER_TYPE=... and WM_COMPILER=...
optionValue=$(getOptionValue "$@")
replace etc/bashrc \
replaceEtc bashrc \
WM_COMPILER_TYPE ThirdParty \
WM_COMPILER "$optionValue"
replaceCsh etc/cshrc \
replaceEtcCsh cshrc \
WM_COMPILER_TYPE ThirdParty \
WM_COMPILER "$optionValue"
adjusted=true
@ -390,22 +512,22 @@ do
gmp-[4-9]* | gmp-system)
# gcc-related package
replace etc/config.sh/compiler default_gmp_version "$1"
replace etc/config.csh/compiler default_gmp_version "$1"
replaceEtc config.sh/compiler default_gmp_version "$1"
replaceEtc config.csh/compiler default_gmp_version "$1"
adjusted=true
;;
mpfr-[2-9]* | mpfr-system)
# gcc-related package
replace etc/config.sh/compiler default_mpfr_version "$1"
replace etc/config.csh/compiler default_mpfr_version "$1"
replaceEtc config.sh/compiler default_mpfr_version "$1"
replaceEtc config.csh/compiler default_mpfr_version "$1"
adjusted=true
;;
mpc-[0-9]* | mpc-system)
# gcc-related package
replace etc/config.sh/compiler default_mpc_version "$1"
replace etc/config.csh/compiler default_mpc_version "$1"
replaceEtc config.sh/compiler default_mpc_version "$1"
replaceEtc config.csh/compiler default_mpc_version "$1"
adjusted=true
;;
@ -415,8 +537,8 @@ do
-mpi)
# Explicitly set WM_MPLIB=...
optionValue=$(getOptionValue "$@")
replace etc/bashrc WM_MPLIB "$optionValue"
replaceCsh etc/cshrc WM_MPLIB "$optionValue"
replaceEtc bashrc WM_MPLIB "$optionValue"
replaceEtcCsh cshrc WM_MPLIB "$optionValue"
optMpi=system
adjusted=true
shift
@ -431,34 +553,34 @@ do
_matches "$optMpi" "$expected" || \
die "'$1' has bad value: '$optMpi'"
_inlineSed etc/config.sh/mpi \
_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 etc/config.csh/mpi \
_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'"
replace etc/bashrc WM_MPLIB OPENMPI
replaceCsh etc/cshrc WM_MPLIB OPENMPI
replaceEtc bashrc WM_MPLIB OPENMPI
replaceEtcCsh cshrc WM_MPLIB OPENMPI
adjusted=true
shift
;;
-openmpi-system)
# Explicitly set WM_MPLIB=SYSTEMOPENMPI
replace etc/bashrc WM_MPLIB SYSTEMOPENMPI
replaceCsh etc/cshrc WM_MPLIB SYSTEMOPENMPI
replaceEtc bashrc WM_MPLIB SYSTEMOPENMPI
replaceEtcCsh cshrc WM_MPLIB SYSTEMOPENMPI
optMpi=system
adjusted=true
;;
-openmpi-third)
# Explicitly set WM_MPLIB=OPENMPI, using default setting for openmpi
replace etc/bashrc WM_MPLIB OPENMPI
replaceCsh etc/cshrc WM_MPLIB OPENMPI
replaceEtc bashrc WM_MPLIB OPENMPI
replaceEtcCsh cshrc WM_MPLIB OPENMPI
optMpi=third
adjusted=true
;;
@ -469,8 +591,8 @@ do
-adios | -adios2)
# Replace adios2_version=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/adios2 adios2_version "$optionValue"
replace etc/config.csh/adios2 adios2_version "$optionValue"
replaceEtc config.sh/adios2 adios2_version "$optionValue"
replaceEtc config.csh/adios2 adios2_version "$optionValue"
adjusted=true
shift
;;
@ -478,8 +600,8 @@ do
-adios-path | -adios2-path)
# Replace ADIOS2_ARCH_PATH=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/adios2 ADIOS2_ARCH_PATH "\"$optionValue\""
replaceCsh etc/config.csh/adios2 ADIOS2_ARCH_PATH "\"$optionValue\""
replaceEtc config.sh/adios2 ADIOS2_ARCH_PATH "\"$optionValue\""
replaceEtcCsh config.csh/adios2 ADIOS2_ARCH_PATH "\"$optionValue\""
adjusted=true
shift
;;
@ -487,8 +609,8 @@ do
-boost)
# Replace boost_version=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/CGAL boost_version "$optionValue"
replace etc/config.csh/CGAL boost_version "$optionValue"
replaceEtc config.sh/CGAL boost_version "$optionValue"
replaceEtc config.csh/CGAL boost_version "$optionValue"
adjusted=true
shift
;;
@ -496,8 +618,8 @@ do
-boost-path)
# Replace BOOST_ARCH_PATH=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/CGAL BOOST_ARCH_PATH "\"$optionValue\""
replaceCsh etc/config.csh/CGAL BOOST_ARCH_PATH "\"$optionValue\""
replaceEtc config.sh/CGAL BOOST_ARCH_PATH "\"$optionValue\""
replaceEtcCsh config.csh/CGAL BOOST_ARCH_PATH "\"$optionValue\""
adjusted=true
shift
;;
@ -505,8 +627,8 @@ do
-cgal)
# Replace cgal_version=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/CGAL cgal_version "$optionValue"
replace etc/config.csh/CGAL cgal_version "$optionValue"
replaceEtc config.sh/CGAL cgal_version "$optionValue"
replaceEtc config.csh/CGAL cgal_version "$optionValue"
adjusted=true
shift
;;
@ -514,8 +636,8 @@ do
-cgal-path)
# Replace CGAL_ARCH_PATH=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/CGAL CGAL_ARCH_PATH "$optionValue"
replaceCsh etc/config.csh/CGAL CGAL_ARCH_PATH "$optionValue"
replaceEtc config.sh/CGAL CGAL_ARCH_PATH "$optionValue"
replaceEtcCsh config.csh/CGAL CGAL_ARCH_PATH "$optionValue"
adjusted=true
shift
;;
@ -523,8 +645,8 @@ do
-fftw)
# Replace fftw_version=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/FFTW fftw_version "$optionValue"
replace etc/config.csh/FFTW fftw_version "$optionValue"
replaceEtc config.sh/FFTW fftw_version "$optionValue"
replaceEtc config.csh/FFTW fftw_version "$optionValue"
adjusted=true
shift
;;
@ -532,8 +654,8 @@ do
-fftw-path)
# Replace FFTW_ARCH_PATH=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/FFTW FFTW_ARCH_PATH "\"$optionValue\""
replaceCsh etc/config.csh/FFTW FFTW_ARCH_PATH "\"$optionValue\""
replaceEtc config.sh/FFTW FFTW_ARCH_PATH "\"$optionValue\""
replaceEtcCsh config.csh/FFTW FFTW_ARCH_PATH "\"$optionValue\""
adjusted=true
shift
;;
@ -541,8 +663,15 @@ do
-cmake)
# Replace cmake_version=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/paraview cmake_version "$optionValue"
replace etc/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
;;
@ -550,7 +679,7 @@ do
-kahip)
# Replace KAHIP_VERSION=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/kahip KAHIP_VERSION "$optionValue"
replaceEtc config.sh/kahip KAHIP_VERSION "$optionValue"
adjusted=true
shift
;;
@ -558,7 +687,7 @@ do
-kahip-path)
# Replace KAHIP_ARCH_PATH=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/kahip KAHIP_ARCH_PATH "\"$optionValue\""
replaceEtc config.sh/kahip KAHIP_ARCH_PATH "\"$optionValue\""
adjusted=true
shift
;;
@ -566,7 +695,7 @@ do
-metis)
# Replace METIS_VERSION=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/metis METIS_VERSION "$optionValue"
replaceEtc config.sh/metis METIS_VERSION "$optionValue"
adjusted=true
shift
;;
@ -574,7 +703,7 @@ do
-metis-path)
# Replace METIS_ARCH_PATH=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/metis METIS_ARCH_PATH "\"$optionValue\""
replaceEtc config.sh/metis METIS_ARCH_PATH "\"$optionValue\""
adjusted=true
shift
;;
@ -582,7 +711,7 @@ do
-scotch | -scotchVersion | --scotchVersion)
# Replace SCOTCH_VERSION=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/scotch SCOTCH_VERSION "$optionValue"
replaceEtc config.sh/scotch SCOTCH_VERSION "$optionValue"
adjusted=true
shift
;;
@ -590,7 +719,7 @@ do
-scotch-path | -scotchArchPath | --scotchArchPath)
# Replace SCOTCH_ARCH_PATH=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/scotch SCOTCH_ARCH_PATH "\"$optionValue\""
replaceEtc config.sh/scotch SCOTCH_ARCH_PATH "\"$optionValue\""
adjusted=true
shift
;;
@ -605,8 +734,8 @@ do
_matches "$optionValue" "$expected" || \
[ "$optionValue" != "${optionValue%system}" ] || \
die "'$1' has bad value: '$optionValue'"
replace etc/config.sh/paraview ParaView_VERSION "$optionValue"
replace etc/config.csh/paraview ParaView_VERSION "$optionValue"
replaceEtc config.sh/paraview ParaView_VERSION "$optionValue"
replaceEtc config.csh/paraview ParaView_VERSION "$optionValue"
adjusted=true
shift
;;
@ -614,8 +743,8 @@ do
-paraview-qt)
# Replace ParaView_QT=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/paraview ParaView_QT "$optionValue"
replace etc/config.csh/paraview ParaView_QT "$optionValue"
replaceEtc config.sh/paraview ParaView_QT "$optionValue"
replaceEtc config.csh/paraview ParaView_QT "$optionValue"
adjusted=true
shift
;;
@ -623,17 +752,17 @@ do
-paraview-path | -paraviewInstall | --paraviewInstall)
# Replace ParaView_DIR=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/paraview ParaView_DIR \""$optionValue\""
replaceCsh etc/config.csh/paraview ParaView_DIR \""$optionValue\""
replaceEtc config.sh/paraview ParaView_DIR \""$optionValue\""
replaceEtcCsh config.csh/paraview ParaView_DIR \""$optionValue\""
adjusted=true
shift
;;
-vtk)
# Replace vtk_version=...
-llvm)
# Replace mesa_llvm=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/vtk vtk_version "$optionValue"
replace etc/config.csh/vtk vtk_version "$optionValue"
replaceEtc config.sh/vtk mesa_llvm "$optionValue"
replaceEtc config.csh/vtk mesa_llvm "$optionValue"
adjusted=true
shift
;;
@ -641,8 +770,44 @@ do
-mesa)
# Replace mesa_version=...
optionValue=$(getOptionValue "$@")
replace etc/config.sh/vtk mesa_version "$optionValue"
replace etc/config.csh/vtk mesa_version "$optionValue"
replaceEtc config.sh/vtk mesa_version "$optionValue"
replaceEtc config.csh/vtk mesa_version "$optionValue"
adjusted=true
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
;;

View File

@ -7,23 +7,10 @@
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2016-2017 CINECA
# Copyright (C) 2017-2019 OpenCFD Ltd.
# Copyright (C) 2017-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM.
#
# OpenFOAM is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License
# along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# foamCreateModuleInclude
@ -134,15 +121,24 @@ syspath() {
# Frontend: do all basic sanity checks in the front-end only
if [ -z "$optBackend" ]
then
# Check that it appears to be an OpenFOAM installation
[ -d "$projectDir" -a -f "$projectDir/etc/bashrc" ] || \
die "Incorrect projectDir? $projectDir"
# Check preloads
for file in "$preloads"
do
[ -f "$file" ] || echo "No such file to preload: $file" 1>&2
done
if [ -n "$preloads" ]
then
for file in $preloads
do
[ -f "$file" ] || echo "No such file to preload: $file" 1>&2
done
fi
# Check that it appears to be an OpenFOAM installation
# could also check [ -d "$projectDir/META-INFO" ]
if [ -d "$projectDir" ] && [ -f "etc/bashrc" ]
then
echo "Appears to be an OpenFOAM installation" 1>&2
else
die "Incorrect OpenFOAM projectDir?" \
" $projectDir"
fi
# Call itself with clean environment.
# Tag the start/end of the original PATH, MANPATH, LD_LIBRARY_PATH
@ -234,6 +230,9 @@ unset FOAM_INST_DIR WM_PROJECT_INST_DIR
unset WM_PROJECT_USER_DIR WM_THIRD_PARTY_DIR
unset SCOTCH_VERSION
# Probably don't want these either
unset FOAM_CONFIG_MODE
# Also remove user directories as being unreliable
@ -283,7 +282,7 @@ unalias util 2>/dev/null
#------------------------------------------------
# Generalize environment.
# This needs rethinking since it largely duplicates logic from the etc/config.sh/settings
# Needs rethinking, it largely duplicates logic from etc/config.sh/settings
rewriteEnv()
{
sed \

View File

@ -6,11 +6,10 @@
# \\ / 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, 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
# tools/lib-dir [OPTION] DIR [LIBEXT]
@ -135,7 +134,7 @@ then
fi
# 2) Use fallback if the previous failed
if [ -z "$resolved" -a -n "$alt" ]
if [ -z "$resolved" ] && [ -n "$alt" ]
then
# Fallback
case "$alt" in

View File

@ -1,193 +0,0 @@
#!/bin/bash
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2019 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, licensed under GNU General Public License
# <http://www.gnu.org/licenses/>.
#
# Script
# openfoam [args]
#
# Description
# 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.
#
# This script normally exists in $WM_PROJECT_DIR/bin/tools but can also
# be modified to use a hard-coded PROJECT_DIR entry and placed elsewhere
# in the filesystem (eg, /usr/bin).
#
#------------------------------------------------------------------------------
# Hard-coded value (eg, with autoconfig)
projectDir="@PROJECT_DIR@"
if [ -z "$projectDir" ] || [ "${projectDir#@}" != "$projectDir" ]
then
# Auto-detect from location
toolsDir="${0%/*}" # The bin/tools dir
projectDir="${toolsDir%/bin/tools}" # Project dir
case "$projectDir" in
(/bin | /usr/bin | /usr/local/bin)
# This shouldn't happen.
# If copied to a system dir, should also be using hard-coded values!
echo "Warning: suspicious looking project dir: $projectDir" 1>&2
;;
("$toolsDir")
# Eg, called as ./openfoam etc - need to try harder
projectDir="$(\cd $(dirname $0)/../.. && \pwd -L)" || unset projectDir
;;
esac
fi
#------------------------------------------------------------------------------
usage() {
exec 1>&2
while [ "$#" -ge 1 ]; do echo "$1"; shift; done
cat<<USAGE
Usage: ${0##*/} [OPTION] [application ...]
options:
-prefix=DIR Specify alternative OpenFOAM directory
-sp Single precision
-dp Double precision
-spdp Mixed single/double precision
-int32 | -int64 The label-size
-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)
For more information: www.OpenFOAM.com
USAGE
exit 1
}
#-------------------------------------------------------------------------------
# Only preserve settings for non-interactive?
if [ "$#" -eq 0 ]
then
unset _foamSettings FOAM_SETTINGS
else
_foamSettings="$FOAM_SETTINGS"
fi
# Parse options
while [ "$#" -gt 0 ]
do
case "$1" in
-h | -help*)
usage
;;
-prefix=* | -foam=*)
projectDir="${1#*=}"
;;
-sp | -SP)
# WM_PRECISION_OPTION=...
_foamSettings="$_foamSettings${_foamSettings:+ }WM_PRECISION_OPTION=SP"
;;
-dp | -DP)
# WM_PRECISION_OPTION=...
_foamSettings="$_foamSettings${_foamSettings:+ }WM_PRECISION_OPTION=DP"
;;
-spdp | -SPDP)
# WM_PRECISION_OPTION=...
_foamSettings="$_foamSettings${_foamSettings:+ }WM_PRECISION_OPTION=SPDP"
;;
-int32 | -int64)
# WM_LABEL_SIZE=...
_foamSettings="$_foamSettings${_foamSettings:+ }WM_LABEL_SIZE=${1#-int}"
;;
--)
shift
break
;;
-*)
echo "Error: unknown option: '$1'" 1>&2
exit 1
;;
*)
break
;;
esac
shift
done
#-------------------------------------------------------------------------------
# Remove current OpenFOAM environment
if [ -d "$WM_PROJECT_DIR" ] && [ -f "$WM_PROJECT_DIR/etc/config.sh/unset" ]
then
. "$WM_PROJECT_DIR/etc/config.sh/unset"
fi
[ -d "$projectDir" ] || {
echo "Error: no project dir: $projectDir" 1>&2
exit 2
}
_foamSourceBashEnv="$projectDir/etc/bashrc"
if [ "$#" -eq 0 ]
then
# Interactive shell
_foamSourceBashEnv="$projectDir/bin/tools/source-bashrc"
fi
[ -f "$_foamSourceBashEnv" ] || {
echo "Error: file not found: $_foamSourceBashEnv" 1>&2
exit 2
}
if [ "$#" -eq 0 ]
then
# Source user ~/.bashrc and OpenFOAM etc/bashrc.
# 1) Can either use a tmp file, or 2) chain off to a dedicated file
# We use a dedicated file.
if [ -n "$_foamSettings" ]
then
export FOAM_SETTINGS="$_foamSettings"
fi
## echo "Source with $_foamSourceBashEnv with '$FOAM_SETTINGS'" 1>&2
# Interactive shell (newer bash can use --init-file instead of --rcfile)
exec bash --rcfile "$_foamSourceBashEnv" -i
else
# Non-interactive
# Source bashrc within a function to preserve command-line arguments
# - this will not have aliases, but working non-interactively anyhow
sourceBashrc()
{
. "$_foamSourceBashEnv" $_foamSettings
}
sourceBashrc
exec "$@"
fi
#------------------------------------------------------------------------------

19
bin/tools/openfoam.in Normal file
View File

@ -0,0 +1,19 @@
#!/bin/sh
exec "@PROJECT_DIR@"/etc/openfoam "$@"
#------------------------------------------------------------------------------
# ========= |
# \\ / 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
# Forwarding to OpenFOAM etc/openfoam bash session script.
# Uses a hard-code directory path (eg, generated with autoconfig).
#
#------------------------------------------------------------------------------

View File

@ -5,34 +5,36 @@
# \\ / 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
# bin/tools/source-bashrc
#
# Description
# Source user ~/.bashrc and OpenFOAM etc/bashrc
# Source user ~/.bashrc and OpenFOAM etc/bashrc.
# Not normally sourced manually, but from bash with the --rcfile option.
#
# This file is normally not sourced manually,
# but from bash with the --rcfile option.
#------------------------------------------------------------------------------
# Hard-coded value (eg, with autoconfig)
# Hard-coded directory path (eg, autoconfig)
projectDir="@PROJECT_DIR@"
if [ -z "$projectDir" ] || [ "${projectDir#@}" != "$projectDir" ]
then
# Auto-detect (as per OpenFOAM etc/bashrc)
# Auto-detect location (as per OpenFOAM etc/bashrc)
# --
# Assuming this file is $WM_PROJECT_DIR/bin/tools/source-bashrc,
# the next lines should work when sourced by BASH or ZSH shells.
# --
projectDir="${BASH_SOURCE:-${ZSH_NAME:+$0}}"
[ -n "$projectDir" ] && projectDir="$(\cd $(dirname $projectDir)/../.. && \pwd -L)" || unset projectDir
if [ -n "$projectDir" ]
then
projectDir="$(\cd "$(dirname "$projectDir")"/../.. && \pwd -L)" || \
unset projectDir
fi
fi
#------------------------------------------------------------------------------
@ -66,7 +68,7 @@ then
# Some feedback
if [ -n "$PS1" ] && [ -d "$WM_PROJECT_DIR" ]
then
info="$(foamEtcFile -show-patch 2>/dev/null)"
info="$("$WM_PROJECT_DIR"/bin/foamEtcFile -show-patch 2>/dev/null)"
# echo "Using: OpenFOAM-$WM_PROJECT_VERSION ($FOAM_API${info:+ patch=$info}) - visit www.openfoam.com" 1>&2
echo "Using: OpenFOAM-$WM_PROJECT_VERSION${info:+ (patch=$info)} - visit www.openfoam.com" 1>&2

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.

70
doc/openfoam.1.in Normal file
View File

@ -0,0 +1,70 @@
.TH "OPENFOAM" 1 "OpenFOAM-version" "www.openfoam.com" "OpenFOAM Commands Manual"
.SH NAME
openfoam \- OpenFOAM bash(1) session
.SH SYNOPSIS
\fBopenfoam\fR [\fIOPTIONS\fR] [\fIapplication ...\fR]
.SH DESCRIPTION
Activate an \fBOpenFOAM\fR environment in an interactive or
non-interactive bash(1) session.
If no application is given, an interactive bash session will be used.
If an application (optionally with arguments) is provided, the
OpenFOAM \fIetc/bashrc\fR file will be sourced from the project directory
prior to running the application.
.SH OPTIONS
.TP
\fB\-c\fR \fIcommand\fR
Execute shell commands with OpenFOAM environment
.TP
\fB\-D\fR\fIkey=[value]\fR
Define key/value to pass as a preference
.TP
\fB\-sp\fR
Use single precision for scalar-size
.TP
\fB\-dp\fR
Use double precision for scalar-size
.TP
\fB\-spdp\fR
Use single precision for scalar-size, double for solve-scalar size
.TP
\fB\-int32\fR
Use 32-bit label-size
.TP
\fB\-int64\fR
Use 64-bit label-size
.TP
\fB\-prefix=DIR\fR
Specify alternative OpenFOAM project directory
.TP
\fB\-show-api\fR | \fB\-version\fR
Print META-INFO api value and exit
.TP
\fB\-show-patch\fR
Print META-INFO patch value and exit
.TP
\fB\-show-prefix\fR
Print project directory and exit
.TP
\fB\-help\fR
Print the usage
.SH ARGUMENTS
If arguments remain after option processing, the first argument is
assumed to be an application with options and arguments.
.SH FILES
The \fIetc/bashrc\fR file from the OpenFOAM project directory supplies
the environment settings.
.SH "SEE ALSO"
Online documentation https://www.openfoam.com/documentation/
.SH COPYRIGHT
Copyright \(co 2020 OpenCFD Ltd.

View File

@ -6,11 +6,10 @@
# \\/ 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
# etc/bashrc
@ -30,11 +29,22 @@
# - $WM_PROJECT_SITE/$FOAM_API/etc/prefs.sh
# - $WM_PROJECT_SITE/etc/prefs.sh
#
# Some settings can also be overridden on the command-line when
# sourcing this file. For example,
#
# . /path/etc/bashrc WM_COMPILER=Clang WM_LABEL_SIZE=64
#
# Environment
# FOAM_CONFIG_ETC
# - alternative/additional location for OpenFOAM etc/ directory
#
# FOAM_CONFIG_MODE (search mode for etc config files - see foamEtcFile)
# - eg, FOAM_CONFIG_MODE="o" to only use OpenFOAM config files
# - no influence on OpenFOAM applications, just the config files
#
# FOAM_VERBOSE (set/unset)
# - add extra verbosity when sourcing files
# FOAM_CONFIG_NOUSER (set/unset)
# - suppress use of user/group configuration files
#
# WM_PROJECT_SITE (optional directory)
# - local site-specific directory, uses WM_PROJECT_DIR/site if unset
#
@ -132,6 +142,11 @@ projectDir="$HOME/OpenFOAM/OpenFOAM-$WM_PROJECT_VERSION"
# * on a 32-bit OS this option is ignored (always 32-bit)
#export WM_ARCH_OPTION=64
# [FOAM_EXTRA_CXXFLAGS]
# Additional compilation flags - do not inherit from the environment.
# Set after sourcing or via <prefs.sh> to avoid surprises.
unset FOAM_EXTRA_CXXFLAGS
################################################################################
# NO (NORMAL) USER EDITING BELOW HERE

View File

@ -9,8 +9,13 @@
type forces;
libs ("libforces.so");
writeControl timeStep;
writeInterval 1;
// How often force and moment volume fields will be written
writeControl writeTime; // none
// How often the forces force.dat and moment.dat data files are updated
// Note: .dat files are always updated on writeControl times
executeControl timeStep;
executeInterval 1;
log off;

View File

@ -8,9 +8,10 @@
Description
Solves a transport equation for a scalar field.
The name of the scalar field is specified in this file. A sample scalar
field file, that must be initialised for the case, typically in the 0
directory, is available in $FOAM_ETC/caseDicts/solvers/scalarTransport.
The name of the scalar field is specified in this file.
A sample scalar field file, that must be initialised for the case,
typically in the 0 directory,
is available in tetc/caseDicts/solvers/scalarTransport
\*---------------------------------------------------------------------------*/

View File

@ -5,11 +5,10 @@
# \\ / 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, 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.csh/functions
@ -36,25 +35,13 @@ alias _foamAddLib 'setenv LD_LIBRARY_PATH \!*\:${LD_LIBRARY_PATH}'
alias _foamAddLibAuto 'eval `$WM_PROJECT_DIR/bin/tools/lib-dir -csh \!*`'
# Echo values when FOAM_VERBOSE is on, no-op otherwise
if ($?FOAM_VERBOSE && $?prompt) then
alias _foamEcho 'echo \!*'
else
alias _foamEcho 'true'
endif
# Source an etc file, possibly with some verbosity
if ($?FOAM_VERBOSE && $?prompt) then
if ($?FOAM_CONFIG_NOUSER) then
alias _foamEtc 'eval `$WM_PROJECT_DIR/bin/foamEtcFile -csh-verbose -mode=o \!*`'
else
alias _foamEtc 'eval `$WM_PROJECT_DIR/bin/foamEtcFile -csh-verbose \!*`'
endif
alias _foamEcho 'echo \!*'
alias _foamEtc 'eval `$WM_PROJECT_DIR/bin/foamEtcFile -csh-verbose \!*`'
else
if ($?FOAM_CONFIG_NOUSER) then
alias _foamEtc 'eval `$WM_PROJECT_DIR/bin/foamEtcFile -csh -mode=o \!*`'
else
alias _foamEtc 'eval `$WM_PROJECT_DIR/bin/foamEtcFile -csh \!*`'
endif
alias _foamEcho 'true'
alias _foamEtc 'eval `$WM_PROJECT_DIR/bin/foamEtcFile -csh \!*`'
endif

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
#------------------------------------------------------------------------------

View File

@ -6,11 +6,10 @@
# \\/ 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
# etc/config.csh/settings

View File

@ -18,10 +18,11 @@
# Finalize setup of OpenFOAM environment for C-shell (csh, tcsh)
#
# Environment
# FOAM_CONFIG_MODE (search mode for etc config files - see foamEtcFile)
# - eg, FOAM_CONFIG_MODE="o" to only use OpenFOAM config files
#
# FOAM_VERBOSE (set/unset)
# - add extra verbosity when sourcing files
# FOAM_CONFIG_NOUSER (set/unset)
# - suppress use of user/group configuration files
#
#------------------------------------------------------------------------------
@ -77,14 +78,21 @@ endif
# Overrides via <prefs.csh>
# 1. other (system) values
# 1. Always use (O)ther values from the OpenFOAM project etc/ directory
_foamEtc -mode=o prefs.csh
# 2. user or group values (unless disabled)
if (! $?FOAM_CONFIG_NOUSER ) then
_foamEtc -mode=ug prefs.csh
# 2. (U)ser or (G)roup values (unless disabled). Could use some more work
if ($?FOAM_CONFIG_MODE) then
set configMode="${FOAM_CONFIG_MODE:s/o//}" # Already handled O(ther)
else
set configMode="ug"
endif
# Is the remainder valid - has U(ser) or G(roup)?
switch ("$configMode")
case *[ug]*:
_foamEtc -mode="$configMode" prefs.csh
breaksw
endsw
# Capture and evaluate any command-line parameters
# These can be used to set/unset values, specify additional files etc.
@ -119,6 +127,16 @@ while ( $#argv > 0 )
shift
end
# The prefs may have injected a FOAM_CONFIG_ETC value.
# Verify that it makes sense before continuing.
if ( $?FOAM_CONFIG_ETC ) then
if ( ! -d "$FOAM_CONFIG_ETC" ) then
echo "Ignore invalid FOAM_CONFIG_ETC = $FOAM_CONFIG_ETC"
else if ( "$FOAM_CONFIG_ETC" == "$WM_PROJECT_DIR/etc" ) then
unsetenv FOAM_CONFIG_ETC
endif
endif
# Clean standard environment variables (PATH, MANPATH, LD_LIBRARY_PATH)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

View File

@ -6,11 +6,10 @@
# \\/ 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
# etc/config.csh/unset
@ -46,20 +45,15 @@ endif
unsetenv WM_ARCH
unsetenv WM_ARCH_OPTION
unsetenv WM_CC
unsetenv WM_CFLAGS
unsetenv WM_COMPILER
unsetenv WM_COMPILER_ARCH
unsetenv WM_COMPILER_TYPE
unsetenv WM_COMPILER_LIB_ARCH
unsetenv WM_COMPILE_OPTION
unsetenv WM_CXX
unsetenv WM_CXXFLAGS
unsetenv WM_DIR
unsetenv WM_HOSTS
unsetenv WM_LABEL_OPTION
unsetenv WM_LABEL_SIZE
unsetenv WM_LDFLAGS
unsetenv WM_MPLIB
unsetenv WM_NCOMPPROCS
unsetenv WM_OPTIONS
@ -75,6 +69,11 @@ unsetenv WM_PROJECT_VERSION
unsetenv WM_SCHEDULER
unsetenv WM_THIRD_PARTY_DIR
# Older variables
# Before 1906
unsetenv WM_CC WM_CXX WM_CFLAGS WM_CXXFLAGS WM_LDFLAGS
#------------------------------------------------------------------------------
# Unset FOAM_* environment variables
@ -83,9 +82,12 @@ unsetenv FOAM_API
unsetenv FOAM_APPBIN
unsetenv FOAM_APP
unsetenv FOAM_CODE_TEMPLATES
unsetenv FOAM_CONFIG_ETC
unsetenv FOAM_CONFIG_MODE
unsetenv FOAM_ETC
unsetenv FOAM_EXTRA_CXXFLAGS
unsetenv FOAM_EXTRA_LDFLAGS
unsetenv FOAM_EXT_LIBBIN
unsetenv FOAM_INST_DIR
unsetenv FOAM_JOB_DIR
unsetenv FOAM_LIBBIN
unsetenv FOAM_MPI
@ -102,6 +104,10 @@ unsetenv FOAM_USER_APPBIN
unsetenv FOAM_USER_LIBBIN
unsetenv FOAM_UTILITIES
# Old variables
# Before 1812
unsetenv FOAM_INST_DIR
#------------------------------------------------------------------------------
# Unset MPI-related environment variables

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

@ -6,11 +6,10 @@
# \\/ 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.
#
# File
# etc/config.sh/functions
@ -39,32 +38,25 @@ then
{
foamVar_name="$1"
shift
eval "$($foamClean -sh-env=$foamVar_name $@)"
eval "$($foamClean -sh-env="$foamVar_name" "$@")"
unset "foamVar_name"
}
# Echo values to stderr when FOAM_VERBOSE is on, no-op otherwise
unset -f _foamEcho 2>/dev/null
if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ]
then
_foamEcho() { echo "$@" 1>&2; }
else
_foamEcho() { true; }
fi
# Source an etc file, possibly with some verbosity
# - use eval to avoid intermediate variables (ksh doesn't have 'local')
unset -f _foamEcho 2>/dev/null
unset -f _foamEtc 2>/dev/null
if [ -n "$FOAM_VERBOSE" ] && [ -n "$PS1" ]
then
_foamEtc()
{
eval "$($WM_PROJECT_DIR/bin/foamEtcFile -sh-verbose ${FOAM_CONFIG_NOUSER:+-mode=o} $@)";
_foamEcho() { echo "$@" 1>&2; }
_foamEtc() {
eval "$("$WM_PROJECT_DIR"/bin/foamEtcFile -sh-verbose "$@")";
}
else
_foamEtc()
{
eval "$($WM_PROJECT_DIR/bin/foamEtcFile -sh ${FOAM_CONFIG_NOUSER:+-mode=o} $@)";
_foamEcho() { true; }
_foamEtc() {
eval "$("$WM_PROJECT_DIR"/bin/foamEtcFile -sh "$@")";
}
fi
@ -162,7 +154,7 @@ then
# - use lib-dir script instead of rewriting
_foamAddLibAuto()
{
eval "$($WM_PROJECT_DIR/bin/tools/lib-dir -sh $@)";
eval "$("$WM_PROJECT_DIR"/bin/tools/lib-dir -sh "$@")";
}
fi

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

@ -6,18 +6,17 @@
# \\/ 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
# etc/config.sh/paraview
# - 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
@ -56,7 +55,6 @@
ParaView_VERSION=5.6.3
ParaView_QT=qt-system
cmake_version=cmake-system
# END OF (NORMAL) USER EDITABLE PART
#------------------------------------------------------------------------------
@ -65,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
@ -109,7 +99,7 @@ case "$ParaView_VERSION" in
(system)
unset PV_PLUGIN_PATH
eval "$($WM_PROJECT_DIR/bin/foamEtcFile -sh ${FOAM_CONFIG_NOUSER:+-mode=o} -config paraview-system)"
eval "$($WM_PROJECT_DIR/bin/foamEtcFile -sh -config paraview-system)"
;;
(*)
@ -207,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

@ -6,11 +6,10 @@
# \\/ 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
# etc/config.sh/settings

View File

@ -5,11 +5,10 @@
# \\ / 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, 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/setup
@ -19,15 +18,16 @@
# Finalize setup of OpenFOAM environment for POSIX shell.
#
# Environment
# FOAM_CONFIG_MODE (search mode for etc config files - see foamEtcFile)
# - eg, FOAM_CONFIG_MODE="o" to only use OpenFOAM config files
#
# FOAM_VERBOSE (set/unset)
# - add extra verbosity when sourcing files
# FOAM_CONFIG_NOUSER (set/unset)
# - suppress use of user/group configuration files
#
#------------------------------------------------------------------------------
# [FOAM_API] - The API level for the project
export FOAM_API="$($WM_PROJECT_DIR/bin/foamEtcFile -show-api)"
export FOAM_API=$("$WM_PROJECT_DIR/bin/foamEtcFile" -show-api)
# The installation parent directory
prefixDir="${WM_PROJECT_DIR%/*}"
@ -83,11 +83,22 @@ fi
# Overrides via <prefs.sh>
# 1. other (system) values
# 1. Always use O(ther) values from the OpenFOAM project etc/ directory
_foamEtc -mode=o prefs.sh
# 2. user or group values (unless disabled)
[ -z "$FOAM_CONFIG_NOUSER" ] && _foamEtc -mode=ug prefs.sh
# 2. (U)ser or (G)roup values (unless disabled).
unset configMode
if [ -z "$FOAM_CONFIG_MODE" ]
then
configMode="ug"
else
case "$FOAM_CONFIG_MODE" in (*[u]*) configMode="${configMode}u" ;; esac
case "$FOAM_CONFIG_MODE" in (*[g]*) configMode="${configMode}g" ;; esac
fi
if [ -n "$configMode" ]
then
_foamEtc -mode="$configMode" prefs.sh
fi
# Capture and evaluate any command-line parameters
@ -104,6 +115,21 @@ else
_foamEval "$@"
fi
# The prefs may have injected a FOAM_CONFIG_ETC value.
# Verify that it makes sense before continuing.
if [ -n "$FOAM_CONFIG_ETC" ]
then
if [ ! -d "$FOAM_CONFIG_ETC" ]
then
echo "Ignore invalid FOAM_CONFIG_ETC = $FOAM_CONFIG_ETC" 1>&2
unset FOAM_CONFIG_ETC
elif [ "$FOAM_CONFIG_ETC" = "$WM_PROJECT_DIR/etc" ]
then
# Redundant value
unset FOAM_CONFIG_ETC
fi
fi
# Clean standard environment variables (PATH, MANPATH, LD_LIBRARY_PATH)
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -121,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
@ -132,8 +157,8 @@ then
_foamAddMan "$WM_PROJECT_DIR/doc"
fi
# Interactive shell
if /usr/bin/tty -s 2>/dev/null
# Interactive shell (use PS1, not tty)
if [ -n "$PS1" ]
then
_foamEtc -config aliases
[ "${BASH_VERSINFO:-0}" -ge 4 ] && _foamEtc -config bash_completion

View File

@ -6,11 +6,10 @@
# \\/ 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
# etc/config.sh/unset
@ -35,19 +34,14 @@ foamOldDirs="$WM_PROJECT_DIR $WM_THIRD_PARTY_DIR \
unset WM_ARCH
unset WM_ARCH_OPTION
unset WM_CC
unset WM_CFLAGS
unset WM_COMPILER
unset WM_COMPILER_TYPE
unset WM_COMPILER_LIB_ARCH
unset WM_COMPILE_OPTION
unset WM_CXX
unset WM_CXXFLAGS
unset WM_DIR
unset WM_HOSTS
unset WM_LABEL_OPTION
unset WM_LABEL_SIZE
unset WM_LDFLAGS
unset WM_MPLIB
unset WM_NCOMPPROCS
unset WM_OPTIONS
@ -63,6 +57,10 @@ unset WM_PROJECT_VERSION
unset WM_SCHEDULER
unset WM_THIRD_PARTY_DIR
# Older variables
# Before 1906
unset WM_CC WM_CXX WM_CFLAGS WM_CXXFLAGS WM_LDFLAGS
#------------------------------------------------------------------------------
# Unset FOAM_* environment variables
@ -71,9 +69,12 @@ unset FOAM_API
unset FOAM_APPBIN
unset FOAM_APP
unset FOAM_CODE_TEMPLATES
unset FOAM_CONFIG_ETC
unset FOAM_CONFIG_MODE
unset FOAM_ETC
unset FOAM_EXTRA_CXXFLAGS
unset FOAM_EXTRA_LDFLAGS
unset FOAM_EXT_LIBBIN
unset FOAM_INST_DIR
unset FOAM_JOB_DIR
unset FOAM_LIBBIN
unset FOAM_MPI
@ -90,6 +91,10 @@ unset FOAM_USER_APPBIN
unset FOAM_USER_LIBBIN
unset FOAM_UTILITIES
# Old variables
# Before 1812
unset FOAM_INST_DIR
#------------------------------------------------------------------------------
# Unset MPI-related environment variables

View File

@ -29,11 +29,22 @@
# - $WM_PROJECT_SITE/$FOAM_API/etc/prefs.csh
# - $WM_PROJECT_SITE/prefs.csh
#
# Some settings can also be overridden on the command-line when
# sourcing this file. For example,
#
# source /path/etc/cshrc WM_COMPILER=Clang WM_LABEL_SIZE=64
#
# Environment
# FOAM_CONFIG_ETC
# - alternative/additional location for OpenFOAM etc/ directory
#
# FOAM_CONFIG_MODE (search mode for etc config files - see foamEtcFile)
# - eg, FOAM_CONFIG_MODE="o" to only use OpenFOAM config files
# - no influence on OpenFOAM applications, just the config files
#
# FOAM_VERBOSE (set/unset)
# - add extra verbosity when sourcing files
# FOAM_CONFIG_NOUSER (set/unset)
# - suppress use of user/group configuration files
#
# WM_PROJECT_SITE (optional directory)
# - local site-specific directory, uses WM_PROJECT_DIR/site if unset
#
@ -133,6 +144,11 @@ set projectDir=`lsof +p $$ |& \
# * on a 32-bit OS this option is ignored (always 32-bit)
#setenv WM_ARCH_OPTION 64
# [FOAM_EXTRA_CXXFLAGS]
# Additional compilation flags - do not inherit from the environment.
# Set after sourcing or via <prefs.csh> to avoid surprises.
unsetenv FOAM_EXTRA_CXXFLAGS
################################################################################
# NO (NORMAL) USER EDITING BELOW HERE

305
etc/openfoam Executable file
View File

@ -0,0 +1,305 @@
#!/bin/bash
#------------------------------------------------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2019-2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# Script
# openfoam [options] [args]
#
# Description
# 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.
#
# Note
# This script normally exists in the $WM_PROJECT_DIR/etc/ directory.
# Do not copy/move/link to other locations. Use instead an edited copy of
# `bin/tools/openfoam.in` with a hard-coded projectDir entry.
#
# See OpenFOAM etc/bashrc for (command-line) preferences.
# Some equivalent settings:
# -sp | -DWM_PRECISION_OPTION=SP
# -dp | -DWM_PRECISION_OPTION=DP
# -int32 | -DWM_LABEL_SIZE=32
# -int64 | -DWM_LABEL_SIZE=64
#
# However, the '-D' options grant more flexibility. For example,
# etc/openfoam -DWM_COMPILER=Clang
#
#------------------------------------------------------------------------------
# Auto-detect from location. Do not call from within the etc/directory itself!
projectDir="$(\cd "$(dirname "${0%/*}")" && \pwd -L)"
#------------------------------------------------------------------------------
printHelp() {
cat<<USAGE
Usage: ${0##*/} [OPTION] [application ...]
options:
-c command Execute shell commands with OpenFOAM environment
-Dkey[=value] Define key/value to pass as a preference
-sp Single precision
-dp Double precision
-spdp Mixed single/double precision
-int32 | -int64 The label-size
-etc=DIR Additional project etc/ directory
-prefix=DIR Alternative OpenFOAM project directory
-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:-???})
For a persistent OpenFOAM environment, the following can be added to your
~/.bashrc file:
source ${projectDir:-???}/etc/bashrc
For more information: www.openfoam.com
USAGE
exit 0 # A clean exit
}
#-------------------------------------------------------------------------------
# Get a value from META-INFO/api-info
# $1 : keyword
getApiInfo()
{
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
}
#-------------------------------------------------------------------------------
# - 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 ]
do
case "$1" in
-h | -help* | --help*)
printHelp
;;
-show-api | -version | --version) # Show API and exit
getApiInfo api
exit $?
;;
-show-patch) # Show patch level and exit
getApiInfo patch
exit $?
;;
-show-prefix) # Show project directory and exit
echo "$projectDir"
exit $?
;;
-test-tutorial) # Run tutorials/AutoTest
optTestTut=true
;;
-c) # Shell command
_foamScriptCommand="$2"
[ -n "$_foamScriptCommand" ] || {
echo "$0: missing or bad command argument: $2" 1>&2
exit 1
}
shift 2
break
;;
-D*) # Define key/value to pass as preference
setting="${1#-D}"
if [ -n "$setting" ]
then
_foamSettings="$_foamSettings${_foamSettings:+ }$setting"
fi
;;
-sp | -dp | -spdp )
# WM_PRECISION_OPTION=(SP|DP|SPDP)
setting=$(echo "${1#-}" | sed -e 's/-//g;y/sdp/SDP/')
_foamSettings="$_foamSettings${_foamSettings:+ }WM_PRECISION_OPTION=$setting"
;;
-int32 | -int64)
# WM_LABEL_SIZE=...
_foamSettings="$_foamSettings${_foamSettings:+ }WM_LABEL_SIZE=${1#-int}"
;;
-etc=*)
# Define FOAM_CONFIG_ETC for finding files
_foamEtcDir="${1#*=}"
;;
-prefix=*)
projectDir="${1#*=}"
;;
-verbose)
export FOAM_VERBOSE=true
;;
--)
shift
break
;;
-*)
echo "$0: unknown option: '$1'" 1>&2
exit 1
;;
*)
break
;;
esac
shift
done
#-------------------------------------------------------------------------------
# Sanity check (installed under /bin, /usr/bin, /usr/local/bin)
# This should not happen.
# If copied to a system dir, should also be using hard-coded values!
if [ "${projectDir%/bin}" != "$projectDir" ]
then
echo "Warning: suspicious project dir: $projectDir" 1>&2
fi
[ -d "$projectDir/META-INFO" ] || {
echo "Warning: missing META-INFO in OpenFOAM directory:" 1>&2
echo " $projectDir" 1>&2
}
# Remove current OpenFOAM environment
if [ -d "$WM_PROJECT_DIR" ] && [ -f "$WM_PROJECT_DIR/etc/config.sh/unset" ]
then
. "$WM_PROJECT_DIR/etc/config.sh/unset" || true
fi
unset interactive
if [ "$#" -eq 0 ] && [ -z "$_foamScriptCommand" ] && [ -z "$optTestTut" ]
then
# Interactive shell, chain off via a file
interactive=true
_foamSourceBashEnv="$projectDir/bin/tools/source-bashrc"
else
# Non-interactive shell, use the OPENFOAM etc/bashrc
_foamSourceBashEnv="$projectDir/etc/bashrc"
fi
[ -f "$_foamSourceBashEnv" ] || {
echo "Error: file not found: $_foamSourceBashEnv" 1>&2
exit 2
}
if [ -n "$_foamEtcDir" ] && [ -d "$_foamEtcDir" ]
then
# Additional etc directory
export FOAM_CONFIG_ETC="$_foamEtcDir"
fi
if [ -n "$interactive" ]
then
# Interactive shell
# -----------------
# Source ~/.bashrc and OpenFOAM etc/bashrc in one of two ways:
# 1) Generate and use a tmp file
# 2) Chain off to a dedicated file [This is what we use]
if [ -n "$_foamSettings" ]
then
# Pass preferences via the FOAM_SETTINGS mechanism
export FOAM_SETTINGS="$_foamSettings"
fi
## echo "Source with $_foamSourceBashEnv with '$FOAM_SETTINGS'" 1>&2
# Newer bash can use --init-file instead of --rcfile
exec bash --rcfile "$_foamSourceBashEnv" -i
exit $? # Safety
fi
# Non-interactive shell
# ---------------------
# Source bashrc within a function to preserve command-line arguments
# Suppresses aliases as a side-effect, but non-interactive anyhow.
sourceBashrc()
{
. "$_foamSourceBashEnv" $_foamSettings
}
if [ -n "$_foamScriptCommand" ]
then
# A shell command
sourceBashrc
exec bash -c "$_foamScriptCommand" "$@"
exit $? # Safety
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',
# so we need to catch this to avoid infinite recursion.
if [ -f "$1" ] \
&& [ -n "$(sed -ne '1{/^#!.*\/openfoam$/p; q}' "$1" 2>/dev/null)" ]
then
# A shell script
sourceBashrc
exec bash "$@"
else
# An application
sourceBashrc
exec "$@"
fi
#------------------------------------------------------------------------------

View File

@ -11,7 +11,7 @@ Overview
Meshing
=======
+ Meshing is setup as in the inflowOutflow template
+ See $FOAM_ETC/templates/inflowOutflow/README for details
+ See etc/templates/inflowOutflow/README for details
+ The setup includes an example for one named patch to be generated in the mesh
+ In snappyHexMeshDict, replace <CADregionName> with the name of region in the
trisurface; replace <patchName> with the name of the resulting mesh patch
@ -21,4 +21,4 @@ Initialisation
+ In the field files in the 0 directory, set initial values
+ The template includes a fixedValue boundary condition on <patchName> in 0/T
+ The user can replace <patchName> with a real mesh patch name and apply a
fixed temperature on that patch
fixed temperature on that patch

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

@ -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

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2017 OpenFOAM Foundation
Copyright (C) 2018-2019 OpenCFD Ltd.
Copyright (C) 2018-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -143,7 +143,8 @@ bool Foam::functionEntries::includeEntry::execute
{
if (Foam::functionEntries::includeEntry::log)
{
DetailInfo << fName << endl;
// Report to stdout which file is included
Info<< fName << nl;
}
// Add watch on included file
@ -194,7 +195,8 @@ bool Foam::functionEntries::includeEntry::execute
{
if (Foam::functionEntries::includeEntry::log)
{
DetailInfo << fName << endl;
// Report to stdout which file is included
Info<< fName << nl;
}
// Add watch on included file

View File

@ -6,7 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2015-2017 OpenFOAM Foundation
Copyright (C) 2019 OpenCFD Ltd.
Copyright (C) 2019-2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -123,7 +123,8 @@ bool Foam::functionEntries::includeEtcEntry::execute
{
if (Foam::functionEntries::includeEtcEntry::log)
{
DetailInfo << fName << endl;
// Report to stdout which file is included
Info<< fName << nl;
}
parentDict.read(ifs);
return true;
@ -162,7 +163,8 @@ bool Foam::functionEntries::includeEtcEntry::execute
{
if (Foam::functionEntries::includeEtcEntry::log)
{
DetailInfo << fName << endl;
// Report to stdout which file is included
Info<< fName << nl;
}
entry.read(parentDict, ifs);
return true;

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

@ -286,7 +286,7 @@ Foam::fileOperations::collatedFileOperation::collatedFileOperation
"enabled, deactivate" << nl
<< " threading by setting maxThreadFileBufferSize "
"to 0 in" << nl
<< " $FOAM_ETC/controlDict"
<< " OpenFOAM etc/controlDict"
<< endl;
}

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

@ -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

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

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

@ -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

@ -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

@ -6,6 +6,7 @@
\\/ M anipulation |
-------------------------------------------------------------------------------
Copyright (C) 2011-2016 OpenFOAM Foundation
Copyright (C) 2020 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
@ -78,18 +79,18 @@ Foam::point Foam::BSpline::position
const point& p0 = points()[segment];
const point& p1 = points()[segment+1];
// special cases - no calculation needed
if (mu <= 0.0)
// Special cases - no calculation needed
// Note: only checks at overall endpoints
if ((segment == 0) && (mu <= 0.0))
{
return p0;
}
else if (mu >= 1.0)
else if ((segment == nSegments() - 1) && (mu >= 1.0))
{
return p1;
}
// determine the end points
// Determine the end points
point e0;
point e1;
@ -113,7 +114,6 @@ Foam::point Foam::BSpline::position
e1 = points()[segment+2];
}
return 1.0/6.0 *
(
( e0 + 4*p0 + p1 )

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.
@ -50,13 +50,30 @@ namespace surfaceWriters
namespace Foam
{
//- A (0-1) range for colouring
inline scalar srange01(const scalarMinMax& range, scalar x)
{
if (x >= range.max())
{
return 1;
}
x -= range.min();
if (x < VSMALL)
{
return 0;
}
return x / (range.max() - range.min());
}
//- A (0-1) range for colouring
template<class Type>
static inline scalar rangex(const scalarMinMax& range, const Type& val)
{
scalar x = Foam::mag(val);
return (x - range.min()) / (range.max() - range.min());
return srange01(range, Foam::mag(val));
}
@ -64,8 +81,7 @@ static inline scalar rangex(const scalarMinMax& range, const Type& val)
template<>
inline scalar rangex(const scalarMinMax& range, const scalar& val)
{
scalar x = val;
return (x - range.min()) / (range.max() - range.min());
return srange01(range, val);
}
@ -73,8 +89,7 @@ inline scalar rangex(const scalarMinMax& range, const scalar& val)
template<>
inline scalar rangex(const scalarMinMax& range, const label& val)
{
scalar x = val;
return (x - range.min()) / (range.max() - range.min());
return srange01(range, val);
}
@ -266,8 +281,17 @@ Foam::fileName Foam::surfaceWriters::x3dWriter::writeTemplate
if (!range.valid())
{
range = minMaxMag(values);
if (equal(range.mag(), 0))
{
range.add(range.centre());
}
}
// Slight rounding
range.min() -= VSMALL;
range.max() += VSMALL;
if (!isDir(outputFile.path()))
{
mkDir(outputFile.path());

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

@ -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.
@ -72,7 +72,7 @@ Foam::radiation::P1::P1(const volScalarField& T)
"qr",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
mesh_,
@ -142,7 +142,7 @@ Foam::radiation::P1::P1(const dictionary& dict, const volScalarField& T)
"qr",
mesh_.time().timeName(),
mesh_,
IOobject::NO_READ,
IOobject::READ_IF_PRESENT,
IOobject::AUTO_WRITE
),
mesh_,
@ -190,12 +190,6 @@ Foam::radiation::P1::P1(const dictionary& dict, const volScalarField& T)
{}
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
Foam::radiation::P1::~P1()
{}
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
bool Foam::radiation::P1::read()
@ -240,19 +234,19 @@ void Foam::radiation::P1::calculate()
fvm::laplacian(gamma, G_)
- fvm::Sp(a_, G_)
==
- 4.0*(e_*physicoChemical::sigma*pow4(T_) ) - E_
- 4.0*(e_*physicoChemical::sigma*pow4(T_)) - E_
);
volScalarField::Boundary& qrBf = qr_.boundaryFieldRef();
// Calculate radiative heat flux on boundaries.
volScalarField::Boundary& qrBf = qr_.boundaryFieldRef();
const volScalarField::Boundary& GBf = G_.boundaryField();
const volScalarField::Boundary& gammaBf = gamma.boundaryField();
forAll(mesh_.boundaryMesh(), patchi)
{
if (!G_.boundaryField()[patchi].coupled())
if (!GBf[patchi].coupled())
{
qrBf[patchi] =
-gamma.boundaryField()[patchi]
*G_.boundaryField()[patchi].snGrad();
qrBf[patchi] = -gammaBf[patchi]*GBf[patchi].snGrad();
}
}
}
@ -282,12 +276,9 @@ Foam::tmp<Foam::volScalarField> Foam::radiation::P1::Rp() const
Foam::tmp<Foam::DimensionedField<Foam::scalar, Foam::volMesh>>
Foam::radiation::P1::Ru() const
{
const volScalarField::Internal& G =
G_();
const volScalarField::Internal E =
absorptionEmission_->ECont()()();
const volScalarField::Internal a =
absorptionEmission_->aCont()()();
const volScalarField::Internal& G = G_();
const volScalarField::Internal E = absorptionEmission_->ECont()()();
const volScalarField::Internal a = absorptionEmission_->aCont()()();
return a*G - E;
}
@ -298,4 +289,5 @@ Foam::label Foam::radiation::P1::nBands() const
return absorptionEmission_->nBands();
}
// ************************************************************************* //

View File

@ -107,7 +107,7 @@ public:
//- Destructor
virtual ~P1();
virtual ~P1() = default;
// Member functions

199
tutorials/AutoTest Executable file
View File

@ -0,0 +1,199 @@
#!/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
# tutorials/AutoTest dir [.. dirN]
#
# Description
# Run foamRunTutorials with specified tutorial directories
# Creates/destroys a temporary directory for each test.
#
# Environment
# Requires an initialized OpenFOAM environment.
#
# Note
# Potentially useful for debian autopkgtest
#
#------------------------------------------------------------------------------
# Auto-detect from location
#Unused# projectDir="$(\cd "$(dirname "${0%/*}")" && \pwd -L)"
#------------------------------------------------------------------------------
printHelp() {
cat<<USAGE
usage: ${0##*/} [OPTION] dir [.. dirN]
options:
-1 Modify case controlDict to run only one time step (default)
-full Do not modify controlDict (run tutorial to completion)
-debian Any modifications when running with autopkgtest
-help Print the usage
Run foamRunTutorials with specified tutorial directories.
Creates/destroys a temporary directory for each.
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
}
#------------------------------------------------------------------------------
unset optDebian optVerbose
optRunLimit=1
# Parse options
while [ "$#" -gt 0 ]
do
case "$1" in
-h*)
printHelp
;;
-1)
optRunLimit="${1#-}"
;;
-full)
unset optRunLimit
;;
-debian)
# Redirect stderr to stdout, if autopkgtest (tests/control)
# does NOT use "Restrictions: allow-stderr"
exec 2>&1
;;
--)
break
;;
-*)
die "unknown option $1"
;;
*)
break
;;
esac
shift
done
#------------------------------------------------------------------------------
# Basic sanity checks
[ -n "$FOAM_TUTORIALS" ] || export FOAM_TUTORIALS="$WM_PROJECT_DIR"/tutorials
[ -d "${WM_PROJECT_DIR:?}" ] || die "No OpenFOAM environment: $WM_PROJECT_DIR"
[ -d "$FOAM_TUTORIALS" ] || die "No OpenFOAM tutorials : $FOAM_TUTORIALS"
#------------------------------------------------------------------------------
#
# Modify case controlDicts to run only one time step
#
modifyCaseControlDict()
{
for dict in $(find . -name "controlDict*" -type f)
do
cp -f "${dict}" "${dict}.orig"
sed \
-e 's/\(startFrom[ \t]*\)\([A-Za-z]*\);/\1 latestTime;/' \
-e 's/\(stopAt[ \t]*\)\([A-Za-z]*\);/\1 nextWrite;/' \
-e 's/\(writeControl[ \t]*\)\([A-Za-z]*\);/\1 timeStep;/' \
-e 's/\(writeInterval[ \t]*\)\([-.0-9A-Za-z]*\);/\1 '"$optRunLimit"';/' \
"${dict}.orig" > "${dict}"
done
}
#------------------------------------------------------------------------------
nTests="$#"
nPassed=0
for testdir in "$@"
do
testdir="${testdir#tutorials/}"
testdir="$(echo "$testdir" | sed -e 's@^//*@@; s@//*$@@;')"
suffix="$(echo "$testdir" | sed -e 's@//*@_@g')"
if [ -n "$testdir" ] && [ -d "$FOAM_TUTORIALS/$testdir" ]
then
(
echo "Run test: $testdir"
set -e
TESTDIR="$(mktemp --directory --suffix=".$suffix")"
trap 'rm -rf $TESTDIR' 0 INT QUIT ABRT PIPE TERM
cp -r "$FOAM_TUTORIALS/$testdir"/* "$TESTDIR"/
cd "$TESTDIR"
if [ -n "$optRunLimit" ]
then
set +e
modifyCaseControlDict
set -e
fi
nInput="$(ls | wc -l)"
foamRunTutorials
nOutput="$(ls | wc -l)"
if [ "$nInput" = 0 ]
then
echo "No input for $testdir" 1>&2
exit 1
elif [ "$nOutput" = "$nInput" ]
then
echo "Run failure for $testdir" 1>&2
exit 1
else
echo "run: OK"
fi
) && nPassed=$((nPassed + 1))
else
echo "No tutorial: $testdir" 1>&2
fi
done
if [ "$nTests" = 0 ]
then
die "No tests specified"
elif [ "$nPassed" = "$nTests" ]
then
echo "Passed all $nTests tests"
else
echo "Passed $nPassed/$nTests tests" 1>&2
exit 1
fi
#------------------------------------------------------------------------------

1
tutorials/modules/README Normal file
View File

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

View File

@ -6,11 +6,10 @@
# \\/ 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, 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
# wmake/makefiles/general
@ -67,6 +66,14 @@ EXE_LIBS =
LIB_LIBS =
# These variables are used for some builds - provide fallback values
ifeq (,$(FOAM_SOLVERS))
FOAM_SOLVERS = $(WM_PROJECT_DIR)/applications/solvers
endif
ifeq (,$(FOAM_UTILITIES))
FOAM_UTILITIES = $(WM_PROJECT_DIR)/applications/utilities
endif
#------------------------------------------------------------------------------
# Declare default name of libraries and executables
#------------------------------------------------------------------------------

View File

@ -14,9 +14,12 @@ c++WARN = \
-Wall -Wextra -Wold-style-cast \
-Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof \
-Wno-undefined-var-template \
-Wno-unknown-warning-option
-Wno-unknown-warning-option \
$(FOAM_EXTRA_CXXFLAGS)
c++LESSWARN = \
-Wno-old-style-cast -Wno-unused-local-typedefs \
-Wno-tautological-undefined-compare -Wno-shift-negative-value \
-Wno-null-pointer-arithmetic
#------------------------------------------------------------------------------

View File

@ -1,8 +0,0 @@
# Flags for compiling/linking openmp
# The USE_OMP is for OpenFOAM-specific use (general use is _OPENMP)
# -
# Clang provides 'omp' and a link for 'gomp'.
# With 'gomp' we can use system libs.
COMP_OPENMP = -DUSE_OMP -fopenmp
LINK_OPENMP = -lgomp

View File

@ -0,0 +1 @@
openmp-gomp

View File

@ -0,0 +1,8 @@
# Flags for compiling/linking openmp
# The USE_OMP is for OpenFOAM-specific use (general use is _OPENMP)
# -
# Clang provides 'omp' and a link for 'gomp'.
# With 'gomp' we can also use system libs.
COMP_OPENMP = -DUSE_OMP -fopenmp
LINK_OPENMP = -lgomp

View File

@ -0,0 +1,5 @@
# Flags for compiling/linking openmp
# The USE_OMP is for OpenFOAM-specific use (general use is _OPENMP)
COMP_OPENMP = -DUSE_OMP -fopenmp
LINK_OPENMP = -lomp

View File

@ -13,9 +13,12 @@ ptFLAGS = -DNoRepository -ftemplate-depth-100
c++WARN = \
-Wall -Wextra -Wold-style-cast \
-Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof \
-Wno-attributes -Wno-unknown-pragmas
-Wno-attributes -Wno-unknown-pragmas \
$(FOAM_EXTRA_CXXFLAGS)
c++LESSWARN = \
-Wno-old-style-cast -Wno-unused-local-typedefs -Wno-array-bounds \
-Wno-deprecated-declarations \
-fpermissive
#------------------------------------------------------------------------------

View File

@ -14,7 +14,10 @@ c++WARN = \
-Wall -Wextra \
-Wnon-virtual-dtor -Wno-unused-parameter -Wno-invalid-offsetof \
-Wno-unknown-pragmas \
-diag-disable 327,654,1125,1292,2289,2304,11062,11074,11076
-diag-disable 327,654,1125,1292,2289,2304,11062,11074,11076 \
$(FOAM_EXTRA_CXXFLAGS)
c++LESSWARN = \
-diag-disable 1224,2026,2305
#------------------------------------------------------------------------------

View File

@ -10,5 +10,9 @@ ptFLAGS = -DNoRepository
# - Standard warnings
# - Less restrictive warnings (may be needed for flex++, CGAL, etc.)
c++WARN =
c++WARN = \
$(FOAM_EXTRA_CXXFLAGS)
c++LESSWARN =
#------------------------------------------------------------------------------

View File

@ -14,25 +14,29 @@ GLIBS = -lm
GLIB_LIBS =
COMPILER_FAMILY = $(shell echo "$(WM_COMPILER)" | sed -e 's/[0-9].*//')
DEFAULT_RULES = $(WM_DIR)/rules/$(WM_ARCH)$(COMPILER_FAMILY)
RULES = $(WM_DIR)/rules/$(WM_ARCH)$(WM_COMPILER)
WMAKE_BIN = $(WM_DIR)/platforms/$(WM_ARCH)$(WM_COMPILER)
ARCHITECTURE_RULES = $(WM_DIR)/rules/$(WM_ARCH)
COMPILER_FAMILY = $(shell echo "$(WM_COMPILER)" | sed -e 's/[-+.0-9~].*//')
DEFAULT_RULES = $(ARCHITECTURE_RULES)$(COMPILER_FAMILY)
RULES = $(ARCHITECTURE_RULES)$(WM_COMPILER)
WMAKE_BIN = $(WM_PROJECT_DIR)/platforms/tools/$(WM_ARCH)$(WM_COMPILER)
# Default compilation is 'Opt' - never permit an empty value
ifeq ($(WM_COMPILE_OPTION),)
ifeq (,$(WM_COMPILE_OPTION))
WM_COMPILE_OPTION = Opt
endif
ifeq ($(WM_SCHEDULER),)
ifeq (,$(WM_SCHEDULER))
AND = &&
else
AND = '&&'
endif
include $(DEFAULT_RULES)/general
sinclude $(DEFAULT_RULES)/override
ifneq ("$(COMPILER_FAMILY)","$(WM_COMPILER)")
sinclude $(RULES)/general
sinclude $(RULES)/c++
endif
include $(GENERAL_RULES)/transform
#------------------------------------------------------------------------------

View File

@ -1,3 +0,0 @@
PFLAGS =
PINC =
PLIBS =

1
wmake/rules/General/mplib Symbolic link
View File

@ -0,0 +1 @@
no-mpi

View File

@ -0,0 +1,6 @@
# Empty flags for not compiling/linking with CGAL
CGAL_INC =
CGAL_LIBS =
#------------------------------------------------------------------------------

View File

@ -0,0 +1,7 @@
# Empty flags for not compiling/linking MPI
PFLAGS =
PINC =
PLIBS =
#------------------------------------------------------------------------------

View File

@ -0,0 +1,6 @@
# Empty flags for not compiling/linking OPENMP
COMP_OPENMP =
LINK_OPENMP =
#------------------------------------------------------------------------------

View File

@ -1,6 +1,6 @@
include $(GENERAL_RULES)/Clang/c++
c++ARCH = -m64 -ftrapping-math
c++ARCH = -m64 -pthread -ftrapping-math
include $(DEFAULT_RULES)/c++$(WM_COMPILE_OPTION)

View File

@ -3,7 +3,16 @@ CPP = cpp -traditional-cpp $(GFLAGS)
PROJECT_LIBS = -l$(WM_PROJECT) -ldl
include $(GENERAL_RULES)/standard
include $(GENERAL_RULES)/Clang/openmp
## include $(GENERAL_RULES)/Clang/openmp
# Darwin-specific
# ----
COMP_OPENMP = -DUSE_OMP -Xpreprocessor -fopenmp
LINK_OPENMP = -lomp
# ----
# Or disable
# include $(GENERAL_RULES)/no-openmp
# ----
include $(DEFAULT_RULES)/c
include $(DEFAULT_RULES)/c++

View File

@ -1,6 +1,6 @@
include $(GENERAL_RULES)/Clang/c++
c++ARCH = -m64
c++ARCH = -m64 -pthread
include $(DEFAULT_RULES)/c++$(WM_COMPILE_OPTION)

View File

@ -2,7 +2,7 @@ include $(GENERAL_RULES)/Gcc/c++
CC = CC -std=c++11
c++ARCH = -m64
c++ARCH = -m64 -pthread
include $(DEFAULT_RULES)/c++$(WM_COMPILE_OPTION)

View File

@ -1,6 +1,6 @@
include $(GENERAL_RULES)/Gcc/c++
c++ARCH = -m64
c++ARCH = -m64 -pthread
include $(DEFAULT_RULES)/c++$(WM_COMPILE_OPTION)

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