GenGeo-1.2/AUTHORS0000644000000000000000000000202412533740504011717 0ustar 00000000000000############################################################# ## ## ## Copyright (c) 2007-2014 by The University of Queensland ## ## Centre for Geoscience Computing ## ## http://earth.uq.edu.au/centre-geoscience-computing ## ## ## ## Primary Business: Brisbane, Queensland, Australia ## ## Licensed under the Open Software License version 3.0 ## ## http://www.opensource.org/licenses/osl-3.0.php ## ## ## ############################################################# GenGeo is a community Open Source Software project. The software is maintained by the ESyS-Particle Development Team: https://launchpad.net/~esys-p-dev GenGeo contributors include: S. Abe (2007-) V. Boros (2009-) W. Hancock (2008-) W. Pettersson (2008-2011) D. Weatherley (2008-) For further information about GenGeo authors, email d.weatherley@uq.edu.au. GenGeo-1.2/COPYING0000644000000000000000000000125212533740504011704 0ustar 00000000000000############################################################# ## ## ## Copyright (c) 2007-2014 by The University of Queensland ## ## Centre for Geoscience Computing ## ## http://earth.uq.edu.au/centre-geoscience-computing ## ## ## ## Primary Business: Brisbane, Queensland, Australia ## ## Licensed under the Open Software License version 3.0 ## ## http://www.opensource.org/licenses/osl-3.0.php ## ## ## ############################################################# GenGeo-1.2/ChangeLog0000644000000000000000000000147312533740504012430 0ustar 00000000000000############################################################# ## ## ## Copyright (c) 2007-2014 by The University of Queensland ## ## Centre for Geoscience Computing ## ## http://earth.uq.edu.au/centre-geoscience-computing ## ## ## ## Primary Business: Brisbane, Queensland, Australia ## ## Licensed under the Open Software License version 3.0 ## ## http://www.opensource.org/licenses/osl-3.0.php ## ## ## ############################################################# For information on source code changes, please visit the GenGeo Bazaar repository: https://code.launchpad.net/~esys-p-dev/esys-particle/gengeo GenGeo-1.2/Doxyfile0000644000000000000000000002122012533740504012354 0ustar 00000000000000# Doxyfile 1.4.1-KDevelop #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- PROJECT_NAME = GenGeo PROJECT_NUMBER = 1.1 OUTPUT_DIRECTORY = doc CREATE_SUBDIRS = NO OUTPUT_LANGUAGE = English USE_WINDOWS_ENCODING = NO BRIEF_MEMBER_DESC = YES REPEAT_BRIEF = YES ABBREVIATE_BRIEF = "The $name class" \ "The $name widget" \ "The $name file" \ is \ provides \ specifies \ contains \ represents \ a \ an \ the ALWAYS_DETAILED_SEC = NO INLINE_INHERITED_MEMB = NO FULL_PATH_NAMES = YES STRIP_FROM_PATH = STRIP_FROM_INC_PATH = SHORT_NAMES = NO JAVADOC_AUTOBRIEF = NO MULTILINE_CPP_IS_BRIEF = NO DETAILS_AT_TOP = NO INHERIT_DOCS = YES SEPARATE_MEMBER_PAGES = NO DISTRIBUTE_GROUP_DOC = NO TAB_SIZE = 8 ALIASES = OPTIMIZE_OUTPUT_FOR_C = NO OPTIMIZE_OUTPUT_JAVA = NO SUBGROUPING = YES TYPEDEF_HIDES_STRUCT = NO #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- EXTRACT_ALL = YES EXTRACT_PRIVATE = YES EXTRACT_STATIC = YES EXTRACT_LOCAL_CLASSES = YES EXTRACT_LOCAL_METHODS = NO HIDE_UNDOC_MEMBERS = NO HIDE_UNDOC_CLASSES = NO HIDE_FRIEND_COMPOUNDS = NO HIDE_IN_BODY_DOCS = NO INTERNAL_DOCS = NO CASE_SENSE_NAMES = YES HIDE_SCOPE_NAMES = NO SHOW_INCLUDE_FILES = YES INLINE_INFO = YES SORT_MEMBER_DOCS = YES SORT_BRIEF_DOCS = NO SORT_BY_SCOPE_NAME = NO GENERATE_TODOLIST = YES GENERATE_TESTLIST = YES GENERATE_BUGLIST = YES GENERATE_DEPRECATEDLIST= YES ENABLED_SECTIONS = MAX_INITIALIZER_LINES = 30 SHOW_USED_FILES = YES SHOW_DIRECTORIES = YES SHOW_FILES = YES SHOW_NAMESPACES = YES FILE_VERSION_FILTER = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- QUIET = NO WARNINGS = YES WARN_IF_UNDOCUMENTED = YES WARN_IF_DOC_ERROR = YES WARN_NO_PARAMDOC = YES WARN_FORMAT = "$file:$line: $text" WARN_LOGFILE = doxy_warnings.txt #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- INPUT = src geometry sphere_fitting util Python FILE_PATTERNS = *.cc *.h *.hh RECURSIVE = yes EXCLUDE = EXCLUDE_SYMLINKS = NO EXCLUDE_PATTERNS = EXAMPLE_PATH = EXAMPLE_PATTERNS = * EXAMPLE_RECURSIVE = NO IMAGE_PATH = INPUT_FILTER = FILTER_PATTERNS = FILTER_SOURCE_FILES = NO #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- SOURCE_BROWSER = NO INLINE_SOURCES = NO STRIP_CODE_COMMENTS = YES REFERENCED_BY_RELATION = YES REFERENCES_RELATION = YES VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- ALPHABETICAL_INDEX = YES COLS_IN_ALPHA_INDEX = 5 IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- GENERATE_HTML = YES HTML_OUTPUT = html HTML_FILE_EXTENSION = .html HTML_HEADER = HTML_FOOTER = HTML_STYLESHEET = HTML_ALIGN_MEMBERS = YES GENERATE_HTMLHELP = NO CHM_FILE = HHC_LOCATION = GENERATE_CHI = NO BINARY_TOC = NO TOC_EXPAND = NO DISABLE_INDEX = NO ENUM_VALUES_PER_LINE = 4 GENERATE_TREEVIEW = YES TREEVIEW_WIDTH = 250 #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- GENERATE_LATEX = NO LATEX_OUTPUT = latex LATEX_CMD_NAME = latex MAKEINDEX_CMD_NAME = makeindex COMPACT_LATEX = NO PAPER_TYPE = a4wide EXTRA_PACKAGES = LATEX_HEADER = PDF_HYPERLINKS = NO USE_PDFLATEX = NO LATEX_BATCHMODE = NO LATEX_HIDE_INDICES = NO #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- GENERATE_RTF = NO RTF_OUTPUT = rtf COMPACT_RTF = NO RTF_HYPERLINKS = NO RTF_STYLESHEET_FILE = RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- GENERATE_MAN = NO MAN_OUTPUT = man MAN_EXTENSION = .3 MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- GENERATE_XML = NO XML_OUTPUT = xml XML_SCHEMA = XML_DTD = XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- GENERATE_PERLMOD = NO PERLMOD_LATEX = NO PERLMOD_PRETTY = YES PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- ENABLE_PREPROCESSING = YES MACRO_EXPANSION = NO EXPAND_ONLY_PREDEF = NO SEARCH_INCLUDES = YES INCLUDE_PATH = INCLUDE_FILE_PATTERNS = PREDEFINED = EXPAND_AS_DEFINED = SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::additions related to external references #--------------------------------------------------------------------------- TAGFILES = GENERATE_TAGFILE = gengeo.tag ALLEXTERNALS = NO EXTERNAL_GROUPS = YES PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- CLASS_DIAGRAMS = YES HIDE_UNDOC_RELATIONS = YES HAVE_DOT = YES CLASS_GRAPH = YES COLLABORATION_GRAPH = YES GROUP_GRAPHS = YES UML_LOOK = NO TEMPLATE_RELATIONS = YES INCLUDE_GRAPH = YES INCLUDED_BY_GRAPH = YES CALL_GRAPH = YES GRAPHICAL_HIERARCHY = YES DIRECTORY_GRAPH = YES DOT_IMAGE_FORMAT = png DOT_PATH = DOTFILE_DIRS = MAX_DOT_GRAPH_WIDTH = 1024 MAX_DOT_GRAPH_HEIGHT = 1024 MAX_DOT_GRAPH_DEPTH = 1000 DOT_TRANSPARENT = NO DOT_MULTI_TARGETS = NO GENERATE_LEGEND = YES DOT_CLEANUP = YES #--------------------------------------------------------------------------- # Configuration::additions related to the search engine #--------------------------------------------------------------------------- SEARCHENGINE = NO GenGeo-1.2/Epydoc/0000755000000000000000000000000012533740504012074 5ustar 00000000000000GenGeo-1.2/INSTALL0000644000000000000000000000472312533740504011710 0ustar 00000000000000############################################################# ## ## ## Copyright (c) 2007-2014 by The University of Queensland ## ## Centre for Geoscience Computing ## ## http://earth.uq.edu.au/centre-geoscience-computing ## ## ## ## Primary Business: Brisbane, Queensland, Australia ## ## Licensed under the Open Software License version 3.0 ## ## http://www.opensource.org/licenses/osl-3.0.php ## ## ## ############################################################# INSTALLATION The following instructions describe how to install GenGeo on an Ubuntu distribution of Linux. 1/ Download the GenGeo source code from the Bazaar repository: bzr branch lp:esys-particle/gengeo gengeo cd gengeo/build 2/ Create a configure script for your distribution: ./autogen.sh 3/ Create the Makefiles for GenGeo: ./configure If you are using gcc-4.3 or later, use the following configure command: ./configure CCFLAGS="-fpermissive" CXXFLAGS="-fpermissive" To install in a location other than the default /usr/local, include the switch "--prefix=" followed by the location in which you want to install the libraries; for example: ./configure --prefix=/home/username/gengeo/install 4/ Build GenGeo: make 5/ Install the GenGeo libraries: sudo make install 6/ Update your environment variables (replace "2.6" with your version of Python, and replace "dist-packages" with "site-packages" if this is where your version of Python wants to install the GenGeo python scripts): export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH export PYTHONPATH=/usr/local/lib/python2.6/dist-packages/gengeo:$PYTHONPATH If you have installed in another location, e.g., /home/username/gengeo/install (replace 2.6 with your version of python): export LD_LIBRARY_PATH=/home/myname/gengeo/install/lib:$LD_LIBRARY_PATH export PYTHONPATH=/home/myname/gengeo/install/lib/python2.6/site-packages/gengeo:$PYTHONPATH Set these variables permanently by adding the lines to your shell's initialization file in your home directory. For example, if you are using the Bourne-Again Shell (bash), then add the lines to ~/.bashrc. REINSTALLATION To rebuild and reinstall the source code from a clean distribution: sudo make uninstall make distclean ./configure /* Add other arguments as needed from step 3 above. */ make sudo make install GenGeo-1.2/Makefile.am0000644000000000000000000001725012533740504012712 0ustar 00000000000000############################################################# ## ## ## Copyright (c) 2007-2014 by The University of Queensland ## ## Centre for Geoscience Computing ## ## http://earth.uq.edu.au/centre-geoscience-computing ## ## ## ## Primary Business: Brisbane, Queensland, Australia ## ## Licensed under the Open Software License version 3.0 ## ## http://www.opensource.org/licenses/osl-3.0.php ## ## ## ############################################################# include $(top_srcdir)/config/Python.am PYTHON_DLL_EXT = .so ACLOCAL_AMFLAGS = -I m4 AM_CXXFLAGS = $(PYTHON_CPPFLAGS) $(BOOST_CPPFLAGS) -fPIC -O2 -Wall -pedantic AM_CPPFLAGS += \ -Iutil/ \ -Isrc/ \ -Igeometry/ \ -Isphere_fitting/ \ -Isphere_fitting/utils/ SUBDIRS = libltdl . Epydoc gengeo_PYTHON = Python/__init__.py gengeo_LTLIBRARIES = gengeo.la gengeo_la_CPPFLAGS = $(AM_CPPFLAGS) $(BOOST_PYTHON_CPPFLAGS) gengeo_la_LDFLAGS = -module -shared -shrext $(PYTHON_DLL_EXT) $(AM_LDFLAGS) $(BOOST_PYTHON_LDFLAGS) gengeo_la_SOURCES = \ geometry/AGeometricObject.h \ geometry/Cylinder.h \ geometry/Cylinder.cc \ geometry/Line2D.h \ geometry/Line2D.cc \ geometry/LineSegment.h \ geometry/LineSegment2D.h \ geometry/LineSegment2D.cc \ geometry/Plane.h \ geometry/Plane.cc \ geometry/Sphere.h \ geometry/Sphere.cc \ geometry/SphereIn.h \ geometry/SphereIn.cc \ geometry/Torus.h \ geometry/Torus.cc \ geometry/Triangle3D.h \ geometry/Triangle3D.cc \ Python/AVolume2DPy.h \ Python/AVolume2DPy.cc \ Python/AVolume3DPy.h \ Python/AVolume3DPy.cc \ Python/BoxWithLines2DPy.h \ Python/BoxWithLines2DPy.cc \ Python/BoxWithLines2DSubVolPy.h \ Python/BoxWithLines2DSubVolPy.cc \ Python/BoxWithPlanes3DPy.h \ Python/BoxWithPlanes3DPy.cc \ Python/BoxWithJointSetPy.h \ Python/BoxWithJointSetPy.cc \ Python/CircleVolPy.h \ Python/CircleVolPy.cc \ Python/CircMNTable2DPy.h \ Python/CircMNTable2DPy.cc \ Python/CircMNTableXY2DPy.h \ Python/CircMNTableXY2DPy.cc \ Python/CircMNTable3DPy.h \ Python/CircMNTable3DPy.cc \ Python/ClippedCircleVolPy.h \ Python/ClippedCircleVolPy.cc \ Python/ClippedSphereVolPy.h \ Python/ClippedSphereVolPy.cc \ Python/ConvexPolyhedronPy.h \ Python/ConvexPolyhedronPy.cc \ Python/CylinderVolPy.h \ Python/CylinderVolPy.cc \ Python/CylinderWithJointSetPy.h \ Python/CylinderWithJointSetPy.cc \ Python/DogBonePy.h \ Python/DogBonePy.cc \ Python/FullCircMNTable3DPy.h \ Python/FullCircMNTable3DPy.cc \ Python/ExportModuleUtil.cc \ Python/HexAggregateInsertGenerator2DPy.h \ Python/HexAggregateInsertGenerator2DPy.cc \ Python/HexAggregateInsertGenerator3DPy.h \ Python/HexAggregateInsertGenerator3DPy.cc \ Python/HGrainGenerator2DPy.h \ Python/HGrainGenerator2DPy.cc \ Python/InsertGenerator2DPy.h \ Python/InsertGenerator2DPy.cc \ Python/InsertGenerator3DPy.h \ Python/InsertGenerator3DPy.cc \ Python/Line2DPy.h \ Python/Line2DPy.cc \ Python/LineSegment2DPy.h \ Python/LineSegment2DPy.cc \ Python/MeshVolumePy.h \ Python/MeshVolumePy.cc \ Python/MeshVolWithJointSetPy.h \ Python/MeshVolWithJointSetPy.cc \ Python/MNTable2DPy.h \ Python/MNTable2DPy.cc \ Python/MNTable3DPy.h \ Python/MNTable3DPy.cc \ Python/PlanePy.h \ Python/PlanePy.cc \ Python/PolygonWithLines2DPy.h \ Python/PolygonWithLines2DPy.cc \ Python/ShapePy.h \ Python/ShapePy.cc \ Python/ShapeListPy.h \ Python/ShapeListPy.cc \ Python/SpherePy.h \ Python/SpherePy.cc \ Python/SphereSectionVolPy.h \ Python/SphereSectionVolPy.cc \ Python/SphereVolPy.h \ Python/SphereVolPy.cc \ Python/SphereVolWithJointSetPy.h \ Python/SphereVolWithJointSetPy.cc \ Python/UnionVolPy.h \ Python/UnionVolPy.cc \ Python/IntersectionVolPy.h \ Python/IntersectionVolPy.cc \ Python/DifferenceVolPy.h \ Python/DifferenceVolPy.cc \ Python/EllipsoidVolPy.h \ Python/EllipsoidVolPy.cc \ Python/TriBoxPy.h \ Python/TriBoxPy.cc \ Python/TriPatchSetPy.h \ Python/TriPatchSetPy.cc \ Python/TriWithLines2DPy.h \ Python/TriWithLines2DPy.cc \ Python/Vector3Py.h \ Python/Vector3Py.cc \ sphere_fitting/fit_2d_sphere.h \ sphere_fitting/fit_2d_sphere.cc \ sphere_fitting/fit_3d_sphere.h \ sphere_fitting/fit_3d_sphere.cc \ sphere_fitting/Sphere2DFitter.h \ sphere_fitting/Sphere2DFitter.cc \ sphere_fitting/Sphere3DFitter.h \ sphere_fitting/Sphere3DFitter.cc \ sphere_fitting/fit_functions/fit_2d_sphere_line.h \ sphere_fitting/fit_functions/fit_2d_sphere_line.cc \ sphere_fitting/fit_functions/fit_2d_sphere_2lines.h \ sphere_fitting/fit_functions/fit_2d_sphere_2lines.cc \ sphere_fitting/fit_functions/fit_3d_1sphere_3lines.h \ sphere_fitting/fit_functions/fit_3d_1sphere_3lines.cc \ sphere_fitting/fit_functions/fit_3d_2spheres_2lines.h \ sphere_fitting/fit_functions/fit_3d_2spheres_2lines.cc \ sphere_fitting/fit_functions/fit_3d_3spheres_1line.h \ sphere_fitting/fit_functions/fit_3d_3spheres_1line.cc \ sphere_fitting/utils/nfunction.h \ sphere_fitting/utils/nvector.h \ sphere_fitting/utils/simplex.h \ sphere_fitting/utils/nvector.hh \ sphere_fitting/utils/simplex.hh \ src/AGenerator2D.h \ src/AGenerator3D.h \ src/AVolume.h \ src/AVolume2D.h \ src/AVolume2D.cc \ src/AVolume3D.h \ src/BoxWithLines2D.h \ src/BoxWithLines2D.cc \ src/BoxWithLines2DSubVol.h \ src/BoxWithLines2DSubVol.cc \ src/BoxWithPlanes3D.h \ src/BoxWithPlanes3D.cc \ src/BoxWithJointSet.h \ src/BoxWithJointSet.cc \ src/CircleVol.h \ src/CircleVol.cc \ src/CircMNTable2D.h \ src/CircMNTable2D.cc \ src/CircMNTableXY2D.h \ src/CircMNTableXY2D.cc \ src/CircMNTable3D.h \ src/CircMNTable3D.cc \ src/ClippedCircleVol.h \ src/ClippedCircleVol.cc \ src/ClippedSphereVol.h \ src/ClippedSphereVol.cc \ src/ConvexPolyhedron.h \ src/ConvexPolyhedron.cc \ src/CylinderVol.h \ src/CylinderVol.cc \ src/CylinderWithJointSet.h \ src/CylinderWithJointSet.cc \ src/DogBone.h \ src/DogBone.cc \ src/FullCircMNTable3D.h \ src/FullCircMNTable3D.cc \ src/GenericShape.h \ src/GenericShape.cc \ src/HexAggregateInsertGenerator2D.h \ src/HexAggregateInsertGenerator2D.cc \ src/HexAggregateInsertGenerator2DRand.h \ src/HexAggregateInsertGenerator2DRand.cc \ src/HexAggregateInsertGenerator3D.h \ src/HexAggregateInsertGenerator3D.cc \ src/HexAggregateShape.h \ src/HexAggregateShape.cc \ src/HGrainGenerator.h \ src/HGrainGenerator.cc \ src/InsertGenerator2D.h \ src/InsertGenerator2D.cc \ src/InsertGenerator3D.h \ src/InsertGenerator3D.cc \ src/JointSet.h \ src/MeshVolume.h \ src/MeshVolume.cc \ src/MeshVolWithJointSet.h \ src/MeshVolWithJointSet.cc \ src/MNTable2D.h \ src/MNTable2D.cc \ src/MNTable3D.h \ src/MNTable3D.cc \ src/MNTCell.h \ src/MNTCell.cc \ src/MNTCell3D.h \ src/PolygonWithLines2D.h \ src/PolygonWithLines2D.cc \ src/Shape.h \ src/Shape.cc \ src/ShapeList.h \ src/ShapeList.cc \ src/SphereObj.h \ src/SphereObj.cc \ src/SphereSectionVol.h \ src/SphereSectionVol.cc \ src/SphereVol.h \ src/SphereVol.cc \ src/SphereVolWithJointSet.h \ src/SphereVolWithJointSet.cc \ src/UnionVol.h \ src/UnionVol.cc \ src/IntersectionVol.h \ src/IntersectionVol.cc \ src/DifferenceVol.h \ src/DifferenceVol.cc \ src/EllipsoidVol.h \ src/EllipsoidVol.cc \ src/TriBox.h \ src/TriBox.cc \ src/TriPatchSet.h \ src/TriPatchSet.cc \ src/TriWithLines2D.h \ src/TriWithLines2D.cc \ util/vector3.h \ util/vector3.hh \ util/vector3.cc gengeo_la_LIBADD = $(BOOST_FILESYSTEM_LIBS) $(BOOST_PYTHON_LIBS) $(BOOST_REGEX_LIBS) GenGeo-1.2/NEWS0000644000000000000000000000137712533740504011360 0ustar 00000000000000############################################################# ## ## ## Copyright (c) 2007-2014 by The University of Queensland ## ## Centre for Geoscience Computing ## ## http://earth.uq.edu.au/centre-geoscience-computing ## ## ## ## Primary Business: Brisbane, Queensland, Australia ## ## Licensed under the Open Software License version 3.0 ## ## http://www.opensource.org/licenses/osl-3.0.php ## ## ## ############################################################# Latest news and announcements are available at: https://launchpad.net/esys-particle GenGeo-1.2/Python/0000755000000000000000000000000012533740504012132 5ustar 00000000000000GenGeo-1.2/README0000644000000000000000000000421412533740504011532 0ustar 00000000000000############################################################# ## ## ## Copyright (c) 2007-2014 by The University of Queensland ## ## Centre for Geoscience Computing ## ## http://earth.uq.edu.au/centre-geoscience-computing ## ## ## ## Primary Business: Brisbane, Queensland, Australia ## ## Licensed under the Open Software License version 3.0 ## ## http://www.opensource.org/licenses/osl-3.0.php ## ## ## ############################################################# GenGeo: Scriptable Geometry Creation Library for ESyS-Particle https://launchpad.net/esys-particle OVERVIEW GenGeo is a library for creating geometry files used by ESyS-Particle and other software implementing the Discrete Element Method (DEM). It provides a convenient method for creating arbitrary geometries comprised of spherical particles and bonded particle clusters. A GenGeo script written in Python specifies the geometry that will be generated then written to a text file in a human readable format. The geometry file can then be read by ESyS-Particle or another DEM package to initialise particle locations. FEATURES * Python API for geometry creation * scriptable creation of model geometry files for ESyS-Particle or other DEM simulations * scriptable creation of particle clusters which form the smallest units in a model geometry DEVELOPMENT HISTORY GenGeo has been developed in-house within the Centre for Geoscience Computing at the University of Queensland, Brisbane, Australia since 2008. One of the founding developers, Dr. Steffen Abe, is based at RWTH Aachen, Germany and continues to actively contribute to GenGeo development. CONTRIBUTORS See the AUTHORS file for a list of contributors to GenGeo. GET INVOLVED The GenGeo software development team (https://launchpad.net/~esys-p-dev) is always willing to welcome new developers interested in contributing to the code-base. If you would like to contribute, please contact Dion Weatherley (d.weatherley@uq.edu.au). GenGeo-1.2/autogen.sh0000755000000000000000000000071112533740504012651 0ustar 00000000000000#!/bin/sh # # Script for generating the autoconf configure script # libtoolize --ltdl --force --copy --automake # version >= 1.5.2 aclocal -I m4 # version >= 1.11 for Python 3, 1.8.2 for Python 2.6-2.7 autoheader # version >= 2.59 automake -a -c # version >= 1.11 for Python 3, 1.8.2 for Python 2.6-2.7 autoconf # version >= 2.59 GenGeo-1.2/config/0000755000000000000000000000000012533740504012116 5ustar 00000000000000GenGeo-1.2/configure.ac0000644000000000000000000001276712533740504013154 0ustar 00000000000000############################################################# ## ## ## Copyright (c) 2007-2014 by The University of Queensland ## ## Centre for Geoscience Computing ## ## http://earth.uq.edu.au/centre-geoscience-computing ## ## ## ## Primary Business: Brisbane, Queensland, Australia ## ## Licensed under the Open Software License version 3.0 ## ## http://www.opensource.org/licenses/osl-3.0.php ## ## ## ############################################################# # -*- Autoconf -*- # Process this file with autoconf to produce a configure script. # Boilerplate. AC_INIT([gengeo], [1.1], [d.weatherley@uq.edu.au]) AC_PREREQ([2.59]) AC_LANG([C++]) AC_CONFIG_AUX_DIR([config]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_SRCDIR([src/main.cc]) AC_CONFIG_HEADERS([config/config.h]) # autoconf generates (in configure) a prefix variable test inside the test for # the python script directory based on information in python.m4. Depending on # the version of this macro definition, the prefix variable test does not pass # the default prefix value to the prefix variable. (This happens in the # python.m4 associated with aclocal 1.9 and 1.10. The version with aclocal 1.11 # corrects the problem.) In this case general libraries are installed in # /usr/lib rather than the default /usr/local/lib, and Python 2.6 libraries are # installed in /usr/lib/python2.6/dist-packages rather than the default # /usr/local/lib/python2.6/dist-packages. # # Although autoconf automatically generates a test for the value # of the prefix variable, this test occurs too late in the configure script if # based on a problematic python.m4. Repeating the test here generates the test # earlier in configure and is a safeguard in the event that a newer python.m4 # returns to the problem encountered with the aclocal 1.10 version. test "x$prefix" = "xNONE" && prefix=$ac_default_prefix test "x$exec_prefix" = "xNONE" && exec_prefix=$prefix AM_INIT_AUTOMAKE([subdir-objects]) AM_PATH_PYTHON([2.6]) # # These are the new Libtool macros. Add them and remove the deprecated macros # (not forgetting AC_CONFIG_SUBDIRS near the end of this file) if updating # the Libtool requirements for GenGeo. Be sure to give the user base plenty # of warning before requiring a new version of Libtool (which will be necessary # if the Libtool developers decide no longer to support the deprecated macros). # #LT_CONFIG_LTDL_DIR([libltdl]) #LT_INIT([dlopen]) #LT_PREREQ([2.0]) #LT_LANG([C++]) #LTDL_INIT([subproject convenience]) # # These Libtool macros are deprecated. Remove them if updating the Libtool # requirements for GenGeo. # AC_LIBTOOL_DLOPEN AC_LIBLTDL_CONVENIENCE([libltdl]) AC_PROG_LIBTOOL AC_SUBST([INCLTDL]) AC_SUBST([LIBLTDL]) # # Process the docs option --enable-docs # wants_epydoc=false AC_ARG_ENABLE( [docs], AS_HELP_STRING( [--enable-docs], [Generate HTML documentation on install (requires epydoc) @<:@default=no@:>@.] ), [ if test "x${enableval}" = "xyes"; then wants_epydoc=true fi ] ) # # Process the Epydoc option --with-epydoc[=path/to/epydoc] # AC_ARG_WITH( [epydoc], AS_HELP_STRING( [--with-epydoc@<:@=path/to/epydoc@:>@], [Generate python API documentation in HTML format on install using epydoc @<:@default=no@:>@.] ), [ case "${withval}" in no) wants_epydoc=false ;; yes) wants_epydoc=true; epydocDir="" ;; *) wants_epydoc=true; epydocDir="${withval}" ;; esac ] ) if test "x$wants_epydoc" = "xtrue" ; then if test -n "${epydocDir}" ; then AC_PATH_PROG([EPYDOC_EXE], [epydoc], "no", "${epydocDir}") else AC_PATH_PROG([EPYDOC_EXE], [epydoc], "no") fi if test "$EPYDOC_EXE" = "no" ; then AC_MSG_WARN([epydoc not found! HTML documentation disabled.]) wants_epydoc=false else AC_MSG_NOTICE([epydoc found. HTML documentation enabled.]) fi else AC_MSG_NOTICE([HTML documentation disabled.]) fi AM_CONDITIONAL([EPYDOC_ENABLED], [test "x${wants_epydoc}" = "xtrue"]) # Checks for programs. AC_PROG_CC([icc ecc gcc cc CC cl KCC RCC xlC]) AC_PROG_CXX([icpc ecpc g++ c++ gpp aCC CC cxx cc++ cl FCC KCC RCC xlC_r xlC]) AC_PROG_LN_S AC_CHECK_TOOL([FIND], [find]) # Checks for libraries. PYTHON_SYS_PREFIX=`$PYTHON -c "from __future__ import print_function;import sys;print(sys.prefix)"` AC_CHECK_LIB([python${PYTHON_VERSION}${PYTHON_VERSION_SUFFIX}], [Py_Main]) PYTHON_CPPFLAGS="-I$PYTHON_SYS_PREFIX/include/python${PYTHON_VERSION}${PYTHON_VERSION_SUFFIX}" AC_SUBST([PYTHON_CPPFLAGS]) # Check for boost library if [[ $PYTHON_MAJOR_VERSION -ge 4 ]]; then BOOST_REQUIRE([1.47.0]) elif [[ $PYTHON_MAJOR_VERSION -ge 3 ]]; then if [[ $PYTHON_MINOR_VERSION -ge 2 ]]; then BOOST_REQUIRE([1.47.0]) else BOOST_REQUIRE([1.41.0]) fi else BOOST_REQUIRE([1.34.1]) fi # Check for boost filesystem, python and regex libraries BOOST_FILESYSTEM BOOST_PYTHON BOOST_REGEX # Checks for header files. AC_HEADER_STDBOOL AC_CHECK_HEADERS([stdlib.h sys/time.h]) # Checks for typedefs, structures, and compiler characteristics. AC_C_INLINE AC_TYPE_SIZE_T # Checks for library functions. AC_FUNC_MALLOC AC_FUNC_STRTOD AC_CHECK_FUNCS([floor gettimeofday sqrt]) # Output. AC_CONFIG_SUBDIRS([libltdl]) # Remove when adding the LT* macros above. AC_CONFIG_FILES([Makefile Epydoc/Makefile]) AC_OUTPUT GenGeo-1.2/doc/0000755000000000000000000000000012533740504011416 5ustar 00000000000000GenGeo-1.2/examples/0000755000000000000000000000000012533740504012467 5ustar 00000000000000GenGeo-1.2/geometry/0000755000000000000000000000000012533740504012504 5ustar 00000000000000GenGeo-1.2/m4/0000755000000000000000000000000012533740504011171 5ustar 00000000000000GenGeo-1.2/sphere_fitting/0000755000000000000000000000000012533740504013663 5ustar 00000000000000GenGeo-1.2/src/0000755000000000000000000000000012533740504011440 5ustar 00000000000000GenGeo-1.2/util/0000755000000000000000000000000012533740504011626 5ustar 00000000000000GenGeo-1.2/Epydoc/AuScopeBanner.gif0000644000000000000000000003754712533740504015270 0ustar 00000000000000GIF89ab9uv21845mJ\wmf RubkzZ ֍uUpmnsA|=xWTLHD_P9vy#Q6jHEbԱ\뷥/xF؈q3QDnvöٶ_ڢ煹ֽܩzltЃVN`0tQ_FZWXꟄt0ˑorǰ\J2mXPަ;v# guqddxqܕ[zcgj*~0af|q^L0 :vcE~ r ݢ`OPhV?,bH*\ȰÇ#JHŋ3jȱǏ CIɓ(S\ɲ˗0cʜI͛8sɳϟ@ JѣH*]ʴӧPJJիXj`ÊK٫_ =˶۷px˷߿ LÈ+^̸ǐ#KL˘3k̹ ѢӨS^ͺװc˞M qn Nȓ+_μЇ޽wi#k߾ËOwӫ_Ͼ{G\ѿ?=/e 1|p B 2`VGprjȡ(ar"&B*r2 38bCA( oD‘PB8 X`GSv 4@ `%2(ছ4 Yg#( 8'~:p40(R6 yW9Oj~g(vȒ{>-`qs 6i0eBl )̒j`B\# qcPYxV4-Pd@|MЂ4#;8X2 +;ZҖִEmjUZֵֶcQΖm[FJ}[7!.qqS#ENs\.9-~n ԬPյpk,Pi)wݵ| xK#IW=yh߼>~$)󱋑+GI ex&R"̔* (!t ,?R& qvKB3!041iP+Ԩf5ik)MmlsF7ш{KD"( s_T@纈xR.՞Ȩ:9uj]ܸ+Jc+wGM;(@VzÚ!@LƏdHHz<_IGjRO?CLgJӚT uf@/uVK /_rhAm d.3Τa4mHM>fI)oZ- 8s>d+S=żjPR+.~@`;ΠqDP;ϡK%UT-2Pr^<)KWZ'恭K]kNhL"OnT1Td5;P;Ԡ9u( .1WxL*͜!4y=&9oUkmkiV|'yҗ+>MO"]bFǾrez٫7mxtG؎qV:HXgVX؏Fa`s gLٔNPXwH{hXBk7fׇۨ&YVVD(맄~78F<>I`@BɏՊ[hh =Ұ $9YiTyBIΘ8|8vjϘXY(ԙWG4l#IlݸwllWx鸉zf{Ʉr_4Txn&YnGG ٝɝ q67q8'ir$qYq(q4w.G9ws+XRuř~H]i ]mYlڛCتE* Zy=٧ Xȳ t[vۋAWj *cyd鴜ʥS;l d ),8mH|9e;vz?ɧAYIhJwV9&~˴Yi*cʈZ\^ɹHm ؋=_f0k~6k<0껾8@[P;Kwп|@ܿl \ LlLװ‰0²pl0 ,I&qBN: b(F(B((B*RWXР)_GyfGylxqv 5!?dp C cWŖ ڠ zGL(XC(R:XÂ' gPȊ2!.b#'R"#B " B""!#2# 1ɥ,#̠#I06e$@$E$@$O2 ~PW%]%bBNdb&h&&:x'y2+A|rEuuy8)B nP O KM ޺jRˍ]n>W;92< = C `L/ P p7PV p3{o®MnփO۩v~}/ew=/y0ܮf0. _` P p M`W?j?o PXP&THa… $G$LTVt¤E)T^…;IPDq7tᩀE,`L;6tSHZOBF*е4mHA:q>ם" "DPA G.Ue;6g.r ή^vprȳSժR(l]৓T`Dd`ܹuo'^qɕ/gsѥODصC]BO>xghPno3n1ȒNJi^ni~ jBr *d + +",X-ઋ.:+ajg#61xB 6@fpb@!S<%NKíZ{( 9Ĉ۪sL24L4TsM6:+(Ͻ"\O:xoNS:#8D"$PR)\I&lIxB'(&\) #બ꫰BZ"ŸQ8cdž<#Dd@p +U5 B7u]xw^z M>D'2~HO;>@@Zt?G4JĴMtP,T'UWapVWw%WUQ.bٽd08 Zw#\E Μ%~!{7 et8cgT{vm;n|u8b4/`ۻ p'n?HTK35ә>UTR<5BUO eUa֕OYXbgFgr~07i챥HmB"UBP^{j03쟰'jdp7|Wy.p }<~ H?/@9} wV~,Lq;B"d!  "NjuCl؇PiP@}4Bl@x bh'FщiHE+B [L-ˋ|-kjqZr"o{clщh2'OQF-a}d%-yPwN7 ,Oܗ|E@ aCX,(<*RuJAP%PBPZ.DLT.bG#, ;HE78FiD8Ӟ<Oɀ;v1V5BqMG@x$ @I&T &Vnq!Dʂn9e"IN@q-!wyl LKs) 1YV+ye#3B8#P"iGS4݉S8BdtAG1P VɻZ>S'@ 9#.j k]zy9a!e*/0W:т}N+)ƸY>.cX.+Ґtd+YRV9eOSh>XdSPFb = <N"@A4Ђ5Q0!}G9 WfWە^R>a _V^BN~5 J,NØ-7K%S,K9gsesNK+.8K>Z,K}+ܸViO B%cl G =p r(D iAu'8n}c [2x5RMa JewZjLr~3_S)#&茉Lj>Oo6BA8[)!Ә1(.%r  B&1|N|̗{fHlYpѠ? XR=, 逦p2{ phY8]?Q8!)‚xN(R2A`1XtX*,PH4h'(/;bH; o(rܰ<9ك#@yȧr0 e 00S5+=>CK DA A 8@LDE,DE$GGCTDIICCdCODNPDP|R\DM$ETpGkXlDEYHkEpE6`X򊰠@@`FxF(X`6p:<H``N0Bm!!" "+Z("r;[=T"Գ^ b/8ػ&;ACTB '8 3 M,̼BZSCP9 5<=رHʽ ӍCɹ!:Z$%q:bJl#2r,*)ɲ-,,0t3k3;@֪{GA(h{b*K8ȿ3 ̈+8dh '܀3TH=hQCHxL 伙+|/ IJ،ͶJ4J+?뾡>=??Hz[>yck˂?h?˂G?@ @W1@L@66w`vtpnAqM522cUh&9(x:ywmIpR] u=Q]OBs%U[(8ǁ-qn`>0o6|7`|i'c1tͽ|JOWPϷ]5R}~ӟMNVi!Ue~sJ*<}(y޷-p$E"  ԣ :#Ȑ"G,i$ʓ1VH%̘2gҬi&Μ:wB0P H*]jtiQN8tUVbE鄯D;4,TLM+T9LZ `^0{)3Y 4_=髿>rrG9{#6/$>Z"ȏ:s?1H #p PX#^(9 # 3#<ŎRXBq mb;JaRx4A $ H(rcȀx#eXd%G=f+6I|w",c9 n~#J;]`R<&O2L 0A`eCXjaD"Ee23t'@Xk#"G)X"e i De\ȎС eȄ>y#&@.6t$D8-u*txD)ZbD&JSR}d,HBŠf6Hҝf #DM(>#P6G)D#i`O=#] _lgG6r5(!ZJkza/ȦG|JV1X'! jP*-Q׻QM=)O2_C5թL8z$0"#2c#ER#ЌAHz jiOU x5 dl)Go r" \26E4#LT2@*VHf>ItS߰&mɛGb0h3=~3-AІ>4E3ю~t(M(A269i# %jn pmY TKaBXJ^憲i,+ ЌcC5x7^(HV(VG pzy][hEQ=E9AM ?с^dVɚ1DUa`i!XSzW1=6Eur_ 3Pa^E\*`XeWPQ2 V vJKaG!LM!!ơ!֡!!!  "!!""&"."#6#>"$F$N"%V%^"&f&n"'v'~"((")b**"++",Ƣ,"-֢-".."//"00#11#2&2.#363>|L#5V5^#6f6n#7v7~#88#96@:#;;c;#>#??#;~ $AA$B&B.$C6C>$DFDN$EVE^$FfFn$GvG~$HH$II$JJ@K$LƤL$M֤M$NN$O$COP%QQ%R&R.%SBGTFTN%UVU^%VfVn%WvW~%XX%YY%ZZ%[[%\ƥ\%]֥]|%__%``&aa&b&b.&c6c>&dFdN&eVe^&fffn&gvg~&hh:G$i&jj&kk&lƦl&m֦m&nn&oo&pp'qq'r&r.'s6g|DtN'uVu^'vfvn'wvw~'xx'yy'zz'{{'|Ƨ|'}֧}'~"G'((&.(6>(FN(V^(fn(v~(h|((((ƨ(֨(樎(())&.)6GXN)V^)fn)v~)))))Ʃ)֩)| )**&.*6>*FN*V^*fn*v~**G**ƪ*֪*檮**++&.+6>|DL+V^+fn+v~+++++ƫ++櫾vG؁+,,&.,6>,FN,V^,fn,v~,ȆȎ,ɖ|D+ʮ,˶˾,Ƭ,֬,,,--&.-6>-ԶGV^-fn-v~-؆؎-ٖٞ-ڦڮ-۶۾-ƭ-֭-- |-..&..6>.FN.V^.fn.v~.膮.閮~G.붮.Ʈ.֮...//&./6>/F | T^/fn/v~/////Ư/֯//G00'/07?0GO0W_0go0w00 |Da0 0 ǰ 0 װ 00011'/17?1Gqa|D`T_1go1w11111DZ1ױ1q`|^1  2!!2"'"/2#7#?2$G$O2%W%_2&g&o2'w'2((2)^|z*2++2,Dz,2-ײ-2..2//20031132'2/3373G4O35W5_36g6o37w73883993::3;;3<dz<3=׳=3> | ?3@@4AA4B'B/4C7C?4DGDO4EWE_4FgFo4GwG4HH4IG@JJ4KK4LǴL4M״M4NN4OO4PP5QQ5R'MR7S?5TGTO5UWU_5VgVo5W4Sw5XX5YY5ZZK5\ǵ\5]׵]5^^5__5`]@a6b'v\b76`3cG6_CdWe_6fgfo6gwLa/h6ii6jj6kk6lǶl6m׶@mn6oo6pp7qq϶)&r/7s77 ;GenGeo-1.2/Epydoc/AuScopeBannerCropped739x70.gif0000644000000000000000000003251512533740504017375 0ustar 00000000000000GIF89aFJ?BTJMcZ\f^`lcesjm{suvnp{}degqffiffjywoMGQ V ZT^ ]W]^_a ckcbekkbqr|x&n#t(v#y+z5y2oD~$,+&493<44=<6/>5BGXCIDLHTTZRwflDJEMDS\UZMOT[T]^bdkcdilvsxU\\T^Jelflsu|zffjv{ffkve<רγκŪʷϺǓܦˆ샩혙ÿѻ”ҭ˃!,Fa@Ђ!&,`h!F{(8 APX[xI`Ac" +M0B&&,d LP<1dn"HBĊ<ƸhG!`XC,B!BN,Xd†͗dѳf 7lۦMb@x"SHeˀaGP@?*t ҢḲ_ ښ/[,9}@6b3`~g^,N”qBH.k)ǯOӫ_Ͼ˟O1vH2ßM,H/pBC tJn CSAN0D=tY !CUWaB]}aYB|1[;1BExf(saa5֙dY[m֚ifiin)nqnY}9(qXakDFra^wQ]r E-sߧ*ꨤjꩨ*D 0ѐCA2@-BCapf8OF)4щ$`TA.&S38XV>ق Ce$;ExWʁ1Xa I&e]皀'j1t)݆Ye*]abdisw%\D.*4l8ު H0@S!h+D" L&O@ , 1Z@5 MӂULOI$mAҸVaW^dYC[]R``dɨaW(d)f&z fjIemGz8dln!s[ťD8 w:/o|-N&(? 32HO Y< @@1('ȰOt{ 1OTP7jN[PS_K‹=Vt|;؛ d.`?p \0E;^TRȀ@p_  4YӜ԰FbD8˕O0L1Bc1J&B:lA B7cˢ.z@c&1R03 R8#9> rlxF2q`#5 Oc'Q `P$/,r@xB؄2NR^$\2Rd! WjЅ/xa VB@2 *Ö`@́ "93f˽F$fҸ5<7 an  rԃ0v BAvL9dѵAm'hយ3 sxʋD'JC,( f@,H4&hS4bLu0 6%R A MSR f2pR>!AF0! F'8K@ W qB^Ȇ1lA9$@2"vfd"2)a^h2dn7l i{`;:A]J#<aa4L%2K R6ApKFʈ5Ԋ+9,A1Հj0 B:faNJ`#HH$-M!޺r$.G{KZ#-CpR]UKRbZǘ6܆LbeM sg 31;w@BM LyL_^׸HN*)UɱjB5Ⱥ I0]^mȂHf`lb_f<%m beEYn>AH .@aO+k@Ld26fmnt#gh2tQM@ gxhPL 1èDhBV|DW K&[ x94^*C&bB 26 bȊ()hBjDAkGF"-K+_>aRP)p{0@xx_&eXH%P@0&p(BET,,:9_@zCeQAlQpxSK8y,T0#H'W?Q { 0 P 0p VDڮʘE5I6A\JeE"J+-Pg> Q/:YCjA ~6 }g#2w#@7$R`xq/Pc)M&[Z2lj  5ǭ0 P+P =ǁ| ڵ^|JtgW56r}5o#@59~# /0Ǣ~I@%gi#0ע}J{Vʹ>#ux$ 8`K"%x@W⤅QrU9%&wra0 Q1Cɀp̀ Эp@@P`} `0蛾5S 1оKO!a41OPSKM`d=03`]P;3;C>ˏ۾@SI kO ,?`Pe20reV:V?@m!qhxZ0O8DYFir`)KxLP%[&ǕkR'vF'MrR c&KpǠ Pd\pP& 0x + l*>@=@@GAȋȆlɌIA@dȋNA>=_ɝɇMʩ<ɲLHLI\IP˛xTɌU>F\LlhȤlYp#?`DP-K8,X`s @,UyHYДsPsrLXr9ԴCMnODtNDŅCa]z DOP `b #Xpǁ|(Makpȹe4pnD}q[ ~s}f܇QAulK~':Q1ʸ@Գ=WGK0g4œ+#9@xdQBp$J:%d;Q/QB9h1v@;lPM` 6&]y@0P)ڪ6u=J*b_]+~:]5=~0b g5V_<_" `bj$)x7y!S{E:ەyB ]MPeG ͮ p(\Ż M]vXge4ŸV=,:5Y" ^ hhg=}hk%0[8x!aɈ\& 0WMda 1 kl Q }}Q Z?`XZK ` 1lP #0(~` _Qp&0&PHOM?#&0}7_](`(;(J>?&TO# _~!T(NQ_ /E07`Y;X3`P2$D%H%QqzpC @ BR @@K C :(Q;~QH"ۍcWRdZl÷ a~*I brFÌ;n离n  F{R܂c - Ÿ (<L( YpJ ?aȁ PW=p 68x pW! Z`^tx׈1歗" ,b܋0c 7o(<&AA2v(T( d&Xņ @A##h4tFvD"AJ\D20I=zё}d)i#ɒVF آ#araŶr̤ G=rXآJwb8D"8Nt|X7W8`,9`|wuL(\ 7$|0`{ , DA"Q@+yAE"]:B` YG9 kX֐)5 A5H   P2A[ d@(@e<h.0anK$Hq.b3?3&Gc EZt$l1 O s şC1֊8PԠK޲3ZM\#EΊ{AE0qި4>xA.}kBhaTA8֎o6OƓB#< ?XM0i{d(0J0/KLf 1˴zCJl0! mnu۸tChC R0&tW |ҏv{m& LS p 4v|x8\"I BҩB'#A'?= cPJ7RZ ׏P)HK`6  0Y%VQL`)Lqm!b4C(cJm%|EJp2]ctGHB1EjÑj_ssďҔ ͝b%h潙qtrEJSha 1Rb@08A ,YйAw0xX9ih.jvGTDx]/}wHJR_TǀNZY-x&6k  B9[uC$@~? '9"0)ZWќ7{f` {EWxKNxoLrX{l3dibyErfH2INq? 9׼ 4_j֓=d/2`BU<9>W~sK Rxyͥ.s ^y}~`L|[P:eA9ԁvw:/B!PCC:"dG?:2 tk@@}N sp1a fpF3ؖY,? .rDMHqGb'I=BK6cIyXغ"O~i&ӺL‘"04g)h?g?>8A30hϩ xa2sDexȃa`bq _(؇zȠ\=`{up>>{? H^>`Fț2$)ڮAア P.3*3ڛ3 .r'"#8  ڡ&қqHXCjH!w0O%B*K%:6W9:(Aȅ^dHýO<C6x <$=xe"nɚ?Z0_(H 3'@ 8v \ȉ#a) 3ȃ{j)k%a3$&]0>㛋$ʈ(Ƹ˹,b"b"A"1(ѳ悁4zS 5J)fĀH{)* 0&`) #؁GI‰*D؂GG[+wفu(*0 %<Ӄ*Rgx `BXNJO (CS`$>ZXZ`]_$}^؅^\څ]2aнaȅ=eq=e I%[`Ń\>PeQ$Y/'*("cK12̏bLڛ.r.MܛR#Cǣ"/"㗄̏a#9h3A\fh | /"6 UPYXN6pT dJOT8ۆnyu`Ç7Q%qūQZqS#{@qȾ!W +cWSqf%bLF5.遆ŀ E@Jj#қȄVrMsҙw(*?A:RMAYtJzL/Nž5*J0T:6e&sh;)4(5(S"20ET"U] MY:F L)V2f  頺A)&Gip>*q/DR\ l"\(rp;?p*&]m)\U Aм!VSn٫? 8`XƘ@XF0F4haa?p`a#qd qV,q≮/B :踃zx#ӈ&T?&\4XRqT$?8^$D#`I&]H5;,5L #&VC@<ӏ#b@# < 5@I#v]3k9{H&ԴS&ɴ`#,2MyI|͎'g% #ƻmI> lzћ*ܐ6>f0)G6$ xl7GLpZT&|lFr2ac4DBD!GHN|"()eXiXPI&g lH{PL#R5J@8h~jh>b+Ax&%d3aP)ּ&!F6B"@&K<|FukXIj ;y`9 v#ǝMoF,D!2M_H*@AUh% JrDɏcؐ%aY&9 F=*RD`^ш5yxِVGLcN<DJpD,1&D[O,L$.bi-L$?H0F&J ?,TM4֨(,@j.EH  Ҷc%#H@"tXVvw0 aHx%Ι41'MD,J`C[<K0hX\%T&XӑqݠH+& XBm FTbـ6@ Hܭ8aA$ٶ&>q H(&W ª|]NvaGn`;#`D1Hc?lPc(5 =iCDd 2bE~Do-yӻNK@;GenGeo-1.2/Epydoc/Makefile.am0000644000000000000000000000545112533740504014135 0ustar 00000000000000############################################################# ## ## ## Copyright (c) 2007-2014 by The University of Queensland ## ## Centre for Geoscience Computing ## ## http://earth.uq.edu.au/centre-geoscience-computing ## ## ## ## Primary Business: Brisbane, Queensland, Australia ## ## Licensed under the Open Software License version 3.0 ## ## http://www.opensource.org/licenses/osl-3.0.php ## ## ## ############################################################# include $(top_srcdir)/config/Python.am EPYDOCSTYLESHEET = accessBlue.css EPYDOCSRCSTYLESHEET = $(srcdir)/$(EPYDOCSTYLESHEET) GIFFILES = $(srcdir)/AuScopeBannerCropped739x70.gif EXTRA_DIST = $(GIFFILES) $(EPYDOCSTYLESHEET) ## Hook for building the python API HTML documentation. ## Define it using the install-exec-hook because all the binaries ## and python source/byte-code files need to be installed ## so that Epydoc can import modules and access the docstrings. if EPYDOC_ENABLED LIBDIR = $(DESTDIR)$(libdir) GENGEODIR = $(DESTDIR)$(gengeodir) GENGEODATADOCDIR = $(DESTDIR)$(datadir)/doc/$(PACKAGE)-$(VERSION) PYTHONAPIDOCDIR = $(GENGEODATADOCDIR)/pythonapi EPYDOCTOPDIR = $(PYTHONAPIDOCDIR)/html EPYDOCPUBLICDIR = $(EPYDOCTOPDIR)/public EPYDOCPRIVATEDIR = $(EPYDOCTOPDIR)/private epydoc: install-exec-hook install-exec-hook: export LD_LIBRARY_PATH=$(LIBDIR):$$LD_LIBRARY_PATH; \ export PYTHONPATH=$(GENGEODIR):$$PYTHONPATH; \ if test -d "$(GENGEODATADOCDIR)"; then chmod 755 "$(GENGEODATADOCDIR)"; else ${INSTALL} -m 755 -d "$(GENGEODATADOCDIR)"; fi; \ if test -d "$(PYTHONAPIDOCDIR)"; then chmod 755 "$(PYTHONAPIDOCDIR)"; else ${INSTALL} -m 755 -d "$(PYTHONAPIDOCDIR)"; fi; \ if test -d "$(EPYDOCTOPDIR)"; then chmod 755 "$(EPYDOCTOPDIR)"; else ${INSTALL} -m 755 -d "$(EPYDOCTOPDIR)"; fi; \ if test -d "$(EPYDOCPUBLICDIR)"; then chmod 755 "$(EPYDOCPUBLICDIR)"; else ${INSTALL} -m 755 -d "$(EPYDOCPUBLICDIR)"; fi; \ if test -d "$(EPYDOCPRIVATEDIR)"; then chmod 755 "$(EPYDOCPRIVATEDIR)"; else ${INSTALL} -m 755 -d "$(EPYDOCPRIVATEDIR)"; fi; \ ${INSTALL} -m 644 $(EPYDOCSRCSTYLESHEET) $(PYTHONAPIDOCDIR) ; \ ${INSTALL} -m 644 $(GIFFILES) $(EPYDOCTOPDIR) ; \ ${INSTALL} -m 644 $(GIFFILES) $(EPYDOCPUBLICDIR) ; \ ${INSTALL} -m 644 $(GIFFILES) $(EPYDOCPRIVATEDIR) ; \ if test -f "$(GENGEODIR)/__init__.py"; then cd $(PYTHONAPIDOCDIR) && \ $(EPYDOC_EXE) --html --verbose --no-sourcecode --css accessBlue.css --name "GenGeo $(VERSION)" gengeo; fi uninstall-local: if test -d "$(PYTHONAPIDOCDIR)"; then chmod -R +rw "$(PYTHONAPIDOCDIR)" &&\ rm -r -f "$(PYTHONAPIDOCDIR)"; fi endif GenGeo-1.2/Epydoc/accessBlue.css0000644000000000000000000001064612533740504014666 0ustar 00000000000000/* Body color */ body { background: #ffffff; color: #000000; } /* Tables */ table.summary, table.details, table.index { background: #e8f0f8 ; color: #000000; } tr.summary, tr.details, tr.index { background: #70b0f0; color: #000000; text-align: left; font-size: 120%; } tr.group { background: #c0e0f8; color: #000000; text-align: left; font-size: 120%; font-style: italic; } /* Documentation page titles */ h2.module { margin-top: 0.2em; } h2.class { margin-top: 0.2em; } /* Headings */ h1.heading { font-size: +140%; font-style: italic; font-weight: bold; } h2.heading { font-size: +125%; font-style: italic; font-weight: bold; } h3.heading { font-size: +110%; font-style: italic; font-weight: normal; } /* Base tree */ pre.base-tree { font-size: 80%; margin: 0; } /* Details Sections */ table.func-details { background: #e8f0f8; color: #000000; border: 2px groove #c0d0d0; padding: 0 1em 0 1em; margin: 0.4em 0 0 0; } h3.func-detail { background: transparent; color: #000000; margin: 0 0 1em 0; } table.var-details { background: #e8f0f8; color: #000000; border: 2px groove #c0d0d0; padding: 0 1em 0 1em; margin: 0.4em 0 0 0; } h3.var-details { background: transparent; color: #000000; margin: 0 0 1em 0; } /* Function signatures */ .sig { background: transparent; color: #000000; font-weight: bold; } .sig-name { background: transparent; color: #006080; } .sig-arg, .sig-kwarg, .sig-vararg { background: transparent; color: #008060; } .sig-default { background: transparent; color: #602000; } .summary-sig { background: transparent; color: #000000; } .summary-sig-name { background: transparent; color: #204080; } .summary-sig-arg, .summary-sig-kwarg, .summary-sig-vararg { background: transparent; color: #008060; } /* Doctest blocks */ .py-src { background: transparent; color: #000000; } .py-prompt { background: transparent; color: #005050; font-weight: bold;} .py-string { background: transparent; color: #006030; } .py-comment { background: transparent; color: #003060; } .py-keyword { background: transparent; color: #600000; } .py-output { background: transparent; color: #404040; } pre.doctestblock { background: #f4faff; color: #000000; padding: .5em; margin: 1em; border: 1px solid #708890; } table pre.doctestblock { background: #dce4ec; color: #000000; padding: .5em; margin: 1em; border: 1px solid #708890; } /* Variable values */ pre.variable { background: #dce4ec; color: #000000; padding: .5em; margin: 0; border: 1px solid #708890; } .variable-linewrap { background: transparent; color: #604000; } .variable-ellipsis { background: transparent; color: #604000; } .variable-quote { background: transparent; color: #604000; } .re { background: transparent; color: #000000; } .re-char { background: transparent; color: #006030; } .re-op { background: transparent; color: #600000; } .re-group { background: transparent; color: #003060; } .re-ref { background: transparent; color: #404040; } /* Navigation bar */ table.navbar { background: transparent url(AuScopeBannerCropped739x70.gif) repeat-x; color: #0000ff; border: 2px groove #c0d0d0; height: 90px; } th.navbar { background: transparent #ffffff; color: #0000ff; font-size: 125%; } th.navselect { background: transparent #ffffff; color: #0000ff; font-size: 125%; } .nomargin { margin: 0; } /* Links */ a:link { background: transparent; color: #0000ff; } a:visited { background: transparent; color: #204080; } a.navbar:link { background: transparent; color: #0000ff; text-decoration: none; } a.navbar:visited { background: transparent; color: #204080; text-decoration: none; } /* Lists */ ul { margin-top: 0; } GenGeo-1.2/Python/AVolume2DPy.cc0000644000000000000000000000321312533740504014507 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include #include #include "AVolume2DPy.h" using namespace boost::python; using boost::python::arg; void exportAVolume() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_("AVolume", "Abstract base class for Volume classes in 2D or 3D.", no_init); ; } void exportAVolume2D() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_, boost::noncopyable >( "AVolume2D", "Abstract base class for 2D Volumes.", no_init ) ; } GenGeo-1.2/Python/AVolume2DPy.h0000644000000000000000000000160312533740504014352 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_AVOLUME2D_H #define GENGEO_AVOLUME2D_H #include #include "util/vector3.h" #include "src/AVolume.h" #include "src/AVolume2D.h" void exportAVolume(); void exportAVolume2D(); #endif GenGeo-1.2/Python/AVolume3DPy.cc0000644000000000000000000000240012533740504014505 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include #include #include "AVolume3DPy.h" using namespace boost::python; using boost::python::arg; void exportAVolume3D() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_, boost::noncopyable >( "AVolume3D", "Abstract base class for 3D Volumes.", no_init ) ; } GenGeo-1.2/Python/AVolume3DPy.h0000644000000000000000000000147212533740504014357 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_AVOLUME3D_H #define GENGEO_AVOLUME3D_H #include #include "src/AVolume3D.h" void exportAVolume3D(); #endif GenGeo-1.2/Python/BoxWithJointSetPy.cc0000644000000000000000000000405412533740504016021 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include "BoxWithJointSetPy.h" using namespace boost::python; void exportBoxWithJointSet() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_ >( "BoxWithJointSet", "A class defining a rectangular volume in 3D containing a joint set.", init<>() ) .def(init()) .def( init( ( arg("minPoint"), arg("maxPoint") ), "Constructs a box with the specified corner points.\n" "@type minPoint: L{Vector3}\n" "@kwarg minPoint: Coordinate of bottom-left-front corner of the box\n" "@type maxPoint: L{Vector3}\n" "@kwarg maxPoint: Coordinate of upper-right-back corner of the box\n" ) ) .def( "addJoints", &BoxWithJointSet::addJoints, ( arg("JointSet") ), "Adds to the box a L{TriPatchSet} representing joints. Particles will be fitted around the joints.\n" "@type JointSet: L{TriPatchSet}\n" "@kwarg JointSet: the set of triangular patches to add\n" "@rtype: void\n" ) .def(self_ns::str(self)) ; } GenGeo-1.2/Python/BoxWithJointSetPy.h0000644000000000000000000000161712533740504015665 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_BOXWITHJOINTSETPY_H #define GENGEO_BOXWITHJOINTSETPY_H #include #include "src/AVolume3D.h" #include "src/BoxWithJointSet.h" void exportBoxWithJointSet(); #endif // GENGEO_BOXWITHJOINTSETPY_H GenGeo-1.2/Python/BoxWithLines2DPy.cc0000644000000000000000000000406512533740504015524 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include "BoxWithLines2DPy.h" #include "src/BoxWithLines2D.h" using namespace boost::python; void exportBoxWithLines2D() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_ >( "BoxWithLines2D", "A class defining a rectangular volume in 2D optionally bounded by lines.", init<>() ) .def(init()) .def( init( ( arg("minPoint"), arg("maxPoint") ), "Constructs a box with the specified corner points.\n" "@type minPoint: L{Vector3}\n" "@kwarg minPoint: Coordinate of bottom left corner of the box\n" "@type maxPoint: L{Vector3}\n" "@kwarg maxPoint: Coordinate of upper right corner of the box\n" ) ) .def( "addLine", &BoxWithLines2D::addLine, ( arg("line") ), "Adds a line to the box for fitting particles.\n" "@type line: L{Line2D}\n" "@kwarg line: the line to add to the box\n" "@rtype: void\n" ) .def(self_ns::str(self)) ; // boost::python::implicitly_convertible(); } GenGeo-1.2/Python/BoxWithLines2DPy.h0000644000000000000000000000152212533740504015361 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_BOXWITHLINES2DPY_H #define GENGEO_BOXWITHLINES2DPY_H #include #include "src/BoxWithLines2D.h" void exportBoxWithLines2D(); #endif GenGeo-1.2/Python/BoxWithLines2DSubVolPy.cc0000644000000000000000000000411412533740504016652 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include "BoxWithLines2DSubVolPy.h" #include "src/BoxWithLines2DSubVol.h" using namespace boost::python; void exportBoxWithLines2DSubVol() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_ >( "BoxWithLines2DSubVol", "A class defining a rectangular sub-volume in 2D bounded by lines.", init<>() ) .def(init()) .def( init( ( arg("minPoint"), arg("maxPoint"), arg("svdim_x"), arg("svdim_y") ), "Constructs a box with the specified corner points.\n" "@type minPoint: L{Vector3}\n" "@kwarg minPoint: Coordinate of bottom left corner of the box\n" "@type maxPoint: L{Vector3}\n" "@kwarg maxPoint: Coordinate of upper right corner of the box\n" "@type svdim_x: double\n" "@kwarg svdim_x: length of subvolumes in x-direction\n" "@type svdim_y: double\n" "@kwarg svdim_y: length of subvolumes in y-direction\n" ) ) .def(self_ns::str(self)) ; // boost::python::implicitly_convertible(); } GenGeo-1.2/Python/BoxWithLines2DSubVolPy.h0000644000000000000000000000155212533740504016517 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_BOXWITHLINES2DSUBVOLPY_H #define GENGEO_BOXWITHLINES2DSUBVOLPY_H #include #include "src/BoxWithLines2DSubVol.h" void exportBoxWithLines2DSubVol(); #endif GenGeo-1.2/Python/BoxWithPlanes3DPy.cc0000644000000000000000000000405612533740504015675 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include "BoxWithPlanes3DPy.h" using namespace boost::python; void exportBoxWithPlanes3D() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_ >( "BoxWithPlanes3D", "A class defining a rectangular volume in 3D optionally bounded by planes.", init<>() ) .def(init()) .def( init( ( arg("minPoint"), arg("maxPoint") ), "Constructs a box with the specified corner points.\n" "@type minPoint: L{Vector3}\n" "@kwarg minPoint: Coordinate of bottom-left-front corner of the box\n" "@type maxPoint: L{Vector3}\n" "@kwarg maxPoint: Coordinate of upper-right-back corner of the box\n" ) ) .def( "addPlane", &BoxWithPlanes3D::addPlane, ( arg("plane") ), "Adds a plane to the box for fitting particles.\n" "@type plane: L{Plane}\n" "@kwarg plane: the plane to add to the box\n" "@rtype: void\n" ) .def(self_ns::str(self)) ; // boost::python::implicitly_convertible(); } GenGeo-1.2/Python/BoxWithPlanes3DPy.h0000644000000000000000000000156112533740504015535 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_BOXWITHPLANES3DPY_H #define GENGEO_BOXWITHPLANES3DPY_H #include #include "src/AVolume3D.h" #include "src/BoxWithPlanes3D.h" void exportBoxWithPlanes3D(); #endif GenGeo-1.2/Python/CircMNTable2DPy.cc0000644000000000000000000000552512533740504015232 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include #include #include #include "CircMNTable2DPy.h" using namespace std; using namespace boost::python; using boost::python::arg; void exportCircMNTable2D() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_ >( "CircMNTable2D", "A multi-group neighbours table for constructing 2D particle setups with circular boundary conditions in the X-direction.", init<>() ) .def(init()) .def( init( ( boost::python::arg("minPoint"), boost::python::arg("maxPoint"), boost::python::arg("gridSize"), boost::python::arg("numGroups")=1 ), "Constructs a neighbours table with specified bounds, cell size and initial number of particle groups.\n" "@type minPoint: L{Vector3}\n" "@kwarg minPoint: lower-left point of the particle region\n" "@type maxPoint: L{Vector3}\n" "@kwarg maxPoint: upper-right point of the particle region\n" "@type gridSize: double\n" "@kwarg gridSize: the cell size for neighbour searches\n" "@type numGroups: unsigned int\n" "@kwarg numGroups: the initial number of groups (default: 1)\n" ) ) .def( "generateBonds", &CircMNTable2D::generateBonds, (boost::python::arg("groupID")=0, boost::python::arg("tolerance"), boost::python::arg("bondID") ), "Generates bonds between particle pairs separated by less than the specified tolerance\n" "@type groupID: int\n" "@kwarg groupID: the group ID of particles to bond together (default: 0)\n" "@type tolerance: double\n" "@kwarg tolerance: maximum distance separating bonded particles\n" "@type bondID: int\n" "@kwarg bondID: the bond ID to assign generated bonds\n" "@rtype: void\n" ) .def(self_ns::str(self)) ; } GenGeo-1.2/Python/CircMNTable2DPy.h0000644000000000000000000000151212533740504015064 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_CIRCMNTABLE2D_H #define GENGEO_CIRCMNTABLE2D_H #include #include "src/CircMNTable2D.h" void exportCircMNTable2D(); #endif GenGeo-1.2/Python/CircMNTable3DPy.cc0000644000000000000000000001151012533740504015222 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include #include #include #include "CircMNTable3DPy.h" using namespace std; using namespace boost::python; using boost::python::arg; void exportCircMNTable3D() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_ >( "CircMNTable3D", "A multi-group neighbours table for constructing 3D particle setups with circular boundary conditions in the X-direction.", init<>() ) .def(init()) .def( init( ( boost::python::arg("minPoint"), boost::python::arg("maxPoint"), boost::python::arg("gridSize"), boost::python::arg("numGroups") ), "Constructs a neighbours table with specified bounds, cell size and initial number of particle groups.\n" "@type minPoint: L{Vector3}\n" "@kwarg minPoint: lower-left-front point of the particle region\n" "@type maxPoint: L{Vector3}\n" "@kwarg maxPoint: upper-right-back point of the particle region\n" "@type gridSize: double\n" "@kwarg gridSize: the cell size for neighbour searches\n" "@type numGroups: unsigned int\n" "@kwarg numGroups: the initial number of groups\n" ) ) .def( "tagParticlesAlongPlane", &CircMNTable3D::tagParticlesAlongPlane, ( boost::python::arg("plane"), boost::python::arg("distance"), boost::python::arg("tag"), boost::python::arg("groupID")=0 ), "Assigns the specified tag to all particles from group C{groupID}\n" "that lie within the specified distance of the given plane.\n" "@type plane: L{Plane}\n" "@kwarg plane: the plane along which to tag particles\n" "@type distance: double\n" "@kwarg distance: the maximum distance between tagged particles and the plane\n" "@type tag: int\n" "@kwarg tag: the tag to assign particles\n" "@type groupID: unsigned int\n" "@kwarg groupID: the group ID of particles to tag (default: 0)\n" "@rtype: void\n" ) .def( "generateBonds", &CircMNTable3D::generateBonds, (boost::python::arg("groupID")=0, boost::python::arg("tolerance"), boost::python::arg("bondID") ), "Generates bonds between particle pairs separated by less than the specified tolerance\n" "@type groupID: int\n" "@kwarg groupID: the group ID of particles to bond together (default: 0)\n" "@type tolerance: double\n" "@kwarg tolerance: maximum distance separating bonded particles\n" "@type bondID: int\n" "@kwarg bondID: the bond ID to assign generated bonds\n" "@rtype: void\n" ) .def( "getSumVolume", &CircMNTable3D::getSumVolume, ( boost::python::arg("groupID")=0 ), "Returns the sum of the particle volumes in the specified group.\n" "@type groupID: int\n" "@kwarg groupID: the group ID of particles whose volumes are summed (default: 0).\n" "@rtype: double\n" ) .def( "write", &CircMNTable3D::write, ( boost::python::arg("fileName"), boost::python::arg("outputStyle") ), "Writes the particle assembly and bonding information to the specified\n" "file using the specified output style (0: debug; 1: geo; 2: vtk)\n" "@type fileName: string\n" "@kwarg fileName: the name of the file to write\n" "@type outputStyle: int\n" "@kwarg outputStyle: output style (0: debug; 1: geo; 2: vtk)\n" "@rtype: void\n" ) .def( "generateClusterBonds", &CircMNTable3D::generateClusterBonds, (boost::python::arg("groupID")=0, boost::python::arg("tolerance"), boost::python::arg("bondTag1"), boost::python::arg("bondTag2")), "Generates bonds with tag C{bondTag1} within clusters and C{bondTag2} between clusters\n" ) .def(self_ns::str(self)) ; } GenGeo-1.2/Python/CircMNTable3DPy.h0000644000000000000000000000151212533740504015065 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_CIRCMNTABLE3D_H #define GENGEO_CIRCMNTABLE3D_H #include #include "src/CircMNTable3D.h" void exportCircMNTable3D(); #endif GenGeo-1.2/Python/CircMNTableXY2DPy.cc0000644000000000000000000000444512533740504015513 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include #include #include #include "CircMNTableXY2DPy.h" using namespace std; using namespace boost::python; using boost::python::arg; void exportCircMNTableXY2D() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_ >( "CircMNTableXY2D", "A multi-group neighbours table for constructing 2D particle setups with circular boundary conditions in both (X and Y) directions. This is largely for packing algorithm testing", init<>() ) .def(init()) .def( init( ( boost::python::arg("minPoint"), boost::python::arg("maxPoint"), boost::python::arg("gridSize"), boost::python::arg("numGroups")=1 ), "Constructs a neighbours table with specified bounds, cell size and initial number of particle groups.\n" "@type minPoint: L{Vector3}\n" "@kwarg minPoint: lower-left point of the particle region\n" "@type maxPoint: L{Vector3}\n" "@kwarg maxPoint: upper-right point of the particle region\n" "@type gridSize: double\n" "@kwarg gridSize: the cell size for neighbour searches\n" "@type numGroups: unsigned int\n" "@kwarg numGroups: the initial number of groups (default: 1)\n" ) ) .def(self_ns::str(self)) ; } GenGeo-1.2/Python/CircMNTableXY2DPy.h0000644000000000000000000000152212533740504015346 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_CIRCMNTABLEXY2D_H #define GENGEO_CIRCMNTABLEXY2D_H #include #include "src/CircMNTableXY2D.h" void exportCircMNTableXY2D(); #endif GenGeo-1.2/Python/CircleVolPy.cc0000644000000000000000000000314012533740504014632 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include "CircleVolPy.h" using namespace boost::python; void exportCircleVol() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_ >( "CircleVol", "A class defining a circular L{AVolume2D}.", init<>() ) .def(init()) .def( init( ( arg("centre"), arg("radius") ), "Constructs a circle with the specified centre and radius.\n" "@type centre: L{Vector3}\n" "@kwarg centre: Coordinates of the centre of the circle\n" "@type radius: double\n" "@kwarg radius: Radius of the circle\n" ) ) .def(self_ns::str(self)) ; } GenGeo-1.2/Python/CircleVolPy.h0000644000000000000000000000152612533740504014502 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_CIRCLEVOLPY_H #define GENGEO_CIRCLEVOLPY_H #include #include "src/CircleVol.h" void exportCircleVol(); #endif // GENGEO_CIRCLEVOLPY_H GenGeo-1.2/Python/ClippedCircleVolPy.cc0000644000000000000000000000365412533740504016145 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include "ClippedCircleVolPy.h" using namespace boost::python; void exportClippedCircleVol() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_ >( "ClippedCircleVol", "A class defining a circle in 2D space clipped by lines.", init<>() ) .def(init()) .def( init( ( arg("centre"), arg("radius") ), "Constructs a circle with the specified centre and radius.\n" "@type centre: L{Vector3}\n" "@kwarg centre: Coordinates of the centre of the circle\n" "@type radius: double\n" "@kwarg radius: Radius of the circle\n" ) ) .def( "addLine", &ClippedCircleVol::addLine, ( arg("line"), arg("fit") ), "Adds a line to the area for clipping the circle.\n" "@type line: L{Line2D}\n" "@kwarg line: the line to add to the area\n" "@rtype: void\n" ) .def(self_ns::str(self)) ; } GenGeo-1.2/Python/ClippedCircleVolPy.h0000644000000000000000000000153212533740504016000 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_CLIPPEDCIRCLEVOLPY_H #define GENGEO_CLIPPEDCIRCLEVOLPY_H #include #include "src/ClippedCircleVol.h" void exportClippedCircleVol(); #endif GenGeo-1.2/Python/ClippedSphereVolPy.cc0000644000000000000000000000367212533740504016172 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include "ClippedSphereVolPy.h" using namespace boost::python; void exportClippedSphereVol() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_ >( "ClippedSphereVol", "A class defining a sphere in 3D space clipped by planes.", init<>() ) .def(init()) .def( init( ( arg("centre"), arg("radius") ), "Constructs a sphere with the specified centre and radius.\n" "@type centre: L{Vector3}\n" "@kwarg centre: Coordinates of the centre of the sphere\n" "@type radius: double\n" "@kwarg radius: Radius of the sphere\n" ) ) .def( "addPlane", &ClippedSphereVol::addPlane, ( arg("plane"), arg("fit") ), "Adds a plane to the volume for clipping the sphere.\n" "@type plane: L{Plane}\n" "@kwarg plane: the plane to add to the volume\n" "@rtype: void\n" ) .def(self_ns::str(self)) ; } GenGeo-1.2/Python/ClippedSphereVolPy.h0000644000000000000000000000153212533740504016025 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_CLIPPEDSPHEREVOLPY_H #define GENGEO_CLIPPEDSPHEREVOLPY_H #include #include "src/ClippedSphereVol.h" void exportClippedSphereVol(); #endif GenGeo-1.2/Python/ConvexPolyhedronPy.cc0000644000000000000000000000332712533740504016265 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include "ConvexPolyhedronPy.h" using namespace boost::python; void exportConvexPolyhedron() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_ >( "ConvexPolyhedron", "A class defining a convex polyhedral L{AVolume3D} bounded by planes.", init<>() ) .def(init()) .def( init( ( arg("minPoint"), arg("maxPoint") ), "Specifies the bounding box of a convex polyhedron.\n" "@type minPoint: L{Vector3}\n" "@kwarg minPoint: Coordinate of bottom-left-front corner of the bounding box\n" "@type maxPoint: L{Vector3}\n" "@kwarg maxPoint: Coordinate of upper-right-back corner of the bounding box\n" ) ) .def(self_ns::str(self)) ; } GenGeo-1.2/Python/ConvexPolyhedronPy.h0000644000000000000000000000165712533740504016133 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_CONVEXPOLYHEDRON_H #define GENGEO_CONVEXPOLYHEDRON_H #include #include "src/AVolume3D.h" #include "src/BoxWithPlanes3D.h" #include "src/ConvexPolyhedron.h" void exportConvexPolyhedron(); #endif // GENGEO_CONVEXPOLYHEDRON_H GenGeo-1.2/Python/CylinderVolPy.cc0000644000000000000000000000360212533740504015205 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include "CylinderVolPy.h" using namespace boost::python; void exportCylinderVol() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_ >( "CylinderVol", "A class defining a cylindrical L{AVolume3D}.", init<>() ) .def(init()) .def( init( ( arg("origin"), arg("axis"), arg("length"), arg("radius") ), "Constructs a cylinder with the specified origin, axis, length and radius.\n" "@type origin: L{Vector3}\n" "@kwarg origin: Coordinate of origin (centre of base) of the cylinder\n" "@type axis: L{Vector3}\n" "@kwarg axis: Unit vector in the direction of the cylinder axis\n" "@type length: double\n" "@kwarg length: Length of the cylinder\n" "@type radius: double\n" "@kwarg radius: Radius of the cylinder\n" ) ) .def(self_ns::str(self)) ; } GenGeo-1.2/Python/CylinderVolPy.h0000644000000000000000000000150612533740504015050 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_CYLINDERVOLPY_H #define GENGEO_CYLINDERVOLPY_H #include #include "src/CylinderVol.h" void exportCylinderVol(); #endif GenGeo-1.2/Python/CylinderWithJointSetPy.cc0000644000000000000000000000433412533740504017043 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include "CylinderWithJointSetPy.h" using namespace boost::python; void exportCylinderWithJointSet() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_ >( "CylinderWithJointSet", "A class defining a cylinder in 3D space containing an optional joint set.", init<>() ) .def(init()) .def( init( ( arg("origin"), arg("axis"), arg("length"), arg("radius") ), "Constructs a cylinder with the specified origin, axis, length and radius.\n" "@type origin: L{Vector3}\n" "@kwarg origin: Coordinate of origin (centre of base) of the cylinder\n" "@type axis: L{Vector3}\n" "@kwarg axis: Unit vector in the direction of the cylinder axis\n" "@type length: double\n" "@kwarg length: Length of the cylinder\n" "@type radius: double\n" "@kwarg radius: Radius of the cylinder\n" ) ) .def( "addJoints", &CylinderWithJointSet::addJoints, ( arg("JointSet") ), "Adds a set of triangluar patches as joints.\n" "@type plane: L{Plane}\n" "@kwarg plane: the set of patches\n" "@rtype: void\n" ) .def(self_ns::str(self)) ; } GenGeo-1.2/Python/CylinderWithJointSetPy.h0000644000000000000000000000155212533740504016704 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_CYLINDERWITHJOINTSETPY_H #define GENGEO_CYLINDERWITHJOINTSETPY_H #include #include "src/CylinderWithJointSet.h" void exportCylinderWithJointSet(); #endif GenGeo-1.2/Python/DifferenceVolPy.cc0000644000000000000000000000347712533740504015500 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include "DifferenceVolPy.h" using namespace boost::python; void exportDifferenceVol() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_ >( "DifferenceVol", "A class defining a volume consisting of the difference between two volumes", init<>() ) .def(init()) .def( init( ( arg("volume1"), arg("volume2") ), "Constructs a volume comprised of the difference of two volumes.\n" "The volume to be packed is all points within the first volume that are not also in the second volume.\n" "@type volume1: L{AVolume3D}\n" "@kwarg volume1: The first volume comprising the difference\n" "@type volume2: L{AVolume3D}\n" "@kwarg volume2: The second volume comprising the difference\n" ) ) .def(self_ns::str(self)) ; } GenGeo-1.2/Python/DifferenceVolPy.h0000644000000000000000000000150212533740504015325 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_DIFFVOLPY_H #define GENGEO_DIFFVOLPY_H #include #include "src/DifferenceVol.h" void exportDifferenceVol(); #endif GenGeo-1.2/Python/DogBonePy.cc0000644000000000000000000000401312533740504014265 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include "DogBonePy.h" using namespace boost::python; void exportDogBone() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_ >( "DogBone", "A class defining a dogbone volume.", init<>() ) .def(init()) .def( init( ( arg("origin"), arg("axis"), arg("length"), arg("radius"), arg("l2"), arg("r2") ), "Constructs a dogbone volume with the specified dimensions.\n" "@type origin: L{Vector3}\n" "@kwarg origin: Coordinate of origin (centre of base) of the dogbone\n" "@type axis: L{Vector3}\n" "@kwarg axis: Unit vector in the direction of the dogbone axis\n" "@type length: double\n" "@kwarg length: Length of the dogbone\n" "@type radius: double\n" "@kwarg radius: Radius of the dogbone\n" "@type l2: double\n" "@kwarg l2: L2 of the dogbone\n" "@type r2: double\n" "@kwarg r2: R2 of the dogbone\n" ) ) .def(self_ns::str(self)) ; } GenGeo-1.2/Python/DogBonePy.h0000644000000000000000000000146612533740504014140 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_DOGBONEPY_H #define GENGEO_DOGBONEPY_H #include #include "src/DogBone.h" void exportDogBone(); #endif GenGeo-1.2/Python/EllipsoidVolPy.cc0000644000000000000000000000400612533740504015357 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include "EllipsoidVolPy.h" using namespace boost::python; void exportEllipsoidVol() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_ >( "EllipsoidVol", "A class defining an ellipsoid. Major axes are axis-aligned.", init<>() ) .def(init()) .def( init( ( arg("centre"), arg("Lx"), arg("Ly"), arg("Lz") ), "Constructs an ellipsoid with the specified centre and axis-aligned lengths. WARNING: The surface particles are not fitted to the ellipsoid surface, resulting in blob-like particle clusters.\n" "@type centre: L{Vector3}\n" "@kwarg centre: Coordinates of the centre of the ellipsoid\n" "@type Lx: double\n" "@kwarg Lx: Length of ellipsoid major axis in x-direction\n" "@type Ly: double\n" "@kwarg Ly: Length of ellipsoid major axis in y-direction\n" "@type Lz: double\n" "@kwarg Lz: Length of ellipsoid major axis in z-direction\n" ) ) .def(self_ns::str(self)) ; } GenGeo-1.2/Python/EllipsoidVolPy.h0000644000000000000000000000151212533740504015220 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_ELLIPSOIDVOLPY_H #define GENGEO_ELLIPSOIDVOLPY_H #include #include "src/EllipsoidVol.h" void exportEllipsoidVol(); #endif GenGeo-1.2/Python/ExportModuleUtil.cc0000644000000000000000000000633712533740504015737 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include "Vector3Py.h" #include "Line2DPy.h" #include "LineSegment2DPy.h" #include "AVolume2DPy.h" #include "AVolume3DPy.h" #include "BoxWithLines2DPy.h" #include "TriWithLines2DPy.h" #include "PolygonWithLines2DPy.h" #include "BoxWithLines2DSubVolPy.h" #include "BoxWithPlanes3DPy.h" #include "BoxWithJointSetPy.h" #include "MNTable2DPy.h" #include "MNTable3DPy.h" #include "CircMNTable2DPy.h" #include "CircMNTableXY2DPy.h" #include "CircMNTable3DPy.h" #include "FullCircMNTable3DPy.h" #include "InsertGenerator2DPy.h" #include "InsertGenerator3DPy.h" #include "HexAggregateInsertGenerator2DPy.h" #include "HexAggregateInsertGenerator3DPy.h" #include "HGrainGenerator2DPy.h" #include "PlanePy.h" #include "SpherePy.h" //#include "SphereObjPy.h" #include "CylinderVolPy.h" #include "CylinderWithJointSetPy.h" #include "SphereVolPy.h" #include "SphereVolWithJointSetPy.h" #include "EllipsoidVolPy.h" #include "ClippedSphereVolPy.h" #include "SphereSectionVolPy.h" #include "DogBonePy.h" #include "TriBoxPy.h" #include "CircleVolPy.h" #include "TriPatchSetPy.h" #include "ShapePy.h" #include "ShapeListPy.h" #include "ConvexPolyhedronPy.h" #include "UnionVolPy.h" #include "IntersectionVolPy.h" #include "DifferenceVolPy.h" #include "MeshVolumePy.h" #include "MeshVolWithJointSetPy.h" #include "ClippedCircleVolPy.h" using namespace boost::python; BOOST_PYTHON_MODULE(gengeo) { exportVector3(); exportLine2D(); exportLineSegment2D(); exportAVolume(); exportAVolume2D(); exportAVolume3D(); exportBoxWithLines2D(); exportPolygonWithLines2D(); exportTriWithLines2D(); exportBoxWithLines2DSubVol(); exportMNTable2D(); exportMNTable3D(); exportCircMNTable2D(); exportCircMNTableXY2D(); exportCircMNTable3D(); exportFullCircMNTable3D(); exportAGenerator2D(); exportInsertGenerator2D(); exportAGenerator3D(); exportInsertGenerator3D(); exportHexAggregateInsertGenerator2D(); exportHexAggregateInsertGenerator3D(); exportHGrainGenerator2D(); exportPlane(); exportBoxWithPlanes3D(); exportBoxWithJointSet(); exportCylinderVol(); exportCylinderWithJointSet(); exportSphereVol(); exportSphereVolWithJointSet(); // exportSphereObj(); exportEllipsoidVol(); exportClippedSphereVol(); exportSphereSectionVol(); exportDogBone(); exportTriBox(); exportSphere(); exportCircleVol(); exportTriPatchSet(); exportShape(); exportShapeList(); exportConvexPolyhedron(); exportUnionVol(); exportIntersectionVol(); exportDifferenceVol(); exportMeshVolume(); exportMeshVolWithJointSet(); exportClippedCircleVol(); } GenGeo-1.2/Python/FullCircMNTable3DPy.cc0000644000000000000000000000561112533740504016052 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include #include #include #include "FullCircMNTable3DPy.h" using namespace std; using namespace boost::python; using boost::python::arg; void exportFullCircMNTable3D() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_ >( "FullCircMNTable3D", "A multi-group neighbours table for constructing 3D particle setups with circular boundary conditions in all three directions (X, Y and Z).", init<>() ) .def(init()) .def( init( ( boost::python::arg("minPoint"), boost::python::arg("maxPoint"), boost::python::arg("gridSize"), boost::python::arg("numGroups")=1 ), "Constructs a neighbours table with specified bounds, cell size and initial number of particle groups.\n" "@type minPoint: L{Vector3}\n" "@kwarg minPoint: lower-left-front point of the particle region\n" "@type maxPoint: L{Vector3}\n" "@kwarg maxPoint: upper-right-back point of the particle region\n" "@type gridSize: double\n" "@kwarg gridSize: the cell size for neighbour searches\n" "@type numGroups: unsigned int\n" "@kwarg numGroups: the initial number of groups (default: 1)\n" ) ) .def( "generateBonds", &FullCircMNTable3D::generateBonds, (boost::python::arg("groupID")=0, boost::python::arg("tolerance"), boost::python::arg("bondID") ), "Generates bonds between particle pairs separated by less than the specified tolerance\n" "@type groupID: int\n" "@kwarg groupID: the group ID of particles to bond together (default: 0)\n" "@type tolerance: double\n" "@kwarg tolerance: maximum distance separating bonded particles\n" "@type bondID: int\n" "@kwarg bondID: the bond ID to assign generated bonds\n" "@rtype: void\n" ) .def(self_ns::str(self)) ; } GenGeo-1.2/Python/FullCircMNTable3DPy.h0000644000000000000000000000153212533740504015712 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_FULLCIRCMNTABLE3D_H #define GENGEO_FULLCIRCMNTABLE3D_H #include #include "src/FullCircMNTable3D.h" void exportFullCircMNTable3D(); #endif GenGeo-1.2/Python/HGrainGenerator2DPy.cc0000644000000000000000000000506012533740504016160 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include #include #include "HGrainGenerator2DPy.h" using namespace boost::python; using boost::python::arg; void exportHGrainGenerator2D() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_ >( "HGrainGenerator2D", "A particle packing algorithm for filling 2D spaces with hexagonal grains.", init<>() ) .def(init()) .def( init( ( arg("radius") ), "Initialises a particle packer in preparation for filling " "L{AVolume2D} with bonded hexagonal grains of particles of a specified radius, positioned on a regular base lattice. " "Bonds within hexagonal grains are assigned bondTag=2. No bonds are generated between hexagonal grains.\n" "@type radius: double\n" "@kwarg radius: the radius of grains to pack\n" "@rtype: void\n" ) ) .def( "generatePacking", &HGrainGenerator2D::generatePacking, ( arg("volume"), arg("ntable"), arg("groupID")=0, arg("tag") ), "Generates an assembly of haxagonal grains to fill the specified volume.\n" "@type volume: L{BoxWithLines2D}\n" "@kwarg volume: the 2D volume to fill with particles\n" "@type ntable: L{MNTable2D}\n" "@kwarg ntable: the neighbours table that particles are inserted into\n" "@type groupID: int\n" "@kwarg groupID: the group ID assigned to particles (default: 0)\n" "@type tag: int\n" "@kwarg tag: the tag assigned to particles\n" "@rtype: void\n" ) .def(self_ns::str(self)) ; } GenGeo-1.2/Python/HGrainGenerator2DPy.h0000644000000000000000000000153012533740504016020 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_HGRAINGENERATOR2D_H #define GENGEO_HGRAINGENERATOR2D_H #include #include "src/HGrainGenerator.h" void exportHGrainGenerator2D(); #endif GenGeo-1.2/Python/HexAggregateInsertGenerator2DPy.cc0000644000000000000000000001036012533740504020527 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include #include #include "HexAggregateInsertGenerator2DPy.h" using namespace boost::python; using boost::python::arg; void exportHexAggregateInsertGenerator2D() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_ >( "HexAggregateInsertGenerator2D", "A particle packing algorithm for filling L{AVolume2D} spaces with hexagonal aggregates of particles", init<>() ) .def(init()) .def( init( ( arg("minRadius"), arg("maxRadius"), arg("insertFails"), arg("maxIterations"), arg("tolerance") ), "Initialises a particle packer in preparation for filling an " "L{AVolume2D} with hexagonal aggregates whose radii are in the specified range.\n" "The algorithm consists of two stages: 1) the L{AVolume2D} is packed with particles of a specified " "radius range, then 2) each particle is replaced with a Hexagonal grain of particles of equal size\n" "@type minRadius: double\n" "@kwarg minRadius: the minimum radius of particles to pack\n" "@type maxRadius: double\n" "@kwarg maxRadius: the maximum radius of particles to pack\n" "@type insertFails: int\n" "@kwarg insertFails: the number of particle insertion failures before the packer terminates\n" "@type maxIterations: int\n" "@kwarg maxIterations: the maximum number of iterations of the solver\n" "@rtype: void\n" ) ) .def(self_ns::str(self)) ; class_ >( "HexAggregateInsertGenerator2DRand", "A particle packing algorithm for filling 2D spaces with hexagonal aggregates of particles", init<>() ) .def(init()) .def( init( ( arg("minRadius"), arg("maxRadius"), arg("insertFails"), arg("maxIterations"), arg("tolerance"), arg("removeProb") ), "Initialises a particle packer in preparation for filling a\n" "2D space with hexagonal aggregates whose radii are in the specified range.\n" "The algorithm consists of three stages: \n" "1) the L{AVolume2D} is packed with particles of a specified radius range;\n" "2) each particle is replaced with a hexagonal grain of particles of equal size;\n" "3) for each hexagonal grain, one of the particles within the grain is removed with a specified probability, C{removeProb}\n" "@type minRadius: double\n" "@kwarg minRadius: the minimum radius of particles to pack\n" "@type maxRadius: double\n" "@kwarg maxRadius: the maximum radius of particles to pack\n" "@type insertFails: int\n" "@kwarg insertFails: the number of particle insertion failures before the packer terminates\n" "@type maxIterations: int\n" "@kwarg maxIterations: the maximum number of iterations of the solver\n" "@type removeProb: double\n" "@kwarg removeProb: the probability that one particle is removed from a hexagonal grain during packing\n" "@rtype: void\n" ) ) .def(self_ns::str(self)) ; } GenGeo-1.2/Python/HexAggregateInsertGenerator2DPy.h0000644000000000000000000000167512533740504020402 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_HEXAGGREGATEINSERTGENERATOR2D_H #define GENGEO_HEXAGGREGATEINSERTGENERATOR2D_H #include #include "src/HexAggregateInsertGenerator2D.h" #include "src/HexAggregateInsertGenerator2DRand.h" void exportHexAggregateInsertGenerator2D(); #endif GenGeo-1.2/Python/HexAggregateInsertGenerator3DPy.cc0000644000000000000000000001026012533740504020527 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include #include #include "HexAggregateInsertGenerator3DPy.h" using namespace boost::python; using boost::python::arg; void exportHexAggregateInsertGenerator3D() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_ >( "HexAggregateInsertGenerator3D", "A particle packing algorithm for filling L{AVolume3D} volumes with hexahedral aggregates of particles", init<>() ) .def(init()) .def( init( ( arg("minRadius"), arg("maxRadius"), arg("insertFails"), arg("maxIterations"), arg("tolerance"),arg("seed") ), "Initialises a particle packer in preparation for filling an " "L{AVolume3D} with hexahedral aggregates whose bounding sphere radii are in the specified range.\n" "The algorithm consists of two stages: \n" "1) the L{AVolume3D} is packed with particles of a specified radius range;\n" "2) each particle is replaced with a hexahedral grain of particles of equal size\n" "@type minRadius: double\n" "@kwarg minRadius: the minimum radius of particles to pack\n" "@type maxRadius: double\n" "@kwarg maxRadius: the maximum radius of particles to pack\n" "@type insertFails: int\n" "@kwarg insertFails: the number of particle insertion failures before the packer terminates\n" "@type maxIterations: int\n" "@kwarg maxIterations: the maximum number of iterations of the solver\n" "@type tolerance: double\n" "@kwarg tolerance: the overlap tolerance permitted\n" "@type seed: bool\n" "@kwarg seed: randomize the random number generator if True\n" "@rtype: void\n" ) ) .def( "generatePacking", &HexAggregateInsertGenerator3D::generatePacking3, ( arg("volume"), arg("ntable"), arg("groupID")=0 ), "Generates a particle assembly to fill the specified volume with\n" "hexahedral aggregrates whose constituent particles have the specified particle tag\n" "@type volume: L{AVolume3D}\n" "@kwarg volume: the volume to fill with particles\n" "@type ntable: L{MNTable3D}\n" "@kwarg ntable: the neighbours table that particles are inserted into\n" "@type groupID: int\n" "@kwarg groupID: the group ID assigned to particles (default: 0)\n" "@rtype: void\n" ) .def( "generatePacking", &HexAggregateInsertGenerator3D::generatePacking4, ( arg("volume"), arg("ntable"), arg("groupID")=0, arg("tag") ), "@type tag: int\n" "@kwarg tag: the tag assigned to the generated particles\n" " (optional (default: -1))\n" ) .def( "generatePackingMaxVolume", &HexAggregateInsertGenerator3D::generatePackingMaxVolume, ( arg("volume"), arg("ntable"), arg("groupID")=0, arg("tag"), arg("maxVolume") ), "Fill the specified L{AVolume3D} with particles until the accumulated particle volume exceeds the specified C{maxVolume}.\n" "@type maxVolume: float\n" "@kwarg maxVolume: the maximum cumulative volume of the inserted particles\n" ) .def(self_ns::str(self)) ; } GenGeo-1.2/Python/HexAggregateInsertGenerator3DPy.h0000644000000000000000000000161212533740504020372 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_HEXAGGREGATEINSERTGENERATOR3D_H #define GENGEO_HEXAGGREGATEINSERTGENERATOR3D_H #include #include "src/HexAggregateInsertGenerator3D.h" void exportHexAggregateInsertGenerator3D(); #endif GenGeo-1.2/Python/HexAggregateShapePy.cc0000644000000000000000000000267212533740504016275 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include "HexAggregateShapePy.h" using namespace boost::python; void exportHexAggregateShape () { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_( "HexAggregateShape", "A hexahedral aggregate shape, to be inserted into a packing via a L{ShapeList}\n", init<>() ) .def( "setBias", &HexAggregateShape::bias, ( arg("i") ), "Sets the bias of the shape (how often it should occur)\n" "@type i: int\n" "@kwarg i: the bias as any integer\n" ) ; } GenGeo-1.2/Python/HexAggregateShapePy.h0000644000000000000000000000153612533740504016135 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_HEXAGGREGATESHAPEPY_H #define GENGEO_HEXAGGREGATESHAPEPY_H #include #include "src/HexAggregateShape.h" void exportHexAggregateShape(); #endif GenGeo-1.2/Python/InsertGenerator2DPy.cc0000644000000000000000000001021012533740504016245 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include #include #include "InsertGenerator2DPy.h" using namespace boost::python; using boost::python::arg; void exportAGenerator2D() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_("AGenerator2D", "Abstract base class for 2D InsertGenerators",no_init); } void exportInsertGenerator2D() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_ >( "InsertGenerator2D", "A particle packing algorithm for filling an L{AVolume2D} space", init<>() ) .def(init()) .def( init( ( arg("minRadius"), arg("maxRadius"), arg("insertFails"), arg("maxIterations"), arg("tolerance") ), "Initialises a particle packer in preparation for filling an\n" "L{AVolume2D} with particles whose radii are in the specified range.\n" "The packing will terminate after the specified number of \n" "insertion failures. The iterative solver will compute only the\n" "specified maximum number of iterations. Particles are permitted \n" "to overlap by the specified tolerance.\n" "@type minRadius: double\n" "@kwarg minRadius: the minimum radius of particles to pack\n" "@type maxRadius: double\n" "@kwarg maxRadius: the maximum radius of particles to pack\n" "@type insertFails: int\n" "@kwarg insertFails: the number of particle insertion failures before the packer terminates\n" "@type maxIterations: int\n" "@kwarg maxIterations: the maximum number of iterations of the solver\n" "@type tolerance: double\n" "@kwarg tolerance: the overlap tolerance permitted\n" "@rtype: void\n" ) ) .def( init( ( arg("minRadius"), arg("maxRadius"), arg("insertFails"), arg("maxIterations"), arg("tolerance"),arg("seed") ), "@type seed: bool\n" "@kwarg seed: randomize the random number generator if True (optional)\n" ) ) .def( "generatePacking", &InsertGenerator2D::generatePacking, ( arg("volume"), arg("ntable"), arg("groupID")=0, arg("tag") ), "Generates a particle assembly to fill the specified area.\n" "@type volume: L{AVolume2D}\n" "@kwarg volume: the area to fill with particles\n" "@type ntable: L{MNTable2D}\n" "@kwarg ntable: the neighbours table that particles are inserted into\n" "@type groupID: int\n" "@kwarg groupID: the group ID assigned to particles (default: 0)\n" "@type tag: int\n" "@kwarg tag: the tag assigned to particles\n" "@rtype: void\n" ) .def( "setOldSeeding", &InsertGenerator2D::setOldSeeding, ( arg("old")), "Sets seeding behavior to the older method.\n" "@type old: bool\n" "@kwarg old: toggle between old and new seeding methods.\n" ) .def(self_ns::str(self)) ; } GenGeo-1.2/Python/InsertGenerator2DPy.h0000644000000000000000000000174412533740504016123 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_INSERTGENERATOR2D_H #define GENGEO_INSERTGENERATOR2D_H #include #include "util/vector3.h" #include "src/AGenerator2D.h" #include "src/InsertGenerator2D.h" #include "BoxWithLines2DPy.h" #include "MNTable2DPy.h" void exportAGenerator2D(); void exportInsertGenerator2D(); #endif GenGeo-1.2/Python/InsertGenerator3DPy.cc0000644000000000000000000001256712533740504016267 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include #include #include "InsertGenerator3DPy.h" using namespace boost::python; using boost::python::arg; void exportAGenerator3D() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_("AGenerator3D", "Abstract base class for 3D InsertGenerators", no_init); } void exportInsertGenerator3D() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_ >( "InsertGenerator3D", "A particle packing algorithm for filling L{AVolume3D} spaces.", init<>() ) .def(init()) .def( init( ( arg("minRadius"), arg("maxRadius"), arg("insertFails"), arg("maxIterations"), arg("tolerance") ), "Initialises a particle packer in preparation for filling an\n" "L{AVolume3D} with particles whose radii are in the specified range.\n" "The packing will terminate after the specified number of \n" "insertion failures. The iterative solver will compute only the\n" "specified maximum number of iterations. Particles are permitted \n" "to overlap by the specified tolerance.\n" "@type minRadius: double\n" "@kwarg minRadius: the minimum radius of particles to pack\n" "@type maxRadius: double\n" "@kwarg maxRadius: the maximum radius of particles to pack\n" "@type insertFails: int\n" "@kwarg insertFails: the number of particle insertion failures before the packer terminates\n" "@type maxIterations: int\n" "@kwarg maxIterations: the maximum number of iterations of the solver\n" "@type tolerance: double\n" "@kwarg tolerance: the overlap tolerance permitted\n" "@rtype: void\n" ) ) .def( init( ( arg("minRadius"), arg("maxRadius"), arg("insertFails"), arg("maxIterations"), arg("tolerance"),arg("seed") ), "@type seed: bool\n" "@kwarg seed: randomize the random number generator if True (optional)\n" ) ) .def( "generatePacking", &InsertGenerator3D::generatePacking3, ( arg("volume"), arg("ntable"), arg("groupID")=0 ), "Generates a particle assembly to fill the specified volume.\n" "@type volume: L{AVolume3D}\n" "@kwarg volume: the volume to fill with particles\n" "@type ntable: L{MNTable3D}\n" "@kwarg ntable: the neighbours table that particles are inserted into\n" "@type groupID: int\n" "@kwarg groupID: the group ID assigned to particles (default: 0)\n" "@rtype: void\n" ) .def( "generatePacking", &InsertGenerator3D::generatePacking4, ( arg("volume"), arg("ntable"), arg("groupID")=0, arg("tag") ), "@type tag: int\n" "@kwarg tag: the tag assigned to the generated particles\n" " (optional (default: -1) if not followed by C{ShapeList})\n" ) .def( "generatePacking", &InsertGenerator3D::generatePacking, ( arg("volume"), arg("ntable"), arg("groupID")=0 , arg("tag"), arg("shapeList") ), "@type shapeList: L{ShapeList}\n" "@kwarg shapeList: the list of shapes to be inserted (optional)\n" ) .def( "generatePackingMaxVolume", &InsertGenerator3D::generatePackingMaxVolume, ( arg("volume"), arg("ntable"), arg("groupID")=0, arg("tag"), arg("maxVolume") ), "Fills the specified L{AVolume3D} with particles until the accumulated particle volume exceeds the specified C{maxVolume}.\n" "@type maxVolume: float\n" "@kwarg maxVolume: the maximum cumulative volume of the inserted particles\n" ) .def( "setNextTag", &InsertGenerator3D::setNextTag, ( arg("tag") ), "Sets tag for the next particles generated\n" "@type tag: int\n" "@kwarg tag: tag to assign the next particles generated by the L{InsertGenerator3D}\n" ) .def( "setOldSeeding", &InsertGenerator3D::setOldSeeding, ( arg("old")), "Sets seeding behavior to older method.\n" "@type old: bool\n" "@kwarg old: toggle between old and new seeding methods.\n" ) .def(self_ns::str(self)) ; } GenGeo-1.2/Python/InsertGenerator3DPy.h0000644000000000000000000000175412533740504016125 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_INSERTGENERATOR3D_H #define GENGEO_INSERTGENERATOR3D_H #include #include #include "util/vector3.h" #include "src/AGenerator3D.h" #include "src/InsertGenerator3D.h" #include "MNTable3DPy.h" void exportAGenerator3D(); void exportInsertGenerator3D(); #endif GenGeo-1.2/Python/IntersectionVolPy.cc0000644000000000000000000000333712533740504016107 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include "IntersectionVolPy.h" using namespace boost::python; void exportIntersectionVol() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_ >( "IntersectionVol", "A class defining a volume consisting of the intersection of two volumes in 3D.", init<>() ) .def(init()) .def( init( ( arg("volume1"), arg("volume2") ), "Constructs a volume comprised of the intersection of two volumes.\n" "@type volume1: L{AVolume3D}\n" "@kwarg volume1: The first volume comprising the intersection\n" "@type volume2: L{AVolume3D}\n" "@kwarg volume2: The second volume comprising the intersection\n" ) ) .def(self_ns::str(self)) ; } GenGeo-1.2/Python/IntersectionVolPy.h0000644000000000000000000000152012533740504015741 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_INTERSECTVOLPY_H #define GENGEO_INTERSECTVOLPY_H #include #include "src/IntersectionVol.h" void exportIntersectionVol(); #endif GenGeo-1.2/Python/Line2DPy.cc0000644000000000000000000000517312533740504014035 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include "Line2DPy.h" using namespace boost::python; using boost::python::arg; void exportLine2D() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_( "Line2D", "A class defining a line in 2D space.", init<>() ) .def(init()) .def( init( ( arg("startPoint"), arg("endPoint") ), "Constructs a line in 2D space with specified endpoints.\n" "N.B. This is not an L{AVolume2D} so cannot be used with C{InsertGenerators}.\n" "@type startPoint: L{Vector3}\n" "@kwarg startPoint: location of starting point of the line\n" "@type endPoint: L{Vector3}\n" "@kwarg endPoint: location of end point of the line\n" ) ) .def( "intersect", &Line2D::intersect, ( arg("line") ), "Returns the point of intersection of this line with\n" "the specified line.\n" "@type line: L{Line2D}\n" "@kwarg line: the intersecting line\n" "@rtype: L{Vector3}\n" ) .def( "parallel", &Line2D::parallel, ( arg("distance") ), "Returns a line parallel to this one, separated by\n" "the specified distance.\n" "@type distance: double\n" "@kwarg distance: the distance to the parallel line to construct\n" "@rtype: L{Line2D}\n" ) .def( "getOrig", &Line2D::getOrig, "Returns the origin point of this line.\n" "@rtype: L{Vector3}\n" ) .def( "getNormal", &Line2D::getNormal, "Returns the normal vector to this line.\n" "@rtype: L{Vector3}\n" ) .def(self_ns::str(self)) ; } GenGeo-1.2/Python/Line2DPy.h0000644000000000000000000000146712533740504013701 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_LINE2DPY_H #define GENGEO_LINE2DPY_H #include #include "geometry/Line2D.h" void exportLine2D(); #endif GenGeo-1.2/Python/LineSegment2DPy.cc0000644000000000000000000000335512533740504015360 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include "LineSegment2DPy.h" using namespace boost::python; using boost::python::arg; void exportLineSegment2D() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_ >( "LineSegment2D", "A class defining a line segment in 2 dimensions.", init<>() ) .def(init()) .def( init( ( arg("startPoint"), arg("endPoint") ), "Constructs a line with specified endpoints.\n" "N.B. This is not an L{AVolume2D} so cannot be used with C{InsertGenerators}.\n" "@type startPoint: L{Vector3}\n" "@kwarg startPoint: the starting point of the line\n" "@type endPoint: L{Vector3}\n" "@kwarg endPoint: the end point of the line\n" ) ) .def(self_ns::str(self)) ; } GenGeo-1.2/Python/LineSegment2DPy.h0000644000000000000000000000152312533740504015215 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_LINESEGMENT2DPY_H #define GENGEO_LINESEGMENT2DPY_H #include #include "geometry/LineSegment2D.h" void exportLineSegment2D(); #endif GenGeo-1.2/Python/MNTable2DPy.cc0000644000000000000000000004126112533740504014426 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include #include #include #include "MNTable2DPy.h" using namespace std; using namespace boost::python; using boost::python::arg; void exportMNTable2D() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_( "MNTable2D", "A multi-group neighbour table for constructing 2D particle assemblies", init<>() ) .def(init()) .def( init( ( boost::python::arg("minPoint"), boost::python::arg("maxPoint"), boost::python::arg("gridSize"), boost::python::arg("numGroups")=1 ), "Constructs a neighbour table with specified bounds, cell size and initial number of particle groups.\n" "@type minPoint: L{Vector3}\n" "@kwarg minPoint: lower-left point of the particle region\n" "@type maxPoint: L{Vector3}\n" "@kwarg maxPoint: upper-right point of the particle region\n" "@type gridSize: double\n" "@kwarg gridSize: the cell size for neighbour searches\n" "@type numGroups: unsigned int\n" "@kwarg numGroups: the initial number of groups (default: 1)\n" ) ) .def( "tagParticlesAlongLine", &MNTable2D::tagParticlesAlongLine, ( boost::python::arg("line"), boost::python::arg("distance"), boost::python::arg("tag"), boost::python::arg("groupID")=0 ), "Assigns the specified tag to all particles from group C{groupID}\n" "that lie within the specified distance of the given line.\n" "@type line: L{Line2D}\n" "@kwarg line: the line along which to tag particles\n" "@type distance: double\n" "@kwarg distance: the maximum distance between tagged particles and the line\n" "@type tag: int\n" "@kwarg tag: the tag to assign particles\n" "@type groupID: unsigned int\n" "@kwarg groupID: the group ID of particles to tag (default: 0)\n" "@rtype: void\n" ) .def( "tagParticlesAlongLineWithMask", &MNTable2D::tagParticlesAlongLineWithMask, ( boost::python::arg("line"), boost::python::arg("distance"), boost::python::arg("tag"), boost::python::arg("mask"), boost::python::arg("groupID")=0 ), "Assigns the specified tag to all particles from group C{groupID}\n" "that lie within the specified distance of the given line.\n" "@type line: L{Line2D}\n" "@kwarg line: the line along which to tag particles\n" "@type distance: double\n" "@kwarg distance: the maximum distance between tagged particles and the line\n" "@type tag: int\n" "@kwarg tag: the tag to assign particles\n" "@type mask: int\n" "@kwarg mask: the mask - determines which bits of the tag are influenced \n" "@type groupID: unsigned int\n" "@kwarg groupID: the group ID of particles to tag (default: 0)\n" "@rtype: void\n" ) .def( "tagParticlesAlongLineSegment", &MNTable2D::tagParticlesAlongLineSegment, ( boost::python::arg("linesegment"), boost::python::arg("distance"), boost::python::arg("tag"), boost::python::arg("mask"), boost::python::arg("groupID")=0 ), "Assigns the specified tag to all particles from group C{groupID}\n" "that lie within the specified distance of the given line segment.\n" "@type line: L{Line2D}\n" "@kwarg line: the line along which to tag particles\n" "@type distance: double\n" "@kwarg distance: the maximum distance between tagged particles and the line\n" "@type tag: int\n" "@kwarg tag: the tag to assign particles\n" "@type mask: int\n" "@kwarg mask: the mask - determines which bits of the tag are influenced \n" "@type groupID: unsigned int\n" "@kwarg groupID: the group ID of particles to tag (default: 0)\n" "@rtype: void\n" ) .def( "tagParticlesNear", &MNTable2D::tagParticlesNear, ( boost::python::arg("point"), boost::python::arg("distance"), boost::python::arg("tag"), boost::python::arg("groupID")=0 ), "Assigns the specified tag to all particles from group C{groupID}\n" "that lie within the specified distance of the given point.\n" "@type point: L{Vector3}\n" "@kwarg point: the point around which to tag particles\n" "@type distance: double\n" "@kwarg distance: the maximum distance between tagged particles and the specified point\n" "@type tag: int\n" "@kwarg tag: the tag to assign particles\n" "@type groupID: unsigned int\n" "@kwarg groupID: the group ID of particles to tag (default: 0)\n" "@rtype: void\n" ) .def( "tagClosestParticle", &MNTable2D::tagClosestParticle, ( boost::python::arg("point"), boost::python::arg("tag"), boost::python::arg("groupID")=0 ), "Assigns the specified tag to the particle which is closest to the given point.\n" "@type point: L{Vector3}\n" "@kwarg point: the point closest to the particle to be tagged\n" "@type tag: int\n" "@kwarg tag: the tag to assign closest particle\n" "@type groupID: unsigned int\n" "@kwarg groupID: the group ID of particle to tag (default: 0)\n" "@rtype: void\n" ) .def( "breakBondsAlongLineSegment", &MNTable2D::breakBondsAlongLineSegment, ( boost::python::arg("lineSegment"), boost::python::arg("distance"), boost::python::arg("tag"), boost::python::arg("groupID")=0 ), "Breaks bonds within the specified distance of the given line segment.\n" "Only bonds with the specified tag connecting particles in the\n" "specified group will be broken.\n" "@type lineSegment: L{LineSegment2D}\n" "@kwarg lineSegment: the line segment along which to break bonds\n" "@type distance: double\n" "@kwarg distance: the maximum distance between bonds and the line segment\n" "@type tag: int\n" "@kwarg tag: the bond tag of bonds to break\n" "@type groupID: unsigned int\n" "@kwarg groupID: the group ID of particles whose bonds are broken (default: 0)\n" "@rtype: void\n" ) .def( "generateBonds", &MNTable2D::generateBonds, (boost::python::arg("groupID")=0, boost::python::arg("tolerance"), boost::python::arg("bondID") ), "Generates bonds between particle pairs separated by less than the specified tolerance\n" "@type groupID: int\n" "@kwarg groupID: the group ID of particles to bond together (default: 0)\n" "@type tolerance: double\n" "@kwarg tolerance: maximum distance separating bonded particles\n" "@type bondID: int\n" "@kwarg bondID: the bond ID to assign generated bonds\n" "@rtype: void\n" ) .def( "generateBondsWithMask", &MNTable2D::generateBondsWithMask, (boost::python::arg("groupID")=0, boost::python::arg("tolerance"), boost::python::arg("bondID"), boost::python::arg("tag"), boost::python::arg("mask") ), "Generates bonds between particle pairs separated by less than the specified tolerance.\n" "A tag mask is used to select groups of particles to tag.\n" "@type groupID: int\n" "@kwarg groupID: the group ID of particles to bond together (default: 0)\n" "@type tolerance: double\n" "@kwarg tolerance: maximum distance separating bonded particles\n" "@type bondID: int\n" "@kwarg bondID: the bond ID to assign generated bonds\n" "@type tag: int\n" "@kwarg tag: the tag of particles to bond\n" "@type mask: int\n" "@kwarg mask: the bond mask\n" "@rtype: void\n" ) .def( "generateBondsTaggedMasked", &MNTable2D::generateBondsTaggedMasked, (boost::python::arg("groupID")=0, boost::python::arg("tolerance"), boost::python::arg("bondID"), boost::python::arg("tag1"), boost::python::arg("mask1"), boost::python::arg("tag2"), boost::python::arg("mask2") ), "Generates bonds between particle pairs separated by less than the specified tolerance.\n" "A tag mask is used to select groups of particles to tag.\n" "@type groupID: int\n" "@kwarg groupID: the group ID of particles to bond together (default: 0)\n" "@type tolerance: double\n" "@kwarg tolerance: maximum distance separating bonded particles\n" "@type bondID: int\n" "@kwarg bondID: the bond ID to assign generated bonds\n" "@type tag1: int\n" "@kwarg tag1: the 1st particle tag\n" "@type mask1: int\n" "@kwarg mask1: the mask for the 1st particle tag\n" "@type tag2: int\n" "@kwarg tag2: the 2nd particle tag\n" "@type mask2: int\n" "@kwarg mask2: the mask for the 2nd particle tag\n" "@rtype: void\n" ) .def( "generateRandomBonds", &MNTable2D::generateRandomBonds, (boost::python::arg("groupID"), boost::python::arg("tolerance"), boost::python::arg("probability"), boost::python::arg("bondID"), boost::python::arg("tag"), boost::python::arg("mask") ), "Generates bonds between particle pairs separated by less than the specified tolerance.\n" "Bonds are generated between particle pairs with the prescribed probability.\n" "@type groupID: int\n" "@kwarg groupID: the group ID of particles to bond together (default: 0)\n" "@type tolerance: double\n" "@kwarg tolerance: maximum distance separating bonded particles\n" "@type probability: double\n" "@kwarg probability: probability that a particle-pair is bonded (0.0 < probability < 1.0)\n" "@type bondID: int\n" "@kwarg bondID: the bond ID to assign generated bonds\n" "@type tag: int\n" "@kwarg tag: the tag of particles to bond\n" "@type mask: int\n" "@kwarg mask: the bond mask\n" "@rtype: void\n" ) .def( "generateClusterBonds", &MNTable2D::generateClusterBonds, (boost::python::arg("groupID")=0, boost::python::arg("tolerance"), boost::python::arg("bondTag1"), boost::python::arg("bondTag2")), "Generates bonds between particle pairs separated by less than the specified tolerance.\n" "Bonds generated between particles having the same particle tag are given tag C{bondTag1}\n" "and bonds generated between particles of differing tags are given tag C{bondTag2}\n" "@type groupID: int\n" "@kwarg groupID: the group ID of particles to bond together (default: 0)\n" "@type tolerance: double\n" "@kwarg tolerance: maximum distance separating bonded particles\n" "@type bondTag1: int\n" "@kwarg bondTag1: the bond tag for bonds between particles with the same particle tag\n" "@type bondTag2: int\n" "@kwarg bondTag2: the bond tag for bonds between particles with differing particle tags\n" ) .def( "getSumVolume", &MNTable2D::getSumVolume, ( boost::python::arg("groupID")=0 ), "Returns the sum of the particle areas in the specified group.\n" "@type groupID: int\n" "@kwarg groupID: the group ID of particles whose areas are summed (default: 0).\n" "@rtype: double\n" ) .def( "getNumParticles", &MNTable2D::getNrParticles, ( boost::python::arg("groupID")=0 ), "Returns the number of the particles in the specified group.\n" "@type groupID: int\n" "@kwarg groupID: the group ID of the particles to count (default: 0).\n" "@rtype: int\n" ) .def( "setOutputPrecision", &MNTable2D::SetOutputPrecision, ( boost::python::arg("precision")), "Set the number of significant digits for file output\n" "@type precision: int\n" "@kwarg precision: the number of significant digits (default: 10).\n" ) .def( "write", &MNTable2D::write, ( boost::python::arg("fileName"), boost::python::arg("outputStyle") ), "Writes the particle assembly and bonding information to the specified\n" "file using the specified output style (0: debug; 1: geo; 2: vtk)\n" "@type fileName: string\n" "@kwarg fileName: the name of the file to write\n" "@type outputStyle: int\n" "@kwarg outputStyle: output style (0: debug; 1: geo; 2: vtk)\n" "@rtype: void\n" ) .def( "tagParticlesToClosest", &MNTable2D::tagParticlesToClosest, ( boost::python::arg("groupID1")=0, boost::python::arg("groupID2") ), "Tags particles in C{groupID1} closest to spheres in C{groupID2}\n" "@type groupID1: int\n" "@kwarg groupID1: the group ID of particles to tag (default: 0).\n" "@type groupID2: int\n" "@kwarg groupID2: the group ID of closest spheres.\n" ) .def( "tagParticlesInVolume", &MNTable2D::tagParticlesInVolume, ( boost::python::arg("volume"), boost::python::arg("tag"), boost::python::arg("groupID")=0 ), "Assigns the specified tag to all particles from group C{groupID}\n" "that lie within the specified volume.\n" "@type volume: L{AVolume}\n" "@kwarg volume: the volume within which to tag particles\n" "@type tag: int\n" "@kwarg tag: the tag to assign particles\n" "@type groupID: unsigned int\n" "@kwarg groupID: the group ID of particles to tag (default: 0)\n" "@rtype: void\n" ) .def( "insert", &MNTable2D::insert, ( boost::python::arg("sphere"), boost::python::arg("groupID")=0 ), "Inserts sphere\n" "@type sphere: L{Sphere}\n" "@kwarg sphere: the sphere to insert\n" "@type groupID: int\n" "@kwarg groupID: the group ID of the inserted sphere (default: 0).\n" ) .def( "insertBond", &MNTable2D::insertBond, ( boost::python::arg("Id1"), boost::python::arg("Id2"), boost::python::arg("tag") ), "Inserts bond between particles with the specified particle IDs\n" "@type Id1: int\n" "@kwarg Id1: ID of first particle to bond\n" "@type Id2: int\n" "@kwarg Id2: ID of second particle to bond\n" "@type tag: int\n" "@kwarg tag: the bond tag to assign to the generated bond\n" ) .def( "removeTaggedParticles", &MNTable2D::removeTagged, (boost::python::arg("groupID")=0,boost::python::arg("tag"),boost::python::arg("mask")), "Removes particles with given tag and mask\n" "@type groupID: int\n" "@kwarg groupID: the group ID of particles to remove (default: 0).\n" "@type tag: int\n" "@kwarg tag: the tag of particles to remove.\n" "@type mask: int\n" "@kwarg mask: the tag mask of particles to remove.\n" ) .def( "GrowNGroups", &MNTable2D::GrowNGroups, ( boost::python::arg("numGroups") ), "Expands the neighbour table to permit the specified number of particle groups\n" "@type numGroups: int\n" "@kwarg numGroups: number of groups to create\n" "@rtype: void\n" ) .def( "getSphereListFromGroup", &MNTable2D::getSphereListFromGroup, ( boost::python::arg("groupID")=0 ), "Returns a python list of L{Sphere} objects with the specified group ID\n" "@type groupID: int\n" "@kwarg groupID: the group ID of spheres to return as a list (default: 0)\n" "@rtype: boost::python::list\n" ) .def( "getBondList", &MNTable2D::getBondList, ( boost::python::arg("groupID")=0 ), "Returns a python list of bonds with the specified group ID as int-int pairs \n" "@type groupID: int\n" "@kwarg groupID: the bond tag\n" "@rtype: boost::python::list\n" ) .def(self_ns::str(self)) ; } GenGeo-1.2/Python/MNTable2DPy.h0000644000000000000000000000156112533740504014267 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_MNTABLE2D_H #define GENGEO_MNTABLE2D_H #include #include "util/vector3.h" #include "geometry/Line2D.h" #include "src/MNTable2D.h" void exportMNTable2D(); #endif GenGeo-1.2/Python/MNTable3DPy.cc0000644000000000000000000005030712533740504014430 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include #include #include #include "MNTable3DPy.h" using namespace std; using namespace boost::python; using boost::python::arg; void exportMNTable3D() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_( "MNTable3D", "A multi-group neighbour table for constructing 3D particle assemblies", init<>() ) .def(init()) .def( init( ( boost::python::arg("minPoint"), boost::python::arg("maxPoint"), boost::python::arg("gridSize"), boost::python::arg("numGroups")=1 ), "Constructs a neighbour table with specified bounds, cell size and initial number of particle groups.\n" "@type minPoint: L{Vector3}\n" "@kwarg minPoint: front-lower-left point of the particle region\n" "@type maxPoint: L{Vector3}\n" "@kwarg maxPoint: back-upper-right point of the particle region\n" "@type gridSize: double\n" "@kwarg gridSize: the cell size for neighbour searches\n" "@type numGroups: unsigned int\n" "@kwarg numGroups: the initial number of groups (default: 1)\n" ) ) .def( "insertFromRawFile", &MNTable3D::insertFromRawFile, ( boost::python::arg("fileName"), boost::python::arg("scale"), boost::python::arg("tolerance") ), "Reads in an existing geometry from a file in a raw ASCII format\n" "@type fileName: string\n" "@kwarg fileName: the name of the raw ASCII geometry file to read\n" "@type scale: double\n" "@kwarg scale: a scaling factor to apply to coordinates and radius\n" "@type tolerance: double\n" "@kwarg tolerance: the tolerance for determining whether particles collide\n" ) .def( "tagParticlesInSphere", &MNTable3D::tagParticlesInSphere, ( boost::python::arg("sphere"), boost::python::arg("tag"), boost::python::arg("groupID")=0 ), "Assigns the specified tag to all particles from group C{groupID} " "that lie within the given L{Sphere}.\n" "@type sphere: L{Sphere}\n" "@kwarg sphere: the sphere within which to tag particles\n" "@type tag: int\n" "@kwarg tag: the tag to assign particles\n" "@type groupID: unsigned int\n" "@kwarg groupID: the group ID of particles to tag (default: 0)\n" "@rtype: void\n" ) .def( "tagParticlesAlongPlane", &MNTable3D::tagParticlesAlongPlane, ( boost::python::arg("plane"), boost::python::arg("distance"), boost::python::arg("tag"), boost::python::arg("groupID")=0 ), "Assigns the specified tag to all particles from group C{groupID} " "that lie within the specified distance of the given L{Plane}.\n" "@type plane: L{Plane}\n" "@kwarg plane: the plane along which to tag particles\n" "@type distance: double\n" "@kwarg distance: the maximum distance between tagged particles and the plane\n" "@type tag: int\n" "@kwarg tag: the tag to assign particles\n" "@type groupID: unsigned int\n" "@kwarg groupID: the group ID of particles to tag (default: 0)\n" "@rtype: void\n" ) .def( "tagParticlesInVolume", &MNTable3D::tagParticlesInVolume, ( boost::python::arg("volume"), boost::python::arg("tag"), boost::python::arg("groupID")=0 ), "Assigns the specified tag to all particles within the specified L{AVolume3D} from group C{groupID}\n" "that lie within the specified volume.\n" "@type volume: L{AVolume3D}\n" "@kwarg volume: the volume within which to tag particles\n" "@type tag: int\n" "@kwarg tag: the tag to assign particles\n" "@type groupID: unsigned int\n" "@kwarg groupID: the group ID of particles to tag (default: 0)\n" "@rtype: void\n" ) .def( "tagParticlesAlongPlaneWithMask", &MNTable3D::tagParticlesAlongPlaneWithMask, ( boost::python::arg("plane"), boost::python::arg("distance"), boost::python::arg("tag"),boost::python::arg("mask"), boost::python::arg("groupID")=0 ), "Assigns the specified tag to all particles from group C{groupID} " "that lie within the specified distance of a given L{Plane}." " Use of tag masks is permitted.\n" "@type plane: L{Plane}\n" "@kwarg plane: the plane along which to tag particles\n" "@type distance: double\n" "@kwarg distance: the maximum distance between tagged particles and the plane\n" "@type tag: int\n" "@kwarg tag: the tag to assign particles\n" "@type mask: int\n" "@kwarg mask: the mask determining which bits of the tag are used\n" "@type groupID: unsigned int\n" "@kwarg groupID: the group ID of particles to tag (default: 0)\n" "@rtype: void\n" ) .def( "tagParticlesAlongJoints", &MNTable3D::tagParticlesAlongJoints, ( boost::python::arg("jointset"), boost::python::arg("distance"), boost::python::arg("tag"),boost::python::arg("mask"), boost::python::arg("groupID")=0 ), "Assigns the specified tag to all particles from group C{groupID} " "that lie within the specified distance of a given L{TriPatchSet}\n" "@type joints: L{TriPatchSet}\n" "@kwarg joints: the set of triangular patches along which to tag particles\n" "@type distance: double\n" "@kwarg distance: the maximum distance between tagged particles and the triangles in the L{TriPatchSet}\n" "@type tag: int\n" "@kwarg tag: the tag to assign particles\n" "@type mask: int\n" "@kwarg mask: the mask determining which bits of the tag are used\n" "@type groupID: unsigned int\n" "@kwarg groupID: the group ID of particles to tag (default: 0)\n" "@rtype: void\n" ) .def( "removeParticlesWithTag", &MNTable3D::removeParticlesWithTag, ( boost::python::arg("tag"), boost::python::arg("groupID")=0 ), "Removes all particles with the specified tag from a given group\n" "@type tag: int\n" "@kwarg tag: the tag of particles to remove\n" "@type groupID: unsigned int\n" "@kwarg groupID: the group ID of particles to remove (default: 0)\n" "@rtype: void\n" ) .def( "removeTaggedParticles", &MNTable3D::removeParticlesWithTagMask, (boost::python::arg("groupID")=0, boost::python::arg("tag"), boost::python::arg("mask")), "Removes all particles with a specified tag from a given group\n" "@type groupID: unsigned int\n" "@kwarg groupID: the group ID of particles to remove (default: 0)\n" "@type tag: int\n" "@kwarg tag: the tag of particles to remove\n" "@type mask: int\n" "@kwarg mask: the mask determining which bits of the tag are used\n" "@rtype: void\n" ) .def( "removeParticlesInVolume", &MNTable3D::removeParticlesInVolume, (boost::python::arg("volume"), boost::python::arg("groupID")=0, boost::python::arg("full")), "Removes all particles inside the specified L{AVolume3D}\n" "@type volume: L{AVolume3D}\n" "@kwarg volume: the volume within which to remove particles\n" "@type groupID: unsigned int\n" "@kwarg groupID: the group ID of particles to remove (default: 0)\n" "@type full: bool\n" "@kwarg full: remove particles fully inside volume or only with centres inside the volume\n" ) .def( "removeParticlesInGroup", &MNTable3D::removeParticlesInGroup, ( boost::python::arg("groupID") ), "Removes all particles from a given group\n" "@type groupID: unsigned int\n" "@kwarg groupID: the group ID of particles to remove \n" "@rtype: void\n" ) .def( "renumberParticlesContinuous", &MNTable3D::renumberParticlesContinuous, "Changes all particle IDs so that they are continuous " "i.e. 0,1,..,Np-1\n" ) .def( "generateBonds", &MNTable3D::generateBonds, (boost::python::arg("groupID")=0, boost::python::arg("tolerance"), boost::python::arg("bondID") ), "Generates bonds between particle pairs separated by less than the specified tolerance\n" "@type groupID: int\n" "@kwarg groupID: the group ID of particles to bond together (default: 0)\n" "@type tolerance: double\n" "@kwarg tolerance: maximum distance separating bonded particles\n" "@type bondID: int\n" "@kwarg bondID: the bond ID to assign generated bonds\n" "@rtype: void\n" ) .def( "generateBondsTagged", &MNTable3D::generateBondsTagged, (boost::python::arg("groupID")=0, boost::python::arg("tolerance"), boost::python::arg("bondID"), boost::python::arg("particleTag1"), boost::python::arg("particleTag2") ), "Generates bonds between particle pairs with the two specified tags.\n" "@type groupID: int\n" "@kwarg groupID: the group ID of particles to bond together (default: 0)\n" "@type tolerance: double\n" "@kwarg tolerance: maximum distance separating bonded particles\n" "@type bondID: int\n" "@kwarg bondID: the bond ID to assign generated bonds\n" "@type particleTag1: int\n" "@kwarg particleTag1: the first tag of particles to bond\n" "@type particleTag2: int\n" "@kwarg particleTag2: the second tag of particles to bond\n" "@rtype: void\n" ) .def( "generateRandomBonds", &MNTable3D::generateRandomBonds, (boost::python::arg("groupID")=0, boost::python::arg("tolerance"), boost::python::arg("probability"), boost::python::arg("bondID"), boost::python::arg("particleTag"), boost::python::arg("tagMask") ), "Generates bonds between particle pairs. Bonds will be created with a specified probability <= 1\n" "@type groupID: int\n" "@kwarg groupID: the group ID of particles to bond together (default: 0)\n" "@type tolerance: double\n" "@kwarg tolerance: maximum distance separating bonded particles\n" "@type probability: double\n" "@kwarg probability: the probability that a bond will be generated (0 < probability <= 1)\n" "@type bondID: int\n" "@kwarg bondID: the bond ID to assign generated bonds\n" "@type particleTag: int\n" "@kwarg particleTag: the tag of particles to bond\n" "@type tagMask: int\n" "@kwarg tagMask: the mask determining which bits of the tag are used\n" "@rtype: void\n" ) .def( "generateBondsWithJointSet", &MNTable3D::generateBondsWithJointSet, (boost::python::arg("JointSet"), boost::python::arg("groupID")=0, boost::python::arg("tolerance"), boost::python::arg("bondTag") ), "Generates bonds between particle pairs, checking whether the bond crosses a specified L{TriPatchSet} representing joints.\n" "A bond that crosses a triangle will be assigned a bondTag equal to the tag of the triangle.\n" "A bond that does not cross any triangle will be assigned a bondTag equal to the supplied bondTag.\n" "@type JointSet: L{TriPatchSet}\n" "@kwarg JointSet: Set of triangles to check for crossing bonds\n" "@type groupID: int\n" "@kwarg groupID: the group ID of particles to bond together (default: 0)\n" "@type tolerance: double\n" "@kwarg tolerance: maximum distance separating bonded particles\n" "@type bondTag: int\n" "@kwarg bondTag: the bond tag to assign to bonds that do not cross a joint (DO NOT set this equal to the tag of any triangle contained in the joint set).\n" "@rtype: void\n" ) .def( "generateClusterBonds", &MNTable3D::generateClusterBonds, (boost::python::arg("groupID")=0, boost::python::arg("tolerance"), boost::python::arg("bondTag1"), boost::python::arg("bondTag2")), "Generates bonds with different tags depending on whether the particle tags are the same or different.\n" "@type groupID: int\n" "@kwarg groupID: the group ID of particles to bond together (default: 0)\n" "@type tolerance: double\n" "@kwarg tolerance: maximum distance separating bonded particles\n" "@type bondTag1: int\n" "@kwarg bondTag1: the bond tag to assign for bonds joining particles of the same tag\n" "@type bondTag2: int\n" "@kwarg bondTag2: the bond tag to assign for bonds joining particles of differing tag\n" ) .def( "getSumVolume", &MNTable3D::getSumVolume, ( boost::python::arg("groupID")=0 ), "Returns the sum of the particle volumes in the specified group.\n" "@type groupID: int\n" "@kwarg groupID: the group ID of particles whose volumes are summed (default: 0).\n" "@rtype: double\n" ) .def( "getSphereListFromGroup", &MNTable3D::getSphereListFromGroup, ( boost::python::arg("groupID")=0 ), "Returns a python list of L{Sphere} objects with the specified group ID\n" "@type groupID: int\n" "@kwarg groupID: the group ID of spheres to return as a list (default: 0)\n" "@rtype: boost::python::list\n" ) .def( "getSphereListDist", &MNTable3D::getSphereListDist, ( boost::python::arg("posn"),boost::python::arg("dist"),boost::python::arg("groupID")=0 ), "Returns a python list of L{Sphere} objects within a defined distance \n" "of the specified point\n" "@type posn: L{Vector3}\n" "@kwarg posn: the location of the point\n" "@type dist: double\n" "@kwarg dist: the distance from the point to particles that will be returned\n" "@type groupID: int\n" "@kwarg groupID: the group ID of spheres to return as a list (default: 0)\n" "@rtype: boost::python::list\n" ) .def( "GrowNGroups", &MNTable3D::GrowNGroups, ( boost::python::arg("numGroups") ), "Expands the neighbour table to permit the specified number of particle groups\n" "@type numGroups: int\n" "@kwarg numGroups: number of groups to create\n" "@rtype: void\n" ) .def( "write", &MNTable3D::write, ( boost::python::arg("fileName"), boost::python::arg("outputStyle") ), "Writes the particle assembly and bonding information to the specified\n" "file using the specified output style (0: debug; 1: geo; 2: vtk)\n" "@type fileName: string\n" "@kwarg fileName: the name of the file to write\n" "@type outputStyle: int\n" "@kwarg outputStyle: output style (0: debug; 1: geo; 2: vtk)\n" "@rtype: void\n" ) .def( "tagParticlesInGroup", &MNTable3D::tagParticlesInGroupNT, (boost::python::arg("groupID")=0, boost::python::arg("tag") ), "Tag all particles with the specified C{groupID}\n" "@type groupID: int\n" "@kwarg groupID: the group ID of particles to tag (default: 0)\n" "@type tag: int\n" "@kwarg tag: the tag to be assigned to the selected particles\n" ) .def( "tagParticlesInGroup", &MNTable3D::tagParticlesInGroup, (boost::python::arg("groupID")=0, boost::python::arg("tag"), boost::python::arg("mask") ), "@type mask: int\n" "@kwarg mask: only the bits which are 1 in the mask are actually\n" " changed in the tag (optional)\n" "@rtype: void\n" ) .def( "tagParticlesToClosest", &MNTable3D::tagParticlesToClosest, ( boost::python::arg("groupID1")=0, boost::python::arg("groupID2") ), "Tags particles in C{groupID1} closest to spheres in C{groupID2}.\n" "The particle ID of C{groupID2} specifies the tag assigned to nearest particles in C{groupID1}.\n" "@type groupID1: int\n" "@kwarg groupID1: the group ID of particles to tag (default: 0).\n" "@type groupID2: int\n" "@kwarg groupID2: the group ID of closest spheres.\n" ) .def( "tagParticlesToClosestAnisotropic", &MNTable3D::tagParticlesToClosestAnisotropic, ( boost::python::arg("groupID1")=0, boost::python::arg("groupID2"), boost::python::arg("wx"), boost::python::arg("wy"), boost::python::arg("wz") ), "Tags particles in C{groupID1} closest to spheres in C{groupID2} using distance weighting factors for aniostropic particle cluster shapes.\n" "The particle ID of C{groupID2} specifies the tag assigned to nearest particles in C{groupID1}.\n" "@type groupID1: int\n" "@kwarg groupID1: the group ID of particles to tag (default: 0).\n" "@type groupID2: int\n" "@kwarg groupID2: the group ID of closest spheres.\n" "@type wx: double\n" "@kwarg wx: the weighting of the x-component of the distance.\n" "@type wy: double\n" "@kwarg wy: the weighting of the y-component of the distance.\n" "@type wz: double\n" "@kwarg wz: the weighting of the z-component of the distance.\n" ) .def( "insert", &MNTable3D::insert, ( boost::python::arg("sphere"), boost::python::arg("groupID")=0 ), "Inserts sphere\n" "@type sphere: L{Sphere}\n" "@kwarg sphere: the sphere to insert\n" "@type groupID: int\n" "@kwarg groupID: the group ID of the inserted sphere (default: 0).\n" ) .def( "insertBond", &MNTable3D::insertBond, ( boost::python::arg("Id1"), boost::python::arg("Id2"), boost::python::arg("tag") ), "Inserts bond between particles with the specified particle IDs\n" "@type Id1: int\n" "@kwarg Id1: ID of first particle to bond\n" "@type Id2: int\n" "@kwarg Id2: ID of second particle to bond\n" "@type tag: int\n" "@kwarg tag: the bond tag to assign to the generated bond\n" ) .def( "setOutputPrecision", &MNTable3D::SetOutputPrecision, ( boost::python::arg("precision")), "Set the number of significant digits for file output\n" "@type precision: int\n" "@kwarg precision: the number of significant digits (default: 10).\n" ) .def( "initBlockWriting", &MNTable3D::initBlockWriting, ( boost::python::arg("filename")), "Initialize data needed for blocked writing\n" "@type filename: string\n" "@kwarg filename: The name of the geo file to be written.\n" ) .def( "writeBlock", &MNTable3D::writeBlock, ( boost::python::arg("minPoint"), boost::python::arg("maxPoint")), "Write particles in block to already initialized file\n" "@type minPoint: Vector3\n" "@kwarg minPoint: The minimum point of the block.\n" "@type maxPoint: Vector3\n" "@kwarg maxPoint: The maximum point of the block.\n" ) .def( "writeBondsBlocked", &MNTable3D::writeBondsBlocked, "Writing the current bonds to a temporary file.\n" ) .def( "removeBonds", &MNTable3D::removeBonds, "Delete all currently stored bonds.\n" ) .def( "finishBlockWriting", &MNTable3D::finishBlockWriting, "Finish block writing.\n" ) .def(self_ns::str(self)) ; } GenGeo-1.2/Python/MNTable3DPy.h0000644000000000000000000000147212533740504014271 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_MNTABLE3D_H #define GENGEO_MNTABLE3D_H #include #include "src/MNTable3D.h" void exportMNTable3D(); #endif GenGeo-1.2/Python/MeshVolWithJointSetPy.cc0000644000000000000000000000334012533740504016643 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include "MeshVolWithJointSetPy.h" using namespace boost::python; void exportMeshVolWithJointSet() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_ >( "MeshVolWithJointSet", "A class defining a volume bounded by a triangle mesh containing joints.", init<>() ) .def( init( ( arg("Mesh")), "Constructs a volume from a supplied set of triangles.\n" "@type Mesh: L{TriPatchSet}\n" "@kwarg Mesh: The set of triangles\n" ) ) .def( "addJoints", &MeshVolWithJointSet::addJoints, ( arg("JointSet") ), "Adds a set of triangluar patches as joints.\n" "@type plane: L{Plane}\n" "@kwarg plane: the set of patches\n" "@rtype: void\n" ) ; } GenGeo-1.2/Python/MeshVolWithJointSetPy.h0000644000000000000000000000161012533740504016503 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_MESHVOLWITHJOINTSETPY_H #define GENGEO_MESHVOLWITHJOINTSETPY_H #include #include "src/MeshVolWithJointSet.h" void exportMeshVolWithJointSet(); #endif // GENGEO_MESHVOLWITHJOINTSETPY_H GenGeo-1.2/Python/MeshVolumePy.cc0000644000000000000000000000263212533740504015041 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include "MeshVolumePy.h" using namespace boost::python; void exportMeshVolume() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_ >( "MeshVolume", "A class defining a volume bounded by a triangle mesh.", init<>() ) .def( init( ( arg("Mesh")), "Constructs a volume from a supplied set of triangles.\n" "@type Mesh: L{TriPatchSet}\n" "@kwarg Mesh: The set of triangles\n" ) ) ; } GenGeo-1.2/Python/MeshVolumePy.h0000644000000000000000000000153312533740504014702 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_MESHVOLUMEPY_H #define GENGEO_MESHVOLUMEPY_H #include #include "src/MeshVolume.h" void exportMeshVolume(); #endif // GENGEO_MESHVOLUMEPY_H GenGeo-1.2/Python/PlanePy.cc0000644000000000000000000000373512533740504014021 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include "PlanePy.h" using namespace boost::python; using boost::python::arg; void exportPlane() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_( "Plane", "A class defining a plane in 3D space.", init<>() ) .def(init()) .def( init( ( arg("origin"), arg("normal") ), "Constructs a plane with specifed origin and normal.\n" "N.B. This is not an L{AVolume3D} so cannot be used by C{InsertGenerators}.\n" "@type origin: L{Vector3}\n" "@kwarg origin: a point within the plane\n" "@type normal: L{Vector3}\n" "@kwarg normal: the normal of the plane (will be normalized)\n" ) ) .def( "getOrig", &Plane::getOrig, "Returns the origin point of this plane.\n" "@rtype: L{Vector3}\n" ) .def( "getNormal", &Plane::getNormal, "Returns the normal vector to this plane.\n" "@rtype: L{Vector3}\n" ) .def(self_ns::str(self)) ; } GenGeo-1.2/Python/PlanePy.h0000644000000000000000000000146312533740504013657 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_PLANEPY_H #define GENGEO_PLANEPY_H #include #include "geometry/Plane.h" void exportPlane(); #endif GenGeo-1.2/Python/PolygonWithLines2DPy.cc0000644000000000000000000000557112533740504016426 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include "PolygonWithLines2DPy.h" #include "src/PolygonWithLines2D.h" using namespace boost::python; void exportPolygonWithLines2D() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_ >( "PolygonWithLines2D", "A class defining a polygonal area in 2D space bounded by lines.", init<>() ) .def(init()) .def( init( ( arg("corners") ), "Constructs a polygon from either a list of vertices or a specified centre, radius and number of sides.\n" "@type corners: boost::python::list\n" "@kwarg corners: list of vertices. Do not specify C{centre}, C{radius}, C{nsides} or C{smooth_edges} when using this parameter.\n" ) ) .def( init( ( arg("centre"), arg("radius"), arg("nsides"), arg("smooth_edges") ), "@type centre: L{Vector3}\n" "@kwarg centre: Coordinates of the centre of the polygon. Do not specify C{corners} when using this parameter.\n" "@type radius: double\n" "@kwarg radius: Radius of circle enclosing the polygon. Do not specify C{corners} when using this parameter.\n" "@type nsides: int\n" "@kwarg nsides: Number of sides for the polygon (maximum of 50). Do not specify C{corners} when using this parameter.\n" "@type smooth_edges: bool\n" "@kwarg smooth_edges: Adds bounding lines to edges to achieve smooth edges. Do not specify C{corners} when using this parameter.\n" ) ) .def( "addLine", &PolygonWithLines2D::addLine, ( arg("line") ), "Adds a line to the polygon for fitting particles.\n" "@type line: L{Line2D}\n" "@kwarg line: the line to add to the polygon\n" "@rtype: void\n" ) .def(self_ns::str(self)) ; // boost::python::implicitly_convertible(); } GenGeo-1.2/Python/PolygonWithLines2DPy.h0000644000000000000000000000154212533740504016262 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_POLYGONWITHLINES2DPY_H #define GENGEO_POLYGONWITHLINES2DPY_H #include #include "src/PolygonWithLines2D.h" void exportPolygonWithLines2D(); #endif GenGeo-1.2/Python/ShapeListPy.cc0000644000000000000000000000532312533740504014651 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include "ShapeListPy.h" using namespace boost::python; void exportShapeList () { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_( "ShapeList", "A list of 3D shapes to be inserted into a packing by replacing spheres with scaled versions of the specified shape.\n" "Shapes may be read from a shape database file and the probability with which a given shape is inserted into a packing may be specified.\n", init<>() ) .def( "addHexShape", &ShapeList::addHexShape, ( arg("bias") ), ( arg("random") ), "Adds a hexagonal aggregate to the L{ShapeList}\n" "@type bias: int\n" "@kwarg bias: How often the shape should be added\n" "@type random: int\n" "@kwarg random: 1 to randomly orientate this shape, 0 to have all constant\n" ) .def( "addGenericShape", &ShapeList::addGenericShape, ( arg("db"), arg("name"), arg("bias"), arg("random"), arg("particleTag"), arg("bondTag") ), "Adds a shape from a database file into the list\n" "@type db: string\n" "@kwarg db: The filename of the database file\n" "@type name: string\n" "@kwarg name: The name of the shape to be added, as per database file\n" "@type bias: int\n" "@kwarg bias: The bias of the new shape; in other words, how often it will be added\n" "@type random: int\n" "@kwarg random: Whether the shape should be orientated randomly at each insertion:\n" "0 for not random, 1 for always random\n" "@type particleTag: int\n" "@kwarg particleTag: the ID of each particle inside each inserted shape\n" "@type bondTag: int\n" "@kwarg bondTag: the ID of each bond internal to each shape\n" ) ; } GenGeo-1.2/Python/ShapeListPy.h0000644000000000000000000000147612533740504014520 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_SHAPELISTPY_H #define GENGEO_SHAPELISTPY_H #include "src/ShapeList.h" #include void exportShapeList(); #endif GenGeo-1.2/Python/ShapePy.cc0000644000000000000000000000271512533740504014017 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include "ShapePy.h" using namespace boost::python; void exportShape () { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_( "Shape", "A shape designed for insertion into a L{ShapeList}.\n", //init<>() no_init ) .def( "makeOrientationRandom", &Shape::makeOrientationRandom, ( arg("v") ), "Sets the shape to be randomly orientated every time\n" "it is inserted.\n" "@type v: integer\n" "@kwarg v: 1 to use a random orientation, 0 for constant orientation\n" ); ; } GenGeo-1.2/Python/ShapePy.h0000644000000000000000000000145612533740504013662 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_SHAPEPY_H #define GENGEO_SHAPEPY_H #include #include "src/Shape.h" void exportShape(); #endif GenGeo-1.2/Python/SphereObjPy.cc0000644000000000000000000000256012533740504014636 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include "SphereObjPy.h" using namespace boost::python; void exportSphereObj () { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_( "SphereObj", "A 3D sphere shape to be inserted in a shape list.", init<>() ) .def( "setBias", &::dot, ( arg("i") ), "Sets the bias of the sphere shape (how often it should occur)\n" "@type i: int\n" "@kwarg i: the bias as any integer\n" ) ; } GenGeo-1.2/Python/SphereObjPy.h0000644000000000000000000000147612533740504014505 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_SPHEREOBJPY_H #define GENGEO_SPHEREOBJPY_H #include #include "src/SphereObj.h" void exportSphereObj(); #endif GenGeo-1.2/Python/SpherePy.cc0000644000000000000000000000504112533740504014200 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include "SpherePy.h" using namespace boost::python; using boost::python::arg; void exportSphere() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); // class_ >( class_( "Sphere", "A class defining a sphere.", init<>() ) .def(init()) .def( init( ( arg("centre"), arg("radius") ), "Constructs a sphere with the specified centre and radius.\n" "N.B. This is not a L{AVolume3D} so cannot be used by C{InsertGenerators}.\n" "@type centre: L{Vector3}\n" "@kwarg centre: the centre of the sphere\n" "@type radius: double\n" "@kwarg radius: the radius of the sphere\n" ) ) .def( "Centre", &Sphere::Center, "Returns the centre of the sphere.\n" "@rtype: L{Vector3}\n" ) .def( "Radius", &Sphere::Radius, "Returns the radius of the sphere.\n" "@rtype: double\n" ) .def( "Id", &Sphere::Id, "Returns the particle ID of the sphere.\n" "@rtype: int\n" ) .def( "Tag", &Sphere::Tag, "Returns the particle tag of the sphere.\n" "@rtype: int\n" ) .def( "setTag", &Sphere::setTag, ( arg("Tag")), "Sets the particle tag of the sphere.\n" "@rtype: int\n" ) .def( "setId", &Sphere::setId, ( arg("Id")), "Sets the ID of the sphere.\n" "@rtype: int\n" ) .def(self_ns::str(self)) .def(self_ns::str(self)) ; } GenGeo-1.2/Python/SpherePy.h0000644000000000000000000000146712533740504014052 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_SPHEREPY_H #define GENGEO_SPHEREPY_H #include #include "geometry/Sphere.h" void exportSphere(); #endif GenGeo-1.2/Python/SphereSectionVolPy.cc0000644000000000000000000000411412533740504016206 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include "SphereSectionVolPy.h" using namespace boost::python; void exportSphereSectionVol() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_ >( "SphereSectionVol", "A class defining a section of a spherical L{AVolume3D}.", init<>() ) .def(init()) .def( init( ( arg("centre"), arg("radius"), arg("distance"), arg("normal") ), "Constructs a section of a sphere with the specified centre and radius\n" "cropped by a plane with a given normal vector and distance from the sphere centre.\n" "@type centre: L{Vector3}\n" "@kwarg centre: Coordinates of the centre of the sphere\n" "@type radius: double\n" "@kwarg radius: Radius of the sphere\n" "@type distance: double\n" "@kwarg distance: Distance of section surface from centre of sphere\n" "@type normal: L{Vector3}\n" "@kwarg normal: Coordinates of the unit normal vector pointing from the section surface to the centre of the sphere\n" ) ) .def(self_ns::str(self)) ; } GenGeo-1.2/Python/SphereSectionVolPy.h0000644000000000000000000000153212533740504016051 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_SPHERESECTIONVOLPY_H #define GENGEO_SPHERESECTIONVOLPY_H #include #include "src/SphereSectionVol.h" void exportSphereSectionVol(); #endif GenGeo-1.2/Python/SphereVolPy.cc0000644000000000000000000000314212533740504014661 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include "SphereVolPy.h" using namespace boost::python; void exportSphereVol() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_ >( "SphereVol", "A class defining a spherical L{AVolume3D}.", init<>() ) .def(init()) .def( init( ( arg("centre"), arg("radius") ), "Constructs a sphere with the specified centre and radius.\n" "@type centre: L{Vector3}\n" "@kwarg centre: Coordinates of the centre of the sphere\n" "@type radius: double\n" "@kwarg radius: Radius of the sphere\n" ) ) .def(self_ns::str(self)) ; } GenGeo-1.2/Python/SphereVolPy.h0000644000000000000000000000147612533740504014533 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_SPHEREVOLPY_H #define GENGEO_SPHEREVOLPY_H #include #include "src/SphereVol.h" void exportSphereVol(); #endif GenGeo-1.2/Python/SphereVolWithJointSetPy.cc0000644000000000000000000000370112533740504017176 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include "SphereVolWithJointSetPy.h" using namespace boost::python; void exportSphereVolWithJointSet() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_ >( "SphereVolWithJointSet", "A class defining a spherical L{AVolume3D} containing joints.", init<>() ) .def(init()) .def( init( ( arg("centre"), arg("radius") ), "Constructs a sphere with the specified centre and radius.\n" "@type centre: L{Vector3}\n" "@kwarg centre: Coordinates of the centre of the sphere\n" "@type radius: double\n" "@kwarg radius: Radius of the sphere\n" ) ) .def( "addJoints", &SphereVolWithJointSet::addJoints, ( arg("JointSet") ), "Adds a set of triangluar patches as joints.\n" "@type plane: L{Plane}\n" "@kwarg plane: the set of patches\n" "@rtype: void\n" ) .def(self_ns::str(self)) ; } GenGeo-1.2/Python/SphereVolWithJointSetPy.h0000644000000000000000000000155612533740504017046 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_SPHEREVOLWITHJOINTSETPY_H #define GENGEO_SPHEREVOLWITHJOINTSETPY_H #include #include "src/SphereVolWithJointSet.h" void exportSphereVolWithJointSet(); #endif GenGeo-1.2/Python/TriBoxPy.cc0000644000000000000000000000442512533740504014166 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include "TriBoxPy.h" using namespace boost::python; void exportTriBox() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_ >( "TriBox", "A class defining a triangular prism L{AVolume3D} bounded by planes.", init<>() ) .def(init()) .def( init( ( arg("minPoint"), arg("maxPoint"), arg("inverted") ), "Constructs a triangular prism with the specified coordinates.\n" "The triangle cross-section is in the X-Y plane and may be upright or C{inverted}.\n" "@type minPoint: L{Vector3}\n" "@kwarg minPoint: Coordinate of bottom-left-front corner of the axis-aligned bounding box\n" "@type maxPoint: L{Vector3}\n" "@kwarg maxPoint: Coordinate of upper-right-back corner of the axis-aligned bounding box\n" "@type inverted: boolean\n" "@kwarg inverted: defines whether tribox is inverted (default is False)\n" ) ) .def( "addPlane", &TriBox::addPlane, ( arg("plane") ), "Adds a plane to the TriBox for fitting particles.\n" "@type plane: L{Plane}\n" "@kwarg plane: the plane to add to the TriBox\n" "@rtype: void" ) .def(self_ns::str(self)) ; // boost::python::implicitly_convertible(); } GenGeo-1.2/Python/TriBoxPy.h0000644000000000000000000000151512533740504014025 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_TRIBOXPY_H #define GENGEO_TRIBOXPY_H #include #include "src/AVolume3D.h" #include "src/TriBox.h" void exportTriBox(); #endif GenGeo-1.2/Python/TriPatchSetPy.cc0000644000000000000000000000527112533740504015151 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include #include #include #include "TriPatchSetPy.h" using namespace std; using namespace boost::python; void exportTriPatchSet() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_( "TriPatchSet", "A collection of triangular patches defining a joint set", init<>() ) .def(init()) .def("addTriangle", &TriPatchSet::addTriangle, ( boost::python::arg("Point1"),boost::python::arg("Point2"),boost::python::arg("Point2"),boost::python::arg("tag")), "Adds a triangle by specifying corner coordinates\n" "@type Point1: L{Vector3}\n" "@kwarg Point1: location of first corner of the triangle\n" "@type Point2: L{Vector3}\n" "@kwarg Point2: location of second corner of the triangle\n" "@type Point3: L{Vector3}\n" "@kwarg Point3: location of third corner of the triangle\n" "@type tag: int\n" "@kwarg tag: the tag to assign to the triangle\n" ) .def( "isCrossing", &TriPatchSet::isCrossing, (boost::python::arg("Point1"),boost::python::arg("Point2")), "Checks if the line between two specified points crosses a triangle. " "If so, the triangle tag is returned; if not, -1.\n" "@type Point1: L{Vector3}\n" "@kwarg Point1: location of first corner of the triangle\n" "@type Point2: L{Vector3}\n" "@kwarg Point2: location of second corner of the triangle\n" "@rtype: int\n" ) .def( "getMinPoint", &TriPatchSet::getMinPoint, "Returns minimum corner of the joint set bounding box\n" "@rtype: L{Vector3}\n" ) .def( "getMaxPoint", &TriPatchSet::getMaxPoint, "Returns maximum corner of the joint set bounding box\n" "@rtype: L{Vector3}\n" ); } GenGeo-1.2/Python/TriPatchSetPy.h0000644000000000000000000000152512533740504015011 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __TRIPATCHSET_PY_H #define __TRIPATCHSET_PY_H #include #include "src/TriPatchSet.h" void exportTriPatchSet(); #endif // __TRIPATCHSET_PY_H GenGeo-1.2/Python/TriWithLines2DPy.cc0000644000000000000000000000426012533740504015527 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include "TriWithLines2DPy.h" #include "src/TriWithLines2D.h" using namespace boost::python; void exportTriWithLines2D() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_ >( "TriWithLines2D", "A class defining a triangular L{AVolume2D} bounded by lines.", init<>() ) .def(init()) .def( init( ( arg("vertex0"), arg("vertex1"), arg("vertex2") ), "Constructs a triangle with the specified corner points.\n" "@type vertex0: L{Vector3}\n" "@kwarg vertex0: Coordinate of first corner of the triangle\n" "@type vertex1: L{Vector3}\n" "@kwarg vertex1: Coordinate of second corner of the triangle\n" "@type vertex2: L{Vector3}\n" "@kwarg vertex2: Coordinate of third corner of the triangle\n" ) ) .def( "addLine", &TriWithLines2D::addLine, ( arg("line") ), "Adds a line to the box for fitting particles.\n" "@type line: L{Line2D}\n" "@kwarg line: the line to add to the box\n" "@rtype: void\n" ) .def(self_ns::str(self)) ; // boost::python::implicitly_convertible(); } GenGeo-1.2/Python/TriWithLines2DPy.h0000644000000000000000000000152212533740504015367 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_TRIWITHLINES2DPY_H #define GENGEO_TRIWITHLINES2DPY_H #include #include "src/TriWithLines2D.h" void exportTriWithLines2D(); #endif GenGeo-1.2/Python/UnionVolPy.cc0000644000000000000000000000324012533740504014522 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include "UnionVolPy.h" using namespace boost::python; void exportUnionVol() { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_ >( "UnionVol", "A class defining a volume consisting of the union of two volumes in 3D.", init<>() ) .def(init()) .def( init( ( arg("volume1"), arg("volume2") ), "Constructs a volume comprised of the union of two volumes.\n" "@type volume1: L{AVolume3D}\n" "@kwarg volume1: The first volume comprising the union\n" "@type volume2: L{AVolume3D}\n" "@kwarg volume2: The second volume comprising the union\n" ) ) .def(self_ns::str(self)) ; } GenGeo-1.2/Python/UnionVolPy.h0000644000000000000000000000147212533740504014371 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_UNIONVOLPY_H #define GENGEO_UNIONVOLPY_H #include #include "src/UnionVol.h" void exportUnionVol(); #endif GenGeo-1.2/Python/Vector3Py.cc0000644000000000000000000000577512533740504014315 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include #include "Vector3Py.h" using namespace boost::python; void exportVector3 () { // Disable autogeneration of C++ signatures (Boost 1.34.0 and higher) // for Epydoc which stumbles over indentation in the automatically generated strings. boost::python::docstring_options no_autogen(true,false); class_( "Vector3", "A class defining a location or vector in 3D space", init<>() ) .def(init()) .def( init( ( arg("x"), arg("y"), arg("z") ), "Constructs a vector with specifed component values.\n" "@type x: float\n" "@kwarg x: index 0\n" "@type y: float\n" "@kwarg y: index 1\n" "@type z: float\n" "@kwarg z: index 2\n" ) ) .def(self == self) .def(self - self) .def(self + self) .def(self * double(0.0)) .def( "dot", &::dot, ( arg("v") ), "Returns the dot product of this 3-element vector with\n" "the specified L{Vector3}.\n" "@type v: L{Vector3}\n" "@kwarg v: dot product with this\n" "@rtype: float\n" ) .def( "cross", &::cross, ( arg("v") ), "Returns the cross product of this 3-element vector with\n" "the specified L{Vector3}.\n" "@type v: L{Vector3}\n" "@kwarg v: cross product with this\n" "@rtype: L{Vector3}\n" ) .def( "norm", &Vector3::norm, "Returns the magnitude of this 3-element vector.\n" "@rtype: float\n" "@return: math.sqrt(self.dot(self)).\n" ) .def( "unit", &Vector3::unit, "Returns the unit vector in the direction of this 3-element vector.\n" "@rtype: L{Vector3}\n" "@return: self/self.norm(self).\n" ) .def( "X", &Vector3::x, "Returns the x-coordinate of the vector.\n" "@rtype: double\n" ) .def( "Y", &Vector3::y, "Returns the y-coordinate of the vector.\n" "@rtype: double\n" ) .def( "Z", &Vector3::z, "Returns the z-coordinate of the vector.\n" "@rtype: double\n" ) .def(self_ns::str(self)) ; } GenGeo-1.2/Python/Vector3Py.h0000644000000000000000000000146712533740504014151 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENGEO_VECTOR3PY_H #define GENGEO_VECTOR3PY_H #include #include "util/vector3.h" void exportVector3(); #endif GenGeo-1.2/Python/__init__.py0000644000000000000000000000134112533740504014242 0ustar 00000000000000############################################################# ## ## ## Copyright (c) 2007-2014 by The University of Queensland ## ## Centre for Geoscience Computing ## ## http://earth.uq.edu.au/centre-geoscience-computing ## ## ## ## Primary Business: Brisbane, Queensland, Australia ## ## Licensed under the Open Software License version 3.0 ## ## http://www.opensource.org/licenses/osl-3.0.php ## ## ## ############################################################# # Init file for gengeo package. from gengeo import * GenGeo-1.2/config/Cpp.am0000644000000000000000000000142112533740504013155 0ustar 00000000000000############################################################# ## ## ## Copyright (c) 2007-2014 by The University of Queensland ## ## Centre for Geoscience Computing ## ## http://earth.uq.edu.au/centre-geoscience-computing ## ## ## ## Primary Business: Brisbane, Queensland, Australia ## ## Licensed under the Open Software License version 3.0 ## ## http://www.opensource.org/licenses/osl-3.0.php ## ## ## ############################################################# AM_CPPFLAGS = $(BOOST_CPPFLAGS) AM_LDFLAGS = -release $(PACKAGE_VERSION) $(BOOST_FILESYSTEM_LDFLAGS) GenGeo-1.2/config/Python.am0000644000000000000000000000152212533740504013716 0ustar 00000000000000############################################################# ## ## ## Copyright (c) 2007-2014 by The University of Queensland ## ## Centre for Geoscience Computing ## ## http://earth.uq.edu.au/centre-geoscience-computing ## ## ## ## Primary Business: Brisbane, Queensland, Australia ## ## Licensed under the Open Software License version 3.0 ## ## http://www.opensource.org/licenses/osl-3.0.php ## ## ## ############################################################# include $(top_srcdir)/config/Cpp.am gengeodir = $(pythondir)/gengeo AM_CPPFLAGS += $(PYTHON_CPPFLAGS) $(BOOST_PYTHON_CPPFLAGS) AM_LDFLAGS += $(BOOST_PYTHON_LDFLAGS) GenGeo-1.2/doc/CSG.readme0000644000000000000000000000313012533740504013206 0ustar 00000000000000############################################################# ## ## ## Copyright (c) 2007-2014 by The University of Queensland ## ## Centre for Geoscience Computing ## ## http://earth.uq.edu.au/centre-geoscience-computing ## ## ## ## Primary Business: Brisbane, Queensland, Australia ## ## Licensed under the Open Software License version 3.0 ## ## http://www.opensource.org/licenses/osl-3.0.php ## ## ## ############################################################# Current Status of the CSG based volumes --------------------------------------- The CSG based volumes, i.e. UnionVol, DifferenceVol and IntersectionVol are currently an experimental feature and may not always works as expected. While most basic operations do work there are some things which are either not sufficiently tested or actually known not to work. See below. Known issues: ------------- general: - cascading CSG operations is not well tested and may lead to unexpected results - using volumes with internal fitting surfaces, i.e. BoxWithJointSet or CylinderWithJointSet is untested, the CSG operation may have unexpected effects on the joint set DifferenceVol: - if the difference would result in an empty volume, i.e the 1st volume is fully contained in the 2nd volume, the calculation will not terminate IntersectionVol: - if the intersection is empty, i.e. the two volumes are disjoint, the calculation will not terminate GenGeo-1.2/doc/README0000644000000000000000000000212512533740504012276 0ustar 00000000000000############################################################# ## ## ## Copyright (c) 2007-2014 by The University of Queensland ## ## Centre for Geoscience Computing ## ## http://earth.uq.edu.au/centre-geoscience-computing ## ## ## ## Primary Business: Brisbane, Queensland, Australia ## ## Licensed under the Open Software License version 3.0 ## ## http://www.opensource.org/licenses/osl-3.0.php ## ## ## ############################################################# GenGeo 1.0 Documentation ======================== Currently documentation on GenGeo 1.0 is rather sparse. New users are encouraged to read through the examples/*py and browse the GenGeo Python API documentation: http://esys.geocomp.uq.edu.au/gengeo_python_doc/current/pythonapi/html/index.html If you have any questions, please direct these to the ESyS-Particle Answers forum: https://answers.launchpad.net/esys-particle/ GenGeo-1.2/examples/gengeo_DFN.py0000644000000000000000000000544012533740504014777 0ustar 00000000000000############################################################# ## ## ## Copyright (c) 2007-2014 by The University of Queensland ## ## Centre for Geoscience Computing ## ## http://earth.uq.edu.au/centre-geoscience-computing ## ## ## ## Primary Business: Brisbane, Queensland, Australia ## ## Licensed under the Open Software License version 3.0 ## ## http://www.opensource.org/licenses/osl-3.0.php ## ## ## ############################################################# from gengeo import * from random import random #An example python script to generate a bonded rectangle of particles with a discrete fracture network included width = 50.0 height = width # Define region extremities: minPoint = Vector3(0.0,0.0,0.0) maxPoint = Vector3(width,height,0.0) # Define the geometrical constraints for packing # (e.g. lines bordering a rectangular region in 2D) # QUESTION: Is there a particular order for defining endpoints of lines? top_line = Line2D ( startPoint = Vector3(width,0.0,0.0), endPoint = minPoint ) bottom_line = Line2D ( startPoint = maxPoint, endPoint = Vector3(0.0,height,0.0) ) left_line = Line2D ( startPoint = Vector3(width,0.0,0.0), endPoint = maxPoint ) right_line = Line2D ( startPoint = minPoint, endPoint = Vector3(0.0,height,0.0) ) # Define the Volume to be filled with spheres: # (e.g. a BoxWithLines2D) box = BoxWithLines2D ( minPoint = minPoint, maxPoint = maxPoint ) box.addLine(top_line) box.addLine(bottom_line) box.addLine(left_line) box.addLine(right_line) # Create a multi-group neighbour table to contain the particles: mntable = MNTable2D ( minPoint = minPoint, maxPoint = maxPoint, gridSize = 2.5 ) # Fill the volume with particles: packer = InsertGenerator2D ( minRadius = 0.1, maxRadius = 1.0, insertFails = 10000, maxIterations = 10000, tolerance = 1.0e-6 ) packer.generatePacking( volume = box, ntable = mntable, tag = 0) # create bonds between neighbouring particles: mntable.generateBonds( tolerance = 1.0e-5, bondID = 0 ) #Add a discrete fracture network n_faults = 10 breakLines = [] for f in range(n_faults): x0 = random()*0.8*width + 0.1*width y0 = random()*0.8*height + 0.1*height x1 = random()*0.8*width + 0.1*width y1 = random()*0.8*height + 0.1*height brkLine = LineSegment2D ( startPoint = Vector3(x0,y0,0.0), endPoint = Vector3(x1,y1,0.0) ) breakLines.append(brkLine) mntable.breakBondsAlongLineSegment( lineSegment = brkLine, distance = 0.25, tag = 0 ) # write a geometry file mntable.write( fileName = "temp/geo_DFN_2.vtu", outputStyle = 2 ) GenGeo-1.2/examples/gengeo_crack.py0000644000000000000000000000515412533740504015455 0ustar 00000000000000############################################################# ## ## ## Copyright (c) 2007-2014 by The University of Queensland ## ## Centre for Geoscience Computing ## ## http://earth.uq.edu.au/centre-geoscience-computing ## ## ## ## Primary Business: Brisbane, Queensland, Australia ## ## Licensed under the Open Software License version 3.0 ## ## http://www.opensource.org/licenses/osl-3.0.php ## ## ## ############################################################# from gengeo import * #An example python script to generate a bonded rectangle of particles with a discrete fracture network included width = 50.0 height = width # Define region extremities: minPoint = Vector3(0.0,0.0,0.0) maxPoint = Vector3(width,height,0.0) # Define the geometrical constraints for packing # (e.g. lines bordering a rectangular region in 2D) # QUESTION: Is there a particular order for defining endpoints of lines? top_line = Line2D ( startPoint = Vector3(width,0.0,0.0), endPoint = minPoint ) bottom_line = Line2D ( startPoint = maxPoint, endPoint = Vector3(0.0,height,0.0) ) left_line = Line2D ( startPoint = Vector3(width,0.0,0.0), endPoint = maxPoint ) right_line = Line2D ( startPoint = minPoint, endPoint = Vector3(0.0,height,0.0) ) # Define the Volume to be filled with spheres: # (e.g. a BoxWithLines2D) box = BoxWithLines2D ( minPoint = minPoint, maxPoint = maxPoint ) box.addLine(top_line) box.addLine(bottom_line) box.addLine(left_line) box.addLine(right_line) # Create a multi-group neighbour table to contain the particles: mntable = MNTable2D ( minPoint = minPoint, maxPoint = maxPoint, gridSize = 2.5 ) # Fill the volume with particles: packer = InsertGenerator2D ( minRadius = 0.1, maxRadius = 1.0, insertFails = 10000, maxIterations = 10000, tolerance = 1.0e-6 ) packer.generatePacking( volume = box, ntable = mntable, tag = 0) # create bonds between neighbouring particles: mntable.generateBonds( tolerance = 1.0e-5, bondID = 0 ) #Add a discrete fracture network brkLine = LineSegment2D ( startPoint = Vector3(0.4*width,0.4*height,0.0), endPoint = Vector3(0.6*width,0.6*height,0.0) ) mntable.breakBondsAlongLineSegment( lineSegment = brkLine, distance = 0.25, tag = 0 ) # write a geometry file mntable.write( fileName = "temp/geo_crack.geo", outputStyle = 1 ) # write a vtk file mntable.write( fileName = "temp/geo_crack.vtu", outputStyle = 2 ) GenGeo-1.2/examples/gengeo_example1.py0000644000000000000000000000530412533740504016103 0ustar 00000000000000############################################################# ## ## ## Copyright (c) 2007-2014 by The University of Queensland ## ## Centre for Geoscience Computing ## ## http://earth.uq.edu.au/centre-geoscience-computing ## ## ## ## Primary Business: Brisbane, Queensland, Australia ## ## Licensed under the Open Software License version 3.0 ## ## http://www.opensource.org/licenses/osl-3.0.php ## ## ## ############################################################# from gengeo import Vector3, Line2D, BoxWithLines2D, MNTable2D, InsertGenerator2D #An example python script to generate a 2D bonded rectangle of particles # Define region extremities: minPoint = Vector3(0.0,0.0,0.0) maxPoint = Vector3(10.0,10.0,0.0) # Define the volume to be filled with spheres: box = BoxWithLines2D ( minPoint = minPoint, maxPoint = maxPoint ) # Define the geometrical constraints for packing top_line = Line2D ( startPoint = Vector3(10.0,0.0,0.0), endPoint = minPoint ) bottom_line = Line2D ( startPoint = maxPoint, endPoint = Vector3(0.0,10.0,0.0) ) left_line = Line2D ( startPoint = Vector3(10.0,0.0,0.0), endPoint = maxPoint ) right_line = Line2D ( startPoint = minPoint, endPoint = Vector3(0.0,10.0,0.0) ) box.addLine(top_line) box.addLine(bottom_line) box.addLine(left_line) box.addLine(right_line) # Create a multi-group neighbour table to contain the particles: mntable = MNTable2D ( minPoint = minPoint, # specific regional extremities maxPoint = maxPoint, gridSize = 2.5 # neighbour search algorithm grid size ) # Fill the volume with particles: packer = InsertGenerator2D ( minRadius = 0.1, # minimum radius of spheres to insert maxRadius = 0.4, # maximum radius of spheres to insert insertFails = 5000, # maximum number of insertion failures maxIterations = 1000, # max. iterations for Newton-Raphson solver tolerance = 1.0e-5 # max. allowable overlap of spheres ) packer.generatePacking( volume = box, ntable = mntable, tag = 0) # create bonds between neighbouring particles: mntable.generateBonds( tolerance = 1.0e-5, # max. gap between "touching" particles bondID = 0 # bond ID of created bonds ) # write the geometry to a file in raw format mntable.write( fileName = "temp/geo_example1.txt", outputStyle = 0 ) # write the geometry to an ESyS-Particle geometry file mntable.write( fileName = "temp/geo_example1.geo", outputStyle = 1 ) # write the geometry as a VTK file mntable.write( fileName = "temp/geo_example1.vtu", outputStyle = 2 ) GenGeo-1.2/examples/gengeo_example10.py0000644000000000000000000000675212533740504016173 0ustar 00000000000000############################################################# ## ## ## Copyright (c) 2007-2014 by The University of Queensland ## ## Centre for Geoscience Computing ## ## http://earth.uq.edu.au/centre-geoscience-computing ## ## ## ## Primary Business: Brisbane, Queensland, Australia ## ## Licensed under the Open Software License version 3.0 ## ## http://www.opensource.org/licenses/osl-3.0.php ## ## ## ############################################################# from gengeo import * #An example python script to generate a union/intersection of two volumes # Define region extremities: maxRadius = 1.0 size = 20.0 minPoint = Vector3(0.0,0.0,0.0) maxPoint = Vector3(size,size,size) minPt = Vector3(0,0,0) maxPt = Vector3(size,0.5*size,size) # Define the first volume to be filled with spheres: box = BoxWithPlanes3D ( minPoint = minPt, maxPoint = maxPt ) box.addPlane( Plane( origin = minPt, normal = Vector3(1.0,0.0,0.0) ) ) #or the compact form: box.addPlane(Plane(minPt, Vector3(0.0,1.0,0.0))) box.addPlane(Plane(minPt, Vector3(0.0,0.0,1.0))) box.addPlane(Plane(maxPt, Vector3(-1.0,0.0,0.0))) box.addPlane(Plane(maxPt, Vector3(0.0,-1.0,0.0))) box.addPlane(Plane(maxPt, Vector3(0.0,0.0,-1.0))) sphere = SphereVol ( centre = Vector3(0.5*size,0.5*size,0.5*size), radius = 0.5*size ) sphere1 = SphereVol ( centre = Vector3(0.5*size,0.75*size,0.5*size), radius = 0.5*size ) sphere2 = SphereVol ( centre = Vector3(0.5*size,0.25*size,0.5*size), radius = 0.5*size ) cylinder = CylinderVol ( origin = Vector3 (0.5*size,0,0.5*size), axis = Vector3 (0,1,0), length = 0.5*size, radius = 0.5*size ) cylinder2 = CylinderVol ( origin = Vector3 (0.5*size,0,0.5*size), axis = Vector3 (0,1,0), length = 0.5*size, radius = 0.4*size ) cylinder3 = CylinderVol ( origin = Vector3 (0.5*size,0.25*size,0.5*size), axis = Vector3 (0,1,0), length = 0.5*size, radius = 0.3*size ) unionVol = UnionVol ( volume1 = sphere, volume2 = cylinder ) intersectionVol = IntersectionVol ( volume1 = sphere1, volume2 = sphere2 ) differenceVol = DifferenceVol ( volume1 = cylinder, volume2 = cylinder2 ) differenceVol2 = DifferenceVol ( volume1 = cylinder, volume2 = sphere1 ) differenceVol3 = DifferenceVol ( volume1 = cylinder, volume2 = cylinder3 ) # Create a multi-group neighbour table to contain the particles: mntable = MNTable3D ( minPoint = minPoint, maxPoint = maxPoint, gridSize = 2.5*maxRadius ) # Fill the volume with particles: packer = InsertGenerator3D ( minRadius = 0.2, maxRadius = maxRadius, insertFails = 1000, maxIterations = 1000, tolerance = 1.0e-6 ) packer.generatePacking( # volume = unionVol, # volume = intersectionVol, # volume = differenceVol, volume = differenceVol2, # volume = differenceVol3, # volume = cylinder, ntable = mntable ) # create bonds between neighbouring particles: mntable.generateBonds( tolerance = 1.0e-5, bondID = 0 ) mntable.tagParticlesInVolume ( volume = differenceVol, tag = 12345 ) # write a geometry file mntable.write( fileName = "temp/geo_example10.vtu", outputStyle = 2 ) mntable.write( fileName = "temp/geo_example10.raw", outputStyle = 0 ) mntable.write( fileName = "temp/geo_example10.geo", outputStyle = 1 ) GenGeo-1.2/examples/gengeo_example11.py0000644000000000000000000000574212533740504016172 0ustar 00000000000000############################################################# ## ## ## Copyright (c) 2007-2014 by The University of Queensland ## ## Centre for Geoscience Computing ## ## http://earth.uq.edu.au/centre-geoscience-computing ## ## ## ## Primary Business: Brisbane, Queensland, Australia ## ## Licensed under the Open Software License version 3.0 ## ## http://www.opensource.org/licenses/osl-3.0.php ## ## ## ############################################################# from gengeo import Vector3, Line2D, BoxWithLines2D, MNTable2D, InsertGenerator2D, CircleVol # An example python script to generate a 2D rectangle of particles # containing a circular cluster of bonded particles # Define region extremities: minPoint = Vector3(0.0,0.0,0.0) maxPoint = Vector3(10.0,10.0,0.0) # Define the volume to be filled with spheres: box = BoxWithLines2D ( minPoint = minPoint, maxPoint = maxPoint ) # Define the geometrical constraints for packing top_line = Line2D ( startPoint = Vector3(10.0,0.0,0.0), endPoint = minPoint ) bottom_line = Line2D ( startPoint = maxPoint, endPoint = Vector3(0.0,10.0,0.0) ) left_line = Line2D ( startPoint = Vector3(10.0,0.0,0.0), endPoint = maxPoint ) right_line = Line2D ( startPoint = minPoint, endPoint = Vector3(0.0,10.0,0.0) ) box.addLine(top_line) box.addLine(bottom_line) box.addLine(left_line) box.addLine(right_line) # Create a multi-group neighbour table to contain the particles: mntable = MNTable2D ( minPoint = minPoint, # specific regional extremities maxPoint = maxPoint, gridSize = 2.5 # neighbour search algorithm grid size ) # Fill the volume with particles: packer = InsertGenerator2D ( minRadius = 0.1, # minimum radius of spheres to insert maxRadius = 0.4, # maximum radius of spheres to insert insertFails = 5000, # maximum number of insertion failures maxIterations = 1000, # max. iterations for Newton-Raphson solver tolerance = 1.0e-6 # max. allowable overlap of spheres ) packer.generatePacking( volume = box, ntable = mntable, tag = 0) # define circular area center = Vector3(5.0,5.0,0.0) radius = 2.5 circ_area=CircleVol(center,radius) # tag particles in circular area mntable.tagParticlesInVolume(circ_area,2,0) # create bonds between neighbouring particles with tag 2: mntable.generateBondsWithMask( tolerance = 1.0e-5, # max. gap between "touching" particles bondID = 0, # bond ID of created bonds tag = 2, mask = 2 ) # write the geometry to a file in raw format mntable.write( fileName = "temp/geo_example11.txt", outputStyle = 0 ) # write the geometry to an ESyS-Particle geometry file mntable.write( fileName = "temp/geo_example11.geo", outputStyle = 1 ) # write the geometry as a VTK file mntable.write( fileName = "temp/geo_example11.vtu", outputStyle = 2 ) GenGeo-1.2/examples/gengeo_example2.py0000644000000000000000000000457512533740504016115 0ustar 00000000000000############################################################# ## ## ## Copyright (c) 2007-2014 by The University of Queensland ## ## Centre for Geoscience Computing ## ## http://earth.uq.edu.au/centre-geoscience-computing ## ## ## ## Primary Business: Brisbane, Queensland, Australia ## ## Licensed under the Open Software License version 3.0 ## ## http://www.opensource.org/licenses/osl-3.0.php ## ## ## ############################################################# from __future__ import division, print_function from gengeo import * #An example python script to generate a bonded rectangular prism # Define region extremities: maxRadius = 1.0 size = 10.0 minPoint = Vector3(0.0,0.0,0.0) maxPoint = Vector3(size,2.0*size,size) # Define the volume to be filled with spheres: # (e.g. a box bounded by planes) box = BoxWithPlanes3D ( minPoint = minPoint, maxPoint = maxPoint ) box.addPlane( Plane( origin = minPoint, normal = Vector3(1.0,0.0,0.0) ) ) #or the compact form: box.addPlane(Plane(minPoint, Vector3(0.0,1.0,0.0))) box.addPlane(Plane(minPoint, Vector3(0.0,0.0,1.0))) box.addPlane(Plane(maxPoint, Vector3(-1.0,0.0,0.0))) box.addPlane(Plane(maxPoint, Vector3(0.0,-1.0,0.0))) box.addPlane(Plane(maxPoint, Vector3(0.0,0.0,-1.0))) # Create a multi-group neighbour table to contain the particles: mntable = MNTable3D ( minPoint = minPoint, maxPoint = maxPoint, gridSize = 2.5*maxRadius ) # Fill the volume with particles: packer = InsertGenerator3D ( minRadius = 0.2, maxRadius = maxRadius, insertFails = 1000, maxIterations = 1000, tolerance = 1.0e-6 ) # Instruct packer to generate the particle packing packer.generatePacking( volume = box, ntable = mntable ) # create bonds between neighbouring particles: mntable.generateBonds( tolerance = 1.0e-5, bondID = 0 ) # print the porosity: volume = 2.0*size*size*size porosity = (volume - mntable.getSumVolume())/volume print("Porosity: ", porosity) # write the geometry to a VTK file mntable.write( fileName = "temp/geo_example2.vtu", outputStyle = 2 ) # write the geometry to an ESyS-Particle geo file mntable.write( fileName = "temp/geo_example2.geo", outputStyle = 1 ) GenGeo-1.2/examples/gengeo_example3.py0000644000000000000000000000336712533740504016114 0ustar 00000000000000############################################################# ## ## ## Copyright (c) 2007-2014 by The University of Queensland ## ## Centre for Geoscience Computing ## ## http://earth.uq.edu.au/centre-geoscience-computing ## ## ## ## Primary Business: Brisbane, Queensland, Australia ## ## Licensed under the Open Software License version 3.0 ## ## http://www.opensource.org/licenses/osl-3.0.php ## ## ## ############################################################# from gengeo import * #An example python script to generate a cylinder of unbonded particles # Define region extremities: origin = Vector3(0.0,0.0,0.0) axis = Vector3(0.0,1.0,0.0) size = 5.0 minPoint = Vector3(-1.0*size,0.0,-1.0*size) maxPoint = Vector3(size,3.0*size,size) # Define the volume to be filled with spheres: # (e.g. a cylinder) cylinder = CylinderVol ( origin = origin, axis = axis, length = 3.0*size, radius = size) # Create a multi-group neighbour table to contain the particles: mntable = MNTable3D ( minPoint = minPoint, maxPoint = maxPoint, gridSize = 2.2 ) # Fill the volume with particles: packer = InsertGenerator3D ( minRadius = 0.2, maxRadius = 1.0, insertFails = 1000, maxIterations = 1000, tolerance = 1.0e-6 ) # Generate the packing packer.generatePacking( volume = cylinder, ntable = mntable ) # write a geometry file in VTK format mntable.write( fileName = "temp/geo_example3.vtu", outputStyle = 2 ) # write a geometry file in ESyS-Particle geo format mntable.write( fileName = "temp/geo_example3.geo", outputStyle = 1 ) GenGeo-1.2/examples/gengeo_example4.py0000644000000000000000000000343012533740504016104 0ustar 00000000000000############################################################# ## ## ## Copyright (c) 2007-2014 by The University of Queensland ## ## Centre for Geoscience Computing ## ## http://earth.uq.edu.au/centre-geoscience-computing ## ## ## ## Primary Business: Brisbane, Queensland, Australia ## ## Licensed under the Open Software License version 3.0 ## ## http://www.opensource.org/licenses/osl-3.0.php ## ## ## ############################################################# from gengeo import * #An example python script to generate a dogbone of unbonded particles # Define region extremities: l2 = 10.0 r2 = 2.5 origin = Vector3(0.0,0.0,0.0) axis = Vector3(0.0,1.0,0.0) size = 5.0 minPoint = Vector3(-1.0*size,0.0,-1.0*size) maxPoint = Vector3(size,3.0*size,size) # Define the volume to be filled with spheres: dogbone = DogBone ( origin = origin, axis = axis, length = 3.0*size, radius = size, l2 = l2, r2 = r2 ) # Create a multi-group neighbour table to contain the particles: mntable = MNTable3D ( minPoint = minPoint, maxPoint = maxPoint, gridSize = 2.2 ) # Fill the volume with particles: packer = InsertGenerator3D ( minRadius = 0.2, maxRadius = 1.0, insertFails = 1000, maxIterations = 1000, tolerance = 1.0e-6 ) # Generate the packing packer.generatePacking( volume = dogbone, ntable = mntable ) # write a geometry file in VTK format mntable.write( fileName = "temp/geo_example4.vtu", outputStyle = 2 ) # write a geometry file in ESyS-Particle geo format mntable.write( fileName = "temp/geo_example4.geo", outputStyle = 1 ) GenGeo-1.2/examples/gengeo_example5.py0000644000000000000000000000326012533740504016106 0ustar 00000000000000############################################################# ## ## ## Copyright (c) 2007-2014 by The University of Queensland ## ## Centre for Geoscience Computing ## ## http://earth.uq.edu.au/centre-geoscience-computing ## ## ## ## Primary Business: Brisbane, Queensland, Australia ## ## Licensed under the Open Software License version 3.0 ## ## http://www.opensource.org/licenses/osl-3.0.php ## ## ## ############################################################# from gengeo import * #An example python script to generate a sphere of unbonded particles # Define region extremities: origin = Vector3(0.0,0.0,0.0) size = 5.0 minPoint = Vector3(-1.0*size,-1.0*size,-1.0*size) maxPoint = Vector3(size,size,size) # Define the volume to be filled with spheres: sphereVol = SphereVol ( centre = origin, radius = size ) # Create a multi-group neighbour table to contain the particles: mntable = MNTable3D ( minPoint = minPoint, maxPoint = maxPoint, gridSize = 2.2 ) # Fill the volume with particles: packer = InsertGenerator3D ( minRadius = 0.2, maxRadius = 1.0, insertFails = 1000, maxIterations = 1000, tolerance = 1.0e-6 ) # Generate the packing packer.generatePacking( volume = sphereVol, ntable = mntable ) # write a geometry file in VTK format mntable.write( fileName = "temp/geo_example5.vtu", outputStyle = 2 ) # write a geometry file in ESyS-Particle geo format mntable.write( fileName = "temp/geo_example5.geo", outputStyle = 1 ) GenGeo-1.2/examples/gengeo_example6.py0000644000000000000000000000427012533740504016111 0ustar 00000000000000############################################################# ## ## ## Copyright (c) 2007-2014 by The University of Queensland ## ## Centre for Geoscience Computing ## ## http://earth.uq.edu.au/centre-geoscience-computing ## ## ## ## Primary Business: Brisbane, Queensland, Australia ## ## Licensed under the Open Software License version 3.0 ## ## http://www.opensource.org/licenses/osl-3.0.php ## ## ## ############################################################# from __future__ import division from gengeo import * #An example python script to generate a triangular prism of bonded particles size=5.0 # Define region extremities: minPoint = Vector3(-1.0*size,-1.0*size,-1.0*size) maxPoint = Vector3(size,size,size) # Define the volume to be filled with spheres: tribox = TriBox ( minPoint = minPoint, maxPoint = maxPoint, inverted = False ) tribox.addPlane(Plane(minPoint,Vector3(0.0,1.0,0.0))) tribox.addPlane(Plane(minPoint,Vector3(0.0,0.0,1.0))) tribox.addPlane(Plane(maxPoint,Vector3(0.0,0.0,-1.0))) delta = maxPoint-minPoint dx = delta.X() dy = delta.Y() tribox.addPlane(Plane(minPoint, Vector3(dy,-0.5*dx,0.0).unit())) tribox.addPlane(Plane(maxPoint-Vector3(dx/2.0,0.0,0.0), Vector3(-1.0*dy,-0.5*dx,0.0).unit())) # Create a multi-group neighbour table to contain the particles: mntable = MNTable3D ( minPoint = minPoint, maxPoint = maxPoint, gridSize = 2.5 ) # Fill the volume with particles: packer = InsertGenerator3D ( minRadius = 0.2, maxRadius = 1.0, insertFails = 1000, maxIterations = 1000, tolerance = 1.0e-6 ) # Generate the packing packer.generatePacking( volume = tribox, ntable = mntable ) # generate bonds between neighbouring particles mntable.generateBonds( tolerance = 1.0e-5, bondID = 0 ) # write a geometry file in VTK format mntable.write( fileName = "temp/geo_example6.vtu", outputStyle = 2 ) # write a geometry file in ESyS-Particle geo format mntable.write( fileName = "temp/geo_example6.geo", outputStyle = 1 ) GenGeo-1.2/examples/gengeo_example7.py0000644000000000000000000000472412533740504016116 0ustar 00000000000000############################################################# ## ## ## Copyright (c) 2007-2014 by The University of Queensland ## ## Centre for Geoscience Computing ## ## http://earth.uq.edu.au/centre-geoscience-computing ## ## ## ## Primary Business: Brisbane, Queensland, Australia ## ## Licensed under the Open Software License version 3.0 ## ## http://www.opensource.org/licenses/osl-3.0.php ## ## ## ############################################################# from __future__ import division, print_function from gengeo import * #An example python script to generate an aggregate of hexagonal grains # with circular boundary conditions and tagging of particles along lines # Define region extremities: size = 5.0 minPoint = Vector3(0.0,0.0,0.0) maxPoint = Vector3(size,size,0.0) # Define the geometrical constraints for packing top_line = Line2D ( startPoint = Vector3(size,0.0,0.0), endPoint = minPoint ) bottom_line = Line2D ( startPoint = maxPoint, endPoint = Vector3(0.0,size,0.0) ) box = BoxWithLines2DSubVol ( minPoint = minPoint-Vector3(-0.5,0.0,0.0), maxPoint = maxPoint+Vector3(0.5,0.0,0.0), svdim_x = 2.5, svdim_y = 2.5 ) box.addLine(top_line) box.addLine(bottom_line) # Create a multi-group neighbour table to contain the particles: mntable = CircMNTable2D ( minPoint = minPoint, maxPoint = maxPoint, gridSize = 2.5 ) # Fill the volume with particles: packer = HexAggregateInsertGenerator2D ( minRadius = 0.1, maxRadius = 1.0, insertFails = 1000, maxIterations = 1000, tolerance = 1.0e-6 ) # Generate the packing packer.generatePacking( volume = box, ntable = mntable, tag = 0 ) # tag particles along the top_line and bottom_line mntable.tagParticlesAlongLineWithMask( line = top_line, distance = 0.5, tag = 4, mask = 4 ) #and the compact form: mntable.tagParticlesAlongLineWithMask(bottom_line, 0.5, 8, 8, 0) #print the porosity of the particle packing: volume = size*size porosity = (volume - mntable.getSumVolume())/volume print("Porosity: ",porosity) # write a geometry file in VTK format mntable.write( fileName = "temp/geo_example7.vtu", outputStyle = 2 ) # write a geometry file in ESyS-Particle geo format mntable.write( fileName = "temp/geo_example7.geo", outputStyle = 1 ) GenGeo-1.2/examples/gengeo_example8.py0000644000000000000000000000471212533740504016114 0ustar 00000000000000############################################################# ## ## ## Copyright (c) 2007-2014 by The University of Queensland ## ## Centre for Geoscience Computing ## ## http://earth.uq.edu.au/centre-geoscience-computing ## ## ## ## Primary Business: Brisbane, Queensland, Australia ## ## Licensed under the Open Software License version 3.0 ## ## http://www.opensource.org/licenses/osl-3.0.php ## ## ## ############################################################# from gengeo import * from math import sqrt #An example python script to generate a regular aggregate of hexagonal grains # with bonds broken along lines # Define region extremities: size = 150.0 xsize = size ysize = size minPoint = Vector3(0.0,0.0,0.0) maxPoint = Vector3(xsize,ysize,0.0) # Define the geometrical constraints for packing top_line = Line2D ( startPoint = minPoint, endPoint = Vector3(size,0.0,0.0) ) bottom_line = Line2D ( startPoint = Vector3(0.0,40.,0.0), endPoint = Vector3(40.,40.,0.0) ) #or compact form: left_line = Line2D(Vector3(40.,40.,0.0),Vector3(40.,0.0,0.0)) right_line = Line2D(minPoint, Vector3(0.0,ysize,0.0)) box = BoxWithLines2D ( minPoint = minPoint, maxPoint = maxPoint ) box.addLine(top_line) box.addLine(bottom_line) box.addLine(left_line) box.addLine(right_line) # Create a multi-group neighbour table to contain the particles: mntable = MNTable2D ( minPoint = minPoint, maxPoint = maxPoint, gridSize = 1.25 ) # Fill the volume with particles: packer = HGrainGenerator2D ( radius = 0.5 ) # Generate the packing packer.generatePacking( volume = box, ntable = mntable, tag = 0 ) # bond the particles #mntable.generateBonds(0,1.0e-5,3) # tag particles along the boundary lines (e.g. top_line, left_line etc.) # using the compact form: mntable.tagParticlesAlongLineWithMask(bottom_line, 5.0, 4, -1, 0) mntable.tagParticlesAlongLineWithMask(top_line, 5.0, 8, -1, 0) mntable.tagParticlesAlongLineWithMask(left_line, 8.0, 16, -1, 0) mntable.tagParticlesAlongLineWithMask(right_line, 8.0, 32,-1, 0) # write a geometry file in VTK format mntable.write( fileName = "temp/geo_example8.vtu", outputStyle = 2 ) # write a geometry file in ESyS-Particle geo format mntable.write( fileName = "temp/geo_example8.geo", outputStyle = 1 ) GenGeo-1.2/examples/gengeo_example9.py0000644000000000000000000000331512533740504016113 0ustar 00000000000000############################################################# ## ## ## Copyright (c) 2007-2014 by The University of Queensland ## ## Centre for Geoscience Computing ## ## http://earth.uq.edu.au/centre-geoscience-computing ## ## ## ## Primary Business: Brisbane, Queensland, Australia ## ## Licensed under the Open Software License version 3.0 ## ## http://www.opensource.org/licenses/osl-3.0.php ## ## ## ############################################################# from gengeo import * #An example python script to generate a rough ellipsoid of unbonded particles # Define region extremities: origin = Vector3(0.0,0.0,0.0) size = 5.0 minPoint = Vector3(-1.0*size,-1.0*size,-1.0*size) maxPoint = Vector3(size,size,size) # Define the volume to be filled with spheres: sphereVol = EllipsoidVol ( centre = origin, Lx = 8.0, Ly = 6.0, Lz = 3.0 ) # Create a multi-group neighbour table to contain the particles: mntable = MNTable3D ( minPoint = minPoint, maxPoint = maxPoint, gridSize = 2.2 ) # Fill the volume with particles: packer = InsertGenerator3D ( minRadius = 0.2, maxRadius = 1.0, insertFails = 1000, maxIterations = 1000, tolerance = 1.0e-6 ) # Generate the packing packer.generatePacking( volume = sphereVol, ntable = mntable ) # write a geometry file in VTK format mntable.write( fileName = "temp/geo_example9.vtu", outputStyle = 2 ) # write a geometry file in ESyS-Particle geo format mntable.write( fileName = "temp/geo_example9.geo", outputStyle = 1 ) GenGeo-1.2/examples/gengeo_exampleShapeList.py0000644000000000000000000000542312533740504017641 0ustar 00000000000000############################################################# ## ## ## Copyright (c) 2007-2014 by The University of Queensland ## ## Centre for Geoscience Computing ## ## http://earth.uq.edu.au/centre-geoscience-computing ## ## ## ## Primary Business: Brisbane, Queensland, Australia ## ## Licensed under the Open Software License version 3.0 ## ## http://www.opensource.org/licenses/osl-3.0.php ## ## ## ############################################################# from __future__ import division, print_function from gengeo import * #An example python script to generate a bonded rectangular prism # Define region extremities: maxRadius = 1.0 size = 4.0 minPoint = Vector3(0.0,0.0,0.0) maxPoint = Vector3(size,2.0*size,size) # Define the volume to be filled with spheres: # (e.g. a box bounded by planes) # QUESTION: Are there constraints on normals e.g. inward facing? box = BoxWithPlanes3D ( minPoint = minPoint, maxPoint = maxPoint ) box.addPlane( Plane( origin = minPoint, normal = Vector3(1.0,0.0,0.0) ) ) #or the compact form: box.addPlane(Plane(minPoint, Vector3(0.0,1.0,0.0))) box.addPlane(Plane(minPoint, Vector3(0.0,0.0,1.0))) box.addPlane(Plane(maxPoint, Vector3(-1.0,0.0,0.0))) box.addPlane(Plane(maxPoint, Vector3(0.0,-1.0,0.0))) box.addPlane(Plane(maxPoint, Vector3(0.0,0.0,-1.0))) # Create a multi-group neighbour table to contain the particles: mntable = MNTable3D ( minPoint = minPoint, maxPoint = maxPoint, gridSize = 2.5*maxRadius ) sList = ShapeList() sList.addGenericShape( db = "shapeDatabase.db", name = "sphere", bias = 1, random = 1, particleTag = 1, bondTag = 1 ) sList.addGenericShape( db = "shapeDatabase.db", name = "test", bias = 5, random = 1, particleTag = 2, bondTag = 2 ) # Fill the volume with particles: packer = InsertGenerator3D ( minRadius = 0.2, maxRadius = maxRadius, insertFails = 1000, maxIterations = 1000, tolerance = 1.0e-6 ) packer.generatePacking( volume = box, ntable = mntable, tag = 0, shapeList = sList ) # print the porosity: volume = 2.0*size*size*size porosity = (volume - mntable.getSumVolume())/volume print("Porosity: ", porosity) # write a geometry file in VTK format mntable.write( fileName = "temp/geo_exampleShapeList.vtu", outputStyle = 2 ) # write a geometry file in raw (debug) format mntable.write( fileName = "temp/geo_exampleShapeList.raw", outputStyle = 0 ) # write a geometry file in gengeo file format mntable.write( fileName = "temp/geo_exampleShapeList.geo", outputStyle = 1 ) GenGeo-1.2/examples/gengeo_obstructed_flow.py0000644000000000000000000000631112533740504017573 0ustar 00000000000000############################################################# ## ## ## Copyright (c) 2007-2014 by The University of Queensland ## ## Centre for Geoscience Computing ## ## http://earth.uq.edu.au/centre-geoscience-computing ## ## ## ## Primary Business: Brisbane, Queensland, Australia ## ## Licensed under the Open Software License version 3.0 ## ## http://www.opensource.org/licenses/osl-3.0.php ## ## ## ############################################################# from gengeo import * # Define region extremities: minPoint = Vector3(0.0,25.0,0.0) maxPoint = Vector3(30.0,40.0,0.0) top_line = Line2D ( startPoint = Vector3(30.0,25.0,0.0), endPoint = minPoint ) bottom_line = Line2D ( startPoint = maxPoint, endPoint = Vector3(0.0,40.0,0.0) ) left_line = Line2D ( startPoint = Vector3(30.0,25.0,0.0), endPoint = maxPoint ) right_line = Line2D ( startPoint = minPoint, endPoint = Vector3(0.0,40.0,0.0) ) box = BoxWithLines2D ( minPoint = minPoint, maxPoint = maxPoint ) box.addLine(top_line) box.addLine(bottom_line) box.addLine(left_line) box.addLine(right_line) mntable = MNTable2D ( minPoint = Vector3(0.0,0.0,0.0), maxPoint = Vector3(30.0,40.0,0.0), gridSize = 1.25 ) packer = InsertGenerator2D ( minRadius = 0.4, maxRadius = 0.6, insertFails = 5000, maxIterations = 10000, tolerance = 1.0e-6 ) packer.generatePacking( volume = box, ntable = mntable, tag = 0) #tri = PolygonWithLines2D ( # centre = Vector3(15.0,15.0,0.0), # radius = 10.0, # nsides = 3, # smooth_edges = True #) left_tri = TriWithLines2D ( vertex0 = Vector3(0.0,0.0,0.0), vertex1 = Vector3(10.0,0.0,0.0), vertex2 = Vector3(0.0,17.0,0.0) ) right_tri = TriWithLines2D ( vertex0 = Vector3(20.0,0.0,0.0), vertex1 = Vector3(30.0,0.0,0.0), vertex2 = Vector3(30.0,17.0,0.0) ) obstacle = BoxWithLines2D ( minPoint = Vector3(10.0,15.0,0.0), maxPoint = Vector3(20.0,23.0,0.0) ) t_line = Line2D ( startPoint = Vector3(10.0,23.0,0.0), endPoint = Vector3(20.0,23.0,0.0) ) obstacle.addLine(t_line) b_line = Line2D ( startPoint = Vector3(10.0,15.0,0.0), endPoint = Vector3(20.0,15.0,0.0) ) obstacle.addLine(b_line) l_line = Line2D ( startPoint = Vector3(10.0,15.0,0.0), endPoint = Vector3(10.0,23.0,0.0) ) obstacle.addLine(l_line) r_line = Line2D ( startPoint = Vector3(20.0,15.0,0.0), endPoint = Vector3(20.0,23.0,0.0) ) obstacle.addLine(r_line) packer2 = InsertGenerator2D ( minRadius = 0.1, maxRadius = 1.0, insertFails = 5000, maxIterations = 10000, tolerance = 1.0e-6 ) packer2.generatePacking( volume = left_tri, ntable = mntable, tag = 999) packer2.generatePacking( volume = right_tri, ntable = mntable, tag = 999) packer2.generatePacking( volume = obstacle, ntable = mntable, tag = 999) # write a geometry file mntable.write( fileName = "temp/obstructed_flow.vtu", outputStyle = 2 ) mntable.write( fileName = "temp/obstructed_flow.geo", outputStyle = 1 ) mntable.write( fileName = "temp/obstructed_flow.raw", outputStyle = 0 ) GenGeo-1.2/examples/gengeo_polygon.py0000644000000000000000000000550412533740504016060 0ustar 00000000000000############################################################# ## ## ## Copyright (c) 2007-2014 by The University of Queensland ## ## Centre for Geoscience Computing ## ## http://earth.uq.edu.au/centre-geoscience-computing ## ## ## ## Primary Business: Brisbane, Queensland, Australia ## ## Licensed under the Open Software License version 3.0 ## ## http://www.opensource.org/licenses/osl-3.0.php ## ## ## ############################################################# from __future__ import division from gengeo import * from random import random #An example python script to generate a bonded rectangle of particles with a discrete fracture network included width = 50.0 height = width # Define region extremities: minPoint = Vector3(0.0,0.0,0.0) maxPoint = Vector3(width,height,0.0) # Define the geometrical constraints for packing # (e.g. lines bordering a rectangular region in 2D) # QUESTION: Is there a particular order for defining endpoints of lines? top_line = Line2D ( startPoint = Vector3(width,0.0,0.0), endPoint = minPoint ) bottom_line = Line2D ( # startPoint = maxPoint, startPoint = Vector3(width,0.0,0.0), endPoint = Vector3(width/2.0,height,0.0) ) left_line = Line2D ( startPoint = Vector3(width/2.0,height,0.0), endPoint = minPoint ) right_line = Line2D ( startPoint = minPoint, endPoint = Vector3(0.0,height,0.0) ) # Define the Volume to be filled with spheres: # (e.g. a BoxWithLines2D) box = PolygonWithLines2D ( centre = Vector3(25.0,25.0,0.0), radius = 25.0, nsides = 5, smooth_edges = True ) #box.addLine(top_line) #box.addLine(bottom_line) #box.addLine(left_line) #box.addLine(right_line) # Create a multi-group neighbour table to contain the particles: mntable = MNTable2D ( minPoint = minPoint, maxPoint = maxPoint, gridSize = 2.5 ) # Fill the volume with particles: packer = InsertGenerator2D ( minRadius = 0.1, maxRadius = 1.0, insertFails = 1000, maxIterations = 1000, tolerance = 1.0e-6 ) packer.generatePacking( volume = box, ntable = mntable, tag = 0) # create bonds between neighbouring particles: mntable.generateBonds( tolerance = 1.0e-5, bondID = 0 ) #Add a discrete fracture network n_faults = 10 breakLines = [] for f in range(n_faults): x0 = random()*0.8*width + 0.1*width y0 = random()*0.8*height + 0.1*height x1 = random()*0.8*width + 0.1*width y1 = random()*0.8*height + 0.1*height brkLine = LineSegment2D ( startPoint = Vector3(x0,y0,0.0), endPoint = Vector3(x1,y1,0.0) ) breakLines.append(brkLine) # write a geometry file mntable.write( fileName = "temp/geo_polygon.vtu", outputStyle = 2 ) GenGeo-1.2/examples/gengeo_test_cluster.py0000644000000000000000000000644712533740504017120 0ustar 00000000000000############################################################# ## ## ## Copyright (c) 2007-2014 by The University of Queensland ## ## Centre for Geoscience Computing ## ## http://earth.uq.edu.au/centre-geoscience-computing ## ## ## ## Primary Business: Brisbane, Queensland, Australia ## ## Licensed under the Open Software License version 3.0 ## ## http://www.opensource.org/licenses/osl-3.0.php ## ## ## ############################################################# #from __future__ import print_function from __future__ import division from gengeo import Sphere, Vector3, Line2D, BoxWithLines2D, MNTable2D, InsertGenerator2D from random import random # An example python script to generate a bonded rectangle of particles # and cluster the particles inside the rectangle # Define region extremities: xsize=20.0 ysize=20.0 minPoint = Vector3(0.0,0.0,0.0) maxPoint = Vector3(xsize,ysize,0.0) # Define the geometrical constraints for packing # (e.g. lines bordering a rectangular region in 2D) top_line = Line2D ( startPoint = Vector3(xsize,0.0,0.0), endPoint = minPoint ) bottom_line = Line2D ( startPoint = maxPoint, endPoint = Vector3(0.0,ysize,0.0) ) left_line = Line2D ( startPoint = Vector3(xsize,0.0,0.0), endPoint = maxPoint ) right_line = Line2D ( startPoint = minPoint, endPoint = Vector3(0.0,ysize,0.0) ) # Define the Volume to be filled with spheres: box = BoxWithLines2D ( minPoint = minPoint, maxPoint = maxPoint ) box.addLine(top_line) box.addLine(bottom_line) box.addLine(left_line) box.addLine(right_line) # Create a multi-group neighbour table to contain the particles: mntable = MNTable2D ( minPoint = minPoint, maxPoint = maxPoint, gridSize = 2.5, numGroups = 2 ) # Fill the volume with particles: packer = InsertGenerator2D ( minRadius = 0.1, maxRadius = 1.0, insertFails = 1000, maxIterations = 1000, tolerance = 1.0e-6, seed=0 ) packer.generatePacking( volume = box, ntable = mntable, groupID = 0, tag = 0) # insert zero-radius particles in group 2 as a cluster seeds # use randomly disturbed square grid nx=5 ny=5 for i in range(nx): for j in range(ny): xpos=(float(i)+random())*xsize/float(nx) ypos=(float(j)+random())*ysize/float(ny) cseed=Sphere(Vector3(xpos,ypos,0.0),0.0) # cseed.setTag(i*ny+j) cseed.setTag(int(random()*nx*ny)) mntable.insert( sphere=cseed, groupID=1 ) #print("xpos: ",xpos) mntable.tagParticlesToClosest( groupID1=0, groupID2=1 ) # create cluster bonds between neighbouring particles # bonds between particles with the same tag will have bondTag1 # bonds between particles with different tags will have bondTag2 mntable.generateClusterBonds( groupID = 0, tolerance = 1.0e-5, bondTag1 = 0, bondTag2 = 1, ) # write a geometry file mntable.write( fileName = "temp/cluster.geo", outputStyle = 1 ) # write a vtk file mntable.write( fileName = "temp/cluster.vtu", outputStyle = 2 ) GenGeo-1.2/examples/gouge_example.py0000644000000000000000000000340712533740504015666 0ustar 00000000000000############################################################# ## ## ## Copyright (c) 2007-2014 by The University of Queensland ## ## Centre for Geoscience Computing ## ## http://earth.uq.edu.au/centre-geoscience-computing ## ## ## ## Primary Business: Brisbane, Queensland, Australia ## ## Licensed under the Open Software License version 3.0 ## ## http://www.opensource.org/licenses/osl-3.0.php ## ## ## ############################################################# from gengeo import * from granular_gouge import * xsize = 20.0 ysize = 20.0 ysize_bdry = 4.0 zsize = 20.0 numRidges = 5 heightRidges = 2.5 numInsertFails = 1000 minRadius = 0.2 minGrainRadius = 2.0 maxGrainRadius = 4.0 minPoint = Vector3(0,0,0) maxPoint = Vector3(xsize,ysize,zsize) minGPoint = Vector3(0,ysize_bdry,0) maxGPoint = Vector3(xsize,ysize-ysize_bdry,zsize) mntable = CircMNTable3D ( minPoint = minPoint, maxPoint = maxPoint, gridSize = 2.5, numGroups = 3 ) packer = InsertGenerator3D ( minRadius = minRadius, maxRadius = 1.0, insertFails = numInsertFails, maxIterations = 1000, tolerance = 1.0e-6 ) generate_upper_tri_rough_block(mntable, packer, xsize, ysize_bdry, zsize, ysize-ysize_bdry, numRidges, heightRidges) generate_lower_tri_rough_block(mntable, packer, xsize, ysize_bdry, zsize, 0.0, numRidges, heightRidges) generate_granular_gouge(mntable, packer, minGPoint, maxGPoint, minGrainRadius, maxGrainRadius, numInsertFails) mntable.generateBonds( tolerance = 1.0e-5, bondID = 0 ) mntable.write( fileName = "temp/geo_gouge.vtu", outputStyle = 2 ) GenGeo-1.2/examples/granular_gouge.py0000644000000000000000000000726312533740504016052 0ustar 00000000000000############################################################# ## ## ## Copyright (c) 2007-2014 by The University of Queensland ## ## Centre for Geoscience Computing ## ## http://earth.uq.edu.au/centre-geoscience-computing ## ## ## ## Primary Business: Brisbane, Queensland, Australia ## ## Licensed under the Open Software License version 3.0 ## ## http://www.opensource.org/licenses/osl-3.0.php ## ## ## ############################################################# from __future__ import division from gengeo import * def generate_upper_tri_rough_block(NT, G, xt, yt, zt, y0, nr, yr): min = Vector3(0.0,y0,0.0) min_2 = Vector3(0.0,y0+yr,0.0) max = Vector3(xt,y0+yt,zt) xr = xt/(1.0*nr) top_plane = Plane (max, Vector3(0,-1,0)) bottom_plane_1 = Plane(min, Vector3(0,1,0)) bottom_plane_2 = Plane(min_2, Vector3(0,1,0)) front_plane = Plane(min, Vector3(0,0,1)) back_plane = Plane(max, Vector3(0,0,-1)) diff = Vector3(1,0,0) Box = BoxWithPlanes3D (min_2-diff,max+diff) Box.addPlane(top_plane) Box.addPlane(bottom_plane_2) Box.addPlane(front_plane) Box.addPlane(back_plane) G.generatePacking(Box,NT,0) for i in range(0,nr): x1 = (1.0*i)*xr x2 = (1.0*i+1.0)*xr lmin = Vector3(x1,y0,0.0) lmax = Vector3(x2,y0+yr,zt) left_plane = Plane (lmin+Vector3(xr/2.0,0.0,0.0), (Vector3(yr,-0.5*xr,0.0)).unit()) right_plane = Plane (lmax, Vector3(-1.0*yr,-0.5*xr,0.0).unit()) RBox = TriBox (lmin,lmax,True) RBox.addPlane(front_plane) RBox.addPlane(back_plane) RBox.addPlane(left_plane) RBox.addPlane(right_plane) G.generatePacking(RBox, NT, 0) # NT.tagParticlesAlongPlane(top_plane,0.5,3,0) NT.tagParticlesAlongPlane(top_plane,yt,3,0) def generate_lower_tri_rough_block(NT, G, xt, yt, zt, y0, nr, yr): min = Vector3(0.0,y0,0.0) max_2 = Vector3(xt,y0+(yt-yr),zt) max = Vector3(xt,y0+yt,zt) xr = xt/(nr) top_plane = Plane (max, Vector3(0,-1,0)) top_plane_2 = Plane(max_2, Vector3(0,-1,0)) bottom_plane = Plane(min, Vector3(0,1,0)) front_plane = Plane(min, Vector3(0,0,1)) back_plane = Plane(max, Vector3(0,0,-1)) diff = Vector3(1,0,0) Box = BoxWithPlanes3D (min-diff,max_2+diff) Box.addPlane(top_plane_2) Box.addPlane(bottom_plane) Box.addPlane(front_plane) Box.addPlane(back_plane) G.generatePacking(Box,NT,0) for i in range(0,nr): x1 = (1.0*i)*xr x2 = (1.0*i+1.0)*xr lmin = Vector3(x1,y0+(yt-yr),0.0) lmax = Vector3(x2,y0+yt,zt) left_plane = Plane (lmin, Vector3(yr,-0.5*xr,0).unit()) right_plane = Plane (lmax-Vector3(xr/2.0,0.0,0.0), Vector3(-1.0*yr,-0.5*xr,0.0).unit()) RBox = TriBox (lmin,lmax,False) RBox.addPlane(front_plane) RBox.addPlane(back_plane) RBox.addPlane(left_plane) RBox.addPlane(right_plane) G.generatePacking(RBox, NT, 0) # NT.tagParticlesAlongPlane(bottom_plane,0.5,4,0) NT.tagParticlesAlongPlane(bottom_plane,yt,4,0) def generate_granular_gouge(NT, G, Pmin, Pmax, grmin, grmax, gntry): T_aux = MNTable3D (Pmin, Pmax, 2.1*grmax, 1) G_aux = InsertGenerator3D (grmin, grmax, gntry, 1000, 1.0e-5) V_aux = BoxWithPlanes3D (Pmin, Pmax) G_aux.generatePacking(V_aux, T_aux, 0) sphere_list = T_aux.getSphereListFromGroup(0) ngr = len(sphere_list) NT.GrowNGroups(1+ngr) ggid = 1 for ss in sphere_list: S = SphereVol(ss.Centre(), ss.Radius()) G.generatePacking(S,NT,ggid) NT.generateBonds(ggid,1.0e-5,1) ggid += 1 GenGeo-1.2/examples/hlayer_example.py0000644000000000000000000000425012533740504016041 0ustar 00000000000000############################################################# ## ## ## Copyright (c) 2007-2014 by The University of Queensland ## ## Centre for Geoscience Computing ## ## http://earth.uq.edu.au/centre-geoscience-computing ## ## ## ## Primary Business: Brisbane, Queensland, Australia ## ## Licensed under the Open Software License version 3.0 ## ## http://www.opensource.org/licenses/osl-3.0.php ## ## ## ############################################################# from gengeo import * xsize=50.0 ysize=50.0 ysize_cl=10.0 ntry=1000 rmin_nb=0.2 rmin_b=0.2 pbond=0.5 y_bdry_1=0.5*(ysize-ysize_cl) y_bdry_2=ysize-y_bdry_1 T = MNTable2D(Vector3(0.0,0.0,0.0),Vector3(xsize,ysize,0.0),2.5,1) GB = InsertGenerator2D(rmin_b,1.0,ntry,1000,1e-6) GNB = InsertGenerator2D(rmin_nb,1.0,ntry,1000,1e-6) CenterBox = BoxWithLines2D (Vector3(0.0,y_bdry_1,0.0),Vector3(xsize,y_bdry_2,0.0)) CenterBox.addLine(Line2D(Vector3(0.0,y_bdry_1,0.0),Vector3(0.0,y_bdry_2,0.0))) CenterBox.addLine(Line2D(Vector3(xsize,y_bdry_1,0.0),Vector3(xsize,y_bdry_2,0.0))) CenterBox.addLine(Line2D(Vector3(0.0,y_bdry_1,0.0),Vector3(xsize,y_bdry_1,0.0))) CenterBox.addLine(Line2D(Vector3(0.0,y_bdry_2,0.0),Vector3(xsize,y_bdry_2,0.0))) GB.generatePacking(CenterBox,T,0,1) T.generateRandomBonds(0,1e-5,pbond,0,1,0) BottomBox = BoxWithLines2D (Vector3(0.0,0.0,0.0),Vector3(xsize,y_bdry_1+0.5,0.0)) BottomBox.addLine(Line2D(Vector3(0.0,0.0,0.0),Vector3(0.0,y_bdry_1,0.0))) BottomBox.addLine(Line2D(Vector3(xsize,0.0,0.0),Vector3(xsize,y_bdry_1,0.0))) BottomBox.addLine(Line2D(Vector3(0.0,0.0,0.0),Vector3(xsize,0.0,0.0))) GNB.generatePacking(BottomBox,T,0,2) TopBox = BoxWithLines2D (Vector3(0.0,y_bdry_2-0.5,0.0),Vector3(xsize,ysize,0.0)) TopBox.addLine(Line2D(Vector3(0.0,y_bdry_2,0.0),Vector3(0.0,ysize,0.0))) TopBox.addLine(Line2D(Vector3(xsize,y_bdry_2,0.0),Vector3(xsize,ysize,0.0))) TopBox.addLine(Line2D(Vector3(0.0,ysize,0.0),Vector3(xsize,ysize,0.0))) GNB.generatePacking(TopBox,T,0,3) T.write("temp/geo_hlayer.vtu",2) GenGeo-1.2/examples/jointed_box_file.py0000644000000000000000000000477412533740504016360 0ustar 00000000000000############################################################# ## ## ## Copyright (c) 2007-2014 by The University of Queensland ## ## Centre for Geoscience Computing ## ## http://earth.uq.edu.au/centre-geoscience-computing ## ## ## ## Primary Business: Brisbane, Queensland, Australia ## ## Licensed under the Open Software License version 3.0 ## ## http://www.opensource.org/licenses/osl-3.0.php ## ## ## ############################################################# from __future__ import print_function from gengeo import * from read_jointset import * import sys # An example python script to generate a bonded rectangular prism, # import joint sets and tag bonds crossing joints # takes file name of joint set as an argument # particle properties minRadius = 0.2 maxRadius = 1.0 #set up joint set joints=TriPatchSet() # read joints from file readJointFileTagSet(joints,sys.argv[1]) # output bounding box of joint set print("Bounding Box of Joint Set: " , joints.getMinPoint(), joints.getMaxPoint()) # Define region extremities using the bounding box of the joint set minPoint = joints.getMinPoint()-Vector3(1.0,1.0,1.0) maxPoint = joints.getMaxPoint()-Vector3(1.0,1.0,1.0) # Define the volume to be filled with spheres: box = BoxWithPlanes3D ( minPoint = minPoint, maxPoint = maxPoint ) # boundary planes box.addPlane(Plane(minPoint,Vector3(1.0,0.0,0.0))) box.addPlane(Plane(minPoint, Vector3(0.0,1.0,0.0))) box.addPlane(Plane(minPoint, Vector3(0.0,0.0,1.0))) box.addPlane(Plane(maxPoint, Vector3(-1.0,0.0,0.0))) box.addPlane(Plane(maxPoint, Vector3(0.0,-1.0,0.0))) box.addPlane(Plane(maxPoint, Vector3(0.0,0.0,-1.0))) # Create a multi-group neighbour table to contain the particles: mntable = MNTable3D ( minPoint = minPoint, maxPoint = maxPoint, gridSize = 2.5*maxRadius ) # Fill the volume with particles: packer = InsertGenerator3D ( minRadius = minRadius, maxRadius = maxRadius, insertFails = 1000, maxIterations = 1000, tolerance = 1.0e-6, seed=42 ) packer.generatePacking( volume = box, ntable = mntable, tag = 2 ) #bonding tol=1.0e-5 basetag=1 # tag for the "normal" bonds mntable.generateBondsWithJointSet(joints,0,tol,basetag) # write a geometry and a VTK file mntable.write("temp/box_"+str(maxRadius)+".geo",1) mntable.write("temp/box_"+str(maxRadius)+".vtu",2) GenGeo-1.2/examples/layered_example.py0000644000000000000000000001061412533740504016203 0ustar 00000000000000############################################################# ## ## ## Copyright (c) 2007-2014 by The University of Queensland ## ## Centre for Geoscience Computing ## ## http://earth.uq.edu.au/centre-geoscience-computing ## ## ## ## Primary Business: Brisbane, Queensland, Australia ## ## Licensed under the Open Software License version 3.0 ## ## http://www.opensource.org/licenses/osl-3.0.php ## ## ## ############################################################# from __future__ import division from gengeo import * size = 50.0 ntry = 1000 rmin_sand = 0.5 rmin_clay = 0.2 rmax_clay = 0.5 sand_layer_thickness = 0.425*size clay_layer_thickness = 0.15*size center_box_dim = 0.05*size mntable = CircMNTable2D (Vector3(0,0,0), Vector3(size,size,0),2.5,1) sand_packer = HexAggregateInsertGenerator2D (rmin_sand, 1.0, ntry, 1000, 1.0e-6) clay_packer = InsertGenerator2D(rmin_clay, rmax_clay, ntry, 1000, 1.0e-6) clay_layer_min=sand_layer_thickness clay_layer_max=clay_layer_min+clay_layer_thickness clay_box_min = clay_layer_min - rmax_clay clay_box_max = clay_layer_max + rmax_clay ClayBox = BoxWithLines2D(Vector3(clay_layer_min,0.0,0.0),Vector3(clay_layer_max,size,0.0)) ClayBox.addLine(Line2D(Vector3(clay_layer_min,0.0,0.0),Vector3(clay_layer_max,0.0,0.0))) ClayBox.addLine(Line2D(Vector3(clay_layer_max,size,0.0),Vector3(clay_layer_min,size,0.0))) ClayBox.addLine(Line2D(Vector3(clay_layer_max,size,0.0),Vector3(clay_layer_max,0.0,0.0))) ClayBox.addLine(Line2D(Vector3(clay_layer_min,size,0.0),Vector3(clay_layer_max,size,0.0))) clay_packer.generatePacking(ClayBox,mntable,0,2) cbox_layer_minx=sand_layer_thickness-center_box_dim cbox_layer_maxx=sand_layer_thickness+clay_layer_thickness+center_box_dim cbox_layer_miny=0.5*size-center_box_dim cbox_layer_maxy=0.5*size+center_box_dim CenterBox = BoxWithLines2D(Vector3(cbox_layer_minx,cbox_layer_miny,0.0), Vector3(cbox_layer_maxx,cbox_layer_maxy,0.0)) CenterBox.addLine(Line2D(Vector3(cbox_layer_minx,cbox_layer_miny,0.0), Vector3(cbox_layer_maxx,cbox_layer_miny,0.0))) CenterBox.addLine(Line2D(Vector3(cbox_layer_maxx,cbox_layer_maxy,0.0), Vector3(cbox_layer_minx,cbox_layer_maxy,0.0))) CenterBox.addLine(Line2D(Vector3(cbox_layer_maxx,cbox_layer_maxy,0.0), Vector3(cbox_layer_maxx,cbox_layer_miny,0.0))) CenterBox.addLine(Line2D(Vector3(cbox_layer_minx,cbox_layer_maxy,0.0), Vector3(cbox_layer_maxx,cbox_layer_maxy,0.0))) clay_packer.generatePacking(CenterBox,mntable,0,2) sand_layer_min1=0 sand_layer_max1=sand_layer_thickness sand_box_min1=sand_layer_min1-rmin_sand sand_box_max1=sand_layer_max1+rmin_sand SandBox1 = BoxWithLines2D(Vector3(sand_box_min1,0.0,0.0),Vector3(sand_box_max1,size,0.0)) SandBox1.addLine(Line2D(Vector3(sand_layer_min1,size,0.0),Vector3(sand_layer_min1,0.0,0.0))) SandBox1.addLine(Line2D(Vector3(sand_layer_min1,0.0,0.0),Vector3(sand_layer_max1,0.0,0.0))) SandBox1.addLine(Line2D(Vector3(sand_layer_max1,size,0.0),Vector3(sand_layer_max1,0.0,0.0))) SandBox1.addLine(Line2D(Vector3(sand_layer_min1,size,0.0),Vector3(sand_layer_max1,size,0.0))) SandBox1.addLine(Line2D(Vector3(0.0,size/2.0,0.0),Vector3(size,size/2.0,0.0))) sand_packer.generatePacking(SandBox1,mntable,0,1) sand_layer_min2=sand_layer_thickness+clay_layer_thickness sand_layer_max2=size sand_box_min2=sand_layer_min2-rmin_sand sand_box_max2=sand_layer_max2+rmin_sand SandBox2 = BoxWithLines2D(Vector3(sand_box_min2,0.0,0.0),Vector3(sand_box_max2,size,0.0)) SandBox2.addLine(Line2D(Vector3(sand_layer_min2,size,0.0),Vector3(sand_layer_min2,0.0,0.0))) SandBox2.addLine(Line2D(Vector3(sand_layer_min2,0.0,0.0),Vector3(sand_layer_max2,0.0,0.0))) SandBox2.addLine(Line2D(Vector3(sand_layer_max2,size,0.0),Vector3(sand_layer_max2,0.0,0.0))) SandBox2.addLine(Line2D(Vector3(sand_layer_min2,size,0.0),Vector3(sand_layer_max2,size,0.0))) SandBox2.addLine(Line2D(Vector3(0.0,size/2.0,0.0),Vector3(size,size/2.0,0.0))) sand_packer.generatePacking(SandBox2,mntable,0,1) mntable.generateBondsWithMask(0,1.0e-6,0,1,1) top_line = Line2D(Vector3(0.0,size,0.0),Vector3(size,size,0.0)) bottom_line = Line2D(Vector3(0.0,0.0,0.0),Vector3(size,0.0,0.0)) mntable.tagParticlesAlongLineWithMask(top_line,0.5,4,4,0) mntable.tagParticlesAlongLineWithMask(bottom_line,0.5,8,8,0) mntable.write("temp/geo_layered.vtu",2) GenGeo-1.2/examples/runAll.sh0000755000000000000000000000177712533740504014277 0ustar 00000000000000#!/bin/bash mkdir temp python gengeo_example1.py >& temp/ex1_output.txt python gengeo_example2.py >& temp/ex2_output.txt python gengeo_example3.py >& temp/ex3_output.txt python gengeo_example4.py >& temp/ex4_output.txt python gengeo_example5.py >& temp/ex5_output.txt python gengeo_example6.py >& temp/ex6_output.txt python gengeo_example7.py >& temp/ex7_output.txt python gengeo_example8.py >& temp/ex8_output.txt python gengeo_example9.py >& temp/ex9_output.txt python gengeo_example10.py >& temp/ex10_output.txt python gengeo_example11.py >& temp/ex11_output.txt python gengeo_exampleShapeList.py >& temp/ex12_output.txt python gengeo_obstructed_flow.py >& temp/ex13_output.txt python gengeo_polygon.py >& temp/ex14_output.txt python gengeo_crack.py >& temp/ex15_output.txt python gengeo_DFN.py >& temp/ex16_output.txt python gengeo_test_cluster.py >& temp/ex17_output.txt python gouge_example.py >& temp/ex18_output.txt python hlayer_example.py >& temp/ex19_output.txt python layered_example.py >& temp/ex20_output.txt GenGeo-1.2/examples/shapeDatabase.db0000644000000000000000000000025412533740504015524 0ustar 00000000000000 name="sphere", sphereList = [ (0,0,0,1) ] bondList = [ ] name="test", sphereList = [ (0,0,0.5,0.5), (0,0,-0.5,0.5) ] bondList = [ (0,1) ] GenGeo-1.2/geometry/AGeometricObject.h0000644000000000000000000000164712533740504016033 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __AGEOMETRICOBJECT_H #define __AGEOMETRICOBJECT_H #include "util/vector3.h" class AGeometricObject { protected: public: virtual ~AGeometricObject(){}; virtual double getDist(const Vector3&) const=0; }; #endif// __AGEOMETRICOBJECT_H GenGeo-1.2/geometry/Cylinder.cc0000644000000000000000000000302612533740504014565 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "Cylinder.h" Cylinder::Cylinder() { } Cylinder::Cylinder(const Vector3& c,const Vector3& axis,double r) { m_c=c; m_axis=axis; m_r=r; } /*! Get distance between a point and a cylindical surface. The function returns the _absolute_ distance, i.e. the result is always positive. \param P the point */ double Cylinder::getDist(const Vector3& P) const { Vector3 v1=P-m_c; double d=m_axis*v1; return fabs(m_r-(v1-d*m_axis).norm()); } /*! Get distance between a point and a cylindical surface. The function returns the directed distance assuming an inward facing surface normal, i.e. the result is positive if the point is inside the cylinder and negative if it is outside. \param P the point */ double Cylinder::getDirDist(const Vector3& P) const { Vector3 v1=P-m_c; double d=m_axis*v1; return m_r-(v1-d*m_axis).norm(); } GenGeo-1.2/geometry/Cylinder.h0000644000000000000000000000241112533740504014424 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __CYLINDER_H #define __CYLINDER_H //-- project includes -- #include "util/vector3.h" // --- project includes --- #include "AGeometricObject.h" class Cylinder : public AGeometricObject { private: Vector3 m_c; Vector3 m_axis; double m_r; public: Cylinder(); Cylinder(const Vector3&,const Vector3&,double); ~Cylinder(){}; virtual double getDirDist(const Vector3&) const; virtual double getDist(const Vector3&) const; double getRadius() const {return m_r;}; Vector3 getBasePoint() const {return m_c;}; Vector3 getAxis() const {return m_axis;}; }; #endif // __CYLINDER_H GenGeo-1.2/geometry/Line2D.cc0000644000000000000000000000403112533740504014066 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "Line2D.h" //-- system includes -- #include using std::fabs; /*! default constructor -> zero all data */ Line2D::Line2D() {} /*! Construct a line from 2 points. The order of the points determines the direction of the normal. \param p1 1st point \param p2 2nd point \warning doesn't check p1!=p2 */ Line2D::Line2D(const Vector3& p1,const Vector3& p2) { m_p1=p1; m_p2=p2; Vector3 r=(m_p2-m_p1).unit(); m_normal=(Vector3(r.Y(),-1.0*r.X(),0.0)).unit(); } /*! Calculate the intersection with another line. \param L the other line */ Vector3 Line2D::intersect(const Line2D& L) { Vector3 r0=m_p2-m_p1; Vector3 r1=L.m_p2-L.m_p1; Vector3 d=L.m_p1-m_p1; double c1=r0.Y()*r1.X()-r0.X()*r1.Y(); double c2=d.Y()*r0.X()-d.X()*r0.Y(); return L.m_p1+(c2/c1)*r1; } /*! Construct a line parallel to the current line at a given distance. The direction of the normal determines on which side the parallel is constructed. \param d the distance */ Line2D Line2D::parallel(double d) { Vector3 p1=m_p1+d*m_normal; Vector3 p2=m_p2+d*m_normal; return Line2D(p1,p2); } /*! Get the distance of a point from the line \param p the point */ double Line2D::getDist(const Vector3& p) const { return fabs((p-m_p1)*m_normal); } ostream& operator<< (ostream& ost, const Line2D& L) { ost << L.m_p1 << " to " << L.m_p2; return ost; } GenGeo-1.2/geometry/Line2D.h0000644000000000000000000000251412533740504013734 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __LINE2D_H #define __LINE2D_H // --- Project includes --- #include "util/vector3.h" #include "AGeometricObject.h" // --- IO includes --- #include using std::ostream; /*! \brief class for a line in 2D */ class Line2D : public AGeometricObject { protected: Vector3 m_p1,m_p2; Vector3 m_normal; public: Line2D(); Line2D(const Vector3&,const Vector3&); Vector3 intersect(const Line2D&); Line2D parallel(double); virtual double getDist(const Vector3&) const; Vector3 getOrig() const {return m_p1;}; Vector3 getNormal() const {return m_normal;}; friend ostream& operator<< (ostream&, const Line2D&); }; #endif // __LINE2D_H GenGeo-1.2/geometry/LineSegment.h0000644000000000000000000000213212533740504015065 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __LINESEGMENT2D_H #define __LINESEGMENT2D_H // --- Project includes --- ##include "Line.h" /*! \brief class for a line in 2D */ class LineSegment2D : public Line2D { public: LineSegment2D(); LineSegment2D(const Vector3&,const Vector3&); virtual ~LineSegment2D(); virtual double getDist(const Vector3&) const; friend ostream& operator<< (ostream&, const LineSegment2D&); }; #endif // __LINESEGMENT2D_H GenGeo-1.2/geometry/LineSegment2D.cc0000644000000000000000000000335712533740504015423 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "LineSegment2D.h" // -- system includes -- #include using std::fabs; /*! default constructor -> zero all data */ LineSegment2D::LineSegment2D() : Line2D() {} /*! Construct a line segment from 2 points. The order of the points determines the direction of the normal. \param p1 1st point \param p2 2nd point \warning doesn't check p1!=p2 */ LineSegment2D::LineSegment2D(const Vector3& p1,const Vector3& p2) : Line2D(p1,p2) {} /*! Get the distance of a point from the line segment \param p the point */ double LineSegment2D::getDist(const Vector3& p) const { double res; double du=(p-m_p1)*((m_p2-m_p1).unit()); if((0<=du) && (du <=(m_p2-m_p1).norm())){// nearest point inside segment res=fabs((p-m_p1)*m_normal); } else { // nearest point outside -> get distance to closest endpoint double d1=(p-m_p1).norm(); double d2=(p-m_p2).norm(); res = (d1 using std::fabs; Plane::Plane() { m_p=Vector3(0.0,0.0,0.0); m_normal=Vector3(1.0,0.0,0.0); } /*! construct plane from origin and normal \param orig a point within the plane \param normal the normal of the plane (will be normalized) */ Plane::Plane(const Vector3& orig,const Vector3& normal) { m_p=orig; m_normal=normal.unit(); } /*! Get the distance of a point from the line \param p the point */ double Plane::getDist(const Vector3& p) const { return fabs((p-m_p)*m_normal); } ostream& operator<< (ostream& ost, const Plane& P) { ost << P.m_p << "-" << P.m_normal; return ost; } GenGeo-1.2/geometry/Plane.h0000644000000000000000000000236112533740504013716 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __PLANE_H #define __PLANE_H // --- Project includes --- #include "util/vector3.h" #include "AGeometricObject.h" // --- IO includes --- #include using std::ostream; /*! \brief class for a plane in 3D */ class Plane : public AGeometricObject { private: Vector3 m_p,m_normal; public: Plane(); Plane(const Vector3&,const Vector3&); virtual double getDist(const Vector3&) const; Vector3 getOrig() const {return m_p;}; Vector3 getNormal() const {return m_normal;}; friend ostream& operator<< (ostream&, const Plane&); }; #endif // __PLANE_H GenGeo-1.2/geometry/Sphere.cc0000644000000000000000000000445612533740504014252 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "Sphere.h" // --- System includes --- #include using std::sqrt; double Sphere::NearZero=1e-8; int Sphere::s_output_style=0; unsigned int Sphere::s_current_id=0; /*! construct "invalid" Sphere */ Sphere::Sphere() { m_valid=false; m_id=0; m_tag=0; } /*! construct valid Sphere \param center the center of the circle \param rad the radius */ Sphere::Sphere(const Vector3& center,double rad) { m_center=center; m_rad=rad; m_valid=true; m_id=Sphere::s_current_id; Sphere::s_current_id++; m_tag=0; } /*! copy constructor \param S the original */ Sphere::Sphere(const Sphere& S) { m_center=S.m_center; m_rad=S.m_rad; m_valid=S.m_valid; m_id=S.m_id; m_tag=S.m_tag; } /*! get distance between given point and the surface of the Sphere \param P the point */ double Sphere::getDist(const Vector3& P) const { return (P-m_center).norm()-m_rad; } /*! Set id of sphere. If higher than current_id, increase current_id accordingly \param i the new id of the sphere */ void Sphere::setId(int i) { m_id=i; if(i>s_current_id) { s_current_id=i; } } /*! Set output style \param style the output style: 0=Debug, 1=.geo */ void Sphere::SetOutputStyle(int style) { Sphere::s_output_style=style; } ostream& operator << (ostream& ost, const Sphere& S) { if(Sphere::s_output_style==0){ if(S.m_valid){ ost << S.m_center << " | " << S.m_rad << " | " << S.m_id; } else { ost << "invalid Sphere"; } } else if (Sphere::s_output_style==1){ if(S.m_valid){ ost << S.m_center << " " << S.m_rad << " " << S.m_id << " " << S.m_tag; } } return ost; } GenGeo-1.2/geometry/Sphere.h0000644000000000000000000000341512533740504014106 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __SPHERE_H #define __SPHERE_H //-- project includes -- #include "util/vector3.h" // --- IO includes --- #include using std::ostream; // --- project includes --- #include "AGeometricObject.h" /*! \class Sphere \brief Simple sphere implementation. Works both 2D and 3D */ class Sphere : public AGeometricObject { protected: Vector3 m_center; double m_rad; int m_id; int m_tag; bool m_valid; static double NearZero; static int s_output_style; static unsigned int s_current_id; public: // constructors Sphere(); Sphere(const Vector3&,double); Sphere(const Sphere&); // access ops and the like virtual double getDist(const Vector3&) const; inline Vector3 Center() const {return m_center;}; inline double Radius() const {return m_rad;}; inline int Id() const {return m_id;}; inline int Tag() const {return m_tag;}; void setTag(int t){m_tag=t;}; void setId(int); // move it void shift(const Vector3& s){m_center+=s;}; // output static void SetOutputStyle(int); friend ostream& operator << (ostream&,const Sphere&); } ; #endif // __SPHERE_H GenGeo-1.2/geometry/SphereIn.cc0000644000000000000000000000264312533740504014535 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "SphereIn.h" SphereIn::SphereIn():Sphere() {} SphereIn::SphereIn(const Vector3& V,double r): Sphere(V,r) {} /*! Get distance between a point and a cylindical surface. The function returns the _absolute_ distance, i.e. the result is always positive. \param P the point */ double SphereIn::getDist(const Vector3& P) const { return fabs(m_rad-(P-m_center).norm()); } /*! Get distance between a point and a cylindical surface. The function returns the directed distance assuming an inward facing surface normal, i.e. the result is positive if the point is inside the cylinder and negative if it is outside. \param P the point */ double SphereIn::getDirDist(const Vector3& P) const { return m_rad-(P-m_center).norm(); } GenGeo-1.2/geometry/SphereIn.h0000644000000000000000000000203312533740504014370 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __SPHERE_IN_H #define __SPHERE_IN_H //--- project includes --- #include "util/vector3.h" //--- project includes --- #include "Sphere.h" class SphereIn : public Sphere { public: SphereIn(); SphereIn(const Vector3&,double); virtual double getDist(const Vector3&) const; virtual double getDirDist(const Vector3&) const; }; #endif // __SPHERE_IN_H GenGeo-1.2/geometry/Torus.cc0000644000000000000000000000246012533740504014131 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "Torus.h" // --- system includes --- #include using std::sqrt; /*! \param c base point \param axis axis through the middle of the torus \param r1 outer radius \param r2 inner (tube) radius \param inside calc distance inside/outside */ Torus::Torus(const Vector3& c,const Vector3& axis,double r1,double r2,bool inside) { m_c=c; m_axis=axis.unit();; m_r1=r1; m_r2=r2; m_inside=inside; } double Torus::getDist(const Vector3& P) const { Vector3 p0=(P-m_c); double h=m_axis*p0; double e=(p0-h*m_axis).norm(); double res=sqrt((m_r1-e)*(m_r1-e)+h*h)-m_r2; if(m_inside) res=-1.0*res; return res; } GenGeo-1.2/geometry/Torus.h0000644000000000000000000000243212533740504013772 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __TORUS_H #define __TORUS_H //-- project includes -- #include "util/vector3.h" // --- project includes --- #include "AGeometricObject.h" class Torus : public AGeometricObject { private: Vector3 m_c; Vector3 m_axis; double m_r1,m_r2; bool m_inside; public: Torus(const Vector3&,const Vector3&,double,double,bool); Torus(){}; ~Torus(){}; virtual double getDist(const Vector3&) const; double getInnerRadius() const {return m_r1;}; double getOuterRadius() const {return m_r2;}; Vector3 getBasePoint() const {return m_c;}; Vector3 getAxis() const {return m_axis;}; }; #endif //__TORUS_H GenGeo-1.2/geometry/Triangle3D.cc0000644000000000000000000001210012533740504014741 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "Triangle3D.h" #include #include using std::pair; using std::make_pair; /* modified 3x3 equation system solver - only 2 components needed */ pair rsolve(Vector3& v1,Vector3& v2,Vector3& v3,Vector3& rhs) { double det1,detx,dety; det1=v1.X()*(v2.Y()*v3.Z()-v3.Y()*v2.Z())+v2.X()*(v3.Y()*v1.Z()-v1.Y()*v3.Z())+v3.X()*(v1.Y()*v2.Z()-v2.Y()*v1.Z()); detx=rhs.X()*(v2.Y()*v3.Z()-v3.Y()*v2.Z())+v2.X()*(v3.Y()*rhs.Z()-rhs.Y()*v3.Z())+v3.X()*(rhs.Y()*v2.Z()-v2.Y()*rhs.Z()); dety=v1.X()*(rhs.Y()*v3.Z()-v3.Y()*rhs.Z())+rhs.X()*(v3.Y()*v1.Z()-v1.Y()*v3.Z())+v3.X()*(v1.Y()*rhs.Z()-rhs.Y()*v1.Z()); double x=detx/det1; double y=dety/det1; return make_pair(x,y); } Triangle3D::Triangle3D(const Vector3& p1,const Vector3& p2,const Vector3& p3, int tag) :m_p1(p1),m_p2(p2),m_p3(p3),m_tag(tag) {} /*! check if line between 2 points intersects the triangle \param p1 point 1 \param p2 point 2 */ bool Triangle3D::crosses(const Vector3& p1, const Vector3& p2) const { bool res=false; //-- check if points on same side of plane Vector3 plane_normal=cross((m_p2-m_p1),(m_p3-m_p1)); //std::cout << "normal: " << plane_normal << std::endl; double d1=plane_normal*(p1-m_p1); double d2=plane_normal*(p2-m_p1); //std::cout << "d1,d2 " << d1 << " / " << d2 << std::endl; if(d1*d2<0.0){ // sign(d1)!=sign(d2) -> different sides Vector3 v1=m_p2-m_p1; Vector3 v2=m_p3-m_p1; Vector3 v3=p2-p1; Vector3 rhs=p1-m_p1; pair p=rsolve(v1,v2,v3,rhs); res=((p.first>=0.0) && (p.first<=1.0) && (p.second>=0.0) && (p.second<=1.0) && (p.first+p.second<=1.0)); } return res; } /*! get minimum corner of the bounding box */ Vector3 Triangle3D::getMinPoint() const { double xmin=(m_p1.x() < m_p2.x()) ? m_p1.x() : m_p2.x(); xmin = (xmin < m_p3.x()) ? xmin : m_p3.x(); double ymin=(m_p1.y() < m_p2.y()) ? m_p1.y() : m_p2.y(); ymin = (ymin < m_p3.y()) ? ymin : m_p3.y(); double zmin=(m_p1.z() < m_p2.z()) ? m_p1.z() : m_p2.z(); zmin = (zmin < m_p3.z()) ? zmin : m_p3.z(); return Vector3(xmin,ymin,zmin); } /*! get maximum corner of the bounding box */ Vector3 Triangle3D::getMaxPoint() const { double xmax=(m_p1.x() > m_p2.x()) ? m_p1.x() : m_p2.x(); xmax = (xmax > m_p3.x()) ? xmax : m_p3.x(); double ymax=(m_p1.y() > m_p2.y()) ? m_p1.y() : m_p2.y(); ymax = (ymax > m_p3.y()) ? ymax : m_p3.y(); double zmax=(m_p1.z() > m_p2.z()) ? m_p1.z() : m_p2.z(); zmax = (zmax > m_p3.z()) ? zmax : m_p3.z(); return Vector3(xmax,ymax,zmax); } /* local helper function to calculate dist between line segment and point */ double EdgeSep(const Vector3& p0,const Vector3& p1,const Vector3& p) { double sep; Vector3 v=p1-p0; Vector3 vu=v.unit(); double d=((p-p0)*vu); if((d>0.0)&(d cp=rsolve(v2,v1,normal,rhs); if((cp.first>=0.0) && (cp.first<=1.0) && (cp.second>=0.0) && (cp.second<=1.0) && (cp.first+cp.second<=1.0)){ // point inside dist=fabs((p-m_p1)*normal); } else { // need to check distance to edges/corners double d1=EdgeSep(m_p1,m_p2,p); double d2=EdgeSep(m_p1,m_p3,p); double d3=EdgeSep(m_p2,m_p3,p); // find the minimum separation != -1 (messy) if(d1>0.0){ if(d2>0.0){ dist=(d10.0){ dist=(d30){ dist=(d10){ if (d3>0){ dist=(d2 get corner dist d1=(p-m_p1).norm(); d2=(p-m_p2).norm(); d3=(p-m_p3).norm(); dist=(d1 # # This program 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. # # Additional permission under section 7 of the GNU General Public # License, version 3 ("GPLv3"): # # If you convey this file as part of a work that contains a # configuration script generated by Autoconf, you may do so under # terms of your choice. # # This program 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 this program. If not, see . ############# CHANGES FOR GENGEO (search for GENGEO for details) ############# # * order changed of search directories for libraries - /usr/lib is now first # * boost_system always linked with boost_filesystem for newer boost versions # * option to allow specifying name (e.g. boost_python3) for a Boost library # * order changed when searching for Boost library names, to speed up search # * name of Python configuration file altered for Python 3 naming conventions # * search for a Boost library omits system paths when user provides location # * search for a Boost library checks version before testing compatibility # * test added for the Python suffix "-pyXY" in the name of a Boost library # * Search for a Boost library includes multiarch names in a search path m4_define([_BOOST_SERIAL], [m4_translit([ # serial 22 ], [# ], [])]) # Original sources can be found at http://github.com/tsuna/boost.m4 # You can fetch the latest version of the script by doing: # wget http://github.com/tsuna/boost.m4/raw/master/build-aux/boost.m4 # ------ # # README # # ------ # # This file provides several macros to use the various Boost libraries. # The first macro is BOOST_REQUIRE. It will simply check if it's possible to # find the Boost headers of a given (optional) minimum version and it will # define BOOST_CPPFLAGS accordingly. It will add an option --with-boost to # your configure so that users can specify non standard locations. # If the user's environment contains BOOST_ROOT and --with-boost was not # specified, --with-boost=$BOOST_ROOT is implicitly used. # For more README and documentation, go to http://github.com/tsuna/boost.m4 # Note: THESE MACROS ASSUME THAT YOU USE LIBTOOL. If you don't, don't worry, # simply read the README, it will show you what to do step by step. m4_pattern_forbid([^_?(BOOST|Boost)_]) # _BOOST_SED_CPP(SED-PROGRAM, PROGRAM, # [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # -------------------------------------------------------- # Same as AC_EGREP_CPP, but leave the result in conftest.i. # # SED-PROGRAM is *not* overquoted, as in AC_EGREP_CPP. It is expanded # in double-quotes, so escape your double quotes. # # It could be useful to turn this into a macro which extracts the # value of any macro. m4_define([_BOOST_SED_CPP], [AC_LANG_PUSH([C++])dnl AC_LANG_PREPROC_REQUIRE()dnl AC_REQUIRE([AC_PROG_SED])dnl AC_LANG_CONFTEST([AC_LANG_SOURCE([[$2]])]) AS_IF([dnl eval is necessary to expand ac_cpp. dnl Ultrix and Pyramid sh refuse to redirect output of eval, so use subshell. dnl Beware of Windows end-of-lines, for instance if we are running dnl some Windows programs under Wine. In that case, boost/version.hpp dnl is certainly using "\r\n", but the regular Unix shell will only dnl strip `\n' with backquotes, not the `\r'. This results in dnl boost_cv_lib_version='1_37\r' for instance, which breaks dnl everything else. dnl Cannot use 'dnl' after [$4] because a trailing dnl may break AC_CACHE_CHECK (eval "$ac_cpp conftest.$ac_ext") 2>&AS_MESSAGE_LOG_FD | tr -d '\r' | $SED -n -e "$1" >conftest.i 2>&1], [$3], [$4]) rm -rf conftest* AC_LANG_POP([C++])dnl ])# _BOOST_SED_CPP # BOOST_REQUIRE([VERSION], [ACTION-IF-NOT-FOUND]) # ----------------------------------------------- # Look for Boost. If version is given, it must either be a literal of the form # "X.Y.Z" where X, Y and Z are integers (the ".Z" part being optional) or a # variable "$var". # Defines the value BOOST_CPPFLAGS. This macro only checks for headers with # the required version, it does not check for any of the Boost libraries. # On # success, defines HAVE_BOOST. On failure, calls the optional # ACTION-IF-NOT-FOUND action if one was supplied. # Otherwise aborts with an error message. AC_DEFUN([BOOST_REQUIRE], [AC_REQUIRE([AC_PROG_CXX])dnl AC_REQUIRE([AC_PROG_GREP])dnl echo "$as_me: this is boost.m4[]_BOOST_SERIAL" >&AS_MESSAGE_LOG_FD boost_save_IFS=$IFS boost_version_req=$1 IFS=. set x $boost_version_req 0 0 0 IFS=$boost_save_IFS shift boost_version_req=`expr "$[1]" '*' 100000 + "$[2]" '*' 100 + "$[3]"` boost_version_req_string=$[1].$[2].$[3] AC_ARG_WITH([boost], [AS_HELP_STRING([--with-boost=DIR], [prefix of Boost $1 @<:@guess@:>@])])dnl AC_ARG_VAR([BOOST_ROOT],[Location of Boost installation])dnl # If BOOST_ROOT is set and the user has not provided a value to # --with-boost, then treat BOOST_ROOT as if it the user supplied it. if test x"$BOOST_ROOT" != x; then if test x"$with_boost" = x; then AC_MSG_NOTICE([Detected BOOST_ROOT; continuing with --with-boost=$BOOST_ROOT]) with_boost=$BOOST_ROOT else AC_MSG_NOTICE([Detected BOOST_ROOT=$BOOST_ROOT, but overridden by --with-boost=$with_boost]) fi fi AC_SUBST([DISTCHECK_CONFIGURE_FLAGS], ["$DISTCHECK_CONFIGURE_FLAGS '--with-boost=$with_boost'"])dnl boost_save_CPPFLAGS=$CPPFLAGS AC_CACHE_CHECK([for Boost headers version >= $boost_version_req_string], [boost_cv_inc_path], [boost_cv_inc_path=no AC_LANG_PUSH([C++])dnl m4_pattern_allow([^BOOST_VERSION$])dnl AC_LANG_CONFTEST([AC_LANG_PROGRAM([[#include #if !defined BOOST_VERSION # error BOOST_VERSION is not defined #elif BOOST_VERSION < $boost_version_req # error Boost headers version < $boost_version_req #endif ]])]) # If the user provided a value to --with-boost, use it and only it. case $with_boost in #( ''|yes) set x '' /opt/local/include /usr/local/include /opt/include \ /usr/include C:/Boost/include;; #( *) set x "$with_boost/include" "$with_boost";; esac shift for boost_dir do # Without --layout=system, Boost (or at least some versions) installs # itself in /include/boost-. This inner loop helps to # find headers in such directories. # # Any ${boost_dir}/boost-x_xx directories are searched in reverse version # order followed by ${boost_dir}. The final '.' is a sentinel for # searching $boost_dir" itself. Entries are whitespace separated. # # I didn't indent this loop on purpose (to avoid over-indented code) boost_layout_system_search_list=`cd "$boost_dir" 2>/dev/null \ && ls -1 | "${GREP}" '^boost-' | sort -rn -t- -k2 \ && echo .` for boost_inc in $boost_layout_system_search_list do if test x"$boost_inc" != x.; then boost_inc="$boost_dir/$boost_inc" else boost_inc="$boost_dir" # Uses sentinel in boost_layout_system_search_list fi if test x"$boost_inc" != x; then # We are going to check whether the version of Boost installed # in $boost_inc is usable by running a compilation that # #includes it. But if we pass a -I/some/path in which Boost # is not installed, the compiler will just skip this -I and # use other locations (either from CPPFLAGS, or from its list # of system include directories). As a result we would use # header installed on the machine instead of the /some/path # specified by the user. So in that precise case (trying # $boost_inc), make sure the version.hpp exists. # # Use test -e as there can be symlinks. test -e "$boost_inc/boost/version.hpp" || continue CPPFLAGS="$CPPFLAGS -I$boost_inc" fi AC_COMPILE_IFELSE([], [boost_cv_inc_path=yes], [boost_cv_version=no]) if test x"$boost_cv_inc_path" = xyes; then if test x"$boost_inc" != x; then boost_cv_inc_path=$boost_inc fi break 2 fi done done AC_LANG_POP([C++])dnl ]) case $boost_cv_inc_path in #( no) boost_errmsg="cannot find Boost headers version >= $boost_version_req_string" m4_if([$2], [], [AC_MSG_ERROR([$boost_errmsg])], [AC_MSG_NOTICE([$boost_errmsg])]) $2 ;;#( yes) BOOST_CPPFLAGS= ;;#( *) AC_SUBST([BOOST_CPPFLAGS], ["-I$boost_cv_inc_path"])dnl ;; esac if test x"$boost_cv_inc_path" != xno; then AC_DEFINE([HAVE_BOOST], [1], [Defined if the requested minimum BOOST version is satisfied]) # # CHANGED FOR GENGEO: # * boost_cv_lib_version and boost_major_version are now derived from the # BOOST_VERSION C++ definition, as is a new variable, boost_full_version # #AC_CACHE_CHECK([for Boost's header version], # [boost_cv_lib_version], # [m4_pattern_allow([^BOOST_LIB_VERSION$])dnl # _BOOST_SED_CPP([/^boost-lib-version = /{s///;s/\"//g;p;q;}], # [#include #boost-lib-version = BOOST_LIB_VERSION], # [boost_cv_lib_version=`cat conftest.i`])]) AC_CACHE_CHECK([for Boost's header version], [boost_cv_full_lib_version], [m4_pattern_allow([^BOOST_VERSION$])dnl _BOOST_SED_CPP([/^boost-full-lib-version = /{s///p;q;}], [#include boost-full-lib-version = BOOST_VERSION], [boost_cv_full_lib_version=`cat conftest.i`])]) let major_version=${boost_cv_full_lib_version}/100000 let minor_version=${boost_cv_full_lib_version}/100%1000 let patch_level=${boost_cv_full_lib_version}%100 #echo Boost Major Version is ${major_version} #echo Boost Minor Version is ${minor_version} #echo Boost Patch Level is ${patch_level} boost_cv_lib_version=${major_version}_${minor_version} test "${patch_level}" -ne 0 && boost_cv_lib_version=${boost_cv_lib_version}_${patch_level} # e.g. "134" for 1_34_1 or "135" for 1_35 #boost_major_version=`echo "$boost_cv_lib_version" | sed 's/_//;s/_.*//'` boost_major_version=${major_version}${minor_version} boost_full_version=`echo ${boost_cv_lib_version} | sed 's/_/\./g'` test "${patch_level}" -eq 0 && boost_full_version=${boost_full_version}.0 echo Boost Version is ${boost_full_version} case $boost_major_version in #( '' | *[[!0-9]]*) AC_MSG_ERROR([invalid value: boost_major_version=$boost_major_version]) ;; esac fi CPPFLAGS=$boost_save_CPPFLAGS ])# BOOST_REQUIRE # BOOST_STATIC() # -------------- # Add the "--enable-static-boost" configure argument. If this argument is given # on the command line, static versions of the libraries will be looked up. AC_DEFUN([BOOST_STATIC], [AC_ARG_ENABLE([static-boost], [AS_HELP_STRING([--enable-static-boost], [Prefer the static boost libraries over the shared ones [no]])], [enable_static_boost=yes], [enable_static_boost=no])])# BOOST_STATIC # BOOST_FIND_HEADER([HEADER-NAME], [ACTION-IF-NOT-FOUND], [ACTION-IF-FOUND]) # -------------------------------------------------------------------------- # Wrapper around AC_CHECK_HEADER for Boost headers. Useful to check for # some parts of the Boost library which are only made of headers and don't # require linking (such as Boost.Foreach). # # Default ACTION-IF-NOT-FOUND: Fail with a fatal error unless Boost couldn't be # found in the first place, in which case by default a notice is issued to the # user. Presumably if we haven't died already it's because it's OK to not have # Boost, which is why only a notice is issued instead of a hard error. # # Default ACTION-IF-FOUND: define the preprocessor symbol HAVE_ in # case of success # (where HEADER-NAME is written LIKE_THIS, e.g., # HAVE_BOOST_FOREACH_HPP). AC_DEFUN([BOOST_FIND_HEADER], [AC_REQUIRE([BOOST_REQUIRE])dnl if test x"$boost_cv_inc_path" = xno; then m4_default([$2], [AC_MSG_NOTICE([Boost not available, not searching for $1])]) else AC_LANG_PUSH([C++])dnl boost_save_CPPFLAGS=$CPPFLAGS CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" AC_CHECK_HEADER([$1], [m4_default([$3], [AC_DEFINE(AS_TR_CPP([HAVE_$1]), [1], [Define to 1 if you have <$1>])])], [m4_default([$2], [AC_MSG_ERROR([cannot find $1])])]) CPPFLAGS=$boost_save_CPPFLAGS AC_LANG_POP([C++])dnl fi ])# BOOST_FIND_HEADER # BOOST_FIND_LIBS([COMPONENT-NAME], [CANDIDATE-LIB-NAMES], # [PREFERRED-RT-OPT], [HEADER-NAME], [CXX-TEST], # [CXX-PROLOGUE]) # -------------------------------------------------------------- # Look for the Boost library COMPONENT-NAME (e.g., `thread', for # libboost_thread) under the possible CANDIDATE-LIB-NAMES (e.g., # "thread_win32 thread"). Check that HEADER-NAME works and check that # libboost_LIB-NAME can link with the code CXX-TEST. The optional # argument CXX-PROLOGUE can be used to include some C++ code before # the `main' function. # # Invokes BOOST_FIND_HEADER([HEADER-NAME]) (see above). # # Boost libraries typically come compiled with several flavors (with different # runtime options) so PREFERRED-RT-OPT is the preferred suffix. A suffix is one # or more of the following letters: sgdpn (in that order). s = static # runtime, d = debug build, g = debug/diagnostic runtime, p = STLPort build, # n = (unsure) STLPort build without iostreams from STLPort (it looks like `n' # must always be used along with `p'). Additionally, PREFERRED-RT-OPT can # start with `mt-' to indicate that there is a preference for multi-thread # builds. Some sample values for PREFERRED-RT-OPT: (nothing), mt, d, mt-d, gdp # ... If you want to make sure you have a specific version of Boost # (eg, >= 1.33) you *must* invoke BOOST_REQUIRE before this macro. AC_DEFUN([BOOST_FIND_LIBS], [AC_REQUIRE([BOOST_REQUIRE])dnl AC_REQUIRE([_BOOST_FIND_COMPILER_TAG])dnl AC_REQUIRE([BOOST_STATIC])dnl AC_REQUIRE([_BOOST_GUESS_WHETHER_TO_USE_MT])dnl if test x"$boost_cv_inc_path" = xno; then AC_MSG_NOTICE([Boost not available, not searching for the Boost $1 library]) else dnl The else branch is huge and wasn't intended on purpose. AC_LANG_PUSH([C++])dnl AS_VAR_PUSHDEF([Boost_lib], [boost_cv_lib_$1])dnl AS_VAR_PUSHDEF([Boost_lib_LDFLAGS], [boost_cv_lib_$1_LDFLAGS])dnl AS_VAR_PUSHDEF([Boost_lib_LDPATH], [boost_cv_lib_$1_LDPATH])dnl AS_VAR_PUSHDEF([Boost_lib_LIBS], [boost_cv_lib_$1_LIBS])dnl BOOST_FIND_HEADER([$4]) boost_save_CPPFLAGS=$CPPFLAGS CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS" AC_CACHE_CHECK([for the Boost $1 library], [Boost_lib], [_BOOST_FIND_LIBS($@)]) case $Boost_lib in #( (no) _AC_MSG_LOG_CONFTEST AC_MSG_ERROR([cannot find the flags to link with Boost $1]) ;; esac AC_SUBST(AS_TR_CPP([BOOST_$1_LDFLAGS]), [$Boost_lib_LDFLAGS])dnl AC_SUBST(AS_TR_CPP([BOOST_$1_LDPATH]), [$Boost_lib_LDPATH])dnl AC_SUBST([BOOST_LDPATH], [$Boost_lib_LDPATH])dnl AC_SUBST(AS_TR_CPP([BOOST_$1_LIBS]), [$Boost_lib_LIBS])dnl CPPFLAGS=$boost_save_CPPFLAGS AS_VAR_POPDEF([Boost_lib])dnl AS_VAR_POPDEF([Boost_lib_LDFLAGS])dnl AS_VAR_POPDEF([Boost_lib_LDPATH])dnl AS_VAR_POPDEF([Boost_lib_LIBS])dnl AC_LANG_POP([C++])dnl fi ]) # BOOST_FIND_LIB([LIB-NAME], # [PREFERRED-RT-OPT], [HEADER-NAME], [CXX-TEST], # [CXX-PROLOGUE]) # -------------------------------------------------------------- # Backward compatibility wrapper for BOOST_FIND_LIBS. AC_DEFUN([BOOST_FIND_LIB], [BOOST_FIND_LIBS([$1], $@)]) # _BOOST_FIND_LIBS([LIB-NAME], [CANDIDATE-LIB-NAMES], # [PREFERRED-RT-OPT], [HEADER-NAME], [CXX-TEST], # [CXX-PROLOGUE]) # -------------------------------------------------------------- # Real implementation of BOOST_FIND_LIBS: rely on these local macros: # Boost_lib, Boost_lib_LDFLAGS, Boost_lib_LDPATH, Boost_lib_LIBS # # The algorithm is as follows: first look for a given library name # according to the user's PREFERRED-RT-OPT. For each library name, we # prefer to use the ones that carry the tag (toolset name). Each # library is searched through the various standard paths were Boost is # usually installed. If we can't find the standard variants, we try # to enforce -mt (for instance on MacOSX, libboost_thread.dylib # doesn't exist but there's -obviously- libboost_thread-mt.dylib). AC_DEFUN([_BOOST_FIND_LIBS], [Boost_lib=no case "$3" in #( (mt | mt-) boost_mt=-mt; boost_rtopt=;; #( (mt* | mt-*) boost_mt=-mt; boost_rtopt=`expr "X$3" : 'Xmt-*\(.*\)'`;; #( (*) boost_mt=; boost_rtopt=$3;; esac if test $enable_static_boost = yes; then boost_rtopt="s$boost_rtopt" fi # Find the proper debug variant depending on what we've been asked to find. case $boost_rtopt in #( (*d*) boost_rt_d=$boost_rtopt;; #( (*[[sgpn]]*) # Insert the `d' at the right place (in between `sg' and `pn') boost_rt_d=`echo "$boost_rtopt" | sed 's/\(s*g*\)\(p*n*\)/\1\2/'`;; #( (*) boost_rt_d='-d';; esac # If the PREFERRED-RT-OPT are not empty, prepend a `-'. test -n "$boost_rtopt" && boost_rtopt="-$boost_rtopt" $boost_guess_use_mt && boost_mt=-mt # Look for the abs path the static archive. # $libext is computed by Libtool but let's make sure it's non empty. test -z "$libext" && AC_MSG_ERROR([the libext variable is empty, did you invoke Libtool?]) # CHANGED FOR GENGEO: # * Check for $shrext_cmds which stores the shared-object library extension. test -z "${shrext_cmds}" && AC_MSG_ERROR([The shrext_cmds variable is empty. Did you invoke Libtool?]) boost_save_ac_objext=$ac_objext # Generate the test file. AC_LANG_CONFTEST([AC_LANG_PROGRAM([#include <$4> $6], [$5])]) dnl Optimization hacks: compiling C++ is slow, especially with Boost. What dnl we're trying to do here is guess the right combination of link flags dnl (LIBS / LDFLAGS) to use a given library. This can take several dnl iterations before it succeeds and is thus *very* slow. So what we do dnl instead is that we compile the code first (and thus get an object file, dnl typically conftest.o). Then we try various combinations of link flags dnl until we succeed to link conftest.o in an executable. The problem is dnl that the various TRY_LINK / COMPILE_IFELSE macros of Autoconf always dnl remove all the temporary files including conftest.o. So the trick here dnl is to temporarily change the value of ac_objext so that conftest.o is dnl preserved accross tests. This is obviously fragile and I will burn in dnl hell for not respecting Autoconf's documented interfaces, but in the dnl mean time, it optimizes the macro by a factor of 5 to 30. dnl Another small optimization: the first argument of AC_COMPILE_IFELSE left dnl empty because the test file is generated only once above (before we dnl start the for loops). AC_COMPILE_IFELSE([], [ac_objext=do_not_rm_me_plz], [AC_MSG_ERROR([cannot compile a test that uses Boost $1])]) ac_objext=$boost_save_ac_objext boost_failed_libs= # Don't bother to indent the following nested for loops, only the 2 # innermost ones matter. # # CHANGED FOR GENGEO: # * Search order changed to give priority first to a library name provided # on the command line, second to a library name without suffixes, # third to a library name with the -mt suffix before searching for # libraries containing other combinations of suffixes in their names # * Test added for the Python suffix "-pyXY" in the name of a Boost Python library for boost_lib_ in $2; do python_suffix= library_name=${boost_lib_:0:6} test "${library_name}" = python && python_suffix=-py${PYTHON_MAJOR_VERSION}${PYTHON_MINOR_VERSION} for boost_tag_ in '' -$boost_cv_lib_tag; do for boost_ver_ in '' -$boost_cv_lib_version; do for boost_rtopt_ in '' $boost_rtopt -d; do for boost_mt_ in '' $boost_mt -mt; do for boost_py_ in '' ${python_suffix}; do for boost_lib in \ boost_$boost_lib_$boost_tag_$boost_mt_$boost_rtopt_$boost_ver_$boost_py_ \ boost_$boost_lib_$boost_tag_$boost_rtopt_$boost_ver_$boost_py_ \ boost_$boost_lib_$boost_tag_$boost_mt_$boost_ver_$boost_py_ \ boost_$boost_lib_$boost_tag_$boost_ver_$boost_py_ do # Avoid testing twice the same lib case $boost_failed_libs in #( (*@$boost_lib@*) continue;; esac # If with_boost is empty, we'll search in /lib first, which is not quite # right so instead we'll try to a location based on where the headers are. # # CHANGED FOR GENGEO: # * If --with-boost has been set to a folder, assume that the user knows where # the Boost libraries are; do not search standard locations. This is to # speed up the library search and to help avoid finding libraries that are # incompatible with the headers. If the option has not been set, add the # standard possible library locations to the path list. # * Search order of standard locations now puts /usr/lib* before /usr/local/lib* # * Search for a Boost library includes multiarch names in a search path if test x"${with_boost}" != x && test x"${with_boost}" != xyes; then possible_paths="${with_boost}/lib ${with_boost}" else possible_paths="${boost_cv_inc_path%/include}/lib \ /usr/lib*/x86_64* /usr/lib*/i386* /usr/lib*/aarch64* /usr/lib*/arm* /usr/lib*/mips* \ /usr/lib*/powerpc* /usr/lib*/ppc64* /usr/lib*/s390* /usr/lib*/sh4* /usr/lib*/sparc* /usr/lib* \ /usr/local/lib*/x86_64* /usr/local/lib*/i386* /usr/local/lib*/aarch64* /usr/local/lib*/arm* \ /usr/local/lib*/mips* /usr/local/lib*/powerpc* /usr/local/lib*/ppc64* /usr/local/lib*/s390* \ /usr/local/lib*/sh4* /usr/local/lib*/sparc* /usr/local/lib* \ /opt/lib*/x86_64* /opt/lib*/i386* /opt/lib*/aarch64* /opt/lib*/arm* /opt/lib*/mips* \ /opt/lib*/powerpc* /opt/lib*/ppc64* /opt/lib*/s390* /opt/lib*/sh4* /opt/lib*/sparc* /opt/lib* \ /opt/local/lib*/x86_64* /opt/local/lib*/i386* /opt/local/lib*/aarch64* /opt/local/lib*/arm* \ /opt/local/lib*/mips* /opt/local/lib*/powerpc* /opt/local/lib*/ppc64* /opt/local/lib*/s390* \ /opt/local/lib*/sh4* /opt/local/lib*/sparc* /opt/local/lib* \ /lib*/x86_64* /lib*/i386* /lib*/aarch64* /lib*/arm* /lib*/mips* \ /lib*/powerpc* /lib*/ppc64* /lib*/s390* /lib*/sh4* /lib*/sparc* /lib* \ C:/Boost/lib" fi for boost_ldpath in ${possible_paths} '' do # Don't waste time with directories that don't exist. (test x"$boost_ldpath" != x && test ! -d "$boost_ldpath") && continue boost_save_LIBS=$LIBS boost_save_LDFLAGS=$LDFLAGS # Are we looking for a static library? # # CHANGED FOR GENGEO: # * To avoid finding shared libraries that are incompatible with the supplied # headers, resulting in a failed build, check first for the existence of a # library that has Boost's full header version suffixed to the usual library # extension. (This works because Boost and other developers use the # Libtool versioning system to specify release information, which is the same # for all libraries. If Boost in future begins to use the Libtool version # numbers for their intended purpose, the library tests below will need to # be revised.) Allow a library without the version extension only if a # Boost library name has been specified in the configuration options. Assume # in this second case that the user knows the correct library's exact name. # This change is needed because there have been two situations in which the # ``configure'' script incorrectly reports finding a Boost library. The # first arises in connection with Boost Filesystem: As an example, after # rejecting the first variant name for Boost System (boost_system) for # incompatibility and settling on the second (boost_system-mt), the test # for Boost Filesystem accepts the first variant name (boost_filesystem) rather # than the second (boost_filesystem-mt) and the subsequent build fails. # (If one forces the Boost Filesystem search to ignore anything discovered # during the Boost System search, provided through LIBS and LDFLAGS, the test # correctly rejects boost_filesystem and settles on boost_filesystem-mt. But # this approach works not on all systems.) The second situation arises because # the current way of testing for compatible libraries is to test merely for the # existence of a library with a matching name and optionally for a function # in the library that is reported by the headers. Although the function test # successfully screens out libraries that are old enough, it is insufficient # when multiple sets of libraries with closely numbered versions are installed. # Thus although the test will report that version 1.36.0 Boost System libraries # are incompatible with version 1.55.0 headers, it does not screen out 1.49.0 # libraries that are incompatible with 1.52.0 headers, resulting in the # subsequent build failing because of some other function or variable that # was not tested by ``configure''. case $boost_ldpath:$boost_rtopt_ in #( (*?*:*s*) # Yes (Non empty boost_ldpath + s in rt opt) Boost_lib_LIBS="$boost_ldpath/lib$boost_lib.$libext" test -e "$Boost_lib_LIBS" || continue;; #( (*) # No: use -lboost_foo to find the shared library. Boost_lib_LIBS="-l$boost_lib" link_one= link_two= echo ${boost_ldpath}/lib${boost_lib}${shrext_cmds} ... if test -e "${boost_ldpath}/lib${boost_lib}${shrext_cmds}" then # Test if the linked file has the correct version in its name. if test -L "${boost_ldpath}/lib${boost_lib}${shrext_cmds}" && link_one=$(ls -l ${boost_ldpath}/lib${boost_lib}${shrext_cmds}) && test "${link_one#*${shrext_cmds}.}" = "${boost_full_version}" then echo lib${boost_lib}${shrext_cmds} links to ${link_one##* } echo yes... # Occasionally the first linked file is itself a link. Test if the # second linked file has the correct version in its name. elif test -L "${boost_ldpath}/lib${boost_lib}${shrext_cmds}" && test -L "${boost_ldpath}/${link_one##* }" && link_two=$(ls -l ${boost_ldpath}/${link_one##* }) && test "${link_two#*${shrext_cmds}.}" = "${boost_full_version}" then echo lib${boost_lib}${shrext_cmds} links to ${link_one##* } echo ${link_one##* } links to ${link_two##* } echo yes... # If a library name has been provided to ``configure'', assume that the # user knows best. elif (test -n "${boost_system_library}" && test "${boost_lib_}" = "${boost_system_library}") || (test -n "${boost_filesystem_library}" && test "${boost_lib_}" = "${boost_filesystem_library}") || (test -n "${boost_python_library}" && test "${boost_lib_}" = "${boost_python_library}") || (test -n "${boost_regex_library}" && test "${boost_lib_}" = "${boost_regex_library}") then echo "${boost_ldpath}/lib${boost_lib}${shrext_cmds}.${boost_full_version}"\ "does not exist, but user-provided library name matches another library"\ "in ${boost_ldpath}/ ..." else echo no... LIBS=${boost_save_LIBS} LDFLAGS=${boost_save_LDFLAGS} continue fi else echo no... LIBS=${boost_save_LIBS} LDFLAGS=${boost_save_LDFLAGS} continue fi ;; esac LIBS="$Boost_lib_LIBS $LIBS" test x"$boost_ldpath" != x && LDFLAGS="$LDFLAGS -L$boost_ldpath" dnl First argument of AC_LINK_IFELSE left empty because the test file is dnl generated only once above (before we start the for loops). _BOOST_AC_LINK_IFELSE([], [Boost_lib=yes], [Boost_lib=no]) ac_objext=$boost_save_ac_objext LDFLAGS=$boost_save_LDFLAGS LIBS=$boost_save_LIBS if test x"$Boost_lib" = xyes; then # Check or used cached result of whether or not using -R or # -rpath makes sense. Some implementations of ld, such as for # Mac OSX, require -rpath but -R is the flag known to work on # other systems. https://github.com/tsuna/boost.m4/issues/19 AC_CACHE_VAL([boost_cv_rpath_link_ldflag], [case $boost_ldpath in #(( '') # Nothing to do. boost_cv_rpath_link_ldflag= boost_rpath_link_ldflag_found=yes;; *) for boost_cv_rpath_link_ldflag in -Wl,-R, -Wl,-rpath,; do LDFLAGS="$boost_save_LDFLAGS -L$boost_ldpath $boost_cv_rpath_link_ldflag$boost_ldpath" LIBS="$boost_save_LIBS $Boost_lib_LIBS" _BOOST_AC_LINK_IFELSE([], [boost_rpath_link_ldflag_found=yes break], [boost_rpath_link_ldflag_found=no]) done ;; esac AS_IF([test "x$boost_rpath_link_ldflag_found" != "xyes"], [AC_MSG_ERROR([Unable to determine whether to use -R or -rpath])]) LDFLAGS=$boost_save_LDFLAGS LIBS=$boost_save_LIBS ]) test x"$boost_ldpath" != x && Boost_lib_LDFLAGS="-L$boost_ldpath $boost_cv_rpath_link_ldflag$boost_ldpath" Boost_lib_LDPATH="$boost_ldpath" break 8 else # CHANGED FOR GENGEO: # * Helpful information for the user in the event that a candidate library # be rejected echo "no..." echo "There is a problem with locating the correct library. "\ "The candidate failed a compatibility test. "\ "The following may apply:" if test "${library_name}" = python then echo "* The discovered Python executable is not the same version as that"\ "used to build the Boost Python library. If the remaining search"\ "fails for this library, either:" echo " - Add PYTHON=pythonX.Y[[d]][[m]][[u]] (X: major version number; Y: minor"\ "version number) to the configure command to force a search for the"\ "version of Python that matches the discovered Boost Python; or" echo " - If multiple Boost Python libraries corresponding to different"\ "Python versions are in the same directory and the discovered file is"\ "a link to an incompatible version, then add as an option to the"\ "configure command the name of the Boost Python library that is compatible"\ "with the discovered version of Python (i.e., --with-boost-python=boost_python-pyXY)." fi echo "* The version of the candidate library mismatches the version of the"\ "discovered headers. If you have added a library name as an option to"\ "the configure command, check that the name is correct and that the"\ "version of this library matches the version of the headers." fi done # CHANGED FOR GENGEO: # * Update for failed boost_lib search is shifted to outside the loop, where it is # updated once after all the possible folders have been checked for its existence. # # Search for library in all paths exhausted, so ... boost_failed_libs="$boost_failed_libs@$boost_lib@" done done # boost_py_ done # boost_mt_ done # boost_rtopt_ done # boost_ver_ done # boost_tag_ done # boost_lib_ rm -f conftest.$ac_objext ]) # --------------------------------------- # # Checks for the various Boost libraries. # # --------------------------------------- # # List of boost libraries: http://www.boost.org/libs/libraries.htm # The page http://beta.boost.org/doc/libs is useful: it gives the first release # version of each library (among other things). # BOOST_DEFUN(LIBRARY, CODE) # -------------------------- # Define BOOST_ as a macro that runs CODE. # # Use indir to avoid the warning on underquoted macro name given to AC_DEFUN. m4_define([BOOST_DEFUN], [m4_indir([AC_DEFUN], m4_toupper([BOOST_$1]), [m4_pushdef([BOOST_Library], [$1])dnl $2 m4_popdef([BOOST_Library])dnl ]) ]) # BOOST_ARRAY() # ------------- # Look for Boost.Array BOOST_DEFUN([Array], [BOOST_FIND_HEADER([boost/array.hpp])]) # BOOST_ASIO() # ------------ # Look for Boost.Asio (new in Boost 1.35). BOOST_DEFUN([Asio], [AC_REQUIRE([BOOST_SYSTEM])dnl BOOST_FIND_HEADER([boost/asio.hpp])]) # BOOST_BIND() # ------------ # Look for Boost.Bind. BOOST_DEFUN([Bind], [BOOST_FIND_HEADER([boost/bind.hpp])]) # BOOST_CHRONO() # -------------- # Look for Boost.Chrono. BOOST_DEFUN([Chrono], [# Do we have to check for Boost.System? This link-time dependency was # added as of 1.35.0. If we have a version <1.35, we must not attempt to # find Boost.System as it didn't exist by then. if test $boost_major_version -ge 135; then BOOST_SYSTEM([$1]) fi # end of the Boost.System check. boost_filesystem_save_LIBS=$LIBS boost_filesystem_save_LDFLAGS=$LDFLAGS m4_pattern_allow([^BOOST_SYSTEM_(LIBS|LDFLAGS)$])dnl LIBS="$LIBS $BOOST_SYSTEM_LIBS" LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS" BOOST_FIND_LIB([chrono], [$1], [boost/chrono.hpp], [boost::chrono::thread_clock d;]) if test $enable_static_boost = yes && test $boost_major_version -ge 135; then BOOST_FILESYSTEM_LIBS="$BOOST_FILESYSTEM_LIBS $BOOST_SYSTEM_LIBS" fi LIBS=$boost_filesystem_save_LIBS LDFLAGS=$boost_filesystem_save_LDFLAGS ])# BOOST_CHRONO # BOOST_CONVERSION() # ------------------ # Look for Boost.Conversion (cast / lexical_cast) BOOST_DEFUN([Conversion], [BOOST_FIND_HEADER([boost/cast.hpp]) BOOST_FIND_HEADER([boost/lexical_cast.hpp]) ])# BOOST_CONVERSION # BOOST_CRC() # ----------- # Look for Boost.CRC BOOST_DEFUN([CRC], [BOOST_FIND_HEADER([boost/crc.hpp]) ])# BOOST_CRC # BOOST_DATE_TIME([PREFERRED-RT-OPT]) # ----------------------------------- # Look for Boost.Date_Time. For the documentation of PREFERRED-RT-OPT, see the # documentation of BOOST_FIND_LIB above. BOOST_DEFUN([Date_Time], [BOOST_FIND_LIB([date_time], [$1], [boost/date_time/posix_time/posix_time.hpp], [boost::posix_time::ptime t;]) ])# BOOST_DATE_TIME # BOOST_FILESYSTEM([PREFERRED-RT-OPT]) # ------------------------------------ # Look for Boost.Filesystem. For the documentation of PREFERRED-RT-OPT, see # the documentation of BOOST_FIND_LIB above. # Do not check for boost/filesystem.hpp because this file was introduced in # 1.34. # # CHANGED FOR GENGEO: # * addition of --with-boost-filesystem help-string macro, taken from # ax_boost_filesystem.m4, whose license is: # # LICENSE # # Copyright (c) 2009 Thomas Porschberg # Copyright (c) 2009 Michael Tindal # Copyright (c) 2009 Roman Rybalko # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. # # The --with-boost-system and --with-boost-python help-string macros below are # derived from this macro. # # * Boost.System LIBS and LDFLAGS removed from Boost.Filesystem LIBS and LDFLAGS. # This was preventing a proper search for Boost.Filesystem. A successful # search was being reported when no search was being done. This situation can # occur when a system-installed Boost library exists in addition to a # user-installed Boost library. # * replacement of BOOST_FIND_LIB with BOOST_FIND_LIBS # * addition of $boost_filesystem_library to second parameter of # BOOST_FIND_LIBS to allow the macro to be used # * always link boost_system with boost_filesystem for newer boost versions, # not only when linking static libraries BOOST_DEFUN([Filesystem], [# Do we have to check for Boost.System? This link-time dependency was # added as of 1.35.0. If we have a version <1.35, we must not attempt to # find Boost.System as it didn't exist by then. if test $boost_major_version -ge 135; then BOOST_SYSTEM([$1]) fi # end of the Boost.System check. AC_ARG_WITH([boost-filesystem], AS_HELP_STRING([--with-boost-filesystem@<:@=special-lib@:>@], [specify the Boost Filesystem library to use; e.g. --with-boost-filesystem=boost_filesystem-gcc-mt]), [ if test "$withval" = "no"; then want_boost="no" elif test "$withval" = "yes"; then want_boost="yes" boost_filesystem_library="" else want_boost="yes" boost_filesystem_library="${withval#boost_}" fi ], [want_boost="yes"]) boost_filesystem_save_LIBS=$LIBS boost_filesystem_save_LDFLAGS=$LDFLAGS m4_pattern_allow([^BOOST_SYSTEM_(LIBS|LDFLAGS)$])dnl LIBS="$LIBS $BOOST_SYSTEM_LIBS" LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS" BOOST_FIND_LIBS([filesystem], [$boost_filesystem_library filesystem], [$1], [boost/filesystem/path.hpp], [boost::filesystem::path p;]) LIBS=$boost_filesystem_save_LIBS LDFLAGS=$boost_filesystem_save_LDFLAGS if test $boost_major_version -ge 135; then BOOST_FILESYSTEM_LIBS="$BOOST_FILESYSTEM_LIBS $BOOST_SYSTEM_LIBS" fi ])# BOOST_FILESYSTEM # BOOST_FLYWEIGHT() # ----------------- # Look for Boost.Flyweight. BOOST_DEFUN([Flyweight], [dnl There's a hidden dependency on pthreads. AC_REQUIRE([_BOOST_PTHREAD_FLAG])dnl BOOST_FIND_HEADER([boost/flyweight.hpp]) AC_SUBST([BOOST_FLYWEIGHT_LIBS], [$boost_cv_pthread_flag]) ]) # BOOST_FOREACH() # --------------- # Look for Boost.Foreach. BOOST_DEFUN([Foreach], [BOOST_FIND_HEADER([boost/foreach.hpp])]) # BOOST_FORMAT() # -------------- # Look for Boost.Format. # Note: we can't check for boost/format/format_fwd.hpp because the header isn't # standalone. It can't be compiled because it triggers the following error: # boost/format/detail/config_macros.hpp:88: error: 'locale' in namespace 'std' # does not name a type BOOST_DEFUN([Format], [BOOST_FIND_HEADER([boost/format.hpp])]) # BOOST_FUNCTION() # ---------------- # Look for Boost.Function BOOST_DEFUN([Function], [BOOST_FIND_HEADER([boost/function.hpp])]) # BOOST_GEOMETRY() # ---------------- # Look for Boost.Geometry (new since 1.47.0). BOOST_DEFUN([Geometry], [BOOST_FIND_HEADER([boost/geometry.hpp]) ])# BOOST_GEOMETRY # BOOST_GRAPH([PREFERRED-RT-OPT]) # ------------------------------- # Look for Boost.Graphs. For the documentation of PREFERRED-RT-OPT, see the # documentation of BOOST_FIND_LIB above. BOOST_DEFUN([Graph], [BOOST_FIND_LIB([graph], [$1], [boost/graph/adjacency_list.hpp], [boost::adjacency_list<> g;]) ])# BOOST_GRAPH # BOOST_IOSTREAMS([PREFERRED-RT-OPT]) # ----------------------------------- # Look for Boost.IOStreams. For the documentation of PREFERRED-RT-OPT, see the # documentation of BOOST_FIND_LIB above. BOOST_DEFUN([IOStreams], [BOOST_FIND_LIB([iostreams], [$1], [boost/iostreams/device/file_descriptor.hpp], [boost::iostreams::file_descriptor fd; fd.close();]) ])# BOOST_IOSTREAMS # BOOST_HASH() # ------------ # Look for Boost.Functional/Hash BOOST_DEFUN([Hash], [BOOST_FIND_HEADER([boost/functional/hash.hpp])]) # BOOST_LAMBDA() # -------------- # Look for Boost.Lambda BOOST_DEFUN([Lambda], [BOOST_FIND_HEADER([boost/lambda/lambda.hpp])]) # BOOST_LOG([PREFERRED-RT-OPT]) # ----------------------------- # Look for Boost.Log. For the documentation of PREFERRED-RT-OPT, see the # documentation of BOOST_FIND_LIB above. BOOST_DEFUN([Log], [BOOST_FIND_LIB([log], [$1], [boost/log/core/core.hpp], [boost::log::attribute a; a.get_value();]) ])# BOOST_LOG # BOOST_LOG_SETUP([PREFERRED-RT-OPT]) # ----------------------------------- # Look for Boost.Log. For the documentation of PREFERRED-RT-OPT, see the # documentation of BOOST_FIND_LIB above. BOOST_DEFUN([Log_Setup], [AC_REQUIRE([BOOST_LOG])dnl BOOST_FIND_LIB([log_setup], [$1], [boost/log/utility/setup/from_settings.hpp], [boost::log::basic_settings bs; bs.empty();]) ])# BOOST_LOG_SETUP # BOOST_MATH() # ------------ # Look for Boost.Math # TODO: This library isn't header-only but it comes in multiple different # flavors that don't play well with BOOST_FIND_LIB (e.g, libboost_math_c99, # libboost_math_c99f, libboost_math_c99l, libboost_math_tr1, # libboost_math_tr1f, libboost_math_tr1l). This macro must be fixed to do the # right thing anyway. BOOST_DEFUN([Math], [BOOST_FIND_HEADER([boost/math/special_functions.hpp])]) # BOOST_MPI([PREFERRED-RT-OPT]) # ------------------------------- # Look for Boost MPI. For the documentation of PREFERRED-RT-OPT, see the # documentation of BOOST_FIND_LIB above. Uses MPICXX variable if it is # set, otherwise tries CXX # BOOST_DEFUN([MPI], [boost_save_CXX=${CXX} boost_save_CXXCPP=${CXXCPP} if test x"${MPICXX}" != x; then CXX=${MPICXX} CXXCPP="${MPICXX} -E" fi BOOST_FIND_LIB([mpi], [$1], [boost/mpi.hpp], [int argc = 0; char **argv = 0; boost::mpi::environment env(argc,argv);]) CXX=${boost_save_CXX} CXXCPP=${boost_save_CXXCPP} ])# BOOST_MPI # BOOST_MULTIARRAY() # ------------------ # Look for Boost.MultiArray BOOST_DEFUN([MultiArray], [BOOST_FIND_HEADER([boost/multi_array.hpp])]) # BOOST_NUMERIC_UBLAS() # -------------------------- # Look for Boost.NumericUblas (Basic Linear Algebra) BOOST_DEFUN([Numeric_Ublas], [BOOST_FIND_HEADER([boost/numeric/ublas/vector.hpp]) ])# BOOST_NUMERIC_UBLAS # BOOST_NUMERIC_CONVERSION() # -------------------------- # Look for Boost.NumericConversion (policy-based numeric conversion) BOOST_DEFUN([Numeric_Conversion], [BOOST_FIND_HEADER([boost/numeric/conversion/converter.hpp]) ])# BOOST_NUMERIC_CONVERSION # BOOST_OPTIONAL() # ---------------- # Look for Boost.Optional BOOST_DEFUN([Optional], [BOOST_FIND_HEADER([boost/optional.hpp])]) # BOOST_PREPROCESSOR() # -------------------- # Look for Boost.Preprocessor BOOST_DEFUN([Preprocessor], [BOOST_FIND_HEADER([boost/preprocessor/repeat.hpp])]) # BOOST_UNORDERED() # ----------------- # Look for Boost.Unordered BOOST_DEFUN([Unordered], [BOOST_FIND_HEADER([boost/unordered_map.hpp])]) # BOOST_UUID() # ------------ # Look for Boost.Uuid BOOST_DEFUN([Uuid], [BOOST_FIND_HEADER([boost/uuid/uuid.hpp])]) # BOOST_PROGRAM_OPTIONS([PREFERRED-RT-OPT]) # ----------------------------------------- # Look for Boost.Program_options. For the documentation of PREFERRED-RT-OPT, # see the documentation of BOOST_FIND_LIB above. BOOST_DEFUN([Program_Options], [BOOST_FIND_LIB([program_options], [$1], [boost/program_options.hpp], [boost::program_options::options_description d("test");]) ])# BOOST_PROGRAM_OPTIONS # _BOOST_PYTHON_CONFIG(VARIABLE, FLAG) # ------------------------------------ # Save VARIABLE, and define it via `python-config --FLAG`. # Substitute BOOST_PYTHON_VARIABLE. # # CHANGED FOR GENGEO: # * Name of Python configuration file altered to reflect changes in # Python 3 to naming conventions m4_define([_BOOST_PYTHON_CONFIG], [AC_SUBST([BOOST_PYTHON_$1], [`python${PYTHON_VERSION}${PYTHON_VERSION_SUFFIX}-config --$2 2>/dev/null`])dnl boost_python_save_$1=$$1 $1="$$1 $BOOST_PYTHON_$1"]) # BOOST_PYTHON([PREFERRED-RT-OPT]) # -------------------------------- # Look for Boost.Python. For the documentation of PREFERRED-RT-OPT, # see the documentation of BOOST_FIND_LIB above. # # CHANGED FOR GENGEO: # * addition of --with-boost-python help-string macro, modified from # --with-boost-filesystem help-string macro above # * addition of $boost_python_library to second parameter of # BOOST_FIND_LIBS to allow the macro to be used BOOST_DEFUN([Python], [ AC_ARG_WITH([boost-python], AS_HELP_STRING([--with-boost-python@<:@=special-lib@:>@], [specify the Boost Python library to use; e.g. --with-boost-python=boost_python-gcc-mt]), [ if test "$withval" = "no"; then want_boost="no" elif test "$withval" = "yes"; then want_boost="yes" boost_python_library="" else want_boost="yes" boost_python_library="${withval#boost_}" fi ], [want_boost="yes"]) _BOOST_PYTHON_CONFIG([CPPFLAGS], [includes]) _BOOST_PYTHON_CONFIG([LDFLAGS], [ldflags]) _BOOST_PYTHON_CONFIG([LIBS], [libs]) m4_pattern_allow([^BOOST_PYTHON_MODULE$])dnl BOOST_FIND_LIBS([python], [$boost_python_library python python3], [$1], [boost/python.hpp], [], [BOOST_PYTHON_MODULE(empty) {}]) CPPFLAGS=$boost_python_save_CPPFLAGS LDFLAGS=$boost_python_save_LDFLAGS LIBS=$boost_python_save_LIBS ])# BOOST_PYTHON # BOOST_REF() # ----------- # Look for Boost.Ref BOOST_DEFUN([Ref], [BOOST_FIND_HEADER([boost/ref.hpp])]) # BOOST_REGEX([PREFERRED-RT-OPT]) # ------------------------------- # Look for Boost.Regex. For the documentation of PREFERRED-RT-OPT, see the # documentation of BOOST_FIND_LIB above. # # CHANGED FOR GENGEO: # * addition of --with-boost-regex help-string macro, modified from # --with-boost-filesystem help-string macro above # * replacement of BOOST_FIND_LIB with BOOST_FIND_LIBS # * addition of $boost_regex_library to second parameter of # BOOST_FIND_LIBS to allow the macro to be used BOOST_DEFUN([Regex], [ AC_ARG_WITH([boost-regex], AS_HELP_STRING([--with-boost-regex<:@=special-lib@:>@], [specify the Boost Regex library to use; e.g. --with-boost-regex=boost_regex-gcc-mt]), [ if test "$withval" = "no"; then want_boost="no" elif test "$withval" = "yes"; then want_boost="yes" boost_regex_library="" else want_boost="yes" boost_regex_library="${withval#boost_}" fi ], [want_boost="yes"]) BOOST_FIND_LIBS([regex], [$boost_regex_library regex], [$1], [boost/regex.hpp], [boost::regex exp("*"); boost::regex_match("foo", exp);]) ])# BOOST_REGEX # BOOST_SERIALIZATION([PREFERRED-RT-OPT]) # --------------------------------------- # Look for Boost.Serialization. For the documentation of PREFERRED-RT-OPT, see # the documentation of BOOST_FIND_LIB above. BOOST_DEFUN([Serialization], [BOOST_FIND_LIB([serialization], [$1], [boost/archive/text_oarchive.hpp], [std::ostream* o = 0; // Cheap way to get an ostream... boost::archive::text_oarchive t(*o);]) ])# BOOST_SERIALIZATION # BOOST_SIGNALS([PREFERRED-RT-OPT]) # --------------------------------- # Look for Boost.Signals. For the documentation of PREFERRED-RT-OPT, see the # documentation of BOOST_FIND_LIB above. BOOST_DEFUN([Signals], [BOOST_FIND_LIB([signals], [$1], [boost/signal.hpp], [boost::signal s;]) ])# BOOST_SIGNALS # BOOST_SIGNALS2() # ---------------- # Look for Boost.Signals2 (new since 1.39.0). BOOST_DEFUN([Signals2], [BOOST_FIND_HEADER([boost/signals2.hpp]) ])# BOOST_SIGNALS2 # BOOST_SMART_PTR() # ----------------- # Look for Boost.SmartPtr BOOST_DEFUN([Smart_Ptr], [BOOST_FIND_HEADER([boost/scoped_ptr.hpp]) BOOST_FIND_HEADER([boost/shared_ptr.hpp]) ]) # BOOST_STATICASSERT() # -------------------- # Look for Boost.StaticAssert BOOST_DEFUN([StaticAssert], [BOOST_FIND_HEADER([boost/static_assert.hpp])]) # BOOST_STRING_ALGO() # ------------------- # Look for Boost.StringAlgo BOOST_DEFUN([String_Algo], [BOOST_FIND_HEADER([boost/algorithm/string.hpp]) ]) # BOOST_SYSTEM([PREFERRED-RT-OPT]) # -------------------------------- # Look for Boost.System. For the documentation of PREFERRED-RT-OPT, see the # documentation of BOOST_FIND_LIB above. This library was introduced in Boost # 1.35.0. # # CHANGED FOR GENGEO: # * addition of --with-boost-system help-string macro, modified from # --with-boost-filesystem help-string macro above # * replacement of BOOST_FIND_LIB with BOOST_FIND_LIBS # * addition of $boost_system_library to second parameter of # BOOST_FIND_LIBS to allow the macro to be used BOOST_DEFUN([System], [ AC_ARG_WITH([boost-system], AS_HELP_STRING([--with-boost-system@<:@=special-lib@:>@], [specify the Boost System library to use (Boost 1.35 and above); e.g. --with-boost-system=boost_system-gcc-mt]), [ if test "$withval" = "no"; then want_boost="no" elif test "$withval" = "yes"; then want_boost="yes" boost_system_library="" else want_boost="yes" boost_system_library="${withval#boost_}" fi ], [want_boost="yes"]) BOOST_FIND_LIBS([system], [$boost_system_library system], [$1], [boost/system/error_code.hpp], [boost::system::error_code e; e.clear();]) ])# BOOST_SYSTEM # BOOST_TEST([PREFERRED-RT-OPT]) # ------------------------------ # Look for Boost.Test. For the documentation of PREFERRED-RT-OPT, see the # documentation of BOOST_FIND_LIB above. BOOST_DEFUN([Test], [m4_pattern_allow([^BOOST_CHECK$])dnl BOOST_FIND_LIB([unit_test_framework], [$1], [boost/test/unit_test.hpp], [BOOST_CHECK(2 == 2);], [using boost::unit_test::test_suite; test_suite* init_unit_test_suite(int argc, char ** argv) { return NULL; }]) ])# BOOST_TEST # BOOST_THREAD([PREFERRED-RT-OPT]) # --------------------------------- # Look for Boost.Thread. For the documentation of PREFERRED-RT-OPT, see the # documentation of BOOST_FIND_LIB above. BOOST_DEFUN([Thread], [dnl Having the pthread flag is required at least on GCC3 where dnl boost/thread.hpp would complain if we try to compile without dnl -pthread on GNU/Linux. AC_REQUIRE([_BOOST_PTHREAD_FLAG])dnl boost_thread_save_LIBS=$LIBS boost_thread_save_LDFLAGS=$LDFLAGS boost_thread_save_CPPFLAGS=$CPPFLAGS # Link-time dependency from thread to system was added as of 1.49.0. if test $boost_major_version -ge 149; then BOOST_SYSTEM([$1]) fi # end of the Boost.System check. m4_pattern_allow([^BOOST_SYSTEM_(LIBS|LDFLAGS)$])dnl LIBS="$LIBS $BOOST_SYSTEM_LIBS $boost_cv_pthread_flag" LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS" CPPFLAGS="$CPPFLAGS $boost_cv_pthread_flag" # When compiling for the Windows platform, the threads library is named # differently. case $host_os in (*mingw*) boost_thread_lib_ext=_win32;; esac BOOST_FIND_LIBS([thread], [thread$boost_thread_lib_ext], [$1], [boost/thread.hpp], [boost::thread t; boost::mutex m;]) BOOST_THREAD_LIBS="$BOOST_THREAD_LIBS $BOOST_SYSTEM_LIBS $boost_cv_pthread_flag" BOOST_THREAD_LDFLAGS="$BOOST_SYSTEM_LDFLAGS" BOOST_CPPFLAGS="$BOOST_CPPFLAGS $boost_cv_pthread_flag" LIBS=$boost_thread_save_LIBS LDFLAGS=$boost_thread_save_LDFLAGS CPPFLAGS=$boost_thread_save_CPPFLAGS ])# BOOST_THREAD AU_ALIAS([BOOST_THREADS], [BOOST_THREAD]) # BOOST_TOKENIZER() # ----------------- # Look for Boost.Tokenizer BOOST_DEFUN([Tokenizer], [BOOST_FIND_HEADER([boost/tokenizer.hpp])]) # BOOST_TRIBOOL() # --------------- # Look for Boost.Tribool BOOST_DEFUN([Tribool], [BOOST_FIND_HEADER([boost/logic/tribool_fwd.hpp]) BOOST_FIND_HEADER([boost/logic/tribool.hpp]) ]) # BOOST_TUPLE() # ------------- # Look for Boost.Tuple BOOST_DEFUN([Tuple], [BOOST_FIND_HEADER([boost/tuple/tuple.hpp])]) # BOOST_TYPETRAITS() # -------------------- # Look for Boost.TypeTraits BOOST_DEFUN([TypeTraits], [BOOST_FIND_HEADER([boost/type_traits.hpp])]) # BOOST_UTILITY() # --------------- # Look for Boost.Utility (noncopyable, result_of, base-from-member idiom, # etc.) BOOST_DEFUN([Utility], [BOOST_FIND_HEADER([boost/utility.hpp])]) # BOOST_VARIANT() # --------------- # Look for Boost.Variant. BOOST_DEFUN([Variant], [BOOST_FIND_HEADER([boost/variant/variant_fwd.hpp]) BOOST_FIND_HEADER([boost/variant.hpp])]) # BOOST_POINTER_CONTAINER() # ------------------------ # Look for Boost.PointerContainer BOOST_DEFUN([Pointer_Container], [BOOST_FIND_HEADER([boost/ptr_container/ptr_deque.hpp]) BOOST_FIND_HEADER([boost/ptr_container/ptr_list.hpp]) BOOST_FIND_HEADER([boost/ptr_container/ptr_vector.hpp]) BOOST_FIND_HEADER([boost/ptr_container/ptr_array.hpp]) BOOST_FIND_HEADER([boost/ptr_container/ptr_set.hpp]) BOOST_FIND_HEADER([boost/ptr_container/ptr_map.hpp]) ])# BOOST_POINTER_CONTAINER # BOOST_WAVE([PREFERRED-RT-OPT]) # ------------------------------ # NOTE: If you intend to use Wave/Spirit with thread support, make sure you # call BOOST_THREAD first. # Look for Boost.Wave. For the documentation of PREFERRED-RT-OPT, see the # documentation of BOOST_FIND_LIB above. BOOST_DEFUN([Wave], [AC_REQUIRE([BOOST_FILESYSTEM])dnl AC_REQUIRE([BOOST_DATE_TIME])dnl boost_wave_save_LIBS=$LIBS boost_wave_save_LDFLAGS=$LDFLAGS m4_pattern_allow([^BOOST_((FILE)?SYSTEM|DATE_TIME|THREAD)_(LIBS|LDFLAGS)$])dnl LIBS="$LIBS $BOOST_SYSTEM_LIBS $BOOST_FILESYSTEM_LIBS $BOOST_DATE_TIME_LIBS \ $BOOST_THREAD_LIBS" LDFLAGS="$LDFLAGS $BOOST_SYSTEM_LDFLAGS $BOOST_FILESYSTEM_LDFLAGS \ $BOOST_DATE_TIME_LDFLAGS $BOOST_THREAD_LDFLAGS" BOOST_FIND_LIB([wave], [$1], [boost/wave.hpp], [boost::wave::token_id id; get_token_name(id);]) LIBS=$boost_wave_save_LIBS LDFLAGS=$boost_wave_save_LDFLAGS ])# BOOST_WAVE # BOOST_XPRESSIVE() # ----------------- # Look for Boost.Xpressive (new since 1.36.0). BOOST_DEFUN([Xpressive], [BOOST_FIND_HEADER([boost/xpressive/xpressive.hpp])]) # ----------------- # # Internal helpers. # # ----------------- # # _BOOST_PTHREAD_FLAG() # --------------------- # Internal helper for BOOST_THREAD. Computes boost_cv_pthread_flag # which must be used in CPPFLAGS and LIBS. # # Yes, we *need* to put the -pthread thing in CPPFLAGS because with GCC3, # boost/thread.hpp will trigger a #error if -pthread isn't used: # boost/config/requires_threads.hpp:47:5: #error "Compiler threading support # is not turned on. Please set the correct command line options for # threading: -pthread (Linux), -pthreads (Solaris) or -mthreads (Mingw32)" # # Based on ACX_PTHREAD: http://autoconf-archive.cryp.to/acx_pthread.html AC_DEFUN([_BOOST_PTHREAD_FLAG], [AC_REQUIRE([AC_PROG_CXX])dnl AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_LANG_PUSH([C++])dnl AC_CACHE_CHECK([for the flags needed to use pthreads], [boost_cv_pthread_flag], [ boost_cv_pthread_flag= # The ordering *is* (sometimes) important. Some notes on the # individual items follow: # (none): in case threads are in libc; should be tried before -Kthread and # other compiler flags to prevent continual compiler warnings # -lpthreads: AIX (must check this before -lpthread) # -Kthread: Sequent (threads in libc, but -Kthread needed for pthread.h) # -kthread: FreeBSD kernel threads (preferred to -pthread since SMP-able) # -llthread: LinuxThreads port on FreeBSD (also preferred to -pthread) # -pthread: GNU Linux/GCC (kernel threads), BSD/GCC (userland threads) # -pthreads: Solaris/GCC # -mthreads: MinGW32/GCC, Lynx/GCC # -mt: Sun Workshop C (may only link SunOS threads [-lthread], but it # doesn't hurt to check since this sometimes defines pthreads too; # also defines -D_REENTRANT) # ... -mt is also the pthreads flag for HP/aCC # -lpthread: GNU Linux, etc. # --thread-safe: KAI C++ case $host_os in #( *solaris*) # On Solaris (at least, for some versions), libc contains stubbed # (non-functional) versions of the pthreads routines, so link-based # tests will erroneously succeed. (We need to link with -pthreads/-mt/ # -lpthread.) (The stubs are missing pthread_cleanup_push, or rather # a function called by this macro, so we could check for that, but # who knows whether they'll stub that too in a future libc.) So, # we'll just look for -pthreads and -lpthread first: boost_pthread_flags="-pthreads -lpthread -mt -pthread";; #( *) boost_pthread_flags="-lpthreads -Kthread -kthread -llthread -pthread \ -pthreads -mthreads -lpthread --thread-safe -mt";; esac # Generate the test file. AC_LANG_CONFTEST([AC_LANG_PROGRAM([#include ], [pthread_t th; pthread_join(th, 0); pthread_attr_init(0); pthread_cleanup_push(0, 0); pthread_create(0,0,0,0); pthread_cleanup_pop(0);])]) for boost_pthread_flag in '' $boost_pthread_flags; do boost_pthread_ok=false dnl Re-use the test file already generated. boost_pthreads__save_LIBS=$LIBS LIBS="$LIBS $boost_pthread_flag" AC_LINK_IFELSE([], [if grep ".*$boost_pthread_flag" conftest.err; then echo "This flag seems to have triggered warnings" >&AS_MESSAGE_LOG_FD else boost_pthread_ok=:; boost_cv_pthread_flag=$boost_pthread_flag fi]) LIBS=$boost_pthreads__save_LIBS $boost_pthread_ok && break done ]) AC_LANG_POP([C++])dnl ])# _BOOST_PTHREAD_FLAG # _BOOST_gcc_test(MAJOR, MINOR) # ----------------------------- # Internal helper for _BOOST_FIND_COMPILER_TAG. m4_define([_BOOST_gcc_test], ["defined __GNUC__ && __GNUC__ == $1 && __GNUC_MINOR__ == $2 && !defined __ICC @ gcc$1$2"])dnl # _BOOST_mingw_test(MAJOR, MINOR) # ----------------------------- # Internal helper for _BOOST_FIND_COMPILER_TAG. m4_define([_BOOST_mingw_test], ["defined __GNUC__ && __GNUC__ == $1 && __GNUC_MINOR__ == $2 && !defined __ICC && \ (defined WIN32 || defined WINNT || defined _WIN32 || defined __WIN32 \ || defined __WIN32__ || defined __WINNT || defined __WINNT__) @ mgw$1$2"])dnl # _BOOST_FIND_COMPILER_TAG() # -------------------------- # Internal. When Boost is installed without --layout=system, each library # filename will hold a suffix that encodes the compiler used during the # build. The Boost build system seems to call this a `tag'. AC_DEFUN([_BOOST_FIND_COMPILER_TAG], [AC_REQUIRE([AC_PROG_CXX])dnl AC_REQUIRE([AC_CANONICAL_HOST])dnl AC_CACHE_CHECK([for the toolset name used by Boost for $CXX], [boost_cv_lib_tag], [boost_cv_lib_tag=unknown if test x$boost_cv_inc_path != xno; then AC_LANG_PUSH([C++])dnl # The following tests are mostly inspired by boost/config/auto_link.hpp # The list is sorted to most recent/common to oldest compiler (in order # to increase the likelihood of finding the right compiler with the # least number of compilation attempt). # Beware that some tests are sensible to the order (for instance, we must # look for MinGW before looking for GCC3). # I used one compilation test per compiler with a #error to recognize # each compiler so that it works even when cross-compiling (let me know # if you know a better approach). # Known missing tags (known from Boost's tools/build/v2/tools/common.jam): # como, edg, kcc, bck, mp, sw, tru, xlc # I'm not sure about my test for `il' (be careful: Intel's ICC pre-defines # the same defines as GCC's). for i in \ _BOOST_mingw_test(4,8) \ _BOOST_gcc_test(4, 8) \ _BOOST_mingw_test(4,7) \ _BOOST_gcc_test(4, 7) \ _BOOST_mingw_test(4,6) \ _BOOST_gcc_test(4, 6) \ _BOOST_mingw_test(4,5) \ _BOOST_gcc_test(4, 5) \ _BOOST_mingw_test(4,4) \ _BOOST_gcc_test(4, 4) \ _BOOST_mingw_test(4,3) \ _BOOST_gcc_test(4, 3) \ _BOOST_mingw_test(4,2) \ _BOOST_gcc_test(4, 2) \ _BOOST_mingw_test(4,1) \ _BOOST_gcc_test(4, 1) \ _BOOST_mingw_test(4,0) \ _BOOST_gcc_test(4, 0) \ "defined __GNUC__ && __GNUC__ == 3 && !defined __ICC \ && (defined WIN32 || defined WINNT || defined _WIN32 || defined __WIN32 \ || defined __WIN32__ || defined __WINNT || defined __WINNT__) @ mgw" \ _BOOST_gcc_test(3, 4) \ _BOOST_gcc_test(3, 3) \ "defined _MSC_VER && _MSC_VER >= 1500 @ vc90" \ "defined _MSC_VER && _MSC_VER == 1400 @ vc80" \ _BOOST_gcc_test(3, 2) \ "defined _MSC_VER && _MSC_VER == 1310 @ vc71" \ _BOOST_gcc_test(3, 1) \ _BOOST_gcc_test(3, 0) \ "defined __BORLANDC__ @ bcb" \ "defined __ICC && (defined __unix || defined __unix__) @ il" \ "defined __ICL @ iw" \ "defined _MSC_VER && _MSC_VER == 1300 @ vc7" \ _BOOST_gcc_test(2, 95) \ "defined __MWERKS__ && __MWERKS__ <= 0x32FF @ cw9" \ "defined _MSC_VER && _MSC_VER < 1300 && !defined UNDER_CE @ vc6" \ "defined _MSC_VER && _MSC_VER < 1300 && defined UNDER_CE @ evc4" \ "defined __MWERKS__ && __MWERKS__ <= 0x31FF @ cw8" do boost_tag_test=`expr "X$i" : 'X\([[^@]]*\) @ '` boost_tag=`expr "X$i" : 'X[[^@]]* @ \(.*\)'` AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #if $boost_tag_test /* OK */ #else # error $boost_tag_test #endif ]])], [boost_cv_lib_tag=$boost_tag; break], []) done AC_LANG_POP([C++])dnl case $boost_cv_lib_tag in #( # Some newer (>= 1.35?) versions of Boost seem to only use "gcc" as opposed # to "gcc41" for instance. *-gcc | *'-gcc ') :;; #( Don't re-add -gcc: it's already in there. gcc*) boost_tag_x= case $host_os in #( darwin*) if test $boost_major_version -ge 136; then # The `x' added in r46793 of Boost. boost_tag_x=x fi;; esac # We can specify multiple tags in this variable because it's used by # BOOST_FIND_LIB that does a `for tag in -$boost_cv_lib_tag' ... boost_cv_lib_tag="$boost_tag_x$boost_cv_lib_tag -${boost_tag_x}gcc" ;; #( unknown) AC_MSG_WARN([[could not figure out which toolset name to use for $CXX]]) boost_cv_lib_tag= ;; esac fi])dnl end of AC_CACHE_CHECK ])# _BOOST_FIND_COMPILER_TAG # _BOOST_GUESS_WHETHER_TO_USE_MT() # -------------------------------- # Compile a small test to try to guess whether we should favor MT (Multi # Thread) flavors of Boost. Sets boost_guess_use_mt accordingly. AC_DEFUN([_BOOST_GUESS_WHETHER_TO_USE_MT], [# Check whether we do better use `mt' even though we weren't ask to. AC_LANG_PUSH([C++])dnl AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #if defined _REENTRANT || defined _MT || defined __MT__ /* use -mt */ #else # error MT not needed #endif ]])], [boost_guess_use_mt=:], [boost_guess_use_mt=false]) AC_LANG_POP([C++])dnl ]) # _BOOST_AC_LINK_IFELSE(PROGRAM, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) # ------------------------------------------------------------------- # Fork of _AC_LINK_IFELSE that preserves conftest.o across calls. Fragile, # will break when Autoconf changes its internals. Requires that you manually # rm -f conftest.$ac_objext in between to really different tests, otherwise # you will try to link a conftest.o left behind by a previous test. # Used to aggressively optimize BOOST_FIND_LIB (see the big comment in this # macro). # # Don't use "break" in the actions, as it would short-circuit some code # this macro runs after the actions. m4_define([_BOOST_AC_LINK_IFELSE], [m4_ifvaln([$1], [AC_LANG_CONFTEST([$1])])dnl rm -f conftest$ac_exeext boost_save_ac_ext=$ac_ext boost_use_source=: # If we already have a .o, re-use it. We change $ac_ext so that $ac_link # tries to link the existing object file instead of compiling from source. test -f conftest.$ac_objext && ac_ext=$ac_objext && boost_use_source=false && _AS_ECHO_LOG([re-using the existing conftest.$ac_objext]) AS_IF([_AC_DO_STDERR($ac_link) && { test -z "$ac_[]_AC_LANG_ABBREV[]_werror_flag" || test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || $as_executable_p conftest$ac_exeext dnl FIXME: use AS_TEST_X instead when 2.61 is widespread enough. }], [$2], [if $boost_use_source; then _AC_MSG_LOG_CONFTEST fi $3]) ac_objext=$boost_save_ac_objext ac_ext=$boost_save_ac_ext dnl Delete also the IPA/IPO (Inter Procedural Analysis/Optimization) dnl information created by the PGI compiler (conftest_ipa8_conftest.oo), dnl as it would interfere with the next link command. rm -f core conftest.err conftest_ipa8_conftest.oo \ conftest$ac_exeext m4_ifval([$1], [conftest.$ac_ext])[]dnl ])# _BOOST_AC_LINK_IFELSE # Local Variables: # mode: autoconf # End: GenGeo-1.2/m4/python.m40000644000000000000000000002771412533740504012767 0ustar 00000000000000## ------------------------ -*- Autoconf -*- ## Python file handling ## From Andrew Dalke ## Updated by James Henstridge ## ------------------------ # Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008, 2009 # Free Software Foundation, Inc. # # This file is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. # AM_PATH_PYTHON([MINIMUM-VERSION], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) # --------------------------------------------------------------------------- # Adds support for distributing Python modules and packages. To # install modules, copy them to $(pythondir), using the python_PYTHON # automake variable. To install a package with the same name as the # automake package, install to $(pkgpythondir), or use the # pkgpython_PYTHON automake variable. # # The variables $(pyexecdir) and $(pkgpyexecdir) are provided as # locations to install python extension modules (shared libraries). # Another macro is required to find the appropriate flags to compile # extension modules. # # If your package is configured with a different prefix to python, # users will have to add the install directory to the PYTHONPATH # environment variable, or create a .pth file (see the python # documentation for details). # # If the MINIMUM-VERSION argument is passed, AM_PATH_PYTHON will # cause an error if the version of python installed on the system # doesn't meet the requirement. MINIMUM-VERSION should consist of # numbers and dots only. ############ CHANGES FOR GENGEO (search for GENGEO for details) ############ # * updated the search list of Python executables # * added the detection of Python major and minor versions # * added the detection of ABI tags used in Python names from version 3.2 # * added a check for the location of the fully named Python executable AC_DEFUN([AM_PATH_PYTHON], [ dnl Find a Python interpreter. Python versions prior to 2.0 are not dnl supported. (2.0 was released on October 16, 2000). dnl dnl CHANGED FOR GENGEO: dnl * Search list of Python executables updated m4_define_default([_AM_PYTHON_INTERPRETER_LIST], [python python2 python3 python2.0 python2.1 python2.2 dnl python2.3 python2.4 python2.5 python2.6 python2.7 python3.0 python3.1 python3.2 dnl python3.3 python3.4 python3.5 python3.6 python3.7 python3.8 python3.9]) m4_if([$1],[],[ dnl No version check is needed. # Find any Python interpreter. if test -z "$PYTHON"; then AC_PATH_PROGS([PYTHON], _AM_PYTHON_INTERPRETER_LIST, :) fi am_display_PYTHON=python ], [ dnl A version check is needed. if test -n "$PYTHON"; then # If the user set $PYTHON, use it and don't search something else. AC_MSG_CHECKING([whether $PYTHON version >= $1]) AM_PYTHON_CHECK_VERSION([$PYTHON], [$1], [AC_MSG_RESULT(yes)], [AC_MSG_ERROR(too old)]) am_display_PYTHON=$PYTHON else # Otherwise, try each interpreter until we find one that satisfies # VERSION. AC_CACHE_CHECK([for a Python interpreter with version >= $1], [am_cv_pathless_PYTHON],[ for am_cv_pathless_PYTHON in _AM_PYTHON_INTERPRETER_LIST none; do test "$am_cv_pathless_PYTHON" = none && break AM_PYTHON_CHECK_VERSION([$am_cv_pathless_PYTHON], [$1], [break]) done]) # Set $PYTHON to the absolute path of $am_cv_pathless_PYTHON. if test "$am_cv_pathless_PYTHON" = none; then PYTHON=: else AC_PATH_PROG([PYTHON], [$am_cv_pathless_PYTHON]) fi am_display_PYTHON=$am_cv_pathless_PYTHON fi ]) if test "$PYTHON" = :; then dnl Run any user-specified action, or abort. m4_default([$3], [AC_MSG_ERROR([no suitable Python interpreter found])]) else dnl Query Python for its version number. Getting [:3] seems to be dnl the best way to do this; it's what "site.py" does in the standard dnl library. AC_CACHE_CHECK([for $am_display_PYTHON version], [am_cv_python_version], [am_cv_python_version=`$PYTHON -c "import sys; sys.stdout.write(sys.version[[:3]])"`]) AC_SUBST([PYTHON_VERSION], [$am_cv_python_version]) dnl CHANGED FOR GENGEO: dnl * Added the detection of Python major and minor versions dnl * Added the check for Python version 3.2 and higher as the naming convention for dnl libraries changed to allow any combination of the tags `d', `m' and `u'; so this dnl adds the PYTHON_VERSION_SUFFIX variable to be used on any subsequent commands. dnl (The next commented lines are two earlier solutions for handling the new naming convention.) dnl * Added a check for the location of the fully named Python executable am_cv_python_major_version=`$PYTHON -c "import sys;sys.stdout.write(str(sys.version_info[[0]]))"` am_cv_python_minor_version=`$PYTHON -c "import sys;sys.stdout.write(str(sys.version_info[[1]]))"` AC_SUBST([PYTHON_MAJOR_VERSION], [${am_cv_python_major_version}]) AC_SUBST([PYTHON_MINOR_VERSION], [${am_cv_python_minor_version}]) if [[ $PYTHON_MAJOR_VERSION -ge 4 ]] || ([[ $PYTHON_MAJOR_VERSION -eq 3 ]] && [[ $PYTHON_MINOR_VERSION -ge 2 ]]) then # # Current GENGEO solution to Python's new naming convention AC_MSG_CHECKING(for the Python ABI tags) am_cv_python_version_suffix=`$PYTHON -c "import sys,sysconfig;sys.stdout.write(sysconfig.get_config_var('ABIFLAGS'))"` AC_MSG_RESULT([${am_cv_python_version_suffix}]) # # Second GENGEO solution to Python's new naming convention #am_cv_pyconfig_h=`$PYTHON -c "import sys,sysconfig;sys.stdout.write(sysconfig.get_config_h_filename())"` #am_cv_python_version_suffix=${am_cv_pyconfig_h#*python${PYTHON_VERSION}} #am_cv_python_version_suffix=${am_cv_python_version_suffix%\/*} # # First GENGEO solution to Python's new naming convention #am_cv_python_pymalloc=m #am_cv_python_wide_unicode=`$PYTHON -c "exec(\"import sys\\nif sys.maxunicode == 1114111 and sys.version_info[[0]] == 3 and sys.version_info[[1]] == 2: sys.stdout.write('u')\")"` #AC_MSG_CHECKING(for Python's Py_DEBUG status) #m4_pattern_allow([^Py_DEBUG$])dnl #AC_EGREP_CPP(yes, # [ # #include <${am_cv_pyconfig_h}> # #if Py_DEBUG == 1 # python-pydebug-status = yes # #endif # ], # [am_cv_python_pydebug_status=1; am_cv_python_pydebug=d], # [am_cv_python_pydebug_status="0 or undefined"; am_cv_pydebug_info="no tag"; am_cv_python_pydebug=]) #AC_MSG_RESULT([${am_cv_python_pydebug_status} => ${am_cv_pydebug_info}${am_cv_python_pydebug}]) #AC_MSG_CHECKING(for Python's WITH_PYMALLOC status) #m4_pattern_allow([^WITH_PYMALLOC$])dnl #AC_EGREP_CPP(yes, # [ # #include <${am_cv_pyconfig_h}> # #if WITH_PYMALLOC == 1 # python-pymalloc-status = yes # #endif # ], # [am_cv_python_pymalloc_status=1; am_cv_python_pymalloc=m], # [am_cv_python_pymalloc_status="0 or undefined"; am_cv_pymalloc_info="no tag"; am_cv_python_pymalloc=]) #AC_MSG_RESULT([${am_cv_python_pymalloc_status} => ${am_cv_pymalloc_info}${am_cv_python_pymalloc}]) fi # # First GENGEO solution to Python's new naming convention #AC_SUBST([PYTHON_VERSION_SUFFIX], [$am_cv_python_pydebug$am_cv_python_pymalloc$am_cv_python_wide_unicode]) AC_SUBST([PYTHON_VERSION_SUFFIX], [${am_cv_python_version_suffix}]) AC_MSG_CHECKING([for the location of the Python executable python${PYTHON_VERSION}${PYTHON_VERSION_SUFFIX}]) am_cv_python_bin=$(which python${PYTHON_VERSION}${PYTHON_VERSION_SUFFIX}) if ! test -z ${am_cv_python_bin} then AC_MSG_RESULT([${am_cv_python_bin}]) else AC_MSG_ERROR( [not found: the ABI tag combination "${PYTHON_VERSION_SUFFIX}" calculated for the library name is wrong]) fi dnl Use the values of $prefix and $exec_prefix for the corresponding dnl values of PYTHON_PREFIX and PYTHON_EXEC_PREFIX. These are made dnl distinct variables so they can be overridden if need be. However, dnl general consensus is that you shouldn't need this ability. AC_SUBST([PYTHON_PREFIX], ['${prefix}']) AC_SUBST([PYTHON_EXEC_PREFIX], ['${exec_prefix}']) dnl At times (like when building shared libraries) you may want dnl to know which OS platform Python thinks this is. AC_CACHE_CHECK([for $am_display_PYTHON platform], [am_cv_python_platform], [am_cv_python_platform=`$PYTHON -c "import sys; sys.stdout.write(sys.platform)"`]) AC_SUBST([PYTHON_PLATFORM], [$am_cv_python_platform]) dnl Set up 4 directories: dnl pythondir -- where to install python scripts. This is the dnl site-packages directory, not the python standard library dnl directory like in previous automake betas. This behavior dnl is more consistent with lispdir.m4 for example. dnl Query distutils for this directory. distutils does not exist in dnl Python 1.5, so we fall back to the hardcoded directory if it dnl doesn't work. AC_CACHE_CHECK([for $am_display_PYTHON script directory], [am_cv_python_pythondir], [if test "x$prefix" = xNONE then am_py_prefix=$ac_default_prefix else am_py_prefix=$prefix fi am_cv_python_pythondir=`$PYTHON -c "import sys; from distutils import sysconfig; sys.stdout.write(sysconfig.get_python_lib(0,0,prefix='$am_py_prefix'))" 2>/dev/null || echo "$PYTHON_PREFIX/lib/python$PYTHON_VERSION/site-packages"` case $am_cv_python_pythondir in $am_py_prefix*) am__strip_prefix=`echo "$am_py_prefix" | sed 's|.|.|g'` am_cv_python_pythondir=`echo "$am_cv_python_pythondir" | sed "s,^$am__strip_prefix,$PYTHON_PREFIX,"` ;; esac ]) AC_SUBST([pythondir], [$am_cv_python_pythondir]) dnl pkgpythondir -- $PACKAGE directory under pythondir. Was dnl PYTHON_SITE_PACKAGE in previous betas, but this naming is dnl more consistent with the rest of automake. AC_SUBST([pkgpythondir], [\${pythondir}/$PACKAGE]) dnl pyexecdir -- directory for installing python extension modules dnl (shared libraries) dnl Query distutils for this directory. distutils does not exist in dnl Python 1.5, so we fall back to the hardcoded directory if it dnl doesn't work. AC_CACHE_CHECK([for $am_display_PYTHON extension module directory], [am_cv_python_pyexecdir], [if test "x$exec_prefix" = xNONE then am_py_exec_prefix=$am_py_prefix else am_py_exec_prefix=$exec_prefix fi am_cv_python_pyexecdir=`$PYTHON -c "import sys; from distutils import sysconfig; sys.stdout.write(sysconfig.get_python_lib(1,0,prefix='$am_py_exec_prefix'))" 2>/dev/null || echo "$PYTHON_EXEC_PREFIX/lib/python$PYTHON_VERSION/site-packages"` case $am_cv_python_pyexecdir in $am_py_exec_prefix*) am__strip_prefix=`echo "$am_py_exec_prefix" | sed 's|.|.|g'` am_cv_python_pyexecdir=`echo "$am_cv_python_pyexecdir" | sed "s,^$am__strip_prefix,$PYTHON_EXEC_PREFIX,"` ;; esac ]) AC_SUBST([pyexecdir], [$am_cv_python_pyexecdir]) dnl pkgpyexecdir -- $(pyexecdir)/$(PACKAGE) AC_SUBST([pkgpyexecdir], [\${pyexecdir}/$PACKAGE]) dnl Run any user-specified action. $2 fi ]) # AM_PYTHON_CHECK_VERSION(PROG, VERSION, [ACTION-IF-TRUE], [ACTION-IF-FALSE]) # --------------------------------------------------------------------------- # Run ACTION-IF-TRUE if the Python interpreter PROG has version >= VERSION. # Run ACTION-IF-FALSE otherwise. # This test uses sys.hexversion instead of the string equivalent (first # word of sys.version), in order to cope with versions such as 2.2c1. # This supports Python 2.0 or higher. (2.0 was released on October 16, 2000). AC_DEFUN([AM_PYTHON_CHECK_VERSION], [prog="import sys # split strings by '.' and convert to numeric. Append some zeros # because we need at least 4 digits for the hex conversion. # map returns an iterator in Python 3.0 and a list in 2.x minver = list(map(int, '$2'.split('.'))) + [[0, 0, 0]] minverhex = 0 # xrange is not present in Python 3.0 and range returns an iterator for i in list(range(0, 4)): minverhex = (minverhex << 8) + minver[[i]] sys.exit(sys.hexversion < minverhex)" AS_IF([AM_RUN_LOG([$1 -c "$prog"])], [$3], [$4])]) GenGeo-1.2/sphere_fitting/Sphere2DFitter.cc0000644000000000000000000000351112533740504016764 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "Sphere2DFitter.h" // --- project includes --- #include "sphere_fitting/utils/nvector.h" #include "sphere_fitting/utils/nfunction.h" #include "sphere_fitting/utils/simplex.h" #include "fit_2d_sphere.h" // --- IO includes --- #include Sphere FitSphere2D(const AGeometricObject* GO1, const AGeometricObject* GO2, const AGeometricObject* GO3, const Vector3& spos, int max_iter,double prec) { Sphere res; simplex_method *simplex; nvector start,sol; fit_2d_sphere_fn* sfn; // set initial position to barycenter of input spheres start[0]=spos.x(); start[1]=spos.y(); // set fitting function sfn=new fit_2d_sphere_fn(GO1,GO2,GO3); // solve for center simplex=new simplex_method(sfn); sol=simplex->solve(prec,start,max_iter); // calc radius : min radius relative to 3 spheres - tol Vector3 center=Vector3(sol[0],sol[1],0.0); double r1=GO1->getDist(center); double r2=GO2->getDist(center); double r3=GO3->getDist(center); double r=(r1 Sphere FitSphere3D(const AGeometricObject* GO1, const AGeometricObject* GO2, const AGeometricObject* GO3, const AGeometricObject* GO4, const Vector3& spos, int max_iter,double prec) { Sphere res; simplex_method *simplex; nvector start,sol; fit_3d_sphere_fn* sfn; // set initial position to barycenter of input spheres start[0]=spos.x(); start[1]=spos.y(); start[2]=spos.z(); // set fitting function sfn=new fit_3d_sphere_fn(GO1,GO2,GO3,GO4); // solve for center simplex=new simplex_method(sfn); sol=simplex->solve(prec,start,max_iter); // calc radius : min radius relative to 3 spheres - tol Vector3 center=Vector3(sol[0],sol[1],sol[2]); double r1=GO1->getDist(center); double r2=GO2->getDist(center); double r3=GO3->getDist(center); double r4=GO4->getDist(center); double r=(r1 #include using std::sqrt; /*! */ fit_2d_sphere_fn::fit_2d_sphere_fn(const AGeometricObject* GO1,const AGeometricObject* GO2,const AGeometricObject* GO3) { m_GO1=GO1; m_GO2=GO2; m_GO3=GO3; } double fit_2d_sphere_fn::operator()(const nvector& data) const { Vector3 x=Vector3(data[0],data[1],0.0); double ra=m_GO1->getDist(x); double rb=m_GO2->getDist(x); double rc=m_GO3->getDist(x); double rq=(ra+rb+rc)/3.0; double dr=sqrt((rq-ra)*(rq-ra)+(rq-rb)*(rq-rb)+(rq-rc)*(rq-rc)); return dr; } GenGeo-1.2/sphere_fitting/fit_2d_sphere.h0000644000000000000000000000236212533740504016554 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __FIT_2D_SPHERE_FN_H #define __FIT_2D_SPHERE_FN_H // --- project includes --- #include "sphere_fitting/utils/nvector.h" #include "sphere_fitting/utils/nfunction.h" #include "util/vector3.h" #include "geometry/AGeometricObject.h" class fit_2d_sphere_fn : public nfunction { private: const AGeometricObject *m_GO1,*m_GO2,*m_GO3; public: fit_2d_sphere_fn(const AGeometricObject*,const AGeometricObject*,const AGeometricObject*); virtual ~fit_2d_sphere_fn(){}; virtual double operator()(const nvector&) const; }; #endif // __FIT_2D_SPHERE_FN_H GenGeo-1.2/sphere_fitting/fit_3d_sphere.cc0000644000000000000000000000253512533740504016715 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "fit_3d_sphere.h" #include #include using std::sqrt; fit_3d_sphere_fn::fit_3d_sphere_fn(const AGeometricObject* GO1, const AGeometricObject* GO2, const AGeometricObject* GO3, const AGeometricObject* GO4) { m_GO1=GO1; m_GO2=GO2; m_GO3=GO3; m_GO4=GO4; } double fit_3d_sphere_fn::operator()(const nvector& data) const { Vector3 x=Vector3(data[0],data[1],data[2]); double ra=m_GO1->getDist(x); double rb=m_GO2->getDist(x); double rc=m_GO3->getDist(x); double rd=m_GO4->getDist(x); double rq=(ra+rb+rc+rd)*0.25; double dr=sqrt((rq-ra)*(rq-ra)+(rq-rb)*(rq-rb)+(rq-rc)*(rq-rc)+(rq-rd)*(rq-rd)); return dr; } GenGeo-1.2/sphere_fitting/fit_3d_sphere.h0000644000000000000000000000242012533740504016550 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __FIT_3D_SPHERE_FN_H #define __FIT_3D_SPHERE_FN_H // --- project includes --- #include "sphere_fitting/utils/nvector.h" #include "sphere_fitting/utils/nfunction.h" #include "util/vector3.h" #include "geometry/AGeometricObject.h" class fit_3d_sphere_fn : public nfunction { private: const AGeometricObject *m_GO1,*m_GO2,*m_GO3,*m_GO4; public: fit_3d_sphere_fn(const AGeometricObject*,const AGeometricObject*,const AGeometricObject*,const AGeometricObject*); virtual ~fit_3d_sphere_fn(){}; virtual double operator()(const nvector&) const; }; #endif // __FIT_2D_SPHERE_FN_H GenGeo-1.2/sphere_fitting/fit_functions/0000755000000000000000000000000012533740504016535 5ustar 00000000000000GenGeo-1.2/sphere_fitting/module.mk0000644000000000000000000000023612533740504015502 0ustar 00000000000000SRC += sphere_fitting/Sphere2DFitter.cc SRC += sphere_fitting/Sphere3DFitter.cc SRC += sphere_fitting/fit_2d_sphere.cc SRC += sphere_fitting/fit_3d_sphere.cc GenGeo-1.2/sphere_fitting/utils/0000755000000000000000000000000012533740504015023 5ustar 00000000000000GenGeo-1.2/sphere_fitting/fit_functions/fit_2d_sphere_2lines.cc0000644000000000000000000000261312533740504023037 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "fit_2d_sphere_2lines.h" #include using std::sqrt; using std::fabs; fit_2d_sphere_2lines_fn::fit_2d_sphere_2lines_fn(const Vector3& sc, double r,const Vector3& o1, const Vector3& n1,const Vector3& o2, const Vector3&n2) { m_p=sc; m_r=r; m_orig1=o1; m_nor1=n1; m_orig2=o2; m_nor2=n2; } double fit_2d_sphere_2lines_fn::operator()(const nvector& data) const { double x=data[0]; double y=data[1]; double ra=sqrt((x-m_p.x())*(x-m_p.x())+(y-m_p.y())*(y-m_p.y()))-m_r; double rb=fabs(dot((Vector3(x,y,0.0)-m_orig1),m_nor1)); double rc=fabs(dot((Vector3(x,y,0.0)-m_orig2),m_nor2)); double rq=(ra+rb+rc)/3.0; double dr=sqrt((rq-ra)*(rq-ra)+(rq-rb)*(rq-rb)+(rq-rc)*(rq-rc)); return dr; } GenGeo-1.2/sphere_fitting/fit_functions/fit_2d_sphere_2lines.h0000644000000000000000000000245012533740504022700 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __FIT_2D_SPHERE_2LINES_FN_H #define __FIT_2D_SPHERE_2LINES_FN_H #include "sphere_fitting/utils/nvector.h" #include "sphere_fitting/utils/nfunction.h" #include "util/vector3.h" class fit_2d_sphere_2lines_fn : public nfunction { private: Vector3 m_p; // sphere center double m_r; // sphere radii Vector3 m_orig1,m_nor1,m_orig2,m_nor2; // lines public: fit_2d_sphere_2lines_fn(const Vector3&, double,const Vector3&, const Vector3& ,const Vector3&, const Vector3&); virtual ~fit_2d_sphere_2lines_fn(){}; virtual double operator()(const nvector&) const; }; #endif // __FIT_2D_SPHERE_2LINES_FN_H GenGeo-1.2/sphere_fitting/fit_functions/fit_2d_sphere_line.cc0000644000000000000000000000263612533740504022577 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "fit_2d_sphere_line.h" #include using std::sqrt; using std::fabs; /*! */ fit_2d_sphere_line_fn::fit_2d_sphere_line_fn(const Vector3& sc1, double r1,const Vector3& sc2, double r2,const Vector3& o, const Vector3& n) { m_p1=sc1; m_p2=sc2; m_r1=r1; m_r2=r2; m_orig=o; m_nor=n; } /*! */ double fit_2d_sphere_line_fn::operator()(const nvector& data) const { double x=data[0]; double y=data[1]; double ra=sqrt((x-m_p1.x())*(x-m_p1.x())+(y-m_p1.y())*(y-m_p1.y()))-m_r1; double rb=sqrt((x-m_p2.x())*(x-m_p2.x())+(y-m_p2.y())*(y-m_p2.y()))-m_r2; double rc=fabs(dot((Vector3(x,y,0.0)-m_orig),m_nor)); double rq=(ra+rb+rc)/3.0; double dr=sqrt((rq-ra)*(rq-ra)+(rq-rb)*(rq-rb)+(rq-rc)*(rq-rc)); return dr; } GenGeo-1.2/sphere_fitting/fit_functions/fit_2d_sphere_line.h0000644000000000000000000000241612533740504022435 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __FIT_2D_SPHERE_LINE_FN_H #define __FIT_2D_SPHERE_LINE_FN_H #include "sphere_fitting/utils/nvector.h" #include "sphere_fitting/utils/nfunction.h" #include "util/vector3.h" class fit_2d_sphere_line_fn : public nfunction { private: Vector3 m_p1,m_p2; // sphere centers double m_r1,m_r2; // sphere radii Vector3 m_orig,m_nor; // line public: fit_2d_sphere_line_fn(const Vector3&, double,const Vector3&, double,const Vector3&, const Vector3&); virtual ~fit_2d_sphere_line_fn(){}; virtual double operator()(const nvector&) const; }; #endif // __FIT_2D_SPHERE_LINE_FN_H GenGeo-1.2/sphere_fitting/fit_functions/fit_3d_1sphere_3lines.cc0000644000000000000000000000315712533740504023126 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "fit_3d_1sphere_3lines.h" #include using std::sqrt; using std::fabs; fit_3d_1sphere_3lines_fn::fit_3d_1sphere_3lines_fn(const Vector3& sc, double r, const Vector3& o1, const Vector3& n1, const Vector3& o2, const Vector3& n2, const Vector3& o3, const Vector3& n3) { m_p1=sc; m_r1=r; m_orig1=o1; m_nor1=n1; m_orig2=o2; m_nor2=n2; m_orig3=o3; m_nor3=n3; } double fit_3d_1sphere_3lines_fn::operator()(const nvector& data) const { double x=data[0]; double y=data[1]; double z=data[2]; double ra=sqrt((x-m_p1.x())*(x-m_p1.x())+(y-m_p1.y())*(y-m_p1.y())+(z-m_p1.z())*(z-m_p1.z()))-m_r1; double rb=fabs(dot((Vector3(x,y,z)-m_orig1),m_nor1)); double rc=fabs(dot((Vector3(x,y,z)-m_orig2),m_nor2)); double rd=fabs(dot((Vector3(x,y,z)-m_orig3),m_nor3)); double rq=0.25*(ra+rb+rc+rd); double dr=sqrt((rq-ra)*(rq-ra)+(rq-rb)*(rq-rb)+(rq-rc)*(rq-rc)+(rq-rd)*(rq-rd)); return dr; } GenGeo-1.2/sphere_fitting/fit_functions/fit_3d_1sphere_3lines.h0000644000000000000000000000254012533740504022763 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __FIT_3D_1SPHERE_3LINES_FN_H #define __FIT_3D_1SPHERE_3LINES_FN_H #include "sphere_fitting/utils/nvector.h" #include "sphere_fitting/utils/nfunction.h" #include "util/vector3.h" class fit_3d_1sphere_3lines_fn : public nfunction { private: Vector3 m_p1; // sphere center double m_r1; // sphere radius Vector3 m_orig1,m_nor1,m_orig2,m_nor2,m_orig3,m_nor3; // planes public: fit_3d_1sphere_3lines_fn(const Vector3&, double, const Vector3& ,const Vector3&,const Vector3&, const Vector3&,const Vector3&, const Vector3&); virtual ~fit_3d_1sphere_3lines_fn(){}; virtual double operator()(const nvector&) const; }; #endif // __FIT_3D_1SPHERE_3LINES_FN_H GenGeo-1.2/sphere_fitting/fit_functions/fit_3d_2spheres_2lines.cc0000644000000000000000000000322512533740504023305 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "fit_3d_2spheres_2lines.h" #include using std::sqrt; using std::fabs; fit_3d_2spheres_2lines_fn::fit_3d_2spheres_2lines_fn(const Vector3& sc1, double r1, const Vector3& sc2, double r2, const Vector3& o1, const Vector3& n1, const Vector3& o2, const Vector3& n2) { m_p1=sc1; m_p2=sc2; m_r1=r1; m_r2=r2; m_orig1=o1; m_nor1=n1; m_orig2=o2; m_nor2=n2; } double fit_3d_2spheres_2lines_fn::operator()(const nvector& data) const { double x=data[0]; double y=data[1]; double z=data[2]; double ra=sqrt((x-m_p1.x())*(x-m_p1.x())+(y-m_p1.y())*(y-m_p1.y())+(z-m_p1.z())*(z-m_p1.z()))-m_r1; double rb=sqrt((x-m_p2.x())*(x-m_p2.x())+(y-m_p2.y())*(y-m_p2.y())+(z-m_p2.z())*(z-m_p2.z()))-m_r2; double rc=dot((Vector3(x,y,z)-m_orig1),m_nor1); double rd=dot((Vector3(x,y,z)-m_orig2),m_nor2); double rq=0.25*(ra+rb+rc+rd); double dr=sqrt((rq-ra)*(rq-ra)+(rq-rb)*(rq-rb)+(rq-rc)*(rq-rc)+(rq-rd)*(rq-rd)); return dr; } GenGeo-1.2/sphere_fitting/fit_functions/fit_3d_2spheres_2lines.h0000644000000000000000000000253012533740504023145 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __FIT_3D_2SPHERES_2LINES_FN_H #define __FIT_3D_2SPHERES_2LINES_FN_H #include "sphere_fitting/utils/nvector.h" #include "sphere_fitting/utils/nfunction.h" #include "util/vector3.h" class fit_3d_2spheres_2lines_fn : public nfunction { private: Vector3 m_p1,m_p2; // sphere centers double m_r1,m_r2; // sphere radii Vector3 m_orig1,m_nor1,m_orig2,m_nor2; // planes public: fit_3d_2spheres_2lines_fn(const Vector3&, double,const Vector3&, double,const Vector3&, const Vector3&,const Vector3&, const Vector3&); virtual ~fit_3d_2spheres_2lines_fn(){}; virtual double operator()(const nvector&) const; }; #endif // __FIT_3D_2SPHERES_2LINES_FN_H GenGeo-1.2/sphere_fitting/fit_functions/fit_3d_3spheres_1line.cc0000644000000000000000000000325612533740504023126 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "fit_3d_3spheres_1line.h" #include using std::sqrt; using std::fabs; fit_3d_3spheres_1line_fn::fit_3d_3spheres_1line_fn(const Vector3& sc1, double r1, const Vector3& sc2, double r2, const Vector3& sc3, double r3, const Vector3& o, const Vector3& n) { m_p1=sc1; m_p2=sc2; m_p3=sc3; m_r1=r1; m_r2=r2; m_r3=r3; m_orig=o; m_nor=n; } double fit_3d_3spheres_1line_fn::operator()(const nvector& data) const { double x=data[0]; double y=data[1]; double z=data[2]; double ra=sqrt((x-m_p1.x())*(x-m_p1.x())+(y-m_p1.y())*(y-m_p1.y())+(z-m_p1.z())*(z-m_p1.z()))-m_r1; double rb=sqrt((x-m_p2.x())*(x-m_p2.x())+(y-m_p2.y())*(y-m_p2.y())+(z-m_p2.z())*(z-m_p2.z()))-m_r2; double rc=sqrt((x-m_p3.x())*(x-m_p3.x())+(y-m_p3.y())*(y-m_p3.y())+(z-m_p3.z())*(z-m_p3.z()))-m_r3; double rd=dot((Vector3(x,y,z)-m_orig),m_nor); double rq=0.25*(ra+rb+rc+rd); double dr=sqrt((rq-ra)*(rq-ra)+(rq-rb)*(rq-rb)+(rq-rc)*(rq-rc)+(rq-rd)*(rq-rd)); return dr; } GenGeo-1.2/sphere_fitting/fit_functions/fit_3d_3spheres_1line.h0000644000000000000000000000247612533740504022773 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __FIT_3D_3SPHERES_1LINE_FN_H #define __FIT_3D_3SPHERES_1LINE_FN_H #include "sphere_fitting/utils/nvector.h" #include "sphere_fitting/utils/nfunction.h" #include "util/vector3.h" class fit_3d_3spheres_1line_fn : public nfunction { private: Vector3 m_p1,m_p2,m_p3; // sphere centers double m_r1,m_r2,m_r3; // sphere radii Vector3 m_orig,m_nor; // line public: fit_3d_3spheres_1line_fn(const Vector3&, double,const Vector3&, double,const Vector3&, double,const Vector3&, const Vector3&); virtual ~fit_3d_3spheres_1line_fn(){}; virtual double operator()(const nvector&) const; }; #endif // __FIT_2D_SPHERE_LINE_FN_H GenGeo-1.2/sphere_fitting/fit_functions/module.mk0000644000000000000000000000014612533740504020354 0ustar 00000000000000SRC+=sphere_fitting/fit_functions/fit_2d_sphere.cc SRC+=sphere_fitting/fit_functions/fit_3d_sphere.cc GenGeo-1.2/sphere_fitting/utils/module.mk0000644000000000000000000000001012533740504016630 0ustar 00000000000000SRC += GenGeo-1.2/sphere_fitting/utils/nfunction.h0000644000000000000000000000164212533740504017202 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// // function of nvector #ifndef __NFUNCTION_H #define __NFUNCTION_H #include "nvector.h" template class nfunction { public: virtual T operator()(const nvector&) const=0; virtual ~nfunction(){}; }; #endif //__NFUNCTION_H GenGeo-1.2/sphere_fitting/utils/nvector.h0000644000000000000000000000314312533740504016655 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// // arbitrary size vectors #ifndef __NVECTOR_H #define __NVECTOR_H #include using std::ostream; template class nvector; template nvector operator/(const nvector&, T); template ostream& operator<<(ostream& ,const nvector&); template class nvector { private: T m_data[n]; public: nvector(); nvector(const T); nvector(const nvector&); ~nvector(); inline T operator[](int i) const {return m_data[i];}; inline T& operator[](int i){return m_data[i];}; nvector& operator=(const nvector&); nvector& operator-=(const nvector&); nvector& operator+=(const nvector&); nvector operator-(const nvector&) const; nvector operator+(const nvector&) const; friend nvector operator/ <>(const nvector&,T); static nvector unit(int); friend ostream& operator<< <>(ostream&,const nvector&); }; #include "nvector.hh" #endif //__NVECTOR_H GenGeo-1.2/sphere_fitting/utils/nvector.hh0000644000000000000000000000466112533740504017033 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// template nvector::nvector() {} template nvector::nvector(const T t) { for(int i=0;i nvector::nvector(const nvector& v) { for(int i=0;i nvector::~nvector() {} template nvector& nvector::operator=(const nvector& v) { if(&v!=this){ for(int i=0;i nvector& nvector::operator-=(const nvector& v) { for(int i=0;i nvector& nvector::operator+=(const nvector& v) { for(int i=0;i nvector nvector::operator+(const nvector& v) const { nvector res; for(int i=0;i nvector nvector::operator-(const nvector& v) const { nvector res; for(int i=0;i nvector operator/(const nvector& v, T d) { nvector res; for(int i=0;i nvector nvector::unit(int i) { nvector res; for(int j=0;j ostream& operator<<(ostream& ost,const nvector& v) { ost << "<" << v.m_data[0]; for(int i=1;i"; return ost; } GenGeo-1.2/sphere_fitting/utils/simplex.h0000644000000000000000000000224712533740504016662 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// // simplex method #ifndef __SIMPLEX_H #define __SIMPLEX_H #include "nvector.h" #include "nfunction.h" #include template class simplex_method { private: nfunction* m_func; nvector m_vert[n+1]; T m_val[n+1]; nvector reflect(int); void insert(const nvector&,T,int); void shrink(); void sort(); public: simplex_method(nfunction*); nvector solve(T,const nvector &,int max=-1); }; #include "simplex.hh" #endif //__SIMPLEX_H GenGeo-1.2/sphere_fitting/utils/simplex.hh0000644000000000000000000000651512533740504017034 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// template simplex_method::simplex_method(nfunction* f) { m_func=f; } template nvector simplex_method::reflect(int idx) { nvector sum=nvector(T(0)); for(int i=0;i void simplex_method::insert(const nvector& vert,T val,int idx) { bool up=true; bool down=true; m_vert[idx]=vert; m_val[idx]=val; int i=idx; while(up && (im_val[i+1]){ up=false; } else { // swap nvector h_vert=m_vert[i]; T h_val=m_val[i]; m_vert[i]=m_vert[i+1]; m_val[i]=m_val[i+1]; m_vert[i+1]=h_vert; m_val[i+1]=h_val; i++; } } while(down && (i>0)){ if(m_val[i] h_vert=m_vert[i]; T h_val=m_val[i]; m_vert[i]=m_vert[i-1]; m_val[i]=m_val[i-1]; m_vert[i-1]=h_vert; m_val[i-1]=h_val; i--; } } } template void simplex_method::shrink() { nvector center=m_vert[0]; for(int i=1;i void simplex_method::sort() { for(int i=0;i h_vert=m_vert[j]; T h_val=m_val[j]; m_vert[j]=m_vert[j+1]; m_val[j]=m_val[j+1]; m_vert[j+1]=h_vert; m_val[j+1]=h_val; } } } } template nvector simplex_method::solve(T lim, const nvector & start,int max) { int idx; for(int i=0;i temp_vert=start+nvector::unit(i); T temp_val=(*m_func)(temp_vert); insert(temp_vert,temp_val,i+1); } T eps=m_val[0]; int count=0; while((eps>lim)&&((count temp_vert=reflect(idx); T temp_val=(*m_func)(temp_vert); if(temp_val #include using std::pair; using std::vector; /*! \class AVolume Abstract base class for a 2D volume for particle packing */ class AVolume { private: public: virtual ~AVolume(){}; virtual pair getBoundingBox() = 0; virtual Vector3 getAPoint(int) const = 0; // virtual bool hasPlane() const = 0; // virtual bool isIn(const Vector3&) = 0; virtual bool isIn(const Vector3&) const = 0; virtual bool isIn(const Sphere&) =0; virtual int getNumberSubVolumes()const{return 1;}; }; #endif // __AVOLUME_H GenGeo-1.2/src/AVolume2D.cc0000644000000000000000000000162212533740504013506 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "AVolume2D.h" // dummy implemetation - returns empty list const map AVolume2D::getClosestObjects(const Vector3& P,int) const { map res; return res; } GenGeo-1.2/src/AVolume2D.h0000644000000000000000000000226412533740504013353 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __AVOLUME2D_H #define __AVOLUME2D_H // --- Project includes --- #include "AVolume.h" #include "geometry/Line2D.h" // --- STL includes --- #include using std::map; class AVolume2D : public AVolume { public: virtual ~AVolume2D(){}; virtual Line2D getClosestPlane(const Vector3&) = 0; virtual const map getClosestPlanes(const Vector3&,int) const = 0; virtual const map getClosestObjects(const Vector3&,int) const; }; #endif // __AVOLUME2D_H GenGeo-1.2/src/AVolume3D.h0000644000000000000000000000213012533740504013344 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __AVOLUME3D_H #define __AVOLUME3D_H // --- Project includes --- #include "AVolume.h" #include "geometry/Plane.h" // --- STL includes --- #include using std::map; class AVolume3D : public AVolume { public: virtual ~AVolume3D(){}; virtual const map getClosestObjects(const Vector3&,int) const = 0; virtual bool isFullyOutside(const Sphere&) =0; }; #endif // __AVOLUME3D_H GenGeo-1.2/src/BoxWithJointSet.cc0000644000000000000000000000532512533740504015020 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "BoxWithJointSet.h" // --- STL includes --- #include #include using std::make_pair; using std::map; BoxWithJointSet::BoxWithJointSet() {} /*! Construct box. Just calls constructor of base class. \param pmin minimum point of bounding box \param pmax maximum point of bounding box */ BoxWithJointSet::BoxWithJointSet(const Vector3& pmin,const Vector3& pmax) : BoxWithPlanes3D(pmin,pmax) {} /*! get the n geometrical objects closest to a given point \param p the point \param nmax the max. nr. of objects \return a map of [dist,*object] pairs */ const map BoxWithJointSet::getClosestObjects(const Vector3& p,int nmax) const { map res; for(vector::const_iterator iter=m_planes.begin(); iter!=m_planes.end(); iter++){ double ndist=iter->getDist(p); res.insert(make_pair(ndist,&(*iter))); } for(vector::const_iterator iter=m_joints.begin(); iter!=m_joints.end(); iter++){ double ndist=iter->getDist(p); res.insert(make_pair(ndist,&(*iter))); } return res; } /*! add a set of triangular patches as joints \param t the joint set */ void BoxWithJointSet::addJoints(const TriPatchSet& t) { for(vector::const_iterator iter=t.triangles_begin(); iter!=t.triangles_end(); iter++){ m_joints.push_back(*iter); } } /*! check if a Sphere is inside and doesn't intersect any planes or other objects \param S the Sphere */ bool BoxWithJointSet::isIn(const Sphere& S) { double r=S.Radius(); Vector3 p=S.Center(); // check inside & planes via base class bool res=BoxWithPlanes3D::isIn(S); if(res){ // check intersection with joints vector::iterator iter=m_joints.begin(); double dist=2*r; while((iter!=m_joints.end()) && res){ dist=iter->getDist(p); res=(dist>r); iter++; } } return res; } ostream& operator<< (ostream& ost, const BoxWithJointSet& B) { ost << B.m_pmin << " to " << B.m_pmax; return ost; } GenGeo-1.2/src/BoxWithJointSet.h0000644000000000000000000000320312533740504014653 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __BOXWITHJOINTSET_H #define __BOXWITHJOINTSET_H // --- Project includes --- #include "BoxWithPlanes3D.h" #include "TriPatchSet.h" #include "geometry/Triangle3D.h" // --- STL includes --- #include using std::vector; //--- IO includes --- #include /*! \class BoxWithJointSet A Box shaped volume with a set of triangular patches to which the particles are fitted. Additionally, an arbitrary number of (boundary) planes can be added to which the particles are fitted. */ class BoxWithJointSet : public BoxWithPlanes3D { protected: vector m_joints; public: BoxWithJointSet(); BoxWithJointSet(const Vector3&,const Vector3&); virtual ~BoxWithJointSet(){}; virtual const map getClosestObjects(const Vector3&,int) const; void addJoints(const TriPatchSet&); virtual bool isIn(const Sphere&); friend ostream& operator<< (ostream&, const BoxWithJointSet&); }; #endif // __BOXWITHJOINTSET_H GenGeo-1.2/src/BoxWithLines2D.cc0000644000000000000000000000737712533740504014532 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "BoxWithLines2D.h" //-- system includes -- #include using std::rand; // --- STL includes --- #include #include using std::make_pair; using std::map; //--- IO includes --- #include /*! helper function, return random value between min & max */ double BoxWithLines2D::m_random(double imin,double imax) const { return imin+((imax-imin)*((double)(rand())/(double)(RAND_MAX))); } BoxWithLines2D::BoxWithLines2D() {} /*! Construct box \param pmin minimum point of bounding box \param pmax maximum point of bounding box */ BoxWithLines2D::BoxWithLines2D(const Vector3& pmin,const Vector3& pmax) : m_pmin(pmin),m_pmax(pmax) {} /*! add a line \param l the line */ void BoxWithLines2D::addLine(const Line2D& l) { m_lines.push_back(l); } /*! get bounding box */ pair BoxWithLines2D::getBoundingBox() { return make_pair(m_pmin,m_pmax); } /*! get point inside the box. The Argument is ignored */ Vector3 BoxWithLines2D::getAPoint(int) const { double px,py; px=m_random(m_pmin.x(),m_pmax.x()); py=m_random(m_pmin.y(),m_pmax.y()); return Vector3(px,py,0.0); } /*! Return closest plane to a given point. Assumes that the list of Planes/Lines is not empty. \param p the point \warning check non-empty list of lines (via hasPlane()) before invoking */ Line2D BoxWithLines2D::getClosestPlane(const Vector3& p) { std::cout << "getClosestPlane : " << p << std::endl; vector::iterator PL=m_lines.begin(); double dist=PL->getDist(p); for(vector::iterator iter=m_lines.begin(); iter!=m_lines.end(); iter++){ double ndist=iter->getDist(p); std::cout << "Line: " << *iter << " Distance: " << ndist << std::endl; if(ndist BoxWithLines2D::getClosestPlanes(const Vector3& p,int nmax) const { map res; for(vector::const_iterator iter=m_lines.begin(); iter!=m_lines.end(); iter++){ double ndist=iter->getDist(p); const Line2D *l=&(*iter); res.insert(make_pair(ndist,l)); } return res; } /*! check if point is inside \param p the point */ bool BoxWithLines2D::isIn(const Vector3& p) const { return ((p.x()>m_pmin.x()) && (p.x()m_pmin.y()) && (p.y()m_pmin.X()+r) && (p.X()m_pmin.Y()+r) && (p.Y()::iterator iter=m_lines.begin(); double dist=2*r; while(iter!=m_lines.end() && dist>r){ dist=iter->getDist(p); iter++; } return inside && (dist>r); } ostream& operator<< (ostream& ost, const BoxWithLines2D& L) { ost << L.m_pmin << " to " << L.m_pmax; return ost; } GenGeo-1.2/src/BoxWithLines2D.h0000644000000000000000000000353512533740504014364 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __BOXWITHLINES2D_H #define __BOXWITHLINES2D_H // --- Project includes --- #include "AVolume2D.h" // --- STL includes --- #include #include // --- IO includes --- #include using std::vector; using std::map; using std::ostream; /*! \class BoxWithLines2D A class for the generation of random particles inside a box. An arbitrary number of lines can be added to which the particles are fitted. */ class BoxWithLines2D : public AVolume2D { protected: Vector3 m_pmin; Vector3 m_pmax; vector m_lines; double m_random(double,double)const; public: BoxWithLines2D(); BoxWithLines2D(const Vector3&,const Vector3&); virtual ~BoxWithLines2D(){}; void addLine(const Line2D&); virtual pair getBoundingBox(); virtual Vector3 getAPoint(int)const; virtual bool hasPlane() const{return (m_lines.size()>0);}; virtual Line2D getClosestPlane(const Vector3&); virtual const map getClosestPlanes(const Vector3&,int) const; virtual bool isIn(const Vector3&) const; virtual bool isIn(const Sphere&); friend ostream& operator<< (ostream&, const BoxWithLines2D&); }; #endif // __BOXWITHLINES2D_H GenGeo-1.2/src/BoxWithLines2DSubVol.cc0000644000000000000000000000376712533740504015664 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "BoxWithLines2DSubVol.h" // --- system includes --- #include using std::ceil; BoxWithLines2DSubVol::BoxWithLines2DSubVol() {} /*! construct box \param pmin minimum point of bounding box \param pmax maximum point of bounding box \param svdim_x \param svdim_y */ BoxWithLines2DSubVol::BoxWithLines2DSubVol(const Vector3& pmin,const Vector3& pmax,double svdim_x,double svdim_y):BoxWithLines2D(pmin,pmax) { m_nsv_x=int(ceil((pmax-pmin).X())/svdim_x); m_nsv_y=int(ceil((pmax-pmin).Y())/svdim_y); m_svdim_x=(pmax-pmin).X()/double(m_nsv_x); m_svdim_y=(pmax-pmin).X()/double(m_nsv_x); } /*! get a point within a given subvolume \param id index of the subvolume */ Vector3 BoxWithLines2DSubVol::BoxWithLines2DSubVol::getAPoint(int id) const { int idx=id%m_nsv_x; int idy=id/m_nsv_x; double minx=double(idx)*m_svdim_x; double maxx=double(idx+1)*m_svdim_x; double miny=double(idy)*m_svdim_y; double maxy=double(idy+1)*m_svdim_y; double px=m_random(minx,maxx); double py=m_random(miny,maxy); //std::cout << "id, x, y, p " << id << " [ " << minx << " - " << maxx << " ] [ " << miny << " - " << maxy << " ] [ " << px << " - " << py << " ] " << std::endl; return Vector3(px,py,0.0); } int BoxWithLines2DSubVol::BoxWithLines2DSubVol::getNumberSubVolumes() const { return m_nsv_x*m_nsv_y; } GenGeo-1.2/src/BoxWithLines2DSubVol.h0000644000000000000000000000274112533740504015515 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __BOXWITHLINES2DSUBVOL_H #define __BOXWITHLINES2DSUBVOL_H // --- Project includes --- #include "BoxWithLines2D.h" // --- STL includes --- #include using std::vector; /*! \class BoxWithLines2DSubVol A class for the generation of random particles inside a box. An arbitrary number of lines can be added to which the particles are fitted. The class supplies a number of subvolumes for the getAPoint function */ class BoxWithLines2DSubVol : public BoxWithLines2D { private: double m_svdim_x,m_svdim_y; int m_nsv_x,m_nsv_y; public: BoxWithLines2DSubVol(); BoxWithLines2DSubVol(const Vector3&,const Vector3&,double,double); virtual ~BoxWithLines2DSubVol(){}; virtual Vector3 getAPoint(int) const; virtual int getNumberSubVolumes() const; }; #endif // __BOXWITHLINES2DSUBVOL_H GenGeo-1.2/src/BoxWithPlanes3D.cc0000644000000000000000000001040612533740504014666 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "BoxWithPlanes3D.h" //-- system includes -- #include using std::rand; // --- STL includes --- #include #include using std::make_pair; using std::map; //--- IO includes --- #include BoxWithPlanes3D::BoxWithPlanes3D() { } /*! helper function, return random value between min & max */ double BoxWithPlanes3D::m_random(double imin,double imax) const { return imin+((imax-imin)*((double)(rand())/(double)(RAND_MAX))); } /*! Construct box \param pmin minimum point of bounding box \param pmax maximum point of bounding box */ BoxWithPlanes3D::BoxWithPlanes3D(const Vector3& pmin,const Vector3& pmax): m_pmin(pmin),m_pmax(pmax) {} /*! add a plane to the box \param P the plane */ void BoxWithPlanes3D::addPlane(const Plane& P) { m_planes.push_back(P); } /*! get bounding box */ pair BoxWithPlanes3D::getBoundingBox() { return make_pair(m_pmin,m_pmax); } /*! get point inside the box. The Argument is ignored */ Vector3 BoxWithPlanes3D::getAPoint(int) const { double px,py,pz; px=m_random(m_pmin.x(),m_pmax.x()); py=m_random(m_pmin.y(),m_pmax.y()); pz=m_random(m_pmin.z(),m_pmax.z()); return Vector3(px,py,pz); } /*! Return closest plane to a given point. Assumes that the list of Planes is not empty. \param p the point \warning check non-empty list of lines (via hasPlane()) before invoking */ Plane BoxWithPlanes3D::getClosestPlane(const Vector3& p) { vector::iterator PL=m_planes.begin(); double dist=PL->getDist(p); for(vector::iterator iter=m_planes.begin(); iter!=m_planes.end(); iter++){ double ndist=iter->getDist(p); if(ndist BoxWithPlanes3D::getClosestObjects(const Vector3& p,int nmax) const { map res; for(vector::const_iterator iter=m_planes.begin(); iter!=m_planes.end(); iter++){ double ndist=iter->getDist(p); res.insert(make_pair(ndist,&(*iter))); } return res; } /*! check if point is inside \param p the point */ bool BoxWithPlanes3D::isIn(const Vector3& p) const { return ((p.x()>m_pmin.x()) && (p.x()m_pmin.y()) && (p.y()m_pmin.z()) && (p.z()m_pmin.X()+r) && (p.X()m_pmin.Y()+r) && (p.Y()m_pmin.Z()+r) && (p.Z()::iterator iter=m_planes.begin(); double dist=2*r; while((iter!=m_planes.end()) && (dist>r)){ dist=iter->getDist(p); iter++; } return inside && (dist>r); } /* check if a Sphere is fully outside the box \param S the Sphere */ bool BoxWithPlanes3D::isFullyOutside(const Sphere& S) { double r=S.Radius(); Vector3 p=S.Center(); // std::cout << "rad: " << r << " pos: " << p << std::endl; bool outside= (p.X()m_pmax.X()+r) || (p.Y()m_pmax.Y()+r) || (p.Z()m_pmax.Z()+r); return outside; } ostream& operator<< (ostream& ost, const BoxWithPlanes3D& L) { ost << L.m_pmin << " to " << L.m_pmax; return ost; } GenGeo-1.2/src/BoxWithPlanes3D.h0000644000000000000000000000357612533740504014542 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __BOXWITHPLANES3D_H #define __BOXWITHPLANES3D_H // --- Project includes --- #include "AVolume3D.h" #include "geometry/Plane.h" // --- STL includes --- #include #include using std::vector; using std::map; /*! \class BoxWithPlanes3D A class for the generation of random particles inside a 3D box. An arbitrary number of planes can be added to which the particles are fitted. */ class BoxWithPlanes3D : public AVolume3D { protected: Vector3 m_pmin; Vector3 m_pmax; vector m_planes; double m_random(double,double)const; public: BoxWithPlanes3D(); BoxWithPlanes3D(const Vector3&,const Vector3&); virtual ~BoxWithPlanes3D(){}; void addPlane(const Plane&); virtual pair getBoundingBox(); virtual Vector3 getAPoint(int)const; virtual bool hasPlane() const{return (m_planes.size()>0);}; virtual Plane getClosestPlane(const Vector3&); virtual const map getClosestObjects(const Vector3&,int) const; virtual bool isIn(const Vector3&) const; virtual bool isIn(const Sphere&); virtual bool isFullyOutside(const Sphere&); friend ostream& operator<< (ostream&, const BoxWithPlanes3D&); }; #endif // __BOXWITHPLANES3D_H GenGeo-1.2/src/CircMNTable2D.cc0000644000000000000000000002464112533740504014227 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "CircMNTable2D.h" // --- System includes --- #include // --- IO includes --- #include using std::endl; using std::floor; CircMNTable2D::CircMNTable2D() {} /*! Construct CircMNTable2D. \param MinPt minimum point (z component ignored) \param MaxPt maximum point (z component ignored) \param cd cell dimension \param ngroups initial number of particle groups */ CircMNTable2D::CircMNTable2D(const Vector3& MinPt,const Vector3& MaxPt,double cd,unsigned int ngroups): MNTable2D(MinPt, MaxPt, cd, ngroups) { set_x_circ(); // check if grid spacing fits size in circular direction: double nx=(MaxPt-MinPt).X()/m_celldim; // error message if not if(nx!=floor(nx)){ std::cout << "WARNING! grid spacing " << m_celldim << " doesn't fit periodic x-dimension " << (MaxPt-MinPt).X() << std::endl; } double shift_x=(m_nx-2)*m_celldim; m_shift_vec_x=Vector3(shift_x,0.0,0.0); } /*! Destruct CircMNTable2D. Just calls MNTable2D destructor. */ CircMNTable2D::~CircMNTable2D() {} /*! set circularity of x-dimension to 1 */ void CircMNTable2D::set_x_circ() { m_x_periodic=1; } int CircMNTable2D::getXIndex(const Vector3& Pos) const { return int(floor((Pos.x()-m_x0)/m_celldim)); } int CircMNTable2D::getYIndex(const Vector3& Pos) const { return int(floor((Pos.y()-m_y0)/m_celldim)); } int CircMNTable2D::getFullIndex(const Vector3& Pos) const { int ix=int(floor((Pos.x()-m_x0)/m_celldim)); int iy=int(floor((Pos.y()-m_y0)/m_celldim)); return idx(ix,iy); } /*! get the cell index for a given position \param Pos the position \return the cell index if Pos is inside the table, -1 otherwise */ int CircMNTable2D::getIndex(const Vector3& Pos) const { int ret; int ix=int(floor((Pos.x()-m_x0)/m_celldim)); int iy=int(floor((Pos.y()-m_y0)/m_celldim)); // check if pos is in table excl. padding if((ix>=0) && (ix<=m_nx-1) && (iy>0) && (iy > bonds; if((id2==id) && (i!=0)){ // intra-cell, not for boundary //std::cout << id << " - " << id << std::endl; bonds=m_data[id].getBonds(gid,tol); } else if(id2>id){ // inter-cell //std::cout << id << " - " << id2 << std::endl; bonds=m_data[id].getBonds(gid,tol,m_data[id2]); } for(vector >::iterator iter=bonds.begin(); iter!=bonds.end(); iter++){ //std::cout << iter->first << " | " << iter->second << " "; m_bonds[btag].insert(*iter); } //std::cout << std::endl; } } //std::cout << std::endl; } } } /*! Generate bonds between particles of a group with identical particle tag. Takes cloned particles into account. \param gid the group ID \param tol max. difference between bond length and equilibrium dist. \param btag bond tag \param ptag the particle tag \param mask the mask for the particle tag */ void CircMNTable2D::generateBondsWithMask(int gid,double tol,int btag, int ptag, int mask) { std::cout << "CircMNTable2D::generateBondsWithMask( " << gid << " , " << tol << " , " << btag << " " << ptag <<" " << mask<<" )" << std::endl; // loop over all cells for(int i=0;i > bonds; if((id2==id) && (i!=0)){ // intra-cell, not for boundary //std::cout << id << " - " << id << std::endl; bonds=m_data[id].getBonds(gid,tol,ptag,mask); } else if(id2>id){ // inter-cell //std::cout << id << " - " << id2 << std::endl; bonds=m_data[id].getBonds(gid,tol,m_data[id2],ptag,mask); } for(vector >::iterator iter=bonds.begin(); iter!=bonds.end(); iter++){ //std::cout << iter->first << " | " << iter->second << " "; m_bonds[btag].insert(*iter); } //std::cout << std::endl; } } //std::cout << std::endl; } } } /*! Output the content of a MNTable2D to an ostream. The output format depends on the value of MNTable2D::s_output_style (see MNTable2D::SetOutputStyle). If it is set to 0, output suitable for debugging is generated, if it is set to 1 output in the esys .geo format is generated. If MNTable2D::s_output_style is set to 2, the output format is VTK-XML. \param ost the output stream \param T the table */ ostream& operator << (ostream& ost,const CircMNTable2D& T) { if(CircMNTable2D::s_output_style==0){ // debug style // don't print padding MNTCell::SetOutputStyle(0); for(int i=0;i > >::const_iterator iter=T.m_bonds.begin(); iter!=T.m_bonds.end(); iter++){ nbonds+=iter->second.size(); } ost << nbonds << endl; for(map > >::const_iterator iter=T.m_bonds.begin(); iter!=T.m_bonds.end(); iter++){ for(set >::const_iterator v_iter=iter->second.begin(); v_iter!=iter->second.end(); v_iter++){ ost << v_iter->first << " " << v_iter->second << " " << iter->first << endl; } } ost << "EndConnect" << endl; } else if (CircMNTable2D::s_output_style==2){ // vtk-xml T.WriteAsVtkXml(ost); } return ost; } GenGeo-1.2/src/CircMNTable2D.h0000644000000000000000000000341712533740504014067 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __CIRCMNTABLE2D_H #define __CIRCMNTABLE2D_H // --- Project includes --- #include "MNTable2D.h" /*! \class CircMNTable2D \brief circular 2D Multi-group Neighbour table Neighbour table supporting multiple tagged groups of particles and circular boundary conditions (x only at the moment) */ class CircMNTable2D : public MNTable2D { protected: Vector3 m_shift_vec_x; virtual void set_x_circ(); virtual int getIndex(const Vector3&) const; int getXIndex(const Vector3&) const; int getYIndex(const Vector3&) const; int getFullIndex(const Vector3&) const; public: CircMNTable2D(); CircMNTable2D(const Vector3&,const Vector3&,double,unsigned int); virtual ~CircMNTable2D(); virtual bool insert(const Sphere&,unsigned int); virtual bool insertChecked(const Sphere&,unsigned int,double tol=s_small_value); virtual bool checkInsertable(const Sphere&,unsigned int); virtual void generateBonds(int,double,int); virtual void generateBondsWithMask(int,double,int,int,int); // output friend ostream& operator << (ostream&,const CircMNTable2D&); }; #endif // __CIRCMNTABLE2D_H GenGeo-1.2/src/CircMNTable3D.cc0000644000000000000000000002352112533740504014224 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "CircMNTable3D.h" // --- System includes --- #include using std::floor; CircMNTable3D::CircMNTable3D() {} /*! Construct CircMNTable3D. Just calls MNTable3D constructor. \param MinPt minimum point (z component ignored) \param MaxPt maximum point (z component ignored) \param cd cell dimension \param ngroups initial number of particle groups */ CircMNTable3D::CircMNTable3D(const Vector3& MinPt,const Vector3& MaxPt,double cd,unsigned int ngroups): MNTable3D(MinPt, MaxPt, cd, ngroups) { // check if grid spacing fits size in circular direction: double nx=(MaxPt-MinPt).X()/m_celldim; // error message if not if(nx!=floor(nx)){ std::cout << "WARNING! grid spacing " << m_celldim << " doesn't fit periodic x-dimension " << (MaxPt-MinPt).X() << std::endl; } m_shift_x=Vector3((m_max_pt-m_min_pt).X(),0.0,0.0); set_x_circ(); } /*! Destruct CircMNTable3D. Just calls MNTable3D destructor. */ CircMNTable3D::~CircMNTable3D() {} /*! set circularity of x-dimension to 1 */ void CircMNTable3D::set_x_circ() { m_x_periodic=1; } int CircMNTable3D::getXIndex(const Vector3& Pos) const { return int(floor((Pos.x()-m_origin.x())/m_celldim)); } int CircMNTable3D::getYIndex(const Vector3& Pos) const { return int(floor((Pos.y()-m_origin.y())/m_celldim)); } int CircMNTable3D::getZIndex(const Vector3& Pos) const { return int(floor((Pos.z()-m_origin.z())/m_celldim)); } int CircMNTable3D::getFullIndex(const Vector3& Pos) const { int ix=int(floor((Pos.x()-m_origin.x())/m_celldim)); int iy=int(floor((Pos.y()-m_origin.y())/m_celldim)); int iz=int(floor((Pos.z()-m_origin.z())/m_celldim)); return idx(ix,iy,iz); } /*! get the cell index for a given position \param Pos the position \return the cell index if Pos is inside the table, -1 otherwise */ int CircMNTable3D::getIndex(const Vector3& Pos) const { int ret; int ix=int(floor((Pos.x()-m_origin.x())/m_celldim)); int iy=int(floor((Pos.y()-m_origin.y())/m_celldim)); int iz=int(floor((Pos.z()-m_origin.z())/m_celldim)); // check if pos is in table excl. padding if((ix>=0) && (ix<=m_nx-1) && (iy>0) && (iy0) && (iz0) && (idx0) && (idx close_spheres=getSpheresFromGroupNear(S.Center(),S.Radius()-s_small_value,gid); orig_insertable=(close_spheres.size()==0); // calculate clone location int xidx=getXIndex(S.Center()); // check if clone is insertable if (xidx==1){ // original in x-min slice of the table -> shift clone to +x needs_cloning=true; SClone.shift(m_shift_x); multimap close_spheres=getSpheresFromGroupNear(SClone.Center(),SClone.Radius()-s_small_value,gid); clone_insertable=(close_spheres.size()==0); } else if (xidx==m_nx-2){ // original in x-max slice of the table -> shift clone to -x needs_cloning=true; SClone.shift(-1.0*m_shift_x); multimap close_spheres=getSpheresFromGroupNear(SClone.Center(),SClone.Radius()-s_small_value,gid); clone_insertable=(close_spheres.size()==0); } // original not in end slices -> no cloning } return (orig_insertable && (clone_insertable || (!needs_cloning))); // original is insertable and clone is either insertable or not needed } /*! Insert sphere if it doesn't collide with other spheres. Insert clone into other side of Table. \param S the Sphere \param gid the group id */ bool CircMNTable3D::insertChecked(const Sphere& S,unsigned int gid,double tol) { bool res; bool orig_insertable=false; bool clone_insertable=false; bool needs_cloning=false; int id=getIndex(S.Center()); int idx=getXIndex(S.Center()); Sphere SClone=S; tol+=s_small_value; if((id!=-1) && (idx>0) && (idx close_spheres=getSpheresFromGroupNear(S.Center(),S.Radius()-tol,gid); orig_insertable=(close_spheres.size()==0); // insertable if there are no spheres too close // calculate clone location int xidx=getXIndex(S.Center()); // check if clone is insertable if (xidx==1){ // original in x-min slice of the table -> shift clone to +x needs_cloning=true; SClone.shift(m_shift_x); multimap close_spheres=getSpheresFromGroupNear(SClone.Center(),SClone.Radius()-tol,gid); clone_insertable=(close_spheres.size()==0); } else if (xidx==m_nx-2){ // original in x-max slice of the table -> shift clone to -x needs_cloning=true; SClone.shift(-1.0*m_shift_x); multimap close_spheres=getSpheresFromGroupNear(SClone.Center(),SClone.Radius()-tol,gid); clone_insertable=(close_spheres.size()==0); } // original not in end slices -> no cloning } if(orig_insertable && (clone_insertable || (!needs_cloning))){ // if origin is insertable and clone is either insertable or not needed m_data[id].insert(S,gid); // insert original if (needs_cloning) { // if needed, insert clone int clone_id=getFullIndex(SClone.Center()); m_data[clone_id].insert(SClone,gid); } res=true; } else { res=false; } return res; } /*! generate bonds between particles of a group \param gid the group ID \param tol max. difference between bond length and equilibrium dist. \param btag bond tag */ void CircMNTable3D::generateBonds(int gid,double tol,int btag) { std::cout << "MNTable3D::generateBonds( " << gid << " , " << tol << " , " << btag << " )" << std::endl; // loop over all cells for(int i=0;i > bonds; if(((ii+jj+kk)==0)){ // intra-cell, not for boundary bonds=m_data[id].getBonds(gid,tol); } else if(id2>id){ // inter-cell bonds=m_data[id].getBonds(gid,tol,m_data[id2]); } for(vector >::iterator iter=bonds.begin(); iter!=bonds.end(); iter++){ m_bonds[btag].insert(*iter); } } } } } } } } /*! generate bonds between particles of a group \param gid the group ID \param tol max. difference between bond length and equilibrium dist. \param btag1 tag for bonds within clusters (same particle tag) \param btag2 tag for bonds betweem clusters (different particle tag) */ void CircMNTable3D::generateClusterBonds(int gid,double tol,int btag1, int btag2) { for(int i=0;i > same_bonds; vector > diff_bonds; if((id==id2) && (id!=-1)){ // intra-cell, not for boundary same_bonds=m_data[id].getBondsSame(gid,tol); diff_bonds=m_data[id].getBondsDiff(gid,tol); } else if((id2>id) && (id!=-1) && (id2!=-1) ){ // inter-cell same_bonds=m_data[id].getBondsSame(gid,tol,m_data[id2]); diff_bonds=m_data[id].getBondsDiff(gid,tol,m_data[id2]); } // insert intra-cluster bonds for(vector >::iterator iter=same_bonds.begin(); iter!=same_bonds.end(); iter++){ if(m_bonds[btag1].find(*iter)==m_bonds[btag1].end()){ m_bonds[btag1].insert(*iter); } } // insert inter-cluster bonds for(vector >::iterator iter=diff_bonds.begin(); iter!=diff_bonds.end(); iter++){ if(m_bonds[btag2].find(*iter)==m_bonds[btag2].end()){ m_bonds[btag2].insert(*iter); } } } } } } } } } GenGeo-1.2/src/CircMNTable3D.h0000644000000000000000000000332112533740504014062 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __CIRCMNTABLE3D_H #define __CIRCMNTABLE3D_H // --- Project includes --- #include "MNTable3D.h" /*! \class CircMNTable3D \brief circular Multi-group Neighbour table Neighbour table supporting multiple tagged groups of particles and circular boundary conditions (x only at the moment) */ class CircMNTable3D : public MNTable3D { protected: Vector3 m_shift_x; virtual void set_x_circ(); virtual int getIndex(const Vector3&) const; int getXIndex(const Vector3&) const; int getYIndex(const Vector3&) const; int getZIndex(const Vector3&) const; int getFullIndex(const Vector3&) const; public: CircMNTable3D(); CircMNTable3D(const Vector3&,const Vector3&,double,unsigned int); ~CircMNTable3D(); virtual bool insert(const Sphere&,unsigned int); virtual bool checkInsertable(const Sphere&,unsigned int); virtual bool insertChecked(const Sphere&,unsigned int,double=s_small_value); virtual void generateBonds(int,double,int); virtual void generateClusterBonds(int,double,int,int); }; #endif // __CIRCMNTABLE3D_H GenGeo-1.2/src/CircMNTableXY2D.cc0000644000000000000000000002316512533740504014510 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "CircMNTableXY2D.h" // --- System includes --- #include // --- IO includes --- #include using std::endl; using std::floor; CircMNTableXY2D::CircMNTableXY2D() {} /*! Construct CircMNTableXY2D. \param MinPt minimum point (z component ignored) \param MaxPt maximum point (z component ignored) \param cd cell dimension \param ngroups initial number of particle groups */ CircMNTableXY2D::CircMNTableXY2D(const Vector3& MinPt,const Vector3& MaxPt,double cd,unsigned int ngroups): CircMNTable2D(MinPt, MaxPt, cd, ngroups) { set_y_circ(); // check if grid spacing fits size in circular direction: double ny=(MaxPt-MinPt).Y()/m_celldim; // error message if not if(ny!=floor(ny)){ std::cout << "WARNING! grid spacing " << m_celldim << " doesn't fit periodic y-dimension " << (MaxPt-MinPt).Y() << std::endl; } double shift_y=(m_ny-2)*m_celldim; m_shift_vec_y=Vector3(0.0,shift_y,0.0); } /*! Destruct CircMNTable2D. Just calls MNTable2D destructor. */ CircMNTableXY2D::~CircMNTableXY2D() {} /*! set circularity of y-dimension to 1 */ void CircMNTableXY2D::set_y_circ() { m_y_periodic=1; } /*! get the cell index for a given position \param Pos the position \return the cell index if Pos is inside the table, -1 otherwise */ int CircMNTableXY2D::getIndex(const Vector3& Pos) const { int ret; int ix=int(floor((Pos.x()-m_x0)/m_celldim)); int iy=int(floor((Pos.y()-m_y0)/m_celldim)); // check if pos is in table excl. padding if((ix>=0) && (ix<=m_nx-1) && (iy>=0) && (iy<=m_ny-1)){ ret=idx(ix,iy); } else { ret=-1; } return ret; } /*! Insert sphere. Insert clone into other side of Table. \param S the Sphere \param gid the group id */ bool CircMNTableXY2D::insert(const Sphere& S,unsigned int gid) { bool res; int id=getIndex(S.Center()); int idx=getXIndex(S.Center()); int idy=getYIndex(S.Center()); if((id!=-1) && (idx!=0) && (idx!=m_nx-1) && (idy!=0) && (idy!=m_ny-1) && (gid close_spheres=getSpheresFromGroupNear(S.Center(),S.Radius()-s_small_value,gid); if(close_spheres.size()==0){ res=true; } else res=false; } else { res=false; } return res; } /*! Insert sphere if it doesn't collide with other spheres. Insert clone into other side of Table. \param S the Sphere \param gid the group id */ bool CircMNTableXY2D::insertChecked(const Sphere& S,unsigned int gid,double tol) { bool res; int id=getIndex(S.Center()); int idx=getXIndex(S.Center()); int idy=getYIndex(S.Center()); // std::cout << "CircMNTable2D::insertChecked(" << S << ") id=" << id << " idx= " << idx << std::endl; tol+=s_small_value; if((id!=-1) && (idx!=0) && (idx!=m_nx-1) && (idy!=0) && (idy!=m_ny-1) && (gid close_spheres=getSpheresFromGroupNear(S.Center(),S.Radius()-tol,gid); if(close_spheres.size()==0){ m_data[id].insert(S,gid); res=true; } else res=false; // insert x-clone if (idx==1){ Sphere SClone=S; SClone.shift(m_shift_vec_x); multimap close_spheres=getSpheresFromGroupNear(SClone.Center(),SClone.Radius()-tol,gid); if(close_spheres.size()==0){ int clone_id=getFullIndex(SClone.Center()); m_data[clone_id].insert(SClone,gid); } } else if (idx==m_nx-2){ Sphere SClone=S; SClone.shift(-1.0*m_shift_vec_x); multimap close_spheres=getSpheresFromGroupNear(SClone.Center(),SClone.Radius()-tol,gid); if(close_spheres.size()==0){ int clone_id=getFullIndex(SClone.Center()); m_data[clone_id].insert(SClone,gid); } } // insert y-clone if (idy==1){ Sphere SClone=S; SClone.shift(m_shift_vec_y); multimap close_spheres=getSpheresFromGroupNear(SClone.Center(),SClone.Radius()-tol,gid); if(close_spheres.size()==0){ int clone_id=getFullIndex(SClone.Center()); m_data[clone_id].insert(SClone,gid); } } else if (idy==m_ny-2){ Sphere SClone=S; SClone.shift(-1.0*m_shift_vec_y); multimap close_spheres=getSpheresFromGroupNear(SClone.Center(),SClone.Radius()-tol,gid); if(close_spheres.size()==0){ int clone_id=getFullIndex(SClone.Center()); m_data[clone_id].insert(SClone,gid); } } } else { res=false; } return res; } /*! Generate bonds between particles of a group. Takes cloned particles into account. \param gid the group ID \param tol max. difference between bond length and equilibrium dist. \param btag bond tag */ void CircMNTableXY2D::generateBonds(int gid,double tol,int btag) { std::cout << "CircMNTableXY2D::generateBonds( " << gid << " , " << tol << " , " << btag << " )" << std::endl; // loop over all cells for(int i=0;i > bonds; if(((ii+jj)==0)){ // intra-cell, not for boundary bonds=m_data[id].getBonds(gid,tol); } else if(id2>id){ // inter-cell bonds=m_data[id].getBonds(gid,tol,m_data[id2]); } for(vector >::iterator iter=bonds.begin(); iter!=bonds.end(); iter++){ m_bonds[btag].insert(*iter); } } } } } } /*! Output the content of a MNTable2D to an ostream. The output format depends on the value of MNTable2D::s_output_style (see MNTable2D::SetOutputStyle). If it is set to 0, output suitable for debugging is generated, if it is set to 1 output in the esys .geo format is generated. If MNTable2D::s_output_style is set to 2, the output format is VTK-XML. \param ost the output stream \param T the table */ ostream& operator << (ostream& ost,const CircMNTableXY2D& T) { if(CircMNTableXY2D::s_output_style==0){ // debug style // don't print padding MNTCell::SetOutputStyle(0); for(int i=0;i > >::const_iterator iter=T.m_bonds.begin(); iter!=T.m_bonds.end(); iter++){ nbonds+=iter->second.size(); } ost << nbonds << endl; for(map > >::const_iterator iter=T.m_bonds.begin(); iter!=T.m_bonds.end(); iter++){ for(set >::const_iterator v_iter=iter->second.begin(); v_iter!=iter->second.end(); v_iter++){ ost << v_iter->first << " " << v_iter->second << " " << iter->first << endl; } } ost << "EndConnect" << endl; } else if (CircMNTable2D::s_output_style==2){ // vtk-xml T.WriteAsVtkXml(ost); } return ost; } GenGeo-1.2/src/CircMNTableXY2D.h0000644000000000000000000000316712533740504014352 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __CIRCMNTABLEXY2D_H #define __CIRCMNTABLEXY2D_H // --- Project includes --- #include "CircMNTable2D.h" /*! \class CircMNTableXY2D \brief circular 2D Multi-group Neighbour table Neighbour table supporting multiple tagged groups of particles and circular boundary conditions in both x- and y- direction */ class CircMNTableXY2D : public CircMNTable2D { protected: Vector3 m_shift_vec_y; virtual void set_y_circ(); virtual int getIndex(const Vector3&) const; public: CircMNTableXY2D(); CircMNTableXY2D(const Vector3&,const Vector3&,double,unsigned int); virtual ~CircMNTableXY2D(); virtual bool insert(const Sphere&,unsigned int); virtual bool insertChecked(const Sphere&,unsigned int,double tol=s_small_value); virtual bool checkInsertable(const Sphere&,unsigned int); virtual void generateBonds(int,double,int); // output friend ostream& operator << (ostream&,const CircMNTableXY2D&); }; #endif // __CIRCMNTABLEXY2D_H GenGeo-1.2/src/CircleVol.cc0000644000000000000000000000412512533740504013633 0ustar 00000000000000//////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "CircleVol.h" //--- #include #include using std::cos; using std::sin; // --- STL includes --- #include using std::make_pair; CircleVol::CircleVol() {} CircleVol::CircleVol(const Vector3& c,double r) { m_sph=SphereIn(c,r); } pair CircleVol::getBoundingBox() { Vector3 r=Vector3(m_sph.Radius(),m_sph.Radius(),0.0); return make_pair(m_sph.Center()-r,m_sph.Center()+r); } Vector3 CircleVol::getAPoint(int) const { double r=m_sph.Radius()*((double)(rand())/(double)(RAND_MAX)); double rho=2.0*M_PI*((double)(rand())/(double)(RAND_MAX)); return m_sph.Center()+r*Vector3(cos(rho),sin(rho),0.0); } Line2D CircleVol::getClosestPlane(const Vector3& V) { Line2D res; return res; } const map CircleVol::getClosestPlanes(const Vector3& p,int nmax) const { map res; return res; } const map CircleVol::getClosestObjects(const Vector3& P,int) const { map res; res.insert(make_pair(m_sph.getDist(P),&m_sph)); return res; } bool CircleVol::isIn(const Vector3& P) const { double dist=(m_sph.Center()-P).norm(); return (dist using std::map; class CircleVol : public AVolume2D { protected: SphereIn m_sph; public: CircleVol(); CircleVol(const Vector3&,double); virtual ~CircleVol(){}; virtual pair getBoundingBox(); virtual Vector3 getAPoint(int) const; virtual Line2D getClosestPlane(const Vector3&); virtual const map getClosestPlanes(const Vector3&,int) const; virtual const map getClosestObjects(const Vector3&,int) const; virtual bool isIn(const Vector3&) const; virtual bool isIn(const Sphere&); friend ostream& operator << (ostream&,const CircleVol&); }; #endif // __CIRCLE_VOL_H GenGeo-1.2/src/ClippedCircleVol.cc0000644000000000000000000000552012533740504015134 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "ClippedCircleVol.h" using std::make_pair; ClippedCircleVol::ClippedCircleVol() {} /*! constructor taking center and radius of the circle as arguments \param center the center of the circle \param radius the radius of the circle */ ClippedCircleVol::ClippedCircleVol(const Vector3& center,double radius): CircleVol(center,radius) {} /*! add a line to the volume \param l the line \param fit if true, line is used for fitting, if false line is only used for in/out detection */ void ClippedCircleVol::addLine(const Line2D& l,bool fit) { m_lines.push_back(make_pair(l,fit)); } /*! get a random point inside the volume \param n is ignored */ Vector3 ClippedCircleVol::getAPoint(int n) const { Vector3 res; do { res=CircleVol::getAPoint(n); } while (!isIn(res)); return res; } /*! get objects closest to a given point \param pos the point \param nr the max. number of objects returned */ const map ClippedCircleVol::getClosestObjects(const Vector3& pos,int nr) const { map res=CircleVol::getClosestObjects(pos,nr); for(vector >::const_iterator iter=m_lines.begin(); iter!=m_lines.end(); iter++){ if(iter->second){ double dist=iter->first.getDist(pos); res.insert(make_pair(dist,&(iter->first))); } } return res; } /*! test if a point is inside the volume \param pos the point */ bool ClippedCircleVol::isIn(const Vector3& pos) const { bool res=CircleVol::isIn(pos); vector >::const_iterator iter=m_lines.begin(); while(res && iter!=m_lines.end()){ bool rside=((pos-iter->first.getOrig())*iter->first.getNormal())>0.0; res=res && rside; iter++; } return res; } /*! test if a sphere(circle) is completely inside the volume \param S the sphere */ bool ClippedCircleVol::isIn(const Sphere& S) { bool res=CircleVol::isIn(S); vector >::const_iterator iter=m_lines.begin(); while(res && iter!=m_lines.end()){ bool rside=((S.Center()-iter->first.getOrig())*iter->first.getNormal())>S.Radius(); res=res && rside; iter++; } return res; } GenGeo-1.2/src/ClippedCircleVol.h0000644000000000000000000000332112533740504014773 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __CLIPPED_CIRCLE_VOL_H #define __CLIPPED_CIRCLE_VOL_H // --- Project includes --- #include "CircleVol.h" #include "geometry/Line2D.h" // --- STL includes --- #include #include using std::map; using std::pair; /*! A clipped circle volume. The volume is bounded by a circle and by the lines added to the volume using the addLine function. The in/out decision does depend on the line normals, i.e. particles on the side of a line where the normal is positive are considered inside, those on the negative side outside. */ class ClippedCircleVol : public CircleVol { protected: vector > m_lines; public: ClippedCircleVol(); ClippedCircleVol(const Vector3&,double); virtual ~ClippedCircleVol(){}; void addLine(const Line2D&,bool); virtual Vector3 getAPoint(int) const; virtual const map getClosestObjects(const Vector3&,int) const; virtual bool isIn(const Vector3&) const; virtual bool isIn(const Sphere&); }; #endif // __CLIPPED_CIRCLE_VOL_H GenGeo-1.2/src/ClippedSphereVol.cc0000644000000000000000000000454012533740504015162 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "ClippedSphereVol.h" using std::make_pair; ClippedSphereVol::ClippedSphereVol() {} /*! constructor taking center and radius of the Sphere as arguments \param center the center of the sphere \param radius the radius of the sphere */ ClippedSphereVol::ClippedSphereVol(const Vector3& center,double radius): SphereVol(center,radius) {} void ClippedSphereVol::addPlane(const Plane& p, bool fit) { m_planes.push_back(make_pair(p,fit)); } Vector3 ClippedSphereVol::getAPoint(int n) const { Vector3 res; do { res=SphereVol::getAPoint(n); } while (!isIn(res)); return res; } const map ClippedSphereVol::getClosestObjects(const Vector3& pos ,int nr) const { map res=SphereVol::getClosestObjects(pos,nr); for(vector >::const_iterator iter=m_planes.begin(); iter!=m_planes.end(); iter++){ if(iter->second){ double dist=iter->first.getDist(pos); res.insert(make_pair(dist,&(iter->first))); } } return res; } bool ClippedSphereVol::isIn(const Vector3& pos) const { bool res=SphereVol::isIn(pos); vector >::const_iterator iter=m_planes.begin(); while(res && iter!=m_planes.end()){ bool rside=((pos-iter->first.getOrig())*iter->first.getNormal())>0.0; res=res && rside; iter++; } return res; } bool ClippedSphereVol::isIn(const Sphere& S) { bool res=SphereVol::isIn(S); vector >::const_iterator iter=m_planes.begin(); while(res && iter!=m_planes.end()){ bool rside=((S.Center()-iter->first.getOrig())*iter->first.getNormal())>S.Radius(); res=res && rside; iter++; } return res; } GenGeo-1.2/src/ClippedSphereVol.h0000644000000000000000000000271512533740504015026 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __CLIPPED_SPHERE_VOL_H #define __CLIPPED_SPHERE_VOL_H // --- Project includes --- #include "SphereVol.h" #include "geometry/Plane.h" // --- STL includes --- #include #include using std::map; using std::pair; class ClippedSphereVol : public SphereVol { protected: vector > m_planes; public: ClippedSphereVol(); ClippedSphereVol(const Vector3&,double); virtual ~ClippedSphereVol(){}; void addPlane(const Plane&,bool); virtual Vector3 getAPoint(int) const; virtual const map getClosestObjects(const Vector3&,int) const; virtual bool isIn(const Vector3&) const; virtual bool isIn(const Sphere&); //friend ostream& operator << (ostream&,const ClippedSphereVol&); }; #endif // __CLIPPED_SPHERE_VOL_H GenGeo-1.2/src/ConvexPolyhedron.cc0000644000000000000000000000551012533740504015256 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "ConvexPolyhedron.h" ConvexPolyhedron::ConvexPolyhedron() {} /*! Construct polyhedron - without planes its just a box \param pmin minimum point of bounding box \param pmax maximum point of bounding box */ ConvexPolyhedron::ConvexPolyhedron(const Vector3& pmin,const Vector3& pmax) : BoxWithPlanes3D(pmin,pmax) {} ConvexPolyhedron::~ConvexPolyhedron() {} /*! get point inside the box. The Argument is ignored */ Vector3 ConvexPolyhedron::getAPoint(int)const { double px,py,pz; Vector3 res; // std::cout << m_pmin << " - " << m_pmax << std::endl; do{ px=m_random(m_pmin.x(),m_pmax.x()); py=m_random(m_pmin.y(),m_pmax.y()); pz=m_random(m_pmin.z(),m_pmax.z()); res=Vector3(px,py,pz); } while (!isIn(res)); return res; } /*! check if point is inside \param p the point */ bool ConvexPolyhedron::isIn(const Vector3& p) const { bool res; // std::cout << p << std::endl; // check inside bounding box res= ((p.x()>m_pmin.x()) && (p.x()m_pmin.y()) && (p.y()m_pmin.z()) && (p.z()::const_iterator iter=m_planes.begin(); while((iter!=m_planes.end()) && (res)){ Vector3 normal=iter->getNormal(); Vector3 pdist=p-(iter->getOrig()); res=(normal*pdist>0); iter++; } } return res; } /*! check if a Sphere is inside and doesn't intersect any planes \param S the Sphere */ bool ConvexPolyhedron::isIn(const Sphere& S) { bool res; double r=S.Radius(); Vector3 p=S.Center(); // std::cout << "rad: " << r << " pos: " << p << std::endl; // inside bbx res=(p.X()>m_pmin.X()+r) && (p.X()m_pmin.Y()+r) && (p.Y()m_pmin.Z()+r) && (p.Z()::const_iterator iter=m_planes.begin(); while((iter!=m_planes.end()) && (res)){ Vector3 normal=iter->getNormal(); Vector3 pdist=p-(iter->getOrig()); res=(normal*pdist>r); iter++; } } return res; } GenGeo-1.2/src/ConvexPolyhedron.h0000644000000000000000000000303312533740504015116 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __CONVEX_POLYHEDRON_H #define __CONVEX_POLYHEDRON_H // --- Project includes --- #include "BoxWithPlanes3D.h" #include "geometry/Plane.h" // --- STL includes --- #include #include using std::vector; using std::map; /*! \class ConvexPolyhedron A class for the generation of random particles inside a convex polyhedron. The polyhedron defined by a bounding box and an arbitrary number of planes to which the particles are fitted. The bounding box is largely there to prevent the generation of infinite polyhedra. */ class ConvexPolyhedron : public BoxWithPlanes3D { protected: public: ConvexPolyhedron(); ConvexPolyhedron(const Vector3&,const Vector3&); virtual ~ConvexPolyhedron(); virtual Vector3 getAPoint(int)const; virtual bool isIn(const Vector3&) const; virtual bool isIn(const Sphere&); }; #endif //__CONVEX_POLYHEDRON_H GenGeo-1.2/src/CylinderVol.cc0000644000000000000000000000710012533740504014177 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "CylinderVol.h" //--- #include #include using std::cos; using std::sin; using std::fabs; // --- STL includes --- #include using std::make_pair; CylinderVol::CylinderVol() { } CylinderVol::CylinderVol(const Vector3& c,const Vector3& axis,double l,double r): m_cyl(c,axis,r) { m_bottom=Plane(c,axis); m_top=Plane(c+l*axis.unit(),-1.0*axis); m_len=l; // calculate "in plane" vectors m_xd=Vector3(axis.y(),-axis.x(),0); if (m_xd.norm()==0) { m_xd = Vector3(0,axis.z(),-axis.y()) ; } if (m_xd.norm()==0) { m_xd = Vector3(axis.z(),0,-axis.x()) ; } m_xd = m_xd.unit(); m_yd = cross(axis,m_xd); } pair CylinderVol::getBoundingBox() { Vector3 center=m_cyl.getBasePoint()+0.5*m_len*m_cyl.getAxis(); Vector3 abs_axis=Vector3(fabs(m_cyl.getAxis().X()),fabs(m_cyl.getAxis().Y()),fabs(m_cyl.getAxis().Z())); Vector3 p0=center-0.5*m_len*abs_axis-Vector3(m_cyl.getRadius(),m_cyl.getRadius(),m_cyl.getRadius()); Vector3 p1=center+0.5*m_len*abs_axis+Vector3(m_cyl.getRadius(),m_cyl.getRadius(),m_cyl.getRadius()); return make_pair(p0,p1); } Vector3 CylinderVol::getAPoint(int) const { double l=m_len*((double)(rand())/(double)(RAND_MAX)); double r=m_cyl.getRadius()*((double)(rand())/(double)(RAND_MAX)); double phi=2*M_PI*((double)(rand())/(double)(RAND_MAX)); Vector3 p0=m_cyl.getBasePoint()+l*m_cyl.getAxis(); double x=cos(phi); double y=sin(phi); Vector3 dir=x*m_xd+y*m_yd; return p0+r*dir; } const map CylinderVol::getClosestObjects(const Vector3& P,int) const { map res; res.insert(make_pair(m_cyl.getDist(P),&m_cyl)); res.insert(make_pair(m_bottom.getDist(P),&m_bottom)); res.insert(make_pair(m_top.getDist(P),&m_top)); return res; } bool CylinderVol::isIn(const Vector3& P) const { bool in_cyl=(m_cyl.getDirDist(P)>0); bool above_bottom=(m_bottom.getNormal()*(P-m_bottom.getOrig())>0); bool below_top=(m_top.getNormal()*(P-m_top.getOrig())>0); return in_cyl && above_bottom && below_top; } bool CylinderVol::isIn(const Sphere& S) { bool in_cyl=(m_cyl.getDirDist(S.Center())>S.Radius()); bool above_bottom=(m_bottom.getNormal()*(S.Center()-m_bottom.getOrig())>S.Radius()); bool below_top=(m_top.getNormal()*(S.Center()-m_top.getOrig())>S.Radius()); bool res=in_cyl && above_bottom && below_top; return res; } /* check if a Sphere is completely outside the cylinder \param S the sphere */ bool CylinderVol::isFullyOutside(const Sphere& S) { bool outside_cyl=(m_cyl.getDirDist(S.Center())<(-1.0*S.Radius())); bool below_bottom=(m_bottom.getNormal()*(S.Center()-m_bottom.getOrig())<(-1.0*S.Radius())); bool above_top=(m_top.getNormal()*(S.Center()-m_top.getOrig())<(-1.0*S.Radius())); bool res=outside_cyl || below_bottom || above_top; return res; } ostream& operator << (ostream& ost,const CylinderVol& T) { return ost; } GenGeo-1.2/src/CylinderVol.h0000644000000000000000000000311512533740504014043 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __CYLINDERVOL_H #define __CYLINDERVOL_H // --- Project includes --- #include "AVolume3D.h" #include "geometry/Cylinder.h" #include "geometry/Plane.h" // --- STL includes --- #include #include using std::vector; using std::map; class CylinderVol : public AVolume3D { protected: Cylinder m_cyl; Plane m_bottom,m_top; double m_len; Vector3 m_xd,m_yd; // "in plane" vectors; public: CylinderVol(); CylinderVol(const Vector3&,const Vector3&,double,double); virtual ~CylinderVol(){}; virtual pair getBoundingBox(); virtual Vector3 getAPoint(int) const; virtual const map getClosestObjects(const Vector3&,int) const; virtual bool isIn(const Vector3&) const; virtual bool isIn(const Sphere&); virtual bool isFullyOutside(const Sphere&); friend ostream& operator << (ostream&,const CylinderVol&); }; #endif // __CYLINDERVOL_H GenGeo-1.2/src/CylinderWithJointSet.cc0000644000000000000000000000441312533740504016036 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "CylinderWithJointSet.h" //--- #include #include using std::cos; using std::sin; using std::fabs; // --- STL includes --- #include using std::make_pair; CylinderWithJointSet::CylinderWithJointSet() { } CylinderWithJointSet::CylinderWithJointSet(const Vector3& c,const Vector3& axis,double l,double r): CylinderVol(c,axis,l,r) { } const map CylinderWithJointSet::getClosestObjects(const Vector3& P,int) const { map res; res.insert(make_pair(m_cyl.getDist(P),&m_cyl)); res.insert(make_pair(m_bottom.getDist(P),&m_bottom)); res.insert(make_pair(m_top.getDist(P),&m_top)); for(vector::const_iterator iter=m_joints.begin(); iter!=m_joints.end(); iter++){ double ndist=iter->getDist(P); res.insert(make_pair(ndist,&(*iter))); } return res; } void CylinderWithJointSet::addJoints(const TriPatchSet& t) { for(vector::const_iterator iter=t.triangles_begin(); iter!=t.triangles_end(); iter++){ m_joints.push_back(*iter); } } bool CylinderWithJointSet::isIn(const Sphere& S) { double r=S.Radius(); Vector3 p=S.Center(); // check inside & planes via base class bool res=CylinderVol::isIn(S); if(res){ // check intersection with joints vector::iterator iter=m_joints.begin(); double dist=2*r; while((iter!=m_joints.end()) && res){ dist=iter->getDist(p); res=(dist>r); iter++; } } return res; } ostream& operator << (ostream& ost,const CylinderWithJointSet& T) { return ost; } GenGeo-1.2/src/CylinderWithJointSet.h0000644000000000000000000000273612533740504015706 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __CYLINDERWITHJOINTSET_H #define __CYLINDERWITHJOINTSET_H // --- Project includes --- #include "CylinderVol.h" #include "geometry/Plane.h" #include "TriPatchSet.h" #include "geometry/Triangle3D.h" // --- STL includes --- #include #include using std::vector; using std::map; class CylinderWithJointSet : public CylinderVol { protected: vector m_joints; public: CylinderWithJointSet(); CylinderWithJointSet(const Vector3&,const Vector3&,double,double); virtual ~CylinderWithJointSet(){}; virtual const map getClosestObjects(const Vector3&,int) const; void addJoints(const TriPatchSet&); virtual bool isIn(const Sphere&); friend ostream& operator << (ostream&,const CylinderWithJointSet&); }; #endif // __CYLINDERWITHJOINTSET_H GenGeo-1.2/src/DifferenceVol.cc0000644000000000000000000000514312533740504014465 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "DifferenceVol.h" //--- #include #include using std::cos; using std::sin; // --- STL includes --- #include using std::make_pair; DifferenceVol::DifferenceVol() { std::cout << "WARNING: DifferenceVol is an experimental feature and may not always work as expected. For details see doc/CSG.readme" << std::endl; m_vol1 = NULL; m_vol2 = NULL; } DifferenceVol::DifferenceVol(AVolume3D& v1, AVolume3D& v2) { std::cout << "WARNING: DifferenceVol is an experimental feature and may not always work as expected. For details see doc/CSG.readme" << std::endl; m_vol1 = &v1; m_vol2 = &v2; // std::cout << m_vol1 << std::endl; // std::cout << m_vol2 << std::endl; } pair DifferenceVol::getBoundingBox() { return m_vol1->getBoundingBox(); } Vector3 DifferenceVol::getAPoint(int ivol) const { Vector3 aPoint; bool found = false; while (!(found)) { aPoint = m_vol1->getAPoint(ivol); found = !(m_vol2->isIn(aPoint)); } return aPoint; } const map DifferenceVol::getClosestObjects(const Vector3& P,int ival) const { map res; map res2; res = m_vol1->getClosestObjects(P,ival); res2 = m_vol2->getClosestObjects(P,ival); res.insert(res2.begin(), res2.end()); return res; } bool DifferenceVol::isIn(const Vector3& P) const { bool res = false; if ((m_vol1->isIn(P)) && (!(m_vol2->isIn(P)))) { res = true; } return res; } bool DifferenceVol::isIn(const Sphere& S) { return m_vol1->isIn(S) && m_vol2->isFullyOutside(S); } /*! Check if a sphere is fully outside the volume. Tests if the sphere is fully outside volume1 or fully inside volume2. \param S the sphere */ bool DifferenceVol::isFullyOutside(const Sphere& S) { return m_vol2->isIn(S) || m_vol1->isFullyOutside(S); } ostream& operator << (ostream& ost,const DifferenceVol& T) { return ost; } GenGeo-1.2/src/DifferenceVol.h0000644000000000000000000000277612533740504014340 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __DIFFERENCE_VOLUME_SET_H #define __DIFFERENCE_VOLUME_SET_H // --- Project includes --- #include "AVolume3D.h" // --- STL includes --- #include using std::map; class DifferenceVol : public AVolume3D { protected: AVolume3D* m_vol1; AVolume3D* m_vol2; public: DifferenceVol (); DifferenceVol (AVolume3D& , AVolume3D&); virtual ~DifferenceVol (){}; virtual const map getClosestObjects(const Vector3&,int) const; virtual pair getBoundingBox(); virtual Vector3 getAPoint(int) const; virtual bool isIn(const Vector3&) const; virtual bool isIn(const Sphere&); virtual int getNumberSubVolumes()const{return 2;}; virtual bool isFullyOutside(const Sphere&); friend ostream& operator << (ostream&,const DifferenceVol&); }; #endif // __DIFFERENCE_VOLUME_SET_H GenGeo-1.2/src/DogBone.cc0000644000000000000000000000365612533740504013276 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "DogBone.h" // --- STL includes --- #include using std::make_pair; DogBone::DogBone() {} /*! \param c base point \param axis central axis \param l total length \param r total radius \param l2 length of cylindrical end pieces \param r2 center radius */ DogBone::DogBone(const Vector3& c,const Vector3& axis,double l,double r,double l2,double r2) : CylinderVol(c,axis,l,r) { // calc torus center Vector3 tcenter=c+0.5*l*axis; // torus inner radius double h=0.5*l-l2; double k=(r-r2); double ri=0.5*(k+(h*h)/k); // torus outer radius double ro=ri+r2; std::cout << "torus: " << tcenter << " - " << ro << " , " << ri << std::endl; m_tor=Torus(tcenter,axis,ro,ri,false); } const map DogBone::getClosestObjects(const Vector3& P,int n) const { map res=CylinderVol::getClosestObjects(P,n); res.insert(make_pair(m_tor.getDist(P),&m_tor)); return res; } bool DogBone::isIn(const Vector3& P) const { bool res=CylinderVol::isIn(P); bool in_torus=(m_tor.getDist(P)>0); return res && in_torus; } bool DogBone::isIn(const Sphere& S) { bool res=CylinderVol::isIn(S); bool in_torus=(m_tor.getDist(S.Center())>S.Radius()); return res && in_torus; } GenGeo-1.2/src/DogBone.h0000644000000000000000000000250512533740504013130 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __DOGBONE_H #define __DOGBONE_H // --- Project includes --- #include "CylinderVol.h" #include "geometry/Cylinder.h" #include "geometry/Torus.h" #include "geometry/Plane.h" // --- STL includes --- #include #include using std::vector; using std::map; class DogBone : public CylinderVol { protected: Torus m_tor; public: DogBone(); DogBone(const Vector3&,const Vector3&,double,double,double,double); virtual ~DogBone(){}; virtual const map getClosestObjects(const Vector3&,int) const; virtual bool isIn(const Vector3&) const; virtual bool isIn(const Sphere&); }; #endif // __DOGBONE_H GenGeo-1.2/src/EllipsoidVol.cc0000644000000000000000000000470312533740504014360 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "EllipsoidVol.h" //--- #include #include using std::cos; using std::sin; // --- STL includes --- #include using std::make_pair; EllipsoidVol::EllipsoidVol() {} EllipsoidVol::EllipsoidVol(const Vector3& c, double lx, double ly, double lz) { m_posn=c; m_lx=lx; m_ly=ly; m_lz=lz; } pair EllipsoidVol::getBoundingBox() { Vector3 r=Vector3(0.5*m_lx,0.5*m_ly,0.5*m_lz); return make_pair(m_posn-r,m_posn+r); } Vector3 EllipsoidVol::getAPoint(int) const { /* double r=m_sph.Radius()*((double)(rand())/(double)(RAND_MAX)); double phi=M_PI*((double)(rand())/(double)(RAND_MAX)); double rho=2*M_PI*((double)(rand())/(double)(RAND_MAX)); */ double rx = m_lx*((double)(rand())/(double)(RAND_MAX) - 0.5); double ry = m_ly*((double)(rand())/(double)(RAND_MAX) - 0.5); double rz = m_lz*((double)(rand())/(double)(RAND_MAX) - 0.5); return m_posn + Vector3(rx,ry,rz); } const map EllipsoidVol::getClosestObjects(const Vector3& P,int) const { map res; // res.insert(make_pair(m_sph.getDist(P),&m_sph)); return res; } bool EllipsoidVol::isIn(const Vector3& P) const { Vector3 dR = P - m_posn; double rx = dR.x(); double ry = dR.y(); double rz = dR.z(); double delta = rx*rx/(m_lx*m_lx) + ry*ry/(m_ly*m_ly) + rz*rz/(m_lz*m_lz) ; return (delta < 1.0); } /*! \warning WRONG */ bool EllipsoidVol::isIn(const Sphere& S) { // return (m_sph.getDist(S.Center())>S.Radius()); return (isIn(S.Center())); } /* Check if sphere is fully outside the volume. \param S the sphere \warning DUMMY IMPLEMENTATION */ bool EllipsoidVol::isFullyOutside(const Sphere&) { return true; } ostream& operator << (ostream& ost,const EllipsoidVol& T) { return ost; } GenGeo-1.2/src/EllipsoidVol.h0000644000000000000000000000266612533740504014230 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __ELLIPSOID_VOL_H #define __ELLIPSOID_VOL_H // --- Project includes --- #include "AVolume3D.h" // --- STL includes --- #include using std::map; class EllipsoidVol : public AVolume3D { protected: double m_lx,m_ly,m_lz; Vector3 m_posn; public: EllipsoidVol(); EllipsoidVol(const Vector3&,double,double,double); virtual ~EllipsoidVol(){}; virtual pair getBoundingBox(); virtual Vector3 getAPoint(int) const; virtual const map getClosestObjects(const Vector3&,int) const; virtual bool isIn(const Vector3&) const; virtual bool isIn(const Sphere&); virtual bool isFullyOutside(const Sphere&); friend ostream& operator << (ostream&,const EllipsoidVol&); }; #endif // __ELLIPSOID_VOL_H GenGeo-1.2/src/FullCircMNTable3D.cc0000644000000000000000000003072412533740504015052 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "FullCircMNTable3D.h" // --- System includes --- #include // --- IO includes --- #include using std::endl; using std::floor; FullCircMNTable3D::FullCircMNTable3D() {} /*! Construct FullCircMNTable3D. \param MinPt minimum point \param MaxPt maximum point \param cd cell dimension \param ngroups initial number of particle groups */ FullCircMNTable3D::FullCircMNTable3D(const Vector3& MinPt,const Vector3& MaxPt,double cd,unsigned int ngroups): CircMNTable3D(MinPt, MaxPt, cd, ngroups) { m_shift_y=Vector3(0.0,(m_max_pt-m_min_pt).Y(),0.0); m_shift_z=Vector3(0.0,0.0,(m_max_pt-m_min_pt).Z()); // check if grid spacing fits size in circular directions: double ny=(MaxPt-MinPt).Y()/m_celldim; double nz=(MaxPt-MinPt).Z()/m_celldim; // error message if not if(ny!=floor(ny)){ std::cout << "WARNING! grid spacing " << m_celldim << " doesn't fit periodic y-dimension " << (MaxPt-MinPt).Y() << std::endl; } if(nz!=floor(nz)){ std::cout << "WARNING! grid spacing " << m_celldim << " doesn't fit periodic z-dimension " << (MaxPt-MinPt).Z() << std::endl; } } /*! Destruct FullCircMNTable3D. */ FullCircMNTable3D::~FullCircMNTable3D() {} /*! set circularity of y-dimension to 1 */ void FullCircMNTable3D::set_y_circ() { m_y_periodic=1; } /*! set circularity of z-dimension to 1 */ void FullCircMNTable3D::set_z_circ() { m_z_periodic=1; } /*! get the cell index for a given position \param Pos the position \return the cell index if Pos is inside the table, -1 otherwise */ int FullCircMNTable3D::getIndex(const Vector3& Pos) const { int ret; int ix=int(floor((Pos.x()-m_origin.x())/m_celldim)); int iy=int(floor((Pos.y()-m_origin.y())/m_celldim)); int iz=int(floor((Pos.z()-m_origin.z())/m_celldim)); // check if pos is in table excl. padding if((ix>=0) && (ix<=m_nx-1) && (iy>=0) && (iy<=m_ny-1) && (iz>=0) && (iz<=m_nz-1)){ ret=idx(ix,iy,iz); } else { ret=-1; } return ret; } /*! Insert sphere. Insert clone into other side of Table. \param S the Sphere \param gid the group id */ bool FullCircMNTable3D::insert(const Sphere& S,unsigned int gid) { bool res; int id=getIndex(S.Center()); int xidx=getXIndex(S.Center()); int yidx=getYIndex(S.Center()); int zidx=getZIndex(S.Center()); if((id!=-1) && (xidx!=0) && (xidx!=m_nx-1) && (yidx!=0) && (yidx!=m_ny-1) && (zidx!=0) && (zidx!=m_nz-1) && (gid close_spheres=getSpheresFromGroupNear(S.Center(),S.Radius()-tol,gid); orig_insertable=(close_spheres.size()==0); // insertable if there are no spheres too close // check if clone is insertable // -- x -- if (xidx==1){ // original in x-min slice of the table -> shift clone to +x needs_xcloning=true; XClone.shift(m_shift_x); multimap close_spheres=getSpheresFromGroupNear(XClone.Center(),XClone.Radius()-tol,gid); xclone_insertable=(close_spheres.size()==0); } else if (xidx==m_nx-2){ // original in x-max slice of the table -> shift clone to -x needs_xcloning=true; XClone.shift(-1.0*m_shift_x); multimap close_spheres=getSpheresFromGroupNear(XClone.Center(),XClone.Radius()-tol,gid); xclone_insertable=(close_spheres.size()==0); } // -- y -- if (yidx==1){ // original in y-min slice of the table -> shift clone to +y needs_ycloning=true; YClone.shift(m_shift_y); multimap close_spheres=getSpheresFromGroupNear(YClone.Center(),YClone.Radius()-tol,gid); yclone_insertable=(close_spheres.size()==0); } else if (yidx==m_ny-2){ // original in y-max slice of the table -> shift clone to -y needs_ycloning=true; YClone.shift(-1.0*m_shift_y); multimap close_spheres=getSpheresFromGroupNear(YClone.Center(),YClone.Radius()-tol,gid); yclone_insertable=(close_spheres.size()==0); } // -- z -- if (zidx==1){ // original in z-min slice of the table -> shift clone to +z needs_zcloning=true; ZClone.shift(m_shift_z); multimap close_spheres=getSpheresFromGroupNear(ZClone.Center(),ZClone.Radius()-tol,gid); zclone_insertable=(close_spheres.size()==0); } else if (zidx==m_nz-2){ // original in z-max slice of the table -> shift clone to -z needs_zcloning=true; ZClone.shift(-1.0*m_shift_z); multimap close_spheres=getSpheresFromGroupNear(ZClone.Center(),ZClone.Radius()-tol,gid); zclone_insertable=(close_spheres.size()==0); } // original not in end slices -> no cloning } if(orig_insertable && (xclone_insertable || (!needs_xcloning)) && (yclone_insertable || (!needs_ycloning)) && (zclone_insertable || (!needs_zcloning))){ // if origin is insertable and all clones are either insertable or not needed m_data[id].insert(S,gid); // insert original if (needs_xcloning) { // if needed, insert xclone int clone_id=getFullIndex(XClone.Center()); m_data[clone_id].insert(XClone,gid); } if (needs_ycloning) { // if needed, insert clone int clone_id=getFullIndex(YClone.Center()); m_data[clone_id].insert(YClone,gid); } if (needs_zcloning) { // if needed, insert clone int clone_id=getFullIndex(ZClone.Center()); m_data[clone_id].insert(ZClone,gid); } res=true; } else { res=false; } return res; } bool FullCircMNTable3D::checkInsertable(const Sphere& S,unsigned int gid) { bool orig_insertable=false; bool clone_insertable=false; bool needs_cloning=false; int id=this->getIndex(S.Center()); int xidx=getXIndex(S.Center()); int yidx=getYIndex(S.Center()); int zidx=getZIndex(S.Center()); Sphere SClone=S; if((id!=-1) && (xidx!=0) && (xidx!=m_nx-1) && (yidx!=0) && (yidx!=m_ny-1) && (zidx!=0) && (zidx!=m_nz-1) && (gid close_spheres=getSpheresFromGroupNear(S.Center(),S.Radius()-s_small_value,gid); orig_insertable=(close_spheres.size()==0); // check if clone is insertable // -- x -- if (xidx==1){ // original in x-min slice of the table -> shift clone to +x needs_cloning=true; SClone.shift(m_shift_x); multimap close_spheres=getSpheresFromGroupNear(SClone.Center(),SClone.Radius()-s_small_value,gid); clone_insertable=(close_spheres.size()==0); } else if (xidx==m_nx-2){ // original in x-max slice of the table -> shift clone to -x needs_cloning=true; SClone.shift(-1.0*m_shift_x); multimap close_spheres=getSpheresFromGroupNear(SClone.Center(),SClone.Radius()-s_small_value,gid); clone_insertable=(close_spheres.size()==0); } // -- y -- if (yidx==1){ // original in y-min slice of the table -> shift clone to +y needs_cloning=true; SClone.shift(m_shift_y); multimap close_spheres=getSpheresFromGroupNear(SClone.Center(),SClone.Radius()-s_small_value,gid); clone_insertable=(close_spheres.size()==0); } else if (yidx==m_ny-2){ // original in y-max slice of the table -> shift clone to -y needs_cloning=true; SClone.shift(-1.0*m_shift_y); multimap close_spheres=getSpheresFromGroupNear(SClone.Center(),SClone.Radius()-s_small_value,gid); clone_insertable=(close_spheres.size()==0); } // -- z -- if (zidx==1){ // original in z-min slice of the table -> shift clone to +z needs_cloning=true; SClone.shift(m_shift_z); multimap close_spheres=getSpheresFromGroupNear(SClone.Center(),SClone.Radius()-s_small_value,gid); clone_insertable=(close_spheres.size()==0); } else if (zidx==m_nz-2){ // original in z-max slice of the table -> shift clone to -z needs_cloning=true; SClone.shift(-1.0*m_shift_z); multimap close_spheres=getSpheresFromGroupNear(SClone.Center(),SClone.Radius()-s_small_value,gid); clone_insertable=(close_spheres.size()==0); } // original not in end slices -> no cloning } return (orig_insertable && (clone_insertable || (!needs_cloning))); // original is insertable and clone is either insertable or not needed } /*! Generate bonds between particles of a group. Takes cloned particles into account. \param gid the group ID \param tol max. difference between bond length and equilibrium dist. \param btag bond tag */ void FullCircMNTable3D::generateBonds(int gid,double tol,int btag) { std::cout << "FullCircMNTable3D::generateBonds( " << gid << " , " << tol << " , " << btag << " )" << std::endl; // loop over all inner cells for(int i=0;i > bonds; if((ii+jj+kk)==0){ // intra-cell, not for boundary // std::cout << id << " - " << id << std::endl; bonds=m_data[id].getBonds(gid,tol); } else if(id2>id){ // inter-cell //std::cout << id << " - " << id2 << std::endl; bonds=m_data[id].getBonds(gid,tol,m_data[id2]); } for(vector >::iterator iter=bonds.begin(); iter!=bonds.end(); iter++){ //std::cout << iter->first << " | " << iter->second << " "; if(iter->second > iter->first){ m_bonds[btag].insert(*iter); } } //std::cout << std::endl; } } } //std::cout << std::endl; } } } } // ostream& FullCircMNTable3D::operator << (ostream&,const FullCircMNTable3D&) // {} GenGeo-1.2/src/FullCircMNTable3D.h0000644000000000000000000000324312533740504014710 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __FULLCIRCMNTABLE3D_H #define __FULLCIRCMNTABLE3D_H // --- Project includes --- #include "CircMNTable3D.h" /*! \class FullCircMNTable3D \brief circular 3D Multi-group Neighbour table Neighbour table supporting multiple tagged groups of particles and circular boundary conditions in x, y and z */ class FullCircMNTable3D : public CircMNTable3D { protected: Vector3 m_shift_y,m_shift_z; virtual void set_y_circ(); virtual void set_z_circ(); virtual int getIndex(const Vector3&) const; public: FullCircMNTable3D(); FullCircMNTable3D(const Vector3&,const Vector3&,double,unsigned int); virtual ~FullCircMNTable3D(); virtual bool insert(const Sphere&,unsigned int); virtual bool insertChecked(const Sphere&,unsigned int,double tol=s_small_value); virtual bool checkInsertable(const Sphere&,unsigned int); virtual void generateBonds(int,double,int); // output // friend ostream& operator << (ostream&,const FullCircMNTable3D&); }; #endif // __FULLCIRCMNTABLE3D_H GenGeo-1.2/src/GenericShape.cc0000644000000000000000000001162112533740504014305 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "GenericShape.h" #include #include #ifdef DEBUG #include #define DPRINT(...) printf("%s:%d ",__FUNCTION__,__LINE__);printf(__VA_ARGS__); #else #define DPRINT(...) #endif /* DEBUG */ #define NEXTLINE \ if ( valid == 1 ) { \ if ( std::getline(infile,line).eof()) { \ valid = 0; \ } \ } GenericShape::GenericShape(string fileDB, string name) { int valid; regex re; string line; std::ifstream infile(fileDB.c_str()); valid = 1; NEXTLINE try { // Find the shape in the file with the correct name re.assign("name=\"" + name + "\","); while ( (!regex_match(line,re)) && ( valid == 1)) { NEXTLINE // Find matching shape } if (regex_match(line,re)) { NEXTLINE // Will retrieve "sphereList = [" line NEXTLINE // Skip over "sphereList = [" line to first sphere // Extract out all following lines containing 4-tuples as origins and // radii regex retwo; retwo.assign("\\((-?[\\d\\.]+),(-?[\\d\\.]+),(-?[\\d\\.]+),([\\d\\.]+)\\),?"); boost::cmatch matches; while (regex_match(line.c_str(),matches,retwo)) { string xstr(matches[1].first, matches[1].second); double x = strtod(xstr.c_str(),NULL); string ystr(matches[2].first, matches[2].second); double y = strtod(ystr.c_str(),NULL); string zstr(matches[3].first, matches[3].second); double z = strtod(zstr.c_str(),NULL); string rstr(matches[4].first, matches[4].second); double r = strtod(rstr.c_str(),NULL); if (( sqrt(x*x+y*y+z*z) <= 1.0f ) && ( r > 0 )) { Vector3 center(x,y,z); origins.push_back(center); radii.push_back(r); } NEXTLINE // Next line in file } NEXTLINE // Skip over "]" line NEXTLINE // Skip over "bondList = [" line // Extract out all following lines containing tuples as bonds. retwo.assign("\\((\\d+),(\\d+)\\),?"); while (regex_match(line.c_str(),matches,retwo)) { string firststr(matches[1].first, matches[1].second); unsigned int first = atoi(firststr.c_str()); string secondstr(matches[2].first, matches[2].second); unsigned int second = atoi(secondstr.c_str()); if ((first <= radii.size()) &&( second <= radii.size()) && (first != second)) { vector bond; bond.push_back(first); bond.push_back(second); std::cout << "Pair added: " << first << ", " << second << std::endl; bonds.push_back(bond); } NEXTLINE } // At this point we simply assume the shape is now valid // valid = 1; } } catch (boost::regex_error& e) { std::cout << "Regexp failed:" << e.code() << std::endl; } if ( origins.size() != radii.size() ) { std::cout << "Parsed " << radii.size() << " radii and " << origins.size() << " origins. Something broken.\n"; } std::cout << "Parsed " << radii.size() << " spheres and " << bonds.size() << " bonds.\n"; if ( valid != 1 ) { std::cout << "Error parsing." << std::endl; bonds.clear(); radii.clear(); origins.clear(); } infile.close(); return; } void GenericShape::insert(Vector3 pos, double radius, MNTable3D* table, int tag, int id) { int *ids; if ( ( ids = (int *)(malloc(radii.size()*sizeof(int)))) == NULL ) { std::cout << "Err: Cannot allocate memory for IDs" << std::endl; return; } if ( this->useRandomOrientation() ) { this->setRandomOrientation(); } unsigned int k; for(k=0;kcheckInsertable(Sk,id)){ Sk.setTag(this->getParticleTag()); table->insert(Sk,id); ids[k] = Sk.Id(); } else { ids[k] = 0; } } for(k=0;k bondpair = bonds[k]; int particleA = bondpair[0]; int particleB = bondpair[1]; if (( ids[particleA] == 0 )|| ( ids[particleB] == 0)) { } else { table->insertBond(ids[particleA],ids[particleB],this->getBondTag()); } } } int GenericShape::bias() { return Shape::bias(); } void GenericShape::setBias(int i) { Shape::setBias(i); } GenGeo-1.2/src/GenericShape.h0000644000000000000000000000232212533740504014145 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef GENERICSHAPE_H #define GENERICSHAPE_H #include #include #include "util/vector3.h" #include "Shape.h" #include "string" using std::string; using boost::regex; using boost::regex_match; class GenericShape : public Shape { public: GenericShape(string, string); void insert(Vector3 pos, double radius, MNTable3D* ntable, int, int); int bias(); void setBias(int); protected: vector origins; vector radii; vector > bonds; }; #endif /* GENERICSHAPE_H */ GenGeo-1.2/src/HGrainGenerator.cc0000644000000000000000000000727712533740504015003 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// // --- Project includes --- #include "HGrainGenerator.h" // --- system includes --- #include using std::ceil; using std::sqrt; // --- IO includes --- #include HGrainGenerator2D::HGrainGenerator2D() {} /*! constructor \param rad particle radius */ HGrainGenerator2D::HGrainGenerator2D(double rad) { m_rad=rad; } /*! destructor - do nothing */ HGrainGenerator2D::~HGrainGenerator2D() {} /*! generate packing \param vol a pointer to the volume in which the packing is generated \param ntable a pointer to the neighbour table used \param gid particle group id \param tag the particle tag */ void HGrainGenerator2D::generatePacking(AVolume2D* vol,MNTable2D* ntable,int gid, int tag) { const double tol=1e-5; // --- GENERATE REGULAR LATTICE --- // get bounding box pair bbx=vol->getBoundingBox(); double dx=(bbx.second.X()-bbx.first.X())-2.0*m_rad; double dy=(bbx.second.Y()-bbx.first.Y())-2.0*m_rad; // get index limits for seeding int imax=int(floor(dx/(m_rad*2.0)))+1; if(dx-(double(imax)*m_rad*2.0)>0.5*m_rad) imax++; int jmax=int(floor(dy/(m_rad*sqrt(3.0))))+1; // check if odd or even bool even=(dx-(double(imax)*m_rad*2.0)>0.5*m_rad); std::cout << "imax, jmax, even " << imax << " " << jmax << " " << even << std::endl; // seed positions for(int i=0;iinsert(S,gid); } } for(int j=0;jinsert(S,gid); } } // pick hex grains if(!even){ double x0=bbx.first.X()+tol+4.0*m_rad; double y0=bbx.first.Y()+tol+(1.0+sqrt(3.0))*m_rad; double dxi=5.0*m_rad; double dxi3=m_rad; double dyi=sqrt(3.0)*m_rad; int igmax=ceil(dx/5.0*m_rad); double dxj=m_rad; double dyj=3.0*sqrt(3.0)*m_rad; double dyj3=sqrt(3.0)*m_rad; int jgmax=ceil(dy/(3.0*sqrt(3.0))*m_rad); for(int i=0;i=3.0*m_rad) && (bbx.second.X()-px>=3.0*m_rad)&& (py-bbx.first.Y()>=(sqrt(3.0)+1.0)*m_rad) && (bbx.second.Y()-py>=(sqrt(3.0)+1.0)*m_rad)){ ntable->tagParticlesNear(Vector3(px,py,0.0),m_rad+tol,gid,2); ntable->generateBondsWithMask(gid,tol,2,2,2); ntable->tagParticlesNear(Vector3(px,py,0.0),m_rad+tol,gid,1); } } } } ntable->removeTagged(gid,0,7); } ostream& operator << (ostream& ost,const HGrainGenerator2D& T) { return ost; } GenGeo-1.2/src/HGrainGenerator.h0000644000000000000000000000240412533740504014630 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __HGRAINGENERATOR2D_H #define __HGRAINGENERATOR2D_H // --- Project includes --- #include "AVolume2D.h" #include "MNTable2D.h" #include "AGenerator2D.h" /*! \class HGrainGenerator2D class the generate hexagonal grains on a regular base lattice */ class HGrainGenerator2D : public AGenerator2D { protected: double m_rad; public: HGrainGenerator2D(); HGrainGenerator2D(double); virtual ~HGrainGenerator2D(); virtual void generatePacking (AVolume2D*,MNTable2D*,int,int); friend ostream& operator << (ostream&,const HGrainGenerator2D&); }; #endif // __HGRAINGENERATOR2D_H GenGeo-1.2/src/HexAggregateInsertGenerator2D.cc0000644000000000000000000001651112533740504017530 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "HexAggregateInsertGenerator2D.h" // --- System includes --- #include #include using std::ceil; using std::sqrt; using std::sin; using std::cos; // --- project includes --- #include "sphere_fitting/Sphere2DFitter.h" HexAggregateInsertGenerator2D::HexAggregateInsertGenerator2D() {} /*! Constructor \param rmin minimum particle radius \param rmax maximum particle radius \param ntries max. nr. of tries to insert particle \param max_iter maximum iterations within the iterative solvers \param prec max. error in iterative solvers */ HexAggregateInsertGenerator2D::HexAggregateInsertGenerator2D(double rmin, double rmax, int tries, int max_iter, double prec) : InsertGenerator2D(rmin,rmax,tries,max_iter,prec) {} /*! seed the area with particles \param vol a pointer to the packing volume \param ntable a pointer to the neighbour table used \param gid particle group id \param tag the particle tag */ void HexAggregateInsertGenerator2D::seedParticles(AVolume2D* vol,MNTable2D*ntable ,int gid,int tag) { std::cout << "HexAggregateInsertGenerator2D::seedParticles" << std::endl; // get bounding box pair bbx=vol->getBoundingBox(); double dx=(bbx.second.X()-bbx.first.X())-2.0*m_rmax; double dy=(bbx.second.Y()-bbx.first.Y())-2.0*m_rmax; // get index limits for seeding int imax=int(ceil(dx/(m_rmax*2.0))); int jmax=int(ceil(dy/(m_rmax*sqrt(3.0)))); // seed positions for(int i=0;im_rmin){ // calc random radius double r; double jitter; if(deisIn(S) && ntable->checkInsertable(S,gid); if(fit){ // -- insert 7 smaller particles instead of 1 large double rn=r/3.0; // new radii // center sphere Sphere Sc(Vector3(px,py,0.0),rn); Sc.setTag(tag); ntable->insertChecked(Sc,gid); int Sc_id=Sc.Id(); // outer spheres int Sk_id[6]; // random rotation double k_off=(double)(rand())/(double)(RAND_MAX); for(int k=0;k<6;k++){ double phi=double(k+k_off)*1.04719551; // (k+k_off)*pi/3 double pxk=px+2.0000*rn*sin(phi); double pyk=py+2.0000*rn*cos(phi); Sphere Sk(Vector3(pxk,pyk,0.0),rn*0.9999); if(vol->isIn(Sk) && ntable->checkInsertable(Sk,gid)){ Sk.setTag(tag); ntable->insert(Sk,gid); Sk_id[k]=Sk.Id(); ntable->insertBond(Sc_id,Sk_id[k],0); // bond between center and outer } else { Sk_id[k]=-1; } } for(int k=0;k<6;k++){ int k2=(k+1) % 6; if((Sk_id[k]!=-1) && (Sk_id[k2]!=-1)) { ntable->insertBond(Sk_id[k],Sk_id[k2],0); } } } } } } } /*! seed the area with particles \param vol a pointer to the packing volume \param ntable a pointer to the neighbour table used \param gid particle group id \param tag the particle tag */ void HexAggregateInsertGenerator2D::fillIn(AVolume2D* vol,MNTable2D* ntable ,int gid,int tag) { Sphere nsph; int total_tries=0; int count_insert=0; int nvol=vol->getNumberSubVolumes(); for(int ivol=0;ivolgetAPoint(ivol); // get random point within volume multimap close_particles=ntable->getSpheresClosestTo(P,3); // get 3 nearest spheres map close_lines=vol->getClosestPlanes(P,2); // get 2 nearest planes map geomap; geomap.insert(close_particles.begin(),close_particles.end()); geomap.insert(close_lines.begin(),close_lines.end()); if(geomap.size()>=3){ map::iterator iter=geomap.begin(); const AGeometricObject* GO1=iter->second;iter++; const AGeometricObject* GO2=iter->second;iter++; const AGeometricObject* GO3=iter->second; nsph=FitSphere2D(GO1,GO2,GO3,P,m_max_iter,m_prec); findfit=true; } if(findfit){ // check if within radius range bool is_radius=(m_rminnsph.Radius()); // check inside volume, intersections ... bool fit=vol->isIn(nsph) && ntable->checkInsertable(nsph,gid); if(fit && is_radius){ // acceptable particle // -- insert 7 smaller particles instead of 1 large double rn=nsph.Radius()/3.0; // new radii double px=nsph.Center().X(); double py=nsph.Center().Y(); // center sphere Sphere Sc(Vector3(px,py,0.0),rn); Sc.setTag(tag); ntable->insertChecked(Sc,gid); int Sc_id=Sc.Id(); // outer spheres int Sk_id[6]; for(int k=0;k<6;k++){ double phi=double(k)*1.04719551; // k*pi/3 double pxk=px+2.0*rn*sin(phi); double pyk=py+2.0*rn*cos(phi); Sphere Sk(Vector3(pxk,pyk,0.0),rn*0.9999); Sk.setTag(tag); if(vol->isIn(Sk) && ntable->checkInsertable(Sk,gid)){ Sk.setTag(tag); ntable->insert(Sk,gid); Sk_id[k]=Sk.Id(); ntable->insertBond(Sc_id,Sk_id[k],0); // bond between center and outer } else { Sk_id[k]=-1; } } for(int k=0;k<6;k++){ int k2=(k+1) % 6; if((Sk_id[k]!=-1) && (Sk_id[k2]!=-1)) { ntable->insertBond(Sk_id[k],Sk_id[k2],0); } } count_insert++; if((count_insert%100)==0) std::cout << "inserted: " << count_insert << std::endl; total_tries+=countfail; if(countfail>m_max_tries/10) std::cout << countfail << " tries" << std::endl; countfail=0; // reset failure counter } else countfail++; } else countfail++; } } std::cout << "total tries: " << total_tries << std::endl; } GenGeo-1.2/src/HexAggregateInsertGenerator2D.h0000644000000000000000000000246212533740504017372 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __HEXAGGREGATEINSERTGENERATOR2D_H #define __HEXAGGREGATEINSERTGENERATOR2D_H // --- Project includes --- #include "InsertGenerator2D.h" /*! \class InsertGenerator2D Packing generator using Place et al. insertion based algorithm. */ class HexAggregateInsertGenerator2D : public InsertGenerator2D { protected: virtual void seedParticles(AVolume2D* ,MNTable2D* ,int,int); public: HexAggregateInsertGenerator2D(); HexAggregateInsertGenerator2D(double,double,int,int,double); virtual ~HexAggregateInsertGenerator2D(){}; virtual void fillIn(AVolume2D* ,MNTable2D* ,int,int); }; #endif // __HEXAGGREGATEINSERTGENERATOR2D_H GenGeo-1.2/src/HexAggregateInsertGenerator2DRand.cc0000644000000000000000000001705612533740504020342 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "HexAggregateInsertGenerator2DRand.h" // --- System includes --- #include #include #include using std::ceil; using std::sqrt; using std::sin; using std::cos; // --- project includes --- #include "sphere_fitting/Sphere2DFitter.h" HexAggregateInsertGenerator2DRand::HexAggregateInsertGenerator2DRand() {} /*! Constructor \param rmin minimum particle radius \param rmax maximum particle radius \param ntries max. nr. of tries to insert particle \param max_iter maximum iterations within the iterative solvers \param prec max. error in iterative solvers \param rprob probablility (0..1) that one of the particles is removed */ HexAggregateInsertGenerator2DRand::HexAggregateInsertGenerator2DRand(double rmin, double rmax, int tries, int max_iter, double prec, double rprob) : HexAggregateInsertGenerator2D(rmin,rmax,tries,max_iter,prec) { m_remove_prob=rprob; struct timeval tv; gettimeofday(&tv,NULL); int random_seed=tv.tv_usec; srand(random_seed); } /*! seed the area with particles \param vol a pointer to the packing volume \param ntable a pointer to the neighbour table used \param gid particle group id \param tag the particle tag */ void HexAggregateInsertGenerator2DRand::seedParticles(AVolume2D* vol,MNTable2D*ntable ,int gid,int tag) { std::cout << "HexAggregateInsertGenerator2DRand::seedParticles" << std::endl; // get bounding box pair bbx=vol->getBoundingBox(); double dx=(bbx.second.X()-bbx.first.X())-2.0*m_rmax; double dy=(bbx.second.Y()-bbx.first.Y())-2.0*m_rmax; // get index limits for seeding int imax=int(ceil(dx/(m_rmax*2.0))); int jmax=int(ceil(dy/(m_rmax*sqrt(3.0)))); // seed positions for(int i=0;im_rmin){ // calc random radius double r; if(deisIn(S) && ntable->checkInsertable(S,gid); if(fit){ // -- insert 7 smaller particles instead of 1 large double rn=r/3.0; // new radii // center sphere Sphere Sc(Vector3(px,py,0.0),rn); Sc.setTag(tag); ntable->insertChecked(Sc,gid); int Sc_id=Sc.Id(); // outer spheres int Sk_id[6]; // generate random value double rval=((double)(rand())/(double)(RAND_MAX)); int npart; if(rval>m_remove_prob){ // if random value exceed removal probability - all 6 particles npart = 6; } else { npart = 5; Sk_id[5]=-1; } for(int k=0;kisIn(Sk) && ntable->checkInsertable(Sk,gid)){ Sk.setTag(tag); ntable->insert(Sk,gid); Sk_id[k]=Sk.Id(); ntable->insertBond(Sc_id,Sk_id[k],0); // bond between center and outer } else { Sk_id[k]=-1; } } for(int k=0;kinsertBond(Sk_id[k],Sk_id[k2],0); } } } } } } } /*! seed the area with particles \param vol a pointer to the packing volume \param ntable a pointer to the neighbour table used \param gid particle group id \param tag the particle tag */ void HexAggregateInsertGenerator2DRand::fillIn(AVolume2D* vol,MNTable2D* ntable ,int gid,int tag) { Sphere nsph; int total_tries=0; int count_insert=0; int nvol=vol->getNumberSubVolumes(); for(int ivol=0;ivolgetAPoint(ivol); // get random point within volume multimap close_particles=ntable->getSpheresClosestTo(P,3); // get 3 nearest spheres map close_lines=vol->getClosestPlanes(P,2); // get 2 nearest planes map geomap; geomap.insert(close_particles.begin(),close_particles.end()); geomap.insert(close_lines.begin(),close_lines.end()); if(geomap.size()>=3){ map::iterator iter=geomap.begin(); const AGeometricObject* GO1=iter->second;iter++; const AGeometricObject* GO2=iter->second;iter++; const AGeometricObject* GO3=iter->second; nsph=FitSphere2D(GO1,GO2,GO3,P,m_max_iter,m_prec); findfit=true; } if(findfit){ // check if within radius range bool is_radius=(m_rminnsph.Radius()); // check inside volume, intersections ... bool fit=vol->isIn(nsph) && ntable->checkInsertable(nsph,gid); if(fit && is_radius){ // acceptable particle // -- insert 7 smaller particles instead of 1 large double rn=nsph.Radius()/3.0; // new radii double px=nsph.Center().X(); double py=nsph.Center().Y(); // center sphere Sphere Sc(Vector3(px,py,0.0),rn); Sc.setTag(tag); ntable->insertChecked(Sc,gid); int Sc_id=Sc.Id(); // outer sphere int Sk_id[6]; // generate random value double rval=((double)(rand())/(double)(RAND_MAX)); int npart; if(rval>m_remove_prob){ // if random value exceed removal probability - all 6 particles npart = 6; } else { npart = 5; Sk_id[5]=-1; } for(int k=0;kisIn(Sk) && ntable->checkInsertable(Sk,gid)){ Sk.setTag(tag); ntable->insert(Sk,gid); Sk_id[k]=Sk.Id(); ntable->insertBond(Sc_id,Sk_id[k],0); // bond between center and outer } else { Sk_id[k]=-1; } } for(int k=0;kinsertBond(Sk_id[k],Sk_id[k2],0); } } count_insert++; if((count_insert%100)==0) std::cout << "inserted: " << count_insert << std::endl; total_tries+=countfail; if(countfail>m_max_tries/10) std::cout << countfail << " tries" << std::endl; countfail=0; // reset failure counter } else countfail++; } else countfail++; } } std::cout << "total tries: " << total_tries << std::endl; } GenGeo-1.2/src/HexAggregateInsertGenerator2DRand.h0000644000000000000000000000260512533740504020176 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __HEXAGGREGATEINSERTGENERATOR2DRAND_H #define __HEXAGGREGATEINSERTGENERATOR2DRAND_H // --- Project includes --- #include "HexAggregateInsertGenerator2D.h" /*! \class InsertGenerator2D Packing generator using Place et al. insertion based algorithm. */ class HexAggregateInsertGenerator2DRand : public HexAggregateInsertGenerator2D { protected: double m_remove_prob; virtual void seedParticles(AVolume2D* ,MNTable2D* ,int,int); public: HexAggregateInsertGenerator2DRand(); HexAggregateInsertGenerator2DRand(double,double,int,int,double,double); virtual ~HexAggregateInsertGenerator2DRand(){}; virtual void fillIn(AVolume2D* ,MNTable2D* ,int,int); }; #endif // __HEXAGGREGATEINSERTGENERATOR2DRAND_H GenGeo-1.2/src/HexAggregateInsertGenerator3D.cc0000644000000000000000000002064412533740504017533 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "HexAggregateInsertGenerator3D.h" // --- System includes --- #include #include using std::ceil; using std::sqrt; using std::sin; using std::cos; // --- project includes --- #include "sphere_fitting/Sphere3DFitter.h" HexAggregateInsertGenerator3D::HexAggregateInsertGenerator3D() {} /*! Constructor \param rmin minimum particle radius \param rmax maximum particle radius \param ntries max. nr. of tries to insert particle \param max_iter maximum iterations within the iterative solvers \param prec max. error in iterative solvers \param seed if true, initialize random number generator via time */ HexAggregateInsertGenerator3D::HexAggregateInsertGenerator3D(double rmin,double rmax ,int ntries,int max_iter,double prec, bool seed) :InsertGenerator3D(rmin,rmax,ntries,max_iter,prec,seed) {} /*! take a sphere and insert a aggregate grain into the ntable instead \param S the sphere */ void HexAggregateInsertGenerator3D::ParticleToAggregate(MNTable3D* ntable, const Sphere& S, int gid) { double rn=S.Radius()/3.0; // new radii // center sphere Sphere Sc(S.Center(),rn); Sc.setTag(S.Tag()); ntable->insertChecked(Sc,gid); int Sc_id=Sc.Id(); // outer spheres int Sk_id[6]; for(int k=0;k<6;k++){ double phi=double(k)*1.04719551; // k*pi/3 Vector3 offset=Vector3(2.0000*rn*sin(phi),2.0000*rn*cos(phi),0.0); Sphere Sk(S.Center()+offset,rn*0.99999); if(ntable->checkInsertable(Sk,gid)){ Sk.setTag(S.Tag()); ntable->insert(Sk,gid); Sk_id[k]=Sk.Id(); ntable->insertBond(Sc_id,Sk_id[k],0); // bond between center and outer } else { Sk_id[k]=-1; } } for(int k=0;k<6;k++){ int k2=(k+1) % 6; if((Sk_id[k]!=-1) && (Sk_id[k2]!=-1)) { ntable->insertBond(Sk_id[k],Sk_id[k2],0); } } // upper spheres int Sk_up[3]; double alpha=0.5235987755982988; // pi/6 (30) double beta=1.5707963267948965-atan(0.7071067811865475); for(int k=0;k<3;k++){ double rho=beta; double phi=double(1+4*k)*alpha; Vector3 offset=Vector3(2.0*rn*sin(phi)*cos(rho), 2.0*rn*cos(phi)*cos(rho), 2.0*rn*sin(rho)); Sphere Sk(S.Center()+offset,rn*0.99999); if(ntable->checkInsertable(Sk,gid)){ Sk.setTag(S.Tag()); ntable->insert(Sk,gid); Sk_up[k]=Sk.Id(); ntable->insertBond(Sc_id,Sk_up[k],0); // bond between center and upper if(Sk_id[k*2]!=-1) ntable->insertBond(Sk_id[k*2],Sk_up[k],0); if(Sk_id[(k*2+1)%6]!=-1) ntable->insertBond(Sk_id[(k*2+1)%6],Sk_up[k],0); } else { Sk_up[k]=-1; } } // bond within upper for(int k=0;k<3;k++){ int k2=(k+1) % 3; if((Sk_up[k]!=-1) && (Sk_up[k2]!=-1)) { ntable->insertBond(Sk_up[k],Sk_up[k2],0); } } // lower spheres for(int k=0;k<3;k++){ double rho=beta; double phi=double(1+4*k)*alpha; Vector3 offset=Vector3(2.0*rn*sin(phi)*cos(rho), 2.0*rn*cos(phi)*cos(rho), -2.0*rn*sin(rho)); Sphere Sk(S.Center()+offset,rn*0.99999); if(ntable->checkInsertable(Sk,gid)){ Sk.setTag(S.Tag()); ntable->insert(Sk,gid); Sk_up[k]=Sk.Id(); ntable->insertBond(Sc_id,Sk_up[k],0); // bond between center and upper if(Sk_id[k*2]!=-1) ntable->insertBond(Sk_id[k*2],Sk_up[k],0); if(Sk_id[(k*2+1)%6]!=-1) ntable->insertBond(Sk_id[(k*2+1)%6],Sk_up[k],0); } else { Sk_up[k]=-1; } } // bond within upper for(int k=0;k<3;k++){ int k2=(k+1) % 3; if((Sk_up[k]!=-1) && (Sk_up[k2]!=-1)) { ntable->insertBond(Sk_up[k],Sk_up[k2],0); } } } /*! seed the volume with particles \param vol a pointer to the packing volume \param ntable a pointer to the neighbour table used \param gid particle group id \param tag the particle tag */ void HexAggregateInsertGenerator3D::seedParticles(AVolume3D* vol,MNTable3D* ntable,int gid,int tag) { std::cout << "HexAggregateInsertGenerator3D::seedParticles" << std::endl; // get bounding box pair bbx=vol->getBoundingBox(); std::cout << "bbx: " << bbx.first << " - " << bbx.second << std::endl; double dx=(bbx.second.X()-bbx.first.X()); double dy=(bbx.second.Y()-bbx.first.Y()); double dz=(bbx.second.Z()-bbx.first.Z()); // get index limits for seeding int imax=int(ceil(dx/(m_rmax*2.0))); int jmax=int(ceil(dy/(m_rmax*sqrt(3.0)))); int kmax=int(ceil(dz/(m_rmax*2.0*sqrt(2.0/3.0)))); // seed positions for(int i=0;i<=imax;i++){ for(int j=0;j<=jmax;j++){ for(int k=0;k<=kmax;k++){ double px=bbx.first.X()+((double(i)+0.5*double(j%2)+0.5*double(k%2))*m_rmax*2.0)+m_rmax+1e-5; double py=bbx.first.Y()+((double(j)+double(k%2)/3.0)*sqrt(3.0)*m_rmax)+m_rmax+1e-5; double pz=bbx.first.Z()+((double(k)*2.0*sqrt(2.0/3.0))*m_rmax)+m_rmax+1e-5; // get dist to egde double dex=(bbx.second.X()-px) < (px-bbx.first.X()) ? bbx.second.X()-px : px-bbx.first.X(); double dey=(bbx.second.Y()-py) < (py-bbx.first.Y()) ? bbx.second.Y()-py : py-bbx.first.Y(); double dez=(bbx.second.Z()-pz) < (pz-bbx.first.Z()) ? bbx.second.Z()-pz : pz-bbx.first.Z(); double de=(dexm_rmin){ // calc random radius double r; if(deisIn(S) && ntable->checkInsertable(S,gid); if(fit){ ParticleToAggregate(ntable,S,gid); } } } } } } /*! fill the remaining volume with particles \param vol a pointer to the packing volume \param ntable a pointer to the neighbour table used \param gid particle group id \param tag the particle tag */ void HexAggregateInsertGenerator3D::fillIn(AVolume3D*vol ,MNTable3D* ntable,int gid,int tag) { Sphere nsph; int total_tries=0; int count_insert=0; int nvol=vol->getNumberSubVolumes(); for(int ivol=0;ivolgetAPoint(ivol); // get random point within volume multimap close_particles=ntable->getSpheresClosestTo(P,4); // get 3 nearest spheres map close_lines=vol->getClosestObjects(P,3); // get 2 nearest planes map geomap; geomap.insert(close_particles.begin(),close_particles.end()); geomap.insert(close_lines.begin(),close_lines.end()); if(geomap.size()>=4){ map::iterator iter=geomap.begin(); const AGeometricObject* GO1=iter->second;iter++; const AGeometricObject* GO2=iter->second;iter++; const AGeometricObject* GO3=iter->second;iter++; const AGeometricObject* GO4=iter->second; nsph=FitSphere3D(GO1,GO2,GO3,GO4,P,m_max_iter,m_prec); findfit=true; } if(findfit){ // check if within radius range bool is_radius=(m_rminnsph.Radius()); // check inside volume, intersections ... bool fit=vol->isIn(nsph) && ntable->checkInsertable(nsph,gid); if(fit && is_radius){ // acceptable particle nsph.setTag(tag); ParticleToAggregate(ntable,nsph,gid); count_insert++; total_tries+=countfail; last_fail_count+=countfail; if((count_insert%100)==0) { std::cout << "inserted " << count_insert << " at avg. " << double(last_fail_count)*0.01 << std::endl; last_fail_count=0; } //if(countfail>m_max_tries/10) std::cout << countfail << " tries" << std::endl; countfail=0; // reset failure counter } else { countfail++; } } else countfail++; } } std::cout << "total tries: " << total_tries << std::endl; } GenGeo-1.2/src/HexAggregateInsertGenerator3D.h0000644000000000000000000000273412533740504017375 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __HEXAGGREGATEINSERTGENERATOR3D_H #define __HEXAGGREGATEINSERTGENERATOR3D_H // --- Project includes --- #include "InsertGenerator3D.h" /*! \class HexAggregateInsertGenerator3D Packing generator using Place et al. insertion based algorithm to generate 1st generation particles which are replaced by regular 12-particle aggreagates. */ class HexAggregateInsertGenerator3D : public InsertGenerator3D { protected: virtual void seedParticles(AVolume3D* ,MNTable3D* ,int,int); void ParticleToAggregate(MNTable3D*, const Sphere&,int); public: HexAggregateInsertGenerator3D(); HexAggregateInsertGenerator3D(double,double,int,int,double,bool); virtual ~HexAggregateInsertGenerator3D(){}; virtual void fillIn(AVolume3D* ,MNTable3D* ,int,int); }; #endif // __HEXAGGREGATEINSERTGENERATOR2D_H GenGeo-1.2/src/HexAggregateShape.cc0000644000000000000000000000665712533740504015301 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "HexAggregateShape.h" void HexAggregateShape::insert(Vector3 pos, double radius, MNTable3D* table, int tag, int id) { if ( this->useRandomOrientation() ) { this->setRandomOrientation(); } double rn=radius/3.0; // new radii // center sphere Sphere Sc(pos,rn); Sc.setTag(tag); table->insertChecked(Sc,id); int Sc_id=id; // outer spheres int Sk_id[6]; for(int k=0;k<6;k++){ double phi=double(k)*1.04719551; // k*pi/3 Vector3 offset=Vector3(2.0000*rn*sin(phi),2.0000*rn*cos(phi),0.0); Sphere Sk(pos + rotatePoint(offset),rn*0.99999); if(table->checkInsertable(Sk,id)){ Sk.setTag(tag); table->insert(Sk,id); Sk_id[k]=id; table->insertBond(Sc_id,Sk_id[k],0); // bond between center and outer } else { Sk_id[k]=-1; } } for(int k=0;k<6;k++){ int k2=(k+1) % 6; if((Sk_id[k]!=-1) && (Sk_id[k2]!=-1)) { table->insertBond(Sk_id[k],Sk_id[k2],0); } } // upper spheres int Sk_up[3]; double alpha=0.5235987755982988; // pi/6 (30) double beta=1.5707963267948965-atan(0.7071067811865475); for(int k=0;k<3;k++){ double rho=beta; double phi=double(1+4*k)*alpha; Vector3 offset=Vector3(2.0*rn*sin(phi)*cos(rho), 2.0*rn*cos(phi)*cos(rho), 2.0*rn*sin(rho)); Sphere Sk(pos+rotatePoint(offset),rn*0.99999); if(table->checkInsertable(Sk,id)){ Sk.setTag(tag); table->insert(Sk,id); Sk_up[k]=id; table->insertBond(Sc_id,Sk_up[k],0); // bond between center and upper if(Sk_id[k*2]!=-1) table->insertBond(Sk_id[k*2],Sk_up[k],0); if(Sk_id[(k*2+1)%6]!=-1) table->insertBond(Sk_id[(k*2+1)%6],Sk_up[k],0); } else { Sk_up[k]=-1; } } // bond within upper for(int k=0;k<3;k++){ int k2=(k+1) % 3; if((Sk_up[k]!=-1) && (Sk_up[k2]!=-1)) { table->insertBond(Sk_up[k],Sk_up[k2],0); } } // lower spheres for(int k=0;k<3;k++){ double rho=beta; double phi=double(1+4*k)*alpha; Vector3 offset=Vector3(2.0*rn*sin(phi)*cos(rho), 2.0*rn*cos(phi)*cos(rho), -2.0*rn*sin(rho)); Sphere Sk(pos+rotatePoint(offset),rn*0.99999); if(table->checkInsertable(Sk,id)){ Sk.setTag(tag); table->insert(Sk,id); Sk_up[k]=id; table->insertBond(Sc_id,Sk_up[k],0); // bond between center and upper if(Sk_id[k*2]!=-1) table->insertBond(Sk_id[k*2],Sk_up[k],0); if(Sk_id[(k*2+1)%6]!=-1) table->insertBond(Sk_id[(k*2+1)%6],Sk_up[k],0); } else { Sk_up[k]=-1; } } // bond within upper for(int k=0;k<3;k++){ int k2=(k+1) % 3; if((Sk_up[k]!=-1) && (Sk_up[k2]!=-1)) { table->insertBond(Sk_up[k],Sk_up[k2],0); } } } int HexAggregateShape::bias() { return Shape::bias(); } void HexAggregateShape::setBias(int i) { Shape::setBias(i); } GenGeo-1.2/src/HexAggregateShape.h0000644000000000000000000000160012533740504015122 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "util/vector3.h" #include "Shape.h" class HexAggregateShape : public Shape { public: void insert(Vector3 pos, double radius, MNTable3D* ntable, int, int); int bias(); void setBias(int); }; GenGeo-1.2/src/InsertGenerator2D.cc0000644000000000000000000001614012533740504015252 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "InsertGenerator2D.h" // --- System includes --- #include #include #include using std::ceil; using std::sqrt; // --- project includes --- #include "sphere_fitting/Sphere2DFitter.h" InsertGenerator2D::InsertGenerator2D() {} /*! Destructor */ InsertGenerator2D::~InsertGenerator2D() {} /*! Constructor \param rmin minimum particle radius \param rmax maximum particle radius \param ntries max. nr. of tries to insert particle \param max_iter maximum iterations within the iterative solvers \param prec max. error in iterative solvers */ InsertGenerator2D::InsertGenerator2D(double rmin,double rmax,int tries, int max_iter,double prec) { m_rmin=rmin; m_rmax=rmax; m_max_tries=tries; m_max_iter=max_iter; m_prec=prec; m_old_seeding=false; } /*! Constructor. Added random seed parameter \param rmin minimum particle radius \param rmax maximum particle radius \param ntries max. nr. of tries to insert particle \param max_iter maximum iterations within the iterative solvers \param prec max. error in iterative solvers \param seed if true, initialize random number generator via time */ InsertGenerator2D::InsertGenerator2D(double rmin,double rmax,int tries, int max_iter,double prec, bool seed) { if(seed){ struct timeval tv; gettimeofday(&tv,NULL); int random_seed=tv.tv_usec; srand(random_seed); } m_rmin=rmin; m_rmax=rmax; m_max_tries=tries; m_max_iter=max_iter; m_prec=prec; m_old_seeding=false; } /*! toggle between old (pre rev.84, ansiotropic) and new (rev 84 onwards) seeding behaviour \param old if true -> old behaviour, if false -> new behaviour */ void InsertGenerator2D::setOldSeeding(bool old) { m_old_seeding=old; } /*! generate packing \param vol a pointer to the volume in which the packing is generated \param ntable a pointer to the neighbour table used \param gid particle group id \param tag the particle tag */ void InsertGenerator2D::generatePacking (AVolume2D* vol,MNTable2D* ntable,int gid, int tag) { // use this-> to accomodate virtual seed/fill functions this->seedParticles(vol,ntable,gid,tag); this->fillIn(vol,ntable,gid,tag); } /*! seed the area with particles \param vol a pointer to the packing volume \param ntable a pointer to the neighbour table used \param gid particle group id \param tag the particle tag */ void InsertGenerator2D::seedParticles(AVolume2D* vol,MNTable2D* ntable,int gid, int tag) { // get bounding box pair bbx=vol->getBoundingBox(); double dx=(bbx.second.X()-bbx.first.X())-2.0*m_rmin; double dy=(bbx.second.Y()-bbx.first.Y())-2.0*m_rmin; // get index limits for seeding int imax=int(ceil(dx/(m_rmax*2.0))); int jmax=int(ceil(dy/(m_rmax*sqrt(3.0)))); // seed positions for(int i=0;im_rmin){ // calc random radius double r; double jitter; if(deisIn(S); bool fit_check=ntable->checkInsertable(S,gid); if(fit_in && fit_check){ S.setTag(tag); ntable->insertChecked(S,gid); } } } } } /*! Fill in particles \param vol a pointer to the packing volume \param ntable a pointer to the neighbour table used \param gid particle group id \param tag the particle tag */ void InsertGenerator2D::fillIn(AVolume2D* vol,MNTable2D* ntable,int gid, int tag) { Sphere nsph; int total_tries=0; int count_insert=0; int nvol=vol->getNumberSubVolumes(); for(int ivol=0;ivolgetAPoint(ivol); // get random point within volume multimap close_particles=ntable->getSpheresClosestTo(P,3); // get 3 nearest spheres map close_lines=vol->getClosestPlanes(P,2); // get 2 nearest planes map close_objects=vol->getClosestObjects(P,2); // get 2 nearest "objects" map geomap; geomap.insert(close_particles.begin(),close_particles.end()); geomap.insert(close_lines.begin(),close_lines.end()); geomap.insert(close_objects.begin(),close_objects.end()); if(geomap.size()>=3){ map::iterator iter=geomap.begin(); const AGeometricObject* GO1=iter->second;iter++; const AGeometricObject* GO2=iter->second;iter++; const AGeometricObject* GO3=iter->second; nsph=FitSphere2D(GO1,GO2,GO3,P,m_max_iter,m_prec); findfit=true; } if(findfit){ // check if within radius range bool is_radius=(m_rminnsph.Radius()); // check inside volume, intersections ... bool fit=vol->isIn(nsph) && ntable->checkInsertable(nsph,gid); if(fit && is_radius){ // acceptable particle nsph.setTag(tag); ntable->insertChecked(nsph,gid); // insert count_insert++; if((count_insert%100)==0) std::cout << "inserted: " << count_insert << std::endl; total_tries+=countfail; if(countfail>m_max_tries/10) std::cout << countfail << " tries" << std::endl; countfail=0; // reset failure counter } else countfail++; } else countfail++; } } std::cout << "total tries: " << total_tries << std::endl; } ostream& operator << (ostream& ost,const InsertGenerator2D& T) { return ost; } GenGeo-1.2/src/InsertGenerator2D.h0000644000000000000000000000303312533740504015111 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __INSERTGENERATOR2D_H #define __INSERTGENERATOR2D_H // --- Project includes --- #include "AGenerator2D.h" /*! \class InsertGenerator2D Packing generator using Place et al. insertion based algorithm. */ class InsertGenerator2D : public AGenerator2D { protected: double m_rmin; double m_rmax; double m_max_tries; int m_max_iter; double m_prec; bool m_old_seeding; virtual void seedParticles(AVolume2D* ,MNTable2D* ,int,int); public: InsertGenerator2D(); InsertGenerator2D(double,double,int,int,double); InsertGenerator2D(double,double,int,int,double,bool); virtual ~InsertGenerator2D(); void setOldSeeding(bool); virtual void fillIn(AVolume2D* ,MNTable2D* ,int,int); virtual void generatePacking (AVolume2D*,MNTable2D*,int,int); friend ostream& operator << (ostream&,const InsertGenerator2D&); }; #endif // __INSERTGENERATOR2D_H GenGeo-1.2/src/InsertGenerator3D.cc0000644000000000000000000004212112533740504015251 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "InsertGenerator3D.h" #include // --- System includes --- #include using std::ceil; using std::sqrt; // --- project includes --- #include "sphere_fitting/Sphere3DFitter.h" InsertGenerator3D::InsertGenerator3D() {} /*! Constructor \param rmin minimum particle radius \param rmax maximum particle radius \param ntries max. nr. of tries to insert particle \param max_iter maximum iterations within the iterative solvers \param prec max. error in iterative solvers */ InsertGenerator3D::InsertGenerator3D(double rmin,double rmax,int tries,int max_iter,double prec) { m_rmin=rmin; m_rmax=rmax; m_max_tries=tries; m_max_iter=max_iter; m_prec=prec; } /*! Constructor \param rmin minimum particle radius \param rmax maximum particle radius \param ntries max. nr. of tries to insert particle \param max_iter maximum iterations within the iterative solvers \param prec max. error in iterative solvers \param seed if true, initialize random number generator via time */ InsertGenerator3D::InsertGenerator3D(double rmin,double rmax,int tries,int max_iter,double prec, bool seed) { if (seed){ struct timeval tv; gettimeofday(&tv,NULL); int random_seed=tv.tv_usec; srand(random_seed); } m_rmin=rmin; m_rmax=rmax; m_max_tries=tries; m_max_iter=max_iter; m_prec=prec; m_next_tag=0; } /*! Destructor */ InsertGenerator3D::~InsertGenerator3D() {} /*! toggle between old (pre rev.84, ansiotropic) and new (rev 84 onwards) seeding behaviour \param old if true -> old behaviour, if false -> new behaviour */ void InsertGenerator3D::setOldSeeding(bool old) { m_old_seeding=old; } /*! Set tag for the next particles to be generated. Persists until changed. \param tag the tag */ void InsertGenerator3D::setNextTag(int tag) { m_next_tag=tag; } void InsertGenerator3D::generatePacking3 (AVolume3D* vol,MNTable3D* ntable,int gid) { int tag=-1; generatePacking4(vol,ntable,gid,tag); } void InsertGenerator3D::generatePacking4 (AVolume3D* vol,MNTable3D* ntable,int gid, int tag=-1) { ShapeList* list = (ShapeList*)0; generatePacking(vol,ntable,gid,tag,list); } /*! generate packing with at most a given total volume of the inserted particles \param vol a pointer to the volume in which the packing is generated \param ntable a pointer to the neighbour table used \param gid particle group id \param tag the tagid of particles to be inserted \param maxvol maximum cumulative volume of inserted particles (may not be reached) */ void InsertGenerator3D::generatePackingMaxVolume(AVolume3D* vol,MNTable3D* ntable,int gid, int tag, double maxvol) { this->seedParticles(vol,ntable,gid,tag); this->fillIn(vol,ntable,gid,tag,maxvol); } /*! generate packing \param vol a pointer to the volume in which the packing is generated \param ntable a pointer to the neighbour table used \param gid particle group id \param tag the tagid of particles to be inserted \param list the list of shapes to be inserted */ void InsertGenerator3D::generatePacking (AVolume3D* vol,MNTable3D* ntable,int gid, int tag=-1, ShapeList* list = (ShapeList*)0) { if(list == (ShapeList*)0) { if(tag==-1){ this->seedParticles(vol,ntable,gid,(int)m_next_tag); this->fillIn(vol,ntable,gid,(int)m_next_tag); } else { this->seedParticles(vol,ntable,gid,tag); this->fillIn(vol,ntable,gid,tag); } } else { if(tag==-1){ this->seedParticles(vol,ntable,gid,(int)m_next_tag,list); this->fillIn(vol,ntable,gid,(int)m_next_tag,list); } else { this->seedParticles(vol,ntable,gid,tag,list); this->fillIn(vol,ntable,gid,tag,list); } } } /*! seed the area with particles \param vol a pointer to the packing volume \param ntable a pointer to the neighbour table used \param gid particle group id \param tag the tag for the generated particles */ void InsertGenerator3D::seedParticles(AVolume3D* vol,MNTable3D* ntable,int gid, int tag) { // get bounding box std::cout << "InsertGenerator3D::seedParticles" << std::endl; pair bbx=vol->getBoundingBox(); std::cout << "bbx: " << bbx.first << " - " << bbx.second << std::endl; double dx=(bbx.second.X()-bbx.first.X()); double dy=(bbx.second.Y()-bbx.first.Y()); double dz=(bbx.second.Z()-bbx.first.Z()); // get index limits for seeding int imax=int(ceil(dx/(m_rmax*2.0))); int jmax=int(ceil(dy/(m_rmax*sqrt(3.0)))); int kmax=int(ceil(dz/(m_rmax*2.0*sqrt(2.0/3.0)))); // seed positions for(int i=0;i<=imax;i++){ for(int j=0;j<=jmax;j++){ for(int k=0;k<=kmax;k++){ // get position // double px=bbx.first.X()+(double(i)+0.5*double(j%2)-0.25)*m_rmax*2.0; // double py=bbx.first.Y()+(double(j)+(double(k%2)-0.5)/3.0)*sqrt(3.0)*m_rmax; // double pz=bbx.first.Z()+(double(k)*2.0*sqrt(2.0/3.0))*m_rmax; double px=bbx.first.X()+((double(i)+0.5*double(j%2)+0.5*double(k%2))*m_rmax*2.0)+m_rmax+1e-5; double py=bbx.first.Y()+((double(j)+double(k%2)/3.0)*sqrt(3.0)*m_rmax)+m_rmax+1e-5; double pz=bbx.first.Z()+((double(k)*2.0*sqrt(2.0/3.0))*m_rmax)+m_rmax+1e-5; // get dist to egde double dex=(bbx.second.X()-px) < (px-bbx.first.X()) ? bbx.second.X()-px : px-bbx.first.X(); double dey=(bbx.second.Y()-py) < (py-bbx.first.Y()) ? bbx.second.Y()-py : py-bbx.first.Y(); double dez=(bbx.second.Z()-pz) < (pz-bbx.first.Z()) ? bbx.second.Z()-pz : pz-bbx.first.Z(); double de=(dexm_rmin){ // calc random radius double r; double jitter; if(deisIn(S) && ntable->checkInsertable(S,gid); if(fit){ S.setTag(tag); ntable->insertChecked(S,gid); //std::cout << "inserted" << std::endl; } // else { // std::cout << "isIn " << vol->isIn(S) << " insertable: " << ntable->checkInsertable(S,gid) << std::endl; // } } } } } } /*! seed the area with particles \param vol a pointer to the packing volume \param ntable a pointer to the neighbour table used \param gid particle group id \param tag the tag for the generated particles */ void InsertGenerator3D::seedParticles(AVolume3D* vol,MNTable3D* ntable,int gid, int tag, ShapeList* sList) { // get bounding box std::cout << "InsertGenerator3D::seedParticles" << std::endl; pair bbx=vol->getBoundingBox(); std::cout << "bbx: " << bbx.first << " - " << bbx.second << std::endl; double dx=(bbx.second.X()-bbx.first.X()); double dy=(bbx.second.Y()-bbx.first.Y()); double dz=(bbx.second.Z()-bbx.first.Z()); // get index limits for seeding int imax=int(ceil(dx/(m_rmax*2.0))); int jmax=int(ceil(dy/(m_rmax*sqrt(3.0)))); int kmax=int(ceil(dz/(m_rmax*2.0*sqrt(2.0/3.0)))); // seed positions for(int i=0;i<=imax;i++){ for(int j=0;j<=jmax;j++){ for(int k=0;k<=kmax;k++){ // get position // double px=bbx.first.X()+(double(i)+0.5*double(j%2)-0.25)*m_rmax*2.0; // double py=bbx.first.Y()+(double(j)+(double(k%2)-0.5)/3.0)*sqrt(3.0)*m_rmax; // double pz=bbx.first.Z()+(double(k)*2.0*sqrt(2.0/3.0))*m_rmax; double px=bbx.first.X()+((double(i)+0.5*double(j%2)+0.5*double(k%2))*m_rmax*2.0)+m_rmax+1e-5; double py=bbx.first.Y()+((double(j)+double(k%2)/3.0)*sqrt(3.0)*m_rmax)+m_rmax+1e-5; double pz=bbx.first.Z()+((double(k)*2.0*sqrt(2.0/3.0))*m_rmax)+m_rmax+1e-5; // get dist to egde double dex=(bbx.second.X()-px) < (px-bbx.first.X()) ? bbx.second.X()-px : px-bbx.first.X(); double dey=(bbx.second.Y()-py) < (py-bbx.first.Y()) ? bbx.second.Y()-py : py-bbx.first.Y(); double dez=(bbx.second.Z()-pz) < (pz-bbx.first.Z()) ? bbx.second.Z()-pz : pz-bbx.first.Z(); double de=(dexm_rmin){ // calc random radius double r; if(deisIn(S) && ntable->checkInsertable(S,gid); if(fit){ // A sphere fits, so insert a "shape" //S.setTag(tag); sList->insertShape(Vector3(px,py,pz),r,ntable,tag,gid); //ntable->insertChecked(S,gid); //std::cout << "inserted" << std::endl; } // else { // std::cout << "isIn " << vol->isIn(S) << " insertable: " << ntable->checkInsertable(S,gid) << std::endl; // } } } } } } /*! Fill in particles \param vol a pointer to the packing volume \param ntable a pointer to the neighbour table used \param gid particle group id */ void InsertGenerator3D::fillIn(AVolume3D* vol,MNTable3D* ntable,int gid, int tag) { Sphere nsph; int total_tries=0; int count_insert=0; int nvol=vol->getNumberSubVolumes(); // for(int ivol=0;ivolgetAPoint(0); // get random point within volume multimap close_particles=ntable->getSpheresClosestTo(P,4); // get 3 nearest spheres map close_lines=vol->getClosestObjects(P,4); // get 2 nearest planes map geomap; geomap.insert(close_particles.begin(),close_particles.end()); geomap.insert(close_lines.begin(),close_lines.end()); if(geomap.size()>=4){ map::iterator iter=geomap.begin(); const AGeometricObject* GO1=iter->second;iter++; const AGeometricObject* GO2=iter->second;iter++; const AGeometricObject* GO3=iter->second;iter++; const AGeometricObject* GO4=iter->second; nsph=FitSphere3D(GO1,GO2,GO3,GO4,P,m_max_iter,m_prec); findfit=true; } if(findfit){ // check if within radius range bool is_radius=(m_rminnsph.Radius()); // check inside volume, intersections ... bool fit=vol->isIn(nsph); // && ntable->checkInsertable(nsph,gid); if(fit && is_radius){ // acceptable particle nsph.setTag(tag); if(ntable->insertChecked(nsph,gid)){; // insert count_insert++; total_tries+=countfail; last_fail_count+=countfail; if((count_insert%100)==0) { std::cout << "inserted " << count_insert << " at avg. " << double(last_fail_count)*0.01 << std::endl; last_fail_count=0; } countfail=0; // reset failure counter } else countfail++; } else { countfail++; } } else countfail++; } // } std::cout << "total tries: " << total_tries << std::endl; } /*! Fill in particles \param vol a pointer to the packing volume \param ntable a pointer to the neighbour table used \param gid particle group id \param tag the tag of the new particles \param maxvol maximum particle volume */ void InsertGenerator3D::fillIn(AVolume3D* vol,MNTable3D* ntable,int gid, int tag, double maxvol) { // get vol. of particles already in ntable double tvol=ntable->getSumVolume(gid); std::cout << "particle volume: " << tvol << std::endl; Sphere nsph; int total_tries=0; int count_insert=0; int nvol=vol->getNumberSubVolumes(); for(int ivol=0;ivolgetAPoint(ivol); // get random point within volume multimap close_particles=ntable->getSpheresClosestTo(P,4); // get 3 nearest spheres map close_lines=vol->getClosestObjects(P,3); // get 2 nearest planes map geomap; geomap.insert(close_particles.begin(),close_particles.end()); geomap.insert(close_lines.begin(),close_lines.end()); if(geomap.size()>=4){ map::iterator iter=geomap.begin(); const AGeometricObject* GO1=iter->second;iter++; const AGeometricObject* GO2=iter->second;iter++; const AGeometricObject* GO3=iter->second;iter++; const AGeometricObject* GO4=iter->second; nsph=FitSphere3D(GO1,GO2,GO3,GO4,P,m_max_iter,m_prec); findfit=true; } if(findfit){ // check if within radius range bool is_radius=(m_rminnsph.Radius()); // check inside volume, intersections ... bool fit=vol->isIn(nsph) && ntable->checkInsertable(nsph,gid); if(fit && is_radius){ // acceptable particle nsph.setTag(tag); ntable->insertChecked(nsph,gid); // insert count_insert++; double rad=nsph.Radius(); tvol+=(4.0/3.0)*3.1415926*rad*rad*rad; // V=4/3*pi*r^3 total_tries+=countfail; last_fail_count+=countfail; if((count_insert%100)==0) { std::cout << "inserted " << count_insert << " with volume " << tvol << " at avg. " << double(last_fail_count)*0.01 << std::endl; last_fail_count=0; } //if(countfail>m_max_tries/10) std::cout << countfail << " tries" << std::endl; countfail=0; // reset failure counter } else { countfail++; } } else countfail++; } } std::cout << "total tries: " << total_tries << std::endl; } /*! Fill in particles \param vol a pointer to the packing volume \param ntable a pointer to the neighbour table used \param gid particle group id */ void InsertGenerator3D::fillIn(AVolume3D* vol,MNTable3D* ntable,int gid, int tag, ShapeList *list) { Sphere nsph; int total_tries=0; int count_insert=0; int nvol=vol->getNumberSubVolumes(); for(int ivol=0;ivolgetAPoint(ivol); // get random point within volume multimap close_particles=ntable->getSpheresClosestTo(P,4); // get 3 nearest spheres map close_lines=vol->getClosestObjects(P,3); // get 2 nearest planes map geomap; geomap.insert(close_particles.begin(),close_particles.end()); geomap.insert(close_lines.begin(),close_lines.end()); if(geomap.size()>=4){ map::iterator iter=geomap.begin(); const AGeometricObject* GO1=iter->second;iter++; const AGeometricObject* GO2=iter->second;iter++; const AGeometricObject* GO3=iter->second;iter++; const AGeometricObject* GO4=iter->second; nsph=FitSphere3D(GO1,GO2,GO3,GO4,P,m_max_iter,m_prec); findfit=true; } if(findfit){ // check if within radius range bool is_radius=(m_rminnsph.Radius()); // check inside volume, intersections ... bool fit=vol->isIn(nsph) && ntable->checkInsertable(nsph,gid); if(fit && is_radius){ // acceptable particle nsph.setTag(tag); // ntable->insertChecked(nsph,gid); // insert list->insertShape(nsph.Center(),nsph.Radius(),ntable,tag,gid); count_insert++; total_tries+=countfail; last_fail_count+=countfail; if((count_insert%100)==0) { std::cout << "inserted " << count_insert << " at avg. " << double(last_fail_count)*0.01 << std::endl; last_fail_count=0; } //if(countfail>m_max_tries/10) std::cout << countfail << " tries" << std::endl; countfail=0; // reset failure counter } else { countfail++; } } else countfail++; } } std::cout << "total tries: " << total_tries << std::endl; } ostream& operator << (ostream& ost,const InsertGenerator3D& T) { return ost; } GenGeo-1.2/src/InsertGenerator3D.h0000644000000000000000000000376212533740504015123 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __INSERTGENERATOR3D_H #define __INSERTGENERATOR3D_H // --- Project includes --- #include "AGenerator3D.h" /*! \class InsertGenerator3D Packing generator using Place et al. insertion based algorithm in 3D. */ class InsertGenerator3D : public AGenerator3D { protected: double m_rmin; double m_rmax; double m_max_tries; int m_max_iter; double m_prec; double m_next_tag; bool m_old_seeding; virtual void seedParticles(AVolume3D* ,MNTable3D* ,int,int); virtual void seedParticles(AVolume3D* ,MNTable3D* ,int,int,ShapeList*); public: InsertGenerator3D(); InsertGenerator3D(double,double,int,int,double); InsertGenerator3D(double,double,int,int,double,bool); virtual ~InsertGenerator3D(); void setOldSeeding(bool); virtual void fillIn(AVolume3D* ,MNTable3D* ,int,int); virtual void fillIn(AVolume3D* ,MNTable3D* ,int,int,ShapeList*); virtual void fillIn(AVolume3D* ,MNTable3D* ,int,int,double); virtual void generatePacking3 (AVolume3D*,MNTable3D*,int); virtual void generatePacking4 (AVolume3D*,MNTable3D*,int,int); virtual void generatePackingMaxVolume(AVolume3D*,MNTable3D*,int,int,double); virtual void generatePacking (AVolume3D*,MNTable3D*,int,int,ShapeList*); void setNextTag(int); friend ostream& operator << (ostream&,const InsertGenerator3D&); }; #endif // __INSERTGENERATOR2D_H GenGeo-1.2/src/IntersectionVol.cc0000644000000000000000000001024012533740504015073 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "IntersectionVol.h" //--- #include #include using std::cos; using std::sin; // --- STL includes --- #include using std::make_pair; IntersectionVol::IntersectionVol() { std::cout << "WARNING: IntersectionVol is an experimental feature and may not always work as expected. For details see doc/CSG.readme" << std::endl; m_vol1 = NULL; m_vol2 = NULL; } IntersectionVol::IntersectionVol(AVolume3D& v1, AVolume3D& v2) { std::cout << "WARNING: IntersectionVol is an experimental feature and may not always work as expected. For details see doc/CSG.readme" << std::endl; m_vol1 = &v1; m_vol2 = &v2; // std::cout << m_vol1 << std::endl; // std::cout << m_vol2 << std::endl; } pair IntersectionVol::getBoundingBox() { // BoundingBox is the box containing both volumes pair bbx1=m_vol1->getBoundingBox(); // std::cout << "bbx1 = (" << bbx1.first.X() << " , " << bbx1.first.Y() << " , " << bbx1.first.Z() << ") ; (" << bbx1.second.X() << " , " << bbx1.second.Y() << " , " << bbx1.second.Z() << ")" << std::endl; pair bbx2=m_vol2->getBoundingBox(); // std::cout << "bbx2 = (" << bbx2.first.X() << " , " << bbx2.first.Y() << " , " << bbx2.first.Z() << ") ; (" << bbx2.second.X() << " , " << bbx2.second.Y() << " , " << bbx2.second.Z() << ")" << std::endl; double X0,X1; double Y0,Y1; double Z0,Z1; if (bbx1.first.X() < bbx2.first.X()) { X0 = bbx1.first.X(); } else { X0 = bbx2.first.X(); } if (bbx1.first.Y() < bbx2.first.Y()) { Y0 = bbx1.first.Y(); } else { Y0 = bbx2.first.Y(); } if (bbx1.first.Z() < bbx2.first.Z()) { Z0 = bbx1.first.Z(); } else { Z0 = bbx2.first.Z(); } Vector3 minPt = Vector3(X0,Y0,Z0); if (bbx1.second.X() > bbx2.second.X()) { X1 = bbx1.second.X(); } else { X1 = bbx2.second.X(); } if (bbx1.second.Y() > bbx2.second.Y()) { Y1 = bbx1.second.Y(); } else { Y1 = bbx2.second.Y(); } if (bbx1.second.Z() > bbx2.second.Z()) { Z1 = bbx1.second.Z(); } else { Z1 = bbx2.second.Z(); } Vector3 maxPt = Vector3(X1,Y1,Z1); // std::cout << "minPt = (" << X0 << " , " << Y0 << " , " << Z0 << ")" << std::endl; // std::cout << "maxPt = (" << X1 << " , " << Y1 << " , " << Z1 << ")" << std::endl; return make_pair(minPt,maxPt); } Vector3 IntersectionVol::getAPoint(int ivol) const { Vector3 aPoint; bool found = false; while (!(found)) { aPoint = m_vol1->getAPoint(ivol); found = m_vol2->isIn(aPoint); } return aPoint; } const map IntersectionVol::getClosestObjects(const Vector3& P,int ival) const { map res; map res2; res = m_vol1->getClosestObjects(P,ival); res2 = m_vol2->getClosestObjects(P,ival); res.insert(res2.begin(), res2.end()); return res; } bool IntersectionVol::isIn(const Vector3& P) const { bool res = false; if ((m_vol1->isIn(P)) && (m_vol2->isIn(P))) { res = true; } return res; } bool IntersectionVol::isIn(const Sphere& S) { bool res = false; if ((m_vol1->isIn(S)) && (m_vol2->isIn(S))) { res = true; } return res; } /*! Check if sphere is fully outside the volume. Tests if the sphere is outside one of the subvolumes. \param S the sphere */ bool IntersectionVol::isFullyOutside(const Sphere& S) { return m_vol1->isFullyOutside(S) || m_vol2->isFullyOutside(S); } ostream& operator << (ostream& ost,const IntersectionVol& T) { return ost; } GenGeo-1.2/src/IntersectionVol.h0000644000000000000000000000300512533740504014736 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __INTERSECT_VOLUME_SET_H #define __INTERSECT_VOLUME_SET_H // --- Project includes --- #include "AVolume3D.h" // --- STL includes --- #include using std::map; class IntersectionVol : public AVolume3D { protected: AVolume3D* m_vol1; AVolume3D* m_vol2; public: IntersectionVol (); IntersectionVol (AVolume3D& , AVolume3D&); virtual ~IntersectionVol (){}; virtual const map getClosestObjects(const Vector3&,int) const; virtual pair getBoundingBox(); virtual Vector3 getAPoint(int) const; virtual bool isIn(const Vector3&) const; virtual bool isIn(const Sphere&); virtual bool isFullyOutside(const Sphere&); virtual int getNumberSubVolumes()const{return 1;}; friend ostream& operator << (ostream&,const IntersectionVol&); }; #endif // __INTERSECT_VOLUME_SET_H GenGeo-1.2/src/JointSet.h0000644000000000000000000000176512533740504013361 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __JOINTSET_H #define __JOINTSET_H // project includes #include "util/vector3.h" /*! class to store joints (i.e. surface patches) and check if a bond crosses one of them */ class JointSet { public: virtual ~JointSet(){}; virtual int isCrossing(const Vector3&, const Vector3&) const=0; }; #endif // __JOINTSET_H GenGeo-1.2/src/MNTCell.cc0000644000000000000000000007345612533740504013224 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "MNTCell.h" // --- STL includes --- #include using std::make_pair; using std::endl; // --- System includes --- #include using std::fabs; int MNTCell::s_output_style=0; /*! construct MNTCell \param ngroups initial number of particle groups, can be extended later */ MNTCell::MNTCell(unsigned int ngroups) { m_data=vector >(ngroups); } /*! increase the number of groups. If the number of groups is already greater then the given number, do nothing. \param ngroups the new number of groups */ void MNTCell::SetNGroups(unsigned int ngroups) { if(ngroups>m_data.size()) m_data.resize(ngroups); } /*! insert sphere into cell \param S the sphere \param gid the group id \warning no check for validity of gid */ void MNTCell::insert(const Sphere& S, int gid) { m_data[gid].push_back(S); } int MNTCell::NParts() const { int np=0; for(vector >::const_iterator group_iter=m_data.begin(); group_iter!=m_data.end(); group_iter++){ np+=group_iter->size(); } return np; } /*! get all spheres within a given distance to a point, irrespective of group \param P the point \param d max. distance between the point and the surface of the sphere */ const multimap MNTCell::getSpheresNear(const Vector3& P,double d) const { multimap res; // for all groups for(vector >::const_iterator group_iter=m_data.begin(); group_iter!=m_data.end(); group_iter++){ // for all particles in the group for(vector::const_iterator iter=group_iter->begin(); iter!=group_iter->end(); iter++){ double dist=iter->getDist(P); if(dist<=d){ res.insert(make_pair(dist,&(*iter))); } } } return res; } /*! get all spheres from one group within a given distance to a point \param P the point \param d max. distance between the point and the surface of the sphere \param gid the group id \warning no check for validity of gid */ const multimap MNTCell::getSpheresFromGroupNear(const Vector3& P,double d,int gid) const { multimap res; for(vector::const_iterator iter=m_data[gid].begin(); iter!=m_data[gid].end(); iter++){ double dist=iter->getDist(P); if(dist<=d){ res.insert(make_pair(dist,&(*iter))); } } return res; } /*! get all spheres from one group within a given distance to a point \param P the point \param d max. distance between the point and the surface of the sphere \param gid the group id \warning no check for validity of gid */ multimap MNTCell::getSpheresFromGroupNearNC(const Vector3& P,double d,int gid) { multimap res; for(vector::iterator iter=m_data[gid].begin(); iter!=m_data[gid].end(); iter++){ double dist=iter->getDist(P); if(dist<=d){ res.insert(make_pair(dist,&(*iter))); } } return res; } /*! get the closest spheres to a given point \param p the point \param nmax the maximum number of spheres returned */ const multimap MNTCell::getSpheresClosestTo(const Vector3& p,unsigned int nmax) const { multimap pmap; double max_dist; // for all groups for(vector >::const_iterator group_iter=m_data.begin(); group_iter!=m_data.end(); group_iter++){ // for all particles in the group for(vector::const_iterator iter=group_iter->begin(); iter!=group_iter->end(); iter++){ double dist=iter->getDist(p); if(pmap.size() insert pmap.insert(make_pair(dist,&(*iter))); max_dist=(pmap.rbegin())->first; } else if(dist insert pmap.erase(max_dist); pmap.insert(make_pair(dist,&(*iter))); max_dist=(pmap.rbegin())->first; } } } return pmap; } /*! tag the closest spheres to a given point \param p the point \param dist max. distance to which particles are tagged \param gid the group Id \param tag the tag */ void MNTCell::tagSpheresNear(const Vector3& p,double dist,int gid, int tag) { for(vector::iterator iter=m_data[gid].begin(); iter!=m_data[gid].end(); iter++){ double d=(iter->getDist(p)); if(d<=dist){ iter->setTag(tag); } } } /*! tag the closest sphere to a given point \param p the point \param gid the group Id \param tag the tag */ void MNTCell::tagClosestParticle(const Vector3& p,int gid,int tag) { if(m_data[gid].size()>0){ vector::iterator closest=m_data[gid].begin(); double min_dist=(closest->getDist(p)); for(vector::iterator iter=m_data[gid].begin() ; iter!=m_data[gid].end(); iter++){ double d=(iter->getDist(p)); if(dsetTag(tag); } } /*! get the sphere within a given group closest to given sphere \param s the sphere \param gid the group \param maximum distance */ const Sphere* MNTCell::getClosestSphereFromGroup(const Sphere& s,int gid, double md) const { const Sphere* res=NULL; double d=md; for(vector::const_iterator iter=m_data[gid].begin(); iter!=m_data[gid].end(); iter++){ double dist=iter->getDist(s.Center())-s.Radius(); if(dist<=d){ res=&(*iter); d=dist; } } return res; } /*! Get the sphere within a given group closest to given sphere, using anisotropic weighted distance. \param s the sphere \param gid the group \param md distance */ const Sphere* MNTCell::getClosestSphereFromGroup(const Sphere& s,int gid, double md, double wx, double wy, double wz) const { const Sphere* res=NULL; double d=md; for(vector::const_iterator iter=m_data[gid].begin(); iter!=m_data[gid].end(); iter++){ double dist=(iter->Center()-s.Center()).wnorm2(wx,wy,wz); if(dist<=d){ res=&(*iter); d=dist; } } return res; } /*! get the sphere within a given group closest to given sphere \param s the sphere \param gid the group \param maximum distance */ Sphere* MNTCell::getClosestSphereFromGroup(const Vector3& p,int gid, double md) { Sphere* res=NULL; double d=md; for(vector::iterator iter=m_data[gid].begin(); iter!=m_data[gid].end(); iter++){ double dist=(iter->Center()-p).norm(); if(dist<=d){ res=&(*iter); d=dist; } } return res; } /* tag all particles within a group \param gid the group Id \param tag the tag \param mask the tag mask (i.e. new_tag = new_tag=(old_tag & (~mask)) | (tag & mask)) */ void MNTCell::tagSpheresInGroup(int gid,int tag,int mask) { for(vector::iterator iter=m_data[gid].begin(); iter!=m_data[gid].end(); iter++){ int old_tag=iter->Tag(); int new_tag = (old_tag & (~mask)) | (tag & mask); iter->setTag(new_tag); } } /*! get all spheres from a group \param gid the goup Id */ const vector MNTCell::getAllSpheresFromGroup(int gid) const { vector res; for(vector::const_iterator iter=m_data[gid].begin(); iter!=m_data[gid].end(); iter++){ res.push_back(&(*iter)); } return res; } /*! get all spheres from a group \param gid the goup Id */ vector MNTCell::getAllSpheresFromGroupNC(int gid) { vector res; for(vector::iterator iter=m_data[gid].begin(); iter!=m_data[gid].end(); iter++){ res.push_back(&(*iter)); } return res; } /*! get particles close to geometric object \param G the geometric object \param dist the maximum distance \param gid the group Id */ const vector MNTCell::getSpheresNearObject(const AGeometricObject* G,double dist,unsigned int gid) { vector res; for(vector::iterator iter=m_data[gid].begin(); iter!=m_data[gid].end(); iter++){ double d=G->getDist(iter->Center())-iter->Radius(); if(d<=dist){ res.push_back(&(*iter)); } } return res; } /*! get particles inside a volume \param V the volume \param gid the group Id */ const vector MNTCell::getSpheresInVolume(const AVolume* V,unsigned int gid) { vector res; for(vector::iterator iter=m_data[gid].begin(); iter!=m_data[gid].end(); iter++){ bool isin=V->isIn(iter->Center()); if(isin){ res.push_back(&(*iter)); } } return res; } /*! get the sum of the area/volume of all particles in a group, assuming 2D \param gid the group id */ double MNTCell::getSumVolume2D(unsigned int gid) { double res=0.0; // check if gid is valid if(gid::const_iterator iter=m_data[gid].begin(); iter!=m_data[gid].end(); iter++){ double rad=iter->Radius(); res+=3.1415926*rad*rad; // A=pi*r^2 } } return res; } /*! get the number of particles in a group \param gid the group id */ int MNTCell::getNrParticles(int gid) { return m_data[gid].size(); } /*! remove particle with given id \param id the particle id \param gid the group Id */ void MNTCell::remove(int id, int gid) { } /*! remove particles inside a volume \param Vol the volume \param full remove particles fully inside volume or center inside */ void MNTCell::removeInVolume(const AVolume* Vol,int gid,bool full) { vector tmp; for(vector::iterator iter=m_data[gid].begin(); iter!=m_data[gid].end(); iter++){ if(!Vol->isIn(iter->Center())){ tmp.push_back(*iter); } } m_data[gid].swap(tmp); } /*! remove particles with a given tag \param tag the particle tag \param mask the tag mask \param gid the group Id */ void MNTCell::removeTagged(int gid,int tag, int mask) { vector tmp; for(vector::iterator iter=m_data[gid].begin(); iter!=m_data[gid].end(); iter++){ if((iter->Tag() & mask) != (tag & mask)){ tmp.push_back(*iter); } } m_data[gid]=tmp; } /*! change particle IDs so that they are continous \param id0 lowest ID to be used \return lowest free ID, i.e. highest used ID+1 */ int MNTCell::renumberParticlesContinuous(int id0) { int id=id0; for(vector >::iterator giter=m_data.begin(); giter!=m_data.end(); giter++){ for(vector::iterator iter=giter->begin(); iter!=giter->end(); iter++){ iter->setId(id); id++; } } return id; } /*! get the sum of the area/volume of all particles in a group, assuming 3D \param gid the group id */ double MNTCell::getSumVolume3D(unsigned int gid) { double res=0.0; // check if gid is valid if(gid::const_iterator iter=m_data[gid].begin(); iter!=m_data[gid].end(); iter++){ double rad=iter->Radius(); res+=(4.0/3.0)*3.1415926*rad*rad*rad; // V=4/3*pi*r^3 } } return res; } /*! get Ids of particles in cell */ vector MNTCell::getIdList() { vector res; for(vector >::const_iterator group_iter=m_data.begin(); group_iter!=m_data.end(); group_iter++){ // for all particles in the group for(vector::const_iterator iter=group_iter->begin(); iter!=group_iter->end(); iter++){ res.push_back(iter->Id()); } } return res; } /*! intra-cell bonds \param gid group ID \param tol max. difference between bond length and equilibrium dist. */ vector > MNTCell::getBonds(int gid,double tol) { vector > res; // check if gid is valid if(gid::const_iterator iter=m_data[gid].begin(); iter!=m_data[gid].end(); iter++){ for(vector::const_iterator iter2=iter; iter2!=m_data[gid].end(); iter2++){ if(iter!=iter2){ double d=(iter->Center()-iter2->Center()).norm(); // dist between centers double r0=iter->Radius()+iter2->Radius(); // sum of radii -> equilibrium distance if(fabs(d-r0)<(r0*tol)){ if(iter->Id()Id()){ res.push_back(make_pair(iter->Id(),iter2->Id())); } else { res.push_back(make_pair(iter2->Id(),iter->Id())); } } } } } } return res; } /*! intra-cell bonds between particles with the same (arbitrary) tag \param gid group ID \param tol max. difference between bond length and equilibrium dist. */ vector > MNTCell::getBondsSame(int gid,double tol) { vector > res; // check if gid is valid if(gid::const_iterator iter=m_data[gid].begin(); iter!=m_data[gid].end(); iter++){ for(vector::const_iterator iter2=iter; iter2!=m_data[gid].end(); iter2++){ if(iter!=iter2){ double d=(iter->Center()-iter2->Center()).norm(); // dist between centers double r0=iter->Radius()+iter2->Radius(); // sum of radii -> equilibrium distance if((fabs(d-r0)<(r0*tol)) && (iter->Tag()==iter2->Tag())){ if(iter->Id()Id()){ res.push_back(make_pair(iter->Id(),iter2->Id())); } else { res.push_back(make_pair(iter2->Id(),iter->Id())); } } } } } } return res; } /*! intra-cell bonds with positions \param gid group ID \param tol max. difference between bond length and equilibrium dist. */ vector MNTCell::getBondsWithPos(int gid,double tol) { vector res; // check if gid is valid if(gid::const_iterator iter=m_data[gid].begin(); iter!=m_data[gid].end(); iter++){ for(vector::const_iterator iter2=iter; iter2!=m_data[gid].end(); iter2++){ if(iter!=iter2){ double d=(iter->Center()-iter2->Center()).norm(); // dist between centers double r0=iter->Radius()+iter2->Radius(); // sum of radii -> equilibrium distance if(d-r0<(r0*tol)){ if(iter->Id()Id()){ BondWithPos bwp; bwp.first=iter->Id(); bwp.second=iter2->Id(); bwp.firstPos=iter->Center(); bwp.secondPos=iter2->Center(); res.push_back(bwp); } else { BondWithPos bwp; bwp.first=iter2->Id(); bwp.second=iter->Id(); bwp.firstPos=iter2->Center(); bwp.secondPos=iter->Center(); res.push_back(bwp); } } } } } } return res; } /*! intra-cell bonds between particles with the same (arbitrary) tag \param gid group ID \param tol max. difference between bond length and equilibrium dist. */ vector MNTCell::getBondsWithPos(int gid,double tol ,const MNTCell& C) { vector res; // check if gid is valid if(gid::const_iterator iter=m_data[gid].begin(); iter!=m_data[gid].end(); iter++){ for(vector::const_iterator iter2=C.m_data[gid].begin(); iter2!=C.m_data[gid].end(); iter2++){ double d=(iter->Center()-iter2->Center()).norm(); // dist between centers double r0=iter->Radius()+iter2->Radius(); // sum of radii -> equilibrium distance if(d-r0<(r0*tol)){ if(iter->Id()Id()){ BondWithPos bwp; bwp.first=iter->Id(); bwp.second=iter2->Id(); bwp.firstPos=iter->Center(); bwp.secondPos=iter2->Center(); res.push_back(bwp); } else { BondWithPos bwp; bwp.first=iter2->Id(); bwp.second=iter->Id(); bwp.firstPos=iter2->Center(); bwp.secondPos=iter->Center(); res.push_back(bwp); } } } } } return res; } /*! intra-cell bonds between particles with a different (arbitrary) tag \param gid group ID \param tol max. difference between bond length and equilibrium dist. */ vector > MNTCell::getBondsDiff(int gid,double tol) { vector > res; // check if gid is valid if(gid::const_iterator iter=m_data[gid].begin(); iter!=m_data[gid].end(); iter++){ for(vector::const_iterator iter2=iter; iter2!=m_data[gid].end(); iter2++){ if(iter!=iter2){ double d=(iter->Center()-iter2->Center()).norm(); // dist between centers double r0=iter->Radius()+iter2->Radius(); // sum of radii -> equilibrium distance if((fabs(d-r0)<(r0*tol)) && (iter->Tag()!=iter2->Tag())){ if(iter->Id()Id()){ res.push_back(make_pair(iter->Id(),iter2->Id())); } else { res.push_back(make_pair(iter2->Id(),iter->Id())); } } } } } } return res; } /*! intra-cell bonds between particles with 2 defined tags \param gid group ID \param tol max. difference between bond length and equilibrium dist. \param tag1 1st particle tag \param tag2 2nd particle tag */ vector > MNTCell::getBondsTagged(int gid,double tol, int tag1, int tag2) { vector > res; // check if gid is valid if(gid::const_iterator iter=m_data[gid].begin(); iter!=m_data[gid].end(); iter++){ for(vector::const_iterator iter2=iter; iter2!=m_data[gid].end(); iter2++){ if(iter!=iter2){ double d=(iter->Center()-iter2->Center()).norm(); // dist between centers double r0=iter->Radius()+iter2->Radius(); // sum of radii -> equilibrium distance if((fabs(d-r0)<(r0*tol)) && (((iter->Tag()==tag1) && (iter2->Tag()==tag2)) || ((iter->Tag()==tag2)&&(iter2->Tag()==tag1)))) { if(iter->Id()Id()){ res.push_back(make_pair(iter->Id(),iter2->Id())); } else { res.push_back(make_pair(iter2->Id(),iter->Id())); } } } } } } return res; } /*! intra-cell bonds between particles with the same, defined tag \param gid group ID \param tol max. difference between bond length and equilibrium dist. \param ptag the particle tag \param mask the mask for the particle tag */ vector > MNTCell::getBonds(int gid,double tol, int ptag, int mask) { vector > res; // check if gid is valid if(gid::const_iterator iter=m_data[gid].begin(); iter!=m_data[gid].end(); iter++){ for(vector::const_iterator iter2=iter; iter2!=m_data[gid].end(); iter2++){ if(iter!=iter2){ double d=(iter->Center()-iter2->Center()).norm(); // dist between centers double r0=iter->Radius()+iter2->Radius(); // sum of radii -> equilibrium distance if((fabs(d-r0)<(r0*tol)) && (iter->Tag()==ptag) && (iter2->Tag()==ptag)) { if(iter->Id()Id()){ res.push_back(make_pair(iter->Id(),iter2->Id())); } else { res.push_back(make_pair(iter2->Id(),iter->Id())); } } } } } } return res; } /*! inter-cell bonds \param gid group ID \param tol max. difference between bond length and equilibrium dist. \param C the other cell */ vector > MNTCell::getBonds(int gid,double tol,const MNTCell& C) { vector > res; // check if gid is valid if(gid::const_iterator iter=m_data[gid].begin(); iter!=m_data[gid].end(); iter++){ for(vector::const_iterator iter2=C.m_data[gid].begin(); iter2!=C.m_data[gid].end(); iter2++){ double d=(iter->Center()-iter2->Center()).norm(); // dist between centers double r0=iter->Radius()+iter2->Radius(); // sum of radii -> equilibrium distance if(fabs(d-r0)<(r0*tol)){ if(iter->Id()Id()){ res.push_back(make_pair(iter->Id(),iter2->Id())); } else { res.push_back(make_pair(iter2->Id(),iter->Id())); } } } } } return res; } /*! inter-cell bonds between particles with the same (arbitrary) tag \param gid group ID \param tol max. difference between bond length and equilibrium dist. \param C the other cell */ vector > MNTCell::getBondsSame(int gid,double tol,const MNTCell& C) { vector > res; // check if gid is valid if(gid::const_iterator iter=m_data[gid].begin(); iter!=m_data[gid].end(); iter++){ for(vector::const_iterator iter2=C.m_data[gid].begin(); iter2!=C.m_data[gid].end(); iter2++){ double d=(iter->Center()-iter2->Center()).norm(); // dist between centers double r0=iter->Radius()+iter2->Radius(); // sum of radii -> equilibrium distance if((fabs(d-r0)<(r0*tol)) && (iter->Tag()==iter2->Tag())){ if(iter->Id()Id()){ res.push_back(make_pair(iter->Id(),iter2->Id())); } else { res.push_back(make_pair(iter2->Id(),iter->Id())); } } } } } return res; } /*! inter-cell bonds between particles with a different (arbitrary) tag \param gid group ID \param tol max. difference between bond length and equilibrium dist. \param C the other cell */ vector > MNTCell::getBondsDiff(int gid,double tol,const MNTCell& C) { vector > res; // check if gid is valid if(gid::const_iterator iter=m_data[gid].begin(); iter!=m_data[gid].end(); iter++){ for(vector::const_iterator iter2=C.m_data[gid].begin(); iter2!=C.m_data[gid].end(); iter2++){ double d=(iter->Center()-iter2->Center()).norm(); // dist between centers double r0=iter->Radius()+iter2->Radius(); // sum of radii -> equilibrium distance if((fabs(d-r0)<(r0*tol)) && (iter->Tag()!=iter2->Tag())){ if(iter->Id()Id()){ res.push_back(make_pair(iter->Id(),iter2->Id())); } else { res.push_back(make_pair(iter2->Id(),iter->Id())); } } } } } return res; } /*! inter-cell bonds between particles with the same, defined tag \param gid group ID \param tol max. difference between bond length and equilibrium dist. \param C the other cell \param ptag the particle tag \param mask the mask for the particle tag */ vector > MNTCell::getBonds(int gid,double tol,const MNTCell& C, int ptag, int mask) { vector > res; // check if gid is valid if(gid::const_iterator iter=m_data[gid].begin(); iter!=m_data[gid].end(); iter++){ for(vector::const_iterator iter2=C.m_data[gid].begin(); iter2!=C.m_data[gid].end(); iter2++){ double d=(iter->Center()-iter2->Center()).norm(); // dist between centers double r0=iter->Radius()+iter2->Radius(); // sum of radii -> equilibrium distance if((fabs(d-r0)<(r0*tol)) && (iter->Tag()==ptag) && (iter2->Tag()==ptag)) { if(iter->Id()Id()){ res.push_back(make_pair(iter->Id(),iter2->Id())); } else { res.push_back(make_pair(iter2->Id(),iter->Id())); } } } } } return res; } /*! inter-cell bonds between particles with 2 defined tags \param gid group ID \param tol max. difference between bond length and equilibrium dist. \param C the other cell \param tag1 1st particle tag \param tag2 2nd particle tag */ vector > MNTCell::getBondsTagged(int gid,double tol,const MNTCell& C, int tag1, int tag2) { vector > res; // check if gid is valid if(gid::const_iterator iter=m_data[gid].begin(); iter!=m_data[gid].end(); iter++){ for(vector::const_iterator iter2=C.m_data[gid].begin(); iter2!=C.m_data[gid].end(); iter2++){ double d=(iter->Center()-iter2->Center()).norm(); // dist between centers double r0=iter->Radius()+iter2->Radius(); // sum of radii -> equilibrium distance if((fabs(d-r0)<(r0*tol)) && (((iter->Tag()==tag1) && (iter2->Tag()==tag2)) || ((iter->Tag()==tag2)&&(iter2->Tag()==tag1)))) { if(iter->Id()Id()){ res.push_back(make_pair(iter->Id(),iter2->Id())); } else { res.push_back(make_pair(iter2->Id(),iter->Id())); } } } } } return res; } /*! intra-cell bonds between particles with 2 defined tags \param gid group ID \param tol max. difference between bond length and equilibrium dist. \param tag1 1st particle tag \param tag2 2nd particle tag */ vector > MNTCell::getBondsTaggedMasked(int gid,double tol ,int tag1 ,int mask1,int tag2 ,int mask2) { vector > res; // check if gid is valid if(gid::const_iterator iter=m_data[gid].begin(); iter!=m_data[gid].end(); iter++){ for(vector::const_iterator iter2=iter; iter2!=m_data[gid].end(); iter2++){ if(iter!=iter2){ double d=(iter->Center()-iter2->Center()).norm(); // dist between centers double r0=iter->Radius()+iter2->Radius(); // sum of radii -> equilibrium distance if((fabs(d-r0)<(r0*tol)) && ((((iter->Tag() & mask1)== (tag1 & mask1)) && ((iter2->Tag() & mask2) == (tag2 & mask2))) || (((iter->Tag() & mask2)== (tag2 & mask2)) && ((iter2->Tag() & mask1) == (tag1 & mask1))))) { if(iter->Id()Id()){ res.push_back(make_pair(iter->Id(),iter2->Id())); } else { res.push_back(make_pair(iter2->Id(),iter->Id())); } } } } } } return res; } /*! inter-cell bonds between particles with 2 defined tags \param gid group ID \param tol max. difference between bond length and equilibrium dist. \param C the other cell \param tag1 1st particle tag \param tag2 2nd particle tag */ vector > MNTCell::getBondsTaggedMasked(int gid,double tol,const MNTCell& C,int tag1,int mask1,int tag2,int mask2) { vector > res; // check if gid is valid if(gid::const_iterator iter=m_data[gid].begin(); iter!=m_data[gid].end(); iter++){ for(vector::const_iterator iter2=C.m_data[gid].begin(); iter2!=C.m_data[gid].end(); iter2++){ double d=(iter->Center()-iter2->Center()).norm(); // dist between centers double r0=iter->Radius()+iter2->Radius(); // sum of radii -> equilibrium distance if((fabs(d-r0)<(r0*tol)) && ((((iter->Tag() & mask1)== (tag1 & mask1)) && ((iter2->Tag() & mask2) == (tag2 & mask2))) || (((iter->Tag() & mask2)== (tag2 & mask2)) && ((iter2->Tag() & mask1) == (tag1 & mask1))))) { if(iter->Id()Id()){ res.push_back(make_pair(iter->Id(),iter2->Id())); } else { res.push_back(make_pair(iter2->Id(),iter->Id())); } } } } } return res; } /*! Set output style \param style the output style: 0 = debug, 1 = .geo */ void MNTCell::SetOutputStyle(int style) { MNTCell::s_output_style=style; } ostream& operator << (ostream& ost ,const MNTCell& C) { if(MNTCell::s_output_style==0){ Sphere::SetOutputStyle(0); int gcount=0; // for all groups for(vector >::const_iterator group_iter=C.m_data.begin(); group_iter!=C.m_data.end(); group_iter++){ ost << "-- Group " << gcount << " -- " << endl; gcount++; // for all particles in the group for(vector::const_iterator iter=group_iter->begin(); iter!=group_iter->end(); iter++){ ost << " [ " << *iter << " ] "; } ost << endl; } } else if(MNTCell::s_output_style==1){ Sphere::SetOutputStyle(1); // for all groups for(vector >::const_iterator group_iter=C.m_data.begin(); group_iter!=C.m_data.end(); group_iter++){ // for all particles in the group for(vector::const_iterator iter=group_iter->begin(); iter!=group_iter->end(); iter++){ ost << *iter << endl; } } } return ost; } void MNTCell::writePositions(ostream& ost) { for(vector >::const_iterator group_iter=m_data.begin(); group_iter!=m_data.end(); group_iter++){ // for all particles in the group for(vector::const_iterator iter=group_iter->begin(); iter!=group_iter->end(); iter++){ ost << iter->Center() << " "; } } } void MNTCell::writeRadii(ostream& ost) { for(vector >::const_iterator group_iter=m_data.begin(); group_iter!=m_data.end(); group_iter++){ // for all particles in the group for(vector::const_iterator iter=group_iter->begin(); iter!=group_iter->end(); iter++){ ost << iter->Radius() << " "; } } } void MNTCell::writeIDs(ostream& ost) { for(vector >::const_iterator group_iter=m_data.begin(); group_iter!=m_data.end(); group_iter++){ // for all particles in the group for(vector::const_iterator iter=group_iter->begin(); iter!=group_iter->end(); iter++){ ost << iter->Id() << " "; } } } void MNTCell::writeTags(ostream& ost) { for(vector >::const_iterator group_iter=m_data.begin(); group_iter!=m_data.end(); group_iter++){ // for all particles in the group for(vector::const_iterator iter=group_iter->begin(); iter!=group_iter->end(); iter++){ ost << iter->Tag() << " "; } } } unsigned int MNTCell::writeParticlesInBlock(ostream& ost, const Vector3& min_pt, const Vector3& max_pt) { Sphere::SetOutputStyle(1); unsigned int count=0; // for all groups for(vector >::const_iterator group_iter=m_data.begin(); group_iter!=m_data.end(); group_iter++){ // for all particles in the group for(vector::const_iterator iter=group_iter->begin(); iter!=group_iter->end(); iter++){ Vector3 pos=iter->Center(); if((pos.X()>=min_pt.x()) && (pos.X()=min_pt.y()) && (pos.Y()=min_pt.z()) && (pos.Z() #include #include using std::vector; using std::map; using std::multimap; using std::pair; // --- IO includes --- #include using std::ostream; // --- Project includes --- #include "geometry/Sphere.h" #include "AVolume.h" struct BondWithPos { int first; int second; Vector3 firstPos; Vector3 secondPos; }; /*! \class MNTCell \brief class for a cell in a neighbor table (MNTable2D or MNTable3D) */ class MNTCell { private: vector > m_data; static int s_output_style; public: MNTCell(unsigned int ngroups=1); void SetNGroups(unsigned int); void insert(const Sphere&,int); int NParts() const; const multimap getSpheresNear(const Vector3&,double) const; const multimap getSpheresFromGroupNear(const Vector3&,double,int) const; multimap getSpheresFromGroupNearNC(const Vector3&,double,int); const multimap getSpheresClosestTo(const Vector3&,unsigned int) const; const Sphere* getClosestSphereFromGroup(const Sphere&,int,double) const; const Sphere* getClosestSphereFromGroup(const Sphere&,int,double,double,double,double) const; Sphere* getClosestSphereFromGroup(const Vector3&,int,double); const vector getAllSpheresFromGroup(int) const; vector getAllSpheresFromGroupNC(int); const vector getSpheresNearObject(const AGeometricObject*,double,unsigned int); const vector getSpheresInVolume(const AVolume*,unsigned int); vector getIdList(); void remove(int,int); void removeTagged(int,int,int); void removeInVolume(const AVolume*,int,bool); void tagSpheresNear(const Vector3&,double,int,int); void tagClosestParticle(const Vector3&,int,int); void tagSpheresInGroup(int,int,int); int renumberParticlesContinuous(int); // get bonds vector > getBonds(int,double); vector > getBonds(int,double,const MNTCell&); vector getBondsWithPos(int,double); vector getBondsWithPos(int,double,const MNTCell&); vector > getBonds(int,double,int,int); vector > getBonds(int,double,const MNTCell&,int,int); vector > getBondsSame(int,double); vector > getBondsSame(int,double,const MNTCell&); vector > getBondsDiff(int,double); vector > getBondsDiff(int,double,const MNTCell&); vector > getBondsTagged(int,double,int,int); vector > getBondsTagged(int,double,const MNTCell&,int,int); vector > getBondsTaggedMasked(int,double,int,int,int,int); vector > getBondsTaggedMasked(int,double,const MNTCell&,int,int,int,int); // output double getSumVolume2D(unsigned int); double getSumVolume3D(unsigned int); int getNrParticles(int); static void SetOutputStyle(int); friend ostream& operator << (ostream&,const MNTCell&); void writePositions(ostream&); void writeRadii(ostream&); void writeIDs(ostream&); void writeTags(ostream&); // for block writing unsigned int writeParticlesInBlock(ostream&, const Vector3&, const Vector3&); }; #endif // MNTCELL_H GenGeo-1.2/src/MNTCell3D.h0000644000000000000000000000323512533740504013241 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __MNTCELL3D_H #define __MNTCELL3D_H // --- STL includes --- #include #include using std::vector; using std::map; // --- IO includes --- #include using std::ostream; // --- Project includes --- #include /*! \class MNTCell3D \brief class for a cell in a 3D neighbor table (MNTable3D) */ class MNTCell3D { private: vector > m_data; static int s_output_style; public: MNTCell3D(unsigned int ngroups=1); void SetNGroups(unsigned int); void insert(const Sphere3D&,int); int NParts() const; vector getSpheresNear(const Vector3&,double); vector getSpheresFromGroupNear(const Vector3&,double,int); map getSpheresClosestTo(const Vector3&,unsigned int); // output double getSumVolume(unsigned int); static void SetOutputStyle(int); friend ostream& operator << (ostream&,const MNTCell2D&); void writePositions(ostream&); void writeRadii(ostream&); }; #endif // MNTCELL_H GenGeo-1.2/src/MNTable2D.cc0000644000000000000000000006737112533740504013435 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "MNTable2D.h" // --- STL includes --- #include using namespace std; using std::make_pair; // --- System includes --- #include #include #include #include using std::ceil; using std::endl; using std::rand; int MNTable2D::s_output_style=0; double MNTable2D::s_small_value=1e-7; MNTable2D::MNTable2D():m_write_prec(10) { } /*! construct MNTable2D \param MinPt minimum point (z component ignored) \param MaxPt maximum point (z component ignored) \param cd cell dimension \param ngroups initial number of particle groups */ MNTable2D::MNTable2D(const Vector3& MinPt,const Vector3& MaxPt,double cd,unsigned int ngroups) { m_celldim=cd; m_ngroups=ngroups; // get number of cells Vector3 req_size=MaxPt-MinPt; // requested size m_nx=int(ceil(req_size.X()/m_celldim))+2; m_ny=int(ceil(req_size.Y()/m_celldim))+2; // add padding m_x0=MinPt.x()-m_celldim; m_y0=MinPt.y()-m_celldim; // allocate cell array m_data=new MNTCell[m_nx*m_ny]; for(int i=0;im_ngroups){ m_ngroups=ngroups; for(int i=0;i0) && (ix0) && (iy close_spheres=getSpheresFromGroupNear(S.Center(),S.Radius()-s_small_value,gid); if(close_spheres.size()==0){ m_data[id].insert(S,gid); res=true; } else res=false; } else { res=false; } return res; } /*! get the closest spheres to a given point \param p the point \param nmax the maximum number of spheres returned */ const multimap MNTable2D::getSpheresClosestTo(const Vector3& p,unsigned int nmax) const { multimap res; for(int i=-1;i<=1;i++){ for(int j=-1;j<=1;j++){ Vector3 pos=p+Vector3(double(i)*m_celldim,double(j)*m_celldim,0.0); int idx=getIndex(pos); if(idx!=-1){ multimap smap=m_data[idx].getSpheresClosestTo(p,nmax); res.insert(smap.begin(),smap.end()); } } } return res; } /*! get all spheres from one group within a given distance to a point \param P the point \param d max. distance between the point and the surface of the sphere \param gid the group id \warning no check for validity of gid */ const multimap MNTable2D::getSpheresFromGroupNear(const Vector3& P,double d,int gid) const { multimap res; for(int i=-1;i<=1;i++){ for(int j=-1;j<=1;j++){ Vector3 np=P+Vector3(double(i)*m_celldim,double(j)*m_celldim,0.0); int idx=getIndex(np); if(idx!=-1){ multimap v=m_data[idx].getSpheresFromGroupNear(P,d,gid); res.insert(v.begin(),v.end()); } } } return res; } /*! get vector of pointers to all spheres of a group \param gid goup Id */ const vector MNTable2D::getAllSpheresFromGroup(int gid) const { vector res; for(int i=1;i cr=m_data[idx(i,j)].getAllSpheresFromGroup(gid); res.insert(res.end(),cr.begin(),cr.end()); } } return res; } /*! get the sphere within a given group closest to given sphere \param s the sphere \param gid the group */ const Sphere* MNTable2D::getClosestSphereFromGroup(const Sphere& s,int gid) const { const Sphere* res=NULL; int max_dim=m_nx>m_ny ? m_nx : m_ny; int found=max_dim; double dist=max_dim*m_celldim; // search within the same cell int idx=getIndex(s.Center()); const Sphere* v=m_data[idx].getClosestSphereFromGroup(s,gid,2.0*max_dim); if(v!=NULL){ double d=(v->Center()-s.Center()).norm()-s.Radius(); found=1; if(dCenter()-s.Center()).norm()-s.Radius(); found=range+1; if(dm_ny ? m_nx : m_ny; int found=max_dim; double dist=max_dim*m_celldim; // search within the same cell int idx=getIndex(p); Sphere* v=m_data[idx].getClosestSphereFromGroup(p,gid,2.0*max_dim); if(v!=NULL){ double d=(v->Center()-p).norm(); found=1; if(dCenter()-p).norm(); found=range+1; if(dTag(); }else{ res=-1; } return res; } /*! tag the spheres in a group A according to the tag of the closest spheres from a another group B \param gid1 the group Id A \param gid1 the group Id B */ void MNTable2D::tagParticlesToClosest(int gid1, int gid2) { for(int i=0;i v=m_data[idx(i,j)].getAllSpheresFromGroupNC(gid1); for(vector::iterator iter=v.begin(); iter!=v.end(); iter++){ int t=getTagOfClosestSphereFromGroup(*(*iter),gid2); (*iter)->setTag(t); } } } } /*! tag the closest spheres to a given point \param p the point \param dist max distance \param gid the group id \param tag the tag */ void MNTable2D::tagParticlesNear(const Vector3& p,double dist,int gid, int tag) { for(int i=-1;i<=1;i++){ for(int j=-1;j<=1;j++){ Vector3 np=p+Vector3(double(i)*m_celldim,double(j)*m_celldim,0.0); int idx=getIndex(np); if(idx!=-1){ m_data[idx].tagSpheresNear(p,dist,gid,tag); } } } } /*! tag all particles inside a specified volume \param V the volume \param tag the tag \param gid group Id */ void MNTable2D::tagParticlesInVolume(const AVolume& V,int tag,unsigned int gid) { for(int i=0;i vs=m_data[idx(i,j)].getSpheresInVolume(&V,gid); for(vector::iterator iter=vs.begin(); iter!=vs.end(); iter++){ (*iter)->setTag(tag); } } } } /*! tag the closest sphere to a given point \param p the point \param gid the group id \param tag the tag */ void MNTable2D::tagClosestParticle(const Vector3& p,int gid, int tag) { Sphere* sp=getClosestSphereFromGroup(p,gid); if(sp!=NULL){ sp->setTag(tag); } } /*! insert sphere if it doesn't collide with other spheres \param S the Sphere \param gid the group id */ bool MNTable2D::checkInsertable(const Sphere& S,unsigned int gid) { bool res; int id=getIndex(S.Center()); // std::cout << "center : " << S.Center() << " index : " << id << std::endl; if((id!=-1) && (gid close_spheres=getSpheresFromGroupNear(S.Center(),S.Radius()-s_small_value,gid); if(close_spheres.size()==0){ res=true; } else res=false; } else { res=false; } return res; } /* get the sum of the area/volume of all particles in a group \param gid the group id */ double MNTable2D::getSumVolume(int gid) { double res=0.0; for(int i=1;i > bonds; if((ii==0) && (jj==0) && (i!=0) && (j!=0)){ // intra-cell, not for boundary bonds=m_data[id].getBonds(gid,tol); } else if(id2>id){ // inter-cell bonds=m_data[id].getBonds(gid,tol,m_data[id2]); } for(vector >::iterator iter=bonds.begin(); iter!=bonds.end(); iter++){ if(m_bonds[btag].find(*iter)==m_bonds[btag].end()){ m_bonds[btag].insert(*iter); } } } } } } } /*! generate bonds between particles with identical particle tag of a group \param gid the group ID \param tol max. difference between bond length and equilibrium dist. \param btag bond tag \param ptag the particle tag \param mask the mask for the particle tag */ void MNTable2D::generateBondsWithMask(int gid,double tol,int btag, int ptag, int mask) { //std::cout << "MNTable2D::generateBonds( " << gid << " , " << tol << " , " << btag << // " " << ptag <<" " << mask<<" )" << std::endl; // loop over all cells // loop over all cells for(int i=0;i > bonds; if((ii==0) && (jj==0) && (i!=0) && (j!=0)){ // intra-cell, not for boundary bonds=m_data[id].getBonds(gid,tol,ptag,mask); } else if(id2>id){ // inter-cell bonds=m_data[id].getBonds(gid,tol,m_data[id2],ptag,mask); } for(vector >::iterator iter=bonds.begin(); iter!=bonds.end(); iter++){ m_bonds[btag].insert(*iter); } } } } } } /*! generate bonds between particles with given particle tag \param gid the group ID \param tol max. difference between bond length and equilibrium dist. \param btag bond tag \param ptag1 the 1st particle tag \param mask1 the mask for the 1st particle tag \param ptag2 the 2nd particle tag \param mask2 the mask for the 2nd particle tag */ void MNTable2D::generateBondsTaggedMasked(int gid,double tol,int btag,int ptag1,int mask1,int ptag2,int mask2) { for(int i=0;i > bonds; if((ii==0) && (jj==0) && (i!=0) && (j!=0)){ // intra-cell, not for boundary bonds=m_data[id].getBondsTaggedMasked(gid,tol,ptag1,mask1,ptag2,mask2); } else if(id2>id){ // inter-cell bonds=m_data[id].getBondsTaggedMasked(gid,tol,m_data[id2],ptag1,mask1,ptag2,mask2); } for(vector >::iterator iter=bonds.begin(); iter!=bonds.end(); iter++){ m_bonds[btag].insert(*iter); } } } } } } /*! generate bonds between particles with identical particle tag of a group with a given probablility (0..1) \param gid the group ID \param tol max. difference between bond length and equilibrium dist. \param prob probablility of bond generation \param btag bond tag \param ptag the particle tag \param mask the mask for the particle tag */ void MNTable2D::generateRandomBonds(int gid,double tol,double prob,int btag, int ptag, int mask) { //std::cout << "MNTable2D::generateBonds( " << gid << " , " << tol << " , " << btag << // " " << ptag <<" " << mask<<" )" << std::endl; // loop over all cells // loop over all cells for(int i=0;i > bonds; if((ii==0) && (jj==0) && (i!=0) && (j!=0)){ // intra-cell, not for boundary bonds=m_data[id].getBonds(gid,tol,ptag,mask); } else if(id2>id){ // inter-cell bonds=m_data[id].getBonds(gid,tol,m_data[id2],ptag,mask); } for(vector >::iterator iter=bonds.begin(); iter!=bonds.end(); iter++){ double rn=((double)(rand())/(double)(RAND_MAX)); if(rn > same_bonds; vector > diff_bonds; if((ii==0) && (jj==0) && (i!=0) && (j!=0)){ // intra-cell, not for boundary same_bonds=m_data[id].getBondsSame(gid,tol); diff_bonds=m_data[id].getBondsDiff(gid,tol); } else if(id2>id){ // inter-cell same_bonds=m_data[id].getBondsSame(gid,tol,m_data[id2]); diff_bonds=m_data[id].getBondsDiff(gid,tol,m_data[id2]); } // insert intra-cluster bonds for(vector >::iterator iter=same_bonds.begin(); iter!=same_bonds.end(); iter++){ if(m_bonds[btag1].find(*iter)==m_bonds[btag1].end()){ m_bonds[btag1].insert(*iter); } } // insert inter-cluster bonds for(vector >::iterator iter=diff_bonds.begin(); iter!=diff_bonds.end(); iter++){ if(m_bonds[btag2].find(*iter)==m_bonds[btag2].end()){ m_bonds[btag2].insert(*iter); } } } } } } } /*! insert bond between particles with given ID \param id1 id of 1st particle \param id2 id of 2nd particle \param btag bond tag */ void MNTable2D::insertBond(int id1,int id2,int btag) { if(id1 vs=m_data[idx(i,j)].getSpheresNearObject(&L,dist,gid); for(vector::iterator iter=vs.begin(); iter!=vs.end(); iter++){ (*iter)->setTag(tag); } } } } /*! tag all particles close to a line \param L the line \param dist max. distance \param tag the tag \param the tag mask \param gid group Id */ void MNTable2D::tagParticlesAlongLineWithMask(const Line2D& L,double dist,int tag,int mask,unsigned int gid) { for(int i=1;i vs=m_data[idx(i,j)].getSpheresNearObject(&L,dist,gid); for(vector::iterator iter=vs.begin(); iter!=vs.end(); iter++){ int oldtag=(*iter)->Tag(); int newtag=(tag & mask) | (oldtag & ~mask); (*iter)->setTag(newtag); } } } } /*! tag all particles close to a line segment \param L the line segment \param dist max. distance \param tag the tag \param mask the tag mask \param gid group Id */ void MNTable2D::tagParticlesAlongLineSegment(const LineSegment2D& L,double dist,int tag ,int mask, unsigned int gid) { for(int i=1;i vs=m_data[idx(i,j)].getSpheresNearObject(&L,dist,gid); for(vector::iterator iter=vs.begin(); iter!=vs.end(); iter++){ int oldtag=(*iter)->Tag(); int newtag=(tag & mask) | (oldtag & ~mask); (*iter)->setTag(newtag); } } } } /*! break bonds along a line segment \param L the line segment \param dist max. distance from the line \param tag the bond tag \param gid group Id */ void MNTable2D::breakBondsAlongLineSegment(const LineSegment2D& L,double dist,int tag, unsigned int gid) { // get particles near line set near_particle_set; for(int i=1;i vs=m_data[idx(i,j)].getSpheresNearObject(&L,dist,gid); for(vector::iterator iter=vs.begin(); iter!=vs.end(); iter++){ near_particle_set.insert((*iter)->Id()); } } } // for all bonds with tag set >::iterator iter=m_bonds[tag].begin(); while(iter!=m_bonds[tag].end()){ // check if both particles near line if(near_particle_set.find(iter->first)!=near_particle_set.end() && near_particle_set.find(iter->second)!=near_particle_set.end()){ // remove set >::iterator iter_t=iter; iter++; m_bonds[tag].erase(iter_t); } else { iter++; } } } /*! Set output style \param style the output style: 0 = debug, 1 = .geo */ void MNTable2D::SetOutputStyle(int style) { MNTable2D::s_output_style=style; } /*! Set output precision \param prec number of significant digits */ void MNTable2D::SetOutputPrecision(int prec) { m_write_prec=prec; } /*! Output the content of a MNTable2D to an ostream. The output format depends on the value of MNTable2D::s_output_style (see MNTable2D::SetOutputStyle). If it is set to 0, output suitable for debugging is generated, if it is set to 1 output in the esys .geo format is generated. If MNTable2D::s_output_style is set to 2, the output format is VTK-XML. \param ost the output stream \param T the table */ ostream& operator << (ostream& ost,const MNTable2D& T) { if(MNTable2D::s_output_style==0){ // debug style // don't print padding MNTCell::SetOutputStyle(0); for(int i=1;i > >::const_iterator iter=T.m_bonds.begin(); iter!=T.m_bonds.end(); iter++){ nbonds+=iter->second.size(); } ost << nbonds << endl; for(map > >::const_iterator iter=T.m_bonds.begin(); iter!=T.m_bonds.end(); iter++){ for(set >::const_iterator v_iter=iter->second.begin(); v_iter!=iter->second.end(); v_iter++){ ost << v_iter->first << " " << v_iter->second << " " << iter->first << endl; } } ost << "EndConnect" << endl; } else if (MNTable2D::s_output_style==2){ // vtk-xml T.WriteAsVtkXml(ost); } return ost; } /*! output content as VTK-XML format \param vtkfile the output stream */ void MNTable2D::WriteAsVtkXml(ostream& vtkfile) const { // inverse mapping index<->particle id map inv_map; int pcount=0; for(int i=1;i ids=m_data[idx(i,j)].getIdList(); for(vector::iterator iter=ids.begin(); iter!=ids.end(); iter++){ inv_map.insert(make_pair(*iter,pcount)); pcount++; } } } // get bond count int bcount=0; for(map > >::const_iterator iter=m_bonds.begin(); iter!=m_bonds.end(); iter++){ bcount+=iter->second.size(); } // write header vtkfile << "\n"; vtkfile << "\n"; int nparts=0; for(int i=1;i\n"; // write particle pos vtkfile << "\n"; vtkfile << "\n"; for(int i=1;i\n"; vtkfile << "\n"; // --- write particle data --- // radius vtkfile << "\n"; vtkfile << "\n"; for(int i=1;i\n"; // ID vtkfile << "\n"; for(int i=1;i\n"; // Tag vtkfile << "\n"; for(int i=1;i\n"; vtkfile << "\n"; // --- write cells section --- // connections vtkfile << "\n"; vtkfile << "\n"; for(map > >::const_iterator iter=m_bonds.begin(); iter!=m_bonds.end(); iter++){ for(set >::const_iterator iter_b=iter->second.begin(); iter_b!=iter->second.end(); iter_b++){ vtkfile << inv_map[iter_b->first] << " " << inv_map[iter_b->second] << endl; } } vtkfile << "\n"; // offsets vtkfile << "\n"; for (size_t i = 1; i < bcount*2; i+=2) vtkfile << i+1 << "\n"; vtkfile << "\n"; // element type vtkfile << "\n"; const int CELL_LINE_TYPE = 3; for (size_t i = 0; i < bcount; i++) vtkfile << CELL_LINE_TYPE << endl; vtkfile << "\n"; vtkfile << "\n"; // cell data vtkfile << "\n"; vtkfile << "\n"; for(map > >::const_iterator iter=m_bonds.begin(); iter!=m_bonds.end(); iter++){ for(set >::const_iterator iter_b=iter->second.begin(); iter_b!=iter->second.end(); iter_b++){ vtkfile << iter->first << endl; } } vtkfile << "\n"; vtkfile << "\n"; // write footer vtkfile << "\n"; vtkfile << "\n"; vtkfile << "\n"; } void MNTable2D::write(char *filename, int outputStyle) { ofstream outFile; // set output precision outFile.precision(m_write_prec); SetOutputStyle(outputStyle); outFile.open(filename); outFile << *(this); outFile.close(); } boost::python::list MNTable2D::getSphereListFromGroup(int gid) const { boost::python::list l; vector sphere_vector; sphere_vector = getAllSpheresFromGroup(gid); for (vector::iterator iter=sphere_vector.begin(); iter!= sphere_vector.end(); iter++) { l.append(*(*(iter))); } return l; } /*! return the bonds of a given tag as list of pairs \param btag the bond tag */ boost::python::list MNTable2D::getBondList(int btag) { boost::python::list l; for(set >::const_iterator iter=m_bonds[btag].begin(); iter!=m_bonds[btag].end(); iter++){ l.append(boost::python::make_tuple(iter->first,iter->second)); } return l; } GenGeo-1.2/src/MNTable2D.h0000644000000000000000000000751112533740504013265 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __MNTABLE_H #define __MNTABLE_H // --- STL includes --- #include #include #include #include using std::vector; using std::map; using std::multimap; using std::set; // --- IO includes --- #include using std::ostream; // --- Project includes --- #include "MNTCell.h" #include "geometry/Sphere.h" #include "geometry/Line2D.h" #include "geometry/LineSegment2D.h" /*! \class MNTable2D \brief Multi-group Neighbour table Neighbour table supporting multiple tagged groups of particles */ class MNTable2D { public: // types typedef pair bond; protected: MNTCell* m_data; map > > m_bonds; double m_x0,m_y0; //!< origin double m_celldim; //!< cell size int m_nx,m_ny; //!< number of cells in x- and y-direction unsigned int m_ngroups; static int s_output_style; static double s_small_value; int m_x_periodic; int m_y_periodic; int m_write_prec; //!< precision (nr. of significant digits) for file output virtual int getIndex(const Vector3&) const; inline int idx(int i,int j) const {return i*m_ny+j;}; void WriteAsVtkXml(ostream&) const; public: MNTable2D(); MNTable2D(const Vector3&,const Vector3&,double,unsigned int); virtual ~MNTable2D(); virtual bool insert(const Sphere&,unsigned int); virtual bool insertChecked(const Sphere&,unsigned int,double tol=s_small_value); virtual bool checkInsertable(const Sphere&,unsigned int); void GrowNGroups(unsigned int); const multimap getSpheresClosestTo(const Vector3&,unsigned int) const; const multimap getSpheresFromGroupNear(const Vector3&,double,int) const; const vector getAllSpheresFromGroup(int) const; const Sphere* getClosestSphereFromGroup(const Sphere&,int) const; Sphere* getClosestSphereFromGroup(const Vector3&,int) const; int getTagOfClosestSphereFromGroup(const Sphere&,int) const; void tagParticlesAlongLine(const Line2D&,double,int,unsigned int); void tagParticlesAlongLineWithMask(const Line2D&,double,int,int, unsigned int); void tagParticlesAlongLineSegment(const LineSegment2D&,double,int,int, unsigned int); void tagParticlesNear(const Vector3&,double,int,int); void tagClosestParticle(const Vector3&,int,int); void tagParticlesToClosest(int,int); void tagParticlesInVolume(const AVolume&,int,unsigned int); boost::python::list getSphereListFromGroup(int) const; boost::python::list getBondList(int); virtual void generateBonds(int,double,int); virtual void generateBondsWithMask(int,double,int,int,int); virtual void generateRandomBonds(int,double,double,int,int,int); virtual void generateClusterBonds(int,double,int,int); virtual void generateBondsTaggedMasked(int,double,int,int,int,int,int); void insertBond(int,int,int); void breakBondsAlongLineSegment(const LineSegment2D&,double,int, unsigned int); void removeTagged(int,int,int); // output double getSumVolume(int); int getNrParticles(int); friend ostream& operator << (ostream&,const MNTable2D&); static void SetOutputStyle(int); void SetOutputPrecision(int); void write(char *filename, int outputStyle); }; #endif // __MNTABLE_H GenGeo-1.2/src/MNTable3D.cc0000644000000000000000000011457712533740504013437 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "MNTable3D.h" // --- STL includes --- #include using namespace std; using std::make_pair; // --- System includes --- #include using std::floor; using std::endl; using std::ceil; // --- IO includes --- #include #include using std::ifstream; int MNTable3D::s_output_style=0; double MNTable3D::s_small_value=1e-7; MNTable3D::MNTable3D():m_write_prec(10) {} /*! construct MNTable3D \param MinPt minimum point (z component ignored) \param MaxPt maximum point (z component ignored) \param cd cell dimension \param ngroups initial number of particle groups */ MNTable3D::MNTable3D(const Vector3& MinPt,const Vector3& MaxPt,double cd,unsigned int ngroups) { m_celldim=cd; m_ngroups=ngroups; m_min_pt=MinPt; // get number of cells Vector3 req_size=MaxPt-MinPt; // requested size m_nx=int(ceil(req_size.X()/m_celldim))+2; m_ny=int(ceil(req_size.Y()/m_celldim))+2; m_nz=int(ceil(req_size.Z()/m_celldim))+2; std::cout << "nx,ny,nz: " << m_nx << " , " << m_ny << " , " << m_nz << std::endl; // add padding m_origin=MinPt-Vector3(m_celldim,m_celldim,m_celldim); m_max_pt=m_min_pt+Vector3(m_celldim*(m_nx-2),m_celldim*(m_ny-2),m_celldim*(m_nz-2)); // allocate cell array m_data=new MNTCell[m_nx*m_ny*m_nz]; for(int i=0;i> x >> y >> z >> r; bool can_insert=insertChecked(Sphere(Vector3(x*scale,y*scale,z*scale),r*scale),0,tol); if(!can_insert){ std::cout << "couldn't insert particle : " << Vector3(x*scale,y*scale,z*scale) << " r= " << r*scale << std::endl; } else { count++; } } std::cout << "inserted particle count:" << count << std::endl; infile.close(); return true; } /*! Increase the number of particle groups. Do nothing if the number is already large enough \param ngroups the new number of particle groups */ void MNTable3D::GrowNGroups(unsigned int ngroups) { if(ngroups>m_ngroups){ m_ngroups=ngroups; for(int i=0;i0) && (ix0) && (iy0) && (izgetIndex(S.Center()); if((id!=-1) && (gidgetIndex(S.Center()); tol+=s_small_value; if((id!=-1) && (gid close_spheres=getSpheresFromGroupNear(S.Center(),S.Radius()-tol,gid); if(close_spheres.size()==0){ m_data[id].insert(S,gid); res=true; if(m_bbx_tracking){ // if bounding box tracking is on, update bbx Vector3 pmin=S.Center()-Vector3(S.Radius(),S.Radius(),S.Radius()); Vector3 pmax=S.Center()+Vector3(S.Radius(),S.Radius(),S.Radius()); m_min_tbbx.X()=std::min(m_min_tbbx.X(),pmin.X()); m_min_tbbx.Y()=std::min(m_min_tbbx.Y(),pmin.Y()); m_min_tbbx.Z()=std::min(m_min_tbbx.Z(),pmin.Z()); m_max_tbbx.X()=std::max(m_max_tbbx.X(),pmax.X()); m_max_tbbx.Y()=std::max(m_max_tbbx.Y(),pmax.Y()); m_max_tbbx.Z()=std::max(m_max_tbbx.Z(),pmax.Z()); } } else res=false; } else { res=false; } return res; } /*! get the closest spheres to a given point \param p the point \param nmax the maximum number of spheres returned */ const multimap MNTable3D::getSpheresClosestTo(const Vector3& p,unsigned int nmax) const { multimap res; for(int i=-1;i<=1;i++){ for(int j=-1;j<=1;j++){ for(int k=-1;k<=1;k++){ Vector3 pos=p+Vector3(double(i)*m_celldim,double(j)*m_celldim,double(k)*m_celldim); int idx=this->getIndex(pos); if(idx!=-1){ multimap smap=m_data[idx].getSpheresClosestTo(p,nmax); res.insert(smap.begin(),smap.end()); } } } } return res; } /*! get all spheres from one group within a given distance to a point \param P the point \param d max. distance between the point and the surface of the sphere \param gid the group id \warning no check for validity of gid */ const multimap MNTable3D::getSpheresFromGroupNear(const Vector3& P,double d,int gid) const { multimap res; for(int i=-1;i<=1;i++){ for(int j=-1;j<=1;j++){ for(int k=-1;k<=1;k++){ Vector3 np=P+Vector3(double(i)*m_celldim,double(j)*m_celldim,double(k)*m_celldim); int idx=this->getIndex(np); if(idx!=-1){ multimap v=m_data[idx].getSpheresFromGroupNear(P,d,gid); res.insert(v.begin(),v.end()); } } } } return res; } /*! get the sphere within a given group closest to given sphere \param s the sphere \param gid the group */ const Sphere* MNTable3D::getClosestSphereFromGroup(const Sphere& s,int gid) const { const Sphere* res=NULL; int max_dim=m_nx>m_ny ? m_nx : m_ny; max_dim=m_nz>max_dim ? m_nz : max_dim; int found=max_dim; double dist=max_dim*m_celldim; // search within the same cell int idx=getIndex(s.Center()); const Sphere* v=m_data[idx].getClosestSphereFromGroup(s,gid,2.0*max_dim); if(v!=NULL){ double d=(v->Center()-s.Center()).norm()-s.Radius(); found=1; if(dCenter()-s.Center()).norm()-s.Radius(); found=range+1; if(dTag(); }else{ res=-1; } return res; } /*! Get the sphere within a given group closest to given sphere, using anisotropic weighted distance. \param s the sphere \param gid the group \param wx weighting of the x-component of the distance \param wy weighting of the y-component of the distance \param wz weighting of the z-component of the distance */ const Sphere* MNTable3D::getClosestSphereFromGroup(const Sphere& s,int gid,double wx, double wy, double wz) const { const Sphere* res=NULL; int max_dim=m_nx>m_ny ? m_nx : m_ny; max_dim=m_nz>max_dim ? m_nz : max_dim; int found=max_dim; double dist=max_dim*m_celldim; // search within the same cell int idx=getIndex(s.Center()); const Sphere* v=m_data[idx].getClosestSphereFromGroup(s,gid,2.0*max_dim,wx,wy,wz); if(v!=NULL){ double d=(v->Center()-s.Center()).wnorm2(wx,wy,wz); found=1; if(dCenter()-s.Center()).wnorm2(wx,wy,wz); if(d need to limit search range found=range+1; } } } } } } range++; } return res; } /*! Convenience function which calls getClosestSphereFromGroup, using anisotropic weighted distance and returns the tag of the found sphere or -1 if none is found. \param s the sphere \param gid the group \param wx weighting of the x-component of the distance \param wy weighting of the y-component of the distance \param wz weighting of the z-component of the distance */ int MNTable3D::getTagOfClosestSphereFromGroup(const Sphere& s,int gid, double wx, double wy, double wz) const { int res; const Sphere* sp=getClosestSphereFromGroup(s,gid,wx,wy,wz); if(sp!=NULL){ res=sp->Tag(); }else{ res=-1; } return res; } /*! check if sphere is insertable \param S the Sphere \param gid the group id */ bool MNTable3D::checkInsertable(const Sphere& S,unsigned int gid) { bool res; int id=this->getIndex(S.Center()); if((id!=-1) && (gid close_spheres=getSpheresFromGroupNear(S.Center(),S.Radius()-s_small_value,gid); if(close_spheres.size()==0){ res=true; } else { res=false; // for(map::const_iterator iter=close_spheres.begin(); // iter!=close_spheres.end(); // iter++){ // std::cout << iter->first << " | " << *(iter->second) << std::endl; // } } } else { res=false; } return res; } /* get the sum of the area/volume of all particles in a group \param gid the group id */ double MNTable3D::getSumVolume(int gid) { double res=0.0; for(int i=1;i > bonds; if(((ii+jj+kk)==0)){ // intra-cell, not for boundary bonds=m_data[id].getBonds(gid,tol); } else if(id2>id){ // inter-cell bonds=m_data[id].getBonds(gid,tol,m_data[id2]); } for(vector >::iterator iter=bonds.begin(); iter!=bonds.end(); iter++){ m_bonds[btag].insert(*iter); } } } } } } } } /*! generate bonds between particles with given tags of a group \param gid the group ID \param tol max. difference between bond length and equilibrium dist. \param btag bond tag \param tag1 \param tag2 */ void MNTable3D::generateBondsTagged(int gid,double tol,int btag,int tag1,int tag2) { std::cout << "MNTable3D::generateBondsTagged( " << gid << " , " << tol << " , " << btag << " , " << tag1 << " , " << tag2 << " )" << std::endl; // loop over all cells for(int i=1;i > bonds; if(((ii+jj+kk)==0)){ // intra-cell, not for boundary bonds=m_data[id].getBondsTagged(gid,tol,tag1,tag2); } else if(id2>id){ // inter-cell bonds=m_data[id].getBondsTagged(gid,tol,m_data[id2],tag1,tag2); } for(vector >::iterator iter=bonds.begin(); iter!=bonds.end(); iter++){ m_bonds[btag].insert(*iter); } } } } } } } } /*! generate bonds between particles with identical particle tag of a group with a given probablility (0..1) \param gid the group ID \param tol max. difference between bond length and equilibrium dist. \param prob probablility of bond generation \param btag bond tag \param ptag particle tag \param mask */ void MNTable3D::generateRandomBonds(int gid,double tol, double prob, int btag,int ptag,int mask) { std::cout << "MNTable3D::generateRandomBonds( " << gid << " , " << tol << " , " << prob << " , " << btag << " , " << ptag << " , " << mask << " )" << std::endl; // loop over all cells for(int i=1;i > bonds; if((id==id2) && (i!=0) && (j!=0)&& (k!=0) ){ // intra-cell, not for boundary bonds=m_data[id].getBonds(gid,tol,ptag,mask); } else if(id2>id){ // inter-cell bonds=m_data[id].getBonds(gid,tol,m_data[id2],ptag,mask); } for(vector >::iterator iter=bonds.begin(); iter!=bonds.end(); iter++){ double rn=((double)(rand())/(double)(RAND_MAX)); if(rn > same_bonds; vector > diff_bonds; if((id==id2) && (i!=0) && (j!=0) && (k!=0)){ // intra-cell, not for boundary same_bonds=m_data[id].getBondsSame(gid,tol); diff_bonds=m_data[id].getBondsDiff(gid,tol); } else if(id2>id){ // inter-cell same_bonds=m_data[id].getBondsSame(gid,tol,m_data[id2]); diff_bonds=m_data[id].getBondsDiff(gid,tol,m_data[id2]); } // insert intra-cluster bonds for(vector >::iterator iter=same_bonds.begin(); iter!=same_bonds.end(); iter++){ if(m_bonds[btag1].find(*iter)==m_bonds[btag1].end()){ m_bonds[btag1].insert(*iter); } } // insert inter-cluster bonds for(vector >::iterator iter=diff_bonds.begin(); iter!=diff_bonds.end(); iter++){ if(m_bonds[btag2].find(*iter)==m_bonds[btag2].end()){ m_bonds[btag2].insert(*iter); } } } } } } } } } /*! generate bonds taking a list of joint surfaces into account, i.e. bonds which cross one of the surface get tagged differently (according to the tag of the joint) \param Joints the set of joint surfaces \param gid the particle group id \param tol the bond generation tolerance, i.e. bonds up to length (equilibrium length*tol) get generated \param tag the tag for the bonds not crossing any surface */ void MNTable3D::generateBondsWithJointSet(const TriPatchSet& Joints,int gid,double tol,int tag) { std::cout << "MNTable3D::generateBondsWithJointSet( " << tag << " )" << std::endl; // loop over all cells for(int i=1;i bonds; if(((ii+jj+kk)==0)){ // intra-cell, not for boundary bonds=m_data[id].getBondsWithPos(gid,tol); } else if(id2>id){ // inter-cell bonds=m_data[id].getBondsWithPos(gid,tol,m_data[id2]); } for(vector::iterator iter=bonds.begin(); iter!=bonds.end(); iter++){ // check if bond crosses surface int jtag=Joints.isCrossing(iter->firstPos,iter->secondPos) ; if(jtag==-1){ m_bonds[tag].insert(make_pair(iter->first,iter->second)); } else { m_bonds[jtag].insert(make_pair(iter->first,iter->second)); } } } } } } } } } /*! insert bond between particles with given ID \param id1 id of 1st particle \param id2 id of 2nd particle \param btag bond tag */ void MNTable3D::insertBond(int id1,int id2,int btag) { if(id1 > >::const_iterator iter=T.m_bonds.begin(); * iter!=T.m_bonds.end(); * iter++){ * iter->clear(); * } */ m_bonds.clear(); } /*! get vector of pointers to all spheres of a group \param gid goup Id */ const vector MNTable3D::getAllSpheresFromGroup(int gid) const { vector res; for(int i=1;i cr=m_data[idx(i,j,k)].getAllSpheresFromGroup(gid); res.insert(res.end(),cr.begin(),cr.end()); } } } return res; } boost::python::list MNTable3D::getSphereListFromGroup(int gid) const { boost::python::list l; vector sphere_vector; sphere_vector = getAllSpheresFromGroup(gid); for (vector::iterator iter=sphere_vector.begin(); iter!= sphere_vector.end(); iter++) { l.append(*(*(iter))); } return l; } boost::python::list MNTable3D::getSphereListDist(const Vector3& pos, double dist, int gid) const { boost::python::list l; multimap sphere_map = getSpheresFromGroupNear(pos,dist,gid); for (map::iterator iter=sphere_map.begin(); iter!= sphere_map.end(); iter++) { l.append(*(iter->second)); } return l; } /*! Set output style \param style the output style: 0 = debug, 1 = .geo */ void MNTable3D::SetOutputStyle(int style) { MNTable3D::s_output_style=style; } /*! Output the content of a MNTable3D to an ostream. The output format depends on the value of MNTable3D::s_output_style (see MNTable3D::SetOutputStyle). If it is set to 0, output suitable for debugging is generated, if it is set to 1 output in the esys .geo format is generated. If MNTable3D::s_output_style is set to 2, the output format is VTK-XML. \param ost the output stream \param T the table */ ostream& operator << (ostream& ost,const MNTable3D& T) { if(MNTable3D::s_output_style==0){ // debug style // don't print padding MNTCell::SetOutputStyle(0); for(int i=0;i > >::const_iterator iter=T.m_bonds.begin(); iter!=T.m_bonds.end(); iter++){ nbonds+=iter->second.size(); } ost << nbonds << endl; for(map > >::const_iterator iter=T.m_bonds.begin(); iter!=T.m_bonds.end(); iter++){ for(set >::const_iterator v_iter=iter->second.begin(); v_iter!=iter->second.end(); v_iter++){ if(v_iter->first<=v_iter->second){ ost << v_iter->first << " " << v_iter->second << " " << iter->first << endl; } else { ost << v_iter->second << " " << v_iter->first << " " << iter->first << endl; } } } ost << "EndConnect" << endl; } else if (MNTable3D::s_output_style==2){ // vtk-xml T.WriteAsVtkXml(ost); } return ost; } /*! tag all particles close to a plane \param P the plane \param dist max. distance \param tag the tag \param gid group Id */ void MNTable3D::tagParticlesAlongPlane(const Plane& P,double dist,int tag,unsigned int gid) { for(int i=1;i vs=m_data[idx(i,j,k)].getSpheresNearObject(&P,dist,gid); for(vector::iterator iter=vs.begin(); iter!=vs.end(); iter++){ (*iter)->setTag(tag); } } } } } /*! tag all particles inside a specified volume \param V the volume \param tag the tag \param gid group Id */ void MNTable3D::tagParticlesInVolume(const AVolume& V,int tag,unsigned int gid) { for(int i=1;i vs=m_data[idx(i,j,k)].getSpheresInVolume(&V,gid); for(vector::iterator iter=vs.begin(); iter!=vs.end(); iter++){ (*iter)->setTag(tag); } } } } } /*! tag all particles close to a plane \param P the plane \param dist max. distance \param the tag mask \param tag the tag \param gid group Id */ void MNTable3D::tagParticlesAlongPlaneWithMask(const Plane& P,double dist,int tag,int mask,unsigned int gid) { for(int i=1;i vs=m_data[idx(i,j,k)].getSpheresNearObject(&P,dist,gid); for(vector::iterator iter=vs.begin(); iter!=vs.end(); iter++){ int oldtag=(*iter)->Tag(); int newtag=(tag & mask) | (oldtag & ~mask); (*iter)->setTag(newtag); } } } } } /*! tag all particles close to a joint set \param T the joint set \param dist max. distance \param the tag mask \param tag the tag \param gid group Id */ void MNTable3D::tagParticlesAlongJoints(const TriPatchSet& T,double dist,int tag, int mask, unsigned int gid) { for(int i=1;i::const_iterator iter=T.triangles_begin(); iter!=T.triangles_end(); iter++){ vector vs=m_data[idx(i,j,k)].getSpheresNearObject(&(*iter),dist,gid); for(vector::iterator iter=vs.begin(); iter!=vs.end(); iter++){ int oldtag=(*iter)->Tag(); int newtag=(tag & mask) | (oldtag & ~mask); (*iter)->setTag(newtag); } } } } } } /*! tag all particles fully within a sphere \param S the sphere \param tag the tag \param gid group Id */ void MNTable3D::tagParticlesInSphere(const Sphere &S,int tag,unsigned int gid) { int range=int(ceil(S.Radius()/m_celldim)); for(int i=-1*range;i<=range;i++){ for(int j=-1*range;j<=range;j++){ for(int k=-1*range;k<=range;k++){ Vector3 np=S.Center()+Vector3(double(i)*m_celldim,double(j)*m_celldim,double(k)*m_celldim); int idx=this->getIndex(np); if(idx!=-1){ multimap v=m_data[idx].getSpheresFromGroupNearNC(S.Center(),S.Radius(),gid); for(multimap::iterator iter=v.begin(); iter!=v.end(); iter++){ double outer_dist=(iter->first+(iter->second)->Radius()); if(outer_dist<=S.Radius()) (iter->second)->setTag(tag); } } } } } } /*! tag the spheres in a group A according to the tag of the closest spheres from a another group B \param gid1 the group Id A \param gid1 the group Id B */ void MNTable3D::tagParticlesToClosest(int gid1, int gid2) { for(int i=0;i v=m_data[idx(i,j,k)].getAllSpheresFromGroupNC(gid1); for(vector::iterator iter=v.begin(); iter!=v.end(); iter++){ int t=getTagOfClosestSphereFromGroup(*(*iter),gid2); (*iter)->setTag(t); } } } } } /*! Tag the spheres in a group A according to the tag of the closest spheres from a another group B, using an anisotropic distance measure \param gid1 the group Id A \param gid1 the group Id B \param wx weighting of the x-component of the distance \param wy weighting of the y-component of the distance \param wz weighting of the z-component of the distance */ void MNTable3D::tagParticlesToClosestAnisotropic(int gid1, int gid2, double wx, double wy,double wz) { for(int i=0;i v=m_data[idx(i,j,k)].getAllSpheresFromGroupNC(gid1); for(vector::iterator iter=v.begin(); iter!=v.end(); iter++){ int t=getTagOfClosestSphereFromGroup(*(*iter),gid2,wx,wy,wz); (*iter)->setTag(t); } } } } } /* tag all particles within a group \param gid the group Id \param tag the tag \param mask the tag mask (i.e. new_tag = new_tag=(old_tag & (~mask)) | (tag & mask)) */ void MNTable3D::tagParticlesInGroup(int gid, int tag, int mask) { for(int i=1;iparticle id map inv_map; int pcount=0; for(int i=1;i ids=m_data[idx(i,j,k)].getIdList(); for(vector::iterator iter=ids.begin(); iter!=ids.end(); iter++){ inv_map.insert(make_pair(*iter,pcount)); pcount++; } } } } // get bond count int bcount=0; for(map >::const_iterator iter=m_bonds.begin(); iter!=m_bonds.end(); iter++){ bcount+=iter->second.size(); } // write header vtkfile << "\n"; vtkfile << "\n"; int nparts=0; for(int i=1;i\n"; // write particle pos vtkfile << "\n"; vtkfile << "\n"; for(int i=1;i\n"; vtkfile << "\n"; // --- write particle data --- // radius vtkfile << "\n"; vtkfile << "\n"; for(int i=1;i\n"; // ID vtkfile << "\n"; for(int i=1;i\n"; // Tag vtkfile << "\n"; for(int i=1;i\n"; vtkfile << "\n"; // --- write cells section --- // connections vtkfile << "\n"; vtkfile << "\n"; for(map >::const_iterator iter=m_bonds.begin(); iter!=m_bonds.end(); iter++){ for(set::const_iterator iter_b=iter->second.begin(); iter_b!=iter->second.end(); iter_b++){ vtkfile << inv_map[iter_b->first] << " " << inv_map[iter_b->second] << endl; } } vtkfile << "\n"; // offsets vtkfile << "\n"; for (size_t i = 1; i < bcount*2; i+=2) vtkfile << i+1 << "\n"; vtkfile << "\n"; // element type vtkfile << "\n"; const int CELL_LINE_TYPE = 3; for (size_t i = 0; i < bcount; i++) vtkfile << CELL_LINE_TYPE << endl; vtkfile << "\n"; vtkfile << "\n"; // cell data vtkfile << "\n"; vtkfile << "\n"; for(map >::const_iterator iter=m_bonds.begin(); iter!=m_bonds.end(); iter++){ for(set::const_iterator iter_b=iter->second.begin(); iter_b!=iter->second.end(); iter_b++){ vtkfile << iter->first << endl; } } vtkfile << "\n"; vtkfile << "\n"; // write footer vtkfile << "\n"; vtkfile << "\n"; vtkfile << "\n"; } /*! Set output precision \param prec number of significant digits */ void MNTable3D::SetOutputPrecision(int prec) { m_write_prec=prec; } void MNTable3D::write(char *filename, int outputStyle) { ofstream outFile; outFile.precision(m_write_prec); SetOutputStyle(outputStyle); outFile.open(filename); outFile << *(this); outFile.close(); } // --- block writing --- void MNTable3D::initBlockWriting(const string& filename) { m_outfilename=filename; m_temp_bondfilename=filename+string("_tmp_bond"); m_block_particles_written=0; m_block_bonds_written=0; // write header ofstream ost(filename.c_str()); ost << "LSMGeometry 1.2" << endl; if(m_write_tight_bbx & m_has_tight_bbx){ ost << "BoundingBox " << m_min_tbbx << " " << m_max_tbbx << endl; } else { ost << "BoundingBox " << m_min_pt << " " << m_max_pt << endl; } ost << "PeriodicBoundaries " << m_x_periodic << " " << m_y_periodic << " " << m_z_periodic << endl; ost << "Dimension 3D" << endl; // particles ost << "BeginParticles" << endl; ost << "Simple" << endl; m_np_write_pos=ost.tellp(); ost << " " << endl; // IMPORTANT: 10 spaces as placeholder for the number of particles std::cout << m_np_write_pos << std::endl; m_is_writing_blocks=true; } void MNTable3D::writeBlock(const Vector3& min_pt,const Vector3& max_pt) { ofstream ost(m_outfilename.c_str(),ios::app); // open file in append mode ost.precision(m_write_prec); for(int i=1;i > >::const_iterator iter=m_bonds.begin(); iter!=m_bonds.end(); iter++){ for(set >::const_iterator v_iter=iter->second.begin(); v_iter!=iter->second.end(); v_iter++){ if(v_iter->first<=v_iter->second){ ost << v_iter->first << " " << v_iter->second << " " << iter->first << endl; } else { ost << v_iter->second << " " << v_iter->first << " " << iter->first << endl; } m_block_bonds_written++; } } ost.close(); std::cout << "bonds written: " << m_block_bonds_written << std::endl; } void MNTable3D::finishBlockWriting() { ofstream ost(m_outfilename.c_str(),ios::in | ios::out | ios::ate); // open for writing, initially positioned at the end // -- write end of particles -- ost << "EndParticles" << endl; // -- write bonds -- ost << "BeginConnect" << endl; ost << m_block_bonds_written << endl; ifstream ifs(m_temp_bondfilename.c_str()); ost << ifs.rdbuf(); ifs.close(); ost << "EndConnect" << endl; // -- reposition to the place where nr. of particles should be ost.seekp(m_np_write_pos); // overwrite placeholders ost << m_block_particles_written; // close file ost.close(); } GenGeo-1.2/src/MNTable3D.h0000644000000000000000000001312412533740504013263 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __MNTABLE3D_H #define __MNTABLE3D_H // --- STL includes --- #include #include #include #include #include using std::vector; using std::map; using std::multimap; using std::string; using std::set; // --- IO includes --- #include using std::ostream; // --- Project includes --- #include "MNTCell.h" #include "AVolume3D.h" #include "AVolume.h" #include "geometry/Sphere.h" #include "util/vector3.h" #include "geometry/Plane.h" #include "JointSet.h" #include "TriPatchSet.h" // --- STL includes --- #include #include #include #include using std::vector; using std::map; using std::pair; using std::string; /*! \class MNTable3D \brief Multi-group Neighbour table Neighbour table supporting multiple tagged groups of particles */ class MNTable3D { public: // types typedef pair bond; protected: MNTCell* m_data; map > m_bonds; Vector3 m_origin; //!< origin Vector3 m_min_pt, m_max_pt; // original min/max point double m_celldim; //!< cell size int m_nx,m_ny,m_nz; //!< number of cells in x-, y- and z-direction unsigned int m_ngroups; static int s_output_style; static double s_small_value; int m_x_periodic,m_y_periodic,m_z_periodic; // bounding box handling bool m_bbx_tracking; //!< if true, bbx is updated for each insert operation bool m_has_tight_bbx; //!< true if a tight bounding box has been calculated bool m_write_tight_bbx; //!< if true, tight bbx is written instead of min/max Vector3 m_min_tbbx, m_max_tbbx; //!< corner points of tight bounding box virtual int getIndex(const Vector3&) const; inline int idx(int i,int j, int k) const{return i*m_ny*m_nz+j*m_nz+k;}; void WriteAsVtkXml(ostream&) const; virtual void set_x_circ(); virtual void set_y_circ(); virtual void set_z_circ(); int m_write_prec; //!< precision (nr. of significant digits) for file output // blocked output handling bool m_is_writing_blocks; string m_outfilename; string m_temp_bondfilename; std::ios::pos_type m_np_write_pos; unsigned int m_block_particles_written; unsigned int m_block_bonds_written; public: MNTable3D(); MNTable3D(const Vector3&,const Vector3&,double,unsigned int); virtual ~MNTable3D(); bool insertFromRawFile(const string&,double,double); virtual bool insert(const Sphere&,unsigned int); virtual bool insertChecked(const Sphere&,unsigned int,double=s_small_value); virtual bool checkInsertable(const Sphere&,unsigned int); void GrowNGroups(unsigned int); const multimap getSpheresClosestTo(const Vector3&,unsigned int) const; const multimap getSpheresFromGroupNear(const Vector3&,double,int) const; const vector getAllSpheresFromGroup(int) const; const Sphere* getClosestSphereFromGroup(const Sphere&,int) const; int getTagOfClosestSphereFromGroup(const Sphere&,int) const; const Sphere* getClosestSphereFromGroup(const Sphere&,int,double,double,double) const; int getTagOfClosestSphereFromGroup(const Sphere&,int,double,double,double) const; void tagParticlesAlongPlane(const Plane&,double,int,unsigned int); void tagParticlesAlongPlaneWithMask(const Plane&,double,int,int,unsigned int); void tagParticlesInSphere(const Sphere&,int,unsigned int); void tagParticlesInGroupNT(int tag,int gid){tagParticlesInGroup(tag,gid,-1);}; void tagParticlesInGroup(int,int,int); void tagParticlesToClosest(int,int); void tagParticlesToClosestAnisotropic(int,int,double,double,double); void removeParticlesWithTag(int,unsigned int); void removeParticlesWithTagMask(unsigned int,int,int); void removeParticlesInVolume(AVolume3D*, int, bool); void removeParticlesInGroup(unsigned int); void tagParticlesAlongJoints(const TriPatchSet&,double,int, int, unsigned int); void tagParticlesInVolume(const AVolume&,int,unsigned int); void renumberParticlesContinuous(); // bbx handling virtual void calculateTightBoundingBox(); void setBoundingBoxTracking(bool); boost::python::list getSphereListFromGroup(int) const; boost::python::list getSphereListDist(const Vector3&, double, int) const; virtual void generateBonds(int,double,int); virtual void generateClusterBonds(int,double,int,int); virtual void generateBondsWithJointSet(const TriPatchSet&,int,double,int); virtual void generateBondsTagged(int,double,int,int,int); virtual void generateRandomBonds(int,double,double,int,int,int); virtual void removeBonds(); void insertBond(int,int,int); // output double getSumVolume(int); friend ostream& operator << (ostream&,const MNTable3D&); static void SetOutputStyle(int); void SetOutputPrecision(int); void SetWriteTightBoundingBox(bool); void write(char *filename, int outputStyle); // block writing void initBlockWriting(const string&); void writeBlock(const Vector3&,const Vector3&); void writeBondsBlocked(); void finishBlockWriting(); }; #endif // __MNTABLE_H GenGeo-1.2/src/MeshVolWithJointSet.cc0000644000000000000000000000657312533740504015653 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "MeshVolWithJointSet.h" // --- Project includes --- #include "geometry/Triangle3D.h" //-- system includes -- #include using std::rand; // --- STL includes --- #include // --- I/O includes #include using std::make_pair; /*! Constructor */ MeshVolWithJointSet::MeshVolWithJointSet() {} /*! Constructor \param tp the triangle set */ MeshVolWithJointSet::MeshVolWithJointSet(const TriPatchSet& tp) { m_mesh=tp; m_MinPoint=m_mesh.getBoundingBox().first; m_MaxPoint=m_mesh.getBoundingBox().second; m_DistPoint=m_MinPoint-Vector3(1.0,1.0,1.0); } /*! returns a map of the closest mesh facets and their distances to a given point \param P the point \param nmax the maximum number of objects to be returned */ const map MeshVolWithJointSet::getClosestObjects(const Vector3& P,int nmax) const { map res; for(vector::const_iterator iter=m_mesh.triangles_begin(); iter!=m_mesh.triangles_end(); iter++){ double ndist=iter->getDist(P); res.insert(make_pair(ndist,&(*iter))); } for(vector::const_iterator iter=m_joints.begin(); iter!=m_joints.end(); iter++){ double ndist=iter->getDist(P); res.insert(make_pair(ndist,&(*iter))); } return res; } /*! Check if a point is inside the volume. Works by checking if a line between the point and a point outside crosses an odd number of mesh facets. \param P the point */ bool MeshVolWithJointSet::isIn(const Vector3& P) const { int cross_count=0; for(vector::const_iterator iter=m_mesh.triangles_begin(); iter!=m_mesh.triangles_end(); iter++){ if(iter->crosses(P,m_DistPoint)) cross_count++; } return (cross_count%2)==1; } /*! Check if a sphere is fully inside the volume. Works by testing if center of the sphere is inside and sphere doesn't intersect a mesh facet. \param S the sphere */ bool MeshVolWithJointSet::isIn(const Sphere& S) { double r=S.Radius(); Vector3 p=S.Center(); bool res=isIn(S.Center()); vector::const_iterator iter=m_mesh.triangles_begin(); while((iter!=m_mesh.triangles_end()) && res){ res=(iter->getDist(S.Center())>S.Radius()); iter++; } if(res){ // check intersection with joints vector::iterator iter=m_joints.begin(); double dist=2*r; while((iter!=m_joints.end()) && res){ dist=iter->getDist(p); res=(dist>r); iter++; } } return res; } void MeshVolWithJointSet::addJoints(const TriPatchSet& t) { for(vector::const_iterator iter=t.triangles_begin(); iter!=t.triangles_end(); iter++){ m_joints.push_back(*iter); } } GenGeo-1.2/src/MeshVolWithJointSet.h0000644000000000000000000000346412533740504015511 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __MESH_VOL_JOINT_SET_H #define __MESH_VOL_JOINT_SET_H // --- Project includes --- #include "MeshVolume.h" #include "TriPatchSet.h" #include "util/vector3.h" // --- STL includes --- /*! \class MeshVolWithJointSet A class for the generation of random particles inside a volume bounded by a triangle mesh, with the option of including joint sets. The correctness of the supplied mesh, i.e. that it actually defines a closed surface, is not checked in the class. Instead the caller is responsible to supply a correct mesh. No convexity or other topological requirements apply to the volume. Facet orientations is not relevant. Works also if the mesh encloses multiple volumes. */ class MeshVolWithJointSet : public MeshVolume { protected: vector m_joints; public: MeshVolWithJointSet(); MeshVolWithJointSet(const TriPatchSet&); virtual ~MeshVolWithJointSet(){}; virtual const map getClosestObjects(const Vector3&,int) const; virtual bool isIn(const Vector3&) const; virtual bool isIn(const Sphere&); void addJoints(const TriPatchSet&); }; #endif // __MESH_VOL_JOINT_SET_H GenGeo-1.2/src/MeshVolume.cc0000644000000000000000000000746412533740504014046 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "MeshVolume.h" // --- Project includes --- #include "geometry/Triangle3D.h" //-- system includes -- #include using std::rand; // --- STL includes --- #include // --- I/O includes #include using std::make_pair; /*! helper function, return random value between min & max */ double MeshVolume::m_random(double imin,double imax) const { return imin+((imax-imin)*((double)(rand())/(double)(RAND_MAX))); } /*! Constructor */ MeshVolume::MeshVolume() {} /*! Constructor \param tp the triangle set */ MeshVolume::MeshVolume(const TriPatchSet& tp) { m_mesh=tp; m_MinPoint=m_mesh.getBoundingBox().first; m_MaxPoint=m_mesh.getBoundingBox().second; m_DistPoint=m_MinPoint-Vector3(1.0,1.0,1.0); } /*! get bounding box */ pair MeshVolume::getBoundingBox() { return m_mesh.getBoundingBox(); } /*! Get a point inside the volume. The argument is ignored. \warning if the mesh is incorrect the function might loop forever */ Vector3 MeshVolume::getAPoint(int) const { Vector3 res; double px,py,pz; do{ px=m_random(m_MinPoint.x(),m_MaxPoint.x()); py=m_random(m_MinPoint.y(),m_MaxPoint.y()); pz=m_random(m_MinPoint.z(),m_MaxPoint.z()); res=Vector3(px,py,pz); } while (!isIn(res)); return res; } /*! returns a map of the closest mesh facets and their distances to a given point \param P the point \param nmax the maximum number of objects to be returned */ const map MeshVolume::getClosestObjects(const Vector3& P,int nmax) const { map res; for(vector::const_iterator iter=m_mesh.triangles_begin(); iter!=m_mesh.triangles_end(); iter++){ double ndist=iter->getDist(P); res.insert(make_pair(ndist,&(*iter))); } return res; } /*! Check if a point is inside the volume. Works by checking if a line between the point and a point outside crosses an odd number of mesh facets. \param P the point */ bool MeshVolume::isIn(const Vector3& P) const { int cross_count=0; for(vector::const_iterator iter=m_mesh.triangles_begin(); iter!=m_mesh.triangles_end(); iter++){ if(iter->crosses(P,m_DistPoint)) cross_count++; } return (cross_count%2)==1; } /*! Check if a sphere is fully inside the volume. Works by testing if center of the sphere is inside and sphere doesn't intersect a mesh facet. \param S the sphere */ bool MeshVolume::isIn(const Sphere& S) { bool res=isIn(S.Center()); vector::const_iterator iter=m_mesh.triangles_begin(); while((iter!=m_mesh.triangles_end()) && res){ res=(iter->getDist(S.Center())>S.Radius()); iter++; } return res; } /*! Check if a sphere is fully outside the volume. Works by testing if center of the sphere is not inside and sphere doesn't intersect a mesh facet. \param S the sphere */ bool MeshVolume::isFullyOutside(const Sphere& S) { bool res=!isIn(S.Center()); vector::const_iterator iter=m_mesh.triangles_begin(); while((iter!=m_mesh.triangles_end()) && res){ res=(iter->getDist(S.Center())>S.Radius()); iter++; } return res; } GenGeo-1.2/src/MeshVolume.h0000644000000000000000000000361412533740504013701 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __MESH_VOLUME_H #define __MESH_VOLUME_H // --- Project includes --- #include "AVolume3D.h" #include "TriPatchSet.h" #include "util/vector3.h" // --- STL includes --- /*! \class MeshVolume A class for the generation of random particles inside a volume bounded by a triangle mesh. The correctness of the supplied mesh, i.e. that it actually defines a closed surface, is not checked in the class. Instead the caller is responsible to supply a correct mesh. No convexity or other topological requirements apply to the volume. Facet orientations is not relevant. Works also if the mesh encloses multiple volumes. */ class MeshVolume : public AVolume3D { protected: TriPatchSet m_mesh; Vector3 m_MinPoint; Vector3 m_MaxPoint; Vector3 m_DistPoint; double m_random(double,double)const; public: MeshVolume(); MeshVolume(const TriPatchSet&); virtual ~MeshVolume(){}; virtual pair getBoundingBox(); virtual Vector3 getAPoint(int) const; virtual const map getClosestObjects(const Vector3&,int) const; virtual bool isIn(const Vector3&) const; virtual bool isIn(const Sphere&); virtual bool isFullyOutside(const Sphere&); }; #endif // __MESH_VOLUME_H GenGeo-1.2/src/Model2D.cc0000644000000000000000000000365412533740504013205 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "Model2D.h" // --- IO includes --- #include #include using std::ofstream; using std::endl; /*! constructor \param Pmin minimum point \param Pmax maximum point \param cdim cell dimension for neigbour table */ Model2D::Model2D(const Vector3& Pmin,const Vector3& Pmax,double cdim) { m_ntable=new MNTable2D(Pmin,Pmax,cdim,1); m_ngroups=1; m_max_gid=-1; m_min_pt=Pmin; m_max_pt=Pmax; } /*! destructor */ Model2D::~Model2D() { if(m_ntable!=NULL) delete m_ntable; } /*! Add particle group \param PGPtr pointer to particle group \return id of the particle group */ int Model2D::AddParticleGroup(AParticleGroup* PGPtr) { m_max_gid++; if(m_max_gid>=m_ngroups){ m_ngroups=m_ngroups*2; m_ntable->GrowNGroups(m_ngroups); } PGPtr->Init(m_ntable,m_max_gid); m_pgroups.push_back(PGPtr); return m_max_gid; } /*! Write Geonmetry out to file \param filename the filename */ void Model2D::WriteAsGeoFile(const string& filename) { ofstream outfile(filename.c_str()); outfile << "LSMGeometry 1.2" << endl; outfile << "BoundingBox" << m_min_pt << " " << m_max_pt << endl; outfile << "PeriodicBoundaries 0 0 0" << endl; outfile << "Dimension 2D" << endl; outfile << *m_ntable; outfile.close(); } GenGeo-1.2/src/Model2D.h0000644000000000000000000000243212533740504013040 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __MODEL2D_H #define __MODEL2D_H // --- Project includes --- #include "src/MNTable2D.h" #include "src/AParticleGroup.h" #include "util/vector3.h" // --- STL includes --- #include #include using std::list; using std::string; /*! \class Model2D \brief */ class Model2D { private: MNTable2D* m_ntable; list m_pgroups; Vector3 m_min_pt; Vector3 m_max_pt; int m_ngroups; int m_max_gid; public: Model2D(const Vector3&,const Vector3&,double); ~Model2D(); int AddParticleGroup(AParticleGroup*); void WriteAsGeoFile(const string&); }; #endif // __MODEL2D_H GenGeo-1.2/src/PolygonWithLines2D.cc0000644000000000000000000001550712533740504015423 0ustar 00000000000000///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "PolygonWithLines2D.h" //-- system includes -- #include //#include using std::rand; // --- STL includes --- #include #include #include using std::make_pair; using std::map; using std::list; //--- IO includes --- #include /*! helper function, return random value between min & max */ double PolygonWithLines2D::m_random(double imin,double imax) const { return imin+((imax-imin)*((double)(rand())/(double)(RAND_MAX))); } PolygonWithLines2D::PolygonWithLines2D() {} /*! Construct regular n-sided polygon \param centre the center postition of the polygon \param rad the distance of the corners fron the center, i.e. the radius of the circle into which the polygon is incribed \param nsides nr. of sides \param add_bounding_lines add fitting lines to sides of polygon (yes/no) */ PolygonWithLines2D::PolygonWithLines2D(const Vector3& centre,double rad,int nsides,bool add_bounding_lines) : m_centre(centre),m_radius(rad),m_nsides(nsides) { Vector3 pmin, pmax; int i; double px,py,pz,theta,theta0; Line2D l; pmin[0]=m_centre[0]-m_radius; pmin[1]=m_centre[1]-m_radius; pmin[2]=m_centre[2]; pmax[0]=m_centre[0]+m_radius; pmax[1]=m_centre[1]+m_radius; pmax[2]=m_centre[2]; m_pmin=(pmin); m_pmax=(pmax); for (i=0;i begin(corners), end; list vertex_list=list(begin, end); int idx=0; //go though list of corner points for(list::iterator iter=vertex_list.begin(); iter!=vertex_list.end(); iter++){ m_vertices[idx]=*iter; idx++; // update bounding box if(idx==1){ m_pmin=*iter; m_pmax=*iter; } m_pmin=comp_min(m_pmin,*iter); m_pmax=comp_max(m_pmax,*iter); } // m_vertices[idx]=m_vertices[0]; // closure std::cout << m_pmin << " - " << m_pmax << std::endl; m_nsides=idx; m_centre=0.5*(m_pmin+m_pmax); for(int i=0;i PolygonWithLines2D::getBoundingBox() { return make_pair(m_pmin,m_pmax); } /*! get point inside the box. The Argument is ignored */ Vector3 PolygonWithLines2D::getAPoint(int) const { double px,py; bool found_a_point; Vector3 aPoint; found_a_point = false; do { px=m_random(m_pmin.x(),m_pmax.x()); py=m_random(m_pmin.y(),m_pmax.y()); aPoint = Vector3(px,py,0.0); found_a_point = isIn(aPoint); } while (found_a_point==false); return Vector3(px,py,0.0); } /*! Return closest plane to a given point. Assumes that the list of Planes/Lines is not empty. \param p the point \warning check non-empty list of lines (via hasPlane()) before invoking */ Line2D PolygonWithLines2D::getClosestPlane(const Vector3& p) { std::cout << "getClosestPlane : " << p << std::endl; vector::iterator PL=m_lines.begin(); double dist=PL->getDist(p); for(vector::iterator iter=m_lines.begin(); iter!=m_lines.end(); iter++){ double ndist=iter->getDist(p); std::cout << "Line: " << *iter << " Distance: " << ndist << std::endl; if(ndist PolygonWithLines2D::getClosestPlanes(const Vector3& p,int nmax) const { map res; for(vector::const_iterator iter=m_lines.begin(); iter!=m_lines.end(); iter++){ double ndist=iter->getDist(p); const Line2D *l=&(*iter); res.insert(make_pair(ndist,l)); } return res; } /*! check if point is inside \param p the point */ bool PolygonWithLines2D::isIn(const Vector3& p) const { bool inside,inbox; double dp,dv; Vector3 cp,cv; int i; inbox = ((p.x()>m_pmin.x()) && (p.x()m_pmin.y()) && (p.y()m_pmin.X()+r) && (p.X()m_pmin.Y()+r) && (p.Y()::iterator iter=m_lines.begin(); double dist=2*r; while(iter!=m_lines.end() && dist>r){ dist=iter->getDist(p); iter++; } return inside && (dist>r); } ostream& operator<< (ostream& ost, const PolygonWithLines2D& L) { ost << " centre: " << L.m_centre << " radius: " << L.m_radius << " number of sides: " << L.m_nsides; return ost; } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������GenGeo-1.2/src/PolygonWithLines2D.h�����������������������������������������������������������������0000644�0000000�0000000�00000004204�12533740504�015255� 0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __POLYGONWITHLINES2D_H #define __POLYGONWITHLINES2D_H // --- Project includes --- #include "AVolume2D.h" // --- STL includes --- #include #include // --- IO includes --- #include // --- Boost includes --- #include #include using std::vector; using std::map; using std::ostream; #define MAX_VERTICES 50 /*! \class PolygonWithLines2D A class for the generation of random particles inside a 2D polygon. An arbitrary number of lines can be added to which the particles are fitted. */ class PolygonWithLines2D : public AVolume2D { protected: Vector3 m_pmin; Vector3 m_pmax; Vector3 m_centre; double m_radius; int m_nsides; Vector3 m_vertices[MAX_VERTICES]; vector m_lines; double m_random(double,double)const; public: PolygonWithLines2D(); PolygonWithLines2D(const Vector3&,double,int,bool); PolygonWithLines2D(boost::python::list); virtual ~PolygonWithLines2D(){}; void addLine(const Line2D&); virtual pair getBoundingBox(); virtual Vector3 getAPoint(int)const; virtual bool hasPlane() const{return (m_lines.size()>0);}; virtual Line2D getClosestPlane(const Vector3&); virtual const map getClosestPlanes(const Vector3&,int) const; virtual bool isIn(const Vector3&) const; virtual bool isIn(const Sphere&); friend ostream& operator<< (ostream&, const PolygonWithLines2D&); }; #endif // __TRIWITHLINES2D_H ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������GenGeo-1.2/src/Shape.cc�����������������������������������������������������������������������������0000644�0000000�0000000�00000006675�12533740504�013025� 0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "Shape.h" #include #include using std::cos; using std::sin; Shape::Shape() { this->pitch=0; this->yaw=0; this->roll=0; this->randomOrientation = 0; } Shape::~Shape() { } /** * Tell the shape to be randomly orientated. This will make every object * have a random orientation * \param i 1 for using random orientation, 0 to disable */ void Shape::makeOrientationRandom(int i) { this->randomOrientation = i; } /** * Returns 1 if the shape is to be randomly orientated * \returns 1 if shape is to be randomly orientated */ int Shape::useRandomOrientation() { return this->randomOrientation; } /** * Sets a random orientation. Note that this will be run before every * insert if the appropriate function is called. */ void Shape::setRandomOrientation() { setRandomPitch(); setRandomYaw(); setRandomRoll(); } /** * Set a random pitch to the object */ void Shape::setRandomPitch() { this->pitch = (rand() % 180) - 90; } /** * Set a random yaw to the object */ void Shape::setRandomYaw() { this->yaw = (rand() % 360) - 180; } /** * Set a random roll to the object */ void Shape::setRandomRoll() { this->roll = (rand() % 360) - 180; } /** * Rotate a point around the x, y and z axies. Rotation values are given * using setRoll functions etc. * \param point the point to rotate * \returns the rotated point */ Vector3 Shape::rotatePoint(Vector3 point) { double roll = this->roll *M_PI/180; double yaw = this->yaw *M_PI/180; double pitch = this->pitch *M_PI/180; /* double x = (cos(yaw)*cos(roll)+sin(yaw)*sin(pitch)*sin(roll))* point.x() + (-sin(yaw)*cos(pitch)) * point.y() + (sin(yaw)*sin(pitch)*cos(roll)-cos(yaw)*sin(roll))* point.z(); double y = (sin(yaw)*cos(roll)-cos(yaw)*sin(pitch)*sin(roll))* point.x() + (cos(yaw)*cos(pitch)) * point.y() + (-cos(yaw)*sin(pitch)*cos(roll)-sin(yaw)*sin(roll))*point.z(); double z = (cos(pitch)*sin(roll))*point.x() + (sin(pitch)*point.y()) + (cos(pitch)*cos(roll))*point.y(); Vector3 newpoint(x,y,z); */ Vector3 newpoint = point.rotate(Vector3(roll,yaw,pitch),Vector3(0,0,0)); return newpoint; } int Shape::bias() { return this->bias_factor; } void Shape::setBias(int i) { this->bias_factor = i; } void Shape::setPitch(double pitch) { this->pitch = pitch; } double Shape::getPitch() { return this->pitch; } void Shape::setYaw(double yaw) { this->yaw = yaw; } double Shape::getYaw() { return this->yaw; } void Shape::setRoll(double roll) { this->roll = roll; } double Shape::getRoll() { return this->roll; } void Shape::setBondTag(int tag) { bondTag = tag; } int Shape::getBondTag() { return bondTag; } void Shape::setParticleTag(int tag) { particleTag = tag; } int Shape::getParticleTag() { return particleTag; } �������������������������������������������������������������������GenGeo-1.2/src/Shape.h������������������������������������������������������������������������������0000644�0000000�0000000�00000005312�12533740504�012652� 0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef SHAPE_H #define SHAPE_H #include "util/vector3.h" #include "MNTable3D.h" class Shape { public: Shape(); /** * Tell the shape to be randomly orientated. This will make every object * have a random orientation * \param i 1 for using random orientation, 0 to disable */ void makeOrientationRandom(int i); /** * Returns 1 if the shape is to be randomly orientated * \returns 1 if shape is to be randomly orientated */ int useRandomOrientation(); /** * Sets a random orientation. Note that this will be run before every * insert if the appropriate function is called. */ void setRandomOrientation(); /** * Set a random pitch to the object */ void setRandomPitch(); /** * Set a random yaw to the object */ void setRandomYaw(); /** * Set a random roll to the object */ void setRandomRoll(); /** * Rotate a point around the x, y and z axies. Rotation values are given * using setRoll functions etc. * \param point the point to rotate * \returns the rotated point */ Vector3 rotatePoint(Vector3 point); virtual void insert(Vector3 pos, double radius, MNTable3D* ntable,int tag,int id ) { std::cout << "No shape" << std::endl; return;} ; /** * Show the bias of a given shape (ie how likely it is to occur. * Note that the function must return a deterministic value. */ int bias(); /** * Set the bias of the given shape * \param bias the bias of the shape */ void setBias(int); void setPitch(double); double getPitch(); void setYaw(double); double getYaw(); void setRoll(double); double getRoll(); void setBondTag(int); int getBondTag(); void setParticleTag(int); int getParticleTag(); ~Shape(); protected: double pitch; double yaw; double roll; int bias_factor; int randomOrientation; int bondTag; int particleTag; }; #endif /* SHAPE_H */ ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������GenGeo-1.2/src/ShapeList.cc�������������������������������������������������������������������������0000644�0000000�0000000�00000004043�12533740504�013644� 0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "ShapeList.h" #include "HexAggregateShape.h" void ShapeList::addHexShape(int bias, int random) { HexAggregateShape shape; shape.setBias(bias); shape.makeOrientationRandom(random); shapeList.push_back(&shape); } void ShapeList::insertShape(Vector3 pos, double radius, MNTable3D* ntable, int tag, int id) { std::vector biasList; unsigned int i; int biasTotal=0; // at all bias values. for(i=0; i < shapeList.size() ; i++) { int currBias = shapeList[i]->bias(); biasTotal = biasTotal + currBias; biasList.push_back ( currBias ); } if ( biasTotal == 0 ) { return; } // at a random value to select a shape int randomValue = rand() % biasTotal; i=0; // Find appropriate shape in list. while ( randomValue > shapeList[i]->bias() ) { randomValue = randomValue - shapeList[i]->bias(); i++; if (i == shapeList.size() ) { std::cout << "Error in ShapeList::insertShape :> randomValue too high\n"; return; } } shapeList[i]->insert(pos, radius, ntable, tag,id); } void ShapeList::addGenericShape(string db, string name, int bias, int random, int particleTag, int bondTag) { shapeList.push_back(new GenericShape(db,name)); Shape *shape = shapeList[shapeList.size()-1]; shape->setBias(bias); shape->makeOrientationRandom(random); shape->setParticleTag(particleTag); shape->setBondTag(bondTag); } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������GenGeo-1.2/src/ShapeList.h��������������������������������������������������������������������������0000644�0000000�0000000�00000002126�12533740504�013506� 0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef SHAPELIST_H #define SHAPELIST_H #include "Shape.h" #include "GenericShape.h" #include "util/vector3.h" #include "MNTable3D.h" using std::string; class ShapeList { protected: std::vector shapeList; public: void addHexShape(int, int); void addGenericShape(string,string,int,int,int,int); void insertShape(Vector3, double, MNTable3D *ntable,int tag,int id); }; #endif /* SHAPELIST_H */ ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������GenGeo-1.2/src/SphereObj.cc�������������������������������������������������������������������������0000644�0000000�0000000�00000003713�12533740504�013634� 0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "SphereObj.h" void SphereObj::insert(Vector3 pos, double radius, MNTable3D* table,int tag,int id) { // First list all (only 1 in this case) sphere locations relative to the // middle of the "empty space" Vector3 sphere_origin(0,0,0); // Rotate each one through all axis using the rotate function as below // // The below will do nothing, but is an example of what to do with more // complex shapes with multiple spheres. if ( this->useRandomOrientation() ) { this->setRandomOrientation(); sphere_origin = this->rotatePoint(sphere_origin); } // Translate all spheres to the given position sphere_origin = sphere_origin + pos; // Expand radius from unit circle to actual given radius for each circle // For example a circle that has radius 1/4 of unit circle should get // radius 0.25f*radius. double r = radius*1.0f; // Finally insert all spheres and bonds where relevant. Sphere Sc(sphere_origin, r); if ( table->checkInsertable(Sc,id) ) { Sc.setTag(tag); table->insert(Sc,id); } } void SphereObj::setBias(int factor) { this->bias_factor = factor; } int SphereObj::bias() { return this->bias_factor; } �����������������������������������������������������GenGeo-1.2/src/SphereObj.h��������������������������������������������������������������������������0000644�0000000�0000000�00000001660�12533740504�013475� 0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "util/vector3.h" #include "MNTable3D.h" #include "Shape.h" class SphereObj : public Shape { public: void setBias(int); void insert(Vector3 pos, double radius, MNTable3D* ntable, int,int); int bias(); protected: int bias_factor; }; ��������������������������������������������������������������������������������GenGeo-1.2/src/SphereSectionVol.cc������������������������������������������������������������������0000644�0000000�0000000�00000005350�12533740504�015206� 0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "SphereSectionVol.h" //--- #include #include using std::cos; using std::sin; // --- STL includes --- #include using std::make_pair; SphereSectionVol::SphereSectionVol() {} SphereSectionVol::SphereSectionVol(const Vector3& c,const double r,const double h, const Vector3& n) { m_sph=SphereIn(c,r); m_section_dist = h; m_section_normal = n; } pair SphereSectionVol::getBoundingBox() { Vector3 r=Vector3(m_sph.Radius(),m_sph.Radius(),m_sph.Radius()); return make_pair(m_sph.Center()-r,m_sph.Center()+r); } Vector3 SphereSectionVol::getAPoint(int) const { double r=m_sph.Radius()*((double)(rand())/(double)(RAND_MAX)); double phi=M_PI*((double)(rand())/(double)(RAND_MAX)); double rho=2*M_PI*((double)(rand())/(double)(RAND_MAX)); return m_sph.Center()+r*Vector3(sin(phi)*cos(rho),sin(phi)*sin(rho),cos(phi)); } const map SphereSectionVol::getClosestObjects(const Vector3& P,int) const { map res; res.insert(make_pair(m_sph.getDist(P),&m_sph)); return res; } bool SphereSectionVol::isIn(const Vector3& P) const { double dist; bool isInSection; Vector3 posn_vector; double norm_comp; isInSection = false; posn_vector = P - m_sph.Center(); dist = posn_vector.norm(); if (distm_section_dist)) { if ((fabs(norm_comp)/dist - m_section_dist/m_sph.Radius()) > 0) { isInSection = true; } } } return (isInSection); } bool SphereSectionVol::isIn(const Sphere& S) { bool isInSection; isInSection = false; if ((isIn(S.Center()))&&(m_sph.getDist(S.Center())>S.Radius())) { isInSection = true; } return (isInSection); } /* Check if sphere is fully outside the volume. \param S the sphere \warning DUMMY IMPLEMENTATION */ bool SphereSectionVol::isFullyOutside(const Sphere& S) { return true; } ostream& operator << (ostream& ost,const SphereSectionVol& T) { return ost; } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������GenGeo-1.2/src/SphereSectionVol.h�������������������������������������������������������������������0000644�0000000�0000000�00000003053�12533740504�015046� 0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __SPHERE_SECTION_VOL_H #define __SPHERE_SECTION_VOL_H // --- Project includes --- #include "AVolume3D.h" #include "geometry/SphereIn.h" // --- STL includes --- #include using std::map; class SphereSectionVol : public AVolume3D { protected: SphereIn m_sph; double m_section_dist; Vector3 m_section_normal; public: SphereSectionVol(); SphereSectionVol(const Vector3&,const double, const double, const Vector3&); virtual ~SphereSectionVol(){}; virtual pair getBoundingBox(); virtual Vector3 getAPoint(int) const; virtual const map getClosestObjects(const Vector3&,int) const; virtual bool isIn(const Vector3&) const; virtual bool isIn(const Sphere&); virtual bool isFullyOutside(const Sphere&); friend ostream& operator << (ostream&,const SphereSectionVol&); }; #endif // __SPHERE_SECTION_VOL_H �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������GenGeo-1.2/src/SphereVol.cc�������������������������������������������������������������������������0000644�0000000�0000000�00000004112�12533740504�013654� 0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "SphereVol.h" //--- #include #include using std::cos; using std::sin; // --- STL includes --- #include using std::make_pair; SphereVol::SphereVol() {} SphereVol::SphereVol(const Vector3& c,double r) { m_sph=SphereIn(c,r); } pair SphereVol::getBoundingBox() { Vector3 r=Vector3(m_sph.Radius(),m_sph.Radius(),m_sph.Radius()); return make_pair(m_sph.Center()-r,m_sph.Center()+r); } Vector3 SphereVol::getAPoint(int) const { double r=m_sph.Radius()*((double)(rand())/(double)(RAND_MAX)); double phi=M_PI*((double)(rand())/(double)(RAND_MAX)); double rho=2*M_PI*((double)(rand())/(double)(RAND_MAX)); return m_sph.Center()+r*Vector3(sin(phi)*cos(rho),sin(phi)*sin(rho),cos(phi)); } const map SphereVol::getClosestObjects(const Vector3& P,int) const { map res; res.insert(make_pair(m_sph.getDist(P),&m_sph)); return res; } bool SphereVol::isIn(const Vector3& P) const { return (m_sph.getDirDist(P)>0); } bool SphereVol::isIn(const Sphere& S) { return (m_sph.getDirDist(S.Center())>S.Radius()); } /* check if sphere is fully outside volume. \param S the sphere */ bool SphereVol::isFullyOutside(const Sphere& S) { double d=(m_sph.Center()-S.Center()).norm(); return d>(m_sph.Radius()+S.Radius()); } ostream& operator << (ostream& ost,const SphereVol& T) { return ost; } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������GenGeo-1.2/src/SphereVol.h��������������������������������������������������������������������������0000644�0000000�0000000�00000002626�12533740504�013526� 0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __SPHERE_VOL_H #define __SPHERE_VOL_H // --- Project includes --- #include "AVolume3D.h" #include "geometry/SphereIn.h" // --- STL includes --- #include using std::map; class SphereVol : public AVolume3D { protected: SphereIn m_sph; public: SphereVol(); SphereVol(const Vector3&,double); virtual ~SphereVol(){}; virtual pair getBoundingBox(); virtual Vector3 getAPoint(int) const; virtual const map getClosestObjects(const Vector3&,int) const; virtual bool isIn(const Vector3&) const; virtual bool isIn(const Sphere&); virtual bool isFullyOutside(const Sphere&); friend ostream& operator << (ostream&,const SphereVol&); }; #endif // __SPHERE_VOL_H ����������������������������������������������������������������������������������������������������������GenGeo-1.2/src/SphereVolWithJointSet.cc�������������������������������������������������������������0000644�0000000�0000000�00000004144�12533740504�016175� 0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "SphereVolWithJointSet.h" //--- #include #include using std::cos; using std::sin; // --- STL includes --- #include using std::make_pair; SphereVolWithJointSet::SphereVolWithJointSet() {} SphereVolWithJointSet::SphereVolWithJointSet(const Vector3& c,double r) { m_sph=SphereIn(c,r); } const map SphereVolWithJointSet::getClosestObjects(const Vector3& P,int) const { map res; res.insert(make_pair(m_sph.getDist(P),&m_sph)); for(vector::const_iterator iter=m_joints.begin(); iter!=m_joints.end(); iter++){ double ndist=iter->getDist(P); res.insert(make_pair(ndist,&(*iter))); } return res; } bool SphereVolWithJointSet::isIn(const Sphere& S) { double r=S.Radius(); Vector3 p=S.Center(); bool res=(m_sph.getDirDist(S.Center())>S.Radius()); if(res){ // check intersection with joints vector::iterator iter=m_joints.begin(); double dist=2*r; while((iter!=m_joints.end()) && res){ dist=iter->getDist(p); res=(dist>r); iter++; } } return res; } void SphereVolWithJointSet::addJoints(const TriPatchSet& t) { for(vector::const_iterator iter=t.triangles_begin(); iter!=t.triangles_end(); iter++){ m_joints.push_back(*iter); } } ostream& operator << (ostream& ost,const SphereVolWithJointSet& T) { return ost; } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������GenGeo-1.2/src/SphereVolWithJointSet.h��������������������������������������������������������������0000644�0000000�0000000�00000002630�12533740504�016035� 0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __SPHERE_VOL_WITH_JOINT_SET_H #define __SPHERE_VOL_WITH_JOINT_SET_H // --- Project includes --- #include "SphereVol.h" #include "geometry/SphereIn.h" #include "TriPatchSet.h" // --- STL includes --- #include using std::map; class SphereVolWithJointSet : public SphereVol { protected: vector m_joints; public: SphereVolWithJointSet(); SphereVolWithJointSet(const Vector3&,double); virtual ~SphereVolWithJointSet(){}; void addJoints(const TriPatchSet&); virtual const map getClosestObjects(const Vector3&,int) const; virtual bool isIn(const Sphere&); friend ostream& operator << (ostream&,const SphereVolWithJointSet&); }; #endif // __SPHERE_VOL_WITH_JOINT_SET_H ��������������������������������������������������������������������������������������������������������GenGeo-1.2/src/TriBox.cc����������������������������������������������������������������������������0000644�0000000�0000000�00000007430�12533740504�013162� 0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "TriBox.h" //-- system includes -- #include using std::rand; // --- STL includes --- #include #include using std::make_pair; using std::map; //--- IO includes --- #include TriBox::TriBox() {} double TriBox::m_random(double imin,double imax)const { return imin+((imax-imin)*((double)(rand())/(double)(RAND_MAX))); } TriBox::TriBox(const Vector3& pmin,const Vector3& pmax,bool inverted):m_pmin(pmin),m_pmax(pmax) { m_inverted=inverted; } /*! add a plane to the box \param P the plane */ void TriBox::addPlane(const Plane& P) { m_planes.push_back(P); } pair TriBox::getBoundingBox() { return make_pair(m_pmin,m_pmax); } Vector3 TriBox::getAPoint(int)const { double px,py,pz; pz=m_random(m_pmin.z(),m_pmax.z()); py=m_random(m_pmin.y(),m_pmax.y()); double dy=m_pmax.y()-m_pmin.y(); double y=py-m_pmin.y(); double ry=m_inverted ? y/dy : 1.0-(y/dy); double dx=(m_pmax.x()-m_pmin.x())/2.0; double xmin=(m_pmin.x()+m_pmax.x())/2.0-dx*ry; double xmax=(m_pmin.x()+m_pmax.x())/2.0+dx*ry; px=m_random(xmin,xmax); return Vector3(px,py,pz); } Plane TriBox::getClosestPlane(const Vector3& p) { vector::iterator PL=m_planes.begin(); double dist=PL->getDist(p); for(vector::iterator iter=m_planes.begin(); iter!=m_planes.end(); iter++){ double ndist=iter->getDist(p); if(ndist TriBox::getClosestObjects(const Vector3& p,int nmax) const { map res; for(vector::const_iterator iter=m_planes.begin(); iter!=m_planes.end(); iter++){ double ndist=iter->getDist(p); res.insert(make_pair(ndist,&(*iter))); } return res; } bool TriBox::isIn(const Vector3& V) const { bool res; res=(V.z()m_pmin.z()); if((V.y()m_pmin.y())){ double dy=m_pmax.y()-m_pmin.y(); double y=V.y()-m_pmin.y(); double ry=m_inverted ? y/dy : 1.0-(y/dy); double dx=(m_pmax.x()-m_pmin.x())/2.0; double xmin=(m_pmin.x()+m_pmax.x())/2.0-dx*ry; double xmax=(m_pmin.x()+m_pmax.x())/2.0+dx*ry; // std::cout << "y: " << V.Y() << " dy: " << dy << " ry: " << ry << " dx: " << dx << " xmin: " << xmin << "xmax: " << xmax << std::endl; res=res && (V.x()xmin); } else { res=false; } return res; } bool TriBox::isIn(const Sphere& S) { double r=S.Radius(); Vector3 p=S.Center(); bool res=isIn(p); vector::iterator iter=m_planes.begin(); // std::cout << "p: " << p<< " r: " << r; double dist=2*r; while((iter!=m_planes.end()) && (dist>r)){ dist=iter->getDist(p); // std::cout << " dist: " << dist ; iter++; } // std::cout << std::endl; return res && (dist>r); } /*! Check if sphere is fully outside volume \param S the sphere \warning DUMMY IMPLEMENTATION */ bool TriBox::isFullyOutside(const Sphere& S) { return true; } ostream& operator<< (ostream& ost, const TriBox& L) { ost << L.m_pmin << " to " << L.m_pmax; return ost; } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������GenGeo-1.2/src/TriBox.h�����������������������������������������������������������������������������0000644�0000000�0000000�00000003252�12533740504�013022� 0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __TRIBOX_H #define __TRIBOX_H // --- Project includes --- #include "AVolume3D.h" #include "geometry/Plane.h" // --- STL includes --- #include #include using std::vector; using std::map; class TriBox : public AVolume3D { protected: vector m_planes; Vector3 m_pmin; Vector3 m_pmax; bool m_inverted; double m_random(double,double)const; public: TriBox(); TriBox(const Vector3&,const Vector3&,bool inverted=false); virtual ~TriBox(){}; void addPlane(const Plane&); virtual pair getBoundingBox(); virtual Vector3 getAPoint(int)const; virtual bool hasPlane() const{return (m_planes.size()>0);}; virtual Plane getClosestPlane(const Vector3&); virtual const map getClosestObjects(const Vector3&,int) const; virtual bool isIn(const Vector3&) const; virtual bool isIn(const Sphere&); virtual bool isFullyOutside(const Sphere&); friend ostream& operator<< (ostream&, const TriBox&); }; #endif // __TRIBOX_H ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������GenGeo-1.2/src/TriPatchSet.cc�����������������������������������������������������������������������0000644�0000000�0000000�00000004104�12533740504�014140� 0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "TriPatchSet.h" TriPatchSet::TriPatchSet() { m_bbx_set=false; } /*! check if a line between the given points crosses the triangle and return the triangle tag, -1 otherwise \param p1 \param p2 */ int TriPatchSet::isCrossing(const Vector3& p1, const Vector3& p2) const { int res=-1; vector::const_iterator iter=m_triangles.begin(); while((iter!=m_triangles.end()) && (res==-1)){ if(iter->crosses(p1,p2)) res=iter->getTag(); iter++; } return res; } void TriPatchSet::addTriangle(const Vector3& p1, const Vector3& p2, const Vector3& p3,int tag) { Triangle3D T=Triangle3D(p1,p2,p3,tag); Vector3 tmin=T.getMinPoint(); Vector3 tmax=T.getMaxPoint(); m_triangles.push_back(Triangle3D(p1,p2,p3,tag)); // update bounding box if(m_bbx_set){ // already have bbx -> update m_pmin.X()=(m_pmin.X() < tmin.X()) ? m_pmin.X() : tmin.X(); m_pmin.Y()=(m_pmin.Y() < tmin.Y()) ? m_pmin.Y() : tmin.Y(); m_pmin.Z()=(m_pmin.Z() < tmin.Z()) ? m_pmin.Z() : tmin.Z(); m_pmax.X()=(m_pmax.X() > tmax.X()) ? m_pmax.X() : tmax.X(); m_pmax.Y()=(m_pmax.Y() > tmax.Y()) ? m_pmax.Y() : tmax.Y(); m_pmax.Z()=(m_pmax.Z() > tmax.Z()) ? m_pmax.Z() : tmax.Z(); } else { // no bbx yet -> initialize m_pmin=tmin; m_pmax=tmax; m_bbx_set=true; } //std::cout << "patch set size: " << m_triangles.size() //<< " bbx: " << m_pmin << " - " << m_pmax << std::endl; } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������GenGeo-1.2/src/TriPatchSet.h������������������������������������������������������������������������0000644�0000000�0000000�00000003350�12533740504�014004� 0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __TRIPATCHSET_H #define __TRIPATCHSET_H // project includes #include "JointSet.h" #include "geometry/Triangle3D.h" #include "util/vector3.h" // STL includes #include #include using std::vector; using std::pair; using std::make_pair; /*! class to store joints as a collection of triangular patches and check if a bond crosses one of them */ class TriPatchSet : public JointSet { private: vector m_triangles; Vector3 m_pmin; Vector3 m_pmax; bool m_bbx_set; public: TriPatchSet(); virtual ~TriPatchSet(){}; virtual int isCrossing(const Vector3&, const Vector3&) const; void addTriangle(const Vector3&, const Vector3&, const Vector3&,int); Vector3 getMinPoint() const {return m_pmin;}; Vector3 getMaxPoint() const {return m_pmax;}; vector::const_iterator triangles_begin() const {return m_triangles.begin();}; vector::const_iterator triangles_end() const {return m_triangles.end();}; pair getBoundingBox() {return make_pair(m_pmin,m_pmax);}; }; #endif // __TRIPATCHSET_H ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������GenGeo-1.2/src/TriWithLines2D.cc��������������������������������������������������������������������0000644�0000000�0000000�00000013427�12533740504�014531� 0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "TriWithLines2D.h" //-- system includes -- #include using std::rand; // --- STL includes --- #include #include using std::make_pair; using std::map; //--- IO includes --- #include /*! helper function, return random value between min & max */ double TriWithLines2D::m_random(double imin,double imax) const { return imin+((imax-imin)*((double)(rand())/(double)(RAND_MAX))); } TriWithLines2D::TriWithLines2D() {} /*! Construct Triangle \param p0 first corner of triangle box \param p1 second corner of triangle box \param p2 third corner of triangle box */ TriWithLines2D::TriWithLines2D(const Vector3& p0,const Vector3& p1,const Vector3& p2) : m_p0(p0),m_p1(p1),m_p2(p2) { Vector3 pmin, pmax; double minV,maxV; Line2D l; int i; for (i=0;i<3;i++) { minV=p0[i]; maxV=p0[i]; if (p1[i] < minV) minV = p1[i]; if (p1[i] > maxV) maxV = p1[i]; if (p2[i] < minV) minV = p2[i]; if (p2[i] > maxV) maxV = p2[i]; pmin[i] = minV; pmax[i] = maxV; } m_pmin=(pmin); m_pmax=(pmax); m_a0=((p1[1] - p0[1])/(p1[0]-p0[0])); m_b0=(1.0); m_c0=(p0[1] - m_a0*p0[0]); m_a1=((p2[1] - p1[1])/(p2[0]-p1[0])); m_b1=(1.0); m_c1=(p1[1] - m_a1*p1[0]); m_a2=((p0[1] - p2[1])/(p0[0]-p2[0])); m_b2=(1.0); m_c2=(p2[1] - m_a2*p2[0]); l = Line2D(p0,p1); addLine(l); l = Line2D(p1,p2); addLine(l); l = Line2D(p2,p0); addLine(l); } /*! add a line \param l the line */ void TriWithLines2D::addLine(const Line2D& l) { m_lines.push_back(l); } /*! get bounding box */ pair TriWithLines2D::getBoundingBox() { return make_pair(m_pmin,m_pmax); } /*! get point inside the box. The Argument is ignored */ Vector3 TriWithLines2D::getAPoint(int) const { double px,py; bool found_a_point; Vector3 aPoint; found_a_point = false; do { px=m_random(m_pmin.x(),m_pmax.x()); py=m_random(m_pmin.y(),m_pmax.y()); aPoint = Vector3(px,py,0.0); found_a_point = isIn(aPoint); } while (found_a_point==false); return Vector3(px,py,0.0); } /*! Return closest plane to a given point. Assumes that the list of Planes/Lines is not empty. \param p the point \warning check non-empty list of lines (via hasPlane()) before invoking */ Line2D TriWithLines2D::getClosestPlane(const Vector3& p) { std::cout << "getClosestPlane : " << p << std::endl; vector::iterator PL=m_lines.begin(); double dist=PL->getDist(p); for(vector::iterator iter=m_lines.begin(); iter!=m_lines.end(); iter++){ double ndist=iter->getDist(p); std::cout << "Line: " << *iter << " Distance: " << ndist << std::endl; if(ndist TriWithLines2D::getClosestPlanes(const Vector3& p,int nmax) const { map res; for(vector::const_iterator iter=m_lines.begin(); iter!=m_lines.end(); iter++){ double ndist=iter->getDist(p); const Line2D *l=&(*iter); res.insert(make_pair(ndist,l)); } return res; } /*! check if point is inside \param p the point */ bool TriWithLines2D::isIn(const Vector3& p) const { bool inside0,inside1,inside2,inbox; double dp,dv; Vector3 cp,cv; inside0 = false; inside1 = false; inside2 = false; // dp = m_a0*p[0] + m_b0*p[1] + m_c0; // dv = m_a0*m_p2[0] + m_b0*m_p2[1] + m_c0; cp = cross(m_p1-m_p0,p-m_p0); cv = cross(m_p1-m_p0,m_p2-m_p0); dp = cp.z(); dv = cv.z(); if (dp*dv>0.0) inside0=true; // dp = m_a1*p[0] + m_b1*p[1] + m_c1; // dv = m_a1*m_p0[0] + m_b1*m_p0[1] + m_c1; cp = cross(m_p2-m_p1,p-m_p1); cv = cross(m_p2-m_p1,m_p0-m_p1); dp = cp.z(); dv = cv.z(); if (dp*dv>0.0) inside1=true; // dp = m_a2*p[0] + m_b2*p[1] + m_c2; // dv = m_a2*m_p1[0] + m_b2*m_p1[1] + m_c2; cp = cross(m_p0-m_p2,p-m_p2); cv = cross(m_p0-m_p2,m_p1-m_p2); dp = cp.z(); dv = cv.z(); if (dp*dv>0.0) inside2=true; inbox = ((p.x()>m_pmin.x()) && (p.x()m_pmin.y()) && (p.y()m_pmin.x()) && (p.x()m_pmin.y()) && (p.y()m_pmin.X()+r) && (p.X()m_pmin.Y()+r) && (p.Y()::iterator iter=m_lines.begin(); double dist=2*r; while(iter!=m_lines.end() && dist>r){ dist=iter->getDist(p); iter++; } return inside && (dist>r); } ostream& operator<< (ostream& ost, const TriWithLines2D& L) { ost << L.m_p0 << " to " << L.m_p1 << " to " << L.m_p2; return ost; } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������GenGeo-1.2/src/TriWithLines2D.h���������������������������������������������������������������������0000644�0000000�0000000�00000004037�12533740504�014370� 0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __TRIWITHLINES2D_H #define __TRIWITHLINES2D_H // --- Project includes --- #include "AVolume2D.h" // --- STL includes --- #include #include // --- IO includes --- #include using std::vector; using std::map; using std::ostream; /*! \class TriWithLines2D A class for the generation of random particles inside a triangle. An arbitrary number of lines can be added to which the particles are fitted. */ class TriWithLines2D : public AVolume2D { protected: Vector3 m_pmin; Vector3 m_pmax; Vector3 m_p0; Vector3 m_p1; Vector3 m_p2; double m_a0,m_a1,m_a2; double m_b0,m_b1,m_b2; double m_c0,m_c1,m_c2; vector m_lines; double m_random(double,double)const; public: TriWithLines2D(); // TriWithLines2D(const Vector3&,const Vector3&); TriWithLines2D(const Vector3&,const Vector3&,const Vector3&); virtual ~TriWithLines2D(){}; void addLine(const Line2D&); virtual pair getBoundingBox(); virtual Vector3 getAPoint(int)const; virtual bool hasPlane() const{return (m_lines.size()>0);}; virtual Line2D getClosestPlane(const Vector3&); virtual const map getClosestPlanes(const Vector3&,int) const; virtual bool isIn(const Vector3&) const; virtual bool isIn(const Sphere&); friend ostream& operator<< (ostream&, const TriWithLines2D&); }; #endif // __TRIWITHLINES2D_H �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������GenGeo-1.2/src/UnionVol.cc��������������������������������������������������������������������������0000644�0000000�0000000�00000010271�12533740504�013521� 0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "UnionVol.h" //--- #include #include using std::cos; using std::sin; // --- STL includes --- #include using std::make_pair; UnionVol::UnionVol() { std::cout << "WARNING: UnionVol is an experimental feature and may not always work as expected. For details see doc/CSG.readme" << std::endl; m_vol1 = NULL; m_vol2 = NULL; } UnionVol::UnionVol(AVolume3D& v1, AVolume3D& v2) { std::cout << "WARNING: UnionVol is an experimental feature and may not always work as expected. For details see doc/CSG.readme" << std::endl; m_vol1 = &v1; m_vol2 = &v2; //std::cout << m_vol1 << std::endl; //std::cout << m_vol2 << std::endl; } pair UnionVol::getBoundingBox() { // BoundingBox is the box containing both volumes pair bbx1=m_vol1->getBoundingBox(); //std::cout << "bbx1 = (" << bbx1.first.X() << " , " << bbx1.first.Y() << " , " << bbx1.first.Z() << ") ; (" << bbx1.second.X() << " , " << bbx1.second.Y() << " , " << bbx1.second.Z() << ")" << std::endl; pair bbx2=m_vol2->getBoundingBox(); //std::cout << "bbx2 = (" << bbx2.first.X() << " , " << bbx2.first.Y() << " , " << bbx2.first.Z() << ") ; (" << bbx2.second.X() << " , " << bbx2.second.Y() << " , " << bbx2.second.Z() << ")" << std::endl; double X0,X1; double Y0,Y1; double Z0,Z1; if (bbx1.first.X() < bbx2.first.X()) { X0 = bbx1.first.X(); } else { X0 = bbx2.first.X(); } if (bbx1.first.Y() < bbx2.first.Y()) { Y0 = bbx1.first.Y(); } else { Y0 = bbx2.first.Y(); } if (bbx1.first.Z() < bbx2.first.Z()) { Z0 = bbx1.first.Z(); } else { Z0 = bbx2.first.Z(); } Vector3 minPt = Vector3(X0,Y0,Z0); if (bbx1.second.X() > bbx2.second.X()) { X1 = bbx1.second.X(); } else { X1 = bbx2.second.X(); } if (bbx1.second.Y() > bbx2.second.Y()) { Y1 = bbx1.second.Y(); } else { Y1 = bbx2.second.Y(); } if (bbx1.second.Z() > bbx2.second.Z()) { Z1 = bbx1.second.Z(); } else { Z1 = bbx2.second.Z(); } Vector3 maxPt = Vector3(X1,Y1,Z1); //std::cout << "minPt = (" << X0 << " , " << Y0 << " , " << Z0 << ")" << std::endl; //std::cout << "maxPt = (" << X1 << " , " << Y1 << " , " << Z1 << ")" << std::endl; return make_pair(minPt,maxPt); } Vector3 UnionVol::getAPoint(int ivol) const { double r=((double)(rand())/(double)(RAND_MAX)); Vector3 aPoint; if (r < 0.5) { //if (ivol == 0) { aPoint = m_vol1->getAPoint(ivol); } else { aPoint = m_vol2->getAPoint(ivol); } return aPoint; } const map UnionVol::getClosestObjects(const Vector3& P,int ival) const { map res; map res2; if (!m_vol2->isIn(P)) { res = m_vol1->getClosestObjects(P,ival); } if (!m_vol1->isIn(P)) { res2 = m_vol2->getClosestObjects(P,ival); } res.insert(res2.begin(), res2.end()); return res; } bool UnionVol::isIn(const Vector3& P) const { bool res = false; if ((m_vol1->isIn(P)) || (m_vol2->isIn(P))) { res = true; } return res; } bool UnionVol::isIn(const Sphere& S) { bool res = false; if ((m_vol1->isIn(S)) || (m_vol2->isIn(S))) { res = true; } return res; } /*! Check if sphere is fully outside the volume. Tests if the sphere is outside both subvolumes. \param S the sphere */ bool UnionVol::isFullyOutside(const Sphere& S) { return m_vol1->isFullyOutside(S) && m_vol2->isFullyOutside(S); } ostream& operator << (ostream& ost,const UnionVol& T) { return ost; } ���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������GenGeo-1.2/src/UnionVol.h���������������������������������������������������������������������������0000644�0000000�0000000�00000002726�12533740504�013371� 0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __UNION_VOLUME_SET_H #define __UNION_VOLUME_SET_H // --- Project includes --- #include "AVolume3D.h" // --- STL includes --- #include using std::map; class UnionVol : public AVolume3D { protected: AVolume3D* m_vol1; AVolume3D* m_vol2; public: UnionVol (); UnionVol (AVolume3D& , AVolume3D&); virtual ~UnionVol (){}; virtual const map getClosestObjects(const Vector3&,int) const; virtual pair getBoundingBox(); virtual Vector3 getAPoint(int) const; virtual bool isIn(const Vector3&) const; virtual bool isIn(const Sphere&); virtual bool isFullyOutside(const Sphere&); virtual int getNumberSubVolumes()const{return 2;}; friend ostream& operator << (ostream&,const UnionVol&); }; #endif // __UNION_VOLUME_SET_H ������������������������������������������GenGeo-1.2/src/granular_gouge.cc��������������������������������������������������������������������0000644�0000000�0000000�00000022654�12533740504�014761� 0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "granular_gouge.h" // --- project includes --- #include "BoxWithPlanes3D.h" #include "TriBox.h" #include "Plane.h" #include "MNTable3D.h" #include "SphereVol.h" #include "src/InsertGenerator3D.h" /*! \param NT \param G \param xt total x-dim \param yt total y-dim \param zt total z-dim \param y0 y-offset \param nr nr raised ridges \param yr height of ridges */ void generate_upper_rough_block(MNTable3D* NT, AGenerator3D* G, double xt, double yt, double zt, double y0, int nr, double yr) { Vector3 min=Vector3(0.0,y0,0.0); Vector3 min_2=Vector3(0.0,y0+yr,0.0); Vector3 max=Vector3(xt,y0+yt,zt); double xr=xt/(2.0*double(nr)); Plane top_plane=Plane(max,Vector3(0.0,-1.0,0.0)); Plane bottom_plane_1=Plane(min,Vector3(0.0,1.0,0.0)); Plane bottom_plane_2=Plane(min_2,Vector3(0.0,1.0,0.0)); Plane front_plane=Plane(min,Vector3(0.0,0.0,1.0)); Plane back_plane=Plane(max,Vector3(0.0,0.0,-1.0)); Plane left_plane=Plane(min,Vector3(1.0,0.0,0.0)); Plane right_plane=Plane(max,Vector3(-1.0,0.0,0.0)); Vector3 diff(1.0,0.0,0.0); BoxWithPlanes3D Box(min_2-diff,max+diff); Box.addPlane(top_plane); Box.addPlane(bottom_plane_2); Box.addPlane(front_plane); Box.addPlane(back_plane); Box.addPlane(left_plane); Box.addPlane(right_plane); G->generatePacking(&Box,NT,0); if(yt>0.0){ for(int i=0;igeneratePacking(&RBox,NT,0); } } } /*! \param NT \param G \param xt total x-dim \param yt total y-dim \param zt total z-dim \param y0 y-offset \param nr nr raised ridges \param yr height of ridges */ void generate_lower_rough_block(MNTable3D* NT, AGenerator3D* G, double xt, double yt, double zt, double y0, int nr, double yr) { Vector3 min=Vector3(0.0,y0,0.0); Vector3 max_2=Vector3(xt,y0+(yt-yr),zt); Vector3 max=Vector3(xt,y0+yt,zt); double xr=xt/(2.0*double(nr)); Plane top_plane=Plane(max,Vector3(0.0,-1.0,0.0)); Plane top_plane_2=Plane(max_2,Vector3(0.0,-1.0,0.0)); Plane bottom_plane=Plane(min,Vector3(0.0,1.0,0.0)); Plane front_plane=Plane(min,Vector3(0.0,0.0,1.0)); Plane back_plane=Plane(max,Vector3(0.0,0.0,-1.0)); Plane left_plane=Plane(min,Vector3(1.0,0.0,0.0)); Plane right_plane=Plane(max,Vector3(-1.0,0.0,0.0)); Vector3 diff(1.0,0.0,0.0); BoxWithPlanes3D Box(min-diff,max_2+diff); Box.addPlane(top_plane_2); Box.addPlane(bottom_plane); Box.addPlane(front_plane); Box.addPlane(back_plane); Box.addPlane(left_plane); Box.addPlane(right_plane); G->generatePacking(&Box,NT,0); if(yt>0.0){ for(int i=0;igeneratePacking(&RBox,NT,0); } } } /*! \param NT \param G \param xt total x-dim \param yt total y-dim \param zt total z-dim \param y0 y-offset \param nr nr raised ridges \param yr height of ridges */ void generate_upper_tri_rough_block(MNTable3D* NT, AGenerator3D* G, double xt, double yt, double zt, double y0, int nr, double yr) { Vector3 min=Vector3(0.0,y0,0.0); Vector3 min_2=Vector3(0.0,y0+yr,0.0); Vector3 max=Vector3(xt,y0+yt,zt); double xr=xt/double(nr); Plane top_plane=Plane(max,Vector3(0.0,-1.0,0.0)); Plane bottom_plane_1=Plane(min,Vector3(0.0,1.0,0.0)); Plane bottom_plane_2=Plane(min_2,Vector3(0.0,1.0,0.0)); Plane front_plane=Plane(min,Vector3(0.0,0.0,1.0)); Plane back_plane=Plane(max,Vector3(0.0,0.0,-1.0)); // Plane left_plane=Plane(min,Vector3(1.0,0.0,0.0)); // Plane right_plane=Plane(max,Vector3(-1.0,0.0,0.0)); Vector3 diff(1.0,0.0,0.0); BoxWithPlanes3D Box(min_2-diff,max+diff); Box.addPlane(top_plane); Box.addPlane(bottom_plane_2); Box.addPlane(front_plane); Box.addPlane(back_plane); // Box.addPlane(left_plane); // Box.addPlane(right_plane); G->generatePacking(&Box,NT,0); for(int i=0;igeneratePacking(&RBox,NT,0); } NT->tagParticlesAlongPlane(top_plane,0.5,3,0); } /*! \param NT \param G \param xt total x-dim \param yt total y-dim \param zt total z-dim \param y0 y-offset \param nr nr raised ridges \param yr height of ridges */ void generate_lower_tri_rough_block(MNTable3D* NT, AGenerator3D* G, double xt, double yt, double zt, double y0, int nr, double yr) { Vector3 min=Vector3(0.0,y0,0.0); Vector3 max_2=Vector3(xt,y0+(yt-yr),zt); Vector3 max=Vector3(xt,y0+yt,zt); double xr=xt/(double(nr)); Plane top_plane=Plane(max,Vector3(0.0,-1.0,0.0)); Plane top_plane_2=Plane(max_2,Vector3(0.0,-1.0,0.0)); Plane bottom_plane=Plane(min,Vector3(0.0,1.0,0.0)); Plane front_plane=Plane(min,Vector3(0.0,0.0,1.0)); Plane back_plane=Plane(max,Vector3(0.0,0.0,-1.0)); // Plane left_plane=Plane(min,Vector3(1.0,0.0,0.0)); // Plane right_plane=Plane(max,Vector3(-1.0,0.0,0.0)); Vector3 diff(1.0,0.0,0.0); BoxWithPlanes3D Box(min-diff,max_2+diff); Box.addPlane(top_plane_2); Box.addPlane(bottom_plane); Box.addPlane(front_plane); Box.addPlane(back_plane); // Box.addPlane(left_plane); // Box.addPlane(right_plane); G->generatePacking(&Box,NT,0); for(int i=0;igeneratePacking(&RBox,NT,0); } NT->tagParticlesAlongPlane(bottom_plane,0.5,4,0); } /*! generate spherical grains in the middle \param NT \param G \param Pmin minimum corner of the gouge box \param Pmax maximum corner of the gouge box \param grmin minimun grain radius \param grmax maximum grain radius \param gntry nr. of tries for grain fitting */ void generate_granular_gouge(MNTable3D* NT, AGenerator3D* G, const Vector3& Pmin, const Vector3& Pmax, double grmin, double grmax, int gntry) { std::cout << "Granular Gouge: " << Pmin << " - " << Pmax << " " << grmin << " " << grmax << " " << gntry << std::endl; // == stage 1 - generate grains == // -- setup auxillary Table,Volume and Generator MNTable3D T_aux(Pmin,Pmax,2.1*grmax,1); InsertGenerator3D G_aux(grmin,grmax,gntry,1000,1e-5); BoxWithPlanes3D V_aux(Pmin,Pmax); // -- generate grains G_aux.generatePacking(&V_aux,&T_aux,0); // -- extract grains vector grain_sph=T_aux.getAllSpheresFromGroup(0); // == stage 2 - fill grains == // -- get nr. of grains int ngr=grain_sph.size(); std::cout << " found " << ngr << " grains" << std:: endl; // -- grow nr. of particle groups in main NTable NT->GrowNGroups(1+ngr); // -- for each grain, do filling int ggid=1; // group id for(vector::iterator iter=grain_sph.begin(); iter!=grain_sph.end(); iter++){ // -- setup sphere volume SphereVol S=SphereVol((*iter)->Center(),(*iter)->Radius()); // -- generate packing G->generatePacking(&S,NT,ggid); // -- generate bonds NT->generateBonds(ggid,1e-5,1); ggid++; } } ������������������������������������������������������������������������������������GenGeo-1.2/src/granular_gouge.h���������������������������������������������������������������������0000644�0000000�0000000�00000002454�12533740504�014617� 0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __GRANULAR_GOUGE_H #define __GRANULAR_GOUGE_H #include "AGenerator3D.h" #include "MNTable3D.h" void generate_upper_rough_block(MNTable3D*,AGenerator3D*,double,double,double,double,int,double); void generate_lower_rough_block(MNTable3D*,AGenerator3D*,double,double,double,double,int,double); void generate_upper_tri_rough_block(MNTable3D*,AGenerator3D*,double,double,double,double,int,double); void generate_lower_tri_rough_block(MNTable3D*,AGenerator3D*,double,double,double,double,int,double); void generate_granular_gouge(MNTable3D*,AGenerator3D*,const Vector3&,const Vector3&,double,double,int); #endif // __GRANULAR_GOUGE_H ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������GenGeo-1.2/src/main.cc������������������������������������������������������������������������������0000644�0000000�0000000�00000021522�12533740504�012675� 0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// /*! \file main.cc $Revision:$ $Date:$ */ #include "geometry/Sphere.h" #include "geometry/Line2D.h" #include "geometry/LineSegment2D.h" #include "util/vector3.h" #include "MNTable2D.h" #include "MNTable3D.h" #include "CircMNTable3D.h" #include "FullCircMNTable3D.h" #include "CircMNTable2D.h" #include "CircMNTableXY2D.h" #include "InsertGenerator2D.h" #include "HexAggregateInsertGenerator2D.h" #include "HGrainGenerator.h" #include "InsertGenerator3D.h" #include "BoxWithLines2D.h" #include "BoxWithLines2DSubVol.h" #include "BoxWithPlanes3D.h" #include "CylinderVol.h" #include "DogBone.h" #include "SphereVol.h" #include "TriBox.h" // --- IO includes --- #include using std::cout; using std::cout; using std::endl; // -- System includes -- #include #include #include using std::atoi; using std::atof; using std::sqrt; int main(int argc, char** argv) { int ret=0; double size=atof(argv[1]); int ntry=atoi(argv[2]); double rmin=atof(argv[3]); int outputstyle=atoi(argv[4]); int dim=atoi(argv[5]); double vol; // seed RNG struct timeval tv; gettimeofday(&tv,NULL); int random_seed=tv.tv_usec; srand(random_seed); if(dim==2){ double ratio=atof(argv[6]); double xsize=ratio*size; double ysize=size; MNTable2D T(Vector3(0.0,0.0,0.0),Vector3(xsize,ysize,0.0),2.5,1); Vector3 min=Vector3(0.0,0.0,0.0); Vector3 max=Vector3(xsize,ysize,0.0); MNTable2D::SetOutputStyle(outputstyle); InsertGenerator2D *G=new InsertGenerator2D(rmin,1.0,ntry,10000,1e-7); BoxWithLines2D Box(Vector3(0.0,0.0,0.0),Vector3(xsize,ysize,0.0)); Line2D top_line(Vector3(xsize,0.0,0.0),min); Line2D bottom_line(max,Vector3(0.0,ysize,0.0)); Line2D left_line(Vector3(xsize,0.0,0.0),max); Line2D right_line(min,Vector3(0.0,ysize,0.0)); Box.addLine(top_line); Box.addLine(bottom_line); Box.addLine(left_line); Box.addLine(right_line); G->generatePacking(&Box,&T,0,0); T.generateBonds(0,1e-5,0); T.tagParticlesAlongLineWithMask(left_line,0.5,4,4,0); T.tagParticlesAlongLineWithMask(right_line,0.5,8,8,0); vol=xsize*ysize; double poros=(vol-T.getSumVolume(0))/vol; cout << "Porosity: " << poros << endl; cout << T << endl; delete G; } else if(dim==3){ // 3D block 1x2x1 double rmax=atof(argv[6]); Vector3 min=Vector3(0.0,0.0,0.0); Vector3 max=Vector3(size,2.0*size,size); MNTable3D T(min,max,2.5*rmax,1); MNTable3D::SetOutputStyle(outputstyle); InsertGenerator3D G(rmin,rmax,ntry,1000,1e-6); BoxWithPlanes3D Box(min,max); Box.addPlane(Plane(min,Vector3(1.0,0.0,0.0))); Box.addPlane(Plane(min,Vector3(0.0,1.0,0.0))); Box.addPlane(Plane(min,Vector3(0.0,0.0,1.0))); Box.addPlane(Plane(max,Vector3(-1.0,0.0,0.0))); Box.addPlane(Plane(max,Vector3(0.0,-1.0,0.0))); Box.addPlane(Plane(max,Vector3(0.0,0.0,-1.0))); G.generatePacking(&Box,&T,0); T.generateBonds(0,1e-5,0); double vol=2.0*size*size*size; double poros=(vol-T.getSumVolume(0))/vol; cout << "Porosity: " << poros << endl; cout << T << endl; } else if(dim==4){ // Cylinder, 3:1 Vector3 orig=Vector3(0.0,0.0,0.0); Vector3 axis=Vector3(0.0,1.0,0.0); Vector3 min=Vector3(-1.0*size,0.0,-1.0*size); Vector3 max=Vector3(size,3.0*size,size); MNTable3D T(min,max,2.2,1); MNTable3D::SetOutputStyle(outputstyle); InsertGenerator3D G(rmin,1.0,ntry,1000,1e-6); CylinderVol Cyl(orig,axis,3.0*size,size); G.generatePacking(&Cyl,&T,0); cout << T << endl; } else if(dim==5){ // Torus, 3:1 double l2=atof(argv[6]); double r2=atof(argv[7]); Vector3 orig=Vector3(0.0,0.0,0.0); Vector3 axis=Vector3(0.0,1.0,0.0); Vector3 min=Vector3(-1.0*size,0.0,-1.0*size); Vector3 max=Vector3(size,3.0*size,size); MNTable3D T(min,max,2.2,1); MNTable3D::SetOutputStyle(outputstyle); InsertGenerator3D G(rmin,1.0,ntry,1000,1e-6); DogBone DB(orig,axis,3.0*size,size,l2,r2); G.generatePacking(&DB,&T,0); cout << T << endl; } else if(dim==6){ // sphere Vector3 orig=Vector3(0.0,0.0,0.0); Vector3 min=Vector3(-1.0*size,-1.0*size,-1.0*size); Vector3 max=Vector3(size,size,size); MNTable3D T(min,max,2.2,1); MNTable3D::SetOutputStyle(outputstyle); InsertGenerator3D G(rmin,1.0,ntry,1000,1e-6); SphereVol Sph(orig,size); G.generatePacking(&Sph,&T,0); cout << T << endl; } else if(dim==7){ Vector3 min=Vector3(0.0,0.0,0.0); Vector3 max=Vector3(size,size,size); MNTable3D T(min,max,2.5,1); MNTable3D::SetOutputStyle(outputstyle); InsertGenerator3D G(rmin,1.0,ntry,1000,1e-6); TriBox Box(min,max); Box.addPlane(Plane(min,Vector3(0.0,1.0,0.0))); // bottom Box.addPlane(Plane(min,Vector3(0.0,0.0,1.0))); // front Box.addPlane(Plane(max,Vector3(0.0,0.0,-1.0))); // back double dx=(max-min).X(); double dy=(max-min).Y(); Box.addPlane(Plane(min,(Vector3(dy,-0.5*dx,0.0)).unit())); // top left Box.addPlane(Plane(max-Vector3(dx/2.0,0.0,0.0),(Vector3(-1.0*dy,-0.5*dx,0.0)).unit())); // top right G.generatePacking(&Box,&T,0); T.generateBonds(0,1e-5,0); cout << T << endl; } else if(dim==8){ Vector3 min=Vector3(0.0,0.0,0.0); Vector3 max=Vector3(size,size,size); MNTable3D T(min,max,2.5,1); MNTable3D::SetOutputStyle(outputstyle); InsertGenerator3D G(rmin,1.0,ntry,1000,1e-6); TriBox Box(min,max,true); Box.addPlane(Plane(max,Vector3(0.0,-1.0,0.0))); // top Box.addPlane(Plane(min,Vector3(0.0,0.0,1.0))); // front Box.addPlane(Plane(max,Vector3(0.0,0.0,-1.0))); // back double dx=(max-min).X(); double dy=(min-max).Y(); Box.addPlane(Plane(min+Vector3(dx/2.0,0.0,0.0),(Vector3(dy,-0.5*dx,0.0)).unit())); // top left Box.addPlane(Plane(max,(Vector3(-1.0*dy,-0.5*dx,0.0)).unit())); // top right G.generatePacking(&Box,&T,0); T.generateBonds(0,1e-5,0); cout << T << endl; } else if(dim==9){ CircMNTable2D T(Vector3(0.0,0.0,0.0),Vector3(size,size,0.0),2.5,1); Vector3 min=Vector3(0.0,0.0,0.0); Vector3 max=Vector3(size,size,0.0); CircMNTable2D::SetOutputStyle(outputstyle); HexAggregateInsertGenerator2D *G=new HexAggregateInsertGenerator2D(rmin,1.0,ntry,1000,1e-6); BoxWithLines2DSubVol Box(Vector3(-0.5,0.0,0.0),Vector3(size+0.5,size,0.0),10.0,10.0); Line2D top_line(Vector3(size,0.0,0.0),min); Line2D bottom_line(max,Vector3(0.0,size,0.0)); Box.addLine(top_line); Box.addLine(bottom_line); G->generatePacking(&Box,&T,0,0); T.tagParticlesAlongLineWithMask(top_line,0.5,4,4,0); T.tagParticlesAlongLineWithMask(bottom_line,0.5,8,8,0); vol=size*size; double poros=(vol-T.getSumVolume(0))/vol; cout << "Porosity: " << poros << endl; cout << T << endl; delete G; } else if(dim==20){ // hex grain regular double xsize=size; double ysize=size; MNTable2D T(Vector3(0.0,0.0,0.0),Vector3(xsize,ysize,0.0),2.5,1); Vector3 min=Vector3(0.0,0.0,0.0); Vector3 max=Vector3(xsize,ysize,0.0); CircMNTable2D::SetOutputStyle(outputstyle); HGrainGenerator2D *G=new HGrainGenerator2D(rmin); BoxWithLines2D Box(Vector3(0.0,0.0,0.0),Vector3(xsize,ysize,0.0)); Line2D top_line(Vector3(xsize,0.0,0.0),min); Line2D bottom_line(max,Vector3(0.0,ysize,0.0)); Line2D left_line(Vector3(xsize,0.0,0.0),max); Line2D right_line(min,Vector3(0.0,ysize,0.0)); Box.addLine(top_line); Box.addLine(bottom_line); Box.addLine(left_line); Box.addLine(right_line); G->generatePacking(&Box,&T,0,0); T.generateBonds(0,1e-5,0); T.tagParticlesAlongLineWithMask(top_line,5.0,4,4,0); T.tagParticlesAlongLineWithMask(bottom_line,5.0,8,8,0); T.tagParticlesAlongLineWithMask(left_line,8.0,16,16,0); T.tagParticlesAlongLineWithMask(right_line,8.0,32,32,0); double ldx=0.5*ysize; double ldy=(sqrt(3.0)/2.0)*ldx; double lx0=atof(argv[6]); double ly0=atof(argv[7]); LineSegment2D breakLine(Vector3(lx0,ly0,0.0),Vector3(lx0-ldx,ly0+ldy,0.0)); T.breakBondsAlongLineSegment(breakLine,1.0,0,0); vol=xsize*ysize; double poros=(vol-T.getSumVolume(0))/vol; cout << "Porosity: " << poros << endl; cout << T << endl; delete G; } return ret; } ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������GenGeo-1.2/src/main_gouge.cc������������������������������������������������������������������������0000644�0000000�0000000�00000004113�12533740504�014060� 0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "geometry/Sphere.h" #include "util/vector3.h" #include "CircMNTable3D.h" #include "InsertGenerator3D.h" #include "granular_gouge.h" // --- IO includes --- #include using std::cout; using std::cout; using std::endl; // -- System includes -- #include #include using std::atoi; using std::atof; int main(int argc, char** argv) { int ret=0; double xsize=atof(argv[1]); double ysize=atof(argv[2]); double ysize_bdry=atof(argv[3]); double zsize=atof(argv[4]); int nrid=atoi(argv[5]); double rid=atoi(argv[6]); int ntry=atoi(argv[7]); double rmin=atof(argv[8]); double grmin=atof(argv[9]); double grmax=atof(argv[10]); int outputstyle=atoi(argv[11]); // seed RNG struct timeval tv; gettimeofday(&tv,NULL); int random_seed=tv.tv_usec; srand(random_seed); Vector3 min=Vector3(0.0,0.0,0.0); Vector3 max=Vector3(xsize,ysize,zsize); Vector3 gmin=Vector3(0.0,ysize_bdry,0.0); Vector3 gmax=Vector3(xsize,ysize-ysize_bdry,zsize); CircMNTable3D T(min,max,2.5,3); CircMNTable3D::SetOutputStyle(outputstyle); InsertGenerator3D G(rmin,1.0,ntry,1000,1e-6); generate_upper_tri_rough_block(&T,&G,xsize,ysize_bdry,zsize,ysize-ysize_bdry,nrid,rid); generate_lower_tri_rough_block(&T,&G,xsize,ysize_bdry,zsize,0.0,nrid,rid); generate_granular_gouge(&T,&G,gmin,gmax,grmin,grmax,ntry); T.generateBonds(0,1e-5,0); cout << T << endl; return ret; } �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������GenGeo-1.2/src/main_gouge.d�������������������������������������������������������������������������0000644�0000000�0000000�00000000515�12533740504�013720� 0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ src/main_gouge.d src/main_gouge.o: src/main_gouge.cc geometry/Sphere.h \ geometry/AGeometricObject.h \ util/vec3.h util/vec3.h src/CircMNTable3D.h src/MNTable3D.h \ src/MNTCell.h \ geometry/Sphere.h geometry/Plane.h src/InsertGenerator3D.h \ src/AGenerator3D.h src/AVolume3D.h src/AVolume.h \ src/granular_gouge.h \ �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������GenGeo-1.2/src/main_hlayer.cc�����������������������������������������������������������������������0000644�0000000�0000000�00000006273�12533740504�014247� 0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "geometry/Sphere.h" #include "util/vector3.h" #include "InsertGenerator2D.h" #include "MNTable2D.h" #include "BoxWithLines2D.h" // --- IO includes --- #include using std::cout; using std::cout; using std::endl; // -- System includes -- #include #include using std::atoi; using std::atof; int main(int argc, char** argv) { int ret=0; double xsize=atof(argv[1]); double ysize=atof(argv[2]); double ysize_cl=atof(argv[3]); int ntry=atoi(argv[4]); double rmin_nb=atof(argv[5]); double rmin_b=atof(argv[6]); double pbond=atof(argv[7]); int outputstyle=atoi(argv[8]); // calc dependent parameters double y_bdry_1=0.5*(ysize-ysize_cl); double y_bdry_2=ysize-y_bdry_1; MNTable2D* T=new MNTable2D(Vector3(0.0,0.0,0.0),Vector3(xsize,ysize,0.0),2.5,1); InsertGenerator2D *GB=new InsertGenerator2D(rmin_b,1.0,ntry,1000,1e-6); InsertGenerator2D *GNB=new InsertGenerator2D(rmin_nb,1.0,ntry,1000,1e-6); // seed RNG struct timeval tv; gettimeofday(&tv,NULL); int random_seed=tv.tv_usec; srand(random_seed); MNTable2D::SetOutputStyle(outputstyle); // center layer (bonded) BoxWithLines2D CenterBox(Vector3(0.0,y_bdry_1,0.0),Vector3(xsize,y_bdry_2,0.0)); CenterBox.addLine(Line2D(Vector3(0.0,y_bdry_1,0.0),Vector3(0.0,y_bdry_2,0.0))); // left CenterBox.addLine(Line2D(Vector3(xsize,y_bdry_1,0.0),Vector3(xsize,y_bdry_2,0.0))); // right CenterBox.addLine(Line2D(Vector3(0.0,y_bdry_1,0.0),Vector3(xsize,y_bdry_1,0.0))); // bottom CenterBox.addLine(Line2D(Vector3(0.0,y_bdry_2,0.0),Vector3(xsize,y_bdry_2,0.0))); // top GB->generatePacking(&CenterBox,T,0,1); T->generateRandomBonds(0,1e-5,pbond,0,1,0); // bottom layer BoxWithLines2D BottomBox(Vector3(0.0,0.0,0.0),Vector3(xsize,y_bdry_1+0.5,0.0)); BottomBox.addLine(Line2D(Vector3(0.0,0.0,0.0),Vector3(0.0,y_bdry_1,0.0))); // left BottomBox.addLine(Line2D(Vector3(xsize,0.0,0.0),Vector3(xsize,y_bdry_1,0.0))); // right BottomBox.addLine(Line2D(Vector3(0.0,0.0,0.0),Vector3(xsize,0.0,0.0))); // bottom GNB->generatePacking(&BottomBox,T,0,2); // top layer BoxWithLines2D TopBox(Vector3(0.0,y_bdry_2-0.5,0.0),Vector3(xsize,ysize,0.0)); TopBox.addLine(Line2D(Vector3(0.0,y_bdry_2,0.0),Vector3(0.0,ysize,0.0))); // left TopBox.addLine(Line2D(Vector3(xsize,y_bdry_2,0.0),Vector3(xsize,ysize,0.0))); // right TopBox.addLine(Line2D(Vector3(0.0,ysize,0.0),Vector3(xsize,ysize,0.0))); // top GNB->generatePacking(&TopBox,T,0,3); cout << *T << endl; delete T; delete GB; delete GNB; return ret; } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������GenGeo-1.2/src/main_hlayer.d������������������������������������������������������������������������0000644�0000000�0000000�00000000554�12533740504�014101� 0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ src/main_hlayer.d src/main_hlayer.o: src/main_hlayer.cc geometry/Sphere.h \ geometry/AGeometricObject.h \ util/vec3.h util/vec3.h src/InsertGenerator2D.h src/AGenerator2D.h \ src/AVolume2D.h src/AVolume.h \ geometry/Line2D.h \ src/MNTable2D.h \ src/MNTCell.h \ geometry/Sphere.h geometry/LineSegment2D.h geometry/Line2D.h \ src/BoxWithLines2D.h ����������������������������������������������������������������������������������������������������������������������������������������������������GenGeo-1.2/src/main_layered.cc����������������������������������������������������������������������0000644�0000000�0000000�00000013125�12533740504�014402� 0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "geometry/Sphere.h" #include "util/vector3.h" #include "InsertGenerator2D.h" #include "HexAggregateInsertGenerator2D.h" #include "CircMNTable2D.h" #include "BoxWithLines2D.h" // --- IO includes --- #include using std::cout; using std::cout; using std::endl; // -- System includes -- #include #include using std::atoi; using std::atof; int main(int argc, char** argv) { int ret=0; double size=atof(argv[1]); int ntry=atoi(argv[2]); double rmin_sand=atof(argv[3]); double rmin_clay=atof(argv[4]); double rmax_clay=atof(argv[5]); int outputstyle=atoi(argv[6]); double sand_layer_thickness=0.425*size; double clay_layer_thickness=0.15*size; double center_box_dim=0.05*size; CircMNTable2D* T=new CircMNTable2D(Vector3(0.0,0.0,0.0),Vector3(size,size,0.0),2.5,1); HexAggregateInsertGenerator2D *G_sand=new HexAggregateInsertGenerator2D(rmin_sand,1.0,ntry,1000,1e-6); InsertGenerator2D *G_clay=new InsertGenerator2D(rmin_clay,rmax_clay,ntry,1000,1e-6); // seed RNG struct timeval tv; gettimeofday(&tv,NULL); int random_seed=tv.tv_usec; srand(random_seed); CircMNTable2D::SetOutputStyle(outputstyle); // clay layer double clay_layer_min=sand_layer_thickness; double clay_layer_max=clay_layer_min+clay_layer_thickness; double clay_box_min= clay_layer_min-rmax_clay; double clay_box_max= clay_layer_max+rmax_clay; BoxWithLines2D ClayBox(Vector3(clay_layer_min,0.0,0.0),Vector3(clay_layer_max,size,0.0)); ClayBox.addLine(Line2D(Vector3(clay_layer_min,0.0,0.0),Vector3(clay_layer_max,0.0,0.0))); // left ClayBox.addLine(Line2D(Vector3(clay_layer_max,size,0.0),Vector3(clay_layer_min,size,0.0))); // right ClayBox.addLine(Line2D(Vector3(clay_layer_max,size,0.0),Vector3(clay_layer_max,0.0,0.0))); // top ClayBox.addLine(Line2D(Vector3(clay_layer_min,size,0.0),Vector3(clay_layer_max,size,0.0))); // right G_clay->generatePacking(&ClayBox,T,0,2); // little center box double cbox_layer_minx=sand_layer_thickness-center_box_dim; double cbox_layer_maxx=sand_layer_thickness+clay_layer_thickness+center_box_dim; double cbox_layer_miny=0.5*size-center_box_dim; double cbox_layer_maxy=0.5*size+center_box_dim; BoxWithLines2D CenterBox(Vector3(cbox_layer_minx,cbox_layer_miny,0.0), Vector3(cbox_layer_maxx,cbox_layer_maxy,0.0)); CenterBox.addLine(Line2D(Vector3(cbox_layer_minx,cbox_layer_miny,0.0), Vector3(cbox_layer_maxx,cbox_layer_miny,0.0))); // left CenterBox.addLine(Line2D(Vector3(cbox_layer_maxx,cbox_layer_maxy,0.0), Vector3(cbox_layer_minx,cbox_layer_maxy,0.0))); // right CenterBox.addLine(Line2D(Vector3(cbox_layer_maxx,cbox_layer_maxy,0.0), Vector3(cbox_layer_maxx,cbox_layer_miny,0.0))); // top CenterBox.addLine(Line2D(Vector3(cbox_layer_minx,cbox_layer_maxy,0.0), Vector3(cbox_layer_maxx,cbox_layer_maxy,0.0))); // right G_clay->generatePacking(&CenterBox,T,0,2); // --- sand layers // layer 1 double sand_layer_min1=0; double sand_layer_max1=sand_layer_thickness; double sand_box_min1=sand_layer_min1-rmin_sand; double sand_box_max1=sand_layer_max1+rmin_sand; BoxWithLines2D SandBox1(Vector3(sand_box_min1,0.0,0.0),Vector3(sand_box_max1,size,0.0)); SandBox1.addLine(Line2D(Vector3(sand_layer_min1,size,0.0),Vector3(sand_layer_min1,0.0,0.0))); // bottom SandBox1.addLine(Line2D(Vector3(sand_layer_min1,0.0,0.0),Vector3(sand_layer_max1,0.0,0.0))); // left SandBox1.addLine(Line2D(Vector3(sand_layer_max1,size,0.0),Vector3(sand_layer_max1,0.0,0.0))); // top SandBox1.addLine(Line2D(Vector3(sand_layer_min1,size,0.0),Vector3(sand_layer_max1,size,0.0))); // right SandBox1.addLine(Line2D(Vector3(0.0,size/2.0,0.0),Vector3(size,size/2.0,0.0))); // middle G_sand->generatePacking(&SandBox1,T,0,1); // layer 2 double sand_layer_min2=sand_layer_thickness+clay_layer_thickness; double sand_layer_max2=size; double sand_box_min2=sand_layer_min2-rmin_sand; double sand_box_max2=sand_layer_max2+rmin_sand; BoxWithLines2D SandBox2(Vector3(sand_box_min2,0.0,0.0),Vector3(sand_box_max2,size,0.0)); SandBox2.addLine(Line2D(Vector3(sand_layer_min2,size,0.0),Vector3(sand_layer_min2,0.0,0.0))); // bottom SandBox2.addLine(Line2D(Vector3(sand_layer_min2,0.0,0.0),Vector3(sand_layer_max2,0.0,0.0))); // left SandBox2.addLine(Line2D(Vector3(sand_layer_max2,size,0.0),Vector3(sand_layer_max2,0.0,0.0))); // top SandBox2.addLine(Line2D(Vector3(sand_layer_min2,size,0.0),Vector3(sand_layer_max2,size,0.0))); // right SandBox2.addLine(Line2D(Vector3(0.0,size/2.0,0.0),Vector3(size,size/2.0,0.0))); // middle G_sand->generatePacking(&SandBox2,T,0,1); T->generateBonds(0,1e-6,0,1,1); Line2D top_line(Vector3(0.0,size,0.0),Vector3(size,size,0.0)); Line2D bottom_line(Vector3(0.0,0.0,0.0),Vector3(size,0.0,0.0)); T->tagParticlesAlongLine(top_line,0.5,4,4,0); T->tagParticlesAlongLine(bottom_line,0.5,8,8,0); cout << *T << endl; delete T; delete G_sand; delete G_clay; return ret; } �������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������GenGeo-1.2/src/main_sbx.cc��������������������������������������������������������������������������0000644�0000000�0000000�00000007304�12533740504�013553� 0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// /*! \file main.cc $Revision:$ $Date:$ */ #include "geometry/Sphere.h" #include "geometry/Line2D.h" #include "geometry/LineSegment2D.h" #include "util/vector3.h" #include "MNTable2D.h" #include "MNTable3D.h" #include "InsertGenerator2D.h" #include "InsertGenerator3D.h" #include "HexAggregateInsertGenerator2D.h" #include "BoxWithLines2D.h" #include "BoxWithPlanes3D.h" // --- IO includes --- #include using std::cout; using std::cout; using std::endl; // -- System includes -- #include #include using std::atoi; using std::atof; int main(int argc, char** argv) { int ret=0; double size=atof(argv[1]); int ntry=atoi(argv[2]); double rmin=atof(argv[3]); int outputstyle=atoi(argv[4]); int dim=atoi(argv[5]); double vol; // seed RNG struct timeval tv; gettimeofday(&tv,NULL); int random_seed=tv.tv_usec; srand(random_seed); if(dim==2){ double ratio=atof(argv[6]); double xsize=ratio*size; double ysize=size; MNTable2D T(Vector3(0.0,0.0,0.0),Vector3(xsize,ysize,0.0),2.5,1); Vector3 min=Vector3(0.0,0.0,0.0); Vector3 max=Vector3(xsize,ysize,0.0); MNTable2D::SetOutputStyle(outputstyle); InsertGenerator2D *G=new InsertGenerator2D(rmin,1.0,ntry,10000,1e-7); BoxWithLines2D Box(Vector3(0.0,0.0,0.0),Vector3(xsize,ysize,0.0)); Line2D bottom_line(Vector3(xsize,0.0,0.0),min); Line2D top_line(max,Vector3(0.0,ysize,0.0)); Line2D left_line(Vector3(xsize,0.0,0.0),max); Line2D right_line(min,Vector3(0.0,ysize,0.0)); Box.addLine(top_line); Box.addLine(bottom_line); Box.addLine(left_line); Box.addLine(right_line); G->generatePacking(&Box,&T,0,0); //T.generateBonds(0,1e-5,0); LineSegment2D bottom_left(Vector3(xsize/2,0.0,0.0),min); LineSegment2D bottom_right(Vector3(xsize,0.0,0.0),Vector3(xsize/2,0.0,0.0)); T.tagParticlesAlongLine(left_line,0.5,4,4,0); T.tagParticlesAlongLine(right_line,0.5,8,8,0); T.tagParticlesAlongLine(bottom_left,0.5,8,8,0); T.tagParticlesAlongLine(bottom_right,0.5,4,4,0); vol=xsize*ysize; double poros=(vol-T.getSumVolume(0))/vol; cout << "Porosity: " << poros << endl; cout << T << endl; delete G; } else if(dim==3){ // 3D block 1x2x1 double rmax=atof(argv[6]); Vector3 min=Vector3(0.0,0.0,0.0); Vector3 max=Vector3(size,2.0*size,size); MNTable3D T(min,max,2.5*rmax,1); MNTable3D::SetOutputStyle(outputstyle); InsertGenerator3D G(rmin,rmax,ntry,1000,1e-6); BoxWithPlanes3D Box(min,max); Box.addPlane(Plane(min,Vector3(1.0,0.0,0.0))); Box.addPlane(Plane(min,Vector3(0.0,1.0,0.0))); Box.addPlane(Plane(min,Vector3(0.0,0.0,1.0))); Box.addPlane(Plane(max,Vector3(-1.0,0.0,0.0))); Box.addPlane(Plane(max,Vector3(0.0,-1.0,0.0))); Box.addPlane(Plane(max,Vector3(0.0,0.0,-1.0))); G.generatePacking(&Box,&T,0); T.generateBonds(0,1e-5,0); double vol=2.0*size*size*size; double poros=(vol-T.getSumVolume(0))/vol; cout << "Porosity: " << poros << endl; cout << T << endl; } return ret; } ����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������GenGeo-1.2/src/main_sbx.d���������������������������������������������������������������������������0000644�0000000�0000000�00000000324�12533740504�013404� 0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������ src/main_sbx.d src/main_sbx.o: src/main_sbx.cc \ util/vec3.h \ geometry/Sphere.h geometry/Line2D.h geometry/LineSegment2D.h \ util/vec3.h \ geometry/Plane.h util/vec3.h geometry/AGeometricObject.h \ ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������GenGeo-1.2/src/module.mk����������������������������������������������������������������������������0000644�0000000�0000000�00000001370�12533740504�013257� 0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������SRC += src/main.cc #SRC += src/main_gouge.cc #SRC += src/main_layered.cc #SRC += src/main_sbx.cc #SRC += src/main_hlayer.cc SRC += src/MNTCell.cc SRC += src/MNTable2D.cc SRC += src/MNTable3D.cc SRC += src/CircMNTable2D.cc SRC += src/CircMNTable3D.cc SRC += src/CircMNTableXY2D.cc SRC += src/FullCircMNTable3D.cc SRC += src/BoxWithLines2D.cc SRC += src/PolygonWithLines2D.cc SRC += src/TriWithLines2D.cc SRC += src/BoxWithLines2DSubVol.cc SRC += src/BoxWithPlanes3D.cc SRC += src/CylinderVol.cc SRC += src/DogBone.cc SRC += src/SphereVol.cc SRC += src/InsertGenerator2D.cc SRC += src/HexAggregateInsertGenerator2D.cc SRC += src/HGrainGenerator.cc SRC += src/InsertGenerator3D.cc SRC += src/granular_gouge.cc SRC += src/TriBox.cc SRC += src/ConvexPolyhedron.cc ������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������GenGeo-1.2/util/module.mk���������������������������������������������������������������������������0000644�0000000�0000000�00000000030�12533740504�013435� 0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������SRC += util/vector3.cpp ��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������GenGeo-1.2/util/vector3.cc��������������������������������������������������������������������������0000644�0000000�0000000�00000002070�12533740504�013521� 0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #include "vector3.h" #include "vector3.hh" const Vector3 Vector3::ZERO = Vector3(0.0, 0.0, 0.0); bool Vector3::operator<(const Vector3& rhs) const { bool res; if(data[0]!=rhs.data[0]) { res=data[0]= 1 #define VECTOR3_INLINE inline #else #define VECTOR3_INLINE #endif #include #include #include //#include "Foundation/Error.h" using std::ostream; using std::istream; using std::string; //class Matrix3; /* class VecErr:public MError { public: VecErr(const string&); virtual ~VecErr(){}; }; */ struct VDMulVadd; struct VDMul; class Vector3 { protected: double data[3]; public: static const Vector3 ZERO; //! The zero vector. // constructors VECTOR3_INLINE Vector3(); VECTOR3_INLINE explicit Vector3(double s); VECTOR3_INLINE Vector3(double,double,double); VECTOR3_INLINE Vector3(const Vector3&); // vec-vec operators VECTOR3_INLINE Vector3& operator=(const Vector3&); VECTOR3_INLINE Vector3& operator=(double s); VECTOR3_INLINE Vector3& operator-=(const Vector3&); VECTOR3_INLINE Vector3& operator+=(const Vector3&); VECTOR3_INLINE Vector3 operator+(const Vector3&) const; VECTOR3_INLINE Vector3 operator-(const Vector3&) const; //wangyc added ! // VECTOR3_INLINE Vector3 operator*(const Matrix3 &m) const; VECTOR3_INLINE double operator*(const Vector3&) const; VECTOR3_INLINE Vector3 operator-() const; // vec-dbl ops VECTOR3_INLINE Vector3 operator*(double) const; VECTOR3_INLINE Vector3& operator*=(double); VECTOR3_INLINE Vector3 operator/(double) const; VECTOR3_INLINE Vector3 operator-(double) const; VECTOR3_INLINE Vector3 operator+(double) const; VECTOR3_INLINE Vector3& operator+=(double); VECTOR3_INLINE Vector3& operator-=(double); // wangyc added ! VECTOR3_INLINE Vector3& operator/=(double); VECTOR3_INLINE double norm() const; VECTOR3_INLINE double wnorm(double,double,double) const; VECTOR3_INLINE double norm2() const; VECTOR3_INLINE double wnorm2(double,double,double) const; VECTOR3_INLINE Vector3 unit() const; // VECTOR3_INLINE Vector3 unit_s() const; //safe version (throw exceptions) VECTOR3_INLINE double max() const; VECTOR3_INLINE double min() const; VECTOR3_INLINE Vector3 rotate(const Vector3 &axis, const Vector3 &axisPt) const; VECTOR3_INLINE bool operator==(const Vector3&) const; VECTOR3_INLINE bool operator!=(const Vector3&) const; VECTOR3_INLINE friend Vector3 cmax(const Vector3&,const Vector3&); VECTOR3_INLINE friend Vector3 cmin(const Vector3&,const Vector3&); VECTOR3_INLINE friend Vector3 cross(const Vector3&,const Vector3&); VECTOR3_INLINE friend double dot(const Vector3&,const Vector3&); VECTOR3_INLINE friend Vector3 operator*(double,const Vector3&); //n+1-ary operators VECTOR3_INLINE void mul_add_and_assign(const Vector3*,const Vector3*,const double&); VECTOR3_INLINE void mul_and_assign(const Vector3*,const double&); VECTOR3_INLINE Vector3(const VDMulVadd&); VECTOR3_INLINE Vector3& operator=(const VDMulVadd&); VECTOR3_INLINE Vector3(const VDMul&); VECTOR3_INLINE Vector3& operator=(const VDMul&); //access stuff VECTOR3_INLINE void set_x(double x) {data[0] = x;} VECTOR3_INLINE void set_y(double y) {data[1] = y;} VECTOR3_INLINE void set_z(double z) {data[2] = z;} // void set_xyz(double x, double y, double z) // { data[0] = x; data[1] = y; data[2] = z;} VECTOR3_INLINE double& X() {return data[0];}; VECTOR3_INLINE double& Y() {return data[1];}; VECTOR3_INLINE double& Z() {return data[2];}; VECTOR3_INLINE double x() const {return data[0];}; VECTOR3_INLINE double y() const {return data[1];}; VECTOR3_INLINE double z() const {return data[2];}; VECTOR3_INLINE const double &operator[](int i) const {return data[i];} VECTOR3_INLINE double& operator[](int i) {return data[i];} // in/output VECTOR3_INLINE friend ostream& operator << (ostream&,const Vector3&); VECTOR3_INLINE friend istream& operator >> (istream&,Vector3&); // comparison -> enable to use of Vector3 as key in STL map and set bool operator<(const Vector3&) const; // friend class Matrix3; }; VECTOR3_INLINE Vector3 comp_max(const Vector3&,const Vector3&); //!< per component maximum VECTOR3_INLINE Vector3 comp_min(const Vector3&,const Vector3&); //!< per component minimum #if DO_INLINE_VECTOR3 >= 1 #include "vector3.hh" #endif #endif // __VECTOR3_H �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������GenGeo-1.2/util/vector3.hh��������������������������������������������������������������������������0000644�0000000�0000000�00000017537�12533740504�013551� 0����������������������������������������������������������������������������������������������������ustar �����������������������������������������������������������������0000000�0000000������������������������������������������������������������������������������������������������������������������������������������������������������������������������///////////////////////////////////////////////////////////// // // // Copyright (c) 2007-2014 by The University of Queensland // // Centre for Geoscience Computing // // http://earth.uq.edu.au/centre-geoscience-computing // // // // Primary Business: Brisbane, Queensland, Australia // // Licensed under the Open Software License version 3.0 // // http://www.opensource.org/licenses/osl-3.0.php // // // ///////////////////////////////////////////////////////////// #ifndef __VECTOR3_HH #define __VECTOR3_HH //#include "Foundation/Matrix3.h" //the error... /* VECTOR3_INLINE VecErr::VecErr(const string& m):MError(m) { message.insert(0,"Vector3 "); } */ // constructors VECTOR3_INLINE Vector3::Vector3() { data[0]=0; data[1]=0; data[2]=0; } VECTOR3_INLINE Vector3::Vector3(double s) { data[0]=s; data[1]=s; data[2]=s; } VECTOR3_INLINE Vector3::Vector3(double a,double b,double c) { data[0]=a; data[1]=b; data[2]=c; } VECTOR3_INLINE Vector3::Vector3(const Vector3& rhs) { data[0]=rhs.data[0]; data[1]=rhs.data[1]; data[2]=rhs.data[2]; } // operators VECTOR3_INLINE Vector3& Vector3::operator=(const Vector3& rhs) { data[0]=rhs.data[0]; data[1]=rhs.data[1]; data[2]=rhs.data[2]; return *this; } VECTOR3_INLINE Vector3& Vector3::operator=(double s) { data[0]=s; data[1]=s; data[2]=s; return *this; } VECTOR3_INLINE Vector3& Vector3::operator-=(const Vector3& rhs) { data[0]-=rhs.data[0]; data[1]-=rhs.data[1]; data[2]-=rhs.data[2]; return *this; } VECTOR3_INLINE Vector3& Vector3::operator+=(const Vector3& rhs) { data[0]+=rhs.data[0]; data[1]+=rhs.data[1]; data[2]+=rhs.data[2]; return *this; } VECTOR3_INLINE Vector3 Vector3::operator+(const Vector3& rhs) const { return Vector3(data[0]+rhs.data[0], data[1]+rhs.data[1], data[2]+rhs.data[2]); } VECTOR3_INLINE Vector3 Vector3::operator-(const Vector3& rhs) const { return Vector3(data[0]-rhs.data[0], data[1]-rhs.data[1], data[2]-rhs.data[2]); } VECTOR3_INLINE Vector3 Vector3::operator-() const { return Vector3( -data[0],-data[1],-data[2] ); } /* VECTOR3_INLINE Vector3 Vector3::operator*(const Matrix3 &m) const { const double x = m(0,0)*data[0] + m(1,0)*data[1] + m(2,0)*data[2]; const double y = m(0,1)*data[0] + m(1,1)*data[1] + m(2,1)*data[2]; const double z = m(0,2)*data[0] + m(1,2)*data[1] + m(2,2)*data[2]; return Vector3(x,y,z); } */ VECTOR3_INLINE double Vector3::operator*(const Vector3& rhs) const { return data[0]*rhs.data[0]+data[1]*rhs.data[1]+data[2]*rhs.data[2]; } VECTOR3_INLINE Vector3 Vector3::operator*(double s) const { return Vector3(data[0]*s,data[1]*s,data[2]*s) ; } VECTOR3_INLINE Vector3& Vector3::operator*=(double rhs) { data[0]*=rhs; data[1]*=rhs; data[2]*=rhs; return *this; } VECTOR3_INLINE Vector3& Vector3::operator/=(double c) { data[0] /= c; data[1] /= c; data[2] /= c; return *this; } VECTOR3_INLINE Vector3 Vector3::operator/(double s) const { return Vector3(data[0]/s,data[1]/s,data[2]/s) ; } VECTOR3_INLINE Vector3 Vector3::operator+(double s) const { return Vector3(data[0]+s, data[1]+s, data[2]+s) ; } VECTOR3_INLINE Vector3 Vector3::operator-(double s) const { return Vector3(data[0]-s, data[1]-s, data[2]-s); } VECTOR3_INLINE Vector3 Vector3::rotate(const Vector3 &axis, const Vector3 &axisPt) const { const double phi = axis.norm(); if (phi > 0.0) { const Vector3 r = *this - axisPt; const Vector3 n = axis/phi; const double cosPhi = cos(phi); const Vector3 rotatedR = r*cosPhi + n*((dot(n, r))*(1-cosPhi)) + cross(r, n)*sin(phi); return rotatedR + axisPt; } return *this; } VECTOR3_INLINE Vector3 &Vector3::operator+=(double s) { data[0] += s; data[1] += s; data[2] += s; return *this; } VECTOR3_INLINE Vector3 &Vector3::operator-=(double s) { data[0] -= s; data[1] -= s; data[2] -= s; return *this; } // vector product // 9 Flops ( 6 mult, 3 sub ) VECTOR3_INLINE Vector3 cross(const Vector3& lhs,const Vector3& rhs) { return Vector3(lhs.data[1]*rhs.data[2]-lhs.data[2]*rhs.data[1], lhs.data[2]*rhs.data[0]-lhs.data[0]*rhs.data[2], lhs.data[0]*rhs.data[1]-lhs.data[1]*rhs.data[0]); } // dot product VECTOR3_INLINE double dot(const Vector3& v1, const Vector3& v2) { return v1.data[0] * v2.data[0] + v1.data[1] * v2.data[1] + v1.data[2] * v2.data[2]; } VECTOR3_INLINE Vector3 operator*(double f,const Vector3& rhs) { return Vector3(f*rhs.data[0], f*rhs.data[1], f*rhs.data[2]); } // euclidian norm // 6 Flops ( 3 mult, 2 add, 1 sqrt ) VECTOR3_INLINE double Vector3::norm() const { return sqrt(data[0]*data[0]+data[1]*data[1]+data[2]*data[2]); } // weighted euclidian norm VECTOR3_INLINE double Vector3::wnorm(double wx, double wy, double wz) const { double dx=data[0]/wx; double dy=data[1]/wy; double dz=data[2]/wz; return sqrt(dx*dx+dy*dy+dz*dz); } // square of weighted euclidian norm VECTOR3_INLINE double Vector3::wnorm2(double wx, double wy, double wz) const { double dx=data[0]/wx; double dy=data[1]/wy; double dz=data[2]/wz; return dx*dx+dy*dy+dz*dz; } // square of the euclidian norm // 5 Flops ( 3 mult, 2 add) VECTOR3_INLINE double Vector3::norm2() const { return data[0]*data[0]+data[1]*data[1]+data[2]*data[2]; } // returns unit vector in direction of the original vector // 9 Flops ( 3 mult, 2 add, 3 div, 1 sqrt ) VECTOR3_INLINE Vector3 Vector3::unit() const { return (*this)/norm(); } // per element min/max VECTOR3_INLINE Vector3 cmax(const Vector3& v1,const Vector3& v2) { Vector3 res; res.data[0]=v1.data[0]>v2.data[0] ? v1.data[0] : v2.data[0]; res.data[1]=v1.data[1]>v2.data[1] ? v1.data[1] : v2.data[1]; res.data[2]=v1.data[2]>v2.data[2] ? v1.data[2] : v2.data[2]; return res; } VECTOR3_INLINE Vector3 cmin(const Vector3& v1,const Vector3& v2) { Vector3 res; res.data[0]=v1.data[0]data[1] ? data[0] : data[1] ); return ( m>data[2] ? m : data[2] ); } VECTOR3_INLINE double Vector3::min() const { double m = ( data[0] V2.x()) ? V1.x() : V2.x(); double y=(V1.y() > V2.y()) ? V1.y() : V2.y(); double z=(V1.z() > V2.z()) ? V1.z() : V2.z(); return Vector3(x,y,z); } VECTOR3_INLINE Vector3 comp_min(const Vector3& V1,const Vector3& V2) { double x=(V1.x() < V2.x()) ? V1.x() : V2.x(); double y=(V1.y() < V2.y()) ? V1.y() : V2.y(); double z=(V1.z() < V2.z()) ? V1.z() : V2.z(); return Vector3(x,y,z); } // in/output VECTOR3_INLINE std::ostream& operator << (std::ostream& ostr,const Vector3& V) { const char delimiter = ' '; ostr << V.data[0] << delimiter << V.data[1] << delimiter << V.data[2]; return ostr; } VECTOR3_INLINE std::istream& operator >> (std::istream& istr,Vector3& V) { istr >> V.data[0] >> V.data[1] >> V.data[2]; return istr; } #endif // __VECTOR3_HH �����������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������