[WIP] Anisotropic mesh adaptation part 1: feature-based metric tensor#2613
[WIP] Anisotropic mesh adaptation part 1: feature-based metric tensor#2613bmunguia wants to merge 12 commits intosu2code:developfrom
Conversation
…ble with initialization
- GG gradient/Hessian calculation on adaptation-specific variable containers - Metric integration and normalization for steady and unsteady flows - Storing of proper primitive variables for Euler solver
|
Is the mesh adaptation code itself open source? |
|
If you mean MMG, it's on Github https://github.com/MmgTools/mmg If you mean the SU2-MMG interface, it's in Alberto's fork https://github.com/xla27/SU2/tree/feat_adap_mmg |
pcarruscag
left a comment
There was a problem hiding this comment.
Excellent. Next question, what do you need from the python wrapper to do all of this outside of the SU2 core?
|
The python script basically just coordinates calls to SU2 and MMG in 2 nested loops, the inner loop being a series of adaptations at a given target mesh size and the outer loop being over a list of sizes. It also handles file conversions since MMG uses libmeshb for both the mesh and metric field. For the file conversion, Alberto has a straight python implementation that I think only handles tris/tets, and I have a separate repo with a C++ implementation/python API that I used for my results that I presented in Varenna https://github.com/bmunguia/limon |
|
Cool, the functionality would be more flexible if the sensor was also configurable via python, what you have here has a list of hardcoded possible variables, in python it would be very easy to target other solvers, create custom mixes of variables etc. |
| @@ -1551,7 +1569,7 @@ void CSolver::CompleteComms(CGeometry *geometry, | |||
|
|
|||
Check failure
Code scanning / CodeQL
Comparison of narrow type with wide type in loop condition High
| @@ -1551,7 +1569,7 @@ void CSolver::CompleteComms(CGeometry *geometry, | |||
|
|
|||
| /*--- Local variables ---*/ | |||
|
|
|||
Check failure
Code scanning / CodeQL
Multiplication result converted to larger type High
| auto& gradient = base_nodes->GetGradient_Adapt(); | ||
| auto nHess = config->GetGoal_Oriented_Metric()? nVar : config->GetnMetric_Sensor(); | ||
|
|
||
| computeGradientsGreenGauss(this, MPI_QUANTITIES::GRADIENT_ADAPT, PERIODIC_GRAD_ADAPT, |
Check failure
Code scanning / CodeQL
Comparison of narrow type with wide type in loop condition High
|
|
||
| computeGradientsGreenGauss(this, MPI_QUANTITIES::GRADIENT_ADAPT, PERIODIC_GRAD_ADAPT, | ||
| *geometry, *config, solution, 0, nHess, idxVel, gradient); | ||
|
|
Check failure
Code scanning / CodeQL
Multiplication result converted to larger type High
| switch (Kind_Hessian_Method) { | ||
| case GREEN_GAUSS: cout << "Hessian for adaptive metric: Green-Gauss." << endl; break; | ||
| } |
Check notice
Code scanning / CodeQL
No trivial switch statements Note
|
Hi Brian, what's the status? |
|
Hey Nijso, sorry for the delay. I've been a bit swamped lately with a deadline and the holidays so this has been on the backburner, but I'll look at it again this week or next. I know a lot of people have been asking about adaptation on slack so I want to get this in develop ASAP. I still need to implement Pedro's suggestions to use the python wrapper to make the choice of metric sensor more flexible, then I just need to add an example (or maybe a few for different solvers) to test the implementation. |
Proposed Changes
This PR is part of a joint effort with Alberto Perlini (@xla27) and Andrea Rausa (@rois1995) to implement anisotropic mesh adaptation in SU2. In our SU2 conference talks this year, I presented updates to the metric tensor computation in my fork for unsteady adaptation, and Alberto presented updates to the Python adaptation loop to use the open-source MMG remesher, as well as results for incompressible Euler/NS and NEMO.
Part 1 will focus on my contributions in SU2's post-processing/output to calculate metric tensor fields for feature-based adaptation. Part 2 will focus on the implementation of the adaptation loop in Python, including conversion between SU2 restarts/meshes and the .meshb format.
For the metric tensor field computation, I have implemented:
SetPrimitive_Adapt()to store the chosen adaptation sensorcomputeGradientsGreenGauss.hppwhich calculates the Hessian field for the chosen sensor and stores the lower trianglecomputeMetrics.hppThe following relevant config options have been added:
PR Checklist
pre-commit run --allto format old commits.References