Compare commits

...

26 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
78 changed files with 2020 additions and 1580 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=200403
patch=200626

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'.
@ -67,8 +66,8 @@ options:
-config Add config directory prefix for shell type:
with -csh* for a config.csh/ prefix
with -sh* for a config.sh/ prefix
-show-api Print api value from wmake/rules, or meta-info and exit
-show-patch Print patch value from meta-info and exit
-show-api Print META-INFO api value and exit
-show-patch Print META-INFO patch value and exit
-with-api=NUM Specify alternative api value to search with
-quiet (-q) Suppress all normal output
-silent (-s) Suppress stderr, except -csh-verbose, -sh-verbose output
@ -129,54 +128,17 @@ fi
#-------------------------------------------------------------------------------
# The API locations. See wmake/wmakeBuildInfo
rulesFile="$projectDir/wmake/rules/General/general"
metaInfoDir="$projectDir/META-INFO"
# Get api from rules/General/general
#
# Failure modes:
# - No api information (can't find file etc).
# -> Fatal for building, but could be OK for a stripped down version
#
# Fallback. Get from api-info
#
getApi()
# Get a value from META-INFO/api-info
# $1 : keyword
getApiInfo()
{
local value
value="$(sed -ne '/^ *#/!{ /WM_VERSION.*OPENFOAM=/{ s@^.*OPENFOAM= *\([0-9][0-9]*\).*@\1@p; q }}' $rulesFile 2>/dev/null)"
if [ -z "$value" ] && [ -f "$metaInfoDir/api-info" ]
then
# Fallback. Get from api-info
value="$(sed -ne 's@^ *api *= *\([0-9][0-9]*\).*@\1@p' $metaInfoDir/api-info 2>/dev/null)"
fi
if [ -n "$value" ]
then
echo "$value"
else
return 1
fi
}
# Get patch from meta-info / api-info
#
# Failure modes:
# - No patch information (can't find file etc).
#
getPatchLevel()
{
local value
# Fallback. Get from api-info
value="$(sed -ne 's@^ *patch *= *\([0-9][0-9]*\).*@\1@p' $metaInfoDir/api-info 2>/dev/null)"
value="$(sed -ne 's@^'"$1"' *= *\([0-9][0-9]*\).*@\1@p' "$projectDir"/META-INFO/api-info 2>/dev/null)"
if [ -n "$value" ]
then
echo "$value"
else
echo "Could not determine OPENFOAM '$1' value" 1>&2
return 1
fi
}
@ -193,14 +155,12 @@ do
-h | -help*)
printHelp
;;
-show-api)
# Show API and exit
getApi
-show-api) # Show API and exit
getApiInfo api
exit $?
;;
-show-patch)
# Show patch level and exit
getPatchLevel
-show-patch) # Show patch level and exit
getApiInfo patch
exit $?
;;
-with-api=*)
@ -276,7 +236,7 @@ done
#-------------------------------------------------------------------------------
# Establish the API value
[ -n "$projectApi" ] || projectApi=$(getApi)
[ -n "$projectApi" ] || projectApi=$(getApiInfo api)
# Split arguments into filename (for searching) and trailing bits for shell eval
# Silently remove leading ~OpenFOAM/ (as per Foam::findEtcFile)

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

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

View File

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

View File

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

View File

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

1
doc/modules/README Normal file
View File

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

View File

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

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

@ -0,0 +1,35 @@
#----------------------------------*-sh-*--------------------------------------
# ========= |
# \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
# \\ / O peration |
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2020 OpenCFD Ltd.
#------------------------------------------------------------------------------
# License
# This file is part of OpenFOAM, distributed under GPL-3.0-or-later.
#
# File
# etc/config.sh/cmake
# - possibly sourced during make process only.
#
# Description
# CMAKE location (ThirdParty or otherwise) when not found via the PATH
# Does not affect the PATH, that is left for the caller
#
# For system-wide installations:
# cmake_version=cmake-system
# define CMAKE_ARCH_PATH
#
# Note
# No csh version. This file is only used during make processes.
#
#------------------------------------------------------------------------------
# USER EDITABLE PART: Changes made here may be lost with the next upgrade
cmake_version=cmake-system
export CMAKE_ARCH_PATH="$WM_THIRD_PARTY_DIR/platforms/$WM_ARCH$WM_COMPILER/$cmake_version"
# END OF (NORMAL) USER EDITABLE PART
#------------------------------------------------------------------------------

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

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

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

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

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

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

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

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

@ -5,18 +5,27 @@
# \\ / 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, 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
# cmakeFunctions
#
# Description
# Helper functions for CMake
#
# Environment
# Consider CMAKE_INSTALL_PREFIX as a reserved name, although it is not
# set/unset here.
#
# Files
# Uses etc/config.sh/cmake (if it exists) for the
# CMAKE_ARCH_PATH that may specify a possible cmake/bin directory.
#
#------------------------------------------------------------------------------
. ${WM_PROJECT_DIR:?}/wmake/scripts/have_cmake
. ${WM_PROJECT_DIR:?}/wmake/scripts/wmakeFunctions # Require wmake functions
# Export compiler information for cmake
@ -29,48 +38,92 @@ export CXXFLAGS="$(wmake -show-cxxflags)"
#------------------------------------------------------------------------------
#
# Check sentinel file(s) to handle paraview / vtk version changes
# Save build/configure parameter information (dependency) into sentinel file
#
sameDependency()
# 1 - sentinelFile
# 2... build/configure parameters
#
storeDependency()
{
local depend="$1"
local sourceDir="$2"
local objectsDir sentinel prev
local sentinel="$1"
local depend
shift
# Where generated files are stored
objectsDir=$(findObjectDir "$sourceDir") || exit 1 # Fatal
sentinel="$objectsDir/ThirdParty"
echo "$sentinel"
if read -r prev 2>/dev/null < $sentinel
if [ -n "$sentinel" ]
then
if [ "$prev" = "$depend" ]
then
return 0
else
echo "${depend%=*} changed between builds" 1>&2
return 1
fi
elif [ -f "$objectsDir/CMakeCache.txt" ]
then
echo "previous build was incomplete" 1>&2
return 1
else
return 0
mkdir -p "$(dirname "$sentinel")"
echo '# Build/configure parameters' >| "$sentinel"
for depend
do
echo "-- $depend"
done >> "$sentinel"
fi
return 0
}
# CMake with output suppressed according to WM_QUIET
_cmake()
#
# Check sentinel file(s) to handle changed build/configure parameters
# such as paraview / vtk version changes
#
# 1 - sourceDir
# 2... build/configure parameters
#
sameDependency()
{
echo "cmake..."
if [ -n "$WM_QUIET" ]
local sourceDir="$1"
shift
local depend objectsDir
local compare=0
# Where generated files are stored
objectsDir=$(findObjectDir "$sourceDir") || exit 1 # Fatal
local sentinel="$objectsDir/ThirdParty"
if [ -f "$sentinel" ]
then
cmake -DCMAKE_RULE_MESSAGES=OFF $@ >/dev/null
# Create an .update version
storeDependency "${sentinel}.update" $@
cmp "${sentinel}" "${sentinel}.update" >/dev/null 2>&1
compare=$?
if [ "$compare" -ne 0 ]
then
echo "build/configure parameters changed between builds" 1>&2
fi
else
cmake $@
# No sentinel file: First time, or failed compilation?
if [ -f "$objectsDir/CMakeCache.txt" ]
then
echo "previous build was incomplete" 1>&2
compare=1
fi
fi
echo "$sentinel"
return "$compare"
}
# Resolve the location of cmake (if needed) and call with output
# suppressed according to WM_QUIET
call_cmake()
{
if have_cmake
then
if [ -n "$WM_QUIET" ]
then
echo "cmake..."
"$CMAKE_EXE" -DCMAKE_RULE_MESSAGES=OFF $@ >/dev/null
else
echo "cmake $@"
"$CMAKE_EXE" $@
fi
else
return 1
fi
}
@ -93,12 +146,13 @@ cmakeVersioned()
objectsDir=$(findObjectDir "$sourceDir") || exit 1 # Fatal
# Version changed
sentinel=$(sameDependency "$depend" "$sourceDir") || \
sentinel=$(sameDependency "$sourceDir" "$depend" $@) || \
rm -rf "$objectsDir" 2>/dev/null
mkdir -p "$objectsDir" \
&& (cd "$objectsDir" && _cmake "$@" "$sourceDir" && make) \
&& echo "$depend" >| "${sentinel:-/dev/null}"
&& ( cd "$objectsDir" && call_cmake "$@" "$sourceDir" && \
make "-j${WM_NCOMPPROCS:-1}" ) \
&& storeDependency "$sentinel" "$depend" $@
}
@ -119,12 +173,13 @@ cmakeVersionedInstall()
objectsDir=$(findObjectDir "$sourceDir") || exit 1 # Fatal
# Version changed
sentinel=$(sameDependency "$depend" "$sourceDir") || \
sentinel=$(sameDependency "$sourceDir" "$depend" $@) || \
rm -rf "$objectsDir" 2>/dev/null
mkdir -p "$objectsDir" \
&& (cd "$objectsDir" && _cmake "$@" "$sourceDir" && make install) \
&& echo "$depend" >| "${sentinel:-/dev/null}"
&& ( cd "$objectsDir" && call_cmake "$@" "$sourceDir" && \
make "-j${WM_NCOMPPROCS:-1}" install ) \
&& storeDependency "$sentinel" "$depend" $@
}
@ -146,12 +201,12 @@ wmakeVersioned()
objectsDir=$(findObjectDir "$sourceDir") || exit 1 # Fatal
# Version changed
sentinel=$(sameDependency "$depend" "$sourceDir") || \
sentinel=$(sameDependency "$sourceDir" "$depend" $@) || \
rm -rf "$objectsDir" 2>/dev/null
mkdir -p "$objectsDir" \
&& wmake "$@" \
&& echo "$depend" >| "${sentinel:-/dev/null}"
&& storeDependency "$sentinel" "$depend" $@
}

View File

@ -5,11 +5,10 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2019 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
# have_adios2
@ -21,7 +20,7 @@
# ADIOS2_ARCH_PATH
#
# Functions provided
# have_adios2, no_adios2, echo_adios2, hint_adios2
# have_adios2, no_adios2, echo_adios2, hint_adios2, query_adios2
#
# Variables set on success
# HAVE_ADIOS2
@ -38,7 +37,6 @@
no_adios2()
{
unset HAVE_ADIOS2 ADIOS2_INC_DIR ADIOS2_LIB_DIR
return 0
}
@ -68,26 +66,44 @@ INFORMATION
}
# Query settings
query_adios2()
{
local config="config.sh/adios2"
local settings
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile -mode=o "$config")"
then
. "$settings"
_process_query adios2 "$ADIOS2_ARCH_PATH"
else
echo "(no $config settings)" 1>&2
echo "adios2=unknown"
fi
}
# On success, return 0 and export variables
# -> HAVE_ADIOS2, ADIOS2_INC_DIR, ADIOS2_LIB_DIR
have_adios2()
{
local prefix header library incName libName settings warn
# warn="==> skip adios2"
local warn # warn="==> skip adios2"
local config="config.sh/adios2"
local settings
# Setup
if settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/adios2)
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile "$config")"
then
. "$settings"
else
[ -n "$warn" ] && echo "$warn (no config.sh/adios2 settings)"
[ -n "$warn" ] && echo "$warn (no $config settings)"
return 2
fi
# Expected location, include/library names
prefix="$ADIOS2_ARCH_PATH"
incName="adios2.h"
libName="libadios2"
local prefix="$ADIOS2_ARCH_PATH"
local incName="adios2.h"
local libName="libadios2"
local header library
# ----------------------------------
if isNone "$prefix"
@ -134,11 +150,15 @@ have_adios2()
# Reset variables
no_adios2
# Testing
if [ "$1" = "-test" ]
then
# Test/query
case "$1" in
-test)
have_adios2
echo_adios2
fi
;;
-query)
query_adios2
;;
esac
#------------------------------------------------------------------------------

View File

@ -5,23 +5,23 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2019 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
# have_boost
#
# Description
# Detection/setup of Boost
# Detection/setup of BOOST
#
# Requires
# BOOST_ARCH_PATH
# or config.sh/CGAL (when BOOST_ARCH_PATH is empty)
#
# Functions provided
# have_boost, no_boost, echo_boost
# have_boost, no_boost, echo_boost, query_boost
#
# Variables set on success
# HAVE_BOOST
@ -38,7 +38,6 @@
no_boost()
{
unset HAVE_BOOST BOOST_INC_DIR BOOST_LIB_DIR
return 0
}
@ -52,19 +51,48 @@ echo_boost()
}
# Query settings (from CGAL setup)
query_boost()
{
local config="config.sh/CGAL"
local settings
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile -mode=o "$config")"
then
. "$settings"
_process_query boost "$BOOST_ARCH_PATH"
else
echo "(no $config settings)" 1>&2
echo "boost=unknown"
fi
}
# On success, return 0 and export variables
# -> HAVE_BOOST, BOOST_INC_DIR, BOOST_LIB_DIR
have_boost()
{
local prefix header library incName libName settings warn
# warn="==> skip boost"
local warn # warn="==> skip boost"
local config="config.sh/CGAL"
local settings
# Setup - from the current environment
# Setup - current environment if set
if [ -z "$BOOST_ARCH_PATH" ]
then
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile "$config")"
then
. "$settings"
else
[ -n "$warn" ] && echo "$warn (no $config settings)"
return 2
fi
fi
# Expected location, include/library names
prefix="$BOOST_ARCH_PATH"
incName="boost/version.hpp"
libName="libboost_system"
local prefix="$BOOST_ARCH_PATH"
local incName="boost/version.hpp"
local libName="libboost_system"
local header library
# ----------------------------------
if isNone "$prefix"
@ -113,11 +141,15 @@ have_boost()
# Reset variables
no_boost
# Testing
if [ "$1" = "-test" ]
then
# Test/query
case "$1" in
-test)
have_boost
echo_boost
fi
;;
-query)
query_boost
;;
esac
#------------------------------------------------------------------------------

View File

@ -5,23 +5,22 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2019 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
# have_ccmio
#
# Description
# Detection/setup of ccmio
# Detection/setup of CCMIO
#
# Requires
# config.sh/ccmio
#
# Functions provided
# have_ccmio, no_ccmio, echo_ccmio
# have_ccmio, no_ccmio, echo_ccmio, query_ccmio
#
# Variables set on success
# HAVE_CCMIO
@ -38,9 +37,9 @@
no_ccmio()
{
unset HAVE_CCMIO CCMIO_INC_DIR CCMIO_LIB_DIR
return 0
}
# Report
echo_ccmio()
{
@ -51,27 +50,45 @@ echo_ccmio()
}
# Query settings
query_ccmio()
{
local config="config.sh/ccmio"
local settings
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile -mode=o "$config")"
then
. "$settings"
_process_query ccmio "$CCMIO_ARCH_PATH"
else
echo "(no $config settings)" 1>&2
echo "ccmio=unknown"
fi
}
# On success, return 0 and export variables
# -> HAVE_CCMIO, CCMIO_INC_DIR, CCMIO_LIB_DIR
have_ccmio()
{
local prefix header library incName libName settings warn
warn="==> skip ccmio"
local warn="==> skip ccmio"
local config="config.sh/ccmio"
local settings
# Setup
if settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/ccmio)
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile "$config")"
then
. "$settings"
else
[ -n "$warn" ] && echo "$warn (no config.sh/ccmio settings)"
[ -n "$warn" ] && echo "$warn (no $config settings)"
return 2
fi
# Expected location, include/library names
# Link with static libccmio only (fewer issues)
prefix="$CCMIO_ARCH_PATH"
incName="libccmio/ccmio.h"
libName="libccmio.a"
local prefix="$CCMIO_ARCH_PATH"
local incName="libccmio/ccmio.h"
local libName="libccmio.a"
local header library
# ----------------------------------
if isNone "$prefix"
@ -139,11 +156,15 @@ have_ccmio()
# Reset variables
no_ccmio
# Testing
if [ "$1" = "-test" ]
then
# Test/query
case "$1" in
-test)
have_ccmio
echo_ccmio
fi
;;
-query)
query_ccmio
;;
esac
#------------------------------------------------------------------------------

View File

@ -5,11 +5,10 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2019 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
# have_cgal
@ -19,9 +18,10 @@
#
# Requires
# CGAL_ARCH_PATH
# or config.sh/CGAL (when CGAL_ARCH_PATH is empty)
#
# Functions provided
# have_cgal, no_cgal, echo_cgal
# have_cgal, no_cgal, echo_cgal, query_cgal
#
# Variables set on success
# HAVE_CGAL
@ -38,7 +38,6 @@
no_cgal()
{
unset HAVE_CGAL CGAL_INC_DIR CGAL_LIB_DIR
return 0
}
@ -52,19 +51,48 @@ echo_cgal()
}
# Query settings (from CGAL setup)
query_cgal()
{
local config="config.sh/CGAL"
local settings
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile -mode=o "$config")"
then
. "$settings"
_process_query cgal "$CGAL_ARCH_PATH"
else
echo "(no $config settings)" 1>&2
echo "cgal=unknown"
fi
}
# On success, return 0 and export variables
# -> HAVE_CGAL, CGAL_INC_DIR, CGAL_LIB_DIR
have_cgal()
{
local prefix header library incName libName settings warn
# warn="==> skip cgal"
local warn # warn="==> skip cgal"
local config="config.sh/CGAL"
local settings
# Setup - from the current environment
# Setup - current environment if set
if [ -z "$CGAL_ARCH_PATH" ]
then
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile "$config")"
then
. "$settings"
else
[ -n "$warn" ] && echo "$warn (no $config settings)"
return 2
fi
fi
# Expected location, include/library names
prefix="$CGAL_ARCH_PATH"
incName="CGAL/version.h"
libName="libCGAL"
local prefix="$CGAL_ARCH_PATH"
local incName="CGAL/version.h"
local libName="libCGAL"
local header library
# ----------------------------------
if isNone "$prefix"
@ -113,11 +141,15 @@ have_cgal()
# Reset variables
no_cgal
# Testing
if [ "$1" = "-test" ]
then
# Test/query
case "$1" in
-test)
have_cgal
echo_cgal
fi
;;
-query)
query_cgal
;;
esac
#------------------------------------------------------------------------------

122
wmake/scripts/have_cmake Normal file
View File

@ -0,0 +1,122 @@
#----------------------------------*-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
# have_cmake
#
# Description
# Locate CMAKE executable
#
# Files
# Uses etc/config.sh/cmake (if it exists) for the
# CMAKE_ARCH_PATH that may specify a possible cmake/bin directory.
#
# Functions provided
# have_cmake, no_cmake, echo_cmake
#
# Variables set on success
# HAVE_CMAKE
# CMAKE_EXE
#
# When properly resolved, CMAKE_EXE will be an absolute path to the
# cmake executable. On failure it will point to 'false'
#
#------------------------------------------------------------------------------
# Reset variables
no_cmake()
{
unset HAVE_CMAKE CMAKE_EXE
}
# Report
echo_cmake()
{
echo cmake="${CMAKE_EXE:-false}"
echo version="$("${CMAKE_EXE:-false}" --version | sed -ne '1s/^.*version *//p')"
}
#
# Try to locate cmake according to values specified in <etc/config.sh/cmake>
# or just use what is found on the path.
#
# On success: return the resolved value as output.
# On failure: set executable as "false" and return with 1
#
have_cmake()
{
# Treat previous queries as "sticky"
if [ -n "$CMAKE_EXE" ]
then
test "$CMAKE_EXE" != "false"
return $?
fi
local config="config.sh/cmake"
unset CMAKE_ARCH_PATH
local settings candidate foundExe
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile "$config" 2>/dev/null)"
then
. "$settings"
if [ -d "$CMAKE_ARCH_PATH" ]
then
candidate="$CMAKE_ARCH_PATH"/bin/cmake
if [ -f "$candidate" ] && [ -x "$candidate" ]
then
foundExe="$candidate"
fi
fi
fi
if [ -z "$foundExe" ]
then
# Default: resolve from PATH
if candidate="$(command -v cmake 2>/dev/null)"
then
foundExe="$candidate"
fi
fi
if [ -n "$foundExe" ]
then
# OK
export HAVE_CMAKE=true
export CMAKE_EXE="$foundExe"
else
# Failure
export CMAKE_EXE="false" # Avoid repeated calls?
return 2
fi
}
# Reset variables
no_cmake
# Test/query
case "$1" in
-test)
have_cmake
echo_cmake
;;
-query)
## query_cmake
;;
esac
#------------------------------------------------------------------------------

View File

@ -5,11 +5,10 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2019 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
# have_fftw
@ -19,9 +18,10 @@
#
# Requires
# FFTW_ARCH_PATH
# or config.sh/FFTW (when FFTW_ARCH_PATH is empty)
#
# Functions provided
# have_fftw, no_fftw, echo_fftw
# have_fftw, no_fftw, echo_fftw, query_fftw
#
# Variables set on success
# HAVE_FFTW
@ -38,7 +38,6 @@
no_fftw()
{
unset HAVE_FFTW FFTW_INC_DIR FFTW_LIB_DIR
return 0
}
@ -52,19 +51,48 @@ echo_fftw()
}
# Query settings
query_fftw()
{
local config="config.sh/FFTW"
local settings
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile -mode=o "$config")"
then
. "$settings"
_process_query fftw "$FFTW_ARCH_PATH"
else
echo "(no $config settings)" 1>&2
echo "fftw=unknown"
fi
}
# On success, return 0 and export variables
# -> HAVE_FFTW, FFTW_INC_DIR, FFTW_LIB_DIR
have_fftw()
{
local prefix header library incName libName settings warn
# warn="==> skip fftw"
local warn # warn="==> skip fftw"
local config="config.sh/FFTW"
local settings
# Setup - from the current environment
# Setup - current environment if set
if [ -z "$FFTW_ARCH_PATH" ]
then
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile "$config")"
then
. "$settings"
else
[ -n "$warn" ] && echo "$warn (no $config settings)"
return 2
fi
fi
# Expected location, include/library names
prefix="$FFTW_ARCH_PATH"
incName="fftw3.h"
libName="libfftw3"
local prefix="$FFTW_ARCH_PATH"
local incName="fftw3.h"
local libName="libfftw3"
local header library
# ----------------------------------
if isNone "$prefix"
@ -111,11 +139,15 @@ have_fftw()
# Reset variables
no_fftw
# Testing
if [ "$1" = "-test" ]
then
# Test/query
case "$1" in
-test)
have_fftw
echo_fftw
fi
;;
-query)
query_fftw
;;
esac
#------------------------------------------------------------------------------

View File

@ -5,11 +5,10 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2019 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
# have_hypre
@ -19,9 +18,10 @@
#
# Requires
# HYPRE_ARCH_PATH
# or config.sh/hypre
#
# Functions provided
# have_hypre, no_hypre, echo_hypre
# have_hypre, no_hypre, echo_hypre, query_hypre
#
# Variables set on success
# HAVE_HYPRE
@ -38,7 +38,6 @@
no_hypre()
{
unset HAVE_HYPRE HYPRE_INC_DIR HYPRE_LIB_DIR
return 0
}
@ -52,29 +51,48 @@ echo_hypre()
}
# Query settings
query_hypre()
{
local config="config.sh/hypre"
local settings
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile -mode=o "$config")"
then
. "$settings"
_process_query hypre "$HYPRE_ARCH_PATH"
else
echo "(no $config settings)" 1>&2
echo "hypre=unknown"
fi
}
# On success, return 0 and export variables
# -> HAVE_HYPRE, HYPRE_INC_DIR, HYPRE_LIB_DIR
have_hypre()
{
local prefix header library incName libName settings warn
warn="==> skip hypre"
local warn="==> skip hypre"
local config="config.sh/hypre"
local settings
# Setup - prefer current environment value? (TDB)
if [ ! -d "$HYPRE_ARCH_PATH" ]
then
if settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/hypre)
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile "$config")"
then
. "$settings"
else
[ -n "$warn" ] && echo "$warn (no config.sh/hypre settings)"
[ -n "$warn" ] && echo "$warn (no $config settings)"
return 2
fi
fi
# Expected location, include/library names
prefix="$HYPRE_ARCH_PATH"
incName="HYPRE.h"
libName="libHYPRE"
local prefix="$HYPRE_ARCH_PATH"
local incName="HYPRE.h"
local libName="libHYPRE"
local header library
# ----------------------------------
if isNone "$prefix"
@ -121,11 +139,15 @@ have_hypre()
# Reset variables
no_hypre
# Testing
if [ "$1" = "-test" ]
then
# Test/query
case "$1" in
-test)
have_hypre
echo_hypre
fi
;;
-query)
query_hypre
;;
esac
#------------------------------------------------------------------------------

View File

@ -5,11 +5,10 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2019 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
# have_kahip
@ -21,7 +20,7 @@
# config.sh/kahip
#
# Functions provided
# have_kahip, no_kahip, echo_kahip
# have_kahip, no_kahip, echo_kahip, query_kahip
#
# Variables set on success
# HAVE_KAHIP
@ -39,7 +38,6 @@ no_kahip()
{
unset HAVE_KAHIP KAHIP_ARCH_PATH KAHIP_INC_DIR KAHIP_LIB_DIR
unset KAHIP_VERSION
return 0
}
@ -53,26 +51,44 @@ echo_kahip()
}
# Query settings
query_kahip()
{
local config="config.sh/kahip"
local settings
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile -mode=o "$config")"
then
. "$settings"
_process_query kahip "$KAHIP_ARCH_PATH"
else
echo "(no $config settings)" 1>&2
echo "kahip=unknown"
fi
}
# On success, return 0 and export variables
# -> HAVE_KAHIP, KAHIP_ARCH_PATH, KAHIP_INC_DIR, KAHIP_LIB_DIR
have_kahip()
{
local prefix header library incName libName settings warn
warn="==> skip kahip"
local warn="==> skip kahip"
local config="config.sh/kahip"
local settings
# Setup
if settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/kahip)
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile "$config")"
then
. "$settings"
else
[ -n "$warn" ] && echo "$warn (no config.sh/kahip settings)"
[ -n "$warn" ] && echo "$warn (no $config settings)"
return 1
fi
# Expected location, include/library names
prefix="$KAHIP_ARCH_PATH"
incName="kaHIP_interface.h"
libName="libkahip"
local prefix="$KAHIP_ARCH_PATH"
local incName="kaHIP_interface.h"
local libName="libkahip"
local header library
# ----------------------------------
if isNone "$prefix"
@ -122,11 +138,15 @@ have_kahip()
# Reset variables
no_kahip
# Testing
if [ "$1" = "-test" ]
then
# Test/query
case "$1" in
-test)
have_kahip
echo_kahip
fi
;;
-query)
query_kahip
;;
esac
#------------------------------------------------------------------------------

View File

@ -5,23 +5,22 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2019 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
# have_metis
#
# Description
# Detection/setup of metis
# Detection/setup of METIS
#
# Requires
# config.sh/metis
#
# Functions provided
# have_metis, no_metis, echo_metis
# have_metis, no_metis, echo_metis, query_metis
#
# Variables set on success
# HAVE_METIS
@ -39,7 +38,6 @@ no_metis()
{
unset HAVE_METIS METIS_ARCH_PATH METIS_INC_DIR METIS_LIB_DIR
unset METIS_VERSION
return 0
}
@ -53,26 +51,44 @@ echo_metis()
}
# Query settings
query_metis()
{
local config="config.sh/metis"
local settings
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile -mode=o "$config")"
then
. "$settings"
_process_query metis "$METIS_ARCH_PATH"
else
echo "(no $config settings)" 1>&2
echo "metis=unknown"
fi
}
# On success, return 0 and export variables
# -> HAVE_METIS, METIS_ARCH_PATH, METIS_INC_DIR, METIS_LIB_DIR
have_metis()
{
local prefix header library incName libName settings warn
warn="==> skip metis"
local warn="==> skip metis"
local config="config.sh/metis"
local settings
# Setup
if settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/metis)
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile "$config")"
then
. "$settings"
else
[ -n "$warn" ] && echo "$warn (no config.sh/metis settings)"
[ -n "$warn" ] && echo "$warn (no $config settings)"
return 2
fi
# Expected location, include/library names
prefix="$METIS_ARCH_PATH"
incName="metis.h"
libName="libmetis"
local prefix="$METIS_ARCH_PATH"
local incName="metis.h"
local libName="libmetis"
local header library
# ----------------------------------
if isNone "$prefix"
@ -129,11 +145,15 @@ have_metis()
# Reset variables
no_metis
# Testing
if [ "$1" = "-test" ]
then
# Test/query
case "$1" in
-test)
have_metis
echo_metis
fi
;;
-query)
query_metis
;;
esac
#------------------------------------------------------------------------------

View File

@ -5,23 +5,22 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2019 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
# have_mgridgen
#
# Description
# Detection/setup of mgridgen
# Detection/setup of MGRIDGEN
#
# Requires
# config.sh/mgridgen
#
# Functions provided
# have_mgridgen, no_mgridgen, echo_mgridgen
# have_mgridgen, no_mgridgen, echo_mgridgen, query_mgridgen
#
# Variables set on success
# HAVE_MGRIDGEN
@ -39,7 +38,6 @@ no_mgridgen()
{
unset HAVE_MGRIDGEN MGRIDGEN_ARCH_PATH MGRIDGEN_INC_DIR MGRIDGEN_LIB_DIR
unset MGRIDGEN_VERSION
return 0
}
@ -53,27 +51,45 @@ echo_mgridgen()
}
# Query settings
query_mgridgen()
{
local config="config.sh/mgridgen"
local settings
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile -mode=o "$config")"
then
. "$settings"
_process_query mgridgen "$MGRIDGEN_ARCH_PATH"
else
echo "(no $config settings)" 1>&2
echo "mgridgen=unknown"
fi
}
# On success, return 0 and export variables
# -> HAVE_MGRIDGEN, MGRIDGEN_ARCH_PATH, MGRIDGEN_INC_DIR, MGRIDGEN_LIB_DIR
have_mgridgen()
{
local prefix header library incName libName libName2 settings warn
warn="==> skip mgridgen"
local warn="==> skip mgridgen"
local config="config.sh/mgridgen"
local settings
# Setup
if settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/mgridgen)
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile "$config")"
then
. "$settings"
else
#silent# [ -n "$warn" ] && echo "$warn (no config.sh/mgridgen settings)"
#silent# [ -n "$warn" ] && echo "$warn (no $config settings)"
return 2
fi
# Expected location, include/library names
prefix="$MGRIDGEN_ARCH_PATH"
incName="mgridgen.h"
libName="libMGridGen"
libName2="libmgrid"
local prefix="$MGRIDGEN_ARCH_PATH"
local incName="mgridgen.h"
local libName="libMGridGen"
local libName2="libmgrid"
local header library
# ----------------------------------
if isNone "$prefix"
@ -110,7 +126,7 @@ have_mgridgen()
# ----------------------------------
local good label scalar
local label scalar
# Ensure consistent sizes with OpenFOAM and mgridgen header
# Extract typedef for idxtype, realtype
@ -126,7 +142,6 @@ have_mgridgen()
case "$WM_LABEL_SIZE:$label" in
(32:int32_t | 32:int | 64:int64_t | 64:long)
good=true
;;
(*)
@ -140,7 +155,6 @@ have_mgridgen()
esac
case "$WM_PRECISION_OPTION:$scalar" in
(SP:float | SPDP:float | DP:double)
good=true
;;
(*)
@ -166,11 +180,15 @@ have_mgridgen()
# Reset variables
no_mgridgen
# Testing
if [ "$1" = "-test" ]
then
# Test/query
case "$1" in
-test)
have_mgridgen
echo_mgridgen
fi
;;
-query)
query_mgridgen
;;
esac
#------------------------------------------------------------------------------

View File

@ -5,11 +5,10 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2019 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
# have_petsc
@ -19,9 +18,10 @@
#
# Requires
# PETSC_ARCH_PATH
# or config.sh/petsc
#
# Functions provided
# have_petsc, no_petsc, echo_petsc, hint_petsc
# have_petsc, no_petsc, echo_petsc, hint_petsc, query_petsc
#
# Variables set on success
# HAVE_PETSC
@ -38,7 +38,6 @@
no_petsc()
{
unset HAVE_PETSC PETSC_INC_DIR PETSC_LIB_DIR
return 0
}
@ -68,30 +67,49 @@ INFORMATION
}
# Query settings
query_petsc()
{
local config="config.sh/petsc"
local settings
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile -mode=o "$config")"
then
. "$settings"
_process_query petsc "$PETSC_ARCH_PATH"
else
echo "(no $config settings)" 1>&2
echo "petsc=unknown"
fi
}
# On success, return 0 and export variables
# -> HAVE_PETSC, PETSC_INC_DIR, PETSC_LIB_DIR
have_petsc()
{
local prefix header library incName libName pkgName settings warn
warn="==> skip petsc"
local warn="==> skip petsc"
local config="config.sh/petsc"
local settings
# Setup - prefer current environment value? (TDB)
if [ ! -d "$PETSC_ARCH_PATH" ]
then
if settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/petsc)
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile "$config")"
then
. "$settings"
else
[ -n "$warn" ] && echo "$warn (no config.sh/petsc settings)"
[ -n "$warn" ] && echo "$warn (no $config settings)"
return 2
fi
fi
# Expected location, include/library names
prefix="$PETSC_ARCH_PATH"
incName="petsc.h"
libName="libpetsc"
pkgName="PETSc"
local prefix="$PETSC_ARCH_PATH"
local incName="petsc.h"
local libName="libpetsc"
local pkgName="PETSc"
local header library
# ----------------------------------
if isNone "$prefix"
@ -153,11 +171,15 @@ have_petsc()
# Reset variables
no_petsc
# Testing
if [ "$1" = "-test" ]
then
# Test/query
case "$1" in
-test)
have_petsc
echo_petsc
fi
;;
-query)
query_petsc
;;
esac
#------------------------------------------------------------------------------

View File

@ -5,17 +5,16 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2019 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
# have_readline
#
# Description
# Detection/setup of readline
# Detection/setup of READLINE
#
# Requires
# None
@ -37,7 +36,6 @@
no_readline()
{
unset HAVE_LIBREADLINE READLINE_INC_DIR READLINE_LIB_DIR
return 0
}
@ -54,13 +52,14 @@ echo_readline()
# -> HAVE_LIBREADLINE, READLINE_INC_DIR, READLINE_LIB_DIR
have_readline()
{
local prefix header library incName libName settings warn
# warn="==> skip readline"
local warn # warn="==> skip readline"
local settings
# Expected location, include/library names
prefix=system
incName="readline/readline.h"
libName="libreadline"
local prefix=system
local incName="readline/readline.h"
local libName="libreadline"
local header library
# ----------------------------------
if isNone "$prefix"
@ -108,11 +107,12 @@ have_readline()
# Reset variables
no_readline
# Testing
if [ "$1" = "-test" ]
then
# Test/query
case "$1" in
-test)
have_readline
echo_readline
fi
;;
esac
#------------------------------------------------------------------------------

View File

@ -5,23 +5,22 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2019 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
# have_scotch
#
# Description
# Detection/setup of scotch
# Detection/setup of SCOTCH
#
# Requires
# config.sh/scotch
#
# Functions provided
# have_scotch, no_scotch, echo_scotch
# have_scotch, no_scotch, echo_scotch, query_scotch
#
# Variables set on success
# HAVE_SCOTCH
@ -40,7 +39,6 @@ no_scotch()
unset HAVE_SCOTCH SCOTCH_ARCH_PATH SCOTCH_INC_DIR SCOTCH_LIB_DIR
unset SCOTCH_VERSION
unset HAVE_PTSCOTCH PTSCOTCH_ARCH_PATH PTSCOTCH_INC_DIR PTSCOTCH_LIB_DIR
return 0
}
@ -59,26 +57,45 @@ echo_scotch()
}
# Query settings
query_scotch()
{
local config="config.sh/scotch"
local settings
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile -mode=o "$config")"
then
. "$settings"
_process_query scotch "$SCOTCH_ARCH_PATH"
else
echo "(no $config settings)" 1>&2
echo "scotch=unknown"
fi
}
# On success, return 0 and export variables
# -> HAVE_SCOTCH, SCOTCH_ARCH_PATH, SCOTCH_INC_DIR, SCOTCH_LIB_DIR
have_scotch()
{
local prefix header library incName libName settings warn
warn="==> skip scotch"
local warn="==> skip scotch"
local config="config.sh/scotch"
local settings
# Setup
if settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/scotch)
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile "$config")"
then
. "$settings"
else
[ -n "$warn" ] && echo "$warn (no config.sh/scotch settings)"
[ -n "$warn" ] && echo "$warn (no $config settings)"
return 2
fi
# Expected location, include/library names
prefix="$SCOTCH_ARCH_PATH"
incName="scotch.h"
libName="libscotch"
local prefix="$SCOTCH_ARCH_PATH"
local incName="scotch.h"
local libName="libscotch"
local localDir="scotch-int$WM_LABEL_SIZE"
local header library
# ----------------------------------
if isNone "$prefix"
@ -87,13 +104,18 @@ have_scotch()
return 1
elif hasAbsdir "$prefix"
then
header=$(findFirstFile "$prefix/include/$incName")
header=$(findFirstFile \
"$prefix/include/$localDir/$incName" \
"$prefix/include/$incName" \
)
library=$(findExtLib "$libName")
elif isSystem "$prefix"
then
header=$(findFirstFile \
"/usr/local/include/$localDir/$incName" \
"/usr/local/include/scotch/$incName" \
"/usr/local/include/$incName" \
"/usr/include/$localDir/$incName" \
"/usr/include/scotch/$incName" \
"/usr/include/$incName" \
)
@ -102,6 +124,7 @@ have_scotch()
unset prefix
fi
# ----------------------------------
equalBaseName "${header%/*}" "$localDir" || unset localDir
# Header
[ -n "$header" ] || {
@ -111,7 +134,7 @@ have_scotch()
# Library
[ -n "$library" ] \
|| library=$(findLibrary -prefix="$prefix" -name="$libName") \
|| library=$(findLibrary -prefix="$prefix" -name="$libName" -local="$localDir") \
|| {
[ -n "$warn" ] && echo "$warn (no library)"
return 2
@ -119,7 +142,7 @@ have_scotch()
# ----------------------------------
local good label
local label
# Ensure consistent sizes between OpenFOAM and scotch header
# extract 'typedef int64_t SCOTCH_Num' or equivalent
@ -147,7 +170,6 @@ have_scotch()
case "$WM_LABEL_SIZE:$label" in
(32:int32_t | 32:int | 64:int64_t | 64:long)
good=true
;;
(*)
@ -176,8 +198,7 @@ have_scotch()
# -> HAVE_PTSCOTCH, PTSCOTCH_ARCH_PATH, PTSCOTCH_INC_DIR, PTSCOTCH_LIB_DIR
have_ptscotch()
{
local prefix header library incName libName settings warn
warn="==> skip ptscotch"
local warn="==> skip ptscotch"
if [ "$HAVE_SCOTCH" != true ]
then
@ -189,9 +210,11 @@ have_ptscotch()
[ -n "$PTSCOTCH_ARCH_PATH" ] || PTSCOTCH_ARCH_PATH="$SCOTCH_ARCH_PATH"
# Expected location, include/library names
prefix="$PTSCOTCH_ARCH_PATH"
incName="ptscotch.h"
libName="libptscotch"
local prefix="$PTSCOTCH_ARCH_PATH"
local incName="ptscotch.h"
local libName="libptscotch"
local localDir="scotch-int$WM_LABEL_SIZE"
local header library
# ----------------------------------
if isNone "$prefix"
@ -202,25 +225,27 @@ have_ptscotch()
then
header=$(findFirstFile \
"$prefix/include/$FOAM_MPI/$incName" \
"$prefix/include/$localDir/$incName" \
"$prefix/include/$incName"
)
library="$(findExtLib $FOAM_MPI/$libName $libName)"
elif isSystem "$prefix"
then
prefix=/usr
header=$(findFirstFile \
"/usr/local/include/ptscotch/$incName" \
"/usr/local/include/scotch/$incName" \
"/usr/local/include/$incName" \
"/usr/include/$localDir/$incName" \
"/usr/include/ptscotch/$incName" \
"/usr/include/scotch/$incName" \
"/usr/include/$incName" \
)
case "$header" in (/usr/local/*) prefix=/usr/local ;; esac
prefix=$(sysPrefix "$header")
else
unset prefix
fi
# ----------------------------------
equalBaseName "${header%/*}" "$localDir" || unset localDir
# Header
[ -n "$header" ] || {
@ -230,7 +255,7 @@ have_ptscotch()
# Library
[ -n "$library" ] \
|| library=$(findLibrary -prefix="$prefix" -name="$libName") \
|| library=$(findLibrary -prefix="$prefix" -name="$libName" -local="$localDir") \
|| {
[ -n "$warn" ] && echo "$warn (no library)"
return 2
@ -250,11 +275,15 @@ have_ptscotch()
# Reset variables
no_scotch
# Testing
if [ "$1" = "-test" ]
then
# Test/query
case "$1" in
-test)
have_scotch && have_ptscotch
echo_scotch
fi
;;
-query)
query_scotch
;;
esac
#------------------------------------------------------------------------------

View File

@ -5,23 +5,22 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2019 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
# have_zoltan
#
# Description
# Detection/setup of zoltan
# Detection/setup of ZOLTAN
#
# Requires
# config.sh/zoltan
#
# Functions provided
# have_zoltan, no_zoltan, echo_zoltan
# have_zoltan, no_zoltan, echo_zoltan, query_zoltan
#
# Variables set on success
# HAVE_ZOLTAN
@ -38,7 +37,6 @@
no_zoltan()
{
unset HAVE_ZOLTAN ZOLTAN_INC_DIR ZOLTAN_LIB_DIR
return 0
}
@ -52,26 +50,44 @@ echo_zoltan()
}
# Query settings
query_zoltan()
{
local config="config.sh/zoltan"
local settings
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile -mode=o "$config")"
then
. "$settings"
_process_query zoltan "$ZOLTAN_ARCH_PATH"
else
echo "(no $config settings)" 1>&2
echo "zoltan=unknown"
fi
}
# On success, return 0 and export variables
# -> HAVE_ZOLTAN, ZOLTAN_INC_DIR, ZOLTAN_LIB_DIR
have_zoltan()
{
local prefix header library incName libName settings warn
# warn="==> skip zoltan"
local warn # warn="==> skip zoltan"
local config="config.sh/zoltan"
local settings
# Setup
if settings=$($WM_PROJECT_DIR/bin/foamEtcFile config.sh/zoltan)
if settings="$("$WM_PROJECT_DIR"/bin/foamEtcFile "$config")"
then
. "$settings"
else
[ -n "$warn" ] && echo "$warn (no config.sh/zoltan settings)"
[ -n "$warn" ] && echo "$warn (no $config settings)"
return 2
fi
# Expected location, include/library names
prefix="$ZOLTAN_ARCH_PATH"
incName="zoltan.h"
libName="libzoltan"
local prefix="$ZOLTAN_ARCH_PATH"
local incName="zoltan.h"
local libName="libzoltan"
local header library
# ----------------------------------
if isNone "$prefix"
@ -118,11 +134,15 @@ have_zoltan()
# Reset variables
no_zoltan
# Testing
if [ "$1" = "-test" ]
then
# Test/query
case "$1" in
-test)
have_zoltan
echo_zoltan
fi
;;
-query)
query_zoltan
;;
esac
#------------------------------------------------------------------------------

View File

@ -5,11 +5,10 @@
# \\ / A nd | www.openfoam.com
# \\/ M anipulation |
#------------------------------------------------------------------------------
# Copyright (C) 2018-2019 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
# paraviewFunctions
@ -19,8 +18,8 @@
# Setup of variables for creating ParaView plugins
#
# Requires
# ParaView_DIR (unless system)
# PV_PLUGIN_PATH
# ParaView_DIR (unless system)
# PV_PLUGIN_PATH (or rely on automatic mechanism)
#
# Provides Functions
# get_pvplugin_api, have_pvplugin_support, no_paraview, echo_paraview
@ -47,7 +46,6 @@ no_paraview()
{
unset HAVE_PVPLUGIN_SUPPORT FOAM_PV_PLUGIN_LIBBIN
unset PARAVIEW_API PARAVIEW_INC_DIR
return 0
}
@ -87,22 +85,59 @@ cmakePvInstall()
cmakeVersionedInstall "ParaView_DIR=$ParaView_DIR" "$@"
}
#
# Build library - use sentinel file(s) to handle paraview version changes
# Some difficulty handling different installation options as well
# as wmake options, so only handle build/configure information for now
#
# 1 - libName
# 2... build/configure information
#
# Similar to wmakeVersioned
wmakeLibPv()
{
local depend="ParaView_DIR=$ParaView_DIR"
local libName="$1"
shift 1
local sentinel
for libName
do
sentinel=$(sameDependency "$depend" $libName) || \
wclean $libName
sentinel=$(sameDependency "$libName" "$depend" $@) || \
wclean "$libName"
wmake $targetType $libName \
&& echo "$depend" > ${sentinel:-/dev/null}
done
wmake $targetType "$libName" \
&& storeDependency "$sentinel" "$depend" $@
}
# Get ParaView API from given path.
# Eg, "/path/paraview-dir/paraview-5.6" -> "5.6"
#
# Or the output from `paraview --version`
# Eg, "paraview version 5.6.3" -> "5.6"
#
# 1 - the input path ending with paraview-x.y, or paraview --version information
#
# On success, return 0 and echo value
#
get_pvapi()
{
local pv_api
# Extract paraview major+minor version from the directory name
# From /path/paraview-5.6 -> 5.6
pv_api=$(echo "${1:-none}" | \
sed -ne 's@^.*/@@;s@^[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*$@\1@p')
if [ -z "$pv_api" ]
then
# Extract paraview major+minor version from "paraview --version" information
pv_api=$(echo "${1:-none}" | \
sed -ne 's@^.*version *\([0-9][0-9]*\.[0-9][0-9]*\).*$@\1@p')
fi
[ -n "$pv_api" ] || return 1
# OK
echo "$pv_api"
}
@ -124,10 +159,9 @@ get_pvplugin_api()
targetDir="${PV_PLUGIN_PATH##;}"
targetDir="${targetDir%%;*}"
# Extract paraview major+minor version from the directory name
# Extract paraview major+minor version from directory name
# From /path/paraview-5.6 -> 5.6
pv_api=$(echo "$targetDir" | \
sed -ne 's@^.*/@@;s/^[^0-9]*\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/p')
pv_api=$(get_pvapi "$targetDir")
[ -n "$pv_api" ] || return 1
@ -148,8 +182,8 @@ get_pvplugin_api()
#
have_pvplugin_support()
{
local header settings warn pv_api installDir binDir includeDir targetDir
warn="==> skip paraview-plugin"
local warn="==> skip paraview-plugin"
local settings pv_api pv_executable installDir binDir includeDir targetDir
# Trivial check
command -v cmake >/dev/null || {
@ -164,20 +198,36 @@ have_pvplugin_support()
fi
unset FOAM_PV_PLUGIN_LIBBIN PARAVIEW_API
if [ -z "$targetDir" ] || [ -z "$pv_api" ]
then
echo "$warn (could not determine target or major.minor version)"
echo " PV_PLUGIN_PATH=${PV_PLUGIN_PATH:-???}"
return 1
fi
# Probably not needed...
# if [ -z "$targetDir" ] || [ -z "$pv_api" ]
# then
# echo "$warn (could not determine target or major.minor version)"
# echo " PV_PLUGIN_PATH=${PV_PLUGIN_PATH:-???}"
# return 1
# fi
# Include/library names
header="pqServerManagerModel.h"
local header="pqServerManagerModel.h"
if [ -n "$ParaView_DIR" ]
then
# ParaView_DIR defined. Look for include/
# Unless already known, get API value from include directory name
if [ -z "$pv_api" ]
then
for settings in $(find "$ParaView_DIR"/include -maxdepth 1 -name 'paraview-*' -type d)
do
pv_api=$(get_pvapi "$settings") && break
done
if [ -z "$pv_api" ]
then
echo "$warn (could not determine paraview major.minor version)"
return 1
fi
fi
header=$(findFirstFile \
"$ParaView_DIR/include/paraview-$pv_api/$header" \
"$ParaView_DIR/include/paraview/$header"
@ -186,11 +236,14 @@ have_pvplugin_support()
else
# No ParaView_DIR defined
# - use location of 'paraview' to guess an equivalent ParaView_DIR
# - assume we can use paraview-config
# - assume paraview-config works, but might be removed too!
binDir="$(command -v paraview 2>/dev/null)"
binDir="${binDir%/*}" # Eg, /usr/bin/paraview -> /usr/bin
installDir="${binDir%/*}" # Eg, /usr/bin -> /usr
pv_executable="$(command -v paraview 2>/dev/null)" || {
echo "$warn (no paraview found?)"
return 2
}
binDir="${pv_executable%/*}" # Eg, /usr/bin/paraview -> /usr/bin
installDir="${binDir%/*}" # Eg, /usr/bin -> /usr
case "$installDir" in
(/*) # An absolute path
@ -198,6 +251,17 @@ have_pvplugin_support()
;;
esac
# Unless already known, get API value from `paraview --version` information
if [ -z "$pv_api" ]
then
pv_api=$(get_pvapi "$("$pv_executable" --version)")
if [ -z "$pv_api" ]
then
echo "$warn (could not determine paraview major.minor version)"
return 1
fi
fi
header=$(findFirstFile \
"$(paraview-config --include 2>/dev/null |sed -ne 's/^ *-I//p')/$header"\
"${includeDir:+$includeDir/paraview-$pv_api/$header}" \
@ -220,8 +284,9 @@ have_pvplugin_support()
# ----------------------------------
# OK
# Use FOAM_LIBBIN/paraview-maj.min as default
export HAVE_PVPLUGIN_SUPPORT=true
export FOAM_PV_PLUGIN_LIBBIN="$targetDir"
export FOAM_PV_PLUGIN_LIBBIN="${targetDir:-$FOAM_LIBBIN/paraview-$pv_api}"
export PARAVIEW_API="$pv_api"
export PARAVIEW_INC_DIR="${header%/*}" # Basename
@ -232,11 +297,15 @@ have_pvplugin_support()
# Force reset of old variables
no_paraview
# Testing
if [ "$1" = "-test" ]
then
# Test/query
case "$1" in
-test)
have_pvplugin_support
echo_paraview
fi
;;
-query)
## query_paraview
;;
esac
#------------------------------------------------------------------------------

View File

@ -8,8 +8,7 @@
# 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
# sysFunctions
@ -24,6 +23,7 @@
# findSystemInclude
# findLibrary
# findExtLib
# versionCompare
#
# Internal variables used
# extLibraries
@ -40,7 +40,7 @@ then
# Load once, but do not rely on this variable elsewhere
WMAKE_SCRIPTS_SYSFUNCTIONS=loaded
# Handle Debian multi-arch, ignore missing/bad dpkg-architecture.
# Debian multi-arch, ignore missing/bad dpkg-architecture.
if [ -z "$DEB_TARGET_MULTIARCH" ]
then
DEB_TARGET_MULTIARCH=$(dpkg-architecture -qDEB_TARGET_MULTIARCH 2>/dev/null || true)
@ -101,6 +101,35 @@ then
}
# True if '$1' and '$2' have the same directory basename
# Eg,
# equalBaseName "/usr/include/scotch-int32" "scotch-int32"
equalBaseName()
{
test "${1##*/}" = "${2##*/}"
}
# Simple output for -query
# $1 = software
# $2 = setting
_process_query()
{
if isNone "$2"
then
echo "$1=none"
elif isAbsdir "$2" ## not hasAbsdir
then
echo "$1=${2##*/}"
elif isSystem "$2"
then
echo "$1=system"
else
echo "$1=unknown"
fi
}
# Return system prefix (/usr, /usr/local, ...) based on hint provided
# Eg,
# sysPrefix "/usr/local/include/fftw3.h" -> "/usr/local"
@ -170,15 +199,15 @@ then
# This function has two modes of operation.
#
# 1) Automated search.
# Specify -prefix=dirName -name=libName and search for
# (lib, lib64, lib/x86_64..) etc.
# Specify -prefix=dirName -name=libName, optionally -local=subdirName
# and search for (lib, lib64, lib/x86_64..) etc.
#
# 2) Directed search.
# specify the fully qualified names to search on the parameter list
#
findLibrary()
{
local prefixDir searchDir searchName
local prefixDir localDir searchDir searchName
local file ext
searchDir=true
@ -191,6 +220,12 @@ then
shift
;;
-local=*)
# Prefix with directory separator
localDir="/${1#*=}"
shift
;;
-name=*)
searchName="${1#*=}"
shift
@ -204,18 +239,30 @@ then
if [ -n "$searchName" ]
then
# Automated search
# Eg, lib/ lib64/, lib/x86_64-linux-gnu
# Automated search (eg, lib/ lib64/, lib/x86_64-linux-gnu)
# but also handle possible local versions (eg, lib/scotch-int32)
: "${prefixDir:=/usr}" # A reasonable default
[ -d "$prefixDir" ] || return 2
for searchDir in \
lib \
"${WM_COMPILER_LIB_ARCH:+lib}$WM_COMPILER_LIB_ARCH" \
"${DEB_TARGET_MULTIARCH:+lib/}${DEB_TARGET_MULTIARCH}" \
# Local and regular search paths
set -- \
"lib${localDir}" \
"${WM_COMPILER_LIB_ARCH:+lib${WM_COMPILER_LIB_ARCH}${localDir}}" \
"${DEB_TARGET_MULTIARCH:+lib/${DEB_TARGET_MULTIARCH}${localDir}}" \
"lib" \
"${WM_COMPILER_LIB_ARCH:+lib${WM_COMPILER_LIB_ARCH}}" \
"${DEB_TARGET_MULTIARCH:+lib/${DEB_TARGET_MULTIARCH}}" \
;
# Ignore empty local search path ("/")
[ "${#localDir}" -gt 1 ] || shift 3
## echo "search: $# $@" 1>&2
for searchDir in "$@"
do
[ -n "$searchDir" ] || continue
for ext in '' $extLibraries
do
file="$prefixDir/$searchDir/$searchName$ext"
@ -272,6 +319,74 @@ then
return 2
}
# Compare version tuples with syntax similar to POSIX shell,
# but respecting dot separators.
#
# arg1 OP arg2
# OP is one of -eq, -ne, -lt, -le, -gt, or -ge.
# Returns true for a successful comparison.
# Arg1 and arg2 normally comprise positive integers, but leading content
# before a '-' is stripped.
# Missing digits are treated as '0'.
#
# Eg,
# versionCompare "software-1.2.3" -gt 1.1 && echo True
#
# Ad hoc handling of "git" version as always newest.
# "git" -gt "1.2.3" : True
# "1.2.3" -lt "git" : True
versionCompare()
{
[ "$#" -eq 3 ] || {
echo "Compare needs 3 arguments (was given $#)" 1>&2
return 2
}
local arg1="${1#*-}" # Strip leading prefix-
local op="${2}"
local arg2="${3#*-}" # Strip leading prefix-
local result='' # Empty represents 'equal'
arg1="${arg1:-0}."
arg2="${arg2:-0}."
if [ "$arg1" = "$arg2" ]; then unset arg1 arg2 # Identical
elif [ "${arg1#git}" != "$arg1" ]; then result='more' # (git > arg2)
elif [ "${arg2#git}" != "$arg2" ]; then result='less' # (arg1 < git)
fi
while [ -z "$result" ] && [ -n "${arg1}${arg2}" ]
do
local digits1="${arg1%%.*}"
local digits2="${arg2%%.*}"
arg1="${arg1#*.}"
arg2="${arg2#*.}"
: "${digits1:=0}"
: "${digits2:=0}"
# Other handling of non-integer values?
if [ "$digits1" -lt "$digits2" ]; then result='less'
elif [ "$digits1" -gt "$digits2" ]; then result='more'
fi
done
case "$op" in
(-eq | eq) [ -z "$result" ] ;;
(-ne | ne) [ -n "$result" ] ;;
(-lt | lt) [ 'less' = "$result" ] ;;
(-gt | gt) [ 'more' = "$result" ] ;;
(-le | le) [ 'less' = "${result:-less}" ] ;;
(-ge | ge) [ 'more' = "${result:-more}" ] ;;
(*)
echo "Unknown operator: '$op'" 1>&2
return 2
;;
esac
}
fi

View File

@ -0,0 +1,120 @@
#----------------------------------*-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
# wmake/scripts/wmake.cmake-args
#
# Description
# Special-purpose argument parser (eg, for Allwmake scripts)
# that handles -prefix=... and some other simpler tasks
#
# Usage
# # Parse the arguments by sourcing this script
# . ${WM_PROJECT_DIR:?}/wmake/scripts/wmake.cmake-args
#
# Options
# -prefix=...
# Exports CMAKE_INSTALL_PREFIX value.
# Handles u(ser), g(roup), o(ther) short-cuts (see foamEtcFile),
# absolute or relative paths
#
# -j | -jN | -j N
# Compile using all or specified N cores/hyperthreads
#
#------------------------------------------------------------------------------
# NB: nArgs to track the current processing position to avoid wraparound
# when checking for optional parameters (eg, the -j processing)
nArgs="$#"
for arg in "$@"
do
shift; nArgs="$((nArgs - 1))" # Drop argument
case "$arg" in
# Install prefix: user
-prefix=u | -prefix=user)
export CMAKE_INSTALL_PREFIX="${FOAM_USER_LIBBIN%/*}"
echo "Install prefix = user ($CMAKE_INSTALL_PREFIX)" 1>&2
continue # Handled argument
;;
# Install prefix: group
-prefix=g | -prefix=group)
export CMAKE_INSTALL_PREFIX="${FOAM_SITE_LIBBIN%/*}"
echo "Install prefix = group ($CMAKE_INSTALL_PREFIX)" 1>&2
continue # Handled argument
;;
# Install prefix: other/openfoam
-prefix=o | -prefix=other | -prefix=openfoam)
export CMAKE_INSTALL_PREFIX="${FOAM_LIBBIN%/*}"
echo "Install prefix = openfoam ($CMAKE_INSTALL_PREFIX)" 1>&2
continue # Handled argument
;;
# Install prefix: custom
-prefix=*)
export CMAKE_INSTALL_PREFIX="${arg#*=}"
: "${CMAKE_INSTALL_PREFIX:=/usr/local}" # Default as per autoconf
# Require as absolute path
[ "${CMAKE_INSTALL_PREFIX#/}" != "${CMAKE_INSTALL_PREFIX}" ] || \
CMAKE_INSTALL_PREFIX="${PWD}/${CMAKE_INSTALL_PREFIX}"
echo "Install prefix = $CMAKE_INSTALL_PREFIX" 1>&2
continue # Handled argument
;;
# Parallel compilation (all or specified number of cores)
-j)
export WM_NCOMPPROCS=0
if [ "$nArgs" -gt 0 ]
then
case "$1" in
[0-9]*)
if WM_NCOMPPROCS="$(expr 0 + "$1" 2>/dev/null)"
then
shift; nArgs="$((nArgs - 1))" # Drop argument
fi
;;
esac
fi
if [ "${WM_NCOMPPROCS:=0}" -le 0 ]
then
WM_NCOMPPROCS=$(getconf _NPROCESSORS_ONLN 2>/dev/null) || \
WM_NCOMPPROCS=1
fi
echo "Compiling enabled on $WM_NCOMPPROCS cores" 1>&2
continue # Handled argument
;;
# Parallel compilation (specified number of cores)
-j[0-9]*)
export WM_NCOMPPROCS="${arg#-j}"
if [ "${WM_NCOMPPROCS:=0}" -le 0 ]
then
WM_NCOMPPROCS=$(getconf _NPROCESSORS_ONLN 2>/dev/null) || \
WM_NCOMPPROCS=1
fi
echo "Compiling enabled on $WM_NCOMPPROCS cores" 1>&2
continue # Handled argument
;;
esac
set -- "$@" "$arg" # Reinsert unhandled argument
done
#------------------------------------------------------------------------------