is there a way to custom new materials?

A subforum specific to the development of the OpenFoam-based workbenches ( Cfd https://github.com/qingfengxia/Cfd and CfdOF https://github.com/jaheyns/CfdOF )

Moderator: oliveroxtoby

valerie
Posts: 1
Joined: Thu Aug 25, 2022 11:56 am

is there a way to custom new materials?

Post by valerie »

I'am using Argon. So each time I make a new simulation, I have to replace Air by Argon and insert mannually the Argon constants. Is there a way to add and save a new material to the fluids list (as we can do in FEM)?
Thanks
Valerie
KAKM
Posts: 109
Joined: Tue May 04, 2021 12:17 am

Re: is there a way to custom new materials?

Post by KAKM »

I don't think there is at the moment, but it should be straightforward to implement, so I'm going to take a stab at it. In the time between now and getting that written/merged, you might consider recording a macro that includes adding Argon properties and any other standard steps you use for setting up simulations (e.g., solver selection, mesh settings).

Edit: it looks like you can go into the FEM tool and save it into Mod/CfdOf/Data/CfdMaterialProperties. I think that will bring it up in the menu, but I can't currently verify that because I've somehow managed to delete my CfdOF installation and when I try to reinstall it, FreeCAD crashes. (Pretty sure it's an add-on manager issue)
KAKM
Posts: 109
Joined: Tue May 04, 2021 12:17 am

Re: is there a way to custom new materials?

Post by KAKM »

Okay, so it turns out if you use the material editor in the FEM workbench to "save as" a material into Mod/CfdOf/Data/CfdMaterialProperties but don't use add a property to add a 'Type' property, it throws a key error and you can't open the material selection dialog. (the type property is supposed to indicate which physics the material is associated with (e.g., isothermal, compressible))

@oliveroxtoby, there are several different ways I could approach resolving this:
  • Remove the type matching requirement to add a material to the dropdown list
  • Allow it to add materials with no type, but mark them as such
  • Add a checkbox to allow untyped materials
  • Create a CfdOF material editor based on the FEM one that makes type a required field
Thoughts on which approach to take?
User avatar
oliveroxtoby
Posts: 810
Joined: Fri Dec 23, 2016 9:43 am
Location: South Africa

Re: is there a way to custom new materials?

Post by oliveroxtoby »

KAKM wrote: Thu Sep 22, 2022 2:08 am @oliveroxtoby, there are several different ways I could approach resolving this:
  • Remove the type matching requirement to add a material to the dropdown list
  • Allow it to add materials with no type, but mark them as such
  • Add a checkbox to allow untyped materials
  • Create a CfdOF material editor based on the FEM one that makes type a required field
Thoughts on which approach to take?
Great that you're planning to take this on - thanks!

As much as it's a shame to duplicate functionality, I think we would need to do this independently in CfdOF since we had to add quite a lot of unique fields for fluids due to the different inputs accepted by OpenFOAM (aside from Isothermal and Compressible types, there is 'Incompressible' as well where polynomial coefficients are given...so the formatting is quite unique). In other words I think the issue of incompatibility will go beyond just the presence or absence of the 'Type' field.

Hopefully this can be done just by adding a 'Save' option to the existing material properties task panel rather than making a whole new editor...unless I'm missing something?
KAKM
Posts: 109
Joined: Tue May 04, 2021 12:17 am

Re: is there a way to custom new materials?

Post by KAKM »

No, you're right, that should work. I might be able to steal the save function from FEM (plus or minus a bit of tweaking) depending on how exactly it was written. Though, honestly, looking at the format of the .FCMat files, this isn't going to be a big deal to write from scratch.

What's the difference between FCMat and FCdMat? That seems like it might be important.
User avatar
oliveroxtoby
Posts: 810
Joined: Fri Dec 23, 2016 9:43 am
Location: South Africa

Re: is there a way to custom new materials?

Post by oliveroxtoby »

KAKM wrote: Fri Sep 23, 2022 10:55 pm What's the difference between FCMat and FCdMat? That seems like it might be important.
I haven't come across that before. Please feel welcome to run with this and take whichever direction seems best!
KAKM
Posts: 109
Joined: Tue May 04, 2021 12:17 am

Re: is there a way to custom new materials?

Post by KAKM »

oliveroxtoby wrote: Mon Sep 26, 2022 6:52 am I haven't come across that before.
Then I guess it probably isn't particularly important, or it would have broken something by now :D . It's part of the file, and I can't tell any difference between water (which is FCdMat) and everything else (which is FCMat).
Screen Shot 2022-09-26 at 8.45.08 PM.png
Screen Shot 2022-09-26 at 8.45.08 PM.png (16.06 KiB) Viewed 1901 times
User avatar
oliveroxtoby
Posts: 810
Joined: Fri Dec 23, 2016 9:43 am
Location: South Africa

Re: is there a way to custom new materials?

Post by oliveroxtoby »

KAKM wrote: Tue Sep 27, 2022 12:48 am Then I guess it probably isn't particularly important, or it would have broken something by now :D . It's part of the file, and I can't tell any difference between water (which is FCdMat) and everything else (which is FCMat). Screen Shot 2022-09-26 at 8.45.08 PM.png
I suspect it's just a typo! :D
KAKM
Posts: 109
Joined: Tue May 04, 2021 12:17 am

Re: is there a way to custom new materials?

Post by KAKM »

@oliveroxtoby I've got it working. I seem to have failed one of the unit tests, though, and while I'm pretty sure that it doesn't indicate that my code broke CfdOF, I have no idea how to fix it-it's a path compare, which makes me think it might just be a result of running on Mac instead of Linux.

Code: Select all

FAIL: test_new_analysis (TestCfdOF.BlockTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/Katy/Library/Application Support/FreeCAD/Mod/CfdOF/./TestCfdOF.py", line 266, in test_new_analysis
    comparePaths(mesh_ref_dir, mesh_case_dir, self)
  File "/Users/Katy/Library/Application Support/FreeCAD/Mod/CfdOF/./TestCfdOF.py", line 473, in comparePaths
    unit_test.assertFalse(ret, "File \'{}\' test failed.\n{}".format(file, ret))
AssertionError: 'Comparing /Users/Katy/Library/Application Support/FreeCAD/Mod/CfdOF/Data/TestFiles/cases/block/meshCase/gmsh/Box_Geometry.brep to /var/folders/jg/qnd6qm0521l8f8nd4cwl0znw0000gn/T/meshCaseblock/gmsh/Box_Geometry.brep failed!\n--- \n+++ \n@@ -49,49 +49 @@\n-PolygonOnTriangulations 24\n-2 1 3 \n-p 3.5 1 0 100 \n-2 1 2 \n-p 1.83333333333333 1 0 100 \n-2 1 2 \n-p 3.5 1 0 1000 \n-2 2 4 \n-p 1.83333333333333 1 0 1000 \n-2 3 4 \n-p 1.83333333333333 1 0 100 \n-2 1 3 \n-p 1.83333333333333 1 0 100 \n-2 1 2 \n-p 3.5 1 0 1000 \n-2 1 3 \n-p 1.83333333333333 1 0 1000 \n-2 1 2 \n-p 3.5 1 0 100 \n-2 2 4 \n-p 3.5 1 0 100 \n-2 2 4 \n-p 3.5 1 0 1000 \n-2 3 4 \n-p 3.5 1 0 1000 \n-2 3 4 \n-p 3.5 1 0 100 \n-2 2 4 \n-p 1.83333333333333 1 0 100 \n-2 1 3 \n-p 3.5 1 0 1000 \n-2 3 4 \n-p 3.5 1 0 1000 \n-2 1 2 \n-p 3.5 1 0 1000 \n-2 1 3 \n-p 3.5 1 0 1000 \n-2 3 4 \n-p 3.5 1 0 1000 \n-2 1 3 \n-p 3.5 1 0 1000 \n-2 2 4 \n-p 3.5 1 0 1000 \n-2 1 2 \n-p 1.83333333333333 1 0 1000 \n-2 2 4 \n-p 3.5 1 0 1000 \n-2 3 4 \n-p 1.83333333333333 1 0 1000 \n+PolygonOnTriangulations 0\n@@ -105,13 +57 @@\n-Triangulations 6\n-4 2 1 1.83333333333333\n-0 0 0 0 0 100 0 1000 0 0 1000 100 0 0 100 0 0 -1000 100 -1000 2 1 3 2 3 4 \n-4 2 1 3.5\n-0 0 0 1000 0 0 0 0 100 1000 0 100 0 0 0 1000 100 0 100 1000 4 2 1 4 1 3 \n-4 2 1 3.5\n-0 0 100 0 1000 100 1000 0 100 1000 1000 100 0 0 0 1000 1000 0 1000 1000 4 2 1 4 1 3 \n-4 2 1 1.83333333333333\n-0 1000 0 1000 1000 0 0 1000 100 1000 1000 100 0 0 0 1000 100 0 100 1000 4 2 1 4 1 3 \n-4 2 1 3.5\n-0 0 0 0 1000 0 1000 0 0 1000 1000 0 0 0 0 1000 1000 0 1000 1000 4 2 1 4 1 3 \n-4 2 1 3.5\n-1000 0 0 1000 0 100 1000 1000 0 1000 1000 100 0 0 100 0 0 -1000 100 -1000 2 1 3 2 3 4 \n+Triangulations 0\n@@ -139,2 +78,0 @@\n-6  1 2 0\n-6  2 1 0\n@@ -157,2 +94,0 @@\n-6  3 3 0\n-6  4 1 0\n@@ -175,2 +110,0 @@\n-6  5 1 0\n-6  6 4 0\n@@ -186,2 +119,0 @@\n-6  7 5 0\n-6  8 1 0\n@@ -198 +130 @@\n-2  1\n+\n@@ -220,2 +151,0 @@\n-6  9 6 0\n-6  10 2 0\n@@ -238,2 +167,0 @@\n-6  11 6 0\n-6  12 3 0\n@@ -256,2 +183,0 @@\n-6  13 6 0\n-6  14 4 0\n@@ -267,2 +192,0 @@\n-6  15 6 0\n-6  16 5 0\n@@ -279 +203 @@\n-2  6\n+\n@@ -287,2 +210,0 @@\n-6  17 2 0\n-6  18 5 0\n@@ -298,2 +219,0 @@\n-6  19 2 0\n-6  20 3 0\n@@ -310 +230 @@\n-2  2\n+\n@@ -318,2 +237,0 @@\n-6  21 5 0\n-6  22 4 0\n@@ -329,2 +246,0 @@\n-6  23 3 0\n-6  24 4 0\n@@ -341 +257 @@\n-2  4\n+\n@@ -350 +266 @@\n-2  5\n+\n@@ -359 +275 @@\n-2  3\n+\n' is not false : File 'Box_Geometry.brep' test failed.
Comparing /Users/Katy/Library/Application Support/FreeCAD/Mod/CfdOF/Data/TestFiles/cases/block/meshCase/gmsh/Box_Geometry.brep to /var/folders/jg/qnd6qm0521l8f8nd4cwl0znw0000gn/T/meshCaseblock/gmsh/Box_Geometry.brep failed!
User avatar
oliveroxtoby
Posts: 810
Joined: Fri Dec 23, 2016 9:43 am
Location: South Africa

Re: is there a way to custom new materials?

Post by oliveroxtoby »

KAKM wrote: Sat Oct 01, 2022 1:54 am @oliveroxtoby I've got it working. I seem to have failed one of the unit tests, though, and while I'm pretty sure that it doesn't indicate that my code broke CfdOF, I have no idea how to fix it-it's a path compare, which makes me think it might just be a result of running on Mac instead of Linux.

Code: Select all

FAIL: test_new_analysis (TestCfdOF.BlockTest)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/Katy/Library/Application Support/FreeCAD/Mod/CfdOF/./TestCfdOF.py", line 266, in test_new_analysis
    comparePaths(mesh_ref_dir, mesh_case_dir, self)
  File "/Users/Katy/Library/Application Support/FreeCAD/Mod/CfdOF/./TestCfdOF.py", line 473, in comparePaths
    unit_test.assertFalse(ret, "File \'{}\' test failed.\n{}".format(file, ret))
AssertionError: 'Comparing /Users/Katy/Library/Application Support/FreeCAD/Mod/CfdOF/Data/TestFiles/cases/block/meshCase/gmsh/Box_Geometry.brep to /var/folders/jg/qnd6qm0521l8f8nd4cwl0znw0000gn/T/meshCaseblock/gmsh/Box_Geometry.brep failed!\n--- \n+++ \n@@ -49,49 +49 @@\n-PolygonOnTriangulations 24\n-2 1 3 \n-p 3.5 1 0 100 \n-2 1 2 \n-p 1.83333333333333 1 0 100 \n-2 1 2 \n-p 3.5 1 0 1000 \n-2 2 4 \n-p 1.83333333333333 1 0 1000 \n-2 3 4 \n-p 1.83333333333333 1 0 100 \n-2 1 3 \n-p 1.83333333333333 1 0 100 \n-2 1 2 \n-p 3.5 1 0 1000 \n-2 1 3 \n-p 1.83333333333333 1 0 1000 \n-2 1 2 \n-p 3.5 1 0 100 \n-2 2 4 \n-p 3.5 1 0 100 \n-2 2 4 \n-p 3.5 1 0 1000 \n-2 3 4 \n-p 3.5 1 0 1000 \n-2 3 4 \n-p 3.5 1 0 100 \n-2 2 4 \n-p 1.83333333333333 1 0 100 \n-2 1 3 \n-p 3.5 1 0 1000 \n-2 3 4 \n-p 3.5 1 0 1000 \n-2 1 2 \n-p 3.5 1 0 1000 \n-2 1 3 \n-p 3.5 1 0 1000 \n-2 3 4 \n-p 3.5 1 0 1000 \n-2 1 3 \n-p 3.5 1 0 1000 \n-2 2 4 \n-p 3.5 1 0 1000 \n-2 1 2 \n-p 1.83333333333333 1 0 1000 \n-2 2 4 \n-p 3.5 1 0 1000 \n-2 3 4 \n-p 1.83333333333333 1 0 1000 \n+PolygonOnTriangulations 0\n@@ -105,13 +57 @@\n-Triangulations 6\n-4 2 1 1.83333333333333\n-0 0 0 0 0 100 0 1000 0 0 1000 100 0 0 100 0 0 -1000 100 -1000 2 1 3 2 3 4 \n-4 2 1 3.5\n-0 0 0 1000 0 0 0 0 100 1000 0 100 0 0 0 1000 100 0 100 1000 4 2 1 4 1 3 \n-4 2 1 3.5\n-0 0 100 0 1000 100 1000 0 100 1000 1000 100 0 0 0 1000 1000 0 1000 1000 4 2 1 4 1 3 \n-4 2 1 1.83333333333333\n-0 1000 0 1000 1000 0 0 1000 100 1000 1000 100 0 0 0 1000 100 0 100 1000 4 2 1 4 1 3 \n-4 2 1 3.5\n-0 0 0 0 1000 0 1000 0 0 1000 1000 0 0 0 0 1000 1000 0 1000 1000 4 2 1 4 1 3 \n-4 2 1 3.5\n-1000 0 0 1000 0 100 1000 1000 0 1000 1000 100 0 0 100 0 0 -1000 100 -1000 2 1 3 2 3 4 \n+Triangulations 0\n@@ -139,2 +78,0 @@\n-6  1 2 0\n-6  2 1 0\n@@ -157,2 +94,0 @@\n-6  3 3 0\n-6  4 1 0\n@@ -175,2 +110,0 @@\n-6  5 1 0\n-6  6 4 0\n@@ -186,2 +119,0 @@\n-6  7 5 0\n-6  8 1 0\n@@ -198 +130 @@\n-2  1\n+\n@@ -220,2 +151,0 @@\n-6  9 6 0\n-6  10 2 0\n@@ -238,2 +167,0 @@\n-6  11 6 0\n-6  12 3 0\n@@ -256,2 +183,0 @@\n-6  13 6 0\n-6  14 4 0\n@@ -267,2 +192,0 @@\n-6  15 6 0\n-6  16 5 0\n@@ -279 +203 @@\n-2  6\n+\n@@ -287,2 +210,0 @@\n-6  17 2 0\n-6  18 5 0\n@@ -298,2 +219,0 @@\n-6  19 2 0\n-6  20 3 0\n@@ -310 +230 @@\n-2  2\n+\n@@ -318,2 +237,0 @@\n-6  21 5 0\n-6  22 4 0\n@@ -329,2 +246,0 @@\n-6  23 3 0\n-6  24 4 0\n@@ -341 +257 @@\n-2  4\n+\n@@ -350 +266 @@\n-2  5\n+\n@@ -359 +275 @@\n-2  3\n+\n' is not false : File 'Box_Geometry.brep' test failed.
Comparing /Users/Katy/Library/Application Support/FreeCAD/Mod/CfdOF/Data/TestFiles/cases/block/meshCase/gmsh/Box_Geometry.brep to /var/folders/jg/qnd6qm0521l8f8nd4cwl0znw0000gn/T/meshCaseblock/gmsh/Box_Geometry.brep failed!
Brilliant, thanks! I think I will just remove this file from the comparison - I suspect the exact content is sensitive to the OCC version or such. So, could you go ahead and open a pull request on https://gitlab.com/opensimproject/cfdof ?
Post Reply