Closed startrekman closed 3 years ago
@startrekman I think all operations should be done using MFEM APIs. @mortezah can confirm.
Okay, so I have mesh = mfem.Mesh(10, 10, "TRIANGLE") how would I change the shape from [0,1] x [0,1] to say [x,y] x [xi, eta]?
How would I change the dimension of the mesh such that: mesh.Dimension() = 3?
Thank you for your help :-)
@startrekman I am assuming this is in regards to assignment 4 and not a general question about MFEM. Understanding the inner workings of MFEM and MFEM mesh format is not straightforward. Now can you specify why you would need to make a mesh? For the assignments, all the meshes are provided in the data
folder.
As for the boundary conditions, here is the info that you need. The boundary elements in an MFEM mesh have attributes. For example, for the meshes in the data
folder, all the mesh edges on the right-most edge of the square have the attribute 7, and so on for the rest of the boundary edges as shown in this figure https://github.com/SCOREC/fep/blob/master/a4/data/1x1_square_details.png
Now to apply a boundary condition, you have to specify which boundary will get each type of boundary condition, and in MFEM that is done by means of these attributes. For example, you can say set the value of the solution to 12.0 for all things with attribute 7 and that would apply that condition to all edges (and/or verts) on the right-most-edge of that square domain. An example of this is done here https://github.com/SCOREC/fep/blob/d16f0b636671f519bcfb8ea91d07fc04638ad091/a4/a4_diffusion.cpp#L99 for Dirichlet type boundary conditions and here https://github.com/SCOREC/fep/blob/d16f0b636671f519bcfb8ea91d07fc04638ad091/a4/a4_diffusion.cpp#L115 for Neumann type boundary conditions.
Okay, so I have mesh = mfem.Mesh(10, 10, "TRIANGLE") how would I change the shape from [0,1] x [0,1] to say [x,y] x [xi, eta]?
How would I change the dimension of the mesh such that: mesh.Dimension() = 3?
Thank you for your help :-)
I don't exactly understand what is being asked here.
no this is a general question, I finished a4 earlier this week. I am working on getting mfem setup in python so that I can put it through UQ/ AI stuff
However, it seems likely there would be a 3d rectangular plate shape that could be used or modified.
If you want to make a 3D mesh you probably want to use this API instead
http://mfem.github.io/doxygen/html/classmfem_1_1Mesh.html#a52d3f7cfa529e9cbf5ec7396b69eb7e1
so something like mfem.mesh(10,101,0, "QUADRILATERAL", 10,10,2) would create a 10x10x2 box
However, this does not work with the python wrapper. It seems like python only wants the .mesh file.
Are you using PyMFEM?
You cannot have a 3D mesh with quadrilateral elements. You will need a 3D element type like a Hexahedron
Yes, I am
I just checked the source code of PyMFEM. The api you are using seems to have been implemented in PyMFEM. So my guess is that you are not using it correctly. If you think there is still a problem with that python API you should submit an issue to the PyMFEM github repo here https://github.com/mfem/PyMFEM
Yes, but I intended something 2D like: mfem.mesh(10,10, "QUADRILATERAL", 10., 10.)
Is this correct?
I am not sure where to find the documentation
Most of the examples (that I have seen) seem to use the mesh file
I guess you are missing an argument after "Quad" and before the first 10. Also mesh.mesh
should be changed to mesh.Mesh
Here is a short script that I just tested and it correctly creates the attached picture
import sys
from os.path import expanduser, join
import numpy as np
from mfem.common.arg_parser import ArgParser
from mfem import path
import mfem.ser as mfem
import os
# mesh = mfem.Mesh(10, 10, "QUADRILATERAL", False, 5., 7, True)
mesh = mfem.Mesh(10, 10, "QUADRILATERAL", False, 1.0, 3.0, True)
mesh.PrintVTU("outmesh")
Most of the python APIs have similar declarations to the corresponding C++ APIs.
Also, there is a rough manual here https://github.com/mfem/PyMFEM/blob/master/docs/manual.txt
Your PyMFEM related questions should be posted on the corresponding repo. The developers of PyMFEM will be a lot quicker to respond to these questions.
I am having a bit of trouble figuring out how to work the mesh files in mfem. I am curious about how to write a mesh file for just a simple mesh. For example, for a quad, I would have:
dimension 2
elements 2 2 3 0 1 2 3
boundary 1 0
vertices 6 0 0 0 1 1 0 1 1
But I still don't really understand how it works. For example in elements, I think 2 refers to the dimension of the element, 3 refers to the quad shape, 0 1 2 3 refers to the vertex points. But does 0 -> 00, 1 -> 0 1, 2-> 1 0, 3-> 1 1? Second, how does the boundary work? I really do not understand this. For example, if I only wanted a boundary condition on vertex 0 would it be as it is above?