Skip to content

Instantly share code, notes, and snippets.

View precise-simulation's full-sized avatar
🌐
Physics Simulation Made Easy!

Precise Simulation precise-simulation

🌐
Physics Simulation Made Easy!
View GitHub Profile
@precise-simulation
precise-simulation / featool_2d_solution_extrusion_example.m
Created April 6, 2022 07:33
Extrusion/interpolation of 2D solution to 3D
% FEATool Multiphysics script example for extruding/interpolating a 2D solution to a 3D domain.
%
% Note! This will only work as is for 1st order/linear shape functions. For
% higher order shape functions interpolation order is more complicated
% due to degrees of freedom corresponding to cell center and edge mid points.
% Define and solve Poisson problem on 2x1 2D rectangle.
fea.sdim = {'x', 'y'};
fea.geom.objects = {gobj_rectangle(0, 2, 0, 1)};
fea.grid = gridgen(fea ,' hmax', 0.1);
@precise-simulation
precise-simulation / local_boundary_mesh_size_example.fes
Last active November 9, 2021 08:43
FEATool Multiphysics mesh geneneration example for prescibing mesh sizes on individual boundaries
{"meta":{"app":"FEATool Multiphysics","author":"Precise Simulation","build":"1.15.0","date":"04-Nov-2021","descr":"Meshing example with setting local boundary mesh sizes","dim":2,"image":"","keyw":"mesh","mlver":"","name":"local_boundary_mesh_size_example","phys":[],"system":"PCWIN64","time":738464,"title":"local_boundary_mesh_size_example","type":"mesh_example","user":"precsim","ver":[1,15,0]},
"fields":["type","id","ui_arg","fcn_type","fcn_oarg"],
"data":[
["uipushtool","Standard.NewFigure",[],"ClickedCallback",[]],
["uicontrol","button_dlgnew_ok",[],"Callback",[]],
["uimenu",["Geometry","Create Object...","Rectangle"],[],"Callback",[]],
["uicontrol","button_dlggobj_ok",[],"Callback",[]],
["uimenu",["Geometry","Create Object...","Rectangle"],[],"Callback",[]],
["uicontrol","edit_x_min","1","Callback",[]],
["uicontrol","edit_x_max","2","Callback",[]],
@precise-simulation
precise-simulation / featool_solver_hook_example.m
Created September 28, 2021 09:14
FEATool solver hook example for implementing the (summation) constraint c1 = c2 over a subdomain
function [ fea ] = featool_solver_hook_example()
%FEATOOL_SOLVER_HOOK_EXAMPLE
%
% Solver hook example to add a constraint that sum(ci_j) = 0 for two
% dependent variables c1 and c2 (and j is the nodes/degrees of freedom).
% Copyright 2021 Precise Simulation, Ltd.
% Geometry and grid.
fea.sdim = { 'x', 'y' };
% Prostprocessing MATLAB m-file script for the fluid_structure1 tutorial model.
%
% Used to create the visualization: https://youtu.be/UwANmWvC9YM
close all
miu = 1;
i_int = [5:8,11:13]; % Integration boundaries.
i_cub = 10;
s_tfx = ['nx*p+',num2str(miu),'*(-2*nx*ux-ny*(uy+vx))'];
s_tfy = ['ny*p+',num2str(miu),'*(-nx*(vx+uy)-2*ny*vy)'];
@precise-simulation
precise-simulation / parrun.sh
Last active March 22, 2022 21:26
Bash xargs script to run parallel MATLAB and Octave jobs
#!/bin/bash
#
# Bash script using xargs to run Matlab and Octave jobs in parallel.
#
n_parruns=16 # Total number of runs.
n_parproc=3 # Number of simultaneous parallel processes.
# Define Matlab/Octave executable and main m-scipt file to run.
export runcmd='/mnt/c/Octave/Octave-4.2.1/bin/octave-cli.exe'
@precise-simulation
precise-simulation / fem-poisson-solver-julia-matlab-fortran-benchmark.txt
Created August 29, 2017 01:58
Julia Matlab Fortran Benchmark - Finite Element FEM Poisson Equation
| 1/h | FEAT2D | FEATool | FEniCS | | SFEA |
|------|---------|---------------|------------|----------|---------|
| | Fortran | Matlab/Octave | Python/C++ | Julia | Fortran |
| | GMG | UMFPACK | PETSc | CHOLMOD? | GMG |
| 128 | 0.025 | 0.368 | 0.19 | 0.18 | 0.049 |
| 256 | 0.05 | 1.718 | 0.79 | 0.322 | 0.064 |
| 512 | 0.21 | 7.406 | 4.65 | 0.9 | 0.11 |
| 1024 | 1.1 | 47.646 | 34.1 | 3.4 | 0.16 |
| 2048 | 6 | 338.14 | - | 14.6 | 0.49 |
@precise-simulation
precise-simulation / fem-matrix-assembly-julia-matlab-fortran-benchmark.txt
Created August 29, 2017 01:54
Julia Matlab Fortran Benchmark - Finite Element FEM Matrix Assembly
| 1/h | FEAT2D | FEATool | FEniCS | |
|------|---------|---------------|------------|-------|
| | Fortran | Matlab/Octave | Python/C++ | Julia |
| 128 | 0.05 | 0.05 | 0.05 | 0.24 |
| 256 | 0.13 | 0.14 | 0.12 | 0.57 |
| 512 | 0.42 | 0.43 | 0.31 | 1.7 |
| 1024 | 1.5 | 1.7 | 1.1 | 6.5 |
| 2048 | 6 | 7 | 5 | 26 |
| 4096 | 24 | | | 105 |
@precise-simulation
precise-simulation / fem-benchmark-sparse-matvec.txt
Last active September 28, 2021 09:28
Julia Matlab Fortran Benchmark - Finite Element Sparse FEM Matrix Vector Product
| 1/h | FEAT2D | FEATool | | SFEA |
|------|---------|---------------|-------|---------|
| | Fortran | Matlab/Octave | Julia | Fortran |
| 128 | 0 | 0.002 | 0.03 | 0 |
| 256 | 0.001 | 0.002 | 0.031 | 0 |
| 512 | 0.005 | 0.006 | 0.034 | 0.001 |
| 1024 | 0.024 | 0.021 | 0.05 | 0.002 |
| 2048 | 0.197 | 0.085 | 0.08 | 0.009 |
| 4096 | 0.411 | | 0.25 | 0.034 |