Using the TAUCS Out of Core solver for Calculix computation with FreeCAD

Using the TAUCS Out of Core solver for Calculix computation with FreeCAD

Calculix is great Finite Element Mechanical simulation tools which support various solvers. We intend to use it as to validate mechnical structure of RuggedPOD and Open Tower. Following this goal, we ended up to recompile it under MacOS, and Linux, as to support most of the features required by RuggedPOD.

First of all RuggedPOD is a complex object to modelize and simulate. The structure of the POD is based on complex shapes, which are either honeycomb base or pushed pin. These shapes implies strong curvature and bad mesh quality due to some negative Jacobian number appearance within the model.

FreeCAD our calculix frontend support FEM through an active development module. This module doesn’t expose up to now all the parameters that the integrated mesher that we use can sustain (Netgen). We had to hardcode within the

void NETGENPlugin_Mesher::SetParameters(const NETGENPlugin_Hypothesis* hyp)

function from FreeCAD-git/src/3rdParty/salomesmesh/src/NETGENPlugin/NETGENPlugin_Mesher.cpp this value as to get rid of negative Jacobians

mparams.minh = 2.0;

The default values are defined into MeshingParameters :: MeshingParameters () from libsrc/meshing/meshtype.cpp within Netgen source code. The minh set to 0, imply that very small Tet can be created and create mess within our model. We will probably have to add a user define interface to get the value configurable by the end user.

    optimize3d = “cmdmustm”;
optsteps3d = 3;
optimize2d = “smsmsmSmSmSm”;
optsteps2d = 3;
opterrpow = 2;
blockfill = 1;
filldist = 0.1;
safety = 5;
relinnersafety = 3;
uselocalh = 1;
grading = 0.3;
delaunay = 1;
maxh = 1e10;
minh = 0;
meshsizefilename = NULL;
startinsurface = 0;
checkoverlap = 1;
checkoverlappingboundary = 1;
checkchartboundary = 1;
curvaturesafety = 2;
segmentsperedge = 1;
parthread = 0;

elsizeweight = 0.2;
giveuptol2d = 200;
giveuptol = 10;
maxoutersteps = 10;
starshapeclass = 5;
baseelnp = 0;
sloppy = 1;

badellimit = 175;
check_impossible = 0;
secondorder = 0;

With this system configuration we got rid of negative jacobian creation on our model. Unfortunatly new issues appears, as the model size started to become very huge and CalculiX direct solver (SPOOLES) build up very huge matrix which are exploding the memory of my development system (16GB). The next step has been to move our CalculiX installation from SPOOLES to TAUCS solver. TAUCS is an old solver which can factorize to an LLT shape define positive matrix (which is our case), and which does support Out Of Core capabilities (use of local storage in the case memory is not big enough).

TAUCS port on MacOS is not straight forard. The source code has not been updated since 2003, and does include some very bad quality code from f2c translation tools to avoid usage of Fortran compiler. As to get rid of it, we decided to use original code written in Fortran using gfortran compiler.

The following darwin15.mk file has been created into the config directory of TAUCS. BLAS support is coming form the excellent OpenBLAS library coming from macport

#########################################################
# Linux                                                 #
#########################################################
OBJEXT=.o
LIBEXT=.a
EXEEXT=
F2CEXT=.f
PATHSEP=/
DEFFLG=-D

#CC        = gcc
CFLAGS    = -O3 -fPIC
COUTFLG   = -o ./

FC        = gfortran-mp-5 -fPIC
FFLAGS    = $(CFLAGS)
FOUTFLG   = $(COUTFLG)

LD        = $(FC)
LDFLAGS   = $(CFLAGS)
LOUTFLG   = $(COUTFLG)

AR        = ar -cr
AOUTFLG   =

RANLIB    = ranlib
RM        = rm -rf

LIBBLAS   = -lopenblas
LIBLAPACK =
LIBMETIS  = -L/opt/local/lib  -lmetis

# LIBF77 = -Lexternal/lib/darwin  -lf2c -lf95
LIBF77 = -Lexternal/lib/darwin -lf2c

# -lf2c
# crypto is for ftime, which is used by the timing routines
# the documentation says its in libcompat, but on my system
# there is no libcompat, but libcrypto provides it
LIBC   = -lm -lcrypto

#########################################################

Out of Core implementation in CalculiX is buggy and probably not used that much as it is directly calling factorization and solving function instead of using the “general” defined interfaced called linsolve. We swaped this piece of code and adapted it to the linsolve with the right parameter for the out of core call

ret = taucs_linsolve(aa,&F,0,NULL,NULL,taufactorooc,NULL); // for the factorization

ret = taucs_linsolve(aa,&F,1,x,b,tausolveooc,NULL); // for the solution

These called implied a small patch into the linsolve function from TAUCS which is not properly opening the scratch handle file before solving the problem and implied a Segfault while solving. Just edit taucs_linsolve.c

Look for this piece of code into linsolve and add the right initialization to opt_occ_handle

    case TAUCS_FACTORTYPE_LLT_OOC:
precond_fn  = taucs_ooc_solve_llt;
// SDS THIS IS WHERE THE BUG HAPPENS IN OOC CONDITION
opt_ooc_handle = taucs_io_open_multifile(opt_ooc_name);
precond_arg = opt_ooc_handle;
break;

We are using the following parameter to taucs call defined in tau.c from CalculiX source code

char* taufactor[]={ “taucs.factor.LLT=true”,”taucs.factor.mf=true”,
“taucs.factor.ordering=amd”,NULL };
char* taufactorooc[]={ “taucs.factor.LLT=true”,”taucs.factor.mf=true”,”taucs.factor.ordering=amd”,”taucs.ooc=true”,
“taucs.ooc.basename=/tmp/scratch”,
“taucs.ooc.memory=500000000.0″,NULL };
char* tausolve[]={ “taucs.factor=false”,NULL };
char* tausolveooc[]={“taucs.factor=false”,”taucs.ooc.basename=/tmp/scratch”,”taucs.ooc.memory=500000000.0″,NULL };

If you properly apply these small patches, you will be able to get the out of core support working straight forward within CalculiX and you will be able to solve much bigger problem as the intro image demo it.

You have to adapt your scratch directory (/tmp/scratch) to your temporary directory.

The neq<1500 needs to be adapted within each (factor / solve) function call into tau.c as to define when to use in-core or out-of-core solver from TAUCS.

facebooktwittergoogle_plusredditpinterestlinkedinmailby feather

Submit a Comment

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

WP-Backgrounds by InoPlugs Web Design and Juwelier Schönmann