poliflows:inputfile
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| poliflows:inputfile [2016/08/03 16:01] – [Results archiving] cerquaglia | poliflows:inputfile [2019/05/07 13:23] (current) – removed boman | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | In this section the structure of the input file will be described in detail. | ||
| - | The description is conceived as an ample and detailed comment to a vitually existing input file: so, practically speaking, the user could ideally copy-paste one after the other the code blocks given in the following and should end up with a working input file, ready to be used. | ||
| - | |||
| - | ====== Header ====== | ||
| - | |||
| - | At this stage, the input file should always start as follows: | ||
| - | | ||
| - | import sys, os, os.path | ||
| - | filePath = os.path.abspath(os.path.dirname(sys.argv[0])) | ||
| - | fileName = os.path.splitext(os.path.basename(__file__))[0] | ||
| - | toolsPath = (' | ||
| - | sys.path.append(toolsPath) | ||
| - | |||
| - | This bunch of commands basically defines "where I am", " | ||
| - | For Python pros, you should understand their meaning at a glance. For all the others, don't worry: there is no need to go any further! | ||
| - | |||
| - | ====== Tools import ====== | ||
| - | |||
| - | Before proceeding to the proper definition of the problem, some tools employed by POL(I)FLOWS have to be imported, as follows: | ||
| - | |||
| - | import pfemutils | ||
| - | pfemutils.findbins() | ||
| - | import pfem as w | ||
| - | import pfemtools as wt | ||
| - | |||
| - | If, later on, we want to use the graphic interface, written in python and called '' | ||
| - | |||
| - | import viewer as v | ||
| - | |||
| - | ====== ' | ||
| - | |||
| - | |||
| - | All the problem properties and simulation options have to be defined inside the ' | ||
| - | |||
| - | def main(): | ||
| - | |||
| - | **NB**: remember that in the Python synthax the body of a function (everything that is described in the following sections, in this case) is defined by indentation, | ||
| - | |||
| - | ====== Geometry and mesh import ====== | ||
| - | |||
| - | As already mentioned, for the moment the geometry and the mesh are built in Gmsh. They can be imported by POL(I)FLOWS as follows: | ||
| - | |||
| - | mshFile = filePath+os.sep+' | ||
| - | msh = w.MshData() | ||
| - | msh.load(mshFile) | ||
| - | |||
| - | If one wants the main information about the imported mesh to be printed on the screen, the following command can be added: | ||
| - | |||
| - | print msh | ||
| - | |||
| - | **NB**: '' | ||
| - | An exception exists, nonetheless: | ||
| - | |||
| - | msh.useVoronoiCells = True/False | ||
| - | |||
| - | If '' | ||
| - | The default value is set to '' | ||
| - | |||
| - | ====== Workspace directory definition ====== | ||
| - | |||
| - | After importing the mesh, the following command should be used in order to create a workspace directory for the specific simulation: | ||
| - | |||
| - | pfemutils.load(fileName) | ||
| - | |||
| - | The creation of the workspace directory is **very important** since all the results and outputs (see [[poliflows: | ||
| - | Besides a cleaner storage of the results, by creating it the user is allowed to run multiple simulations at the same time, without overwriting the results coming from other simulations. | ||
| - | |||
| - | The workspace folder will be called as the input file (without ' | ||
| - | |||
| - | **NB**: If a folder with the same name already exists, i.e. the simulation has already been run in the past, **all the data contained in there will be deleted and replaced by the new ones**! | ||
| - | | ||
| - | ====== Problem definition ====== | ||
| - | |||
| - | |||
| - | The problem can be defined as follows: | ||
| - | |||
| - | pbl = w.Problem() | ||
| - | |||
| - | Then, values can be assigned to problem variables in this way: | ||
| - | |||
| - | pbl.variable_name = variable_value | ||
| - | |||
| - | The list of variables that can be modified by the user is reported in the table below: | ||
| - | |||
| - | ^ Name ^ Type ^ Possible values | ||
| - | |**mu** | ||
| - | |**rho0** | ||
| - | |**alpha** | ||
| - | |**remeshing** | ||
| - | |**beta** | ||
| - | |**gravity** | ||
| - | |**bodyForceX** | ||
| - | |**extP** | ||
| - | |**nonLinAlgorithm** | ||
| - | |**solScheme** | ||
| - | |**scalingU** | ||
| - | |**scalingP** | ||
| - | |**scalingU_NR** | ||
| - | |**matrixScaling** | ||
| - | |**matrixScalingParameter** | ||
| - | |**imposedPressureAtFreeSurface** | ||
| - | |**surfTensionAtFreeSurface** | ||
| - | |||
| - | **mu**\\ | ||
| - | Global problem viscosity, usually used for scaling (in general set it equal to the one of the main medium). | ||
| - | |||
| - | **rho0**\\ | ||
| - | Global problem density, usually used for scaling (in general set it equal to the one of the main medium). | ||
| - | |||
| - | **alpha**\\ | ||
| - | Alpha parameter used in the alpha-shape technique, i.e.: | ||
| - | * '' | ||
| - | * '' | ||
| - | |||
| - | **remeshing**\\ | ||
| - | Remeshing option: | ||
| - | * '' | ||
| - | * '' | ||
| - | |||
| - | **beta**\\ | ||
| - | Distortion factor used to decide whether remesh or not, i.e.: | ||
| - | * '' | ||
| - | * '' | ||
| - | |||
| - | **gravity**\\ | ||
| - | Gravity acceleration.\\ | ||
| - | **NB**: always applied in the y-direction! | ||
| - | |||
| - | **bodyForceX**\\ | ||
| - | Body force along x-direction. | ||
| - | |||
| - | **extP**\\ | ||
| - | External pressure value. | ||
| - | |||
| - | **nonLinAlgorithm**\\ | ||
| - | Non-linear algorithm: | ||
| - | *'' | ||
| - | *'' | ||
| - | |||
| - | **solScheme**\\ | ||
| - | Solution scheme (for the moment limited to incompressible flows): | ||
| - | * '' | ||
| - | * '' | ||
| - | |||
| - | **scalingU**\\ | ||
| - | Global scaling velocity used in the definition of the stabilizing parameter of the Petrov-Galerking pressure stabilization technique. | ||
| - | |||
| - | **scalingP**\\ | ||
| - | Global scaling pressure used in the numerical definition of the tangent stiffness matrix of the Newton-Raphson scheme. | ||
| - | |||
| - | **scalingU_NR**\\ | ||
| - | Global scaling velocity used in the numerical definition of the tangent stiffness matrix of the Newton-Raphson scheme. | ||
| - | |||
| - | **matrixScaling**\\ | ||
| - | Matrix scaling option: | ||
| - | * '' | ||
| - | * '' | ||
| - | |||
| - | **matrixScalingParameter**\\ | ||
| - | If '' | ||
| - | * '' | ||
| - | * '' | ||
| - | * '' | ||
| - | |||
| - | **imposedPressureAtFreeSurface**\\ | ||
| - | Imposed pressure at free surface option: | ||
| - | * `= True` : pressure is strongly imposed at the free surface; | ||
| - | * `= False` : pressure at free surface is introduced in a consistent way as a boundary term in the weak form (default). | ||
| - | | ||
| - | **NB**: The strong imposition of the pressure at free surfaces leads to a violation of the principle of objectivity. The user is strongly discouraged to use this option, unless he/she is fully aware of what he/she is doing!\\ | ||
| - | **NB2**: when imposing the value of the pressure at the free surface, only a zero-pressure condition can be imposed. This means that, consistently, | ||
| - | |||
| - | **surfTensionAtFreeSurface**\\ | ||
| - | Surface tension value at " | ||
| - | For the moment, if '' | ||
| - | |||
| - | ====== Time integration scheme ====== | ||
| - | |||
| - | The time integration scheme can be defined as follows: | ||
| - | |||
| - | scheme = w.TimeIntegrationSchemeName(msh, | ||
| - | |||
| - | The list of available schemes is reported in the table below: | ||
| - | |||
| - | ^ Name ^ Type | ||
| - | |**BackwardEuler** | Implicit | | ||
| - | |||
| - | Then, values can be assigned to time integration scheme parameters in this way: | ||
| - | |||
| - | scheme.parameterName = parameterValue | ||
| - | |||
| - | |||
| - | The available time integration scheme parameters are collected in the table below: | ||
| - | |||
| - | ^ Name ^ Type ^ Possible values | ||
| - | |**ttot** | ||
| - | |**dt** | ||
| - | |**t** | ||
| - | |**savefreq** | ||
| - | |**nthreads** | ||
| - | |**addRemoveNodesOption** | ||
| - | |**gamma** | ||
| - | |**omega** | ||
| - | |**updatePressureAfterRemesh** | '' | ||
| - | |||
| - | **ttot**\\ | ||
| - | Total time of the simulation. | ||
| - | |||
| - | **dt**\\ | ||
| - | Time step (fixed, for the moment). | ||
| - | |||
| - | **t**\\ | ||
| - | Current time.\\ | ||
| - | **NB**:it does not make any sense for the user to interact directly with it, except very special occasions! | ||
| - | |||
| - | **savefreq**\\ | ||
| - | Results archiving frequency, i.e. results are archived every '' | ||
| - | |||
| - | **nthreads**\\ | ||
| - | Number of threads, for parallel computing.\\ | ||
| - | **NB**: for the moment only the most important routines (matrix building and assembly) are parallelized, | ||
| - | |||
| - | **addRemoveNodesOption**\\ | ||
| - | Adding and removing nodes during the simulation, in order to keep a good spatial discretization of the domain:\\ | ||
| - | *'' | ||
| - | *'' | ||
| - | |||
| - | **gamma**\\ | ||
| - | If '' | ||
| - | *'' | ||
| - | *'' | ||
| - | |||
| - | **omega**\\ | ||
| - | If '' | ||
| - | *'' | ||
| - | *'' | ||
| - | |||
| - | **updatePressureAfterRemesh**\\ | ||
| - | Update pressure values at nodes with the ones obtained from the new equilibrium solution or not, i.e.: | ||
| - | *'' | ||
| - | *'' | ||
| - | | ||
| - | **NB** | ||
| - | **NB2** : this is a very artificial feature, that can be used in order to get rid of some annoying pressure oscillations appearing after remeshing. Be aware, if you decide to use it!\\ | ||
| - | **NB3** : of course, the use of this option only makes sense if the `pbl.remeshing` option is activated and the `pbl.beta` parameter is both different from 0 (remeshing at each time step) and from any value high enough to make the code never perform a remeshing!\\ | ||
| - | **NB4** : if two or more subsequent remeshings take place, pressure will never be updated again, until there are at least two subsequent time steps performed without remeshing. In this case results can quickly become meaningless from a physical point of view! | ||
| - | |||
| - | ====== Materials definition ====== | ||
| - | |||
| - | In a general problem, there can be many bodies interacting with each other, therefore there can be different materials. | ||
| - | |||
| - | In POL(I)FLOWS a material is called a `Medium`. Materials can be created and assigned to the different domains in the problem as follows: | ||
| - | |||
| - | w.Medium(msh, | ||
| - | w.Medium(msh, | ||
| - | ... | ||
| - | |||
| - | * '' | ||
| - | |||
| - | * '' | ||
| - | |||
| - | * '' | ||
| - | |||
| - | * '' | ||
| - | |||
| - | ^ Material Type ^ Value ^ Notes | | ||
| - | |**MASTER_FLUID** | ||
| - | |**SLAVE_FLUID** | ||
| - | |**SOLID** | ||
| - | |||
| - | **NB**: since the domain is continuously rebuilt, a given element material is defined according to the materials composing the nodes belonging to the element. Hence, every node has to be assigned a material! | ||
| - | This is done automatically at the very beginning of the simulation, but in order to do it correctly the order in which materials are defined is **very important**: | ||
| - | |||
| - | ====== Boundary conditions definition ====== | ||
| - | |||
| - | Since solving a differential equation without imposing the right boundary conditions (BCs) is meaningless, | ||
| - | |||
| - | In POL(I)FLOWS boundaries can be defined and assigned simple BCs as follows: | ||
| - | |||
| - | w.Boundary(msh, | ||
| - | w.Boundary(msh, | ||
| - | ... | ||
| - | |||
| - | * '' | ||
| - | |||
| - | * '' | ||
| - | |||
| - | ^ Boundary Type ^ Value ^ Notes | | ||
| - | |**DirichletOnU** | ||
| - | |**DirichletOnV** | ||
| - | |**Neumann** | ||
| - | |||
| - | |||
| - | * '' | ||
| - | **NB**: in this way only **space and time constant** boundary conditions can be imposed. More complex BCs can be imposed through what in POL(I)FLOWS are called [[poliflows: | ||
| - | |||
| - | ====== Loadings definition ====== | ||
| - | |||
| - | In POL(I)FLOWS complex boundary or initial conditions are dealt with through what we call `Loadings`.\\ | ||
| - | A '' | ||
| - | |||
| - | In POL(I)FLOWS, | ||
| - | |||
| - | A '' | ||
| - | |||
| - | loadingset = w.LoadingSet(msh) | ||
| - | |||
| - | Then, different loadings can be added as: | ||
| - | |||
| - | loadingset.add(nb1, | ||
| - | loadingset.add(nb2, | ||
| - | ... | ||
| - | |||
| - | * '' | ||
| - | | ||
| - | * '' | ||
| - | |||
| - | * '' | ||
| - | |||
| - | * '' | ||
| - | |||
| - | As already mentioned, loadings can be defined either through some base classes defined in the core C++ implementation, | ||
| - | Below, you will find a list of the already available loadings both as base classes and derived classes. | ||
| - | |||
| - | Remember that base classes are called by POL(I)FLOWS directly, i.e. using a ' | ||
| - | |||
| - | Note that one of the amazing advantages in using a Python interface connected to a C++ implementation is that classes can be derived, or even created, directly in Python, without modifying the C++ source code! This means that if you need a special loading which is not in the list, you can built it your self, as explained in the [[poliflows: | ||
| - | |||
| - | **C++ base classes for Loadings** | ||
| - | |||
| - | ^ Loading Type ^ Physical entity dimension | ||
| - | | **TranslationLoading** | 1D | '' | ||
| - | | **RotationalLoading** | ||
| - | | **InitialVelocity** | ||
| - | |||
| - | |||
| - | **Python derived classes for Loadings** | ||
| - | |||
| - | |||
| - | ^ Loading Type ^ Base class ^ Physical entity dimension | ||
| - | | **ConstTransLoad** | ||
| - | | **SinTransLoad** | ||
| - | | **PieceWiseTransLoad** | ||
| - | | **PythonFunctionTransLoad** | ||
| - | | **ConstRotLoad** | ||
| - | | **SinRotLoad** | ||
| - | | **PieceWiseRotLoad** | ||
| - | | **PythonFunctionRotLoad** | ||
| - | |||
| - | **NB**: for the moment, only time dependent loadings are implemented, | ||
| - | |||
| - | **NB2**: the introduction of functions in the '' | ||
| - | |||
| - | ====== Results archiving ====== | ||
| - | |||
| - | As already explained, in POL(I)FLOWS different kinds of results can be stored (see [[poliflows: | ||
| - | '' | ||
| - | |||
| - | In a different way, more specific data are archived in '' | ||
| - | |||
| - | In POL(I)FLOWS, | ||
| - | |||
| - | Extractors are managed by an '' | ||
| - | |||
| - | extManager = w.ExtractorsManager(msh) | ||
| - | | ||
| - | Then, different extractors can be added to the manager as: | ||
| - | |||
| - | extManager.add(nb1, | ||
| - | extManager.add(nb2, | ||
| - | ... | ||
| - | |||
| - | * '' | ||
| - | |||
| - | * '' | ||
| - | |||
| - | * '' | ||
| - | |||
| - | **Extractors list** | ||
| - | |||
| - | ^ Extractor Type ^ Extractor Name ^ Quantity dimension ^ Description | | ||
| - | | NodalExtractor | ||
| - | | ::: | **VelocityExtractor** | ||
| - | | ::: | **PressureExtractor** | ||
| - | | ::: | **IntForceExtractor** | ||
| - | | ::: | **ExtForceExtractor** | ||
| - | | ::: | **IneForceExtractor** | ||
| - | | GlobalExtractor | ||
| - | | ::: | **KineticEnergyExtractor*** | scalar | ||
| - | | ::: | **ViscousEnergyExtractor*** | scalar | ||
| - | |||
| - | * **NB** : These extractors are completely defined in Python! Actually, as for [[poliflows: | ||
| - | |||
| - | ====== Input file end ====== | ||
| - | |||
| - | In order to make the simulation start, the input file should always end with: | ||
| - | |||
| - | scheme.start() | ||
| - | |||
| - | **NB**: this instruction can be slightly modified if we want to launch the [[poliflows: | ||
| - | |||
| - | **Finally, run a simulation is good, but some times you have to wait until the end before analizing the results and making sure that everything' | ||
| - | Learn how to take advantage of the [[poliflows: | ||
poliflows/inputfile.1470232896.txt.gz · Last modified: by cerquaglia
