#include "src/interfaces/SDFPython.hpp"
|
| | SDFPython () |
| |
| | ~SDFPython () |
| |
| | SDFPython (const SDFPython &)=delete |
| |
| SDFPython & | operator= (const SDFPython &)=delete |
| |
| MoFEMErrorCode | sdfInit (const std::string &file) |
| |
| MoFEMErrorCode | requireDerivatives () const |
| |
| MoFEMErrorCode | evalSdf (double dt, double t, const MatrixDouble &coordinates, const MatrixDouble &normals, int block, VectorDouble &values) const |
| |
| MoFEMErrorCode | evalGradSdf (double dt, double t, const MatrixDouble &coordinates, const MatrixDouble &normals, int block, MatrixDouble &values) const |
| |
| MoFEMErrorCode | evalHessSdf (double dt, double t, const MatrixDouble &coordinates, const MatrixDouble &normals, int block, MatrixDouble &values) const |
| |
| double | value (const std::array< double, 3 > &point, double dt=0, double t=0, int block=0) const |
| |
Python/NumPy must be initialised before loading a script. Destroy evaluators before finalising Python. Each evaluator has an independent script namespace.
- Examples
- mesh_reconstruction.cpp, and mofem/tutorials/adv-1_contact/src/ContactOps.hpp.
Definition at line 16 of file SDFPython.hpp.
◆ SDFPython() [1/2]
| MoFEM::SDFPython::SDFPython |
( |
| ) |
|
|
default |
◆ ~SDFPython()
| MoFEM::SDFPython::~SDFPython |
( |
| ) |
|
Definition at line 77 of file SDFPython.cpp.
77 {
79 PythonLock lock;
81 }
82}
std::unique_ptr< Impl > impl
◆ SDFPython() [2/2]
| MoFEM::SDFPython::SDFPython |
( |
const SDFPython & |
| ) |
|
|
delete |
◆ evalGradSdf()
Definition at line 162 of file SDFPython.cpp.
165 {
171}
Vec t
Removal: the ring edge.
SmartPetscObj< Vec > values
#define MoFEMFunctionBegin
First executable line of each MoFEM function, used for error handling. Final line of MoFEM functions ...
@ MOFEM_OPERATION_UNSUCCESSFUL
#define MoFEMFunctionReturn(a)
Last executable line of each PETSc function used for error handling. Replaces return()
#define CHKERR
Inline error check.
◆ evalHessSdf()
◆ evalSdf()
Definition at line 148 of file SDFPython.cpp.
150 {
157 for (
size_t i = 0;
i !=
values.size(); ++
i)
160}
FTensor::Index< 'i', SPACE_DIM > i
UBlasMatrix< double > MatrixDouble
◆ finalise()
Definition at line 101 of file SDFPython.cpp.
101 {
103 if (Py_IsInitialized() && Py_FinalizeEx() < 0)
105 "Python finalisation failed");
107}
◆ initialise()
Definition at line 84 of file SDFPython.cpp.
84 {
86 Py_Initialize();
87 PythonLock lock;
88 try {
89 bp::import("numpy");
90 np::initialize();
91 if (PyErr_Occurred())
92 bp::throw_error_already_set();
93 } catch (const bp::error_already_set &) {
94 PyErr_Print();
96 "Could not initialise NumPy");
97 }
99}
◆ operator=()
◆ requireDerivatives()
Definition at line 135 of file SDFPython.cpp.
135 {
139 PythonLock lock;
140 for (
const auto *
name : {
"grad_sdf",
"hess_sdf"})
142 !PyCallable_Check(bp::object(
impl->globals[
name]).ptr()))
144 "Contact requires %s in %s",
name,
impl->file.c_str());
146}
@ MOFEM_DATA_INCONSISTENCY
◆ sdfInit()
Definition at line 109 of file SDFPython.cpp.
109 {
111 if (!Py_IsInitialized())
113 "Initialise Python/NumPy before loading an SDF");
114 PythonLock lock;
115 try {
116 auto next = std::make_unique<Impl>();
118 next->globals["__builtins__"] = bp::import("builtins");
119 next->globals[
"__file__"] =
file;
120 next->globals["__name__"] = "mofem_sdf";
121 bp::exec_file(
file.c_str(), next->globals, next->globals);
122 if (!next->globals.has_key("sdf") ||
123 !PyCallable_Check(bp::object(next->globals["sdf"]).ptr()))
125 "Script %s has no callable sdf",
file.c_str());
126 impl = std::move(next);
127 } catch (const bp::error_already_set &) {
128 PyErr_Print();
130 "Could not load SDF script %s",
file.c_str());
131 }
133}
◆ value()
| double MoFEM::SDFPython::value |
( |
const std::array< double, 3 > & |
point, |
|
|
double |
dt = 0, |
|
|
double |
t = 0, |
|
|
int |
block = 0 |
|
) |
| const |
Scalar adapter for implicit geometry; contact-normal arguments are zero.
Definition at line 184 of file SDFPython.cpp.
185 {
187 for (
int d = 0;
d != 3; ++
d) {
190 }
193 "SDF evaluation failed");
195}
#define CHK_THROW_MESSAGE(err, msg)
Check and throw MoFEM exception.
UBlasVector< double > VectorDouble
MoFEMErrorCode evalSdf(double dt, double t, const MatrixDouble &coordinates, const MatrixDouble &normals, int block, VectorDouble &values) const
◆ impl
| std::unique_ptr<Impl> MoFEM::SDFPython::impl |
|
private |
The documentation for this struct was generated from the following files: