Skip to content

Instantly share code, notes, and snippets.

View jnbrunet's full-sized avatar

Jean-Nicolas Brunet jnbrunet

  • Montreal
View GitHub Profile
@jnbrunet
jnbrunet / displacement_exporter.py
Created July 14, 2021 13:26
Simple example of a cantilever beam simulation where the displacement vector is saved into a mesh file at every steps.
import Sofa, SofaRuntime
import meshio, numpy as np
class Exporter (Sofa.Core.Controller):
def __init__(self, *args, **kwargs):
Sofa.Core.Controller.__init__(self, *args, **kwargs)
self.step_id = 0
def onAnimateEndEvent(self, e):
x = self.getContext().mo.position.array()
@jnbrunet
jnbrunet / 6e14ca24.patch
Created May 14, 2021 10:37
Removed clang-specific branch for x86 DCAS-based loads.
diff --git a/boost/atomic/detail/ops_gcc_x86_dcas.hpp_origin b/boost/atomic/detail/ops_gcc_x86_dcas.hpp_patched
index 4dacc66..2c3cde2 100644
--- a/boost/atomic/detail/ops_gcc_x86_dcas.hpp_origin
+++ b/boost/atomic/detail/ops_gcc_x86_dcas.hpp_patched
@@ -158,10 +158,7 @@ struct gcc_dcas_x86
}
else
{
-#if defined(__clang__)
- // Clang cannot allocate eax:edx register pairs but it has sync intrinsics
@jnbrunet
jnbrunet / boost_remove_unsuported_flags_darwin.patch
Last active May 14, 2021 07:29
Boost 1.67 remove unsupported flags for recent Darwin compiler
diff --git a/src/tools/darwin.jam b/src/tools/darwin.jam
index 57d9c752..1886f4c4 100644
--- a/src/tools/darwin.jam
+++ b/src/tools/darwin.jam
@@ -137,16 +137,6 @@ rule init ( version ? : command * : options * : requirement * )
# - Set the toolset generic common options.
common.handle-options darwin : $(condition) : $(command) : $(options) ;
- # - GCC 4.0 and higher in Darwin does not have -fcoalesce-templates.
- if $(real-version) < "4.0.0"
@jnbrunet
jnbrunet / gist:7fe9cd97f15a43ba67c7357dd1b929c9
Created October 22, 2020 13:27
SofaPython3 tests output [Before]
Error: [FileSystem::isDirectory()] /home/runner/work/SofaPython3/SofaPython3/SofaPython3/share/sofa/examples: No such file or directory
Error: [FileSystem::isDirectory()] /home/runner/work/SofaPython3/SofaPython3/SofaPython3/share/sofa: No such file or directory
[INFO] [SofaPython3] Initializing with python version 3.7.9 (default, Aug 18 2020, 13:17:47)
[GCC 7.5.0]
[INFO] [SofaPython3] Registering a scene loader for [.py, .py3, .pyscn, .py3scn] files.
[INFO] [SofaPython3] Shared library name is 'libpython3.7m.so'
[INFO] [SofaPython3] Intializing python
Warning: [PythonEnvironment] SofaPython3 not found in PluginManager's map.
Warning: [SofaSimulationCommon] the library has not been initialized (sofa::simulation::common::init() has never been called, see sofa/helper/init.h)
Warning: [SofaSimulationGraph] the library has not been initialized (sofa::simulation::graph::init() has never been called, see sofa/helper/init.h)
@jnbrunet
jnbrunet / gist:4e3f9dff27213002f6738f311fef59f4
Created October 22, 2020 13:26
SofaPython3 tests output
Error: [FileSystem::isDirectory()] /home/runner/work/SofaPython3/SofaPython3/SofaPython3/share/sofa/examples: No such file or directory
Error: [FileSystem::isDirectory()] /home/runner/work/SofaPython3/SofaPython3/SofaPython3/share/sofa: No such file or directory
[INFO] [SofaPython3] Initializing with python version 3.7.9 (default, Aug 18 2020, 13:17:47)
[GCC 7.5.0]
[INFO] [SofaPython3] Registering a scene loader for [.py, .py3, .pyscn, .py3scn] files.
[INFO] [SofaPython3] Shared library name is 'libpython3.7m.so'
[INFO] [SofaPython3] Intializing python
Warning: [PythonEnvironment] SofaPython3 not found in PluginManager's map.
[INFO] [PythonTestExtractor] File 'Components.py' loaded with 1 unit tests.
[INFO] [PythonTestExtractor] File 'Controller.py' loaded with 7 unit tests.
#!python
from __future__ import print_function
import sys, re, argparse
def get_releases():
data = {}
if sys.version_info[0] < 3:
import urllib, json
data = json.loads(urllib.urlopen("https://api.github.com/repos/sofa-framework/sofa/releases").read())
@jnbrunet
jnbrunet / scene.py
Created May 4, 2020 14:15
Caribou Eigen Sparse Segfault
import Sofa
import numpy as np
import copy
class Beam(Sofa.Core.Controller):
def __init__(self, node, *args, **kwargs):
Sofa.Core.Controller.__init__(self, *args, **kwargs)
self.gridShape = (4, 4, 16, 3)
self.createGraph(node)
@jnbrunet
jnbrunet / triangulate_mesh.py
Created April 30, 2020 08:03
CGAL python script
#!/usr/bin/python3
import os, sys
import numpy as np
from tempfile import NamedTemporaryFile
import meshio
from CGAL.CGAL_Polyhedron_3 import Polyhedron_3
from CGAL.CGAL_Mesh_3 import Mesh_3_Complex_3_in_triangulation_3
from CGAL.CGAL_Mesh_3 import Polyhedral_mesh_domain_3
from CGAL.CGAL_Mesh_3 import Mesh_3_parameters
#include <iostream>
#include <tuple>
template <typename T>
struct NameDecoder {
static std::string GetDefaultTemplateName() { return "rien"; }
};
template<template <typename, typename...> class C, typename T1, typename ...Ts>
struct NameDecoder<C<T1, Ts...>>