jouleHeatingSource change file separator
Summary
Currently, jouleHeatingSource
uses :
file separator (e.g. 0/jouleHeatingSource:V
). This is a bad choice because of a special meaning in GNU Make. It prevents creating dependency lists for automated update.
For example, this is a snippet from my Makefile:
FIELD_FILES_ORIG:=$(wildcard 0.orig/*)
FIELD_FILES:=$(foreach v,$(FIELD_FILES_ORIG),$(notdir $(v)))
FIELD_FILES_INITIAL:=$(foreach v,$(FIELD_FILES),0/$(v))
FIELD_FILES_INITIAL_REGIONS:=$(foreach v,$(FIELD_FILES),$(foreach r,$(REGIONS),0/$(r)/$(v)))
0/cellToRegion: constant/polyMesh $(FIELD_FILES_INITIAL) | 0
rm -f .changeDictionary
splitMeshRegions -cellZones -overwrite
renumberMesh -allRegions -overwrite
This code breaks because of a :
character in file names.
This problem is trivially solved by replacing :
file separator with something more Makefile-friendly. For example, -
character.
If you agree with this, I could create a PR myself.
Steps to reproduce
Execute code
git clone https://develop.openfoam.com/Development/openfoam.git --branch master
cd openfoam/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid
cat > Makefile << _EOF_
FILES:=\$(wildcard 0.orig/**/*)
all: \$(FILES)
echo success
_EOF_
make
Observe GNU Make error.
Fix file names and try again
rename 's/:/-/' 0.orig/solid/*
make
Observe output string success
.
Example case
See Steps to reproduce
What is the current bug behaviour?
OpenFOAM file names break GNU Make automation
What is the expected correct behavior?
OpenFOAM file names do not break GNU Make automation
Environment information
- OpenFOAM version : v2206
- Operating system : GNU Debian bookworm
- Hardware info : x86-64
- Compiler : gcc
Possible fixes
I think that it's enough to replace :
with -
in
- https://develop.openfoam.com/Development/openfoam/-/blob/master/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C#L47
- https://develop.openfoam.com/Development/openfoam/-/blob/master/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSource.C#L118
- https://develop.openfoam.com/Development/openfoam/-/blob/master/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceTemplates.C#L48
- https://develop.openfoam.com/Development/openfoam/-/blob/master/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceTemplates.C#L70
- https://develop.openfoam.com/Development/openfoam/-/blob/master/src/fvOptions/sources/derived/jouleHeatingSource/jouleHeatingSourceTemplates.C#L95
and to rename files in https://develop.openfoam.com/Development/openfoam/-/tree/master/tutorials/heatTransfer/chtMultiRegionSimpleFoam/jouleHeatingSolid/0.orig/solid