Metafor

ULiege - Aerospace & Mechanical Engineering

User Tools

Site Tools


doc:user:tutorials:tuto1

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
doc:user:tutorials:tuto1 [2015/01/07 12:02] – [How to write an input file] bomandoc:user:tutorials:tuto1 [2016/07/11 16:45] (current) – [Temporal Integration] boemer
Line 1: Line 1:
  
-====== How to write an input file? ======+====== How to build my own FE model? ======
  
  
Line 8: Line 8:
  
  
-Before reading this page, the document [[doc:user:tutorials:tuto0]] must be read and understood. In other words, you must be able to use [[doc:user:general:glossaire#Python]] [[doc:user:general:glossaire#interpreter]] in a basic way. +Before reading this page, the document [[doc:user:tutorials:tuto0]] must be read and understood. In other words, you must be able to use [[doc:user:general:glossaire#Python]] [[doc:user:general:glossaire#interpreter]] in a basic way. 
  
-In the following document are described, line after line, the steps leading to the development of a test case where a cylindrical die will crush a block of material in plane stress. Here is a preview of the final deformation.+In the following document are described, line after line, the steps leading to the development of a input file where a cylindrical die will crush a block of material in plane strain. Here is a preview of the final deformation.
  
 <html> <html>
Line 22: Line 22:
 \\ \\
  
-Since Metafor is improved continuously, the syntax of some commands may have changed. However, this test case is part of the [[doc:user:general:glossaire#batterie|test battery]], so the test corresponding to your version of Metafor can be seen in ''apps\tutorials\tutorial1.py''. +Since Metafor is continuously improved and modified, the syntax of some commands may have slightly changed since the writing of this documentation. However, this input file is part of the [[doc:user:general:glossaire#batterie|test battery]], so a working file corresponding to your version of Metafor can be found in ''apps\tutorials\tutorial1.py''.
- +
- +
- +
- +
- +
- +
- +
-===== Data set Description ===== +
- +
- +
-A Metafor data set is a Python module which defines an "analysis" object called ''Metafor''. This object will be retrieved and manipulated by the command ''meta'', which is entered by the user in command line. The image below shows a schematic organization of a module and the hierarchical structure of the various objects that will be involved in the test case. +
- +
- +
- +
-{{ doc:user:objets-metafor.png?400 |Cliquez pour agrandir...}} +
- +
- +
- +
-To sum up, one data set = one (or several) Python files = one Metafor object.  +
- +
- +
- +
- +
- +
  
  
 +===== Input-file Description =====
  
 +A Metafor input file is a Python module which defines an object called ''Metafor''. This main object will be retrieved and used by the GUI once the user presses the blue PLAY button. The image below shows a schematic organization of a module and the hierarchical structure of the various objects that will be involved in the test case.
  
 +{{ doc:user:objets-metafor.png?400 |Click to enlarge the picture}}
  
 +To sum up, one input file = one (or several) Python files = one Metafor object. 
  
 ==== Heading ==== ==== Heading ====
  
- +The module usually begins with some Python comments (preceded by " '' # '' ") .
- +
-The module begins with some comments (preceded by " '' # '' ") . +
- +
  
   # -*- coding: latin-1; -*-   # -*- coding: latin-1; -*-
Line 67: Line 42:
   # Tutorial   # Tutorial
  
- +The line "coding" is required if we want to use accented characters in python. The "SVN tag" ''$Id$'' (optional) allows us to know the version of this file.
- +
-The line "coding" allows the use of accented characters in python. The "CVS tag" $Id$ (optional) allows to know the version of this file. +
- +
  
   from wrap import *   from wrap import *
   import math   import math
  
- +The first line imports the Python/C++ interface of Metafor (called ''wrap'') in the current namespaceso that all compiled C++ objects of Metafor are available in Python. 
- +  
-Like all Metafor [[doc:user:general:glossaire#test cases]], our [[doc:user:general:glossaire#module]] imports all Metafor modules in its namespace. With this, all Metafor [[doc:user:tutorials:tuto0#objects]] can be used without the prefix "''wrap''". For examplethe class ''Domain'' can be used instead of ''wrap.Domain''.  +The ''math'' module is also imported, in this caseto use the sine and cosine functions later.
-The ''math'' module is also imported, in this case to use the functions sine and cosine. +
- +
  
   metafor = Metafor()   metafor = Metafor()
   domain = metafor.getDomain()   domain = metafor.getDomain()
  
- +The main object of the module is now created as an instance of the ''Metafor'' class. This command ''Metafor()'' creates an [[doc:user:tutorials:tuto0#objets|object]] Metafor, from which we can extract a ''Domain''. The domain is a container (see [[doc:user:general:références#References]]). It contains all objects that are required by the model (geometry, elements, nodes, fixations and other boundary conditions, materials, ...).
- +
-The main object of this module is now created, which is the object ''Metafor''. Each module running on Metafor is build on an analysis ''Metafor''. For now, this is the only analysis which belongs to the LTAS-MN2L (other are supplied by [[doc:user:general:glossaire#Oofelie]], but are not included in the executable). This command ''Metafor()'' creates an [[doc:user:tutorials:tuto0#objets|object]] Metafor, from which we can extract a ''Domain''. The domain is a container (see [[doc:user:general:références#References]]). It contains all objects that are required by the model (geometry, elements, nodes, fixations and other boundary conditions, materials, ...).+
  
 The analysis will then handle data from this domain to, for example, integrate temporally over its evolution equations.  The analysis will then handle data from this domain to, for example, integrate temporally over its evolution equations. 
Line 137: Line 103:
  
   geometry = domain.getGeometry()   geometry = domain.getGeometry()
-  geometry.setDimPlaneStrain()+  geometry.setDimPlaneStrain(1.0)
  
  
Line 166: Line 132:
   * Small objects which require few parameters to be defined, like ''[[doc:user:geometry:user:points|]]'' or [[doc:user:conditions:displacements|fixations]], are defined with the function ''set.define()''.   * Small objects which require few parameters to be defined, like ''[[doc:user:geometry:user:points|]]'' or [[doc:user:conditions:displacements|fixations]], are defined with the function ''set.define()''.
  
-  * Bigger objects which require more arguments, like curves, are defined using a temporary object, which is filled and copied. For example, a curve a curve is created by first defining a line (see below).+  * Bigger objects which require more arguments, like curves, are defined using a temporary object, which is filled and copied. For example, a curve is created by first defining a line (see below).
  
-In this example, ''[[doc:user:geometry:user:points]]'' are defined with the first method, as the function named "define". The first argument is a user number, which must be strictly positive and different for each entity in a common set. The next three arguments are the spatial coordinates $x, y \mbox{ and z$. Since the geometry was set to plane strain, the default plane $z=0$ is considered and only $x$ and $y$ are given.+In this example, ''[[doc:user:geometry:user:points]]'' are defined with the first method, i.e. with the "define"-function. The first argument is a user number, which must be strictly positive and different for each entity in a common set. The next three arguments are the spatial coordinates $x$$yand $z$. Since the geometry was set to plane strain, the default plane $z=0$ is considered and only $x$ and $y$ are given.
  
  
Line 263: Line 229:
 The meshers ([[doc:user:geometry:mesh:1d|1D Mesher]], [[doc:user:geometry:mesh:2d|2D Mesher]]) are linked to the entity that must be meshed and executed with the command ''execute()''. For face 1, the [[doc:user:geometry:mesh:2d|integrated mesher TIM]] (Transfinite Interpolation Method), suitable for quadrangles where two opposite edges have the same numbers of elements, is used. The meshers ([[doc:user:geometry:mesh:1d|1D Mesher]], [[doc:user:geometry:mesh:2d|2D Mesher]]) are linked to the entity that must be meshed and executed with the command ''execute()''. For face 1, the [[doc:user:geometry:mesh:2d|integrated mesher TIM]] (Transfinite Interpolation Method), suitable for quadrangles where two opposite edges have the same numbers of elements, is used.
  
-As for the geometry, it is recommended to visually check whether the piece was meshed properly by opening a ''VizWin'' window with the following lines :+As for the geometry, it is recommended to visually check whether the geometry was meshed properly by opening a ''VizWin'' window with the following lines :
  
  
Line 361: Line 327:
 Now, the boundary conditions are considered. The set which handles all boundary conditions commands is called the ''LoadingSet''. Now, the boundary conditions are considered. The set which handles all boundary conditions commands is called the ''LoadingSet''.
  
-The X component of ligne 4 and the Y component of line 1 must be [[doc:user:conditions:displacements|fixed]], by symmetry.+The X component of line 4 and the Y component of line 1 must be [[doc:user:conditions:displacements|fixed]], by symmetry.
  
  
Line 388: Line 354:
  
  
-Setting fixed ends or displacements is done is the same way as the definition of points in the geometry, with the single ''define()'' command. For the non-zero displacement of the die, the geometric entity ''curveset(5)'' is first given, then the direction ''TY,RE'' (= displacement  along ''Y''), the amplitude -0.4 and finally the temporal evolution, with the reference to the function ''fct''. This means that the movement will be described with ''d(t) = -0.4 * fct(t) = -0.4 * t''+Setting fixed ends or displacements is done in the same way as the definition of points in the geometry, with the single ''define()'' command. For the non-zero displacement of the die, the geometric entity ''curveset(5)'' is first given, then the direction ''TY,RE'' (= displacement  along ''Y''), the amplitude -0.4 and finally the temporal evolution, with the reference to the function ''fct''. This means that the movement will be described with ''d(t) = -0.4 * fct(t) = -0.4 * t''.
  
 ==== Contact ==== ==== Contact ====
Line 422: Line 388:
 The deformable entity is specified with the command ''push()'', the rigid one with ''setTool()''. The deformable entity is specified with the command ''push()'', the rigid one with ''setTool()''.
  
-It should be noted that the contact interaction number must be different that the ''FieldApplicator'' number defined earlier, since both objects are included in the same set ''InteractionSet''.+It should be noted that the contact interaction number must be different from the ''FieldApplicator'' number defined earlier, since both objects are included in the same set ''InteractionSet''.
 ==== Temporal Integration ==== ==== Temporal Integration ====
  
 The description of this model is now over. What is left to consider is the way the ''Metafor'' analysis, in charge of running the simulation, will integrate the equations temporally. The description of this model is now over. What is left to consider is the way the ''Metafor'' analysis, in charge of running the simulation, will integrate the equations temporally.
  
-Many options are available, however the simplest one is chosen here, which is a quasi-static integration (where the inertia is neglected). What remains to define is the temporal interval on which the simulation will be run, and the way the results will be saved (see [[doc:user:integration:general:time_step]]).+Many options are available, however the simplest one is chosen here, which is a quasi-static integration (where the inertia is neglected). What remains to be defined is the temporal interval during which the simulation will be run, and the way the results will be saved (see [[doc:user:integration:general:time_step]]).
  
  
Line 446: Line 412:
      
  
-Afterwards, the ''MechanicalIterationManager'' is considered (see [[doc:user:integration:general:mim_tim]]). This object sets the parameters of Newton-Raphson algorithm, used to solve the equilibrium equations. Here, a maximum of 7 mechanical [[doc:user:general:glossaire#iterations]] is set, with the default tolerance of 1.0e-4.+Afterwards, the ''MechanicalIterationManager'' is considered (see [[doc:user:integration:general:mim_tim]]). This object sets the parameters of the Newton-Raphson algorithm, used to solve the equilibrium equations. Here, a maximum of 7 mechanical [[doc:user:general:glossaire#iterations]] is set, with the default tolerance of 1.0e-4.
 ==== Curves Extraction  ==== ==== Curves Extraction  ====
  
Line 453: Line 419:
   valuesmanager = metafor.getValuesManager()   valuesmanager = metafor.getValuesManager()
   valuesmanager.add(1, MiscValueExtractor(metafor,EXT_T),'time')   valuesmanager.add(1, MiscValueExtractor(metafor,EXT_T),'time')
-  valuesmanager.add(2, DbValueExtractor(curveset(1), Field1D(TY,GF2)), SumOperator(), 'force')+  valuesmanager.add(2, DbNodalValueExtractor(curveset(1), Field1D(TY,GF2)), SumOperator(), 'force')
  
 The first line fetches the ''ValuesManager'', in charge of handling the result curves, from the analysis ''Metafor''. The first line fetches the ''ValuesManager'', in charge of handling the result curves, from the analysis ''Metafor''.
doc/user/tutorials/tuto1.1420628550.txt.gz · Last modified: 2016/03/30 15:22 (external edit)

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki