Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resolves 1912: implement nirb tools #1944

Merged
merged 279 commits into from
Mar 8, 2023
Merged

Conversation

thomas-saigre
Copy link
Contributor

@thomas-saigre thomas-saigre commented Sep 21, 2022

  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes?
  • Have you successfully run the Feel++ testsuite with your changes locally?
  • Have you written Doxygen comments in your contribution ?

This is not working in parallel yet


[skip feelpp skip tests skip toolboxes skip mor]

@thomas-saigre thomas-saigre linked an issue Sep 21, 2022 that may be closed by this pull request
9 tasks
},
"C_Cpp.configurationWarnings": "Disabled",
"jupyter.notebookFileRoot": "${workspaceFolder}/build/python/install/lib/python3/dist-packages",
Copy link
Contributor Author

@thomas-saigre thomas-saigre Feb 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@prudhomm @vincentchabannes @alielarif I'm not sure this line should stay here : if the preset selected is not python there is no reason this path should be correct.
The advantage of this setting it that when we run a notebook in vscode, it automatically find the development packages installed in build directory, so there is no need to set by hand $PYTHONPATH.
The drawback is that when we launch a kernel, the working directory is no longer the directory where the ipynb file is saved, it is the one set in this line. So it is messy to load the config file (for example in python/pyfeelpp-mor/feelpp/mor/nirb/test_nirb_offline.ipynb, the path is hard coded to a local path "/home/saigre/Documents/code/feelpp/python/pyfeelpp-mor/feelpp/mor/nirb/model/square/square.cfg" which should have not been pushed, my bad !)

I don't know what would be the best way to set the environment easily : automatically set PYTHONPATH to the install directory, while the working directory still being the one where the notebook file is saved...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you set this in your user settings and not the workspace setting ?

},
"C_Cpp.configurationWarnings": "Disabled",
"jupyter.notebookFileRoot": "${workspaceFolder}/build/python/install/lib/python3/dist-packages",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you set this in your user settings and not the workspace setting ?

"cmake.parallelJobs": 5,
"autoDocstring.docstringFormat": "numpy"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why numpy?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I looked at the list available for default docstring format. When the default one is use, the overview of it in vscode is given in the first figure, with numpy, the format is slightly different and the overview is given in the second figure.
I find this is better the second way, but of course we can choose something else !

image
image

Comment on lines +183 to +188
if self.toolboxType == "heat":
return toolbox.fieldTemperature()
elif self.toolboxType == "fluid":
return toolbox.fieldVelocity()
else:
raise ValueError("Unknown toolbox")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about using a dict to map the function calls ? that way it extends in a nicer way to other toolboxes

Comment on lines +157 to +162
if self.toolboxType == "heat":
tb = heat.heat(dim=self.dimension, order=self.order)
elif self.toolboxType == "fluid":
tb = fluid.fluid(dim=self.dimension)
else:
raise ValueError("Unknown toolbox")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about create the toolbox outside ToolboxModel ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will lead to a lot of code changes. Better to do it in an other branch.

Comment on lines +216 to +221
if self.toolboxType == "heat":
Vh_image = image_tb.spaceTemperature()
Vh_domain = domain_tb.spaceTemperature()
elif self.toolboxType == "fluid":
Vh_image = image_tb.spaceVelocity()
Vh_domain = domain_tb.spaceVelocity()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not good I think to have this everywhere, if we have to extend this to other toolboxes

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A facade needs to be created : please follow this: https://www.geeksforgeeks.org/facade-method-python-design-patterns/

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need to discuss this before doing any major changes to the code

Bh = self.coeffFine[:nb, :nb]
R = np.zeros((nb,nb))
for s in range(nb):
R[s,:] = (np.linalg.inv(BH.transpose() @ BH + regulParam*np.eye(nb))@BH.transpose()@Bh[:,s])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

avoid calling .inv, rather call .solve with multiple right hand sides, @thomas-saigre

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes the correction was made in another branch (in commit 1991f58 on branch 2038-nirb-greedy), we may cherry-pick this commit to put the correction in here


import sys

dataPath = "/data/home/elarif/feelppdb/nirb/heat/np_1/results/Rect/"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should not be hardcoded, please use feel++ framework and repositories

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we replace this file by a notebook one in the branch #2041. This will be easy to manipulate.

feelpp.Environment.setConfigFile(casefile)

run_offline(model_path, rect, greedy)
run_online(model_path, rect)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are there any verifications that the results are ok ?

@prudhomm
Copy link
Member

@alielarif @thomas-saigre minor changes are required.
for example remove all hardcoded path and use feelpp repository handling instead

"cmake.parallelJobs": 5,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I have pussed this by error : I think it was 25 before (too much for my personal laptop), I thought I updated this value only locally, but it seems that it commited anyway, sorry about that.
Shall we change it back ?

# (('testcase/nirb/lid-driven-cavity/', 'cfd2d.cfg', 'cfd2d.json', True) , 'lid-driven-cavity rect'),
(('testcase/nirb/square', 'square.cfg', 'square.json', False, False), 'square2d w/o rect wogreedy'),
(('testcase/nirb/square', 'square.cfg', 'square.json', True, False) , 'square2d rect wogreedy'),
(('testcase/nirb/square', 'square.cfg', 'square.json', True, True) , 'square2d rect egreedy'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the test with Greedy selection dosn't get an error less than 8.10-2. I remove it now by waiting its new version.

@alielarif alielarif requested a review from prudhomm March 8, 2023 13:22
@prudhomm prudhomm merged commit 186642b into develop Mar 8, 2023
@prudhomm prudhomm deleted the 1912-implement-nirb-tools branch March 20, 2023 08:12
@prudhomm prudhomm changed the title 1912-implement-nirb-tools resolves 1912: implement nirb tools Mar 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

implement nirb framework for elliptic problems
4 participants