Got it. For future simulation I need file XML, how I can get this file from XDMF then? I’ve thought that Dolfin can help me with this issue. And this code is created for this purpose.
And even if I use only XDMF type in code like this
#!/usr/bin/python
# -*- coding: utf-8 -*-
from dolfin import *
# Create mesh from XDMF file
mesh = Mesh()
with XDMFFile("mesh.xdmf") as infile:
infile.read(mesh)
# Create a CellFunction to mark cell types
cell_markers = MeshFunction("size_t", mesh, 3)
# Iterate over cells and mark their types
for cell in cells(mesh):
if CellType == "tetrahedron":
cell_markers[cell] = 1 # tetrahedra are marked with value 1
elif CellType == "triangle":
cell_markers[cell] = 2 # triangles are marked with value 2
# Save cell information to XML file
with XDMFFile("cell_info.xml") as outfile:
outfile.write(cell_markers)
# Create subdomain cell function for tetrahedra
mvc_tetra = MeshValueCollection("size_t", mesh, 3)
with XDMFFile("mes_20.xdmf") as infile:
infile.read(mvc_tetra, "name_to_read")
subdomain_marker_tetra = cpp.mesh.MeshFunctionSizet(mesh, mvc_tetra)
# Save subdomain information to XML file
with XDMFFile("subdomain_info_tetra.xdmf") as outfile:
outfile.write(subdomain_marker_tetra)
# Create boundary subdomain facet function for triangles
mvc_triangle = MeshValueCollection("size_t", mesh, 2)
with XDMFFile("mf_20.xdmf") as infile:
infile.read(mvc_triangle, "name_to_read")
boundary_marker_triangle = cpp.mesh.MeshFunctionSizet(mesh, mvc_triangle)
# Save boundary information to XML file
with XDMFFile("boundary_info_triangle.xdmf") as outfile:
outfile.write(boundary_marker_triangle)
I get this ERROR
Traceback (most recent call last):
File "secondpartexam.py", line 27, in <module>
infile.read(mvc_tetra, "name_to_read")
RuntimeError:
*** -------------------------------------------------------------------------
*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at
***
*** fenics-support@googlegroups.com
***
*** Remember to include the error message listed below and, if possible,
*** include a *minimal* running example to reproduce the error.
***
*** -------------------------------------------------------------------------
*** Error: Unable to recognise cell type.
*** Reason: Unknown value "".
*** Where: This error was encountered inside XDMFFile.cpp.
*** Process: 0
***
*** DOLFIN version: 2019.2.0.dev0
*** Git changeset: unknown
Due to this message I realize that Dolfin cannot recognize cell type, but in my XDMF file cell’s type mention like tetra or triangle, however, this information saved as topology. Topology TopologyType=“Tetrahedron”
So, two questions:
How I can get XML file if I have XDMF files?
How help Dolfin recognize cell type if this information saved as topology?
As you have not supplied your msh-file or xdmf-file or a reproducible example, I cannot do much else than point you to the resources I’ve already supplied.
Thank you for support. Could you say me where I can find information about File class?
This is my files xdmf Files XDMF and MSH
And two questions more:
Using meshio.write I can create file XDMF from .msh file or I can create file .xml. Is it right?
Could I create one XML file which will contain the whole information about my mesh like domains, cell type etc. or I always have to create several files one of them contains information about facet, othet about domans and so on & so forth?
Hello, everyone. I have a question, during my study I have a problem like this
Assembling the weak form of operator 'Op1'...
Collecting data for assembler construction...
Data collection finished.
Precalculating singular integrals...
Precalculation of singular integrals took 12.1156 s
Assembly of the weak form of operator 'Op1' took 39.6848 s
Assembling the weak form of operator 'Op2'...
Collecting data for assembler construction...
Data collection finished.
Assembly of the weak form of operator 'Op2' took 0.0617588 s
Calculating the (pseudo)inverse of operator 'Op2'...
Calculation of the (pseudo)inverse of operator 'Op2' took 0.0851854 s
Solving linear system of size 39585 x 39585 (PETSc Krylov solver).
Traceback (most recent call last):
File "newtry.py", line 52, in <module>
for i in range (300): llg.step(state, 2e-11)
File "/usr/local/lib/python2.7/dist-packages/magnumfe/integrators/llg_alouges_project.py", line 151, in step
File "/usr/local/lib/python2.7/dist-packages/magnumfe/integrators/llg_alouges_project.py", line 148, in step
File "/usr/local/lib/python2.7/dist-packages/magnumfe/integrators/llg_alouges_project.py", line 134, in calculate_v
File "/usr/local/lib/python2.7/dist-packages/magnumfe/integrators/llg_alouges_project.py", line 132, in calculate_v
File "/usr/local/lib/python2.7/dist-packages/magnumfe/integrators/llg_alouges_project.py", line 132, in calculate_v
File "/usr/lib/python2.7/dist-packages/dolfin/fem/solving.py", line 279, in solve
return cpp.la_solve(*args)
File "/usr/lib/python2.7/dist-packages/dolfin/cpp/la.py", line 4279, in la_solve
return _la.la_solve(*args)
RuntimeError:
*** -------------------------------------------------------------------------
*** DOLFIN encountered an error. If you are not able to resolve this issue
*** using the information listed below, you can ask for help at
***
*** fenics@fenicsproject.org
***
*** Remember to include the error message listed below and, if possible,
*** include a *minimal* running example to reproduce the error.
***
*** -------------------------------------------------------------------------
*** Error: Unable to solve linear system using PETSc Krylov solver.
*** Reason: Solution failed to converge in 0 iterations (PETSc reason DIVERGED_NANORINF, residual norm ||r|| = -nan).
*** Where: This error was encountered inside PETScKrylovSolver.cpp.
*** Process: unknown
***
*** DOLFIN version: 1.5.0
*** Git changeset: unknown
*** -------------------------
Mesh file, XML and XDMF files
Could you explain me why it cannot solve linear system and how I can fix it? Thanks in advance.