Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Creating an arbitrary geometry, mesh and boundary assignment! #1122

Closed
ashaygan opened this issue Apr 18, 2022 · 6 comments
Closed

Creating an arbitrary geometry, mesh and boundary assignment! #1122

ashaygan opened this issue Apr 18, 2022 · 6 comments

Comments

@ashaygan
Copy link

Creating geometry, meshing, and assigning BCs to the named boundaries

The documentation is very comprehensive, educational, and well written, however a few sections such as Geometry is still missing. It is not clear how to create an arbitrary geometry and mesh it, then impose boundary conditions.

Should a meshed geometry necessarily be created though a third-party software, then get exported into Trixi.jl or it can be done directly in Julia using Trixi.jl? If it is done using another software, which software, and what kind of file format? The documentation quickly mentions to two ways, as far as I understood: 1: Abaqus, 2: P4est.

1: Abaqus: (.inp file), right? Then how Trixi.jl recognizes the names of the boundaries and how they can be assigned with different boundary conditions? By making a dictionary and using the names of the boundaries Abaqus had generated? Is the boundary naming that is made by Abacus directly applicable in Trixi using a Dict?!

2: P4est: It comes in C as well as Julia. Is the Julia package sufficient and can it be used to generate geometry/mesh? If yes, what about boundaries and how to assign each boundary to its boundary condition?

Is there an alternative to the two methods above?
Any kind of solution is appreciated.

By the way, I am working on a simple geometry, that should use adaptive refinement method.
The computational domain is a rectangle with two holes in it! Two circles with different boundary conditions and a rectangular domain with boundary conditions on each wall.

@ranocha
Copy link
Member

ranocha commented Apr 19, 2022

You cannot create arbitrary curved meshes with Trixi.jl itself. However, we provide other tools for meshing, e.g., HOHQMesh.jl. We have a tutorial on that in our docs: https://trixi-framework.github.io/Trixi.jl/stable/tutorials/hohqmesh_tutorial
You can save a mesh generated with HOHQMesh.jl as *.inp file and load it as P4estMesh, see https://trixi-framework.github.io/Trixi.jl/stable/reference-trixi/#Trixi.P4estMesh-Union{Tuple{String},%20Tuple{NDIMS}}%20where%20NDIMS

@andrewwinters5000
Copy link
Member

andrewwinters5000 commented Apr 19, 2022

Before I give more detailed answers I would point you to the Trixi tutorial 9: Unstructured meshes with HOHQMesh.jl. This should help answer some questions and clarify certain aspects of running Trixi on an unstructured mesh, e.g., setting up the boundary condition dictionary. Although this tutorial does not discuss running with AMR via p4est, I will clarify that detail below.

Should a meshed geometry necessarily be created though a third-party software, then get exported into Trixi.jl

Yes, you need to use a third-party software to generate an appropriate mesh file for the type of geometry you mention, an outer boundary and multiple inner curved boundaries. This mesh file can then be parsed by Trixi.

If it is done using another software, which software

The mesh generator that we typically use is HOHMesh.jl. This is a Julia package that is a wrapper around the spectral element mesh generator HOHQMesh that is written in Fortran.

The HOHQMesh generator requires a "control file" to instruct what is the outer boundary, what are the inner boundaries, what are the boundaries named, and other mesh specifics. The most important aspect here is to remember what you named the outer boundary and any of the inner boundary CHAINs in your control file as you will use the same names when creating your boundary condition dictionary.

The tutorial I linked above gives a short walk-through of how to create the control file. If you encounter problems there is a more thorough discussion of control files in the HOHQMesh docs.

and what kind of file format?

There are two options for unstructured mesh formats from HOHQMesh:

  1. ISM-V2 is a proprietary HOHQMesh format that will create a mesh file my_mesh_file.mesh. This is the format used in the tutorial linked above and discussed in the Unstructured quadrilateral mesh part of the Trixi docs. Note this mesh file format only works with the UnstructuredMesh2D and does not support AMR.
  2. ABAQUS is a format available from HOHQMesh that will create a mesh file my_mesh_file.inp. It is described in detail in the P4est-based mesh part of the Trixi docs. Basically it is the "standard" finite element ABAQUS format which is then appended by high-order boundary information and names that are created by HOHQMesh. You do not need to really worry about this, it is all taken care of under the hood, but I mention it to reiterate that you need to keep track on what you have named your outer / inner boundaries to properly set the boundary condition dictionary. This mesh file format only works with the P4estMesh and does support AMR. There is not a tutorial for this configuration but have a look at examples/p4est_2d_dgsem/elixir_euler_wall_bc_amr.jl to see how the setup and mesh construction happens.

Switching to a different mesh format is easy. Once you have your HOHQMesh control file you can freely change winthin the RUN_PARAMTERS the mesh file format = to be either ISM-v2 or ABAQUS and then regenerate the mesh to get the actual mesh file.

Is there an alternative to the two methods above?

We are currently developing some interactive tools within HOHQMesh.jl to somewhat streamline this mesh generation process. These tools will allow a user to add outer / inner boundary curves, change the background grid, change mesh flie format, etc. Then the control file is automatically created for the user and the mesh file is generated. You can follow its development here.

By the way, I am working on a simple geometry, that should use adaptive refinement method.
The computational domain is a rectangle with two holes in it! Two circles with different boundary conditions and a rectangular domain with boundary conditions on each wall.

Then I will lastly mention that the outer boundaries of a box domain are automatically given the names Bottom, Top, Left, and Rightin HOHQMesh. So you would only need to keep track on what you name the inner circular boundaries.

@ashaygan
Copy link
Author

@ranocha @andrewwinters5000

Thank you very much for your helpful and prompt comments. Now It is much more clear.
So if I need it run with AMR, generated meshes through Abaqus and HOHQMesh.jl both work for me. And for both cases, the mesh file should be .inp to be used with AMR. Is that correct?

And is the following conclusion correct?!
As long as I generate a mesh with HOHQMesh.jl and save it in * .inp, it can be used with AMR. This means that the mesh example in https://trixi-framework.github.io/Trixi.jl/stable/tutorials/hohqmesh_tutorial/ cannot directly be used with AMR but if I save it as *.inp, It can be used! Does this mean that I only need to change the file format in the following code from ISM-v2 to inp to be used with AMR? Or the construction is totally different?

\begin{RUN_PARAMETERS}
        mesh file name   = ice_cream_straight_sides.mesh
        plot file name   = ice_cream_straight_sides.tec
        stats file name  = none
        mesh file format = ISM-v2
        polynomial order = 4
        plot file format = skeleton
    \end{RUN_PARAMETERS}

@ranocha
Copy link
Member

ranocha commented Apr 20, 2022

Sounds right to me but @andrewwinters5000 should confirm this, too.
@andrewwinters5000 We should probably update the tutorial to reflect this?

@andrewwinters5000
Copy link
Member

Yes, the file extension *.inp is what the P4estMesh constructor expects. The actual mesh generated by HOHQMesh.jl is the same for either format, all that is changed is the layout of the mesh data in the file. So, in essence, yes you can use the mesh from that tutorial and run with AMR. You would need to change the run parameters block to be

   \begin{RUN_PARAMETERS}
        mesh file name   = ice_cream_straight_sides.inp
        plot file name   = ice_cream_straight_sides.tec
        stats file name  = none
        mesh file format = ABAQUS
        polynomial order = 4
        plot file format = skeleton
    \end{RUN_PARAMETERS}

Then in the mesh construction step of the elixir file you would need to call the appropriate constructor

# create the initial p4est mesh from your mesh file
mesh_file = joinpath("out", "ice_cream_straight_sides.inp")
mesh = P4estMesh{2}(mesh_file)

Also, you need to add an AMR controller and AMR callback to the elixir to turn on this functionality.

@ranocha Yes, it is a good idea to update this tutorial with a small discussion at the end about how to use the p4est and AMR functionality.

@ashaygan
Copy link
Author

@ranocha @andrewwinters5000 It's all clear now. Let me just add this closing comment to thank you all for your very kind and helpful responses.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants