mdolab / idwarp

IDWarp is a mesh warping package for the MACH framework.
Other
17 stars 29 forks source link

Unable to write grid #80

Closed sreekar2858 closed 1 year ago

sreekar2858 commented 1 year ago

Description

I have an cube OpenFOAM mesh and tried to deform top and side faces by x1.05 to test if idwarp works. But I am getting an error at the end of the run. I am attaching the case directory with .py file for reference. OF_idwarp.zip

Steps to reproduce issue

  1. I am using idwarp from dafoam-latest running on docker. https://dafoam.github.io/mydoc_get_started_download_docker.html

Current behavior

Python is throwing error that

 Finished Mesh Initialization.
Traceback (most recent call last):
  File "solid_warp.py", line 44, in <module>
    mesh.writeGrid()
  File "/home/dafoamuser/dafoam/packages/miniconda3/lib/python3.8/site-packages/idwarp/UnstructuredMesh.py", line 505, in writeGrid
    self._writeOpenFOAMVolumePoints(self.getCommonGrid())
AttributeError: 'USMesh' object has no attribute '_writeOpenFOAMVolumePoints'

Expected behavior

It should've changed the polyMesh in OpenFOAM directory

Code versions

sseraj commented 1 year ago

It looks like the function _writeOpenFOAMVolumePoints was moved to pyofm, but the call was not updated in USMesh. The fix should be to just replace this call, is that right @friedenhe?

friedenhe commented 1 year ago

@sseraj, that is right. The _writeOpenFOAMVolumePoints function is deprecated in IDWarp. @sreekar2858, to test IDWarp, please deform the mesh and run the primal solver for one step. It will save the flow solution and the deformed mesh to a folder called "1". You can then use Paraview to load the "1" step and visualize the mesh change.

sreekar2858 commented 1 year ago

Thank you for the prompt response. I can't change the call within docker to pyofm, can I? If yes, can you please direct me how?

friedenhe commented 1 year ago

No, you can't. There is no easy way to directly output the volume mesh without calling the primal solver.

sreekar2858 commented 1 year ago

No, you can't. There is no easy way to directly output the volume mesh without calling the primal solver.

Do you suggest any other way of morphing mesh that has good results as IDWarp? I would like to deform the solid mesh based on a list of points. At some locations the elements are collapsing, so, it would be great if you recommend an alternative short-term.

friedenhe commented 1 year ago

@sreekar2858, to test IDWarp, please deform the mesh and run the primal solver for one step. It will save the flow solution and the deformed mesh to a folder called "1". You can then use Paraview to load the "1" step and visualize the mesh change.

sreekar2858 commented 1 year ago

Sorry, I don't understand what you mean by deform the mesh. I am using dafoam's docker container but the case I shared is for plain OpenFOAM with no optimization. Can you please elaborate on how I can deform the mesh?

My goal is not to optimize the geometry but rather deform it at specific surfaces with corresponding known nodal/ FFD location.

friedenhe commented 1 year ago

Check this: https://github.com/DAFoam/tutorials/blob/4d9761f90492b84cace353e516dc2950dc56adbe/Prowim_Wing_Propeller/runScript_v2.py#L298

sreekar2858 commented 1 year ago

Thank you for the reference I tried using deformMesh on the same geometry I ran optimization on to make it simple. I got the shapez values from out file and modified the json file retaining all other information. I also changed the task to "deformMesh". I can see the mesh change but it is not the same and it is overlapping as in the picture. image Also you can notice that the deformed mesh is overlapping image

I am also attaching the runscript for reference runScript_v2.zip

Thank you Sreekar

sreekar2858 commented 1 year ago

@sseraj Also can I ask if there is any docker image with IDWarp besides DAFoam?

sseraj commented 1 year ago

The MDO Lab docker images also include IDWarp, but the deprecated function call will still be in that image. We will try to update the code soon.

bernardopacini commented 1 year ago

Thanks for bringing this up. It is on my todo list and I will address it soon.

sreekar2858 commented 1 year ago

Check this: https://github.com/DAFoam/tutorials/blob/4d9761f90492b84cace353e516dc2950dc56adbe/Prowim_Wing_Propeller/runScript_v2.py#L298

@friedenhe I am unable to get desired result from "deformMesh". Can you please check the above response if I did anything incorrect?

friedenhe commented 1 year ago

Your run script looks OK, I suspect the issue is in the design variable json file. I suggest you load a json file that has only one shape variable that is non-zero, and then gradually add more non-zero design variables for debugging.