Repository navigation
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. |
|
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. |
|
Hi @bmunguia, any update on this? |
…esolving sensor sol/var indices
|
Sorry for the massive delay. I made the implementation a bit more flexible by resolving the indices using it should set them all as sensors and calculate gradients/Hessians for all of them, as well as a Lp-norm normalized metric field for the first entry. I still need to add the python wrapper bit so we can compute metrics of derived quantities like Mach number. This is currently my top priority since I actually need the Mach metric soon for my own work. I'm hoping to get it implemented today or tomorrow. |
…s struct - Add AdaptiveMetric_ParsedOptions; replace individual CConfig members/getters - Rename config keys to COMPUTE_ADAPTIVE_METRIC, NORMALIZE_ADAPTIVE_METRIC, ADAPTIVE_METRIC_* - Rename metrics/ headers, Python package and test case directory to adaptive_metric - Rename output group/fields to ADAPTIVE_METRIC / AdaptiveMetric_*
- Store one adaptive metric per sensor; output AdaptiveMetric_<Sensor>_* - Take the Hessian absolute value and eigenvalue floor in eigenspace within each pass instead of storing a floored SPD Hessian (fixes NaN for rank-one Hessians); error on a zero normalization integral - Respect NORMALIZE_ADAPTIVE_METRIC for steady runs - Finalize the unsteady time integral when the run actually stops (MAX_TIME, time convergence); add FinalizeAdaptiveMetric() to the Python driver API - Move the metric kernels to computeAdaptiveMetric.cpp, passive double only - Keep the stored Hessian raw; remove unused SetGradient_Adapt
- Error when COMPUTE_ADAPTIVE_METRIC has no ADAPTIVE_METRIC_SENSOR entries - Error on periodic boundaries, which the adaptive metric does not support yet - ADAPTIVE_METRIC_HMIN/HMAX/ARMAX take one value for all sensors or one value per sensor; check hmin > 0, hmax >= hmin, armax >= 1 - Match the GOAL sensor case-insensitively - Default NORMALIZE_ADAPTIVE_METRIC to YES - Remove the redundant Hessian-method check and the unreachable empty-sensor warning in the driver
- Classify output fields once: a vector or tensor requires names ending in _x/_xx followed by the remaining components with the same prefix; everything else is a scalar - Fixes scalar sensors such as VELOCITY_X being written as vectors, and dropped or misaligned arrays when sensor names contain _x/_y - Remove the duplicated substring checks and running field counter from the header and data passes
- Add addSymOuterProduct helper shared by the interior-edge and boundary loops of computeHessiansGreenGauss; fold the boundary sign into the flux - Use auto loop indices in the adaptive metric code - Document that custom sensor names match case-insensitively in CustomSensorRegistry
…uickStart mesh in the examples - Add UnitTests/SU2_CFD/adaptive_metric.cpp: identity, rank-one, and zero Hessians on a unit cube, checking the analytic uniform metric, a finite SPD rank-one metric within the size and aspect ratio constraints, and the eigenvector alignment - Document the adaptive metric options in config_template.cfg - Point both adaptive metric examples at QuickStart/mesh_NACA0012_inv.su2
|
@bigfooted sorry for the delay. I've finished going through the comments. Some of the main changes I made based on @EvertBunschoten's comments:
and based on @rois1995's comments:
|
|
@bigfooted, I agree. I will create one based on this PR once it is fully approved. |
rois1995
left a comment
There was a problem hiding this comment.
Thanks, the earlier points are fixed. One MPI type issue left, plus two small checks.
|
The six earlier points are fixed, with one leftover.
|
…ptive metric - The adaptive metric is only computed by CSinglezoneDriver; error out in CConfig instead of silently writing zero fields - Repeat the multizone check in the zone constructor, since zone configs inherit the multizone flag after SetPostprocessing
…able, time step - Use the time step the solver actually takes (GetDelta_UnstTimeND) instead of the TIME_STEP input, which is zero with UNST_CFL_NUMBER - Accumulate dt/2 (|H_prev| + |H|) per interval, so the trapezoidal rule is exact for variable time steps and the endpoints get half weight without knowing which sample is last - Remove the last-step half-weight subtraction from FinalizeAdaptiveMetric and warn when the metric has a single sample
… 2D and 3D - Add a quadratic-field test checking that the Green-Gauss Hessian is exact at points at least two layers inside a uniform Cartesian mesh, in 2D and 3D - Run the normalization test (identity, rank-one, and zero Hessians) in 2D and 3D on the same 9-node mesh
…e tensors as TENSORS - PARAVIEW_ASCII and PARAVIEW_LEGACY group vector components only for complete adjacent sets, instead of matching "_x" anywhere in the name - Write Hessians and adaptive metrics as legacy TENSORS (full symmetric 3x3, padded in 2D like the XML writer) instead of vectors with duplicate names - Add CFileWriter::GetSymmetricTensor, shared by both writers
- SU2_MPI with MPI_DOUBLE expects su2double, which is an AD type in AD and direct differentiation builds; reducing passivedouble buffers read and wrote past their end there
|
Ok here's a summary of my recent changes:
FYI @bigfooted: the same DD + AddressSanitizer build also reports this pattern in Maybe it's harmless, though. @bigfooted @rois1995 regarding the website page, I'd be happy to help. I can do a quick write-up of my examples, including visualizing the sizing tensor field in ParaView (via a Programmable Filter for now, but I could also directly output it from SU2, either as part of this PR or a separate one if you just want to merge this one), and move them to the Tutorials repo. Andrea/Alberto could then cover the adaptation loop once their implementation is in, if that works for you? |
…ue round trip within tolerance
rois1995
left a comment
There was a problem hiding this comment.
Thanks, all points are fixed. Good catch on the DD case of the MPI wrapper.
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. Part 1 (this PR) computes adaptive metric fields for feature-based adaptation in SU2's post-processing. Part 2 will add the Python adaptation loop with the open-source MMG remesher, including conversion between SU2 restarts/meshes and the .meshb format.
For each sensor, SU2 computes the Green-Gauss gradient and Hessian, and builds an adaptive metric from the absolute value of the Hessian (integrated in time with the trapezoidal rule for unsteady flows), optionally normalized in the Lp norm (see references). Implementation details:
ADAPTIVE_METRIC_SENSOR, and can be:PRESSURE,DENSITY,VELOCITY_X)VELOCITYmagnitude;MACHfor compressible solvers)NU_TILDE;TKE,DISSIPATION;INTERMITTENCY,RE_THETA_T;SPECIES_<i>)SU2.adaptive_metric.CustomSensorRegistry, listed inADAPTIVE_METRIC_CUSTOM_SENSOR)driver.FinalizeAdaptiveMetric()SENSOR_VALUE,SENSOR_GRADIENT,SENSOR_HESSIAN,ADAPTIVE_METRIC(AdaptiveMetric_<Sensor>_*); the ParaView writers (XML and legacy) write the Hessians/metrics as symmetric tensors and only group vector/tensor components that form a complete adjacent setNew config options (see
config_template.cfg):COMPUTE_ADAPTIVE_METRIC(bool, default NO): compute the adaptive metric in post-processing; this does not adapt the meshNORMALIZE_ADAPTIVE_METRIC(bool, default YES): perform the Lp-norm normalizationNUM_METHOD_HESS(default GREEN_GAUSS): Hessian methodADAPTIVE_METRIC_SENSOR(list): sensors, each with its own metricADAPTIVE_METRIC_CUSTOM_SENSOR(list): sensors set through the Python wrapperADAPTIVE_METRIC_NORM(default 2): p of the Lp normADAPTIVE_METRIC_COMPLEXITY(default 10000): target mesh complexityADAPTIVE_METRIC_HMIN/ADAPTIVE_METRIC_HMAX/ADAPTIVE_METRIC_ARMAX(defaults 1e-8 / 100 / 1e6): minimum/maximum cell size and maximum aspect ratio; one value for all sensors, or one per sensorADAP_TIME_SUBINTERVAL(default 1): unsteady adaptation sub-intervals (only 1 for now)Examples are in
TestCases/mesh_adaptation/adaptive_metric(built-in sensors on an inviscid NACA0012, and a custom total-pressure sensor through the Python wrapper on RANS), using the QuickStart mesh.Unit tests are in
UnitTests/SU2_CFD/adaptive_metric.cpp(2D and 3D, including the Green-Gauss Hessian of a quadratic field).PR Checklist
pre-commit run --allto format old commits.References