KVSlab / VaMPy

A collection of tools for pre-processing, simulating, and post-processing vascular morphologies.
https://kvslab.github.io/VaMPy
GNU General Public License v3.0
15 stars 8 forks source link

Error with the tutorial in document #68

Closed yewalenikhil65 closed 2 years ago

yewalenikhil65 commented 2 years ago

I am encountering following error for running the simulation using Oasis for artery example as shown in the documentation

nikhil@fsi:~/VaMPy/simulation$ oasis NSfracStep problem=Artery mesh_path=../test/Case_test_artery/artery.xml.gz T=9.61 save_solution_after_cycle=0 && cd ..

error as follows

 nikhil@fsi:~/VaMPy/simulation$ oasis NSfracStep problem=Artery mesh_path=../test/Case_test_artery/artery.xml.gz T=9.61 save_solution_after_cycle=0 && cd ..
Importing problem module Artery:
/home/nikhil/VaMPy/simulation/Artery.py
=== Starting simulation for case: artery ===
Running with the following parameters:
{'AB_projection_pressure': False,
 'DynamicSmagorinsky': {'Cs_comp_step': 1},
 'KineticEnergySGS': {'Ce': 1.05, 'Ck': 0.08},
 'ModifiedCross': {'a_param': 0.34,
                   'lam': 3.736,
                   'm_param': 2.406,
                   'mu_inf': 0.00372,
                   'mu_o': 0.09,
                   'rho': 1085},
 'Smagorinsky': {'Cs': 0.1677},
 'T': 1902,
 'Wale': {'Cw': 0.325},
 'area_inlet': [],
 'area_ratio': [],
 'cardiac_cycle': 951,
 'checkpoint': 500,
 'dt': 0.0951,
 'dump_probe_frequency': 100,
 'folder': 'results_artery/artery',
 'id_in': [],
 'id_out': [],
 'iters_on_first_timestep': 2,
 'killtime': None,
 'krylov_solvers': {'monitor_convergence': False},
 'les_model': 'NoModel',
 'max_error': 1e-06,
 'max_iter': 1,
 'mesh_path': '../test/Case_test_artery/artery.xml.gz',
 'nn_model': 'NoModel',
 'nu': 0.0033018,
 'nu_nn_krylov_solver': {'method': 'WeightedAverage',
                         'preconditioner_type': 'jacobi',
                         'solver_type': 'cg'},
 'nut_krylov_solver': {'method': 'WeightedAverage',
                       'preconditioner_type': 'jacobi',
                       'solver_type': 'cg'},
 'output_timeseries_as_vector': True,
 'plot_interval': 10,
 'pressure_degree': 1,
 'pressure_krylov_solver': {'preconditioner_type': 'hypre_amg',
                            'solver_type': 'gmres'},
 'print_intermediate_info': 100,
 'print_velocity_pressure_convergence': False,
 'restart_folder': None,
 'save_solution_after_cycle': 1,
 'save_solution_frequency': 5,
 'save_step': 10,
 'scalar_krylov_solver': {'preconditioner_type': 'jacobi',
                          'solver_type': 'bicgstab'},
 'solver': 'IPCS_ABCN',
 't': 0.0,
 'testing': False,
 'tstep': 0,
 'use_krylov_solvers': True,
 'velocity_degree': 1,
 'velocity_krylov_solver': {'preconditioner_type': 'jacobi',
                            'solver_type': 'bicgstab'},
 'velocity_update_solver': {'low_memory_version': False,
                            'method': 'default',
                            'preconditioner_type': 'jacobi',
                            'solver_type': 'cg'}}
Traceback (most recent call last):
  File "/home/nikhil/anaconda3/envs/vampy_environment/bin/oasis", line 33, in <module>
    sys.exit(load_entry_point('oasis', 'console_scripts', 'oasis')())
  File "/home/nikhil/Oasis/oasis/run_oasis.py", line 11, in main
    from oasis import NSfracStep
  File "/home/nikhil/Oasis/oasis/NSfracStep.py", line 60, in <module>
    vars().update(post_import_problem(**vars()))
  File "/home/nikhil/Oasis/oasis/problems/__init__.py", line 212, in post_import_problem
    mesh = mesh(**NS_parameters)
  File "/home/nikhil/VaMPy/simulation/Artery.py", line 79, in mesh
    mesh = Mesh(mesh_path)
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 read data from XML file.
*** Reason:  Not a DOLFIN XML file.
*** Where:   This error was encountered inside XMLFile.cpp.
*** Process: 0
*** 
*** DOLFIN version: 2019.1.0
*** Git changeset:  ba376b6aebd7a9bc089be46b50bdd9f5c548fb91
*** -------------------------------------------------------------------------

Can someone please help me with this ?

hkjeldsberg commented 2 years ago

Hello @yewalenikhil65 ,

Thanks for reporting the issue! This is interesting; did you have any issues or suspicious output during the pre-processing (with automatedPreProcessing.py)? Alternatively, could you provide the .xml.gz (and .vtu) files, if available?

Best regards, Henrik

yewalenikhil65 commented 2 years ago

yes.. i did encounter an error in generating mesh files.. as follows.. I think DOLFIN suitable mesh file wasn't generated properly

Remeshing endcaps
Iteration 1/10
Iteration 2/10
Iteration 3/10
Iteration 4/10
Iteration 5/10
Iteration 6/10
Iteration 7/10
Iteration 8/10
Iteration 9/10
Iteration 10/10
Final mesh improvement
Computing sizing function
Generating volume mesh
TetGen command line options: pq1.414000q10.000000q165.000000YsT1.000000e-08zQm
Assembling final mesh
2022-09-13 18:22:17.674 (  18.644s) [        AE894740]       vtkThreshold.cxx:84    WARN| vtkThreshold::ThresholdByUpper was deprecated for VTK 9.1 and will be removed in a future version.
Writing Dolfin file.
Traceback (most recent call last):
  File "/home/nikhil/VaMPy/automatedPreProcessing/automatedPreProcessing.py", line 505, in <module>
    run_pre_processing(**read_command_line())
  File "/home/nikhil/VaMPy/automatedPreProcessing/automatedPreProcessing.py", line 307, in run_pre_processing
    write_mesh(compress_mesh, file_name_surface_name, file_name_vtu_mesh, file_name_xml_mesh,
  File "/home/nikhil/VaMPy/automatedPreProcessing/common.py", line 756, in write_mesh
    meshWriter.Execute()
  File "/home/nikhil/anaconda3/envs/vampy_environment/lib/python3.10/site-packages/vmtk/vmtkmeshwriter.py", line 365, in Execute
    self.WriteDolfinMeshFile()
  File "/home/nikhil/anaconda3/envs/vampy_environment/lib/python3.10/site-packages/vmtk/vmtkmeshwriter.py", line 268, in WriteDolfinMeshFile
    gzfile.write(xml)
  File "/home/nikhil/anaconda3/envs/vampy_environment/lib/python3.10/gzip.py", line 285, in write
    data = memoryview(data)
TypeError: memoryview: a bytes-like object is required, not 'str'

also attaching .vtuand .xml.gz files generated ..zipped into following artery.zip artery.zip

hkjeldsberg commented 2 years ago

Hi @yewalenikhil65 ,

I think I have experienced something similar before. I think this is an issue with the vmtkmeshgenerator.pyscript, in the way it compresses the Dolfin mesh. So two options I can think of is

  1. Run the pre-processing with --compress-mesh False and use `mesh_path=[some path]/artery.xml

or

  1. Edit the vmtkmeshgenerator.py file (for you located under /home/nikhil/anaconda3/envs/vampy_environment/lib/python3.10/site-packages/vmtk/) and change lines 263 and 268 from 'r' and 'w' to 'rb' and 'wb', respectively.

I will probably include this in the documentation if the issue is not fixed on VMTKs side, so thank you for noticing!

Best, Henrik

yewalenikhil65 commented 2 years ago

hi @hkjeldsberg , i check the file vmtkmeshgenerator.py. However, I couldn't find strings r and w within whole file (quick control+f !). is it some other file ?

can you tell me full command according to the first option ?

hkjeldsberg commented 2 years ago

Hi @yewalenikhil65 ,

Sorry! I meant the vmtkmeshwriter.py file! Located within the WriteDolfinMeshFile() function.

Best, Henrik

yewalenikhil65 commented 2 years ago

Hi @yewalenikhil65 ,

Sorry! I meant the vmtkmeshwriter.py file! Located within the WriteDolfinMeshFile() function.

Best, Henrik

thanks very much.. that did the trick..

I had three more questions, if you would like to address regarding VaMPy 1) Can we use mesh file generated in ANSYS(ICEM-CFD) . i.e. .msh format and read it into VaMPy ? 2) How generalised is the mesh generation procedure adopted in VaMPy , say for the problems of intracranial aneurysms ? 3) how to visualise solution in paraview ? i mean how do I read .h5 files generated in simulations folder?

hkjeldsberg commented 2 years ago

Also, @yewalenikhil65 ,

The full command would be first:

python automatedPreProcessing/automatedPreProcessing.py -m diameter -i test/Case_test_artery/artery.vtp -c 1.3 -cM False

Then

oasis NSfracStep problem=Artery mesh_path=../test/Case_test_artery/artery.xml T=9.61 save_solution_after_cycle=0 && cd ..

Hope this helps!

hkjeldsberg commented 2 years ago

Hi @yewalenikhil65 , Sorry! I meant the vmtkmeshwriter.py file! Located within the WriteDolfinMeshFile() function. Best, Henrik

thanks very much.. that did the trick..

I had three more questions, if you would like to address regarding VaMPy

  1. Can we use mesh file generated in ANSYS(ICEM-CFD) . i.e. .msh format and read it into VaMPy ?
  2. How generalised is the mesh generation procedure adopted in VaMPy , say for the problems of intracranial aneurysms ?
  3. how to visualise solution in paraview ?

@yewalenikhil65 Great! Happy it worked.

  1. I think it is possible, if you manage to save or convert your ANSYS mesh into .xdmf format. Unfortunately, I am not so familiar with the meshing process in Ansys. However I found one possibility you could check out here, posted quite recently.
  2. Mesh generation is rather general to any kinds of tubular or vascular structures, and we are currently extending the pipeline for it to adapt to atrium models. For models harbouring an intracranial aneurysms I would probably run a similar pre-processing, but also perform refinement (using the --refine-region flag set to True) of the aneurysm region.
  3. Currently, we have focused on the hemodynamic indices computed with the post-processing scripts, so it is not directly possible to visualize the flow field without loading them into FEniCS and saving them as ".xdmf" or similar. This would correspond so storing the value u = Function(V) in compute_hemodynamic_indices.py for each time step. Saving to .h5 was initially done to save storage space, but I agree that the velocity field should be part of the solution or post-processing. I can make an issue on this 👍

Best, Henrik

hkjeldsberg commented 2 years ago

Closing this issue for now. The hotfix has been added to the documentation as part of PR #73, and merged to master as soon as the tests pass.