-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* removed old file * mok won't make it to release * updating example readmes * initial add of example * creating multiple mdpas * adding mesh-pics * atarted with readme * increased width * minor
- Loading branch information
1 parent
8a40c15
commit d378e42
Showing
16 changed files
with
345 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,18 @@ | ||
This folder contains scripts and examples for using the functionalities of the plugin standalone, without using the Salome GUI. In Salome terms this is called the **TUI** mode. | ||
## TUI Examples | ||
|
||
Dump Study | ||
This folder contains scripts and examples for using the functionalities of the plugin in **TUI** mode. | ||
|
||
### List of examples: | ||
- **WIP** [Cantilever beam](cantilever): modeled with solid elements. This is a simple example demonstrating the basic stnadalone usage for creating a structural model. | ||
- [Cantilever beam](cantilever): modeled with solid elements. This is a simple example demonstrating the basic TUI usage for creating a structural model. | ||
- **WIP** [Wind turbine blade](wind_turbine_blade): Advanced structural model of a wind turbine blade discretized with shell elements. Shows how to work with multiple meshes and submeshes. | ||
- **WIP** [Tower](tower): Structural Model of a tower, taken from the [salome website](https://www.salome-platform.org/user-section/tui-examples). More complex structural model. | ||
- **WIP** [Flow around cylinder](flow_cylinder): Flow around a cylinder in 2D. Shows how to do mesh refinements and write multiple mdpa files. | ||
- [Flow around cylinder](flow_cylinder): Flow around a cylinder in 2D. Shows how to do mesh refinements and write multiple mdpa files. | ||
- **WIP** [Flow over cross with chimera](flow_cross_chimera): Flow over a cross, modelled with overlappig domains using chimera. One domain is the background, the other is the patch containing the cross. The domains are overlapping. | ||
- **WIP** [Mok FSI](mok_fsi): The Mok FSI benachmark as defined in the dissertation of [Daniel Mok, chapter 7.3](http://dx.doi.org/10.18419/opus-147). This includes two domains, fluid and structure. | ||
- **WIP** [Balls against barrier](balls_barrier): Balls modeled with discrete elements interact with a rigid wall | ||
- **WIP** [Rock falling into cablenet](rock_cablenet): Demonstrating the usage of using discrete elements together with finite elements | ||
- **WIP** [Rock falling into cablenet](rock_cablenet): Demonstrating the usage of using discrete elements together with finite elements | ||
|
||
### Executing the examples | ||
As [described in the README](../../README.md#how-does-it-work) this example can be executed in two ways: | ||
- Loading the file with `File/Load Script ...` inside of Salome | ||
- Using [execute_in_salome](../execute_in_salome.py). E.g. `python3 ../../execute_in_salome.py ~/software/SALOME/SALOME-9.3.0-UB16.04-SRC/salome salome_cantilever_tetra.py` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
This example represents a simple cantilever beam, fixed on one side and loaded on the other side | ||
It is modelled once with hexahedral and once with tetrahedral solid elements | ||
## Cantilever | ||
|
||
This example represents a simple cantilever beam, fixed on one side and loaded on the other side\ | ||
It is modelled once with hexahedral and once with tetrahedral solid elements. | ||
|
||
<img src="media/mesh_hexa.png" width="200"> | ||
<img src="media/mesh_tetra.png" width="200"> | ||
Hexahedral Elements | ||
|
||
Execute Salome with: `python3 ../../execute_in_salome.py ~/software/SALOME/SALOME-9.3.0-UB16.04-SRC/salome salome_cantilever_tetra.py` | ||
<img src="media/mesh_tetra.png" width="200"> | ||
Tetrahedral Elements | ||
|
||
And then run Kratos | ||
After executing Salome with either `salome_cantilever_tetra.py` or `salome_cantilever_hexa.py` the provided Kratos files can be used to run this example. |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"properties" : [{ | ||
"model_part_name" : "FluidModelPart.domain", | ||
"properties_id" : 1, | ||
"Material" : { | ||
"constitutive_law" : { | ||
"name" : "Newtonian2DLaw" | ||
}, | ||
"Variables" : { | ||
"DENSITY" : 1.225, | ||
"DYNAMIC_VISCOSITY" : 1.846e-5 | ||
}, | ||
"Tables" : {} | ||
} | ||
}] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from __future__ import print_function, absolute_import, division #makes KratosMultiphysics backward compatible with python 2.6 and 2.7 | ||
|
||
import KratosMultiphysics | ||
from KratosMultiphysics.FluidDynamicsApplication.fluid_dynamics_analysis import FluidDynamicsAnalysis | ||
|
||
import sys | ||
import time | ||
|
||
class FluidDynamicsAnalysisWithFlush(FluidDynamicsAnalysis): | ||
|
||
def __init__(self,model,project_parameters,flush_frequency=10.0): | ||
super(FluidDynamicsAnalysisWithFlush,self).__init__(model,project_parameters) | ||
self.flush_frequency = flush_frequency | ||
self.last_flush = time.time() | ||
|
||
def FinalizeSolutionStep(self): | ||
super(FluidDynamicsAnalysisWithFlush,self).FinalizeSolutionStep() | ||
|
||
if self.parallel_type == "OpenMP": | ||
now = time.time() | ||
if now - self.last_flush > self.flush_frequency: | ||
sys.stdout.flush() | ||
self.last_flush = now | ||
|
||
if __name__ == "__main__": | ||
|
||
with open("ProjectParameters.json",'r') as parameter_file: | ||
parameters = KratosMultiphysics.Parameters(parameter_file.read()) | ||
|
||
model = KratosMultiphysics.Model() | ||
simulation = FluidDynamicsAnalysisWithFlush(model,parameters) | ||
simulation.Run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
{ | ||
"problem_data" : { | ||
"problem_name" : "flow_cylinder", | ||
"parallel_type" : "OpenMP", | ||
"echo_level" : 0, | ||
"start_time" : 0.0, | ||
"end_time" : 10 | ||
}, | ||
"solver_settings" : { | ||
"model_part_name" : "FluidModelPart", | ||
"domain_size" : 2, | ||
"solver_type" : "FractionalStep", | ||
"model_import_settings" : { | ||
"input_type" : "mdpa", | ||
"input_filename" : "flow_cylinder_0.5", | ||
"input_filename_coarse" : "flow_cylinder_2.0", | ||
"input_filename_med" : "flow_cylinder_1.0", | ||
"input_filename_fine" : "flow_cylinder_0.5" | ||
}, | ||
"material_import_settings": { | ||
"materials_filename": "FluidMaterials.json" | ||
}, | ||
"echo_level" : 0, | ||
"compute_reactions" : false, | ||
"dynamic_tau" : 1.0, | ||
"predictor_corrector" : false, | ||
"pressure_tolerance" : 0.001, | ||
"maximum_pressure_iterations" : 4, | ||
"velocity_tolerance" : 0.001, | ||
"maximum_velocity_iterations" : 4, | ||
"volume_model_part_name" : "domain", | ||
"skin_parts" : ["inlet","outlet","cyl_boundary","walls"], | ||
"no_skin_parts" : [], | ||
"time_stepping" : { | ||
"automatic_time_step" : false, | ||
"time_step" : 0.01 | ||
} | ||
}, | ||
"processes" : { | ||
"initial_conditions_process_list" : [], | ||
"boundary_conditions_process_list" : [{ | ||
"python_module" : "apply_inlet_process", | ||
"kratos_module" : "KratosMultiphysics.FluidDynamicsApplication", | ||
"Parameters" : { | ||
"model_part_name" : "FluidModelPart.inlet", | ||
"variable_name" : "VELOCITY", | ||
"modulus" : 1.0, | ||
"direction" : "automatic_inwards_normal", | ||
"interval" : [0.0,"End"] | ||
} | ||
},{ | ||
"python_module" : "apply_outlet_process", | ||
"kratos_module" : "KratosMultiphysics.FluidDynamicsApplication", | ||
"Parameters" : { | ||
"model_part_name" : "FluidModelPart.outlet", | ||
"variable_name" : "PRESSURE", | ||
"constrained" : true, | ||
"value" : 0.0, | ||
"hydrostatic_outlet" : false, | ||
"h_top" : 0.0 | ||
} | ||
},{ | ||
"python_module" : "apply_noslip_process", | ||
"kratos_module" : "KratosMultiphysics.FluidDynamicsApplication", | ||
"Parameters" : { | ||
"model_part_name" : "FluidModelPart.cyl_boundary" | ||
} | ||
},{ | ||
"python_module" : "apply_noslip_process", | ||
"kratos_module" : "KratosMultiphysics.FluidDynamicsApplication", | ||
"Parameters" : { | ||
"model_part_name" : "FluidModelPart.walls" | ||
} | ||
}], | ||
"gravity" : [], | ||
"auxiliar_process_list" : [] | ||
}, | ||
"output_processes" : { | ||
"vtk_output" : [{ | ||
"python_module" : "vtk_output_process", | ||
"kratos_module" : "KratosMultiphysics", | ||
"process_name" : "VtkOutputProcess", | ||
"help" : "This process writes postprocessing files for Paraview", | ||
"Parameters" : { | ||
"model_part_name" : "FluidModelPart.fluid_computational_model_part", | ||
"output_control_type" : "step", | ||
"output_frequency" : 1, | ||
"file_format" : "ascii", | ||
"output_precision" : 7, | ||
"output_sub_model_parts" : true, | ||
"folder_name" : "vtk_output", | ||
"save_output_files_in_folder" : true, | ||
"nodal_solution_step_data_variables" : ["VELOCITY","PRESSURE"], | ||
"nodal_data_value_variables" : [], | ||
"element_data_value_variables" : [], | ||
"condition_data_value_variables" : [] | ||
} | ||
}] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
## Flow Cylinder | ||
|
||
This example shows a 2D cylinder flow. Meshes with different refinements are created in the same model | ||
|
||
|
||
<img src="media/flow.png" width="400"> | ||
|
||
|
||
### Mesh refinements: | ||
Fine Mesh | ||
|
||
<img src="media/mesh_fine.png" width="400"> | ||
|
||
Medium Mesh | ||
|
||
<img src="media/mesh_med.png" width="400"> | ||
|
||
Coarse Mesh | ||
|
||
<img src="media/mesh_coarse.png" width="400"> | ||
|
||
|
||
After executing Salome with `salome_model.py` the three different `mdpa` files are created and the provided Kratos files can be used to run this example. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,155 @@ | ||
#!/usr/bin/env python | ||
|
||
### | ||
### This file is generated automatically by SALOME v9.4.0 with dump python functionality | ||
### | ||
|
||
import sys | ||
import salome | ||
|
||
salome.salome_init() | ||
import salome_notebook | ||
notebook = salome_notebook.NoteBook() | ||
|
||
### | ||
### GEOM component | ||
### | ||
|
||
import GEOM | ||
from salome.geom import geomBuilder | ||
import math | ||
import SALOMEDS | ||
|
||
|
||
geompy = geomBuilder.New() | ||
|
||
O = geompy.MakeVertex(0, 0, 0) | ||
OX = geompy.MakeVectorDXDYDZ(1, 0, 0) | ||
OY = geompy.MakeVectorDXDYDZ(0, 1, 0) | ||
OZ = geompy.MakeVectorDXDYDZ(0, 0, 1) | ||
Vertex_1 = geompy.MakeVertex(0, 0, 0) | ||
Vertex_2 = geompy.MakeVertex(7, 0, 0) | ||
Vertex_3 = geompy.MakeVertex(7, 2, 0) | ||
Vertex_4 = geompy.MakeVertex(0, 2, 0) | ||
Vertex_5 = geompy.MakeVertex(2.5, 1, 0) | ||
Vertex_6 = geompy.MakeVertex(1.5, 0.5, 0) | ||
Vertex_7 = geompy.MakeVertex(1.5, 1.5, 0) | ||
Vertex_8 = geompy.MakeVertex(5, 0.5, 0) | ||
Vertex_9 = geompy.MakeVertex(5, 1.5, 0) | ||
Circle_1 = geompy.MakeCircle(Vertex_5, None, 0.15) | ||
outer_boundary = geompy.MakePolyline([Vertex_1, Vertex_4, Vertex_3, Vertex_2], True) | ||
inner_boundary = geompy.MakePolyline([Vertex_6, Vertex_7, Vertex_9, Vertex_8], True) | ||
Face_1 = geompy.MakeFaceWires([Circle_1, outer_boundary], 1) | ||
domain = geompy.MakePartition([Face_1], [inner_boundary], [], [], geompy.ShapeType["FACE"], 0, [], 0) | ||
[domain_inner] = geompy.SubShapes(domain, [21]) | ||
[outlet,inlet,cyl_boundary] = geompy.SubShapes(domain, [11, 4, 24]) | ||
walls = geompy.CreateGroup(domain, geompy.ShapeType["EDGE"]) | ||
geompy.UnionIDs(walls, [7, 9]) | ||
boundary_inner = geompy.CreateGroup(domain, geompy.ShapeType["EDGE"]) | ||
geompy.UnionIDs(boundary_inner, [20, 18, 13, 16]) | ||
geompy.addToStudy( O, 'O' ) | ||
geompy.addToStudy( OX, 'OX' ) | ||
geompy.addToStudy( OY, 'OY' ) | ||
geompy.addToStudy( OZ, 'OZ' ) | ||
geompy.addToStudy( Vertex_1, 'Vertex_1' ) | ||
geompy.addToStudy( Vertex_2, 'Vertex_2' ) | ||
geompy.addToStudy( Vertex_3, 'Vertex_3' ) | ||
geompy.addToStudy( Vertex_4, 'Vertex_4' ) | ||
geompy.addToStudy( Vertex_5, 'Vertex_5' ) | ||
geompy.addToStudy( Vertex_6, 'Vertex_6' ) | ||
geompy.addToStudy( Vertex_7, 'Vertex_7' ) | ||
geompy.addToStudy( Vertex_8, 'Vertex_8' ) | ||
geompy.addToStudy( Vertex_9, 'Vertex_9' ) | ||
geompy.addToStudyInFather( domain, inlet, 'inlet' ) | ||
geompy.addToStudy( outer_boundary, 'outer_boundary' ) | ||
geompy.addToStudyInFather( domain, domain_inner, 'domain_inner' ) | ||
geompy.addToStudyInFather( domain, outlet, 'outlet' ) | ||
geompy.addToStudy( Circle_1, 'Circle_1' ) | ||
geompy.addToStudy( Face_1, 'Face_1' ) | ||
geompy.addToStudy( inner_boundary, 'inner_boundary' ) | ||
geompy.addToStudy( domain, 'domain' ) | ||
geompy.addToStudyInFather( domain, cyl_boundary, 'cyl_boundary' ) | ||
geompy.addToStudyInFather( domain, boundary_inner, 'boundary_inner' ) | ||
geompy.addToStudyInFather( domain, walls, 'walls' ) | ||
|
||
### | ||
### SMESH component | ||
### | ||
|
||
import SMESH, SALOMEDS | ||
from salome.smesh import smeshBuilder | ||
|
||
smesh = smeshBuilder.New() | ||
#smesh.SetEnablePublish( False ) # Set to False to avoid publish in study if not needed or in some particular situations: | ||
# multiples meshes built in parallel, complex and numerous mesh edition (performance) | ||
|
||
domain_1 = smesh.Mesh(domain) | ||
Regular_1D = domain_1.Segment() | ||
Max_Size_domain = Regular_1D.MaxSize(0.728011) | ||
MEFISTO_2D = domain_1.Triangle(algo=smeshBuilder.MEFISTO) | ||
Regular_1D_1 = domain_1.Segment(geom=domain_inner) | ||
mesh_domain_inner = Regular_1D_1.GetSubMesh() | ||
Max_Size_domain_inner = Regular_1D_1.MaxSize(0.05) | ||
MEFISTO_2D_1 = domain_1.Triangle(algo=smeshBuilder.MEFISTO,geom=domain_inner) | ||
Regular_1D_2 = domain_1.Segment(geom=inlet) | ||
Local_Length_outter_boundary = Regular_1D_2.LocalLength(0.1,None,1e-07) | ||
Regular_1D_3 = domain_1.Segment(geom=outlet) | ||
status = domain_1.AddHypothesis(Local_Length_outter_boundary,outlet) | ||
Regular_1D_4 = domain_1.Segment(geom=walls) | ||
status = domain_1.AddHypothesis(Local_Length_outter_boundary,walls) | ||
Regular_1D_5 = domain_1.Segment(geom=cyl_boundary) | ||
Local_Length_cyl = Regular_1D_5.LocalLength(0.03,None,1e-07) | ||
Regular_1D_6 = domain_1.Segment(geom=boundary_inner) | ||
|
||
sys.path.append("../../") # adding root folder of plugin to path | ||
import create_kratos_input_tui | ||
|
||
mesh_description_domain = { "elements" : {"Triangle" : {"Element2D3N" : 0} } } | ||
mesh_description_wall = { "conditions" : {"Edge" : {"WallCondition2D2N" : 0} } } | ||
|
||
# create multiple meshes with different refinements | ||
for mesh_factor in [2.0, 1.0, 0.5]: | ||
print("Computing mesh with Factor:", mesh_factor) | ||
|
||
Max_Size_domain.SetLength( mesh_factor ) | ||
Max_Size_domain_inner.SetLength( mesh_factor/10.0 ) | ||
Local_Length_cyl.SetLength( mesh_factor/20.0 ) | ||
Local_Length_cyl.SetPrecision( 1e-07 ) | ||
NETGEN_2D = domain_1.Triangle(algo=smeshBuilder.NETGEN_2D) | ||
isDone = domain_1.Compute() | ||
mesh_inlet = Regular_1D_2.GetSubMesh() | ||
mesh_outlet = Regular_1D_3.GetSubMesh() | ||
mesh_walls = Regular_1D_4.GetSubMesh() | ||
mesh_cyl_boundary = Regular_1D_5.GetSubMesh() | ||
|
||
## Set names of Mesh objects | ||
smesh.SetName(mesh_domain_inner, 'mesh_domain_inner') | ||
smesh.SetName(mesh_walls, 'mesh_walls') | ||
smesh.SetName(Regular_1D.GetAlgorithm(), 'Regular_1D') | ||
smesh.SetName(MEFISTO_2D.GetAlgorithm(), 'MEFISTO_2D') | ||
smesh.SetName(NETGEN_2D.GetAlgorithm(), 'NETGEN 2D') | ||
smesh.SetName(domain_1.GetMesh(), 'domain') | ||
smesh.SetName(Local_Length_outter_boundary, 'Local Length_outter_boundary') | ||
smesh.SetName(Max_Size_domain_inner, 'Max Size_domain_inner') | ||
smesh.SetName(Max_Size_domain, 'Max Size_domain') | ||
smesh.SetName(Local_Length_cyl, 'Local Length_cyl') | ||
smesh.SetName(mesh_outlet, 'mesh_outlet') | ||
smesh.SetName(mesh_cyl_boundary, 'mesh_cyl_boundary') | ||
smesh.SetName(mesh_inlet, 'mesh_inlet') | ||
|
||
# https://docs.salome-platform.org/latest/tui/KERNEL/kernel_salome.html | ||
# saving the study such that it can be loaded in Salome | ||
salome.myStudy.SaveAs("flow_cylinder_{}.hdf".format(mesh_factor), False, False) # args: use_multifile, use_acsii | ||
|
||
meshes = [ | ||
create_kratos_input_tui.SalomeMesh(domain_1, mesh_description_domain, "domain"), | ||
create_kratos_input_tui.SalomeMesh(mesh_inlet, mesh_description_wall, "inlet"), | ||
create_kratos_input_tui.SalomeMesh(mesh_outlet, mesh_description_wall, "outlet"), | ||
create_kratos_input_tui.SalomeMesh(mesh_walls, mesh_description_wall, "walls"), | ||
create_kratos_input_tui.SalomeMesh(mesh_cyl_boundary, mesh_description_wall, "cyl_boundary"), | ||
] | ||
|
||
create_kratos_input_tui.CreateMdpaFile(meshes, "flow_cylinder_{}".format(mesh_factor)) | ||
|
||
if salome.sg.hasDesktop(): | ||
salome.sg.updateObjBrowser() |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
![](https://media.giphy.com/media/3o7btQ0NH6Kl8CxCfK/giphy.gif) |