Commit 22ab497e authored by David Moxey's avatar David Moxey

Rename NekMeshUtils -> NekMesh, change CMake configuration strategy

parent 1ba95c9c
......@@ -342,4 +342,6 @@ INSTALL(DIRECTORY ${TPDIST}/include/
OPTIONAL
)
MESSAGE(STATUS "rpath: ${CMAKE_INSTALL_RPATH}")
ADD_SUBDIRECTORY(docs)
......@@ -7,33 +7,35 @@
########################################################################
IF (NEKTAR_BUILD_PYTHON)
CMAKE_DEPENDENT_OPTION(NEKTAR_USE_PYTHON3
"If true, prefer to use Python 3." OFF "NEKTAR_BUILD_PYTHON" OFF)
# Find Python
IF(CMAKE_VERSION VERSION_GREATER "3.16.0" OR CMAKE_VERSION VERSION_EQUAL "3.16.0")
# If we're using the old version, then we should try to detect older
# variables.
IF (DEFINED PYTHON_EXECUTABLE)
SET(Python_EXECUTABLE ${PYTHON_EXECUTABLE})
ENDIF()
# Set the Python3 status flag as the opposite of the Python3 flag by
# default on first run to ensure Python is searched for.
IF (NOT DEFINED NEKTAR_PYTHON3_STATUS)
SET(NEKTAR_PYTHON3_STATUS NOT ${NEKTAR_USE_PYTHON3} CACHE INTERNAL "")
ENDIF()
IF (DEFINED PYTHON_LIBRARY)
SET(Python_LIBRARY ${PYTHON_LIBRARY})
ENDIF()
IF (NOT NEKTAR_PYTHON3_STATUS STREQUAL NEKTAR_USE_PYTHON3)
unset(PYTHON_EXECUTABLE CACHE)
unset(PYTHON_INCLUDE_DIR CACHE)
unset(PYTHON_LIBRARY CACHE)
unset(PYTHON_LIBRARY_DEBUG CACHE)
unset(BOOST_PYTHON_LIB CACHE)
unset(BOOST_NUMPY_LIB CACHE)
SET(NEKTAR_PYTHON3_STATUS ${NEKTAR_USE_PYTHON3} CACHE INTERNAL "")
ENDIF()
IF (DEFINED PYTHON_LIBRARIES)
SET(Python_LIBRARY ${PYTHON_LIBRARIES})
ENDIF()
FIND_PACKAGE(Python COMPONENTS Interpreter Development REQUIRED)
SET(PYTHONVER 2.7)
IF (NEKTAR_USE_PYTHON3)
SET(PYTHONVER 3.0)
SET(PYTHON_INCLUDE_DIRS ${Python_INCLUDE_DIRS})
SET(PYTHON_EXECUTABLE ${Python_EXECUTABLE})
SET(PYTHON_LIBRARIES ${Python_LIBRARY})
SET(PYTHONLIBS_VERSION_STRING ${Python_VERSION})
ELSE()
FIND_PACKAGE(PythonInterp REQUIRED)
FIND_PACKAGE(PythonLibsNew REQUIRED)
ENDIF()
# Find Python
FIND_PACKAGE(PythonInterp ${PYTHONVER} REQUIRED)
FIND_PACKAGE(PythonLibsNew ${PYTHONVER} REQUIRED)
MESSAGE(STATUS "Found Python executable: ${PYTHON_EXECUTABLE}")
MESSAGE(STATUS "Found Python development: ${PYTHON_LIBRARIES}")
# Include headers from root directory for config file.
......
......@@ -16,7 +16,7 @@ IF (NEKTAR_BUILD_SOLVERS)
ENDIF()
IF (NEKTAR_UTILITY_NEKMESH)
SUBDIRS(NekMeshUtils)
SUBDIRS(NekMesh)
ENDIF()
IF (NEKTAR_UTILITY_FIELDCONVERT OR NEKTAR_BUILD_SOLVERS)
......
import NekPy
import sys
from NekPy.LibUtilities import ShapeType
from NekPy.NekMeshUtils import Node, Element, ElmtConfig, NodeSet, Mesh, Module, ModuleType
import numpy as np
#
# StructuredGrid creates a 2D structured grid of triangles or quads.
#
class StructuredGrid(Module):
def __init__(self, mesh):
super().__init__(mesh)
# This for now only works in 2D.
self.mesh.spaceDim = 2
self.mesh.expDim = 2
# Define some configuration options for this module. AddConfigOption
# requires 3 arguments and has one optional argument:
# - the name of the option;
# - the default value for that option to be used if one is not supplied
# via RegisterConfig;
# - a short description, which is useful if one calls PrintConfig;
# - optionally, if the config option is supposed to be a boolean
# (i.e. on or off), specify True for the fourth parameter.
self.AddConfigOption("nx", "2", "Number of points in x direction")
self.AddConfigOption("ny", "2", "Number of points in y direction")
self.AddConfigOption("lx", "0", "Lower-left x-coordinate")
self.AddConfigOption("rx", "0", "Upper-right x-coordinate")
self.AddConfigOption("ly", "0", "Lower-left y-coordinate")
self.AddConfigOption("ry", "0", "Upper-right y-coordinate")
self.AddConfigOption("compid", "0", "Composite ID")
self.AddConfigOption("shape", "Quadrilateral", "Triangular/Quadrilateral Mesh")
def Process(self):
# Get the input variables from our configuration options. You can use
# either GetFloatConfig, GetIntConfig, GetBoolConfig or GetStringConfig
# depending on the type of data that should have been input into the
# configuration option: in the below we know that the length is a float
# and the numbers of nodes are ints.
coord_1x = self.GetFloatConfig("lx")
coord_1y = self.GetFloatConfig("ly")
coord_2x = self.GetFloatConfig("rx")
coord_2y = self.GetFloatConfig("ry")
nx = self.GetIntConfig("nx")
ny = self.GetIntConfig("ny")
comp_ID = self.GetIntConfig("compid")
shape_type = self.GetStringConfig("shape")
x_points = np.linspace(coord_1x, coord_2x, nx)
y_points = np.linspace(coord_1y, coord_2y, ny)
nodes = []
id_cnt = 0
for y in range(ny):
tmp = []
for x in range(nx):
tmp.append(Node(id_cnt, x_points[x], y_points[y], 0.0))
id_cnt += 1
nodes.append(tmp)
if shape_type[0].lower() == "q":
self._create_quadrilaterals(nodes, nx, ny, comp_ID)
elif shape_type[0].lower() == "t":
self._create_triangles(nodes, nx, ny, comp_ID)
else:
raise ValueError("Unknown shape type: should be quad or tri.")
# Call the Module functions to create all of the edges, faces and
# composites.
self.ProcessVertices()
self.ProcessEdges()
self.ProcessFaces()
self.ProcessElements()
self.ProcessComposites()
def _create_quadrilaterals(self, nodes, nx, ny, comp_ID):
for y in range(ny-1):
for x in range(nx-1):
config = ElmtConfig(ShapeType.Quadrilateral, 1, False, False)
self.mesh.element[2].append(
Element.Create(
config, # Element configuration
[nodes[y][x], nodes[y][x+1], nodes[y+1][x+1], nodes[y+1][x]], # node list
[comp_ID])) # tag for composite.
def _create_triangles(self, nodes, nx, ny, comp_ID):
for y in range(ny-1):
for x in range(nx-1):
config = ElmtConfig(ShapeType.Triangle, 1, False, False)
self.mesh.element[2].append(
Element.Create(
config,
[nodes[y][x], nodes[y+1][x+1], nodes[y+1][x]],
[comp_ID]))
self.mesh.element[2].append(
Element.Create(
config,
[nodes[y][x], nodes[y][x+1], nodes[y+1][x+1]],
[comp_ID]))
# Register our TestInput module with the factory.
Module.Register(ModuleType.Input, "StructuredGrid", StructuredGrid)
if __name__ == '__main__':
if len(sys.argv) != 10:
print("Usage: StructuredGrid.py nx ny lx ly rx ry compid shape outputfile.xml")
print("")
print(" e.g. for a 5x6 quadrilateral grid from (0,1) -> (2,3) with domain composite ID 2:")
print(" StructuredGrid.py 5 6 0.0 1.0 2.0 3.0 2 Quad output.xml")
exit(1)
# Create a 'pipeline' of the input and output modules.
mesh = Mesh()
mod = [
Module.Create(ModuleType.Input, "StructuredGrid", mesh),
Module.Create(ModuleType.Output, "xml", mesh)
]
# Print out config options that we registered in StructuredGrid, just for
# fun and to test they registered correctly!
print("Available options from structured grid generator:")
mod[0].PrintConfig()
# Tell the output module where to write the file.
mod[1].RegisterConfig("outfile", sys.argv[9])
# Now register some sample input configuration options with the module, so
# that it will know the appropriate parameters to generate a mesh for.
mod[0].RegisterConfig("nx", sys.argv[1])
mod[0].RegisterConfig("ny", sys.argv[2])
mod[0].RegisterConfig("lx", sys.argv[3])
mod[0].RegisterConfig("ly", sys.argv[4])
mod[0].RegisterConfig("rx", sys.argv[5])
mod[0].RegisterConfig("ry", sys.argv[6])
mod[0].RegisterConfig("compid", sys.argv[7])
mod[0].RegisterConfig("shape", sys.argv[8])
# Process the pipeline.
for m in mod:
m.SetDefaults()
m.Process()
......@@ -45,7 +45,7 @@
#include <LibUtilities/TimeIntegration/TimeIntegrationScheme.h>
#include <LibUtilities/TimeIntegration/TimeIntegrationSchemeData.h>
#include <NekMeshUtils/Module/ProcessModules/ProcessVarOpti/Evaluator.hxx>
#include <NekMesh/Module/ProcessModules/ProcessVarOpti/Evaluator.hxx>
namespace Nektar
{
......
......@@ -34,9 +34,9 @@
#include <algorithm>
#include <cmath>
#include <NekMeshUtils/2DGenerator/2DGenerator.h>
#include <NekMesh/2DGenerator/2DGenerator.h>
#include <NekMeshUtils/Octree/Octree.h>
#include <NekMesh/Octree/Octree.h>
#include <LibUtilities/BasicUtils/ParseUtils.h>
#include <LibUtilities/BasicUtils/Progressbar.hpp>
......@@ -46,7 +46,7 @@
using namespace std;
namespace Nektar
{
namespace NekMeshUtils
namespace NekMesh
{
ModuleKey Generator2D::className = GetModuleFactory().RegisterCreatorFunction(
......
......@@ -32,18 +32,18 @@
//
////////////////////////////////////////////////////////////////////////////////
#ifndef NEKMESHUTILS_2D_2D
#define NEKMESHUTILS_2D_2D
#ifndef NEKMESH_2D_2D
#define NEKMESH_2D_2D
#include <NekMeshUtils/Module/Module.h>
#include <NekMeshUtils/SurfaceMeshing/CurveMesh.h>
#include <NekMeshUtils/SurfaceMeshing/FaceMesh.h>
#include <NekMesh/Module/Module.h>
#include <NekMesh/SurfaceMeshing/CurveMesh.h>
#include <NekMesh/SurfaceMeshing/FaceMesh.h>
#include <LibUtilities/Interpreter/Interpreter.h>
namespace Nektar
{
namespace NekMeshUtils
namespace NekMesh
{
/**
......
......@@ -41,7 +41,7 @@ using namespace std;
namespace Nektar
{
namespace NekMeshUtils
namespace NekMesh
{
Array<OneD, NekDouble> CADCurve::NormalWRT(NekDouble t, int surf)
......
......@@ -32,17 +32,17 @@
//
////////////////////////////////////////////////////////////////////////////////
#ifndef NEKMESHUTILS_CADSYSTEM_CADCURVE
#define NEKMESHUTILS_CADSYSTEM_CADCURVE
#ifndef NEKMESH_CADSYSTEM_CADCURVE
#define NEKMESH_CADSYSTEM_CADCURVE
#include <LibUtilities/BasicUtils/NekFactory.hpp>
#include <LibUtilities/BasicUtils/SharedArray.hpp>
#include <NekMeshUtils/CADSystem/CADObject.h>
#include <NekMesh/CADSystem/CADObject.h>
namespace Nektar
{
namespace NekMeshUtils
namespace NekMesh
{
// forward declarations
......@@ -77,12 +77,12 @@ public:
*
* @return Array of two entries, min and max parametric coordinate.
*/
NEKMESHUTILS_EXPORT virtual Array<OneD, NekDouble> GetBounds() = 0;
NEKMESH_EXPORT virtual Array<OneD, NekDouble> GetBounds() = 0;
/**
* @brief Returns the minimum and maximum parametric coords t of the curve.
*/
NEKMESHUTILS_EXPORT virtual void GetBounds(
NEKMESH_EXPORT virtual void GetBounds(
NekDouble &tmin, NekDouble &tmax) = 0;
/**
......@@ -93,7 +93,7 @@ public:
* @param tf Second parametric coordinate.
* @return Arc length between \p ti and \p tf.
*/
NEKMESHUTILS_EXPORT virtual NekDouble Length(
NEKMESH_EXPORT virtual NekDouble Length(
NekDouble ti, NekDouble tf) = 0;
/**
......@@ -103,7 +103,7 @@ public:
* @param t Parametric coordinate
* @return Array of x,y,z
*/
NEKMESHUTILS_EXPORT virtual Array<OneD, NekDouble> P(NekDouble t) = 0;
NEKMESH_EXPORT virtual Array<OneD, NekDouble> P(NekDouble t) = 0;
/**
* @brief Gets the location (x,y,z) in an array out of the curve at
......@@ -111,18 +111,18 @@ public:
*
* @param t Parametric coordinate
*/
NEKMESHUTILS_EXPORT virtual void P(
NEKMESH_EXPORT virtual void P(
NekDouble t, NekDouble &x, NekDouble &y, NekDouble &z) = 0;
/**
* @brief Gets the second derivatives at t
*/
NEKMESHUTILS_EXPORT virtual Array<OneD, NekDouble> D2(NekDouble t) = 0;
NEKMESH_EXPORT virtual Array<OneD, NekDouble> D2(NekDouble t) = 0;
/**
* @brief Calculates the radius of curvature of the curve at point t
*/
NEKMESHUTILS_EXPORT virtual NekDouble Curvature(NekDouble t) = 0;
NEKMESH_EXPORT virtual NekDouble Curvature(NekDouble t) = 0;
/**
* @brief Calculates the parametric coordinate and arclength location
......@@ -133,14 +133,14 @@ public:
*
* @todo This really needs improving for accuracy.
*/
NEKMESHUTILS_EXPORT virtual NekDouble tAtArcLength(NekDouble s) = 0;
NEKMESH_EXPORT virtual NekDouble tAtArcLength(NekDouble s) = 0;
/**
* @brief Gets the start and end of the curve.
*
* @return Array with 6 entries of endpoints x1,y1,z1,x2,y2,z2.
*/
NEKMESHUTILS_EXPORT virtual Array<OneD, NekDouble> GetMinMax() = 0;
NEKMESH_EXPORT virtual Array<OneD, NekDouble> GetMinMax() = 0;
/**
* @brief set the ids of the surfaces either side of the curve
......@@ -189,26 +189,26 @@ public:
* @brief locates a point in the parametric space. returns the
* distance to the point and passes t by reference and updates it
*/
NEKMESHUTILS_EXPORT virtual NekDouble loct(
NEKMESH_EXPORT virtual NekDouble loct(
Array<OneD, NekDouble> xyz, NekDouble &t) = 0;
/**
* @brief Returns the orientation of the curve with respect to a given
* surface by id surf
*/
NEKMESHUTILS_EXPORT CADOrientation::Orientation GetOrienationWRT(int surf);
NEKMESH_EXPORT CADOrientation::Orientation GetOrienationWRT(int surf);
/**
* @brief Returns the normal to the curve which is orientate with respect
* to the surface surf
*/
NEKMESHUTILS_EXPORT Array<OneD, NekDouble> NormalWRT(NekDouble t, int surf);
NEKMESH_EXPORT Array<OneD, NekDouble> NormalWRT(NekDouble t, int surf);
/**
* @brief Returns the normal to a curve, it will always point in the concave
* direction
*/
NEKMESHUTILS_EXPORT virtual Array<OneD, NekDouble> N(NekDouble t) = 0;
NEKMESH_EXPORT virtual Array<OneD, NekDouble> N(NekDouble t) = 0;
protected:
/// Length of edge
......
......@@ -32,15 +32,15 @@
//
////////////////////////////////////////////////////////////////////////////////
#ifndef NEKMESHUTILS_CADSYSTEM_CADOBJ
#define NEKMESHUTILS_CADSYSTEM_CADOBJ
#ifndef NEKMESH_CADSYSTEM_CADOBJ
#define NEKMESH_CADSYSTEM_CADOBJ
#include <LibUtilities/Memory/NekMemoryManager.hpp>
#include <NekMeshUtils/NekMeshUtilsDeclspec.h>
#include <NekMesh/NekMeshDeclspec.h>
namespace Nektar
{
namespace NekMeshUtils
namespace NekMesh
{
namespace CADType
......
......@@ -46,7 +46,7 @@ using namespace std;
namespace Nektar
{
namespace NekMeshUtils
namespace NekMesh
{
void CADSurf::OrientateEdges(CADSurfSharedPtr surf,
......
......@@ -32,17 +32,17 @@
//
////////////////////////////////////////////////////////////////////////////////
#ifndef NekMeshUtils_CADSYSTEM_CADSURF
#define NekMeshUtils_CADSYSTEM_CADSURF
#ifndef NekMesh_CADSYSTEM_CADSURF
#define NekMesh_CADSYSTEM_CADSURF
#include <LibUtilities/BasicUtils/NekFactory.hpp>
#include <LibUtilities/BasicUtils/SharedArray.hpp>
#include <NekMeshUtils/CADSystem/CADObject.h>
#include <NekMesh/CADSystem/CADObject.h>
namespace Nektar
{
namespace NekMeshUtils
namespace NekMesh
{
class CADCurve;
......@@ -113,12 +113,12 @@ public:
*
* @return Array of 4 entries with parametric umin,umax,vmin,vmax.
*/
NEKMESHUTILS_EXPORT virtual Array<OneD, NekDouble> GetBounds() = 0;
NEKMESH_EXPORT virtual Array<OneD, NekDouble> GetBounds() = 0;
/**
* @brief Get the limits of the parametric space for the surface.
*/
NEKMESHUTILS_EXPORT virtual void GetBounds(
NEKMESH_EXPORT virtual void GetBounds(
NekDouble &umin, NekDouble &umax, NekDouble &vmin, NekDouble &vmax) = 0;
/**
......@@ -127,7 +127,7 @@ public:
* @param uv Array of u and v parametric coords.
* @return Array of xyz components of normal vector.
*/
NEKMESHUTILS_EXPORT virtual Array<OneD, NekDouble> N(
NEKMESH_EXPORT virtual Array<OneD, NekDouble> N(
Array<OneD, NekDouble> uv) = 0;
/**
......@@ -136,7 +136,7 @@ public:
* @param uv Array of u and v parametric coords.
* @return Array of xyz copmonents of first derivatives.
*/
NEKMESHUTILS_EXPORT virtual Array<OneD, NekDouble> D1(
NEKMESH_EXPORT virtual Array<OneD, NekDouble> D1(
Array<OneD, NekDouble> uv) = 0;
/**
......@@ -145,7 +145,7 @@ public:
* @param uv array of u and v parametric coords
* @return array of xyz copmonents of second derivatives
*/
NEKMESHUTILS_EXPORT virtual Array<OneD, NekDouble> D2(
NEKMESH_EXPORT virtual Array<OneD, NekDouble> D2(
Array<OneD, NekDouble> uv) = 0;
/**
......@@ -154,7 +154,7 @@ public:
* @param uv Array of u and v parametric coords.
* @return Array of x,y,z location.
*/
NEKMESHUTILS_EXPORT virtual Array<OneD, NekDouble> P(
NEKMESH_EXPORT virtual Array<OneD, NekDouble> P(
Array<OneD, NekDouble> uv) = 0;
/**
......@@ -162,7 +162,7 @@ public:
*
* @param uv Array of u and v parametric coords.
*/
NEKMESHUTILS_EXPORT virtual void P(
NEKMESH_EXPORT virtual void P(
Array<OneD, NekDouble> uv, NekDouble &x, NekDouble &y,
NekDouble &z) = 0;
......@@ -173,7 +173,7 @@ public:
* @param p Array of xyz location
* @return The parametric location of xyz on this surface
*/
NEKMESHUTILS_EXPORT virtual Array<OneD, NekDouble> locuv(
NEKMESH_EXPORT virtual Array<OneD, NekDouble> locuv(
Array<OneD, NekDouble> p, NekDouble &dist) = 0;
/**
......@@ -193,19 +193,19 @@ public:
/**
* @brief Returns the bounding box of the surface
*/
NEKMESHUTILS_EXPORT virtual Array<OneD, NekDouble> BoundingBox() = 0;
NEKMESH_EXPORT virtual Array<OneD, NekDouble> BoundingBox() = 0;
/**
* @brief returns curvature at point uv
*/
NEKMESHUTILS_EXPORT virtual NekDouble Curvature(
NEKMESH_EXPORT virtual NekDouble Curvature(
Array<OneD, NekDouble> uv) = 0;
/**
* @brief Is the surface defined by a planar surface (i.e not nurbs and is
* flat)
*/
NEKMESHUTILS_EXPORT virtual bool IsPlanar() = 0;
NEKMESH_EXPORT virtual bool IsPlanar() = 0;
/**
* @brief query reversed normal
......@@ -228,7 +228,7 @@ typedef std::shared_ptr<CADSurf> CADSurfSharedPtr;
typedef LibUtilities::NekFactory<std::string, CADSurf> CADSurfFactory;
CADSurfFactory &GetCADSurfFactory();
} // namespace NekMeshUtils