File: _ymport.cpp

package info (click to toggle)
yade 2025.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 33,308 kB
  • sloc: cpp: 93,298; python: 50,409; sh: 577; makefile: 162
file content (57 lines) | stat: -rw-r--r-- 1,866 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
/*************************************************************************
*  2022 Tóth János                                                       *
*                                                                        *
*  This program is free software; it is licensed under the terms of the  *
*  GNU General Public License v2 or later. See file LICENSE for details. *
*************************************************************************/

// C++ backend of the ymport module.

#include <boost/python.hpp>

#include <lib/base/AliasNamespaces.hpp>
#include <lib/base/LoggingUtils.hpp>
#include <lib/pyutil/doc_opts.hpp>

#include <memory>

#include "ymport/foamfile/PolyMesh.hpp"

CREATE_CPP_LOCAL_LOGGER("_ymport.cpp");

namespace yade {
namespace ymport {
	namespace foamfile {

		py::list readPolyMesh(const std::string& directoryPath, bool patchAsWall, bool emptyAsWall)
		{
			std::unique_ptr<PolyMesh> polyMesh = std::make_unique<PolyMesh>(directoryPath, patchAsWall, emptyAsWall);

			return polyMesh->facetCoords();
		}

	} // namespace foamfile
} // namespace ymport
} // namespace yade

BOOST_PYTHON_MODULE(_ymport)
try {
	using namespace yade::ymport;
	namespace py = ::boost::python;
	YADE_SET_DOCSTRING_OPTS;
	py::def("readPolyMesh", foamfile::readPolyMesh, R"""(
	"""C++ backend of :yref:`yade.ymport.polyMesh`.

	:param str path: directory path. Typical value is: "constant/polyMesh".
	:param bool patchAsWall: load "patch"-es as walls.
	:param bool emptyAsWall: load "empty"-es as walls.
	:param \*\*kw: (unused keyword arguments) is passed to :yref:`yade.utils.facet`
	:returns: list of facets.
    )""");
} catch (...) {
	LOG_FATAL("Importing this module caused an exception and this module is in an inconsistent state now.");
	PyErr_Print();
	PyErr_SetString(PyExc_SystemError, __FILE__);
	boost::python::handle_exception();
	throw;
}