OPM / ResInsight

3D viewer and post processing of reservoir models
http://resinsight.org/
GNU General Public License v3.0
174 stars 92 forks source link

Saved projects with relative paths? #7652

Open EdmundStephens opened 3 years ago

EdmundStephens commented 3 years ago

Request: could relative paths (i.e. led by ./ or ../) be used in the save file, which are relative to the location of the .rsp file ?

We are frequently wanting to pass over .rsp files between groups, which often get used in a different folder. ResInsight is quite robust to a folder change as long as all files are in the same folder, but particularly for ensemble runs this is not the case.

magnesj commented 3 years ago

Thanks for your feedback. Can you describe a bit more in detail the issue you are facing?

If the automatic file detection is not working as expected, it is possible to manually manipulate the externally referenced files directly in the .rsp file. See here for more details https://resinsight.org/misc/projectfile/

EdmundStephens commented 3 years ago

Portability is especially important with us all working from home, we are using projects sometimes on shared network drives, also on laptops, or after being copied to another location. ResInsight is quite robust at detecting a path change, but this does not quite extend to projects with multiple files from different folders (which is desirable for various reasons including version control of different data references).

Example project header which includes data from multiple folders:

<ResInsightProject>
    <DocumentFileName>W:/Project/SF/SF_Ref1/SogneF.rsp</DocumentFileName>
    <ProjectFileVersionString>2020.10.1</ProjectFileVersionString>
    <ReferencedExternalFiles>
        $PathId_034$ W:/Project/SF/SF_Ref1/SF02_BASE.EGRID;
        $PathId_035$ W:/Project/Well_data/WELLS_APPR.DEV;
        $PathId_036$ W:/Project/Well_data/WELLS_DG2_SF_V4.DEV;
        $PathId_037$ W:/Project/SF/SF_Ref1/SF02_BASE.SMSPEC;
        $PathId_038$ W:/Project/SF/SF_Ref1/Ensemble/SF02_Ref2p/SF02_REF2P.SMSPEC;
        $PathId_039$ W:/Project/SF/SF_Ref1/Ensemble/SF02-GWC1_Ref2p/SF02-GWC1_REF2P.SMSPEC;
        $PathId_040$ W:/Project/SF/SF_Ref1/Ensemble/SF02-GWC2_Ref2p/SF02-GWC2_REF2P.SMSPEC;
        ...
        $PathId_071$ W:/Project/SF/Grid_v4/SWIRR_2CH(SWIRR_2CH).GRDECL;
        $PathId_072$ W:/Project/SF/Grid_v4/SWT_2CH(SWT_2CH).GRDECL;
        ...
    </ReferencedExternalFiles>
    ...
</ResInsightProject>

This could be be more robust if the ReferencedExternalFiles entries can be saved (where possible) relative to the project file. The DocumentFileName is Ok as an absolute path so that your existing logic can pick up. Relative paths for the ReferencedExternalFiles can then be formed by stripping out the common path with "..\" per upwards level to the point of difference. And if there is some file with no common path at all (e.g. different drive) then just keep that as an absolute path reference. So the above becomes:

<ResInsightProject>
    <DocumentFileName>W:/Project/SF/SF_Ref1/SogneF.rsp</DocumentFileName>
    <ProjectFileVersionString>2020.10.1</ProjectFileVersionString>
    <ReferencedExternalFiles>
        $PathId_034$ ./SF02_BASE.EGRID;
        $PathId_035$ ../../Well_data/WELLS_APPR.DEV;
        $PathId_036$ ../../Well_data/WELLS_DG2_SF_V4.DEV;
        $PathId_037$ ./SF02_BASE.SMSPEC;
        $PathId_038$ ./Ensemble/SF02_Ref2p/SF02_REF2P.SMSPEC;
        $PathId_039$ ./Ensemble/SF02-GWC1_Ref2p/SF02-GWC1_REF2P.SMSPEC;
        $PathId_040$ ./Ensemble/SF02-GWC2_Ref2p/SF02-GWC2_REF2P.SMSPEC;
        ...
        $PathId_071$ ../Grid_v4/SWIRR_2CH(SWIRR_2CH).GRDECL;
        $PathId_072$ ../Grid_v4/SWT_2CH(SWT_2CH).GRDECL;
        ...
    </ReferencedExternalFiles>
    ...
</ResInsightProject>

One final thought, you could consider adding an interface to interact with the referenced external files: