Hi, everyone. I want to reset all fields like the code shown below. It works well, but can we implement it easier?
@ti.kernel
def clear_data(self):
for i, j in self.values:
self.values[i, j] = 0.
for i, j in self.cases:
self.cases[i, j] = 0
self.edges[i * self.nely + j, 0] = ti.Vector([0., 0.])
self.edges[i * self.nely + j, 1] = ti.Vector([0., 0.])
self.edges[i * self.nely + j, 2] = ti.Vector([0., 0.])
self.edges[i * self.nely + j, 3] = ti.Vector([0., 0.])
I tried to re-declare these field in python scope. The code is shown below. But when I had called this function in a while
loop, the GUI window crashed and returned an error. The question is: What is the correct operation to reset a field?
def clear_data(self):
self.values = ti.field(ti.f32, (self.nelx + 1, self.nely + 1))
self.cases = ti.field(ti.i32, (self.nelx, self.nely))
self.edges = ti.Vector.field(2, ti.f32, (self.nelx * self.nely, 4))
[Taichi] version 0.8.0, llvm 10.0.0, commit 181c9039, osx, python 3.9.2
[Taichi] Starting on arch=arm64
[E 10/07/21 00:11:25.254 631982] Received signal 11 (Segmentation fault: 11)
* Taichi Core - Stack Traceback *
==========================================================================================
| Module | Offset | Function |
|----------------------------------------------------------------------------------------|
* taichi_core.so | 120 | taichi::Logger::error(std::__1::basic_string< |
| char, std::__1::char_traits<char>, std::__1:: |
| allocator<char> > const&, bool) |
* taichi_core.so | 228 | taichi::(anonymous namespace)::signal_handler |
| (int) |
* libsystem_platform.dylib | 56 | (null) |
* libc++.1.dylib | 16 | std::__1::mutex::lock() |
* taichi_core.so | 56 | taichi::ThreadPool::run(int, int, void*, void |
| (*)(void*, int, int)) |
* ??? | 1101562492 | (null) |
* taichi_core.so | 156 | taichi::lang::Kernel::operator()(taichi::lang |
| ::Kernel::LaunchContextBuilder&) |
* taichi_core.so | 180 | void pybind11::cpp_function::initialize<taich |
| i::export_lang(pybind11::module_&)::$_26, voi |
| d, taichi::lang::Kernel*, taichi::lang::Kerne |
| l::LaunchContextBuilder&, pybind11::name, pyb |
| ind11::is_method, pybind11::sibling>(taichi:: |
| export_lang(pybind11::module_&)::$_26&&, void |
| (*)(taichi::lang::Kernel*, taichi::lang::Ker |
| nel::LaunchContextBuilder&), pybind11::name c |
| onst&, pybind11::is_method const&, pybind11:: |
| sibling const&)::'lambda'(pybind11::detail::f |
| unction_call&)::__invoke(pybind11::detail::fu |
| nction_call&) |
* taichi_core.so | 3316 | pybind11::cpp_function::dispatcher(_object*, |
| _object*, _object*) |
* python | 80 | (null) |
* python | 340 | (null) |
* python | 620 | (null) |
* python | 412 | (null) |
* python | 340 | (null) |
* python | 724 | (null) |
* python | 29396 | (null) |
* python | 2968 | (null) |
* python | 240 | (null) |
* python | 30088 | (null) |
* python | 2968 | (null) |
* python | 240 | (null) |
* python | 320 | (null) |
* python | 164 | (null) |
* python | 376 | (null) |
* python | 156 | (null) |
* python | 30088 | (null) |
* python | 2968 | (null) |
* python | 240 | (null) |
* python | 320 | (null) |
* python | 164 | (null) |
* python | 376 | (null) |
* python | 340 | (null) |
* python | 724 | (null) |
* python | 29268 | (null) |
* python | 116 | (null) |
* python | 164 | (null) |
* python | 572 | (null) |
* python | 29268 | (null) |
* python | 116 | (null) |
* python | 572 | (null) |
* python | 29396 | (null) |
* python | 2968 | (null) |
* python | 376 | (null) |
* python | 816 | (null) |
* python | 2916 | (null) |
* python | 1256 | (null) |
* python | 56 | (null) |
* libdyld.dylib | 4 | (null) |
==========================================================================================
Internal error occurred. Check out this page for possible solutions:
https://docs.taichi.graphics/docs/lang/articles/misc/install
Process finished with exit code 255