watts icon indicating copy to clipboard operation
watts copied to clipboard

template file not in project root directory

Open nplinden opened this issue 1 year ago • 0 comments

Hello, i've been trying to use the watts.PluginGeneric to run templated OpenFOAM calculations. First I'm trying to run a simple meshing script, this requires the following directory structure:

.
|-- system
|   |-- blockMeshDict
|   `-- controlDict
`-- watts_script.py

Where blockMeshDict is templated and controlDict is not. My watts script looks like this:

import watts

params = watts.Parameters(nx=20) # Number of mesh cells in the x direction

plugin = watts.PluginGeneric(
    "blockMesh",
    "{self.executable}",
    "system/blockMeshDict",
    extra_inputs=["system/controlDict"],
    show_stdout=True,
    show_stderr=True
    )
result = plugin(params)

This fails because the two files are copied at the root of the temporary directory, so the "system/*" structure is not preserved and OpenFOAM is lost.

Looking at the code it seems there is no obvious way of preserving the path structure, as all path are made absolute and are simply copied to the temp directory using shutil.copy

Is there any way of preserving the directory structure? If not, is there interest in adding this feature? I don't mind implementing this if this is interesting to you.

Cheers

nplinden avatar Nov 13 '24 13:11 nplinden