How to create a geometry#
OpenFDEM supports users to create all types of 2D geometries by using basic geometry types such as squares and circles or even polygons with Boolean operation to cut or remove one geometry from another. All syntaxes of creating geometries are explained in the command reference. A simple geometry as shown below will be created in this tutorial.
1 Code#
Warning
Please note that, all the setting in the example is based on the developer’s computer. You may need to change these details based on your own environment.
To start with programming, create a new empty input file or copy it from the existing examples (later add the .of
extension). Begin writing the following commands:
2.1 Initialize the model#
1 Create a new run and clean up the old memories.
of.new
Set up the folder name to save your results. Here the folder name is set to be “result”.
of.set.result "result"
Set the number of cores to be used for running this model in parallelization.
of.set.omp 15
Set the geometry domain.
of.geometry.domain xmin -12 xmax 12 ymin -12 ymax 12
2.2 Create the geometry#
Create a sqaure block and call it “rock”.
of.geometry.square 'rock' [-10 10 -10 10]
Remove a circular tunnel at the top right corner.
of.geometry.remove.circle 'circle' 'rock' [5 7 1.5 20]
Remove a rectangular tunnel at the top left corner.
of.geometry.remove.square 'square' 'rock' [-6 -4 4 9]
Cut an arc at the center.
of.geometry.cut.arc 'arc' 'rock' [0 0 2 0 180 10]
Cut a rectangle underneath the arc.
of.geometry.cut.square 'base' 'rock' [-2 2 -5 0]
2.3 Create the mesh#
Assign the mesh size and create the mesh
of.geometry.mesh.size 'default' 0.5
of.geometry.mesh auto
Finalize the model and clear memory
of.finalize
2 Full Script#
Create_Geometry.of (click to download from GitHub)
# initialization, this command is to clear the memory in your last run, it is not
# mandatory but strongly recommend.
of.new
# Set the path folder of your output results, //result// in the same path of your input
# file will be created by default
of.set.result "result"
# Set the number of cores you want to use, the parallization will be automatically
# turned on when you use the following command, otherwise the serilization will be
# used by default
of.set.omp 15
# Define the geometry domain
of.geometry.domain xmin -12 xmax 12 ymin -12 ymax 12
###################################### create mesh ######################################
# Create the boundary
of.geometry.square 'rock' [-10 10 -10 10]
# Remove a circle from the rock block
of.geometry.remove.circle 'circle' 'rock' [5 7 1.5 20]
# Remove a rectangle from the rock block
of.geometry.remove.square 'square' 'rock' [-6 -4 4 9]
# Cut the tunnel with an arc at the top
of.geometry.cut.arc 'arc' 'rock' [0 0 2 0 180 10]
of.geometry.cut.square 'base' 'rock' [-2 2 -5 0]
# Create the mesh
of.geometry.mesh.size 'default' 0.5
of.geometry.mesh auto
# Finalize the model and clear the memory