Important information used in my work, that need to be documented to not sink into oblivion.
Some information that should help to understand terms used in CFD computation.
Contents
Dimensionless quantities - Reynolds, Courant and others.
Numerical methods - Inplicit and explicit methods.
Dimensionless quantities |
Reynolds, Courant and others.
Reynolds number
Definition of the viscous model (turbulent or laminar).
It gives a measurement that characterizes the flow regime as laminar or turbulent.
From Wikipedia,[1].
Courant number
Criterion of solution stability.
Also known as Courant-Friedrichs-Lewy number (CFL number). It indicates how many cells the fluid pass through in one timestep. For explicit Euler solvers the Courant number must be smaller than 1 to not add numerical error. Implicit solvers are not restricted by the Courant number.
You will find here some FEM examples implemented in Octave/Matlab, covering one- and two-dimensional problems.
Contents
Spring - Several springs are assembled in a one-dimensional problem.
Truss - Two-dimensional problem of Truss.
Spring |
Several springs are assembled in a one-dimensional problem.
The examples are inspired on the Book of Alves Filho,[Bibliography item alves2000 not found.].
You can download the file 1D_FEM-spring.m with the source code.
Several springs are assembled as presented in the picture below.
In this problem we have
- 5 nodes (A, B, C, D and E).
- 6 spring elements enumerated from 1 to 6.
- Forces applied in B, C and D are given. Fb=400kgf, Fc=300kgf and Fd=500kgf.
- Spring constants are K1=200kgf/mm, K1=100kgf/mm, K1=150kgf/mm, K1=300kgf/mm, K1=400kgf/mm, K1=500kgf/mm
The displacements of B, C and D and the resultant forces in A and E must be computed (Ub, Uc, Ud Fa and Fe)?
Initial considerations:
- A and B are walls, i.e. Ua = Ub = 0.
First thing in the program is the problem design.
The Nodes A, B, C, D and E are enumerated from (1) to (5) into the program. The spring connections are given by the variable Connection, each line corresponds to a spring element and the columns are the Nodes, for example the spring 1 is connected to nodes A(1) and B(2).
The spring constant is inserted in the variable Kelem.
noElems use the function octave/matlab function size to compute the number of spring elements based on Kelem length. The engineer can directly write 6. I just want to minimize the keyboard use :P.
% Model definition (how the elements are conected)
Connection=[1,2; 2,3; 2,3; 2,4; 3,4; 4,5];
% Model parameters
Kelem=[200, 100, 150, 300, 400, 500];
noElems = size(Kelem)(2);
Next step is the input of boundary conditions. Fknown has the known forces, given for this problem. The variable posFknown indicates where the forces are applied.
In the same way are the variables Uknown and posUknown to manage the known displacements.
noNodes corresponds to the number of nodes in this problem.
%Boundary conditions
Fknown=[400, 300, 500];
posFknown=[2:4];
noNodes = 5;
Uknown=[0, 0];
posUknown=[1,5];
Now the equation 'F = K * u' can be build.
% Building the force F vector
F=zeros(1,noNodes);
F(posFknown)=Fknown;
% Building the displacement U vector
U=zeros(1,noNodes);
U(posUknown)=Uknown;
% Building the matrix of coefficients K.
K=zeros(noNodes);
for i=1:noElems
K(Connection(i,1),Connection(i,1))+= Kelem(i);
K(Connection(i,2),Connection(i,2))+= Kelem(i);
K(Connection(i,1),Connection(i,2))-= Kelem(i);
K(Connection(i,2),Connection(i,1))=K(Connection(i,1),Connection(i,2));
endfor
The system of equations are solved initially by computing the displacements U and using the result to solve the forces F.
% solve icognitas
U(posFknown)=K(posFknown,posFknown)\F(posFknown)';
F(posUknown)=K(posUknown,:)*U';
The vectors U and F have the displacements and forces applied on all nodes.
Thats it!!
Truss |
Two-dimensional problem of Truss.
This example is inspired on the Book of Alves Filho,[Bibliography item alves2000 not found.].
You can download the file 2D_FEM-truss.m with the source code.
- Nodes : A, B, C, D
- Elements: a, b, c, d, e, f
- A, B, C and D are articulated. A and B does not allow displacements
- Forces in C are given, (FUC=1000kgf, FVC=500kgf)
- Bars:
- elasticity, E = 21000 kgf/mm2.
- Section, Ae and Af = 300mm2, Aa and Ac have 80% Ae, Ab and Ad have 60% Ae
- Length Le and Lf = 1000mm, La and Lc have 60% Le, Lb and Ld have 80% Le
The displacements of C and D and the resultant forces in A and B must be computed (UC, VC, UD, VD, FUA, FVA, FUB and FVB)?
Initial considerations:
- A and B does not allow displacements, (i.e. UA = VA = UB = VB = 0).
- D has no forces or reactions on it, (i.e. FUD= FVD= 0kgf)
First thing in the program is the problem design.
The Nodes A, B, C, D and E are enumerated from (1) to (5) into the program, as well as the bars a to f in 1 to 6. The truss connections are given by the variable Connection, each line corresponds to a bar element and the columns are the Nodes, for example the bar a (1) is connected to nodes A(1) and B(2).
The bar constant is inserted in the variable Kelem.
noElems use the function octave/matlab function size to compute the number of bar elements based on Kelem length.
% Model definition (how the elements are conected)
Connection=[1,2; 2,3; 3,4; 4,1; 1,3; 2,4];
% Model parameters Kelem = E*A/L
A= 300*[.6, .8, .6, .8, 1., 1.];
L=1000*[.6, .8, .6, .8, 1., 1.];
E=21000*ones(1,size(A)(2));
Kelem=E.*A ./ L;
noElems = size(Kelem)(2);
An important definition of a 2D problem are the transformations matrix that convert the global coordinate system to a local one. The necessary parameters to build the transformations matrix are saved in alpha, for bar angles, mi and lambda.
% Compute mi=sin(alpha) and lambda=cos(alpha) for each Bar element
alpha=pi()/180*[0, 90, 180, 270, 0, 0]; %alpha taken from then
alpha(5:6)=atan([L(2)/L(1), -L(4)/L(1)]); %compute alpha for e and f
mi=sin(alpha);
lambda=cos(alpha);
The input of boundary conditions: Fknown has the known forces, given for this problem. The variable posFknown indicates where the forces are applied.
In the same way are the variables Uknown and posUknown to manage the known displacements.
noNodes corresponds to the number of nodes in this problem. Differently of a 1D problem each node here has 2 degrees of freedom. One can observe that all data input has two information on each node, corresponding to U and V directions.
%Boundary conditions
Fknown=[1000, 500, 0, 0];
posFknown=[5, 6, 7, 8];
noNodes = 2*(4);
Dknown=[0, 0, 0, 0];
posDknown=[1, 2, 3, 4]; % A and B
Building the equation 'F = K * u', where K is the global matrix computed based on the Ke (element matrix in a global coordinate system) Ke = T-1 * ke * T. T is the transformations matrix for global in local coordinate system, T-1=T'. ke is the local element matrix.
% Building the equation F = K * u
F=zeros(1,noNodes);
F(posFknown)=Fknown;
D=zeros(1,noNodes);
D(posDknown)=Dknown;
K=zeros(noNodes);
for i=1:noElems
ke=zeros(4); %matriz de rigidez local
ke([1,3],[1,3])=Kelem(i)*[1,-1;-1,1];
T=zeros(4); %matriz de transformacao
T(1:2,1:2)=[lambda(i),mi(i);-mi(i),lambda(i)];
T(3:4,3:4)=T(1:2,1:2);
Ke=T'*ke*T; %matriz de rigidez global
pos=zeros(1,4); %position in the global matrix
pos=[Connection(i,1)*2-1, Connection(i,1)*2, Connection(i,2)*2-1, Connection(i,2)*2];
K(pos,pos)+=Ke;
endfor
The system of equations are solved initially by computing the displacements U and using the result to solve the forces F.
% solve icognitas
D(posFknown)=K(posFknown,posFknown)\F(posFknown)';
F(posDknown)=K(posDknown,:)*D';
For truss is important to see the longitudinal forces, that implies in compression or traction, (equation: Fi=(A*E/L)*(u2-u1))
% solve internal forces on each element
% it will be done in the local coordinate system
du=zeros(1,noElems);
for i=1:noElems
T=zeros(4); %matriz de transformacao
T(1:2,1:2)=[lambda(i),mi(i);-mi(i),lambda(i)];
T(3:4,3:4)=T(1:2,1:2);
pos=zeros(1,4); %position in the global matrix
pos=[Connection(i,1)*2-1, Connection(i,1)*2, Connection(i,2)*2-1, Connection(i,2)*2];
d=zeros(4); %compute D in local coordinate
d=T*D(pos)';
du(i)=d(3)-d(1); %compute deformation by compression in mm
endfor
Fi=Kelem.*du;
Vectors D, F and Fi has the problem solution, respectively node displacements, node forces and bar longitudinal forces.
[[bibliography]]
- alves2000
- Avelino Alves Filho, Elementos Finitos - A base da Tecnologia CAE, Erica Ltda, 2000, ISBN 85-7194-741-4
[[/bibliography]]
The most information are collected from the STAR-CCM+ documentation [Bibliography item starccmguide not found.].
Contents
Console start - Starting a Server.
Macro - Java Macros.
Console start |
Starting a Server.
Starting a Server without a Client.
It is useful if you want to start a remote server from a Windows machine or from a shell script.
starccm+ -server [portnumber] file.sim
Use portnumber equal to '0' If you want STAR-CCM+ to look for a port number automatically.
Running the Macro in Batch Mode
starccm+ -batch cavity.java
The -batch option ensures that no GUI will be displayed.
Add the -noexit option If you do not want the server process to exit once the batch file has completed (maybe you want to connect to it to analyze results).
For complete information about client-server activity.
Useful to read diagnostic messages from the server and client.
starccm+ -server -cout file.sim
Now launching the workspace and connect to the server. Activating the server locator option will open the diagnostic information from the client and server in two separate tabs of the Output window.
To activate the server locator option:
- select Tools > Options;
- Open the STAR-CCM+ node;
- select the Environment node;
- Tick the checkbox of Server Locator Diagnostics.
Macro |
Java Macros.
A comprehensive range of Java code that functions in STAR-CCM+ macros can be found selecting the Help > Java API… menu item at STAR-CCM+ Workspace.
For a more extensive Java API, visit Sun Microsystems' Java Technology Reference page: http://java.sun.com/reference/index.html. Other references are [Bibliography item thinkginginjava not found.], [Bibliography item javaandjavascript not found.], [Bibliography item javadeveloper not found.], [Bibliography item javasun not found.] and [Bibliography item javawhitepaper not found.].
Number of iterations
simulation_0.getSimulationIterator().step(1); simulation_0.getSimulationIterator().step(1000);
Start simulation
simulation_0.getSimulationIterator().run();
Prompting user input
int ret = promptUserForInput("Dialog title", 1000); double ret = promptUserForInput("Dialog title", -3066.82); String ret = promptUserForInput("Dialog title", "Physics 1");
Providing an Interactive Dialog
import java.io.File; import java.awt.*; import javax.swing.*; import star.base.neo.NeoMacro; import star.base.neo.NeoScriptFile; import star.base.neo.NeoDoubleField; import star.base.neo.NeoIntegerField; import org.openide.DialogDescriptor; import org.openide.NotifyDescriptor; import org.openide.DialogDisplayer; // ... other imports //star class public class partcolor extends StarMacro { //generical function to show a dialog. public boolean promptUserForInput(String title, JComponent panel) { if (System.getProperty("java.awt.headless") == null) { if (title == "") { title = "Input values"; } DialogDescriptor dd = new DialogDescriptor(panel, title, true, NotifyDescriptor.OK_CANCEL_OPTION, NotifyDescriptor.OK_OPTION, null); return DialogDisplayer.getDefault(). notify(dd) == NotifyDescriptor.OK_OPTION; } return false; } //create a panel with radio buttons to select a color. public class ColorChoice extends JPanel { ButtonGroup group; String[] labels = { "Red", "Green", "Blue", "Black", "White", "Gray", "Yellow" }; Color[] colors = { Color.RED, Color.GREEN, Color.BLUE, Color.BLACK, Color.WHITE, Color.GRAY, Color.YELLOW }; public ColorChoice() { super(new GridLayout(0, 1)); setBackground(Color.lightGray); setBorder(BorderFactory. createTitledBorder("Colors")); group = new ButtonGroup(); JRadioButton option; for (int i = 0; i < labels.length; i++) { option = new JRadioButton(labels[i]); if(i==0) option.setSelected(true); option.setForeground(colors[i]); group.add(option); add(option); } } public Color getColor() { Enumeration elements = group.getElements(); while (elements.hasMoreElements()) { AbstractButton button = (AbstractButton)elements.nextElement(); if (button.isSelected()) { String btext=button.getText(); for (int i = 0;i < labels.length; i++) { if(btext==labels[i]) return colors[i]; } } } return Color.RED; } } //main function public void execute() { // ... some code .... ColorChoice p = new ColorChoice(); if (promptUserForInput("Set Color", p)) { Color mycolor = p.getColor(); partDisplayer_10.setDisplayerColorColor(mycolor); // ... do something with the selected color ... } } }
[[bibliography]]
- starccmguide
- STAR-CCM+ online documentation. STAR-CCM+ . file:<STARCCM-install-dir>/starccm+3.04.007/doc/online/index.html .
- thinkginginjava
- Free Electronic Book. //Thinking in Java, 3rd Edition, by Bruce Eckel. URL: http://www.mindview.net/Books/TIJ/
- javaandjavascript
- Java and JavaScript Programming, by Richard G. Baldwin. URL: http://www.dickbaldwin.com/tocint.htm
- javadeveloper
- The Java Developer's Resource by Elliotte Rusty Harold. URL: http://www.ibiblio.org/javafaq/books/jdr/chapters/ or http://www.ibiblio.org/javafaq/javatutorial.html
- javasun
- The Java Tutorial by Sun Microsystems. URL: http://java.sun.com/docs/books/tutorial/
- javawhitepaper
- White Paper - The Java Language Environment by Sun Microsystems. Comparison of Java with C and C++. URL: http://java.sun.com/docs/white/langenv/
[[/bibliography]]
Contents
Process error - The fluent process could not be started.
Process error |
The fluent process could not be started.
A strange problem… I use Fluent in a Ubuntu machine without any problem. The used license is a float license and to get access I work connected in a wired local network and sometimes wireless. Suddenly fluent not starts anymore with the following output:
Loading "/usr/local/share/CFD/Fluent.Inc/fluent6.3.26/lib/fluent.dmp.114-64"
Done.
/usr/local/share/CFD/Fluent.Inc/fluent6.3.26/bin/fluent -r6.3.26 3d -path/usr/local/share/CFD/Fluent.Inc -cx ift75:35712:42613
Starting /usr/local/share/CFD/Fluent.Inc/fluent6.3.26/lnamd64/3d/fluent.6.3.26 -cx ift75:35712:42613
Welcome to Fluent 6.3.26
Copyright 2006 Fluent Inc.
All Rights Reserved
Loading "/usr/local/share/CFD/Fluent.Inc/fluent6.3.26/lib/flprim.dmp.1119-64"
Done.
Segmentation fault
The fluent process could not be started.
version>
I observed that the license server does not receive any query from my fluent process. So I try to figure out which network problem could it be and how to force fluent to get access to the license server. The problem is also strange, because GAMBIT and all other network applications work error free.
I have an old error that only comes when I try to use root privilegies
sudo: unable to resolve host ift75
It is possible to see that fluent uses the machine name ift75 to start the local process, see flag -cx ift75 in the fluent output above.
The solution is to setup a loopback network to the name 'ift75'. As root I edit the file /etc/hosts and include the line
127.0.0.1 ift75
It fixes the fluent start error.