jaheyns / CfdOF

Computational Fluid Dynamics (CFD) for FreeCAD based on OpenFOAM solver
GNU Lesser General Public License v3.0
442 stars 84 forks source link

QoL Improvement: Make CfdAnalysis' "Output Directory" dynamic based on the Project Name, instead of "/tmp/case" as default #148

Open eduncan911 opened 8 months ago

eduncan911 commented 8 months ago

CfdOF WB v1.24.4 FreeCAD 0.21.1 (and LinkStage Tip, which is 0.21)

Problem: The current function of the Properties for CfdOF allows you to manually specify a folder for writing meshes. However, if you are analyzing several different projects, this becomes a problem with data being constantly overwritten.

Suggested Resolution This request is to allow project variables to be used here instead. Such as the Project Label (name). For example:

image

Work Around Currently, this can be set manually from with each project's CfdAnalysis's Property window on a per project basis. And that works. However, most user's workflows in FreeCAD doesn't include, "New project, go edit Property Settings before starting." However, you still have drop to shell to create the freakin' directory.

So this is kind out of the normal workflow for end-users.

image

oliveroxtoby commented 8 months ago

This is a good idea. I'll try to put it in soon, or you're welcome to submit a pull request.

eduncan911 commented 8 months ago

@oliveroxtoby nice! as a follow-up, I dove deep into FEM recently. And, it has everything I mentioned above as well as "smarter than me" logic with even more options.

Maybe follow this Workbench?

image

The "Custom directory" option being the same as CfdOF's Properties View current option.

But note the other two dynamic ones. I especially like the "beside FCStd file" option.

eduncan911 commented 8 months ago

There's also something else... the FEM workbench also defaults to "search in known binary directories" for all the dependencies, instead of requiring their location.

This makes the FEM workbench work out of the box with CAE Linux - since everything is installed. For CfdOF, I have to go find each binary and specify them.

Just some suggestions to improve the the user's experience. :)

image

icojb25 commented 2 months ago

hi @oliveroxtoby any idea what the call is to get the project base label is? Is this accessible via the obj passed to the CfdAnalysis.py class?

def makeCfdAnalysis(name): """ Create a Cfd Analysis group object """ obj = FreeCAD.ActiveDocument.addObject("App::DocumentObjectGroupPython", name) CfdAnalysis(obj)

oliveroxtoby commented 2 months ago

hi @oliveroxtoby any idea what the call is to get the project base label is? Is this accessible via the obj passed to the CfdAnalysis.py class?

FreeCAD.ActiveDocument.Label ?

oliveroxtoby commented 2 months ago

But note the other two dynamic ones. I especially like the "beside FCStd file" option.

@icojb25 just a note in case you end up implementing this aspect of it. CfdOF does currently store files in this location if the user enters a relative path in the analysis object properties - see CfdTools.getOutputPath(). So probably this code can be reused.

oliveroxtoby commented 2 months ago

There's also something else... the FEM workbench also defaults to "search in known binary directories" for all the dependencies, instead of requiring their location.

This makes the FEM workbench work out of the box with CAE Linux - since everything is installed. For CfdOF, I have to go find each binary and specify them.

@eduncan911 CfdOF does actually have default locations for the dependencies, which are searched if no location is given on the Preferences page. However I don't know what these are for CAE Linux, so if you could supply these we can simply add them to the defaults.

icojb25 commented 2 months ago

But note the other two dynamic ones. I especially like the "beside FCStd file" option.

@icojb25 just a note in case you end up implementing this aspect of it. CfdOF does currently store files in this location if the user enters a relative path in the analysis object properties - see CfdTools.getOutputPath(). So probably this code can be reused.

Hi @oliveroxtoby i can chip away at it over the week. Do we want to add these options in the Preferences panel?

oliveroxtoby commented 2 months ago

Hi @oliveroxtoby i can chip away at it over the week. Do we want to add these options in the Preferences panel?

Thank you, that would be great.I don't think we need to have the distinction between custom directory and tmp directories (I think we can just have the custom directory defaulting to tmp directory as we do now), but adding an option in preferences like the 'Beside .FCStd file' one would be nice. And then also saving in a subdirectory with the name of the document label, as the first post alludes to.

icojb25 commented 1 month ago

hi @oliveroxtoby I am nearly finished this implementation, however notice that in CfdPreferences.py, the function loadSettings() is actually never called, which is kind of weird. One would assume this is used to persist the changes (not working for this Feature Request yet, assume because of this).

Can you confirm? I dont see this method called anywhere in the code ... yet it seems to be the persistence method that should be used.

oliveroxtoby commented 1 month ago

hi @oliveroxtoby I am nearly finished this implementation, however notice that in CfdPreferences.py, the function loadSettings() is actually never called, which is kind of weird. One would assume this is used to persist the changes (not working for this Feature Request yet, assume because of this).

It's not called by CfdOF but it is called by FreeCAD when the preferences page is loaded.

icojb25 commented 1 month ago

@eduncan911 @oliveroxtoby Take a look at this and see if it works as intended. Enjoy the long weekend.