This tutorial should give you a good idea of how to use different FEM codes in FEMhub. The document is under continuous development - if you find bugs or would like us to improve something, let us know through the mailing list.
Hermes is a C++ library for rapid prototyping of space and space-time adaptive hp-FEM solvers, and it is one of the FEM engines included in FEMhub. Although Hermes is written in C++ you do not need to know anything about C++ besides basic python when you use Hermes within FEMhub. For details on how to use Hermes itself please refer to Hermes documentation.
Every finite element computation starts with partitioning the domain into a finite element mesh. Hermes uses triangles and quadrilaterals, and can combine both element types in one mesh. While complicated meshes need to be constructed using specialized mesh generation software, in many cases we only need a simple initial mesh that can be created by hand. In Hermes, all you need to do is partition the domain very coarsely into several large elements, and the adaptivity will take care of the rest.
The domain is defined via four macroelements – two quadrilaterals and two curvilinear triangles. The elements are enumerated from 0 to 3. One also needs to enumerate all mesh vertices and assign markers to all boundary edges. Boundary markers are used to link boundary conditions with the boundary edges. The following example Mesh will make clear about how to create mesh in FEMhub.
to be done...
Example of calculation
import hermes_common
import hermes2d
class PyCustomWeakFormPoisson(hermes2d.PyCustomWeakFormReal):
def __init__(self, mat_al, mat_cu):
self.super(1)
self.add_matrix_form(hermes2d.PyDefaultJacobianDiffusion(0,0, mat_al))
self.add_matrix_form(hermes2d.PyDefaultJacobianDiffusion(0,0, mat_cu))
self.add_vector_form(hermes2d.PyDefaultResidualDiffusion(0, mat_al))
self.add_vector_form(hermes2d.PyDefaultResidualDiffusion(0, mat_cu))
self.add_vector_form(hermes2d.PyDefaultVectorFormVol(0))
mesh=hermes2d.PyMesh()
reader=hermes2d.PyMeshReaderH2DXML()
# Load the mesh.
reader.load("domain.xml",mesh)
mesh.refine_all_elements()
# Create a boundary condition
markers = []
markers.append("Bottom")
markers.append("Inner")
markers.append("Outer")
markers.append("Left")
bc = hermes2d.PyDefaultEssentialBCConstReal(markers, 20.0)
# Create the structure for the BCs to be passed
bcs = hermes2d.PyEssentialBCsReal(bc)
space=hermes2d.PyH1SpaceReal(mesh, bcs, 3)
wf= PyCustomWeakFormPoisson("Aluminum", "Copper")
dp = hermes2d.PyDiscreteProblemReal(wf,space)
solution = hermes2d.PySolutionReal()
newton = hermes2d.PyNewtonSolverReal(dp)
coef=[]
for i in range(space.get_num_dofs()):
coef.append(0)
newton.solve(coef)
hermes2d.PySolutionReal().vector_to_solution(newton.get_sln_vector(), space, solution)