fangq / mmc

Mesh-based Monte Carlo (MMC)
Other
40 stars 32 forks source link

[bug] correct errors in mmc2json.m #96

Closed andreafarina closed 2 months ago

andreafarina commented 2 months ago

Fixes an error in creating the json file when the mesh files (faces, nodes, etc) are not in the folder. Fixes a typo in copying cfg.isnormalized to json.

andreafarina commented 2 months ago

Dear Qinquian, thanks a lot for the effort! If I create a json file from the cfg structure containing elements and nodes using mmc2json.m, when I run the simulation I get this error:

MMC ERROR(-1):You must specify mesh files in unit /home/andreafarina/Documents/MCXStudio/MCXSuite/mmc/src/mmc_utils.c:1787  ../../../MCXStudio/MCXSuite/mmc/bin/mmc -f ./sim.json -s pippo3 -G 1 -d 1 -U 0: Signal 127

I solved it by moving the MEshID name above…

thanks a lot!

Andrea

==========================================

Andrea Farina, PhD

Consiglio Nazionale delle Ricerche (CNR), Istituto di Fotonica e Nanotecnologie (IFN)

c/o Politecnico di Milano, Dipartimento di Fisica

Piazza Leonardo da Vinci 32

20133 Milano, Italy

Fax: +39 02 2399 6126

Tel: +39 02 2399 6024

E-mail: @. @.>

Skype account: theflours

==========================================

On 15 Sep 2024, at 15:00, Qianqian Fang @.***> wrote:

@fangq commented on this pull request.

In mmclab/mmc2json.m https://github.com/fangq/mmc/pull/96#discussion_r1760042915:

@@ -96,7 +97,6 @@ Mesh = copycfg(cfg, 'e0', Mesh, 'InitElem');

else

  • Mesh.MeshID = fname; @andreafarina https://github.com/andreafarina, sorry for the delay. I am at fNIRS conference, and was not able to review this timely.

can you let me know what was the issue when the MeshID is defined here?

when one defines MeshNode and MeshElem, as in the other if-branch, then MeshID is not needed.

here is the source code parsing this part of the JSON input file, specifically, you can see it test if MeshID exists or not in a if() condition, which allows it to be missing

https://github.com/fangq/mmc/blob/v2024.2/src/mmc_utils.c#L1267-L1279

— Reply to this email directly, view it on GitHub https://github.com/fangq/mmc/pull/96#pullrequestreview-2305356992, or unsubscribe https://github.com/notifications/unsubscribe-auth/ADSBMM6HCADYEI3HY2TC323ZWWAHJAVCNFSM6AAAAABN6RWGGCVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZDGMBVGM2TMOJZGI. You are receiving this because you were mentioned.

fangq commented 2 months ago

@andreafarina, I see the problem. When you call mmc2json(cfg, 'meshid') without .json suffix, the MeshID field is missing. If your meshid ends with '.json', then it stores everything, including node/elem, in a single .json file. In this case, MeshID is not needed.

I committed the updated change in this one: https://github.com/fangq/mmc/commit/73926c88fbe18d7598f0a5a966f87d2337ffc348