Keywords: Scientific computing, Anisotropic mesh adaptation, Error estimation, Computational fluid dynamics, Turbulence modeling, Aeronautics

In the context of fluid simulations, anisotropic mesh adaptation is a promising tool to capture automatically the main features of a flow on complex geometries without the requirement of prohibitive computational resources. In particular, such technique aims at finding the mesh which minimizes the discretization error committed on a certain quantity, in general the solution itself, or a functional, such as the lift or the drag coefficients. The objective of the present work is to improve the current RANS solver and to enrich the anisotropic error estimation with additional information coming from the turbulence model. For this reason, this work is divided into three main contributions. The first concerns the improvement of the RANS flow solver, in particular by applying novel and automatic CFL and limiter tuning strategies to control the residual convergence, and, the introduction of the strongly coupled turbulence to improve Newton convergence of the nonlinear equations. The second contribution concerns the resolution of the adjoint problem, which turns out to be particularly stiff if compared to the primal flow counterpart resolution, and, at the same time, is of great importance when adapting meshes; here, several methods have been applied to the resolution, such as the flexible GMRES and the pseudo-transient continuation. In addition to that, we have studied the strongly coupled turbulence for the adjoint problem, and we found out that such introduction enriches the adjoint flow with more physicsrelated information. Eventually, the third contribution concerns the error estimate driving the mesh adaptation procedure, which here includes the turbulent contribution coming from the primal and the adjoint flow fields. These procedures have been applied to both classical benchmarks of aeronautics as well as to more complex geometries like the common research models of the 3rd and the 4th AIAA CFD High Lift Prediction Workshops.

I would like to express my sincere gratitude to all the people who have contributed to the completion of my PhD thesis. Their support, guidance, and encouragement have been invaluable throughout this journey.

Firstly, I would like to acknowledge my advisor, Frédéric Alauzet, for his mentorship, trust, and availability. He has been an excellent role model and a constant source of motivation and inspiration. I am grateful for his guidance on how to work in research, which has helped me develop essential skills and knowledge, even for my future career.

I am also indebted to the two thesis reviewers, Siva Nadarajah and Christophe Airiau, for their valuable remarks, corrections, and advices on future work. Their feedback has greatly improved the quality of my thesis, and I appreciate their contributions, specially for the insights about the "obscure" behavior of the adjoint solutions. And, I would like to thank the members of my defense committee for their constructive questions and suggestions, which have given additional value to my research work.

I am particularly grateful to Philippe Spalart for sharing his deep knowledge and experience about turbulence and providing precious hints to understand mesh adaptation when applied to the RANS equations. I would also like to express my gratitude to Dmitry Kamenetskiy for the discussions and the advices on goal-oriented error estimates in this context. I have to express my gratitude also to Alain Dervieux, for providing me with valuable guidance on navigating challenging areas of my PhD thesis, particularly for the adjoint problem.

I am very grateful to my team colleagues for accompanying me on this journey, in particular, Adrien, Cosimo, Eloi, Julien, Loïc M. and Paul Louis for their support and advice, and for trusting me to learn French (I admit this has still some margin of improvement). A huge thank to Matthieu, Lucien and Lucille Marie, I cherish the many funny moments we shared (especially during our time in San Diego !). I would also like to thank Daniele, Rémi, and Agustina, who guided my first steps at INRIA and in Paris, and without whom I would have been completely lost.

Last but not least, I would like to thank my family for their huge support, and to express my gratitude to all the friends that shared both positive and challenging moments : the Adapta Studio guys, and Daniele, Federico, Luigi, Niccolò, Gianluca, Luca, Maria Vittoria, Stefano. Thank you all for being there for me !

Résumé

Dans le contexte de la mécanique des fluides numérique, l'adaptation de maillage anisotrope est un outil prometteur pour capturer automatiquement les principales caractéristiques d'un écoulement sur des géométries complexes sans nécessiter de ressources de calcul prohibitives et d'intervention humaine. En particulier, une telle technique vise à trouver le maillage qui minimise l'erreur de discrétisation commise sur une certaine quantité, en général la solution elle-même, ou une fonctionnelle d'intérêt, telle que la portance ou le coefficient de traînée. L'objectif de ce travail était d'améliorer le solveur RANS, le solveur adjoint et d'enrichir l'estimation d'erreur anisotrope avec des informations supplémentaires provenant du modèle de turbulence. Pour ces raisons, ce travail est divisé en trois contributions principales. La première concerne l'amélioration du solveur RANS. Pour cela, on mis en place de nouvelles stratégies automatiques de contrôle de la CFL et un couplage fort entre les équations de Navier-Stokes et le modèle de turbulence. Ces développements permettent d'améliorer la convergence non linéaire de la méthode de Newton. La deuxième contribution concerne la résolution du problème adjoint, qui s'avère particulièrement raide si on la compare à la résolution du problème primal, et, en même temps, est d'une grande importance lors du processus d'adaptation de maillage. Plusieurs méthodes ont été développées pour la résolution du problème adjoint, telle que la méthode flexible GMRES et une méthode pseudo-transitoire similaire à celle du problème primal. De plus, nous avons étudié l'impact du couplage fort entre les équations de Navier-Stokes et le modèle de turbulence pour le problème adjoint, et nous avons découvert que ce couplage fort enrichit la solution adjointe. Enfin, la troisième contribution concerne l'estimation d'erreur pilotant la procédure d'adaptation du maillage, qui inclut ici la contribution turbulente provenant des champs primaux et adjoints. Ces procédures ont été appliquées aussi bien à des benchmarks classiques de l'aéronautique qu'à des géométries plus complexes comme les modèles d'avion complet des 3ème et 4ème AIAA CFD High Lift Prediction Workshops.

Mots Clefs : Calcul scientifique, Adaptation de maillage anisotrope, Estimations d'erreurs, Dynamique des fluides numérique, Modèle de turbulence, Aéronautique.

Introduction

Contexte scientifique et industriel

Les écoulements laminaires sont caractérisés par un comportement régulier, où les couches du fluide se déplacent avec une tendance régulière. Contrairement aux écoulements laminaires, les écoulements turbulents sont caractérisés par des fluctuations irrégulières et des changements chaotiques [Kolmogorov 1941, Wilcox 1993]. Dans la grande majorité des applications réelles, il est nécessaire de considérer des écoulements turbulents. On peut citer, par exemple, la météorologie, où la turbulence atmosphérique doit être correctement modélisée et prévue afin de réduire les risques et les coûts associés aux vols des avions [Lane et al. 2012] ; l'hydrologie, l'hydraulique et en général les écoulements multi-phasiques [Murzyn andChanson 2008, Katul et al. 2019] ; la combustion, pour réduire les risques d'explosion et la consommation des systèmes de propulsion à base de carburant [Giusti and Mastorakos 2019] ; l'ingénierie biomédicale, pour prédire correctement le flux sanguin à l'intérieur du coeur et des vaisseaux afin de diagnostiquer les maladies potentielles sans effectuer de tests médicaux invasifs [Winfree 1994, Stella et al. 2019]. Cette thèse se concentre sur l'aéronautique : dans ce contexte, la prédiction correcte de la turbulence est importante pour la conception générale des aéronefs. Une bonne conception de l'avion permet de réduire le bruit produit par la cellule, le train d'atterrissage ou les jets [Souliez et al. 2002, Bodony and[START_REF] Bodony | [END_REF]. En outre, la turbulence a un effet dramatique sur la traînée fournie par une forme ou une configuration particulière, ce qui influence l'efficacité aérodynamique, qui, à son tour, se traduit par la consommation de carburant, avec des impacts financiers et environnementaux considérables [Vassberg et al. 2002, Sun andSmith 2017]. Pour les raisons listées, la prédiction correcte des écoulements turbulents représente une classe de problèmes de grande importance. Habituellement, de telles prédictions sont effectuées expérimentalement en utilisant des souffleries, éventuellement couplées à des approches théoriques [Bushnell 2006, Glotzer 2011]. Cependant, ces méthodes présentent plusieurs inconvénients. Premièrement, la construction, l'entretien et l'utilisation des souffleries sont extrêmement coûteux. En 1994, la construction d'une soufflerie basse vitesse coûtait environ 32 millions de dollars, celle d'une soufflerie transsonique 84 millions de dollars, et les coûts d'exploitation variaient de 5 000 à 16 000 dollars par heure et par utilisateur [Light et al. 2011]. En outre, certaines expériences sont difficiles, voire impossibles, à reproduire en soufflerie, comme la reproduction d'écoulements internes ou d'explosions, et d'autres sont fortement influencées par les interférences dues aux supports, aux capteurs et aux effets d'échelle.

La mécanique des fluides numérique (Computational Fluide Dynamics ou CFD en anglais) a commencé à jouer un rôle central [Löhner 2001, Hirsch 2007] dans le calcul des écoulements turbulents à partir des années 1970, principalement grâce à l'augmentation de la puissance de calcul disponible, et aux analyses supplémentaires de la physique fournies par les simulations numériques. Dans le domaine de l'aéronautique, la CFD permet d'explorer différentes configurations d'aéronefs et de prédire les coefficients aéronautiques tels que la portance ou la traînée [Ding et al. 2018, Reuther et al. 1999, Neittaanmäki et al. 2004]. Même si la CFD est moins coûteuse et peut reproduire un plus grand nombre de phénomènes, elle ne peut pas remplacer complètement les souffleries, qui sont nécessaires [Fujii 2005], par exemple pour calibrer et valider les modèles de turbulence. La calcul CFD considère un modèle géometrique definit analytiquement, appellé CAO (conception assis-CAO Mesh Solution Visualization

Figure 1 -Calcul CFD : le domaine autour d'une géométrie CAO est discrétisé en un maillage de calcul, qui est utilisé pour fournir la solution. La solution et les quantités associées sont visualisées à la fin du processus.

tée par ordinateur) représentant le domaine de calcul du problème à résoudre. Ce domaine est "discrétisé", c'est-à-dire qu'un maillage de calcul est construit sur celui-ci, puis une solution est calculée en fonction du maillage lui-même, des paramètres physiques et des conditions aux limites. Après cela, la solution peut être visualisée et analysée. La Figure 1 schématise le calcul en CFD.

Dans les trois premiers blocs du calcul CFD, nous pouvons distinguer quatre types d'erreurs. Le premier concerne l'approximation faite pour représenter la géométrie réelle à travers la CAO. La seconde est l'erreur de discrétisation associée au maillage de calcul, tandis que l'erreur de modélisation et l'erreur numérique sont produites par le calcul de la solution. Dans cette thèse, nous négligeons l'erreur de géométrie et de modélisation, en supposant que la CAO représente parfaitement la géométrie réelle et que le modèle représente parfaitement la physique sous-jacente. En ce qui concerne le maillage de calcul, il est clair que les maillages avec un grand nombre d'éléments, avec une taille plus petite, fournissent des résultats plus précis par rapport aux maillages avec moins d'éléments et avec une taille plus grand, mais les premiers sont plus couteux en termes de temps de calcul. Un compromis entre la précision de la solution et les ressources de calcul devrait être convenablement étudié avant de poursuivre tout calcul. En ce qui concerne la modélisation, nous traitons la turbulence au moyen des équations Reynolds averaged Navier-Stokes (RANS), et plus particulièrement avec le modèle de turbulence à une équation de Spalart-Allmaras pour traiter correctement la viscosité turbulente [Spalart and Allmaras 1992]. La modélisation RANS permet d'éviter les raffinements de maillage très couteux, contrairement aux simulations Large Eddy Simulations (LES), ou aux simulations numériques directes (DNS), car l'idée principale est de diviser une quantité instantanée en une composante moyenne dans le temps et une composante fluctuante, et par conséquent de résoudre uniquement la composante moyenne dans le temps, car un tel calcul ne nécessite pas de maillages relativement fins pour capter toutes les échelles de l'écoulement. Voir, à titre d'exemple, la Figure 2, où la même cascade a été photographiée avec un temps d'exposition court à gauche, et avec un temps d'exposition long à droite. La photographie à gauche montre des structures beaucoup plus complexes et détaillées, tandis que la photographie de longue exposition montre des structures plus grossières et plus lisses en raison du temps d'exposition. Le temps de calcul inférieur requis par les RANS suggère que LES et DNS sont loin d'être largement adoptées dans les processus de conception industriels et sont principalement confinées dans des cas académiques ou de R&D [Larsson and Wang 2014]. Dans tous les cas, nous supposons que le solveur numérique a été validé et vérifié et qu'il résout donc les équations du modèle correct [Oberkampf and Trucano 2002].

Un aspect important des solutions de simulation RANS est la présence de caractéristiques hautement directionnelles, telles que les couches limites, les ondes de choc, les sillages, et également les régions de production et de destruction de la turbulence qui peuvent montrer des directions privilégiées. De plus, les tourbillons, les décollements de la couche limite et de nombreux autres phénomènes physiques doivent être capturés avec précision afin d'obtenir une solution fiable à la fin d'une simulation. Tous ces phénomènes

Istantaneous photograph

Long exposure photograph impliquent un large éventail d'échelles différentes. Dans ce but, le maillage joue un rôle très important [START_REF] Marcum | Adaptive unstructured grid generation for viscous flow applications[END_REF]] car il doit être capable de capturer toutes les caractéristiques de l'écoulement sans gaspiller les ressources informatiques, par exemple en raffinant les couches limites ou en rendant plus grossières les régions d'écoulement uniforme. Par conséquent, la précision de la solution n'est pas seulement affectée par le nombre d'éléments du maillage, mais aussi par la façon dont ils sont disposés. Habituellement, la tâche de génèration et adaptation des maillages adapté à la physique est accomplie manuellement par des ingénieurs ayant un niveau approprié de compétences et d'expertise, et ces maillages sont souvent sous-optimaux, sujets aux erreurs et coûteux en temps ingénieur. De plus, certains phénomènes physiques éloignés de la couche limite sont difficiles à localiser a priori, et généralement omis, et même les structures connues a priori comme les couches limites ne sont pas toujours localisés précisément, par exemple lorsque celles-ci évoluent ou se séparent. Dans certains cas pratiques d'ingénierie, de telles méthodes ad hoc ne sont pas suffisantes pour obtenir une solution fiable en raison de la présence d'une large gamme d'échelles [Mavriplis 2008].

Pour surmonter ces problèmes, cette thèse traite de l'adaptation automatique de maillage anisotrope, car cet outil a dejà montré des résultats prometteurs dans le contexte de calcul CFD [Castro-Díaz et al. 1997, Habashi et al. 2000, Dompierre et al. 2002, Frey and Alauzet 2005, Gruau and Coupez 2005, Alauzet et al. 2006, Micheletti and Perotto 2008, Alauzet and Loseille 2010]. L'adaptation anisotrope du maillage permet de modifier automatiquement la taille et l'orientation de chaque élément d'un maillage de calcul, et donc de cibler avec précision tout phénomène physique survenant dans une simulation CFD. Voir, par exemple, sur la Figure 3, le maillage adapté anisotrope et le nombre de Mach (M a) pour une simulation avec maillage adaptif sur la géometrie d'avion du "Common Research Model" de la NASA

Mesh

Mach number (M a)

Figure 3 -Modèle commun de recherche du 4 th CFD AIAA High Lift Prediction Workshop : à gauche un maillage de calcul anisotrope adapté de ∼ 14 000 000 de sommets, à droite le champ du nombre de Mach.

en configuration hypersustentée du 4 th CFD AIAA High Lift Prediction Workshop : dans ce cas, le maillage adapté anisotrope (avec 14 000 000 de sommets) est capable de suivre les tourbillons générés par les supports des volets du bord d'attaque, les supports des volets du bord de fuite et la nacelle. Ainsi, dans ce contexte, le maillage adapté à l'écoulement n'est pas à la résolution du solveur, mais il fait partie intégrante du processus de résolution, et est déterminé automatiquement, sans aucune intervention humaine. Dans ce cadre, on considère un maillage initial, non adapté, et on l'utilise pour effectuer un calcul préliminaire afin d'obtenir une première estimation du champ d'écoulement. Ensuite, le champ obtenu est utilisé pour adapter le maillage de calcul afin de capturer des caractéristiques d'écoulement supplémentaires. Après avoir répété ce processus plusieurs fois, on obtient une séquence de maillages, et lorsque les modifications du maillage se stabilisent, la solution finale de l'écoulement est calculée sur le dernier maillage de la séquence. Dans ce contexte, le champ d'écoulement lui-même fournit les indicateurs nécessaires pour effectuer les modifications optimales du maillage [START_REF] Venditti | [END_REF], Loseille et al. 2010, Fidkowski and Darmofal 2011]. En général, après le processus d'adaptation, le maillage résultant montre des raffinements sur les régions présentant de fortes variations de solution, mais cela peut dépendre de la fonction utilisée pour conduire le processus d'adaptation. Par exemple, nous citons l'adaptation multi-échelle, où le maillage est modifié afin de minimiser l'erreur d'interpolation sur une fonction u, qui est généralement identifiée avec le champ de nombre de Mach local [START_REF] Alauzet | [END_REF] ; dans ce cas, le maillage résultant suit les caractéristiques de u. Une approche plus sophistiquée est l'adaptation de maillage ciblée à une fonctionelle d'intérêt (en anglais, goal-oriented mesh adaptation), présentée comme une généralisation de l'adaptation multi-échelle [START_REF] Loseille | Fully anisotropic goaloriented mesh adaptation for 3D steady Euler equations[END_REF][START_REF] Alauzet | [END_REF]. Ici, le maillage est modifié afin de minimiser l'erreur de discrétisation associée à une fonction J d'intérêt dépendant de la solution de l'écoulement. Dans ce contexte, la méthode exploite ce que l'on appelle la solution adjointe, qui représente la sensibilité de J par rapport à la solution de chaque pointe du domaine de calcul, et, pour cette raison, le problème adjoint associé aux équations RANS joue un rôle central dans l'adaptation du maillage goal-oriented. En ce qui concerne l'adaptation multi-échelle, cette méthodologie s'est avérée particulièrement utile pour traiter les écoulements non-visqueux (fluides parfaits) [Alauzet andLoseille 2010, Belme 2011], notamment pour suivre les discontinuités telles que les ondes de choc. L'adaptation de maillage goal-oriented s'est avérée utile à la fois pour les écoulements non-visqueux et visqueux (fluides réels). Dans le cas spécifique des écoulements visqueux, elle permet d'obtenir un raffinement approprié des régions de la couche limite [START_REF] Alauzet | [END_REF], ce qui améliore la propriété de captage précoce de l'adaptation du maillage, c'est-à-dire qu'elle est capable d'obtenir des valeurs des fonctionnelles d'intérêt précises même avec des maillages grossiers. Quoi qu'il en soit, les méthodologies actuelles employant l'adaptation de maillage goal-oriented manquent d'un traitement spécifique de la turbulence, et ne tiennent pas compte de la production et de la destruction de la turbulence. En fait, l'un des principaux objectifs de ce travail est d'inclure correctement ces contributions dans le processus d'adaptation de maillage. Afin d'inclure la turbulence dans la procédure d'adaptation de maillage goal-oriented, il faut résoudre le problème adjoint turbulent fortement couplée, c'est-à-dire coupler les équations de l'écoulement moyen et l'équation de la turbulence. À ce sujet, on peut trouver plusieurs exemples dans le contexte de l'optimisation de forme, et l'opinion générale est que cette approche produit des champs adjoints plus nets, plus précis que ceux qui n'utilisent pas un couplage turbulent fort [Zymaris et al. 2009, Papoutsis-Kiachagias et al. 2014]. L'objectif ici est d'étudier l'effet du couplage fort dans le contexte de l'adaptation du maillage.

Objectif

Le but de cette thèse est de développer et d'améliorer les méthodologies CFD actuelles pour traiter des cas industriels réels avec l'adaptation de maillage, et, en parallèle, de développer de nouvelles techniques d'adaptation de maillage spécifique de l'application considerée. Plus en détail, ce travail s'inscrit dans la continuité des travaux menés dans [Frazza 2018, Menier 2015, Belme 2011] dans le cadre de l'étude de l'adaptation de maillage par l'équipe Gamma de l'INRIA. Les activités de l'équipe Gamma comprennent le développement du solveur fluide et du solveur adjoint Wolf, un logiciel écrit en C qui inclut des routines pour résoudre les équations d'Euler, de Navier-Stokes et de Spalart-Allmaras sur des géométries 2D et 3D, les problèmes d'adjoint relatifs et calcule les champs métriques nécessaires pour effectuer l'adaptation de maillage anisotrope.

Contributions

Les contributions apportées dans ce travail couvrent un large éventail de sujets, et peuvent être divisées en trois parties.

• Solveur fluide : nous avons amélioré la robustesse du solveur d'écoulement RANS Wolf, car nous avons constaté une convergence lente ou approximative sur des cas très complexes tels que ceux fournis par le 4 th CFD AIAA High Lift Prediction Workshop. Cibler la bonne solution et avoir des résidus convergents jusqu'à la machine zéro est crucial pour l'utilisation de l'adaptation du maillage dans les simulations haute-fidélité. Nous avons atteint cet objectif en mettant en oeuvre des lois CFL plus sophistiquées, en introduisant des schémas moins dissipatifs et en améliorant le solveur linéaire interne. En outre, étant donné que le solveur RANS résolvait le système formé par les équations de l'écoulement moyen et l'équation de turbulence au moyen d'une approche faiblement couplée, nous avons mis en oeuvre et évalué la version fortement couplée de ce solveur. • Solveur adjoint : nous avons constaté un manque de convergence du problème adjoint sur des maillages adaptés avec un nombre élevé de sommets comme dans le cas de celles obtenues lors des simulations pour le 4 th CFD AIAA High Lift Prediction Workshop. Pour cette raison, nous avons testé plusieurs stratégies pour surmonter ce problème. Plus en détail, nous avons testé plusieurs approches algébriques pour résoudre le système linéaire adjoint. En outre, puisque le solveur adjoint n'était pas en mesure de produire une viscosité turbulente adjointe non nulle, nous avons étudié le rôle de cette quantité en employant un solveur adjoint fortement couplé, comme nous l'avons fait pour le solveur fluide. • Estimation de l'erreur : dans [Frazza 2018], plusieurs stratégies d'adaptation pour les écoulements visqueux ont été étudiées, y compris l'adaptation de maillage multi-échelle et goal-oriented. Dans cette thèse, nous avons développé une estimation d'erreur plus sophistiquée, capable de prendre en compte la viscosité turbulente adjointe, les flux de l'équation de Spalart-Allmaras et sa variable adjointe. Ces ajouts ont permis de mieux comprendre plusieurs phénomènes physiques intrinsèquement liés au modèle de turbulence de Spalart-Allmaras mis en oeuvre, en particulier à l'intérieur des couches limites et dans les régions de production/destruction de la turbulence.

Plan de la thèse

Cette thèse est divisée en cinq chapitres. Les deux premiers chapitres couvrent les sujets concernant le solveur fluide, le troisième chapitre décrit le solveur adjoint, les quatrième et cinquième chapitres décrivent la stratégie d'adaptation de maillage adoptée. En particulier,

• Le Chapitre 1 décrit le solveur fluide Wolf. Il contient une description du modèle physique utilisé, les discrétisations spatiale et temporelle des équations, le solveur linéaire interne et plusieurs stratégies pour améliorer la robustesse du solveur utilisé, • Le Chapitre 2 décrit le solveur fluide turbulent fortement couplé, à la fois pour le cas 2D et 3D, ainsi que la comparaison avec le solveur turbulent faiblement couplé sur plusieurs cas en 2D et 3D, • Le Chapitre 3 introduit la définition et la problématique du problème adjoint, et montre plusieurs approches pour le résoudre. Une paranthèse est faite concernant le rôle de la viscosité turbulente adjointe.

Introduction

Scientific and industrial context

Laminar flows are characterized by a regular behaviour where the layers of the fluid move with a smooth trend. In contrast to laminar flows, turbulent flows are characterized by irregular fluctuations and chaotic changes [Kolmogorov 1941, Wilcox 1993]. The vast majority of real applications deal with turbulent flows. We can cite, for instance, meteorology, where atmospheric turbulence needs to be properly modelled and forecast in order to reduce risks and costs of aircraft flights [Lane et al. 2012]; hydrology, hydraulics and in general multiphase flows [Murzyn andChanson 2008, Katul et al. 2019]; combustion, for instance to reduce the risks of explosion and consumptions of fuel-based propulsion systems [Giusti and Mastorakos 2019]; biomedical engineering, to correctly predict the blood flow inside the heart and vessels in order to diagnose potential diseases without performing invasive medical tests [Winfree 1994, Stella et al. 2019]. This thesis focuses on aeronautics, and within this context the correct prediction of turbulence is important to general design aircrafts. For instance, a proper aircraft design allows to reduce the noise produced by the airframe, the landing gear or by the jets [Souliez et al. 2002, Bodony and[START_REF] Bodony | [END_REF]. Furthermore, turbulence has a dramatic effect on the drag provided by a particular shape or configuration, which influences the aerodynamic efficiency, which, in turn, translates into fuel consumption, financial and environmental impacts [Vassberg et al. 2002, Sun andSmith 2017].

To these aims, the correct prediction of turbulent flows represents a class of problems of great importance. Classically, such predictions are pursued experimentally by using wind tunnels, possibly coupled with theoretical approaches [Bushnell 2006, Glotzer 2011], but these methods present several drawbacks. The construction, the mantainance and the use of wind tunnels are extremely expensive. For instance, in 1994 the construction of a low-speed wind tunnel was about of $32 million, transonic $84 million, and the operating costs varied from $5,000 to $16,000 per hour per user [Light et al. 2011]. Furthermore, some experiments are difficult or even impossible to reproduce in wind tunnel, such as the replication of internal flows or explosions, or are highly influenced by interferences due to supports, sensors and scale effects.

Hence, Computational Fluid Dynamics (CFD) started to play a central role [Löhner 2001, Hirsch 2007] within turbulent flow computations from 1970s, mainly thanks to the increased computational power available, and for the additional physics insights provided by numerical simulations. In aeronautics, CFD allows to explore different configurations for aircrafts and to predict aerodynamic coefficients such as the lift or the drag [Ding et al. 2018, Reuther et al. 1999, Neittaanmäki et al. 2004]. Even though CFD is less expensive and can reproduce a wider range of phenomena, it cannot completely substitute wind tunnels, as these are needed [Fujii 2005], for instance to calibrate and validate turbulence models. The common CFD workflow considers a computer-aided design (CAD) geometry representing the computational domain of the problem at hand. Such domain is discretized, i.e., a computational mesh is constructed on top of it, and then a solution is computed depending on the mesh itself, physical parameters and boundary conditions. After this, the solution can be viewed and analyzed. In Figure 4, the CFD workflow is schematized.

Within the first three blocks of the CFD pipline, we can distinguish four types of errors. The first concerns the approximation made to represent the real geometry through the CAD. The second is the discretization error associated with the computational mesh, CAD Mesh Solution Visualization

Figure 4 -Common CFD workflow: the domain around a CAD geometry is discretized into a computational mesh, which is used to provide the solution. The solution and the related quantites are visualized at the end of the processs.

while the modeling error and the numerical error are produced by the computation of the solution. In this thesis, we neglect the geometry and the modeling error, assuming the CAD is perfectly representing the real geometry and assuming that the model represents perfectly the underlying physics. Concerning the computational mesh, it is clear that meshes with a high number of smaller elements provide more precise results in comparison with meshes with fewer and bigger elements, but the first ones are more demanding in terms of computational time, hence a trade-off between the solution precision and the computational resources should be suitably studied before pursuing any computation. Concerning the modeling, we treat turbulence through the Reynolds-averaged Navier Stokes (RANS) equations, specifically with the Spalart-Allmaras one-equation turbulence model to treat properly the turbulent viscosity [Spalart and Allmaras 1992]. The RANS modeling allows to avoid demanding mesh refinements, in constrast to large eddy simulations (LES) or direct Navier-Stokes (DNS), as the main idea is to split an istantaneous quantity into a time-averaged and a fluctuating component, and consequently to resolve the time-averaged component only, as such computation does not require relatively fine meshes. See, as an illustrating example, Figure 5, where the same waterfall has been photographed with a short exposure time on the left, and with a long exposure time on the right. The photograph on the left shows much more complex and detailed structures, while the long exposure photograph shows coarser and smoother structures as the result of the exposure time. The lower computational time required by RANS suggests that LES and DNS are far from being widely adopted in actual design processes and are mainly confined in academic or R&D cases [Larsson and Wang 2014]. In any case, we assume that flow solver has been validated and verified, and hence it is solving the equations of the correct model [Oberkampf and Trucano 2002].

An important aspect of the RANS simulation solutions is the presence of highly directional features, such as boundary layers, shock waves, wakes, and also regions of turbulence production and destruction can show privileged directions. Furthermore, vortices, detachments of boundary layer, and many other physical phenomena should be captured precisely in order to deal with a reliable solution at the end of a simulation. In addition to this, all these phenomena involve a wide range of different scales. To this aim, the computational mesh plays a role of great importance [START_REF] Marcum | Adaptive unstructured grid generation for viscous flow applications[END_REF]] as it should be able to capture such flow features without wasting computational resources, for instance, by refining the boundary layers or coarsening the freestream regions. Hence, the precision of the solution is not only affected by how many elements the mesh has, but also how these are arranged. Usually, the task of producing physically-sensible meshes is accomplished manually by engineers with a proper level of skills and expertise, and such meshes are often sub-optimal, error-prone and computationally expensive. Furthermore, some physical phenomena far from the boundary layer are difficult to locate a priori, and generally missed, and even a priori-known structures like boundary layers are not always precisely located, for instance when these evolve or separate. In some practical engineering cases such best-practice meshing guidelines are not enough to obtain a reliable solution due to the presence of a wide

Istantaneous photograph

Long exposure photograph range scales [Mavriplis 2008].

To overcome these issues, this thesis deals with automatic anisotropic mesh adaptation, as this tool has shown promising results in the context of CFD computations [Castro-Díaz et al. 1997, Habashi et al. 2000, Dompierre et al. 2002, Frey and Alauzet 2005, Gruau and Coupez 2005, Alauzet et al. 2006, Micheletti and Perotto 2008, Alauzet and Loseille 2010]. Anisotropic mesh adaptation allows to modify automatically the size and the orientation of each element of a computational mesh, and hence allows to target accurately any physical phenomena arising in a CFD simulation. See, e.g., in Figure 6, the anisotropic adapted mesh and the Mach number (M a) of the 4 th CFD AIAA High Lift Prediction Workshop common research model: in this case the anisotropic adapted mesh (with ∼ 14 000 000 vertices) is able to track the vortices generated by the slat brackets, the flap supports, and the nacelle. Hence, within this context the mesh is not preparatory to the solver resolution, but it is an integral part of the resolution process, and is automatically determinated, free from any human intervention.

Within this framework, one considers an initial, un-adapted mesh, and uses it to perform a preliminary computation to get a first flow field guess. Then, the obtained field is used to adapt the computational mesh in order to capture additional flow features. After repeating this process for several times, one obtains a sequence of meshes, and as the mesh modifications stabilize, the final flow solution is computed on the last mesh of the sequence. In this context the flow field itself provides the indicators needed to perform the optimal mesh modifications [START_REF] Venditti | [END_REF], Loseille et al. 2010, Fidkowski and Darmofal 2011]. In general, after the adaptation process, the resulting mesh shows refinements over regions showing steep solution variations, but this could depend on the sensor which is used to drive the adaptation process. For instance, we cite the

Mesh

Mach number (M a)

Figure 6 -4 th CFD AIAA High Lift Prediction Workshop common research model: on the left an anisotropic adapted computational mesh of ∼ 14 000 000 vertices, on the right the Mach number field.

multiscale adaptation, where the mesh is modified in order to minimize the interpolation error on a sensor function u, which is usually identified with the local Mach number field [START_REF] Alauzet | [END_REF]; in such a case, the resulting mesh follows the characteristics of u. A more sophisticated approach is the goal-oriented mesh adaptation, presented as a generalization of the multiscale adaptation [START_REF] Loseille | Fully anisotropic goaloriented mesh adaptation for 3D steady Euler equations[END_REF][START_REF] Alauzet | [END_REF]].

Here, the mesh is modified in order to minimize the discretization error associated with a functional J depending on the flow field solution. Within this context, the method exploits the so-called adjoint solution, which represents the sensitivity of J with respect to the flow equations, and, for this reason, the adjoint problem associated with the RANS equations plays a central role in goal-oriented mesh adaptation. Concerning the multiscale adaptation, such methodology turned out to be particularly useful when dealing with inviscid flows [Alauzet andLoseille 2010, Belme 2011], specially to keep track of discontinuities as shock waves. The goal-oriented mesh adaptation turned out to be useful in both inviscid and viscous flows. Specifically to viscous flows, it is able to obtain a proper refinement of the boundary layer regions [START_REF] Alauzet | [END_REF], and this improves the early capturing property of mesh adaptation, that is, it is able to obtain accurate functional values even with coarse meshes. Anyway, the current methodologies employing goal-oriented mesh adaptation lacks of a specific treatment of turbulence, and do not take into account turbulence production and destruction. In fact, one of the main goals of this work is to properly include these contributions in the mesh adaptation process. In order to include turbulence in the goal-oriented mesh adaptation procedure, one has to solve the strongly coupled turbulence adjoint problem, that is, to couple the mean-flow equations and the turbulence equation. Concerning this topic, one can find several example in the context of shape optimization, and, the general opinion is that this approach produces sharper adjoint fields, more precise than those not employing a strong turbulent coupling [Zymaris et al. 2009, Papoutsis-Kiachagias et al. 2014]. The aim here is to study the effect of the strong coupling in the context of mesh adaptation.

Objective

The objective of this thesis is to develop and improve the current CFD methodologies to deal with real industrial cases and adapted meshes, and, in parallel to this, to develop new mesh adaptation techniques depending of the specific application. More in detail, this work is a continuation of the works pursued in [Frazza 2018, Menier 2015, Belme 2011] in the Gamma team of INRIA. The activities of the Gamma team include the development of the Wolf flow and adjoint solver, which is a software written in C which includes routines to solve the Euler, the Navier-Stokes and the Spalart-Allmaras equations on 2D and 3D geometries, the relative adjoint problems and computes the metric fields which are needed to perform the anisotropic mesh adaptation.

Contributions

The contributions made in this work span over a range of topics, and they can be divided in three groups.

• Flow solver: we have improved the robustness of the RANS flow solver of Wolf, as we experienced slow or rough convergence on highly complex cases such as those provided by the 4 th CFD AIAA High Lift Prediction Workshop. Targeting the correct solution and having machine-zero converged residuals is crucial for the employment of mesh adaptation in high-fidelity simulations. We achieved this goal by implementing more sophisticated CFL laws, by introducing less dissipative schemes, and by improving the inner linear solver. In addition to this, since the Wolf RANS solver solved the system formed by the mean-flow equations and the turbulence equation by means of a weakly coupled approach, we have implemented and assessed the strongly coupled version of such solver. • Adjoint solver: we experienced lack of convergence of the adjoint problem on meshes with a high number of vertices like those of complex 3D geometries. For this reason we have tested several strategies to overcome this issue. More in detail, we tested several algebric approach to solve the adjoint linear system. In addition to this, since the adjoint solver was not able to produce a nonnull adjoint turbulent viscosity, we investigated the role of this quantity by employing a strongly coupled adjoint solver, likewisely we did for the flow solver. • Error estimate: in [Frazza 2018] several adapation strategies for viscous flows have been investigated, including feature-based and goal-oriented mesh adaptation. In this thesis we have developed more sophisticated error estimate, able to take into account the Spalart-Allmaras primal and adjoint variables and its fluxes, including turbulence production and destruction. Such additions provided some insights on several physical phenomena intrinsically linked with the implemented Spalart-Allmaras turbulence model, specially inside boundary layers and in regions of turbulence production/destruction.

Outline

This thesis is divided into five chapters. The first two chapters covers topics concerning the flow solver, the third chapter describes the adjoint solver, the fourth and the fifth chapters described the mesh adaptation strategy adopted. In particular,

• Chapter 1 describes the Wolf flow solver. It contains a description of the used physical model, the spatial and the temporal discretizations of the equations, the inner linear solver and several strategies to increase the robustness of the flow solver used, • Chapter 2 describes the strongly coupled turbulent flow solver, for both the 2D and the 3D case, with several results to compare with the weakly coupled turbulent solver, • Chapter 3 introduces the definition and the problematics of the adjoint problem, and shows several approaches to solve it. A paranthesis is made concerning the role of the adjoint turbulent viscosity.

• Chapter 4 describes the continuous mesh framework, which is the foundation of the anisotropic mesh adaptation strategy employed in this work, and introduces the following chapter, that is • Chapter 5, which explore several goal-oriented error estimates to drive the adaptation procedure, with their benefits and drawbacks depending on the application.

Chapter 1

RANS flow solver

In this chapter we dscribe the steady flow solver which is used to provide reliable numerical solutions to the RANS problem. The implementation of a robust flow solver, being able to reduce, ideally, to machine zero the flux residuals, possibly on highly anisotropic unstructured meshes, is a topic of great importance in high-fidelity simulations. From one side, getting a precise solution allows to pursue the validation of the implemented physical model, and, on the other hand, having a correct solution helps the mesh adaptation process which modifies the computational mesh to improve the computations. In this work, in particular, the flow solver represents the first step towards to production of a reliable mesh. We first describe the spatial and the time discretizations, then the linear algebra solver and several strategies to increase the solver robustness and precision. In particular, the flow solver described here is Wolf, which is a software written in C relying on parallelization based on multithreading. Concerning the spatial dicretization, we use the so-called mixed finite element -finite volume method, which assumes the solution to be stored at the vertices of the computational mesh, and employs finite volumes to discretize the convective fluxes and finite elements to handle viscous and source terms. The time discretization is pursued through the use of the backward Euler scheme BDF1. This chapter is organized as follows: in Section 1.1 we describe the physical model used, that is, the compressible Navier-Stokes equations, the ideal gas law, the Spalart-Allmaras turbulence model and their notation; in Section 1.2 we describe the spatial discretization, while in Section 1.3 the time discretization; in Section 1.4 we describe the data structures and the algorithms used to solve the linear systems: Sections 1.2, 1.3 and 1.4 make a summary of the tools already available at the beginning of the present work. The main contributions to the Wolf flow solver are shown in Section 1.5, where we show several CF L and limiter tuning strategies to increase the flow solver robustness and precision.

Physical model

As said, we solve the compressible RANS equation. We start by writing the Navier-Stokes equation part, reading as

         ∂ρ ∂t + ∇ • (ρu) = 0, ∂ρu ∂t + ∇ • (ρu ⊗ u) + ∇p = ∇ • T , ∂ρE ∂t + ∇ • ((ρE + p)u) = ∇ • (T • u) + ∇ • (λ∇T ), (1.1)
where ρ is the density, u the velocity, E the total energy and p the pressure, which is computed throught the ideal gas law as

p = (γ -1) ρE - 1 2 ρ||u|| 2 , (1.2)
and the temperature T is obtained with

T = 1 c v E - 1 2 ||u|| 2 , (1.3)
λ is the laminar conductivity and T is the stress tensor, reading, in the case of the RANS equations, as

T = (µ + µ t ) (∇ ⊗ u + ∇ ⊗ u T ) - 2 3 ∇ • u 1 , (1.4)
where 1 indicates the identity matrix. Note that the turbulent viscosity µ t provide additional viscosity as it is added to the laminar dynamic viscosity in (1.4), following the Boussinesq hypothesis. The laminar dynamic viscosity and the conductivity are computed through the Sutherland's laws with

µ = µ ∞ T T ∞ 3 2 T ∞ + Su T + Su , and, λ = λ ∞ T T ∞ 3 2 T ∞ + Su T + Su , (1.5)
where Su = 110 and the superscript ∞ indicates reference quantities. We get the laminar conductivity of the air through the definition of the Prandtl number P r = µc p λ , P r = 0.72.

(1.6)

Concerning the turbulent viscosity modeling, Wolf contains the implementation of the Spalart-Allmaras model [Spalart and Allmaras 1992], and a partial implementation of the Menter κ-ω [Menter 1993]. Anyway, this work relies on the first model only. The Spalart-Allmaras model provides a single additional transport equation for the Spalart-Allmaras variable ν, reading as

∂ρν ∂t + u • ∇(ρν) = c b1 Sρν -c w1 f w ρ ν d 2 + ρ σ [∇ • ((ν + ν)∇ν) + c b2 ρ||∇ν|| 2 ]. (1.7)
We remark that the equation in (1.7) represents a slightly simplified version of the model developed in [Spalart and Allmaras 1992], which is called SA-noft2, that is, the trip terms of the original model are not included. Equation (1.7) shows four distinguished terms on the right hand side: the first one represents the turbulence production, the second the turbulence destruction, the third represents the turbulence dissipation and the final one the turbulence diffusion. The turbulent viscosity is obtained with

µ t = ρνf v1 ,
where

f v1 = χ 3 χ 3 + c 3 v1 , χ = ν ν , ν = µ ρ ,
and the remaining terms are given by

f v2 = 1 - χ 1 + χf v1 , S = Ω + ν κ 2 d 2 f v2 , Ω = ||∇ × u||,
where d is the distance to the nearest wall, and the constants are given by σ = 2 3 , c b1 = 0.1355, c b2 = 0.622, κ = 0.41

c w1 = c b1 κ + 1 + c b2 σ , c w2 = 0.3, c w3 = 2, c v1 = 7.1.
In general, the Spalart-Allmaras variable ν should be kept positive through the computation, but allowing it to decrease below zero could be beneficial in terms of flow solver convergence, even though this is not physical. For this reason, Wolf implements also the negative Spalart-Allmaras model (SA-neg-noft2), and in regions where ν < 0 equation (1.7) is modified as follows

∂ρν ∂t + u • ∇(ρν) = c b1 Ωρν -c w1 f w ρ ν d 2 + ρ σ [∇ • ((ν + νf n )∇ν) + c b2 ρ||∇ν|| 2 ],
where

f n = c n1 + χ 3 c n1 -χ 3 , c n1 = 16,
and µ t = 0 where ν < 0.

Wolf allows to choose further Spalart-Allmaras implementations, namely, SA-QCR [Spalart 2000] and the SA-R [ [START_REF] Dacles-Mariani | [END_REF]], but they are not deepen in this work. The SA-QCR implementation presents a correction of the Boussinesq hypothesis, as this does not hold in particular cases like recirculating and impinging jets, and hence the total stress tensor depends also on the rotation tensor.

Equations (1.1) and (1.7) can be arranged in a unique vector equation, written as

W t + ∇ • F (W ) = ∇ • S(W ) + Q(W ), (1.8)
where W = (ρ, ρu, ρv, ρw, ρe, ν), F are the convective fluxes F 1 (W ) = (ρu, ρu 2 + p, ρuv, ρuw, u(ρE + p), ρuν) T , F 2 (W ) = (ρv, ρuv, ρv 2 + p, ρvw, v(ρE + p), ρvν) T , F 3 (W ) = (ρw, ρuw, ρvw, ρw 2 + p, w(ρE + p), ρwν) T ,

(1.9)

S represents the viscous fluxes

S 1 (W ) = 0, T xx , T xy , T xz , uT xx + vT xy + wT xz + ∂ x T, ρ σ (ν + ν)∂ x ν T , S 2 (W ) = 0, T xy , T yy , T yz , uT xy + vT yy + wT yz + ∂ y T, ρ σ (ν + ν)∂ x ν T , S 3 (W ) = 0, T xz , T yz , T zz , uT xz + vT yz + wT zz + ∂ z T, ρ σ (ν + ν)∂ x ν T , (1.10)
where T ij are the components of the total stress tensor (1.4). Q are the source terms, representing the contribution from the Spalart-Allmaras turbulence model, that is

Q(W ) = 0, 0, 0, 0, 0, c b2 ρ σ ||∇ν|| 2 + ρc b1 S ν + c w1 f w ρ ν d 2 T
.

(1.11)

Note that we indicate the turbulent variable in its physical form ν, and not ρν, as we solve the turbulent equation using ν as unknown. In the sequel, this holds also for the RANS adjoint solver and the error estimation. We remark that with Wolf it is possible to run both steady and transient simulations. Anyway, the present work is based on steady simulations only. For this reason the real target of the flow solver part here is to approximate the steady solution W solving

R(W

) := ∇ • F (W ) -∇ • S(W ) -Q(W ) = 0,
(1.12)

where R denotes the continuous residual. In any case, we keep and discretize the time derivative W t as the steady solver implemented relies on the pseudo-transient method [Fletcher 1998], meaning that a transient simulation is run starting from a suitable initial state, and the time is advanced until a steady state is found.

Space discretization

In this section we describe the spacial discretization associated with problem (1.12). We first describe the discretization of the domain, the function space of the approximating solution (indicated by W h ), the discretization of the convective fluxes and the sources by means of finite volumes, and of the viscous fluxes by means of finite element.

The domain Ω is discretized using a triangular (in 2D cases) or a tetrahedral (in 3D ones) conformal mesh H (see Figure 1.1). Hence, the external surfaces of Ω (we assume it is bounded) are a tesselation of segments in 2D and of triangles in 3D, and we indicate the resulting discrete domain as Ω h . The approximating solution to problem (1.12) is indicated by W h , but for the moment we indicate it with W , to avoid heavy notation when representing nodal quantities and fluxes. We assume that the degrees of freedom of the solution W are located at the vertices of the mesh H. This is natural in the context of the finite element, in fact for the computation of the viscous fluxes we treat W as a P 1 function, that is, a piecewise linear function.

To treat the convective fluxes, we associate a finite volume cell to each vertex i of the mesh H, so that Ω h is given by the union of such cells. We indicate a triangle/tetrahedron of H as K, and a general finite volume cell associated with the vertex i as C i . Hence, we have

Ω h = N K i=1 K i = N V i=1 C i ,
where N K is the number of elements, and N V is the number of vertices. The mesh formed by {C i } N V i=1 is the so-called dual mesh of H. Wolf lets the user to select several kinds of cells. We rely on the median cells, which are obtained by joining into segments the barycenter of each element to the midpoints of the surrounding element edges (in 2D), or to the barycenters of the surrounding element faces (in 3D). This splits each triangle in 3 parts, or each tetrahedron in 4 parts. We show also the edge midpoints, indicated by P i P j /2, P i P k /2, and, in 3D, P i P l /2, and the barycenter of each element G. In 3D, we have also indicated the barycenter of the involved faces,

G f i , G f k and G f l .
Wolf gives the possibility to select also the Barth, or, containment cells [Barth 1992], which generate less distortion in quasi-structured meshes so they guarantee an approximate equivalence between finite volumes and finite differences, but we exclude their use as we expect to have highly distortions, also in "regular" regions like boundary layers.

Since we have assumed that the solution W is stored at the vertices of the mesh, we end up with the following system of nonlinear ODEs, (1.13) where F i are the numerical convective fluxes, S i are the numerical viscous fluxes, Q i are the numerical sources, and Γ i are terms coming from the discretization of the boundary conditions. In the following sections, we describe in detail the computation of such numerical fluxes.

|C i | dW i dt + F i = S i + Q i + Γ i ,

Convective fluxes

In this section, we illustrate the discretization of the convective fluxes through the finite volume method. We treat the convective fluxes of the mean-flow equations and of the turbulent equation in two different ways, hence we start by describing the discretization of the mean-flow part first. Within the finite volume method context, we split the computation of F i over the faces of the finite volume cell associated with the vertex i, providing

F i = ∂C i F (W ) • n i dγ P j ∈N (i) F | ∂C ij • ∂C ij n i dγ,
where F is defined as in (1.9), N (i) is the set of vertices connected to i and n i is the normal to the boundary of the cell C i associated with the vertex i. We indicate by F | ∂C ij the value of the flux through the portion of the boundary shared by the cells associated with vertices i and j. Basically, we assume that the solution W i is constant inside each finite volume cell,

W i = 1 |C i | C i W dΩ.
Hence, the problem reduces to the computation of the fluxes at each cell interface between two vertices i and j, and we indicate such flux as Φ conv ij , that is

F | C ij • ∂C ij n i dγ = Φ conv ij (W i , W j , n ij ),
where n ij = ∂C ij n i dγ. We can see that the computation of the fluxes at each cell interface can be reduce to a 1D problem in direction of the edge connecting i and j. For this reason we follow the Godunov's hypothesis, and we end up to solve locally a Riemann problem, which reads as

         ∂ t W + ∂ x F (W ) = 0, W (x, 0) = W L (= W i ), ∀x < 0, W (x, 0) = W R (= W j ), ∀x ≥ 0, (1.14)
where we assumed that the space derivative ∂ x is taken in the direction of the edge connecting i and j, and, without loss of generality, that the vertex i lies on the left of the 1D domain, point j on the right, and that the zero of the domain lies on the cell interface.

With the solution to problem (1.14) it is possible to compute the value of the convective fluxes at each cell interface, but solving directly (1.14) can become expensive as these problems require the resolution of a nonlinear system with several Newton iterations.

HLLC approximate Riemann solver

Wolf provides a suite of approximate Riemann solvers to deal with (1.14). Among these, it includes the Roe and the Roe-Turkel solvers [Roe 1981], but this work is based on the HLLC approximate Riemann solver [START_REF] Batten | [END_REF]], as it is more robust, preserves positivity and satisfies the entropy inequality. The idea of the HLLC flow solver is to build locally a simplified Riemann problem with two intermediate states depending on the local left and right states. The simplified solution to the Riemann problem consists of a contact wave with a velocity S M and two acoustic waves, which may be either shocks or expansion fans. The acoustic waves have the smallest and the largest velocities (S i and S j , respectively) of all the waves present in the solution. If S i > 0 then the flow is supersonic from left to right and the upwind flux is given by F (W i ), and if S j < 0 then the flow is supersonic from right to left and the flux is defined as F (W j ). If S i < 0 < S j we have to compute F (W * i ) and F (W * j ), and here the HLLC flux is given by

Φ HLLC ij (W i , W j , n ij ) =                F (W i ) • n ij if S i > 0, F (W * i ) • n ij if S i ≤ 0 < S M , F (W * j ) • n ij if S M ≤ 0 < S j , F (W j ) • n ij if S j < 0.
(1.15)

W *
i and W * j are evaluated as follows: we define η = u • n, and assuming that η * = η * i = η * j = S M , the following evaluations are proposed

W * = 1 S -S M     ρ(S -η) ρu(S -η) + (p * -p)n ρE(S -η) + p * S M -pη     where p * = ρ(S -η)(S M -η) + p.
Eventually, the definition of the contact wave velocity is

S M = ρ j η j (S j -η j ) -ρ i η i (S i -η i ) + p i -p j ρ j (S j -η j ) -ρ i (S i -η i ) ,
while the definition of the acoustic waves is

S i = min (η i -c i , η -c), S j = min (η j + c j , η + c),
where the η and c are the Roe averages, given by

η = √ ρ i η i + √ ρ j η j √ ρ i + √ ρ j , c = √ ρ i c i + √ ρ j c j √ ρ i + √ ρ j .
With these definitions, the HLLC approximate Rieman solver satisfies the entropy inequality, resolves isolated contacts and shocks exactly and preserves positivity.

Turbulent linear convection

Concerning the numerical flux associated with the turbulent convection, we simply rely on a linear convection, that is

Φ conv,ν ij (W i , W j , n ij ) =    ρην i if η > 0, ρην j otherwise, with η = 1 2 (u i • n ij + u j • n ij ).

Second order accuracy

Wolf provides the possibility to increase the spacial accuracy of the values W i and W j used in (1.15). In particular, the computation of Φ conv is replaced by

Φ conv = Φ conv ij (W ij , W ji , n ij )
, where W ij replaces W i and W ji replaces W j . These new values are obtained by using the MUSCL extrapolation [van Leer 1973], i.e., they are linearly extrapolated as

W ij = W i + 1 2 (∇W ) i • P i P j , W ji = W j + 1 2 (∇W ) j • P j P i .
The way the gradients (∇W ) i and (∇W ) j are defined, provides the order of accuracy of the solver. Following [START_REF] Debiez | [END_REF], these can be constructed by using suitable combinations of upwind, downwind and centered gradients for each edge of the mesh. A possible approach is to use the centered gradient

(∇W ) ij • P i P j = W j -W i , (∇W ) ji • P j P i = W i -W j .
The upwind and downwind gradients are computed according to the definition of upwind and downwind triangles/tetrahedra associated with the edge i -j, and are indicated by K i and K j . In particular, these are the elements K i and K j sharing the vertices i and j, respectively, which are crossed by the extension of the segment linking i and j. A 2D representation is shown in Figure 1.3, while a 3D representation is shown in Figure 1.4. Hence, the upwind and downwind gradients are the values of the P 0 gradients on the upwind and downwind elements, defined as A weighted average of centered, upwind and downwind gradients provide the so-called β-scheme

(∇W ) U ij = (∇W )| K i , (∇W ) D ij = (∇W )| K j . M i M j P i P j K i K j P j P i W ij W ji n 1 ij n 2 ij n ij
K i K j P i P j M i M j
(∇W ) i • P i P j = (1 -β)(∇W ) C ij • P i P j + β(∇W ) U ij • P i P j , (∇W ) j • P j P i = (1 -β)(∇W ) C ij • P j P i + β(∇W ) D ij • P j P i , where β ∈ [0, 1].
With β = 0 we get a centered scheme, with β = 1 we get an upwind scheme. The highest accuracy is reached for β = 1/3 [Koren 1993, Debiez and[START_REF] Debiez | [END_REF], as it is shown that such scheme is third-order accurate for 2D linear advection on structured grids. On unstructured grids, a fourth-order numerical dissipation is obtained and in this case we get the so-called V4-scheme,

(∇W ) V 4 i • P i P j = 2 3 (∇W ) C ij • P i P j + 1 3 (∇W ) U ij • P i P j , (∇W ) V 4 j • P j P i = 2 3 (∇W ) C ij • P j P i + 1 3 (∇W ) D ij • P j P i ,
In [START_REF] Debiez | [END_REF] a sixth order scheme is proposed, and uses additional gradient values obtained in the stencils shown in Figures 1.3 and 1.4. In particular, the authors define the gradient of W gathered at the intersection points M i and M j between the line defined by P i P j , and the opposite faces to i and j, respectively, of the upwind and downwind tetrahedra, indicated by (∇W ) M i ij and (∇W )

M j ij
, and the gradient defined on a point P i as the weighted average of the P 0 gradients on the elements sharing i,

(∇W ) P i ij = 1 (d + 1)|C i | K∈C i |K|(∇W )| K ,
where d = 2, 3 is the dimension of the problem. Hence,

(∇W ) V 6 i • P i P j = (∇W ) V 4 i - 1 30 ((∇W ) U ij -2(∇W ) C ij + (∇W ) D ij ) - 2 15 ((∇W ) M i ij -2(∇W ) P i ij + (∇W ) P j ij ) • P i P j , (∇W ) V 6 j • P j P i . = (∇W ) V 4 j - 1 30 ((∇W ) D ij -2(∇W ) C ij + (∇W ) U ij ) - 2 15 ((∇W ) M j ij -2(∇W ) P j ij + (∇W ) P i ij ) • P j P i .
The V4 and the V6 coefficients are obtained with a Taylor expansion of the values of W , and then by deleting the coefficients of the lower order terms. This is pursued on uniform grids, and the analogy with finite difference is strong. The V4 scheme works quite well also on unstructured grids, and we use it for all the benchmarks of the present work. Anyway, the V6 seems not to be so beneficial, as the gap between the structured grid and the ustructured ones seems to be too wide. A possible approach to overcome this issue could be to enrich the expression of the V6 scheme by using geometric quantities [START_REF] Berger | [END_REF]], but this is beyond the scope of this work.

Slope limiters

The MUSCL schemes are not monotone and can produce spurious oscillations in space, specially in regions characterized by high gradients. Such oscillations could affect the residual convergence or provide unphysical values in the solution field, specially when looking for steady-state solutions [Venkatakrishnan 1993, Venkatakrishnan 1995]. A solution to this problem is to impose the total variation diminishing (TVD) property of the proposed schemes [Harten et al. 1983], ensuring that W ij and W ji are not incorrect. Consider a

With limiter

Without limiter

Figure 1.5 -Two simulations made on a RAE2822 airfoil in transonic conditions showing ρE in the region of the shock wave. On the left the simulation is run with a slope limiter, on the right without.

purely convective problem like (1.14), and a solution at the time step n, W n . Its total variation is defined as

T V (W n ) = i |W n i+1 -W n i |.
With the TVD property, we require that T V (W n+1 ) ≤ T V (W n ). Such property can be ensured by substituting the gradients involved in the MUSCL extrapolation with suitably limited ones (∇W ) lim ij , and the choice of such limiter affects the overall simulation. For instance, Figure 1.5 shows a RAE2822 airfoil simulation in transonic conditions, run with and without limiter function. Without limiting the slope, a spurious oscillation emerges on the shock wave. In general, a limiter function acts by introducing some dissipation inside the MUSCL scheme. For this reason, different kinds of limiter exist, each defining a certain amount of dissipation introduced. With Wolf the user can choose different kinds of limiters. We show here some, ordering them by decreasing dissipation,

• MinMod limiter: this is the simplest kind of limiter, and reads as

(∇W ) lim i =    min (|(∇W ) C ij |, |(∇W ) U ij |) if (∇W ) C ij (∇W ) U ij > 0, 0 otherwise, (∇W ) lim j =    min (|(∇W ) C ij |, |(∇W ) D ij |) if (∇W ) C ij (∇W ) D ij > 0, 0 otherwise.
Such limiter cannot be used with V4 or V6 schemes.

• Van-Albada limiter:

(∇W ) lim i =      (∇W ) C ij 2 (∇W ) U ij +(∇W ) U ij 2 (∇W ) C ij (∇W ) C ij 2 +(∇W ) U ij 2 if (∇W ) C ij (∇W ) U ij ) > 0, 0 otherwise, (∇W ) lim j =      (∇W ) C ij 2 (∇W ) D ij +(∇W ) D ij 2 (∇W ) C ij (∇W ) C ij 2 +(∇W ) D ij 2 if (∇W ) C ij (∇W ) D ij > 0, 0 otherwise.
Such limiter cannot be used with V4 or V6 schemes. • Piperno limiter [START_REF] Piperno | [END_REF]]: this is expressed with the form

(∇W ) lim = (∇W ) HO φ(R), R = (∇W ) U (∇W ) C ,
where

φ(R) =    1 + 3 2 R + 1 (R -1) 3 if R < 1, 3R 2 -6R+19 R 3 -3R+18 , otherwise,
where (∇W ) HO is any high-order gradient like the V4 or the V6. • Gamma limiter (Gamma(Γ)): this is a generalization of the Piperno Limiter, and introduces a parameter γ to control the dissipation, and it is indicated by

(∇W ) lim = (∇W ) HO φ γ (R), φ γ (R) = φ γ (R, R), R(R) = R 1 -(γ -1)R φ γ (R, R) =            1 + 3 2 R + 1 ( R -1) 3 if γR < 1, 1 if R < γ, 3R 2 -6R+19 (R-γ) 3 +3R 2 -6R+19 , otherwise
Here, the higher order region of the Piperno limiter (i.e., where φ = 1) is expanded on an interval length of γ. With γ = 1 we recover the Piperno limiter, and by increasing γ we reduce the total dissipation. In general, limiters like Piperno and Gamma are dependent on a function φ which, in turn, depends on the ratio between higher order and lower order gradients. The employment of such limiters is effective in regions where the value difference between higher order and lower order gradient is maintained through the entire simulation, for instance on shock waves and boundary layer. Some issues could arise when (∇W ) U (∇W ) C 0, for instance in the far field regions. Here, the limiter function φ is continuously activated and deactivated as the ratio R could rise up and suddenly decrease to zero, even between two consecutive time iterations, and this process slows down the convergence. For instance, Figure 1.6 is showing a smooth field over a NACA0012 airfoil. In principle, no limiter is needed here as W is suitably smooth. But, if we compute the ratio R we see that it could indicate high gradients in region even extremely far from the airfoil, even in the far-field upstream regions. The value of R is shown in Figure 1.7 for different zooms. For this reason one can possibly introduce a parameter , and check for the magnitude of the input gradients. If such magnitude is lower than , then the highest order gradient is applied, otherwise the limiter is applied. This can be done, for instance, by looking at the average of the upwind and downwind gradients and the reference solution, (1.16) but this introduces the new parameter , which could be case-specific, and hence, difficult to tune.

φ (R) =    φ(R) if 1 2 ((∇W ) U + (∇W ) D ) ≥ max(W R , W L ), 1 otherwise,

Viscous fluxes

In this section, we show the discretization of the viscous fluxes, which in Wolf is pursued through finite element method. We have

S i = C i ∇ • S(W )dΩ = P j ∈N (i) ∂C ij S(W ) • ndγ + BT,
(1.17)

where BT indicates the boundary contributions. To describe the computation of the viscous numerical fluxes, we indicate as ψ i the P 1 finite element basis function associated with the vertex i. For an element K sharing the vertex i, we have that

K ∇ψ i dΩ = - ∂C i ∩K ndγ,
and since S depends only on the gradient of W , it is constant on each element K. Thus, if we consider for example the computation of T xy on an element K, we have

T xy = P i ∈K µ| K u i ∂ψ i ∂y + v j ∂ψ i ∂x ,
where µ| K is the mean value of µ on the element. Then,

P j ∈N (i) ∂C ij S(W ) • ndγ = K P i S(W )| K • ∂C i ∩K ndγ = - K P i K S(W )| K • ∇ψ i dΩ.
(1.18)

The computation of (1.18) involves integral expressions of the type

K ∇ψ i • ∇ψ j dΩ = |K|∇ψ i | K • ∇ψ j | K .
For this reason, in order to compute the viscous fluxes, we employ a loop cycle over the elements K of the mesh, and then a local nested loop over the vertices of the considered element K. The discretization of the Spalart-Allmaras dissipation term is as well treated with the finite element formulation, that is

Φ dissip i = |K| 1 σ ρ i ((ν| K + ν| K )∇ν| K • ∇ψ i | K ) ,
where ν| K and ν| K are the mean value of ν and ν, respectively, on the element K. The diffusion term is treated like a source term, and its discretization is describd in the next Section 1.2.3. To sum up, we have that the numerical viscous flux contribution to a vertex i on an element K, with P i ∈ K, depends on all the degrees of freedom of W on the element K. In 3D we have that

∂C i ∩K S| K • n i dγ = Φ visc i,K (W i , W j , W k , W l ).

Source terms

The discretization of the diffusion and the source terms of the Spalart-Allmaras equation is rather simple. For the diffusion we have

Φ dif f us i (W i ) = C i c b2 ρ σ ||∇ν|| 2 dΩ |C i | c b2 ρ σ ||∇ν i || 2 ,
where ∇ν i is the nodal gradient obtained with the L2 projection, that is

∇ν i = 1 (d + 1)|C i | K i |K|∇ν| K , (1.19)
where d is the dimension of the considered case. Eventually, the source terms are discretized with

Φ sources i = |C i |Q(W i ).

Boundary conditions

In Wolf the boundary conditions are imposed at each boundary edge/faces, providing an additional flux to be summed up to each involved vertex.

Non-slip boundary condition

For non-slip conditions, we have u = 0, ν = 0 and Φ ρ = 0. Concerning energy, the user can choose between adiabatic condition (null temperature flux) or an isothermal one (enforced temperature). For instance, for an adiabatic wall we have Φ N onSlip = (0, 0, 0, 0, 0, 0) T .

Slip boundary condition

The slip boundary condition is characterized by

u • n = 0.
Its contribution is computed through the flux between the value of W on the boundary and the value of a mirror state W

Φ Slip = Φ HLLC (W, W , n), where W =     ρ ρu ρE     , and W =     ρ ρu -2ρ(u • n)n ρE     . If u • n = 0 then W = W , and hence Φ HLLC (W, W , n) = F (W ) • n. Furthermore, Φ Slip = F (W ) • n = (0, pn, 0) T .
The state W on the boundary does not satisfy this condition unless it is imposed strongly, but this violates the mass conservation. This problem is solved by computing the flux between the state and its mirror state.

Inlet

Inlets are used to prescribe inflow boundary conditions. To this aim, we rely on Riemann invariants across the boundary surface to compute a consistent external state

W ext = (ρ ext , u ext , p ext ).
In supersonic flows, it is possible to prescribe a given state. This cannot be done in the case of subsonic flows, as information can still travel upwind. In such a case the negative Riemann invariant is used to compute the external state. The normal velocity is The outgoing characteristic

η = u • n,
R -= η - 2c γ -1 ,
and the ingoing enthalpy

H tot = γ γ -1
RT tot must be conserved. The quantities on the boundaries are related to the external state as

H tot = c ext γ -1 + u 2 ext 2 , and R -= u ext - 2c ext γ -1 ,
which forms a system of two equations in the unknowns c ext and u ext . We get the value of the second variable, which provides a quadratic equation in c ext : the correct solution is the biggest positive one, and then u ext is deduced. The external pressure and temperature are computed as

p ext = P tot 1 + γ -1 2 u 2 ext c 2 ext , T ext = T tot p ext P tot γ-1 γ
, and hence the external state reads

W ext = p ext RT ext , u ext n, p ext T .

Outlet

For outlets, we still rely on Riemann invariants as for the inlets. We describe the subsonic case only. The downstream invariant reads as

R + = 2c γ -1 + u • n, (1.20)
and the entropy

s = p ρ γ ,
which are computed from the inside of the domain and are assumed constant on the frontier. We deduce

ρ ext = p ext s 1 γ , c ext = γ ext ρ ext ,
and the Riemann invariant

u ext = R + - 2c ext γ -1 .
The tangential velocity is assumed to be constant across the boundary, and hence the external state is given by

W ext = (ρ ext , u ext n + u t , p ext ) T ,
where

u t = u -(u • n)n.

Farfield conditions

The farfield conditions are imposed on boundary Γ ∞ for which we know the state W ∞ = (ρ ∞ , ρu ∞ , ρE ∞ ), and such state is considered uniform. Here, we compute the numerical flux between the state at infinity W ∞ and the inner state W with an HLLC approximate Riemann solver.

Spalart-Allmaras boundary conditions

Concerning the boundary conditions imposed to the fluxes of the ν variable, we can distinguish two kinds of boundaries. On non-slip surfaces, as we said, the value of ν is set to zero, and hence the resulting flux too. For freestream conditions, we impose an external value of ν∞ = 3ν ∞ . Furthermore, it is common to use the so-called wall functions to impose suitable values to the velocity and to the first cell layer lying on non-slip surface. Anyway, in this work the wall treatment is neglected, as it is shown in Chapter 5, we assume that mesh adaptation is able to overcome this issue automatically, and to provide enough refinement to have the first cell layer inside the viscous sublayer. Hence, on non-slip boundaries, we simply keep u = 0 and ν = 0.

Time discretization

After space discretization, we end up with a system of nonlinear ODEs. Concerning the discretization of the time derivative, we rely on the one-step implicit Euler scheme BDF(1), which provides the following expression

|C i | δt n i δW i = -F n+1 i + S n+1 i + Q n+1 i + Γ n+1 i , (1.21)
where δW i = W n+1 i -W n i is the solution increment, F are the numerical convective fluxes, S are the numerical viscous fluxes, Q are the discretized sources and Γ the numerical fluxes associated to the boundary contributions. By linearizing the right-hand-side of (1.21), we end up with

|C| δt n 1 - ∂R n h ∂W n δW n = R n h (W n ), R n h = R h (W n ) (1.22)
where ∂R h ∂W n is the Jacobian of the numerical fluxes with respect to the degrees of freedom of the numerical solution W . The way the fluxes are defined, influences the sparsity pattern of such Jacobian. Consider for instance the entry [ ∂R h

∂W n ] ij , which is a 5-by-5 block in 2D and a 6-by-6 block in 3D. This represents the derivative of the fluxes contributing to vertex i with respect to the solution values of the vertex in j. It is clear that the sparsity of such Jacobian depends on the stencil used to compute the fluxes at the vertex i. For each type of flux, we clarify its stencil.

• Convective fluxes: when applying 2 nd order schemes, we have that the value of the flux in a vertex i depends on the vertex i itself, on the surrounding points (V1-ball), and on the V2-ball (the surrounding points to the surrounding points, see Figure 1.8), as these values are used to enrich the slope used for the Riemann solver. In the computation of the Jacobian, the entries [ ∂R h

∂W n ] ij with j ∈ V 2(i) are omitted in order to reduce the memory burden. One possibility to overcome this simplification could be to rely on a matrix-free approach, or to compute such terms on the fly, but in any case this represents an increase in the algorithmic complexity. With an abuse of notation, we still indicate the Jacobian of the residual R h with [ ∂R h ∂W n ], even if it neglects the constributions coming from the V2-balls.

• Viscous fluxes: the viscous contribution to the vertex i only depends on the values of the solution on the elements K sharing i. For this reason the V1-ball of vertices of i is sufficient to compute an exact differentiation. • Sources: the sources and the diffusion of the Spalart-Allmaras equation at the vertex i only depend on the values of W on the vertex i itself, and hence these terms only provide a diagonal contribution to the Jacobian. • Boundary conditions: given a boundary vertex i, the boundary contributes to the diagonal entries only. The only special case concerns the enforced boundary conditions like the Dirichlet ones. Here, the velocity and the turbulent viscosity are set to zero, and they must not vary. For this reason the corresponding rows of the Jacobian are set to zero, with the exception of the diagonal entry, which is set to 1. This is schematized below

         * * * * * * * * * * * * * * * ... ... 0 1 0 * * * * *                   * * * δW u i *          =          * * * 0 *         
.

In this way δW n,u i = 0 for all n. To sum up, we can write explicitly system (1.22) as

|C i | δt n i 1 d+3 + ∂F n i ∂W i - ∂S n i ∂W i - ∂Q n i ∂W i - ∂Γ n i ∂W i δW n i + P j ∈V 1(i) |C i | δt n i 1 d+3 + ∂F n i ∂W j - ∂S n i ∂W j - ∂Q n i ∂W j - ∂Γ n i ∂W j δW n j = -F n i + S n i + Q n i + Γ n i
(1.23) where 1 d+3 is the identity matrix of dimension d + 3, with d the domain dimension. From equation (1.23) we deduce that the adjacency graph of the Jacobian ∂R h /∂W h can be identified with the mesh H itself.

Linear system resolution

In this section, we describe the data structures and the algorithms to solve the linear system (1.22). During the main part of development of this work, Wolf relied on an edge-based representation of the Jacobian. More precisely, we divide the Jacobian matrix ∂R h /∂W h in the diagonal part, the upper part and the lower part, which are represented in Wolf through three working arrays. Taking advantage of the V1-ball stencils characterizing the adjacency graph of the Jacobian as in (1.23), we associate with each vertex i a diagonal entry block D i = [∂R h /∂W h ] ii , and with each edge e = {i, j} (assuming, without loss of generality, i < j) a couple made of an upper block U e = [∂R h /∂W h ] ij and a lower block L e = [∂R h /∂W h ] ji . With this association it is possible to navigate the matrix through the mesh entities. Furthermore, the mesh vertices are renumbered in Wolf by using either the Hilbert renumbering [START_REF] Loseille | [END_REF] or the BFS algorithm: in this way geometrically near vertices and edges are also near in memory chunks, and this allows to reduce the cache misses when navigating vectors and edge-based matrices like the Jacobian. This speeds up the algebraic computations like scalar products, vector-vector products, matrix-vector producs, as well as the matrix assembling.

In the sequel we indicate the linear system (1.22) in the synthetic form

A n δW n = R n , (1.24)
where A n , δW n and R n are defined as in (1.22).

LU-SGS relaxation

Linear system (1.24) is solved by using the Symmetric Gauss-Seidel (SGS) approach developed in [Jameson and Yoon 1987]. The main advantage of this approach is that it is based on the edge-based representation shown before, and can be easily parallelized with a multithreading paradigma [Sharov et al. 2000, Alauzet andLoseille 2009]. Here, linear system (1.24) is rewritten as

(D + L)D -1 (D + U)δW n = R n + (LD -1 U)δW n ,
and the approximate system is used instead:

(D + L)D -1 (D + U)δW n = R n .

Symmetric Gauss-Seidel (SGS) relaxation

The SGS relaxation [START_REF] Sharov | [END_REF], Luo et al. 1998, Luo et al. 2001] employs a fixed-point approach to solve (1.24). Here, we create a sequence {δW n,k } k such that A n {δW n,k } k → R n . Since (L + D + U)δW n = R n cannot be solved directly, the idea is to keep fixed a part of the system, so that the remaining part can be solved with a backward or a forward substitution sweep

(D + L)δW n,k+1 + UδW n,k fixed = R n .
By studying the convergence of such method, we get

(D + L)δW n,k+1 + UδW n,k = (L + D + U)δW n , (D + L)(δW n,k+1 -δW n ) = -U(δW n,k -δW n ), (δW n,k+1 -δW n ) = -(D + L) -1 U(δW n,k -δW n ).
(1.25) From (1.25) we understand that the convergence of the SGS method is directly related to the biggest eigenvalue of (D+L) -1 U. In particular, if (D+L) contains more contributions than U, we have that (D + L) -1 U provides a small gap δW n,k+1 -δW n . This means that treating system (1.24) as a block improves the convergence, as well as the addition of mass coming from the time step discretization. The SGS steps start by setting the initial solution to zero, and then k max iterations are made using forward and backward sweeps on

(D + L)δW n,k+ 1 2 = R n -UδW n,k , (D + U)δW n,k+1 = R n -LδW n,k+ 1 2 .
Usually, we employ the SGS solver to solve system (1.24), by setting k max up to 40. We found out that reducing the initial residual by 0.01 sufficies to get a satisfactory convergence.

For further available linear solvers that can be employed for the resolution of (1.24), see Section 3.3.

Solver robustness

In this section we decribe the methodologies used to improve and increase the robustness of the RANS flow solver described so far in order to reach a steady state solution [Pandya et al. 2016]. In particular, we first describe the indicators used to monitor the overall convergence, then, we describe the methodologies which, depending on the indicators used, modify the parameters of the flow solver. This section represents an advancement of the work pursued in [Clerici et al. 2021].

Since we are dealing with a pseudo-transient flow solver employing an implicit method, we deal with two kinds of residuals, which theoretically should be reduced up to zero. These are

• the residual associated with the resolution of the RANS system, that is, the Newton residual ||R h (W h )||, and • the residual associated with the resolution of the linear system, that is, the linear system residual ||R n -A n δW n ||. In both cases, we are interested to reduce the relative residual, that is, the ratio between the residual at time step/iteration n and the residual in the first time step/iteration 0. This allows to have a better control over the convergence, as it avoids to reduce it by too much or too few orders of magnitudes. This is always employed in the linear solver, while it can be activated for the Newton one. Concerning the Newton local residual [R h (W h )] i , we are given a distribution, for which we can compute several statistics. This is helpful as very often we observed that the convergence of the global residual is affected by the presence of few vertices having a high residual. For this reason we also introduce the socalled log-residual, which, instead of taking a mean on the values of [R h (W h )] i , it takes a mean over their exponent. This is defined as

LogRes = exp 1 N V N V i=1 log([R h (W h )] i ) .
Another indicator which is used to evaluate the solver convergence is the number of oscillations of the solution W n i through the time resolution. In fact, we observed that regions characterized by a high residual are usually correlated with a continuous activation and deactivation of the slope limiter. This, in turn, provides an oscillating trend in the solution, and leads to limit cycles [START_REF] Krakos | [END_REF]. This is linked to the number of times the increment δW n i passes through 0. For instance, Figure 1.9 is showing the residual of the continuity equation associated to the resolution of a transonic Euler flow over a NACA0012 airfoil, and the number of oscillations of the limiter function φ(R) (in this case, a Gamma limiter with γ = 2). The number of oscillations has been computed by considering the variations of φ from 0 to higher values (i.e., the number of limiter deactivations), in practice by counting the number of times φ directly jumps from values smaller than 10 -5 to values bigger than 10 -2 , and viceversa. Note that the vast majority of the oscillations are located on the shock and below the airfoil, following the residual field.

The local mechanism that sustains such oscillations in a vertex i relies on a continuous compensation of the fluxes coming from the neighboring vertices. To illustrate this, we show in Figure 1.10 the plot of the local sum of the ρ fluxes relative to a RANS simulation made on a M3V4 multi element airfoil, specifically on the vertex having the biggest residual at the end of the simulation (vertex 76) and its surrounding points. We see that after a certain number of iterations, the sum of the fluxes at vertex 76 starts to oscillate between two consecutive iterations, and this mechanism is sustained by the fluxes coming from its V1-ball.

CFL laws

A simple way to control the convergence of the Newton and of the linear system is the CF L number. The CF L number is allocated locally for each vertex and allows to compute the local time step with

δt i = CF L i h 2 h(c + ||u||) + 2 λ+λt 2 ,
where h is the local cell size. For low CF L the convergence of the nonlinear solver is slower as the time step decreases, but this results in an increase in the mass matrix contribution of the linear system (1.22) and, hence, requires less SGS iterations to converge. The CF L field is usually increased at each time step with a geometric law, meaning that

CF L n+1 i = αCF L n i = α n+1 CF L 0 i , α > 1,
where α is a parameter controlling the CF L growth and CF L 0 i is the initial CF L number, that can be set to low values (usually not greater than 1) or can be interpolated from a previous CF L field, for instance, in mesh convergence studies, where CF L 0 is obtained by interpolating CF L n from a lower complexity mesh to a higher complexity one. The CF L number can be controlled locally or globally, depending on the solution and on the solver behavior. For example, with Wolf it is possible to reduce locally the CF L i on a point i whenever this shows unphysical values in ρ or in p. In such cases, CF L i is reduced by being divided by a factor α 4 . Another possibility to control the CF L i locally is to look at the number of oscillations of the solution W i . In particular, we check whether or not the increment δW n i steps through zero, and, if this is the case, CF L i is reduced, again, by a factor α 4 .

One can use the linear system or the Newton convergence to reduce the CF L globally. In Wolf we can set, for the linear system and the nonlinear solvers, two parameters τ and β, and check, for a given residual Res

||Res n+1 || < τ ||Res n ||, (1.26)
that is, we check whether or not the linear system or the Newton residual has been reduced by a factor τ . Here, τ is usually set to a value stricly lower than 1 for the linear solver, while it can be also set to higher value in the case of the Newton check, in order to allow a solution escape from a basin of attraction of a wrong solution. Whenever (1.26) is not satisfied, the CF L is globally reduced by β with CF L n+1 = (1/β)CF L n .

Limiter freezing

Limit cycles and flow instabilities can be reduced by using a high CF L value, getting near to a pure Newton nonlinear solver. This, anyway, reduces the robustness of the solver, by introducing instabilities in the limiters, specially in the far-field regions where, as said, ∇W ∼ 0. This problem can be limited by freezing the gradients involved in the MUSCL extrapolation, i.e., for each time step n we select the minimum gradient computed through the simulation up to n. From one side, this damps the aforementioned limit cycles, but, at the same time, it increases the dissipation of the numerical scheme. The limiter freezing can be triggered in different ways. It can be set automatically after a certain number of user-defined iterations, or can be set when the Newton residual stagnates. The stagnation check, anyway, can be misleading, as the stagnation could be due to few vertices characterized by a high local residual, and hence another possibility is to look at LogRes. As limit cycles produce oscillations in the solution, this usually produces a stagnation in the aerocoefficients computation, and hence, the limiter can be freezed by looking at the convergence of the aerodynamic coefficients. Eventually, the limiter can be freezed locally by looking an the oscillations of the solution increment δW n i .

Shock detection

Instead of freezing the limiter globally, we can apply the limiter only on those locations actually needing a slope limiter. A similar technique can be found in [Dass and Kalita 2018], where the limiter is deactivated in boundary layers and kept active in the rest of the domain. Our approach is to apply the limiter on shock waves only. To do that, we need to mark the involved vertices with an indicator function. We pursue this goal by using a numerical argument: on shock waves, there is a systematic gap between the gradient of the involved variables and a space-averaged, smoother, one. Following this idea we consider the density ρ i and we define

∇ρ i = j∈N (i) ω j ||∇ρ j || j∈N (i) ω j , ω j = ∇ρ j • P i P j , η V,i = ∇ρ i -||∇ρ i ||, η = N V i=1 |C i |η V,i N V i=1 |C i | ,
i.e., ∇ρ i denotes the averaged gradient of ρ, η V,i the gap between the averaged gradient and the local gradient at vertex i, and η is used as a reference value to define the shock indicator S i

S i =    1 if η V,i ≥ αη, 0 otherwise,
where α is usually set to 0.05. The limiter is hence applied on those edges having at least one of its endpoints on a shock wave. In Figure 1.11 we show the convergence history of a RAE2822 airfoil in transonic conditions by • applying no dissipation increase strategy (limiter only),

• applying a global limiter freezing from the beginning,

• applying the limiter freezing only on vertices having an oscillating increment and • applying the limiter only on the shock wave. We see that for this specific case the use of a plain limiter produces oscillations in the residual convergence. By applying a global freezing from the beginning, the convergence is more regular, but still slow. By applying the limiter freezing only on vertices having an oscillation in their increment speeds up the computation, but the fastest residual convergenced is reached when applying the limiter only on shock locations. Anyway, in general, we experienced that it is not possible to design a general strategy to control the robustness of the nonlinear and of the linear solvers. Each methodology is case-specific, and the parameters should be tuned accordingly. To this aim, we have applied such methodologies to the 7 th AIAA CFD Drag prediction Workshop common research model (DPW7), which is a 3D geometry to be run under transonic conditions. We have concluded a preliminary test on a computational adapted mesh with 504 813 vertices, which is shown in Figure 1.12 together with the local Mach number. We have run four different simulations by

• applying no dissipation increase strategy (limiter only),

• applying a global limiter freezing from iteration 1400,

• applying the limiter only on the shock waves and • applying the freezing only on vertices located on shock waves, from iteration 1000. The convergence history of the continuity equation residual is shown in Figure 1.13. We can see that, unlikley to the RAE2822 case shown before, the application of the limiter on shock location does not bring any improvement. The best strategy for the DPW7 case is to apply the gradient freezing on vertices which are lying on the shock wave, instead. We conclude this section by showing a mesh convergence study for the DPW7 benchmark. Such mesh convergence study is pursued by defining a set of increasing mesh complexities, and by performing two nested loops: one iterates at fixed complexity, and the computational mesh is adapted after each RANS resolution (different meshes provide different solutions) until the aerodynamic coefficients stabilizes, and the outer loop increases the mesh complexity. For more detail about this algorithm see Algorithm 6 in Section 5.5.1. The set of mesh complexities is {64000, 128000, 256000, 512000, 1024000} and the plot of the lift coefficient C L is shown in Figure 1.14 for two runs, one made by applying a Gamma(2) limiter globally, while the other by applying the limiter on shock locations only. We can see in this plot many small jumps which are due to the mesh modifications at fixed complexity, and 4 bigger jumps due to the mesh complexity increase. By applying the limiter on shock waves locations only, we are able to slightly anticipate the C L convergence, which, at the end, takes the same value for both the approaches (meaning that the targeted solution is the same).

We close this section by providing the main ingredients characterizing the Wolf RANS flow solver robustness so far, which are arranged in two columns in Table 1.1 case by case, and one should reach a good balance between robustness and solution precision in order to get the optimal simulation run.

Mesh optimization

The properties of the Jacobian ∂R h /∂W h strongly depends on the solution and on the vertex locations/connectivity. In [Zangeneh and Ollivier-Gooch 2017] it is shown a methodology which allows to move the vertices of a mesh in order to optimize the eigenvalues of the Jacobian ∂R h /∂W h . Here, the authors are able to dramatically improve the convergence of the flow solver. Anyway, this method requires the computation of the eigenvalues of the system matrix, which, for highly complex cases, could be infeasible. Following this idea, our aim is to maximize the diagonal dominance of the Jacobian ∂R h /∂W h with respect to the vertices locations. The diagonal dominance of a block matrix in a vertex P i is defined as

D i = ||A n-1 ii || -1 - j∈N (i) ||A ij ||, (1.27)
with ||B|| = max(λ(B)). Particularly for fine meshes, even such problem has a high complexity, as, for 3D cases, it consists in a constrained optimization of 3N V variables, with N V the number of vertices of the mesh. Hence, we simplify such problem by relying on experimental observations. To this aim, we consider a RAE2822 airfoil under transonic conditions, and we run a simulation on an adapted mesh having 38 566 vertices. The computational mesh and the local Mach number are shown in Figure 1.15. By running a simulation using the Gamma(2) limiter, we see that at the end of the simulation we reach a stagnation point. This is underlined by the continuity equation residual, shown in Figure 1.16. By looking at the local residual field, we notice that the main contribution to the global residual is due to a single vertex (vertex 2104), which is located in the wake of the airfoil. We have that the sum of the fluxes at such vertex location has an oscillating trend, as shown previously in Figure 1.10 for the M3V4 airfoil. Figure 1.17 -Transonic RAE2822, α = 2.31, M a = 0.729, Re = 6.5e6. Difference of the diagonal dominance before and after the application of (1.28) to the neighboring vertices of vertex 2104.

Our objective here is to optimize (increase) the diagonal dominance (1.27) relative to the Jacobian row i = 2104 with respect to the vertex coordinates P 2104 , as in this way we expect to break this cycle. A first propotype code relied on NLopt [Johnson 2021] library, but it turned out that the diagonal dominance at vertex i, with the present formulation, can be increased by simply squeezing the surrounding elements to i: ∪ K i K (and, viceversa, can be reduced by expanding the surrounding elements). To this aim, we rely on the following modification to be applied to the neighboring points of i

P new j = (1 -α)P old j + αg i , ∀j ∈ N (i) (1.28)
with α = 0.05 and g i being the barycenter of ∪ K i K. By applying such transformation to the neighboring points of the vertex 2104, and letting the simulation to continue, we get that the diagonal dominance on point 2104 increases. This is shown in Figure 1.17, which shows the difference between the values of D 2104 with and without applying transformation (1.28), that is

|D new i -D old i |, with D new i
the diagonal dominance after the modification and the original value of the diagonal dominance. Note that such difference is negative in the upstream and downstream points, i.e., those points that underwent the strongest cell expansion. By applying the transformation (1.28) to vertex 2104 after 500 iterations, we get that the limit cycle shown in Figure 1.15 is broken, and the global convergence benefits by this modification. This is shown locally for vertex 2104 in Figure 1.18, and globally in Figure 1.19. We can see that after the application of (1.28) to the vertex 2104, the global residual undergoes a steep increase, due to the sudden mesh modification, and then stabilizes on a lower value. Once the limit cycle at point 2104 is broken, one can for instance keep on optimizing locally the mesh after a certain number of iterations. In particular, Figure 1.20 shows the global continuity residual obtained by applying repeatedly transformation (1.28) to the vertex with highest residual each 50 time iterations. In this way, we see that it is possible to obtain a residual decrease of one order of magnitude by applying 11 local operations on the computational mesh. We close this section by showing the local mesh optimization algorithm applied to the HLCRM2D and a NACA0012 airfoils in Figure 1.21. For the HLCRM2D benchmark, 5 local optimizations have been applied, while for the NACA0012 only one. In both cases we see that the global residual convergence benefits from this treatment. The methodology shown in this section is still experimental, but it is showing encouraging results. We have shown that by applying a small perturbation to the neighboring vertices of a vertex having a residual limit cycle is able to break this condition, and this has an impact on the global convergence too. We underline that mesh operation (1.28) has a negligible complexity and it is non-invasive with respect to the mesh. In particular, we applied the squeezing of the surrounding elements of a vertex, as we noticed that this improves the diagonal dominance of the matrix in that specific vertex, but in few cases we found out that by simply randomly moving a problematic vertex turned out to be beneficial. Hence, we cannot conclude that the breaking of limit cycles is only due to the diagonal dominance increase pursued by mesh modification. In addition to that, we have shown that the improvement of D on a vertex i generally worsten the diagonal dominance on the surrounding vertices. Hence, a possible strategy to overcome this issue could be to study more rigorous optimization technique by acting globally on the diagonal dominance of the Jacobian. In fact, even if the breaking of the limit cycles is not really due to the diagonal dominance increase, its increase is still beneficial as we can allow the CF L growth without affecting the SGS solver convergence, and hence to speed up the nonlinear convergence. For instance, when applying operation (1.28) to the vertex 2104 of the RAE2822 airfoil, we obtain the CF L values at the end of the computation shown in Table 1.

Global CF L min 1.6443e3 1.9035e3 Global CF L max 1.6443e3 2.4295e3 CF L 2104 1.6443e3 2.42945e3
As we can see in Table 1.2, if we do not apply any modification we get a uniform CF L field of 1.6443e3. By applying the vertices modification, this is increased up to a minimum of 1.9035e3, and the involved vertex 2104 get the maximum value of 2.42945e3.

Conclusions

In this chapter we have described the RANS flow solver Wolf. Such solver, written in C, is devoted to the resolution of the Navier-Stokes equations together with the Spalart-Allmaras turbulence model, and its aim is to reduce the residual associated with the Navier-Stokes -Spalart-Allmaras equation up to machine zero. We have described the spacial discretization, which is obtained by discretizing the computational domain by means of triangles in 2D or tetrahedra in 3D, assuming the solution to be stored at the cell vertices, and by applying a finite volume discretization to the convective fluxes and the source terms, and the finite element method to the viscous fluxes. We opened a parenthesis concerning TVD schemes for the finite volume part, and how slope limiters can be effective to reduce the spurious oscillations typical of higher order schemes, and their drawbacks, such as the presence of regions characterized by a continuous activation and deactivation of the slope limiter, leading to a difficult or even an absent residual convergence. We have described the time discretization, pursued by an implicit Euler scheme, and how this leads to the resolution of a linear system, to be solved at each time step. Here, the adjacency graph of the Jacobian of the residual corresponds to the computational mesh itself, and this helps in the construction of efficient, cache-friendly and memory-contained class of algorithms, namely, the LU+SGS and the SGS. Eventually, we described several methodologies to improve the convergence of the flow residuals and of the linear system residual by means of slope limiter and CF L tuning, based on several statistics like the global residual, the relative residual, the logarithmic residual convergence, and the oscillation of the solution increment through the time step and the shock detection. We have also shown how by means of simple, local, mesh modifications it is possible to break limit cycles occuring on vertices without affecting the numerical scheme. In most of the cases, the flow solver presented so far is able to solve the Navier-Stokes -Spalart-Allmaras equations with a satisfactory degree of precision even on highly anisotropic mesh over complex geometries. Concerning possible further developments, we divide these into three groups, namely

• further developments of slope limiter and CF L tuning strategies, based on different metrics, such as the so-called nonlinear residual; • implementation and development of new non-linear solvers to solve the flow equations up to machine zero with faster cpu times, and new linear solvers and preconditioners to solve the linear system even for high CF L field; for instance the class of Schwartz method, showing promising results in the context of CFD [Alcin et al. 2012]; • a rigorous formalism concerning mesh optimization, in order to get a mesh globally maximizing the diagonal dominance of the Jacobian of the residual and, hence, leading to the possibility to increase the CF L.

Chapter 2

Strongly coupled turbulence

Before the pursuit of the present work, Wolf flow solver relied on a weakly coupling between the mean-flow equations and the Spalart-Allmaras turbulence model [START_REF] Alauzet | [END_REF]. In this chapter, we describe and discuss the results relative to the strongly coupled implementation in Wolf. In a weakly coupled solver [Pandya et al. 2016], the Jacobian of the system does not include the derivatives of the mean flow fluxes with respect to ν, nor the derivatives of the fluxes of ν with respect to the mean flow variables. For example, consider a 2D problem: when a weakly coupled solver is employed, there are two separate linear systems to be solved at each time step, one relative to the mean flow equations made by 4-by-4 blocks, and another relative to the Spalart-Allmaras equation, made by scalar blocks. The matrix of such systems can be arranged in a single system and viewed as a strongly coupled turbulence jacobian made by 5-by-5 blocks having the lower row and the rightmost column identically null, with the exception of the lower-right element, that is, ∂R ν /∂ ν. A weakly coupled turbulence jacobian block reads as

          ∂R ρ ∂ρ ∂R ρ ∂ρu ∂R ρ ∂ρv ∂R ρ ∂ρe 0 ∂R ρu ∂ρ ∂R ρu ∂ρu ∂R ρu ∂ρv ∂R ρu ∂ρe 0 ∂R ρv ∂ρ ∂R ρv ∂ρu ∂R ρv ∂ρv ∂R ρv ∂ρe 0 ∂R ρe ∂ρ ∂R ρe ∂ρu ∂R ρe ∂ρv ∂R ρe ∂ρe 0 0 0 0 0 ∂R ν ∂ ν          
, while in contrast to this, a strongly coupled turbulence jacobian block (assuming the Spalart-Allmaras model for turbulence) reads as

          ∂R ρ ∂ρ ∂R ρ ∂ρu ∂R ρ ∂ρv ∂R ρ ∂ρe 0 ∂R ρu ∂ρ ∂R ρu ∂ρu ∂R ρu ∂ρv ∂R ρu ∂ρe ∂R ρu ∂ ν ∂R ρv ∂ρ ∂R ρv ∂ρu ∂R ρv ∂ρv ∂R ρv ∂ρe ∂R ρv ∂ ν ∂R ρe ∂ρ ∂R ρe ∂ρu ∂R ρe ∂ρv ∂R ρe ∂ρe ∂R ρe ∂ ν ∂R ν ∂ρ ∂R ν ∂ρu ∂R ν ∂ρv 0 ∂R ν ∂ ν           .
When dealing with RANS equations, the majority of the researchers flow solvers solve separately the mean-flow equations and the turbulence equations by employing a weakly coupled approach like the one provided by Wolf. Hence, a weakly coupled solver assumes that the mean-flow variable variations have little impact on the turbulence equations, and, on the other hand, that the turbulent variables variations have little impact on the mean flow equations. The validity of such assumption is not completely clear and whether a strongly coupled solver is superior to a weakly coupled one is still an open problem [Langer and Suarez 2022]. For instance, in [Kunz and Lakshminarayana 1992], the results relative to a coupled solver employing the κ -turbulence model and the Runge-Kutta scheme is shown, but this seems not to bring improvements with respect to the convergence of the density and turbulence equations: here, the trends appear to be identical. On the contrary, in [START_REF] Liu | [END_REF] the κ -ω model is employed, and the weak and strong coupling are compared by using a multigrid solver, showing substantial improvements on a turbine cascade flow and on a transonic airfoil flow. In [Lee and Choi 2006], Coakley's q -κ is employed on the RAE2882 airfoil, the Onera M6 and the RAE wing body in both the weakly and strongly coupled turbulence versions, and the latter showed a negligible impact on such geometries. Concerning the Spalart-Allmaras turbulence model, it has been pointed out that the introduction of the terms coming from the Spalart-Allmaras equation could provide non positive definite matrices, which could impact negatively the convergence of the SGS linear solver and the turbulence source terms can increase the stiffness of the system [Swanson andRossow 2011, Wackers andKoren 2007]. We have not experienced these latter drawbacks when using the strongly coupled flow solver of Wolf, where all the Spalart-Allmaras terms have been included. In any case, it is clear that the chosen turbulence model as well as the space-time discretization scheme could play a role on the advantage of using a strongly coupled turbulence instead of a weakly coupled one, and in fact this is what we have experienced by employing the strongly coupled turbulence model within Wolf. The initial solution plays an important role too, for instance it is possible to build a small example with a system made of two nonlinear equations, where, depending on the initial guess, the weakly coupled Jacobian Newton method converges while the strongly coupled Jacobian provides a non-convergent residual. Consider the nonlinear system f (x) = 0, where

f (x) = xy 2 + 3y + x y 2 -1 + sin(x) , (2.1)
having a solution x sol (-1.4156, 1.4099) T , the strongly coupled (exact) Jacobian reads as

Jf s = y 2 + 1 2xy + 3 cos(x) 2y
.

If we consider a weakly coupled Jacobian,

Jf w = y 2 + 1 0 0 2y
, we have that by starting the Newton method from x 0 = (1, 1) T , the convergence of the strongly coupled Jacobian based method is faster than the weakly coupled one, but if we start from x 0 = (10, 10) T , not only the weakly coupled Jacobian is still converging, but the strongly coupled Jacobian is not converging the solution at all (see Figure 2.1). This means that in certain cases removing the coupling terms could even be beneficial for the residual convergence when the starting point is far from the solution. This happens even in small examples like the one of (2.1), which is implementing a pure Newton method and the inner linear system Jf -1 f (x n ) is solved up to machine zero at each iteration. In particular, in this case the main benefit of using a weakly coupled Jacobian is the removal of the non-convex component sin(x) inside f . We underline also that the starting solution x 0 = (10, 10) T is far from the optimum, and this affects as well the resolution.

The main reason why a strongly coupled turbulence solver has been developed, relies in the adjoint problem definition associated with the RANS equations. Since Wolf provides the functionalities to drive the mesh adaptation procedure, it includes also an adjoint solver which is associated with the primal RANS flow problem, as it is needed in the context of goal-oriented mesh adaptation. For solely illustrative and motivational purposes, we anticipate here the expression of the adjoint problem which is deepen in Chapter 3, which reads as

∂R h ∂W h T W n h W * h = ∂J ∂W h W n h ,
where W * h is the adjoint solution, J is a functional depending on W h and the transpose of the Jacobian ∂R h ∂W h T is inherited directly from the primal flow solver. The main problem of using a weakly coupled turbulence for the adjoint problem is that it is not possible to compute non-zero values for the adjoint variable ν * when the functional J depends solely on values on no-slip surfaces, and this is an impacting limitation in the development of mesh adaptation strategies depending on turbulence information. In fact, the adjoint system when using a weakly coupled turbulence jacobian in these cases reads as

          ∂R ρ ∂ρ ∂R ρu ∂ρ ∂R ρv ∂ρ ∂R ρe ∂ρ 0 ∂R ρ ∂ρu ∂R ρu ∂ρu ∂R ρv ∂ρu ∂R ρe ∂ρu 0 ∂R ρ ∂ρv ∂R ρu ∂ρv ∂R ρv ∂ρv ∂R ρe ∂ρv 0 ∂R ρ ∂ρe ∂R ρu ∂ρe ∂R ρv ∂ρe ∂R ρe ∂ρe 0 0 0 0 0 ∂R ν ∂ ν                    ρ * (ρu) * (ρv) * (ρe) * ν *          =           ∂J ∂ρ ∂J ∂ρu ∂J ∂ρv ∂J ∂ρe 0          
, and it is clear that here ν * = 0 identically. Hence, in order to obtain a meaningful value for ν * , we must use a strongly coupled turbulence Jacobian, with a resulting system reading as

          ∂R ρ ∂ρ ∂R ρu ∂ρ ∂R ρv ∂ρ ∂R ρe ∂ρ ∂R ν ∂ρ ∂R ρ ∂ρu ∂R ρu ∂ρu ∂R ρv ∂ρu ∂R ρe ∂ρu ∂R ν ∂ρu ∂R ρ ∂ρv ∂R ρu ∂ρv ∂R ρv ∂ρv ∂R ρe ∂ρv ∂R ν ∂ρv ∂R ρ ∂ρe ∂R ρu ∂ρe ∂R ρv ∂ρe ∂R ρe ∂ρe 0 0 ∂R ρu ∂ ν ∂R ρv ∂ ν ∂R ρe ∂ ν ∂R ν ∂ ν                    ρ * (ρu) * (ρv) * (ρe) * ν *          =           ∂J ∂ρ ∂J ∂ρu ∂J ∂ρv ∂J ∂ρe 0           .
As said, the main objective of the work contained in this chapter is to compute and validate the coupling terms which are needed to compute correctly the adjoint turbulent viscosity ν * by employing the strongly coupled Jacobian in the primal flow solver. Hence, we ideally require that the trends of the residuals provided by the strongly coupled solver converge at least as fast as those provided by the weakly coupled solver: this is done by running simulations on single meshes (i.e., outside an adaptation loop). Furthermore, since we need to target the same solution by using both of the two methods, we also show that the targeted aerodynamic coefficients are the same for both the approaches, by employing these inside a full mesh adaptation loop.

This Chapter is organized as follows: in Section 2.1 we describe in detail the Jacobian coupling terms computation. In 2.2 we apply the methodology to 2D cases and in 2.3 to 3D ones, while in 2.4 we draw the conclusions.

Strongly coupled Jacobian computation

In this section we show the computation and the expressions of the coupling terms that complete the strongly coupled turbulence Jacobian. We show both the 2D and the 3D computations, privileging the 3D version when the 2D one can be deducted straightforwardly.

Derivatives of the ν convective fluxes with respect to the mean flow variables

We compute the derivatives of the convective fluxes of the Spalart-Allmaras equation by considering linear convection fluxes. Considering an edge by its ending points subscripted by i and j, we recall that

Φ ν ij (W i , W j , n ij ) =    ηρ i νi if η > 0 ηρ j νj otherwise (2.2)
where η is the mean velocity

η = 1 2 (u i • n ij + u j • n ij )
and n ij is the normal associated with the edge i -j. We have that, for a fixed index i, without loss of generality,

∂η ∂ρ i = - 1 2ρ i (u i •n ij ), ∂η ∂(ρu) i = 1 2ρ i n ij,x , ∂η ∂(ρv) i = 1 2ρ i n ij,y , ∂η ∂(ρw) i = 1 2ρ i n ij,z , and, ∂η ∂(ρe) i = 0. Hence, ∂Φ ν ij ∂ρ i =    ην i + ∂η ∂ρ i ρ i νi if η > 0 ∂η ∂ρ i ρ j νj otherwise, ∂Φ ν ij ∂(ρu) i =    ∂η ∂(ρu) i ρ i νi if η > 0 ∂η ∂(ρu) i ρ j νj otherwise, ∂Φ ν ij ∂(ρv) i =    ∂η ∂(ρv) i ρ i νi if η > 0 ∂η ∂(ρv) i ρ j νj otherwise. ∂Φ ν ij ∂(ρw) i =    ∂η ∂(ρw) i ρ i νi if η > 0 ∂η ∂(ρw) i ρ j νj otherwise,
and

∂Φ ν ij ∂(ρe) i = 0.
In 2D the expression of the Jacobian of the turbulence convective fluxes can be obtained by simply neglecting the z-velocity w.

Derivatives of the mean flow viscous fluxes with respect to ν

The Jacobian of the mean flow viscous fluxes with respect to ν is straightforward. Since the turbulent stress tensor is linear in the turbulent viscosity µ t , we only need to compute the derivative of µ t with respect to ν in a vertex i as

∂µ t,i ∂ νi = 1 (d + 1)ν i ρ i f v1 1 + 3 c 3 v1 χ 3 + c 3 v1 , (2.3)
where the dimension d = 2, 3, takes into account the contribution due to the vertices of the element K to the average viscosity for 2D and 3D settings, respectively, while f v1 and χ are quantities of the Spalart-Allmaras turbulence model. In addition to (2.3), we also add the derivatives of the viscosity µ k with respect to the mean flow variables, as µ k is computed by using the Sutherland law.

Derivatives of the ν production and destruction terms with respect to the mean flow variables

The computation of the derivatives of the production and destruction terms of the Spalart-Allmaras equations with respect to the mean flow variable requires some effort. The production P and the destruction D in a vertex i read as

P i + D i = ρ i c b1 S νi -ρ i c w1 f w νi d i 2 , (2.4)
where c b1 , S, c w1 , f w are Spalart-Allmaras quantities and d i is the distance from the wall. Since S and f w depend on the vorticity ω i , we can distinguish an outer derivative with respect to ρ, which is straightforward to compute and it results into a diagonal contribution, and another contribution, which is more complex, which depends on the derivatives of the vorticity ω i with respect to ρ, ρu, ρv and ρw. Here, we start by considering the 3D case, and then we describe the 2D one, which is simpler. We consider a tetrahedron of vertices i, j, k, l, but we can take into account only two vertices, say i and j, to provide all the diagonal and extra-diagonal contributions in an edge-based Jacobian. With an abuse of notation we call vorticity the norm of the actual vorticity vector (i.e., the curl of the velocity) and we indicate such norm with ω. The vorticity in a vertex i is computed as

ω i = (∂ y w i -∂ z v i ) 2 + (∂ z u i -∂ x w i ) 2 + (∂ x v i -∂ y u i ) 2 .
We provide the differentiation with respect to the physical quantities only, as the derivative of the quantity ω in any vertex with respect to any conservative variable can be recovered by applying the chain rule:

∂ω i ∂(ρu) j = ∂ω i ∂u j ∂u j ∂(ρu) j = 1 ρ j ∂ω i ∂u j .
(2.5)

The nodal gradients of a quantity V i (either physical or conservative) are computed by using the L2-projection method, hence

∂ xn V i = 1 4|C i | K i   |K| j∈K V j n j,xn   , (2.6)
where 1 4 is a factor taking into account the average over 4 vertices of a tetrahedron,

|C i | = 1 4 K i |K|, K
i is a tetrahedron sharing the vertex i, j is a generic vertex of the tetrahedron K, V j is the nodal value of the quantity V and n j,xn is the n th component of the normal associated with the vertex j in the tetrahedron K.

Since the Jacobian of the source terms is computed by performing a loop on the tetrahedra of the mesh, we drop the summation K i and, with an abuse of notation, we focus only on the contribution relative to a single tetrahedron K containing the vertex i,

∂ xn V i = |K| 4|C i | j∈K V j n j,xn .
The incomplete differentiation of ω i with respect to u j , v j , w j reads as

∂ω i ∂u j = 1 ω i (∂ z u i -∂ x w i ) ∂ ∂u j (∂ z u i ) -(∂ x v i -∂ y u i ) ∂ ∂u j (∂ y u i ) , ∂ω i ∂v j = 1 ω i (∂ x v i -∂ y u i ) ∂ ∂v j (∂ x v i ) -(∂ y w i -∂ z v i ) ∂ ∂v j (∂ z v i ) , (2.7
)

∂ω i ∂w j = 1 ω i (∂ y w i -∂ z v i ) ∂ ∂w j (∂ y w i ) -(∂ z u i -∂ x w i ) ∂ ∂w j (∂ x w i ) .
Since these expressions could provide singularities when ω i is small, we set the corresponding contributions to zero when ω i ≤ 10 -18 . At this point it only sufficies to provide the expressions of the derivatives of the nodal gradients with respect to the nodal quantities, which read as

∂ ∂V j (∂ xn V i ) = |K| 4|C i | n j,xn .
The derivative with respect to ρ j requires a bit more effort, in fact, all the nodal physical velocities inside ω i contain the density ρ i . The incomplete derivative of ω i with respect to ρ j reads as

∂ω i ∂ρ j = 1 ω i (∂ y w i -∂ z v i ) ∂ ∂ρ j ∂ y w i -(∂ y w i -∂ z v i ) ∂ ∂ρ j ∂ z v i +(∂ z u i -∂ x w i ) ∂ ∂ρ j ∂ z u i -(∂ z u i -∂ x w i ) ∂ ∂ρ j ∂ x w i +(∂ x v i -∂ y u i ) ∂ ∂ρ j ∂ x v i -(∂ x v i -∂ y u i ) ∂ ∂ρ j ∂ y u i .
The derivatives of the nodal gradients of the velocities are given by

∂ ∂ρ j ∂ xn V i = - |K| 4|C i | V j ρ j n j,xn .
In conclusion, using (2.5) and (2.7) we deduce

∂ω i ∂ρ j = - 1 ρ j ∂ω i ∂u j u j + ∂ω i ∂v j v j + ∂ω i ∂w j w j = - ∂ω i ∂(ρu) j u j + ∂ω i ∂(ρv) j v j + ∂ω i ∂(ρw) j w j .
The 2D case is simpler. In fact, we have that

ω i = |∂ y u i -∂ x v i |.
Hence,

∂ω i ∂u j = sgn(∂ y u i -∂ x v i ) ∂ ∂u j ∂ y u i , ∂ω i ∂v j = sgn(∂ y u i -∂ x v i ) ∂ ∂v j ∂ x v j ,
where

∂ ∂V j ∂ xn V i = |K| 3|C i | n j,xn
where |K| 3 takes into account the contribution of the triangle K to the L2 projection gradient reconstruction at vertex i ∈ K. Again, the derivative with respect to ρ j is obtained with

∂ω i ∂ρ j = sgn(∂ y u i -∂ x v i ) ∂ ∂ρ j ∂ y u i + ∂ ∂ρ j ∂ x v i ,
where

∂ ∂ρ j ∂ xn V i = - |K| 3|C i | V j ρ j n j,xn ,
hence,

∂ω i ∂ρ j = - ∂ω i ∂(ρu) j u j + ∂ω i ∂(ρv) j v j .
Once we have gathered the derivatives of ω i with respect to the nodal quantities, we can compute the Jacobian of the production and the destruction terms by applying the chain rule

∂P i ∂W j = ρ i c b1 νi ∂ S ∂ω i ∂ω i ∂W j , (2.8) ∂D i ∂W j = -c w1 ρ i ν d 2 ∂f w ∂ S ∂ S ∂ω i ∂ω i ∂W j , (2.9)
where ∂ S ∂ω i = 1 and we have omitted the index i from the Spalart-Allmaras quantities, and

∂f w ∂ S = df w dg dg dr dr d S , df w dg = g lim +g dg lim dg , dg dr = 1+c w2 (6r 5 -1), dr d S = - ν (κd S) 2 g lim = 1 + c 6 w3 g 6 + c 6 w3 1 6 , dg lim dg = - g 5 (c 6 w3 + 1) c 6 w3 +1 g 6 +c 6 w3 5 6 g 6 + c 6 w3 ,
where g, c w2 , r, κ and c w3 are quantities of the Spalart-Allmaras model.

Assembling and comparison with finite differences

The assembling of the additional terms arising from the strong coupling between the mean flow and the turbulence equation follows strictly the assembling of the classical terms already present in the weakly coupled implementation. In particular, following the edge-based Jacobian representation, each term is computed inside a particular loop on geometrical entities. We can distinguish four contributions, i.e.,

• the convective contribution as described in 2.1.1, computed inside a loop on edges,

• the viscous contribution as described in 2.1.2, computed by element equivalently to the mean flow viscous part assembling, • the source terms contribution (through ω only) as described in 2.1.3, computed inside a loop on elements: the computation of ω i at each vertex i makes use of L2projection gradients of the velocities, and hence the computation of the derivatives of these quantities is analogous to the viscous fluxes ones, and • the source term contribution (through ρ i only) as described in 2.1.3, which provides a diagonal term only, and hence these are computed inside a loop on vertices. An alternative implementation has been made, where the coupling terms are computed by finite differences. Here, the four contributions are obtained by computing

J num = R(W + δW ) -R(W ) δW , (2.10)
where the increment δW = W ref is proportional to the reference state. Two different loops are used to compute such finite differences, i.e.

• the convective contribution as described in 2.1.1, are computed inside a loop on edges, • all the remaining contributions are computed inside two nested loops: the outer loop on each vertex i, the inner loop runs on the elements sharing the vertex i. The finite difference implementation, made for both the 2D and the 3D settings, has been made to assess the validity of the analytical derivatives of the numerical fluxes shown in this section, and it is not meant to be used in actual simulations. In fact, its loop scheme is inefficient if compared to the one of the analytical Jacobian, but its structure is simpler and more intuitive, in order to reduce the risk of possible bugs when writing the code. Furthermore, the different loop schemes force to avoid code replication from the computation of the numerical fluxes. In this way, possible bugs or errors inside one implementation can be less likely found in another implementation. Eventually, as pointed out in Section 2.2, the finite differences strong coupling is less precise than the analytical strong coupling, hence it is preferable to use this last when a strong coupling is needed.

2D test cases

In this section, we show the results of numerical experiments made on three different airfoils, the HLCRM2D, the RAE2822 and the NACA0012. We first show the results of three simulations made on fixed meshes with a small number of vertices, then, we show the results relative to the fully adaptive processes. The physical parameters and the number of vertices of the fixed meshes are summarized in

Fixed meshes tests

Each mesh has been adapted by using a goal-oriented metric, in particular in the RAE2822 case, the drag coefficient C D has been used as goal functional, while the lift coefficient C L has been used for the HLCRM2D and the NACA0012 cases (see Chapter 5 for further detail). The choice of using an adapted mesh instead of a uniform one is justified by the desire of testing the strong coupling in a realistic scenario. Furthermore, since the goal of this section is to assess the validity of the additional terms of the strongly coupled Jacobian as described in Section 2.1, one must ideally run a pure Newton method by using Jacobians containing an exact differentiation of the residuals. To do so, we run simulations with the following characteristics:

• uniform starting solution, in order to start as far as possible from the zero-residual solution, • 1 st order convective numerical fluxes, so that the Jacobian, with its edge-based structure, represents the exact differentiation of the residuals, • the CFL is reduced only if the non-linear residual or the SGS linear residual increase of a factor 100. This allows to grow the CF L number monotonically to its maximal value (10 6 ) up to extreme convergence issues, so that the time increment procedure tends to be equivalent to a pure Newton method. Note that this can be done here as the involved meshes have a relatively low number of degrees of freedom (and, hence, the linear systems are small), on the contrary, for instance in fully adaptive processes, it is not possible to avoid some form of CFL control (e.g., on the linear or on the non-linear residual), • 100 SGS iterations to solve the linear system at each time step, in order to reduce the error contribution due to the linear system resolution. Again, this can be done here thanks to the low number of vertices, but in more complex cases 100 SGS iterations are not realistic. Furthermore, for each case we run also a simulation based on the finite differences Jacobian (2.10), by setting = 10 -10 . Regarding the choice for such finite difference increment, we selected the value of 10 -10 after several numerical experiments. For this purpose, we show how the convergence history varies by varying such parameter for the HLCRM2D case: Figure 2.5 shows the residual of the continuity and Spalart-Allmaras equations, together with the average CF L number and the total number of SGS iterations for = 10 -7 , = 10 -10 , = 10 -13 , = 10 -16 , = 10 -19 and by using the exact differentiated Jacobian as a reference. We can notice that by using values smaller than δW = 10 -16 W ref , the convergence becomes slower, and this can be related to singularities inside the Jacobian matrix, as well as subtractive cancellation errors, leading to sudden CF L decreases. Eventually, notice how, for the same SGS target residual, the exact differentiated Jacobian requires a smaller number of SGS iterations to converge. In Figures 2.6-2.7-2.8, we show the convergence history of the ρ-residual and the ν-residual for each of the three considered 2D cases, by using a weakly coupled Jacobian (weakly cpl), the strongly coupled Jacobian where the mean flow -turbulence coupling terms have been computed by finite difference (fd strongly cpl), and the strongly coupled Jacobian (strongly cpl), where the coupling terms are exact. We can see that for the ρ-residual no difference arises when switching from the exact differentiated to the finite difference Jacobian. They differ mostly in terms of ν residual convergence. Apart from that, it is clear that the coupled Jacobian is able to decrease the residuals faster, and to reach a lower value, thanks to the additional directional information deriving from the Spalart-Allmaras equation.

Mesh adaptation solution platform tests

We have shown the behavior of the coupled Jacobian in an ideal situation: the convective fluxes are at first order, the grids have a fixed complexity, they have a low number of

CF L Number of SGS iterations

Figure 2.5 -HLCRM2D airfoil test case: convergence history for different finite difference increments and exact differentiation. We can see that for = 10 -16 and = 10 -19 the residual does not converge, and, in general, the strong coupling obtained by means of analytical derivatives performs better than the finite differencen approach. vertices, and the CF L is let to increase to its maximum value. We show here the results relative to a whole mesh adaptive procedure for the cases of Table 2.1. For each case, we start with a number of vertices N V = 4000 and we end up with N V = 1024000. We employ a goal-oriented mesh adaptation (see Chapter 5 for further detail) with the drag coefficient C D as goal functional for the RAE2822 and the NACA0012, while we use the lift coefficient C L for the HLCRM2D. We use the same set of parameters for both the simulations run with the weakly coupled and the strongly coupled Jacobian. We evaluate the strongly coupled Jacobian by comparing two measures, i.e.,

• we compare the curves of the aerodynamic coefficients with respect to the mesh complexities and • we compare the curves of the aerodynamic coefficients with respect to the time iterations. We expect the first set of curves to converge to the same values, as this indicates that both the weakly coupled and the strongly coupled Jacobians converge to the same solution. Regarding the second set of curves, we expect, for a fixed complexity, the strongly coupled Jacobian to converge faster than the weakly coupled Jacobian, in accordance with the previous section. Figures 2.9-2.10-2.11 are showing the plots of the aerodynamic coefficients (lift coefficient C L , drag coefficient C D , pressure drag coefficient C Dp and friction drag coefficient C Df ) for all the considered 2D cases. We can see that in any case the aerodynamic coefficient curves converge to the same values and this indicates that the two approaches are providing the same flow field at convergence.

Concerning the trends of the aerodynamic coefficients with respect to the time iteration (Figures 2.12, 2.13, 2.14), the results are rather heterogeneous, but in general the residual convergence with the strongly coupled Jacobian is at least as fast as the one of the weakly coupled one. The RAE2822 case shows that the strongly coupled Jacobian requires ∼ 20% less of time iterations to reach mesh convergence, the HLCRM2D shows little difference between the two approaches, while the NACA0012 airfoil shows a huge improvement (∼ 50% time iteration less) when switching from the weakly coupling to the strongly one, as the former halves the required number of iterations to reach mesh convergence. Notice, furthermore, the spurious oscillations at the end of the simulation originated by unsteadiness in the C Dp , which are impacting the C D : these are appearing for both the approaches but they are smaller when using the strongly coupled solver. In conclusion, the strongly coupled solver is in general the best choice.

3D test cases

In this section, we show the results of numerical experiments made on three different 3D geometries, the Onera M6 wing (denoted by OM6), the 3D common research model of the 3 rd CFD AIAA High Lift Prediction Workshop (denoted by HLPW3) and the common research model of the 7 th CFD AIAA Drag Prediction Workshop (denoted by DPW7). Such experiments are performed similarly to the 2D cases: first we compare the weakly coupled solver and the strongly coupled solver in an "ideal" situation (uniform starting solution, 1 st order numerical fluxes, pure Newton method, high number of SGS iterations), and then we compare the two approaches in a "real" situation, i.e., inside a mesh adaptation loop. Regarding the physical parameters and the number of nodes of the fixed grids, one can refer to the values in Table 2.2 while the fixed meshes are shown in Figures 2.15-2.16-2.17 along with the Mach number field.

Fixed meshes tests

Similarly to the 2D tests, the experiments shown in this section are conducted by using meshes with a fixed complexity, outside a mesh adaptation loop. The sole difference with respect to the fixed mesh tests of Section 2.2 is that we reduce the CFL if the SGS solver is not able to properly converge (i.e., reduce the initial linear system residuals by at least one order of magnitude) in the HLPW3 and the DPW7 cases, as the resulting linear systems in 3D are stiffer than the ones of the 2D cases. For this reason, we also show the average CFL trend for such benchmarks. The meshes shown in Figures 2.15-2.16-2.17 are adapted by using a goal-oriented mesh adaptation procedure (see Chapter 5 for further details), in particular the drag coefficient C D is used as goal functional for the OM6 and DPW7 geometries, and the lift coefficient C L for the HLPW3 geometry. For all the geometries, we show the convergence of the continuity equation residual (ρ-residual) and

C Dp vs N V C Df vs N V Figure 2
.10 -HLCRM2D airfoil test case: aerodynamic coefficients for each mesh complexity. We can see that we target the same functional values for any approach.

the Spalart-Allmaras equation residual (ν-residual) for the weakly coupled and the strongly coupled solvers. The finite difference Jacobian for these cases has not been run as it is not parallelized and has an inefficient assembling. We see that the trends are overlapping in the OM6 and the HLPW3 cases, while the strongly coupled solver shows a faster residual reduction for the DPW7 case, even though the average CFL is smaller for such method (see Figure 2.21). This is not the case of HLPW3, as here the CFL trends are similar.

Adaptive meshes tests

Similarly to the 2D cases, we show here a comparison between the two coupling methods inside the mesh adaptation loop. Here, the number of vertices N V iterates from 10000 to 2560000 in the OM6 case, from 320000 to 10240000 in the HLPW3 case and from 64000 to 2048000 in the DPW7 case. In Figures 2.22-2.23-2.24, we show the trends of the aerodynamic coefficients with respect to the mesh complexity, while in Figures 2.25-2.26-2.27, we show the same trends with respect to time iterations. We see that the aerodynamic coefficients converge to the same values in all the cases and hence both the approaches are providing the same solution. Concerning the convergence of the aerodynamic coefficients, likewise the 2D cases, we have heterogeneous outcomes: in the OM6 wing case we do not distinguish any difference in the trends of the aerodynamic coefficients versus the mesh

C Dp vs N V C Df vs N V Figure 2
.11 -NACA0012 airfoil test case: aerodynamic coefficients for each mesh complexity. We can see that we target the same functional values for any approach.

complexity in Figure 2.22, meaning that both the approaches are converging toward the same solution. The trend of the OM6 aerodynamic coefficients with respect to the time iterations, shown in Figure 2.25, points out an irregular behavior, specially when a mesh complexity increase occurs, but, still, both the approaches obtain the same aerodynamic coefficient values. We also point out the oscillations in the aerodynamic coefficients, which are due to the presence of a shock wave. In this case, the strongly coupled solver seems to require a higher number of iterations. This is in particular due to a higher number of mesh iterations at mid complexities (more than 80K vertices). It is worth pointing out that at lower complexities (10K, 20K and 40K), the strongly coupled solver provides a faster convergence. On the contrary, in the HLPW3 case the strongly coupled solver is slightly slower than the weakly coupled one at lower complexities (see Figure 2.23), and this can also be noticed in the time convergence of the same quantities, in Figure 2.26. This effect could be related to initial solutions which are far from the optimum, and hence, the weakly coupled solver could show better performances. The case of the DPW7 is more aligned with the one of the OM6: for lower complexities, the strongly coupled solver reaches the same aerodynamic coefficient values with less mesh iterations, but at the end it becomes slower than the weakly coupled one. As it can be noticed from Figure 2.24, we underline that the mesh convergence is not fully reached in the DPW7 case, as neither C Dp nor C Df are stabilized on a target value. More mesh complexity increases should be pursued for this benchmark. In conclusion, we obtain the same outcome as for the 2D cases: in general We can see that the strongly coupled approach performs slightly better than the weakly coupled one.

the strongly coupled solver is as valid as, or better than the weakly coupled one and, in addition, in mesh adaptation loops they provide the same set of aerodynamic coefficients (hence, they target the same solutions).

Strongly coupled Jacobian: conclusions

In this chapter we have described a strongly coupled turbulence solver, by explicitly writing its terms in the case of the Spalart-Allmaras equation and in a 2D/3D setting. We have compared the performances of such solver with respect to the weakly coupled turbulence solver in terms of residual and aerodynamic coefficients convergence. In particular, we have conducted several tests with fixed meshes and within the mesh adaptation loop by varying the geometry, the physical parameters, both in 2D and 3D. The primary objective of this chapter is to demonstrate the validity of the strongly coupled turbulence solver in view of the computation of the adjoint turbulent viscosity, and such objective has been successfully reached. Regarding the comparison between a strongly coupled and a weakly coupled turbulence solvers, we obtained rather heterogeneous results, and hence we are not able to draw conclusions beyond those we have found in literature, even for adaptation 2.14 -NACA0012 airfoil test case: aerodynamic coefficients for each time iteration. We can see that the strongly coupled approach performs significantly better than the weakly coupled approach. Here, we see that there is no difference between the weakly coupled and the strongly coupled approach. Here, we see that the strongly coupled approach performs significantly better than the weakly coupled one.

C Dp vs N V C Df vs N V Figure 2
.23 -HLPW3 geometry test case: aerodynamic coefficients for each mesh complexity. We can see that the targeted functional values are the same for both the approaches, despite the fact that no full convergence has been reached..

C Dp vs N V C Df vs N V Figure 2
.24 -DPW7 geometry test case: aerodynamic coefficients for each mesh complexity. We can see that the targeted functional values are the same for both the approaches, despite the fact that no full convergence has been reached. The strongly coupled approach is slightly faster in the first mesh complexities.

Chapter 3

RANS adjoint solver

In this chapter, we introduce the adjoint problem and the relative solver in Wolf. In particular, we start by providing some examples of adjoint variables and adjoint problems in the Introduction 3.1. Then, we describe the continuous and the discrete adjoint systems for the RANS equations in 3.1.1, the behavior of the discrete adjoint solutions in 3.1.2, and we underline some differences between the weakly coupled and the strongly coupled turbulence adjoint systems in Section 3.2. In Section 3.3, we describe several methods to solve the adjoint problem, namely the biconjugate gradient stabilized (BiCGSTSAB), the generalized minimal residual (GMRES), the flexible GMRES (FGMRES) and the algebraic multigrid preconditioner (AMG). In the last Section 3.4, we show and assess the pseudotransient continuation algorithm (PSTR).

Introduction

The concept of adjoint variable arises naturally in the context of constrained optimization, in fact, consider the following problem

min j(w) s.t. r(w) = 0, w ∈ R n , (3.1)
where j and r are functionals such that j : R n → R represents the functional to be minimized, and r : R n → R n represents a set of n constraints. Problem (3.1), under certain assumptions, is equivalent [Walsh 1975, Kalman 2009] to the unconstrained minimization of the Lagrangian function

L(w, w * ) = j(w) -r(w) T w * , (3.2)
where w * ∈ R n is the so-called Lagrange multiplier, or, adjoint variable. In this context we can see that the adjoint w * acts as a penalty parameter of the constraint r(w) = 0.

Since we want to find the extrema of (3.2), we differentiate the Lagrangian with respect to w and w * and setting the obtained derivatives to zero leads to the system

     ∂r ∂w T w * = ∂j ∂w , r(w) = 0. (3.3)
The first equation of 3.3 is called adjoint equation. Another interpretation of the adjoint variable w * relies on the concept of sensitivity. In fact, assume one wants to compute the derivative of a functional j as defined in (3.1) with respect to the residuals given by r, i.e., ∂j/∂r. As in general there is no direct relation between j and r, one recovers its computation by relying on the chain rule which directly identifies ∂j/∂r with w * . In this sense, in the context of constrained optimization problems, the adjoint variable w * can be seen as the sensitivity of the objective functional with respect to the residual of the constraint.

The adjoint method to minimize a functional under some constraint has been widely used and explored, for instance, in the context of aerodynamic shape and design optimization [Reuther et al. 1996, Kim et al. 1999, Iollo et al. 2001, Giannakoglou and Papadimitriou 2008]. Here, one usually considers a design variable α, which influences the objective functional J (for instance, the drag or the lift coefficient) and the flow field solution W h . The goal is to find the parameter α minimizing J. The corresponding problem reads as

min α J(W h (α)) s.t. R(W h (α), α) = 0.
(3.6)

The resolution of problem (3.6) requires the computation of the gradient of J = J(W h (α)) with respect to α (like, for instance, in the gradient descent algorithm). Such differentiation gives

∂J ∂α = ∂J(s) ∂s W h ∂W h ∂α = ∂J(s) ∂s W h ∂R ∂W h -1 ∂R ∂α = (W * ) T ∂R ∂α , (3.7)
where α is a design parameter, for instance the no-slip surfaces mesh nodes or the control points of a NURBS, and ∂J(s, α)/∂s represents the partial derivative of J with respect to the flow variable W . In (3.7), definition of the adjoint as a sensitivity measure (3.5) has been used in the final equation of the equalities chain. Within this context, the use of the adjoint is particularly advantageous as one can compute the sensitivity of J with respect to any α by computing the adjoint variable W * only once, and then by multiplying it by ∂R ∂α to get the desired measure. The use of adjoint solutions play an important role also in the context of the discretization error estimate, for instance to compute upper bounds for quantities of the type J(W ) -J(W h ), where W is a solution of a differential problem, belonging to some function space V , and J : V → R is a scalar functional. Such discretization error estimate is useful as it can be used to adapt the mesh in order to get more reliable estimations of physically meaningful quantities represented by the functional J [Babuška and Miller 1984b, Babuška and Miller 1984c, Babuška and Miller 1984a, Eriksson and Johnson 1988, Eriksson and Johnson 1993]. Particularly important is the so-called technique Dual-Weighted Residual (DWR) developed and pursued by Becker and Rannacher [Becker and Rannacher 1996c, Becker and Rannacher 1996a, Becker and Rannacher 2001]. We illustrate such procedure by using an example based on linear variational problems. Assume a(•, •) is a bilinear form and f a linear functional over some function space V , and consider the function u solving

a(u, φ) =< f, φ > ∀φ ∈ V, (3.8)
and its finite element counterpart u h solving

a(u h , φ h ) =< f, φ h > ∀φ h ∈ V h , (3.9)
where V h is a space of finite element function. Given a functional J : V h → R, we want to get an estimate to J(u) -J(u h ). To do this, consider the problem

min J(u) s.t. a(u, φ) =< f, φ > ∀φ ∈ V, (3.10)
and the associated Lagrangian L(u, u * ) = J(u) + f z -a(u, z). The differentiation of such Lagrangian provides the Euler-Lagrange equations

   a(u, φ) =< f, φ > ∀φ ∈ V, a (u; φ, z) = J (u; φ) ∀φ ∈ V, (3.11)
and their discrete counterpart

   a(u h , φ h ) =< f, φ h > ∀φ h ∈ V h , a (u h ; φ h , z) = J (u h ; φ h ) ∀φ h ∈ V h , (3.12)
where a (•; •, •) and J (•; •) denote the Fréchet derivatives of a(•, •) and J(•), respectively. Then, we have that [START_REF] Becker | [END_REF]]

J(u) -J(u h ) = 1 2 min φ∈V h ρ(u h ; z -φ h ) + 1 2 min φ∈V h ρ * (z h ; u -φ h ) + R, (3.13)
where ρ and ρ * denote the residual of the primal and of the adjoint equation, i.e., ρ(

•; φ) =< f, φ > -a(•, φ) and ρ * (•; φ) = J (u h ; φ) -a (u h , φ, •).
What is important to underline in expression (3.13) is the role of the continuous adjoint variable z and its discrete counterpart z h . In both the components of (3.13), these are multiplying expressions dependent of the continuous and discrete primal variables u and u h . In this way, the adjoint variable acts as a weight inside the error estimate giving more importance to those domain locations which are more influent to the computation of the functional J.

Continuous and discrete adjoint

In this section, we describe the continuous formulation of the adjoint problem and the discrete formulation. Then we will discuss the advantages and drawbacks of both the approaches. In any case, Wolf employs the latter approach, i.e., the discrete adjoint. Note that contrary to what the name of the continuous approach could suggest, it leads to the definition of a discretized problem. The main difference between the two approaches is that the first writes the adjoint equations relative to the continuous problem and then one discretizes them in order to get the adjoint solution, while the latter directly writes the adjoint of the discretized equations. This means, in general, that, given the same primal flow solution, the continuous adjoint is not dependent of the discretization scheme used to solve the primal flow problem, while the discrete adjoint does. Hence, in the case of the discrete adjoint, this could produce a systematic gap when one compares two adjoint-based mesh adaptation strategies coming from primal solver with different discretization schemes (for instance finite volume vs finite element). To illustrate this point, Figure 3.1 shows the discrete adjoint density fields obtained with GGNS, a Navier Stokes solver developed at Boeing which is based on the SUPG finite element discretization and Wolf, which uses a mixed finite element -finite volume discretization, where both the solutions are computed on the same mesh and with the same primal solution. We can see that, despite the fact that both the solutions show analogies, such as the presence of a gradient on the sonic line, the resulting fields are fundamentally different.

Continuous RANS adjoint

In principle, the continuous formulation can be derived from the interpretation of the adjoint variable as the Lagrange multiplier of a minimization problem of the form (3.1), that is, a constrained minimization problem on functional spaces, but it is possible to derive the continuous adjoint equations by using the functional sensitivity definition as in (3.7). We choose to follow the first approach. We first write the weak formulation associated with the RANS equations [Ali and Soulaimani 2010] and the associated Lagrangian associated with a functional J to be minimized [Micheletti andPerotto 2008, Ali andSoulaimani 2010], and then we derive the adjoint equation. We assume that the functional J is the result of a surface integral over a no-slip adiabatic boundary. By adopting the same notation as Chapter 1, we have that the strong form of the RANS equations:

         ∇ • F (W ) -∇ • S(W ) -Q(W ) = 0 in Ω, u = 0, on Γ D , ∂ n T = 0, on Γ D , (3.14)
where F are the Euler fluxes, S are the viscous fluxes, Q are the source terms and W = (ρ, ρu, ρv, ρe, ν) is the solution to be computed, which belongs to a suitable function space V , and Γ D represents a no-slip boundary. In order to get the weak formulation of (3.14), we assume that W ∈ V D (i.e., the space V includes all the functions satisfying the boundary conditions of (3.14)) and we multiply the equations by a test function Ψ ∈ V , getting

Ω Ψ T (∇ • F (W ) -∇ • S(W ) -Q(W ))dΩ = 0. (3.15)
Next, we integrate by parts the convective and the viscous fluxes, and we are lead to the definition of a functional A(•,

•) : V × V → R A(W, Ψ) = Ω ∇Ψ T -F (W ) + S(W ) -Ψ T Q(W ) dΩ + Γ D Ψ T (F (W ) -S(W ))dσ = 0.
(3.16)

At this point, the Lagrangian associated with a functional J(W ) = Γ D j(W )dσ reads as

L(W, W * ) = J(W ) -A(W, W * ).
(3.17)

The differentiation of (3.17) with respect to W * provides the original equation system (3.14), while the differentiation with respect to W provides the weak form of the continuous adjoint system,

A (W ; W * , Φ) = ∂J ∂W , Φ ∀Φ ∈ V, (3.18)
where

∂J ∂W , Φ = Γ D ∂j ∂W Φdσ, (3.19)
and

A (W ; W * , Φ) = Ω ∇W * T - ∂F ∂W Φ + ∂S ∂W Φ -W * T ∂Q ∂W Φ dΩ + Γ D W * T ∂F ∂W Φ - ∂S ∂W Φ dσ.
(3.20)

We do not provide the expressions of the Fréchet derivatives ∂F ∂W , ∂S ∂W and ∂Q ∂W , as their expression is beyond the illustrative scope of the present section. Furthermore, such expressions can be found, specifically for the Spalart-Allmaras model in [Zymaris et al. 2009] for incompressible flows and in [START_REF] Bueno-Orovio | [END_REF] for compressible ones in the context of shape optimization. In these works, the authors derived the adjoint problem through the direct differentiation of the goal functional, hence, following (3.7). We underline again that the two approaches are interchangable. In [Belme 2011], the strong form of the adjoint equation is explicitly written for transient Euler and viscous flows, together with the continuous adjoint boundary conditions. For further reading, in [START_REF] Giles | [END_REF], the authors compute and explore the analytical solution of the adjoint quasi-one dimensional Euler equations for a variety of flows. Once the explicit terms are gathered, it is possible to compute the adjoint solution W * by means of finite element, or, to derive the strong form of the adjoint equation. Since (3.18) holds for any Φ ∈ V , this immediately provides the strong form of the adjoint RANS equations

     -∂F ∂W * + ∂S ∂W * ∇W * -∂Q ∂W * W * = 0 in Ω, ∂F ∂W * -∂S ∂W * W * = ∂j ∂W , on Γ D , (3.21)
where ∂F ∂W * ∈ V * , ∂S ∂W * ∈ V * and ∂Q ∂W * ∈ V * are the adjoint operators of the Fréchet derivatives of F , S and Q, respectively, and V * is the dual space of V . Note that in this description we have always assumed that W ∈ V D , as assuming W ∈ V provides an additional term in the boundary conditions of (3.21), which we do not include as the primal solution W is assumed to be known during the resolution of the adjoint problem, and W ∈ V D .

Discrete RANS adjoint

Concerning the discrete adjoint problem, which is implemented in Wolf, we note that this can be directly derived from a minimization problem of the form (3.1). This reads as

min J(W h ) s.t. R h (W h ) = 0, W h ∈ R N (3.22)
where W h is the discrete solution to the primal problem represented by a set of N degrees of freedom and R h (W h ) = 0 is the primal equation. The associated discrete Lagrangian reads as

L h (W h , W * h ) = J(W h ) -W * h T R h (W h ), (3.23)
and its differentiation with respect to W h provides directly the discrete adjoint [Mavriplis 2007, Lee andKim 2007]

∂R h ∂W h T W n h W * h = ∂J ∂W h W n h , (3.24)
where the Jacobian of the residuals and the derivative of the functional J are evaluated in the steady discrete primal solution W n h at the final pseudo-time step n. With an abuse of notation, in the sequel, we omit the evaluation of the Jacobian and the functional derivative in W n h , and the subscript of the discrete adjoint solution h, hence we write directly the discrete adjoint problem for the RANS equations as

∂R h ∂W h T W * = ∂J ∂W h . (3.25)
We can see that the resolution of (3.25) requires the evaluation of the transpose Jacobian of the primal solver. In Wolf its computation is made with the same routines of the primal solver, by turning on a flag indicating the transposition during the assembling. Note that system (3.25) has the same algebric properties of the transient primal system when CF L → ∞, in fact we recall that thids reads as

|C| δt n 1 - ∂R h ∂W n h δW n+1 h = R h (W n h ). (3.26)
In general, the mass matrix represented by the contribution (|C|/δt n )1 improves the iterative convergence of the SGS solver to solve the primal linear system because it increases the diagonal dominance of the matrix, and this is particularly true when the CF L is low. For this reason, as it has no CFL-controlled mass contribution, the discrete adjoint problem (3.25) is stiffer than its primal counterpart, specially for a high number of vertices. Hence, the resolution of (3.25) can be hardly pursued by relying on an iterative method like the SGS.

Concerning the choice of the right-hand-side functional of (3.25), Wolf allows different choices. We can distiguish two types of functionals: those computed on surfaces, and those computed on volumes. Regarding the definition of the surface functionals, we start from the expressions of the pressure and skin friction coefficients, that is

C p (x) = p(x) -p ∞ 1 2 ρ ∞ ||u 2 ∞ || , C f (x) = τ w 1 2 ρ ∞ ||u 2 ∞ || , (3.27)
where

τ w = (T • n) • u ∞ /||u ∞ ||, T
is the viscous stress tensor, and the subscript ∞ refers to the quantities at the far field. Using (3.27) it is possible to get the components of the forces (derived from pressure and viscosity) acting on a body, for instance for the pressure component as

    C x C y C z     = 1 |S ref | S C p (x)n(x)dσ (3.28)
One can get the lift C L and the drag C D by applying a proper rotation to (3.28) which takes into account the body orientation. Concerning the discretization of (3.27), we have that for a finite volume cell i, the local pressure coefficient contribution is given by

F i,p = p i n i |dS i | = (γ -1) (ρe) i - 1 2 (u 2 i + v 2 i + w 2 i ) n i |dS i |, (3.29) hence, ∂F i,p ∂W i = (γ -1) ||u i || 2 2 , -u i , -v i , -w i , 1 n i |dS i |.
(3.30)

The skin friction part reads as

F i,v = T • n i |dS i |, (3.31)
and it contains the gradient of the velocity through the stress tensor T , computed through an L2-projection gradient. Hence, its value at the node i needs the values of W h at its neighboring nodes too (see (2.6)). For further detail see [Frazza 2018].

Since the gradients of the variables converge slowly at the boundaries, another possibility is to compute the aeronautic coefficients with respect to the residual. In fact, we have that the residuals of the momentum equations provide the total acceleration of the fluid in that particular location. For this reason, the total force on a no-slip boundary point can be obtained by considering the sum of the momentum fluxes at it finite volume cell interface [Gariépy et al. 2013]. In particular, for example, the drag is defined as

F i,res = e ∞,x R u i + e ∞,y R v i + e ∞,z R w i , (3.32)
where e ∞ denotes the reference directions of the fluid. Hence,

∂F i,res ∂W j = e ∞,x ∂R u i ∂W j + e ∞,y ∂R v i ∂W j + e ∞,z ∂R w i ∂W j , (3.33)
and such expression contains terms already computed inside the Jacobian of the RANS system. Concerning the volume functional types, we give two examples of domain-averaged quantities. The first one is the mean density,

J(W ) = Ω ρdΩ = i |C i |ρ i ,
which, in 3D, provides

∂J ∂W i = |C i |(1, 0, 0),
while the second example is the mean Mach number, that is

J(W ) = Ω ||u|| 2 c dΩ = i |C i | ρ i (u 2 i + v 2 i + w 2 i ) γp i ,
and hence

∂J ∂W i = |C i | c 2γ||u|| 2 p 2     ||u|| 2 p + (γ-1)ρ||u|| 2 2 (2p + (γ -1)ρ||u|| 2 ))u (γ -1)||u|| 2     .

Continuous vs discrete RANS adjoints

As mentioned in the introduction, the first difference between the described approaches relies in the interpretation of the problem. The continuous adjoint problem (3.18) represents a variational problem where the actual unknown belongs to a function space. Such problem can be solved naturally in the context of finite elements, and here one ends up with a discretized adjoint solution W * h . Within this context, we can apply rigorously all the tools which are typical of the finite element framework, including a priori and a posteriori error estimate, and mesh adaptation. Concerning the discrete adjoint problem (3.25), this is the result of a constrained minimization of already discretized equations, and the resulting adjoint solution does not have, in principle, a continuous counterpart, and depends on the discretization which provides R h . For very specific cases, the (discretized) continuous adjoint solution and the discrete adjoint solution are matching, for instance when R h is the result of a P 1 finite element discretization, but this is rarely used in computational fluid dynamics, as one usually wants to reduce the artifical viscosity by using a finite volume scheme as in Wolf or by applying corrections as done in GGNS. Hence, in Wolf, the resolution of the continuous adjoint problem requires an additional effort for writing a finite element solver. Instead, the discrete adjoint only requires the computation of the Jacobian of R h , which is already available from the primal solver if an implicit method is used to get the primal solution W h . We recall that this is not always the case, as many CFD solver do not provide routines for the computation of the Jacobian of the discrete residuals, and in these cases one has to rely on automatic differentiation [Naumann 2011, Nemili et al. 2013]. Nontheless, in [Nadarajah and Jameson 2000] a comparison between the continuous and the discrete adjoints is pursued in the context of shape optimization. Here the authors consider the problem (3.7), and compare the finite difference, the continuous and the discrete adjoint approaches. They found out that the discrete adjoint is slightly closer to the finite difference solution, but in general as the mesh complexity increases, the difference between the continuous and the discrete adjoints reduces, showing a convergent trend. Furthermore, in general, the discrete adjoint solver is able to keep track of the presence of the singularities. In any case, Wolf adjoint solver targets the discrete version of the problem, as the Jacobian computation in (3.25) requires only the transposition of an already computed matrix, and thanks to the convergence properties of the discrete approach to the continuous one as the mesh size reduces.

Boundary conditions

The boundary conditions of the continuous adjoint system for RANS equation are already available in (3.21). Further detail regarding other types of boundary conditions can be found in [START_REF] Giles | [END_REF]. Here, for instance, it is stated that Dirichlet type boundary conditions in the primal problem provide Dirichlet boundary contitions in the adjoint problem, and Neumann boundary type in one formulation provides Robin conditions in the other one. Concerning the boundary values of the discrete adjoint, we rely on a decomposition formula following the approach in [Giles et al. 2001, Giles et al. 2003]. Consider a projection matrix B which provides the boundary components of the solution. Such matrix has unitary diagonal entries on the indices of the Dirichlet conditions, and it is zero elsewhere. We have that B n = B and B T = B. Hence, we can write the primal system as

   (I -B)R h (W h ) = 0, BW h = 0, (3.34)
where the second equation of (3.34) describes the imposition of the boundary conditions.

The linearized problem in a Newton iteration is

(I -B) ∂R h ∂W n h δW n+1 h + R h (W n h ) = 0, BδW n+1 h = 0, (3.35)
we sum up the two equations of (3.35) to reassemble the system,

(I -B) ∂R h ∂W n h + B δW n+1 h = (B -I)R h (W n h ).
(3.36) Expression (3.36) is the pure Newton iteration with the boundary contribution explicitly written. By using this expression, we can write the discrete adjoint counterpart, i.e.

∂R h ∂W h T (I -B) + B W * = ∂J ∂W h . (3.37)
We define the two orthogonal components of the discrete adjoint and the functional as

W * i := (I -B)W * , W * b := BW * ∂J ∂W h i := (I -B) ∂J ∂W h ∂J ∂W h b := B ∂J ∂W h
and we multiply (3.37) by (I-B) to get

(I -B) ∂R h ∂W h T W * i = ∂J ∂W h i BW * i = 0, (3.38)
combining the two equations in (3.39) provides

(I -B) ∂R h ∂W h T + B W * i = ∂J ∂W h i . ( 3
W * b = B ∂J ∂W h - ∂R h ∂W h T W * i . ( 3

Adjoint behavior

In this section we describe briefly the main properties of the adjoint solution, and the main differences with respect to the primal solution. To this purpose, we consider the 2D CFD AIAA High Lift Prediction Workshop common research model (HLCRM2D) as a model problem for this specific section (see Section 2.2 for the complete description of the case). Figure 3.2 shows on the left the primal momentum magnitude, while on the right it shows the x-momentum adjoint variable relative to the lift coefficient J = C L . The computation has been made with Wolf on an adapted mesh with 64 000 vertices, this figure clearly shows that the primal flow comes from left to right. The adjoint flow, instead, comes from right to the left. This behavior can be explained through the interpretation of the adjoint field as a sensitivity of C L with respect to the flow: in fact, the flow in the upstream regions has a higher impact on the computation of C L . This fact has also a mathematical explanation. Consider, for instance, a simple 1D advection-diffusion equation, where we neglect the boundary conditions (this can be done, for instance, by assuming homogeneous Dirichlet conditions and by selecting proper function spaces for the variational formulation of the problem),

β • ∇u -µ∆u = f ∀x ∈ Ω, (3.41)
and a generic volumic functional as

J(u) = Ω gu dΩ. (3.42)
The weak formulation of (3.41) reads as

A(u, φ) = (f, φ) ∀φ ∈ V (3.
A (u * , ψ) = (g, ψ) ∀ψ ∈ V, (3.46)
where We can see that (3.49) is written in a very similar form to (3.41) with the sole exception that the advection term presents a negative sign, while the diffusion term keeps the same sign of the primal counterpart. This means that the drift component of the transport equation reverses, and hence the adjoint flows from downstream to upstream. Note that the adjoint operator of (3.49) is independent of the chosen target functional J(u).

A (u * , ψ) = Ω -ψβ • ∇u * dΩ - Ω µψ∆u * dΩ, (3.47)

Dependency on the mesh size

It has been observed experimentally that the magnitude of the discrete adjoint solution has a strong dependency on the mesh size. To illustrate this, we still use the model problem problem represented by the HLCRM2D case. In particular we consider two meshes of different sizes, and the solution associated to such meshes. The first mesh has a complexity of 64 000 vertices, while the second one of 256 000. We indicate the solution and the adjoint over the first mesh as W 64k and W * 64k , while as W 256k and W * 256k the solution and the adjoint over the second mesh, and we refer to the case of the first mesh as the 64k case and to the case of the second mesh as the 256k case. These two meshes are shown in Figure 3.3, specifically in the location of the slat and the main wing leading edge. Figure 3.4 shows an interesting fact about the adjoint magnitude with respect to the mesh size. The upper couple of images show the adjoint field ρ * of the 64k and the 256k cases, by using their proper value scale. Below the same solution is shown, where the 256k one is rescaled upon the same values of the 64k case. In the upper images the solutions look visually quite similar, while below the 256k case shows a much wider scale. The ratio between the scales is ∼ 1.67, which is comparable to the ratio of the mesh sizes h, which in this case is 2. The main question is whether such difference in the adjoints is only due to the primal solution difference, only due to the different mesh or both the contributions. For this reason, we conduct two additional adjoint crossed computations, i.e.,

• an adjoint computation starting from W 64k interpolated on the mesh of the 256k case, and • an adjoint computation starting from W 256k interpolated on the mesh of the 64k case, and we compare them to the adjoint simulation of the 256k case. To this purpose, in Figure 3.5 we show on the left the result of the first crossed simulation while on the right W * 256k . It is clear here that the sole difference of the primal solution does not impact relevantly the adjoint, as here both the adjoint solutions show the same magnitude scale. We now test the effect of the different meshes. The result of the second crossed simulation ρ * computed with the 256k mesh upon W 64k ρ * computed with the 256k mesh upon W 256k is shown on the left of Figure 3.6, while the original W * 256k is shown on the right. It is clear that the mesh size represents the main contribution to the difference between the adjoints. In order to dig deeper, we compute two additional quantities relative to these two computations, in particular

• the difference between the two adjoint solutions (ρ * only),

• the ratio between the two adjoint solutions: ρ * 256k /ρ * 64k , Note that all these fields are provided by interpolating the values of the 64k case on the 256k mesh, and then by performing the computations. These are shown in Figure 3.7. What it is interesting to note here is that the adjoint difference is higher in the proximity of the sonic line in the upstream region (and this is in accordance with the fact that the adjoint flows from downstream to upstream), and in the upper region of the leading edge of the slat and the main wing. The adjoint ratio shows the maximum difference on the boundaries of the sonic lines, which are the regions presenting the biggest difference in shape (see Figure 3.4). Apart from that, in the near-field regions (i.e., where W * >> 0), the ratio seems to vary around ∼ 1.67, which is the ratio between the two scales. To sum up, whenever the mesh increases in its size, the adjoint solution seems to increase in magnitude (in addition to other modifications due to the mesh refinements which capture more physics -just like the primal field does). Anyway, the mathematical inspection of the phenomenon is not provided here. As a reference, in [START_REF] Giles | [END_REF] it is proven that the analytical adjoint of the quasi-one dimensional Euler equations shows a logarithmic discontinuity on the sonic throat. Should this effect be present also in the context of RANS, the size increase of the computational mesh should only underline this behavior. Furthermore, as we are using the discrete adjoint, the non-linearities of the fluxes produce sharper adjoint fields, and this effect is even more marked when including the turbulent variable inside the adjoint system, where the adjoint fields presents real discontinuitues which are emphasized by the mesh refinement, as it is shown in Section 3.2.

We complete this section by showing the behavior of the adjoint inside the boundary layer location as the mesh refines. To this aim, we still consider the model problem represented by the HLCRM2D, and we consider the values of W h and W * taken on a vertical line starting from the upper side of the main wing at x/L ref = 0.4. We plot such values for all the variables in Figure 3.8 for a set of meshes of increasing complexity from 4 000 vertices to 64 000. Note that here we show only the weakly coupled adjoint results, hence ρ * computed with the 64k mesh upon W 256k ρ * computed with the 256k mesh upon W 256k no adjoint turbulence variable is considered (see Section 3.2 for this topic). We see that the profiles of the primal variable converge as the mesh size increases to a fixed value, while the adjoint boundary layer does not show any kind of convergence, just like the interior field. This effect accelerates the mesh refinement process inside boundary layers, and, as described in the next Section 3.2, the solution of the coupled adjoint problem has even a bigger impact on this trend. The dependency of the adjoint solution with respect to the mesh size has been observed and described in [Lozano 2019]. Here, the author shows how the adjoint boundary values are diverging when solving the Euler primal and adjoint equations when the lift coefficient is used as adjoint right hand side, irrespectively of using the discrete or the continuous adjoint. By setting J = C D , the adjoint converges to a fixed value. The author of [Lozano 2019] noticed that this could be linked to the presence of a discontinuity on the trailing edge of the adjoint solution, which is typical when the lift coefficient is used as right hand side, and we confirm that Wolf has the same behavior, at least with the Euler equations. For instance, Figure 3.9 shows the result of two mesh convergence simulations based on a NACA0012 airfoil and the Euler equations: on the left C D is set as adjoint right hand side, on the right C L , and we can see that in the first case the adjoint converges, contrary to the second one. Anyway, in [Lozano 2019], the author claims that the adjoint converges when the Navier-Stokes model is used, but, as shown previously, this is not the case with Wolf. One possibility to explain this fact is to note that the solution of the discrete adjoint problem as in (3.25) changes unit of measure depending on the dimension of the right hand side of the adjoint problem. By setting a surface functional in place of J in (3.25), the solution W * scales as h 2 , where h is the mesh size. By setting a volumic functional it scales as h 3 . We have pursued a numerical experiment by setting the local Mach number M a as adjoint right hand side, but even in this case the solution seems to diverge as in the case of J = C L : see Figure 3.10. To conclude, it seems that there is no dependency on the unit of measure of J when computing the adjoint solution. The reasons behind the adjoint dependency on to the mesh size are deeper, and these clearly indicate that the adjoint solver of Wolf could not be consistent [Stück 2015], meaning that the discrete adjoint solution does not converge to the continuous adjoint solution as h → 0. Hence, it could be suitable to test and study the continuous adjoint problem, and to compare its solution to the discrete one to get additional insight about this behavior. In such a context, an accurate study of the discrete adjoint boundary conditions could represent the key to understanding of this behavior.

Weakly and strongly coupled adjoints

In this section, we present the differences between the weakly coupled and the strongly coupled discrete adjoints. We recall, from Section 2, that the weakly coupled adjoint in 2D reads as

          ∂R ρ ∂ρ
0 0 0 0 0 ∂R ν ∂ ν                    ρ * (ρu) * (ρv) * (ρe) * ν *          =           ∂J ∂ρ ∂J ∂ρu ∂J ∂ρv ∂J ∂ρe 0          
, this approach is referred also as the frozen turbulence approach. This is because when computing any functional sensitivity of the type (3.7), one neglects the variations of the functional with respect to ν * . The strongly coupled adjoint system in 2D reads as

and
          ∂R ρ ∂ρ
∂R ρu ∂ ν ∂R ρv ∂ ν ∂R ρe ∂ ν ∂R ν ∂ ν                    ρ * (ρu) * (ρv) * (ρe) * ν *          =           ∂J ∂ρ ∂J ∂ρu ∂J ∂ρv ∂J ∂ρe 0          
, and this allows to get non-zero values for ν * . Note that the employment of the strongly coupled adjoint not only provides nonnull values for ν * , but modifies also the other unknown through the compensation operated by the derivates of the turbulence equation fluxes with respect to the mean-flow variable. Examples of Spalart-Allmaras strongly coupled adjoint approach can be found in [Zymaris et al. 2009, Zymaris et al. 2013] for the continuous adjoint, and in [Anderson andBonhaus 1999, Dwight andBrezillon 2006] for the discrete adjoint. In particular, in [Zymaris et al. 2009], the authors show the that strongly coupled adjoint was closer to the results provided by direct differentiation, and that the introduction of the adjoint turbulent variable was relevantly beneficial for functionals highly dependent on turbulence. In [START_REF] Papoutsis-Kiachagias | [END_REF], the authors implement a continuous adjoint model for the Launder-Sharma κ -model, and they make a comparison between the weakly and the strongly coupled systems through the finite difference method. In particular, they made such comparison on shape and flow control optimization problems of S-shaped duct and similarly to [Zymaris et al. 2009], they found out that the strongly coupled adjoint results are closer to those provided by finite differentiation, and that the weakly coupled approach could lead to wrong sign in the sensitivity, and requires a higher amount of optimization iterations to reach the optimum. In general, the additional terms of the strongly coupled adjoint are highly nonlinear, bring a more detailed adjoint flux, and specially provides additional physics-related information to the adjoint field. To this purpose, we compare these two approaches in the next sections for 2D and 3D cases. As usual, we are interested in testing and comparing these methodologies on real cases, and hence we are using adapted meshes to run the adjoint resolutions. In particular, the meshes in this chapter are adapted by using only the information coming from the primal meanflow variables, as here we are interested solely on the description of the structure of the adjoint variables. The interaction between the weakly/strongly coupled adjoint and the mesh adaptation procedure is more complex, and this is deepen in Section 5.

The HLCRM2D case

We describe here the difference between the weakly and the strongly coupled adjoints on the model problem of this section, the HLCRM2D presented in Section 2.2. The adjoint variables for both approaches are shown on a mesh of complexity of 1 024 000 vertices in Figure 3.11. Here we can see that the adjoint fields produce solutions with the same characteristic shapes, but in the case of the strongly coupled adjoint solver, these have a smaller magnitude. The explanation of this relies in the presence of the adjoint turbulence variable ν * , which balances the right-hand side of the mean-flow adjoint equations. This is shown in Figure 3.12. In the case of the strongly coupled adjoint problem, the scale value of ν * is far more wider than the scale of the other adjoint mean-flow variables. This is in accordance with the magnitude ratio of the primal turbulence variable ν and the primal mean-flow variables, as ν takes values which are remarkably lower than the other primal mean-flow variables. For this reason when solving the strongly coupled discrete adjoint system (3.25) the residual associated with ν * masks the residual coming from the adjoint mean-flow, and hence we use a simultaneous row and column scaling to normalize the resulting system [Bauer 1963a, Bauer 1963b]. We recall that the strongly coupled adjoint solution presents discontinuities in its field due to the high nonlinearity of the turbulence production and destruction, but such discontinuities cannot be noticed in Figure 3.11. In fact, these are located in specific critical regions. These are • the trailing edges of the slat and the main wing • the wake produced by the slat and the main wing • the slat and the main wing leading edge • the adjoint boundary layer. We analyze in detail each region.

Trailing edges and their wake

We show in Figures 3.13-3.14 the field of ρ * in the trailing edges of the slat and the main wing, respectively. In both cases, the strongly coupled adjoint solver produces a discontinuous line in both Weakly coupled, ρ * Strongly coupled, ρ * We can see that in this region ω z has a discontinuous derivative (i.e., it goes to zero with an angle). Furthermore, in this specific location, we have that S ω z . For this reason, the resulting r tends to go to infinity, and the same for f w . This produces the cusp discontinuity in the destruction term. Hence, the adjoint variables, when taking into account turbulence, show a discontinuity in this region. In addition to that, such discontinuities are transported in the wake, and produce the discontinuous pattern shown in Figure 3.17, e.g., in the upper part of the main wing (coming from the slat trailing edge).

Slat and main wing leading edges

In the leading edges of the slat and the main wing the adjoint variables are subjected to high gradients, and this is particularly true for the adjoint momentum variables. In Figures 3.18-3.19 we show the values of (ρu) * in these locations. Referring to the main wing leading edge in Figure 3.19, we can notice that in the case of the weakly coupled solver, the resulting solution passes from -50 to -100 with a sharp trend, while the case of the strongly coupled solver presents an abrupt discontinuity. We show the 2D plots of D, f w , r and ω z in Figure 3.20. Here, the vorticity ω z presents a steep gradient, which implies a sharp variation of f w from 0 to 2.

Adjoint field in the boundary layer

We show in Figure 3.21 a set of line plots of the weakly and the strongly coupled adjoints in the same vertical line location as in Figure 3.8. We can see that the trends of the solution provided by the strongly coupled adjoint has the same trend as the one of the weakly coupled adjoint, and it increases in magnitude as the mesh refines. The biggest difference is the presence of an angle point inside the buffer layer, which is particular beneficial when using the coupled adjoint to adapt the mesh as outlined in Section 5.

The HLPW3 case

In this section we compare the solutions obtained with the weakly and the strongly coupled adjoint solvers on a 3D geometry. In particular, we consider the HLPW3 described in Section 2.3. We show the adjoint fields in Figure 3.22 on a cutplane over the ρe profile (ρe) * , strongly coupled Figure 3.21 -HLCRM2D case: plot of the profiles of W h obtained with the weakly coupled adjoint (on the left column) and with the strongly coupled adjoint W * h (on the wing including the slat, the main wing and the outboard flap. We only show the (ρu) * variable as a representative of the adjoint momentum, as the other variables follow the same trend. Notice that in the strongly coupled adjoint solver case, ρ * and (ρe) * change sign the suction region of the flap. This effect is in acccordance with the observations in [START_REF] Papoutsis-Kiachagias | [END_REF], where the frozen turbulence (i.e., the weakly coupled) approach provides a wrong sign in the sensitivities, and this is an undesirable effect in shape optimization. Apart from that, the discrepancies between the weakly and the strongly coupled approaches follow closely the ones of the 2D case. The adjoint mean flow field shows a narrower scale in the strongly coupled case, as it is compensated by the adjoint turbulent variable ν * , which is shown in Figure 3.23 As mentioned before, in 3D cases the vorticity |ω| is unlikely to vanish far from the farfield boundaries, for this reason the discontinuities like those shown in Figures 3.15-3.17 of the 2D case are not present in such 3D case. Nontheless, the adjoint flow appears richer in details in such locations, as anyway the vorticity tends to zero (without reaching it) with a steep gradient. For instance, Figure 3.24 shows the adjoint density ρ * in the region between the slat trailing edge and the main wing. There, we can notice that the isolines of the strongly coupled adjoint indicate a steep gradient in the normal direction to the main wing surface, outward positive. On the same location, the vorticity has a high decrease, which induces the cusp shape in the destruction term, likewise to the ones shown in Figure 3.15. The same behavior appears in the main wing trailing edge (shown in Figure 3.25), but it does not seem to influence the adjoint. Eventually, in Figure 3.26 we have reported (ρu) * for both the approaches, D and ω in the region nearby the leading edge of the main wing, which shows the same trends of the HLCRM2D (see Figure 3.20). Note, anyway, that the vertex density of the HLPW3 case (10 024 000 vertices, 3D) may not be enough to fully resolve the adjoint in the shown locations, compared to the HLPW2DWC case (1 024 000 vertices, 2D). This could explain why the cusp behind the trailing edges and the thin line surrounding the main wing leading edge are not defined like the ones of the HLCRM2D.

Weakly relative to the HLPW3 case in the main wing leading edge.

Krylov space methods

We recall the form of the discrete adjoint system described in Section 3.1.1, that is

∂R h ∂W h T W * = ∂J ∂W h . (3.52)
As previously anticipated, problem (3.52) is algebraically equivalent to solve the primal linear system with CF L → ∞. For this reason, (3.52) is much stiffer than its primal counterpart. This is particularly true for • coupled turbulence adjoint,

• 3D geometries,

• a high number of vertices in the underlying mesh. For example, the maximal and the minimal eigenvalues for the HLCRM2D and the RAE2822 adjoint systems described in Section 2.2 have been computed through the power and the inverse power method, respectively, and the results are shown in Table 3.1. We can see the sole Jacobian matrix contribution provides extremely ill-conditioned systems. Another problematics which arises during the adjoint resolution, is that it requires the relative residual to be converged by a relatively high number of orders of magnitude (∼ 10 -12 ) to be effective in the context of goal-oriented mesh adaptation [START_REF] Alauzet | [END_REF].

In general, the resolution of the adjoint system takes less cpu time with respect to the primal solver, as it is equivalent to solve a single time step iteration. Anyway, for goaloriented mesh adaptation, we experienced that the adjoint solver can take much more time to reach convergence, and the adjoint resolution cpu time ends up to be comparable or even significantly higher than the one of the primal solver. For the above reasons, the standard SGS solver, which is used for the primal system, is not effective to solve (3.52), and hence it is necessary to use a more robust solver. In this section we explore different strategies to solve (3.52) by means of Krylov methods. The leading idea of the Krylov space methods is to solve a system of n linear equations Ax = b by obtaining a particular solution x * ∈ K, where K = {p 1 , p 2 , ..., p r } is a vector space of dimension r < n, that is

x * = r i=1 α k p i . (3.53)
K is generated by the matrix A as follows

K(A, r) = {b, Ab, A 2 b, ..., A r-1 b}. (3.54)
In view of practical applications, the space (3.54) is orthonormalized through the Gram-Schmidt process with respect either to the standard inner product < x, y > or by the scalar product induced by A: < x, y > A = x T Ay. The simplest representative of the class of the Krylov space method is the conjugate gradient (CG) [Hestenes and Stiefel 1952].

Here, the matrix A is assumed to be symmetric and positive definite, and the Krylov basis is orthonormalized with respect to < •, • > A . Here, we have that

p T k b = p T k Ax * = r i=1 α i p T k Ap i = α k p T k Ap k = α k ||p k || 2 A ,
and so,

α k = < p k , b > ||p k || 2 A .
CG can also be interpreted as an iterative algorithm with r maximum iterations and a residual tolerance tol. Here, we compute the weights α k and the residual on the fly through the Gram-Schmidt process (see Algorithm 1), starting from an initial guess x 0 . Note that for almost singular system, the CG method could fail when it computes the coefficients α k , as it may happen that ||p k || A 0.

Algorithm 1: CG init:

r 0 = b -Ax 0 , p 0 = r 0 for k=1, ..., r do α k = <r k ,r k > <p T k A,p k > x k+1 = x k + α k p k r k+1 = r k -α k Ap k if (r k+1 < tol) then exit loop; β k := <r k+1 ,r k+1 > <r k ,r k > p k+1 = r k+1 + β k p k

BiCGSTAB

Since the conjugate gradient methods works only for symmetric systems, this cannot be used to solve the Wolf adjoint problem. In [Fletcher 1976], an iterative method is described starting from a work on the eigenvalue computation of unsymmetric matrices in [Lanczos 1950], namely, the bi-conjugate gradient method (BiCG). Here, as A is not symmetric, two further sequences of vectors are defined, rk and pk so that they satisfy the bi-orthogonality conditions rT k+1 rk = 0 and the bi-conjugate conditions pT k+1 Ap k = 0. Hence, in this case, Algorithm 1 is modified to Algorithm 2.

Algorithm 2: BiCG init: r 1 = b -Ax 0 , p 1 = r 1 for k=1, ..., r do α k = <r k ,r> <p T k A,p k > x k+1 = x k + α k p k r k+1 = r k -α k Ap k rk+1 = rk -α k A T pk if (r k+1 < tol) then exit loop; β k := <r k+1 ,r k+1 > <r k ,r k > p k+1 = r k+1 + β k p k pk+1 = rk+1 + β k pk
The breakdown conditions for Algorithm 2 occur whenever rT k rk = 0 or pT k Ap k = 0. Algorithm 2 requires twice the number of operations as Algorithm 1, and it also requires the computation of the transpose matrix A T . In [START_REF] Sonneveld | [END_REF]], the authors describe the conjugate gradient-squared (CG-S), a modification to Algorithm 2 which allows to avoid the computation of the conjugate residual vectors rk and avoid the multiplication by the transpose matrix A T . Anyway, both the BiCG and CG-S tend to produce an irregular convergence (see, for instance, Figure 3.27), specially when the starting point is near to the solution, for instance in the final iterations of a pseudo-transient resolution. For this reason, in [van der Vorst 1992], the author describes the bi-conjugate gradient stabilized (BiCGSTAB). In such method, one notices that the sequences of residuals of Algorithm 2 can be written as r k = P k (A)r 1 and pk+1 = T k (A)r 1 , where P k and T k are polynomials in A. Hence we have that

T i (A)r 0 = (P i (A) + β k+1 T k-1 (A))r 1 , P i (A)r 0 = (P k-1 (A) -α k AT k-1 (A))r 1 .
In the BiCGSTAB algorithm, one wants recurrence relations of the type The algorithm is depicted in Algorithm 3.

r k = Q k (A)P k (A), where Q k is a polynomial of the form Q k (x) = (1 -ω 1 x)(1 -ω 2 x) • • • (1 -ω k x),
The breakdown conditions of Algorithm 3 happen whenever < r0 , r k > 0. Wolf contains an implementation of the preconditioned BiCG and the BiCGSTAB, but these work well only for 2D cases with a relatively small number of vertices. The main drawback of the BiCGSTAB is that it does not guarantee that the residual at step k + 1 is smaller than the residual at the step k, specially when dealing with ill-conditioned systems. In addition to that, in actual adaptation loops, we found out that the BiCGSTAB stalls after a certain number of meshes and makes the adjoint residual convergence extremely difficult in a reasonable cpu time. For the above reasons, the BiCGSTAB seems not to be suitable to solve accurately the adjoint problem in the context of this work.

GMRES and FGMRES

GMRES Wolf contains an implementation of the generalized minimal residual method (GMRES) [Saad andH. 1986, Saad 2003], which is a Krylov method which guarantees,

Algorithm 3: BiCGSTAB init: r 1 = b -Ax 0 , r1 = r 1 ρ 1 = α = ω 1 = 1 v 1 = p 1 = 0 for k=2, ..., r do ρ k =< r0 , r k-1 >, β = ρ k α ρ k-1 ω k-1 p k = r k-1 + β(p k-1 -ω k-1 v k-1 ) v k = Ap k α = ρ k <r 1 ,v k > s = r k-1 -αv k t = As ω k = <t,s> <t,t> x k = x k-1 + αp k + ω k s r k = s -ω k t if (r k < tol) then exit loop;
when unpreconditioned, that the residual at step k + 1 is smaller than the residual at step k. In particular, here, the idea is to find an approximate solution x * ∈ K which minimizes the norm of the residual

x * = argmin x ||b -Ax||.
(3.55)

In the GMRES method, the vectors of the basis (3.54) are orthonormalized through the Arnoldi iteration, providing an orthonormal basis {q 1 , q 2 , ...q r }, where q 1 = r 0 /||r 0 ||. In this way it is possible to express x * in the compact form

x * = x 0 + Q r y r , (3.56)
where Q r is a matrix whose rows are made with {q i } r i=1 , and y r is the vector of the coefficients of x * in the vector space K. For a given k < r, we have that

||r k || = ||b -Ax k || = ||b -A(x 0 + Q k y k )|| = ||r 0 -AQ k y k || = ||βq 1 -Q k+1 Hk y k || = ||Q n+1 (βe 1 -Hk y k )|| = ||βe 1 -Hk y k ||,
where Hk is an upper (n + 1)-Hessemberg matrix such that AQ k = Q k+1 Hk , β = ||r 0 || and e 1 is the first vector of the canonical basis in R n . At this point, the problem reduces to the minimization of ||βe 1 -Hk y k || with respect to y k , which can be accomplished through the QR factorization. In Wolf, the GMRES method is preconditioned with several SGS iterations. Such preconditioner is applied to each Krylov vector right after its orthonormalization, that is qk = M -1 q k , where M -1 represents the preconditioner and qk represents the preconditioned Krylov vector. The GMRES method requires more memory than the BiCGSTAB, as it needs to store the whole Krylov basis. For this reason, GMRES could become memory consuming for meshes with high complexity, limiting the memory of Krylov vectors. Nontheless, as the projection procedure of GMRES has used all the Krylov vectors of the basis, it is possible to restart the algorithm from the newly found solution x * , but this approach, in general, is prone to produce residual stagnation and it is not as effective as enlarging the Krylov space.

FGMRES When applying the preconditioner to the GMRES Krylov vectors, it is not necessary in principle to store both the unpreconditioned and the preconditioned vectors.

In fact, only qk are actually used in the computation. This is not the case when the preconditioner varies with the projection step k, as one can end up with a non-orthonormal basis. For this reason it is necessary to store both the sequences, and the resulting method is called flexible GMRES (FGMRES) [Saad 1993, Frayssé et al. 2008]. In the FGMRES, the user can choose a different preconditioner for each iteration step, whether iterative or not. Wolf allows the user to choose between two variants of the FGMRES, in particular the SGS-FGMRES and the GMRES-FGMRES. The first method is still based on the SGS preconditioner. We have noticed very often that when using the GMRES, the first few projections reduce the residual quite fast (in terms of cpu time) regardless of the preconditioner, and hence a high number of SGS iterations are not really needed. For this reason, such variant of the FGMRES uses a number of SGS iterations equal to the index of the Krylov projection, and these are increased up to a certain threshold (usually smaller than the number of Krylov vectors employed). In this way, we expect to reduce the cpu time. The second approach, namely the GMRES-FGMRES is based on the observation that at each GMRES iteration, there are r-k unused Krylov vectors that are still allocated in memory. In the GMRES-FGMRES approach, such vectors are used to employ a GMRES of dimension r -k which is used as preconditioner to the main GMRES routine.

Numerical tests

Five experiments have been conducted in order to assess and compare the GMRES, the SGS-GMRES and the GMRES-FGMRES. We have applied these procedures to the weakly coupled adjoint problem of the 2D cases in 2.2, namely the RAE2822, the HLCRM2D, and the NACA0012. Moreover, we have also applied the procedures to a 3D case: two meshes of different size (HLPW4-coarse, HLPW4-fine) have been considered relative to the geometry of the AIAA 4 th CFD High Lift Prediction Workshop common research model. The simulation parameters of each case are shown in Table 3 Concerning the 2D cases, we have set a Krylov space size of 200, and 40 SGS iterations as preconditioner, which is also set as the SGS iteration threshold for the SGS-FGMRES. Concerning the 3D cases, we have set a Krylov space size of 250, and 40 SGS iterations. The 2D cases are run on an Intel(R) Core(R) i9 8-Core @2,3GHz, while the 3D cases on an AMD EPYC 7742 64-Core Processor @2.25GHz. The resulting convergence trends are shown in Figures 3. 28-3.29-3.30-3.31-3.32. The conclusions for all the cases are the same. The GMRES-FGMRES has a performance which is comparable to the one of the standard GMRES in terms of iterations, but it requires much more cpu time to reach convergence. On the other hand, the SGS-FGMRES requires more iterations to converge, but it is always the faster approach in term of cpu time. Seeing these results, more complex strategies for the FGMRES should be investigated. For instance, one could compute on the fly the optimal number of SGS iterations by considering the rate of decrease of the residual ||b-Ax|| with respect to the cpu time, or even consider the GMRES-FGMRES and by maximizing the rate of residual decrease with respect to the GMRES preconditioner Krylov space size, but, in general, the variation of the number of SGS iterations seems to be the key to the problem of controlling the stiffness of the adjoint problem, while reducing the cpu time.

Algebraic Multigrid

This section is devoted to the description of the algebraic multigrid preconditioner (AMG) [Brandt et al. 1984, Stüben 2011] which has been implemented in this work, and which can be used to solve the primal system or as a preconditioner for a Krylov solver such as the BiCGSTAB and the GMRES. Even if this section does not deal directly with the adjoint problem, we choose to set it here as this is a topic closely related to the algebraic methods depicted in this section. The AMG in Wolf has not been deeply tested, but its description is instructive as it shows a wide class of algebric operations on an edge-based matrix data structure. Another motivation for the implementation of such preconditioner can be found in literature, as such method is designed to damp the lowfrequency oscillations in a solution [Stüben 2011, Falgout 2006], and has been widely tested and implemented in third-party libraries [Henson andYang 2002, Brannick et al. 2013]. It is common, when solving differential problems, that the usage of fine meshes produces high frequency errors in the solution. By coarsening the mesh, the error frequency reduces accordingly: in practice, a low frequency error on fine grids is equivalent to high frequency error on a coarse grid. It is possible to create a sequence of meshes and corresponding solutions in such a way that the error frequency is decreased. At this point, one can recursively use the solution of a coarse mesh to correct and damp the low-frequency error produced by using a finer mesh. This procedure, in general, is known as geometric multigrid. In the context of mesh adaptation, for instance, one can exploit the adaptation loop which already generates a sequence of meshes of increasing complexity, and to use the coarse mesh solutions to correct the fine mesh ones. Such procedure is deepen, for instance, in [Menier 2015]. AMG does not rely on meshes, but it only uses the linear system quantities, and follow closely the ideas behind the geometric multigrid. More precisely, assuming a two-levels AMG scheme, we consider a linear system

A f x f = b f , (3.57)
of dimension n and its coarse counterpart

A c x c = b c , (3.58) of dimension m < n.
The coarse level can be computed by introducing an interpolation operator P ∈ R m×n such that

P T A f P = A c , P T v f = v c , Pv c = v f , for any v f ∈ R n and v c ∈ R m .
The resolution steps are based on the cancellation of the smooth fine-grid error component e f by means of the coarse system, see Algorithm 4. Note that at the end of Algorithm 4, it is also possible to apply several SGS iterations to the fine system, as this process is also known as post-smoothing. Such algorithm shows a 2-step Algorithm 4: 2-step AMG init:

A c = P T A f P Apply SGS to A f x f = b f r f ← b f -A f x f Interpolate r c = P T r f Apply SGS A c e c = r c Interpolate e f = P e c x f ← x f + e f
AMG, meaning that there is only one fine and one coarse mesh. In principle, it is possible to treat the coarse system A c e c = r c as a fine system to which apply a coarser smooth error correction. In this way it is possible to create a sequence of progressively coarse systems to which apply the AMG. In general, the coarsest system is enough small that it is possible to solve it with a direct method, for instance in Wolf new levels are created until the number of variables of the coarsest system is 40. Furthermore, it is possible to switch from one system to another in several different way. The sequential resolution of the coarse systems and the relative back interpolation to the fine systems is also known as V-cycle. When arrived at an intermediate level one can, for instance, apply a post-smoothing and get back to the subsequent coarse system instead of back interpolating to the fine one. This gives the possibility to create two further types of AMG cycles: the W-cycle and the F-cycle. These are depicted in 3.33.

In general, the way the interpolation operator P is defined, identifies a type of AMG. Wolf has two different types of interpolation, which give the classical AMG (C-AMG) and the aggregation based AMG (G-AMG).

Classical AMG (C-AMG)

In the classical AMG (C-AMG), the interpolation operator P is based on an heuristic observation. In fact, it has been noticed that in iterative solvers, some variables (or, points), have a strong impact in determining the value of the other points. Such points are called C-points and belong to the set C, while the other points having a weak influence are called F-points and belong to the set F. As an example, in [Stüben 2011] it is shown that for a symmetric diagonal dominant matrix A and for a low-frequency error e, we have

i =j a ij a ii (e i -e j ) 2 e 2 i << 1, (3.59)
that is, algebraically smooth error varies slowly in direction of large (negative) connections. This leads to the definition of influence set of a point i, (3.60) which represents the points j having an influence on a point i. Usually, the parameter α is set to 0.25. We also define S T i = {j = i : i ∈ S j }, that is, the set of points dependent on i. In order to assemble the set C, one usually start by selecting few C-points, and then assigns its influenced points to the set F. Then, another point is selected from the set of the undecided variable, it is marked as a C-point, its influenced points are assigned to the F set, and so on. In order to make a uniform selection, such process must be done in a

S i = {j = i : a ij ≥ α max k =i (-a ik )},
Finest system

2 nd level 3 rd level Coarsest system (direct solver) (a) V-cycle
Finest system certain order. By defining as U the set of the undecided variables, we give to each points a measure of importance (3.61) which represents how much a point is valubale to become a C-point. By denoting the set of all the points by Ω, the selection algorithm is shown in Algorithm 5.

2 nd level 3 rd level Coarsest system (direct solver) (b) W-cycle
λ i = |S T i ∩ U | + 2|S T i ∩ F | ∀i ∈ U,
Algorithm 5: C-AMG variable selection init:

F = ∅, C = ∅, U = Ω init: λ i = |S T i ∩ U | + 2|S T i ∩ F | ∀i ∈ U while U = ∅ do pick i ∈ U with max λ i : C = C ∪ {i}, U = U \{i} ∀j ∈ S T i ∩ U : F = F ∪ {j}, U = U \{j} Update λ i ∀i ∈ U
In Wolf, the Algorithm 5 is executed in serial, because at each step the maximum of the array of λ i is computed and the remaining values must be updated. Anyway, the execution of such algorithm requires a small amount of cpu time with respect to the adjoint resolution. The interpolator P is defined by using the C and the F sets. In particular, one assumes that the error at a point i is mainly determined by a weighted average of the error at its strong neighbors, that is

e i = k∈P i w ik e k , ∀i ∈ F.
(3.62)

We rely on the direct interpolation approach of [Stüben 2011], where the weights w ik have the form

w ik = -α i a ik a ii , ∀i ∈ F, ∀k ∈ C ∩ N (i) α i = j∈N (i) a ij k∈C∩N (i) a ik ,
where N (i) denotes the points connected to the point i, and w ii = 1 ∀i ∈ C. The Jacobian of Wolf is represented through a block matrix, and hence each point represents a whole block rather than a scalar. In this way, it is possible to identify each point/variable of the fine system with a single mesh vertex, but in any case the entries of the interpolator P are scalar. For further detail about the definition of influence points of block matrices, see [START_REF] Griebel | [END_REF]]. During the implementation of the C-AMG, Wolf relied on the edgebased data structure for representing the Jacobian matrix of the primal and the adjoint systems. For this reason, the restriction operation P T A f P is performed by navigating the mesh. By relying on the Einstein's notation for algebraic operations, we have that

[A c ] ij = [P T A f P] ij = p ki a f,kl p lj , i, j ∈ C, k, l ∈ Ω. (3.63)
Such triple matrix product produces a new matrix data structure and a mesh which does not represent an actual mesh, as it could not be even a planar graph. Such product is performed by dividing three types of contributions, which are identified in three possible ways to create a path between the node i and the node j in the coarse matrix through the nodes of the fine matrix: On the left the extra-diagonal contribution (i = j), on the right the diagonal contribution (i = j) to the coarse matrix. Here, i and j are C-points, while k is an F-point.

• 3-path contribution: in this case the node i and the node j are connected through three different edges of the fine mesh, i -k, k -l, and l -j, where k and l are points belonging to the F set. The stencil is shown in Figure 3.34 for both the extra-diagonal and the diagonal contributions • 2-path contribution: i and j are connected through one F-point only, say k. Here, such path provides two contributions: p ki a f,kj and a f,ik p kj . The stencil is shown in Figure 3.35 • 1-path contribution: this is a purely diagonal contribution which adds the diagonal entries corresponding to C-points of the fine matrix to the diagonal entries of the coarse matrix.

The computation of the 3-path contributions is pursued by looping on the edges of the fine mesh, and with two inner nested loops over the neighoring C-points of the endpoints of an edge. This avoids the computation of the second order neighbors of the vertices, hence reducing the memory consumption. The computation of the 2-path is pursued by iterating over the F-points of the fine mesh, and by performing an inner loop over its neighboring C-points. The computation of the 1-path is a simple for-loop over the C-points of the fine mesh, without any nested loop. The C code written in Wolf has been validated with a C++ simple code based on dense matrices by comparing the results produced by both the implementations on small systems. The overall structure of the C-AMG is difficult to parallelize and the code maintainance is hard. For this reason, another type of the AMG solver is implemented, namely, the aggragation based AMG (G-AMG).

Aggregation based AMG (G-AMG)

The aggregation based AMG (G-AMG) is a different type of AMG which does not rely on the definition of the C and F sets. In fact, here, the nodes of the fine mesh are aggregated recursively into groups representing the nodes of the coarse mesh [Emans 2015]. One group G i is connected to another group G j if there is an edge of the fine mesh going from i to j. An example of group aggregation is shown in Figure 3.36. In this context, the interpolator P is simply defined as

P ij =    1 if i ∈ G j , 0 otherwise, (3.64)
and hence

[A c ] ij = [P T AP] ij = k∈G i l∈G j a kl .
(3.65)

In Wolf the partition into groups is accomplished through a breadth-first search algorithm, which groups neighboring vertices, as this allows to aggressively coarsen the system for each level.

Mach number Mesh

Figure 3.37 -NACA0012 (subsonic) AMG test case: Mach number on the left, mesh on the right.

AMG applied cases

Concerning the applications, the C-AMG has been tested for several matrices taken from the SuiteParse matrix database [Kolodziej et al. 2019] and for several primal and adjoint systems from Wolf. In terms of iteration, the C-AMG works better than the classical SGS, but a comparison is difficult as, in practice, the AMG employs several SGS resolutions internally, on systems of different size, and hence often the AMG requires more cpu time to reach convergence with respect to the pure SGS. We have applied the C-AMG as a linear solver to compute the primal flow on a set of five cases in order to illustrate its strenghts and weaknesses. We present here this topic as the AMG was primarly intended to be used to solve the adjoint problem. The cases are the NACA0012, run with an Euler flow on an uniform mesh in subsonic conditions, and on an adapted mesh in transonic conditions, and a multi-element airfoil M3V4, again, over two different meshes (uniform and adapted), and to the HLCRM2D at α = 8, on an adapted mesh. The parameters are shown in Table 3.3, where N SGS represents the number of pre-and post-smoothing SGS iteration in the C-AMG solver, or the number of plain iterations of the SGS solver. All the cases restart from a uniform solution field. For all the cases, except for the HLCRM2D one, we have also the G-AMG results. The Mach number field of the primal solution along with the computational mesh for all the cases are shown in . The convergence of the ρ-residual is shown, for each case, in Figures 3. 42-3.43-3.44-3.45-3.46. As expected, we can see that the AMG solvers require more time to run the simulation, where the G-AMG is slightly faster, but anyway the AMGs are generally able to reach convergence with fewer iterations. Concerning the NACA0012 cases and the M3V4 case on a uniform mesh, the resulting convergence is basically the same for any solver, with the exception of the G-AMG in the transonic NACA0012 benchmark, as here a sudden solver divergence happens around the 800 th iteration, and the CF L is increased to compensate such behavior. In these cases, the AMG is not beneficial. The M3V4 case with an adapted mesh appears quite interesting: the plain SGS solver provides a trend characterized by steady oscillations, and here both the C-AMG and the G-AMG are able to converge the residuals. A similar phenomenon happens in the HLCRM2D case: here the SGS solver stagnates on an unconverged solution, while the C-AMG is able to reduce properly the residuals. Concerning the application of the AMG algorithms as preconditioner to the resolution of the adjoint, we found out that it is not beneficial. Often, the interpolation operator moves the solution away from the real solution, and if it works, it is not competitive with the plain SGS preconditioner to the GMRES/FGMRES. We also tested BoomerAMG of the Hypre library [Henson andYang 2002, Falgout andYang 2002], but it produces results in accordance with the ones of Wolf concerning the adjoint systems. Hence, we do not recommend the AMG to precondition (3.52).

Mach number Mesh

Pseudo-transient continuation

We recall here that the adjoint system (3.52) inherits the stiffness of the primal flow linear system without the mass matrix contribution (that is, for CF L → ∞). Such problem, in the primal solver, is circumvented by acting on the mass contribution of the system, as the diagonal dominance of the matrix can be tuned through properly setting the CF L, while this cannot be done a priori for the adjoint problem. In addition to that, Krylov methods like the GMRES do not get any benefit by restarting from a field which is near the actual solution, making the interpolation from a previous valid field uneffective. Mseshes with a high number of vertices require the istantiation of a great number of Krylov vector to convergen properly, and such number is often infeasible for standard computers. And, when using a reduced number of Krylov vectors, we noticed that the GMRES adjoint solver stalls on a high residual. The corresponding adjoint solutions, having a high residual, show a totally degraded adjoint field, which, in turn, affects negatively any adjoint-based mesh adaptation. For the above reasons, we describe here the so-called pseudo-transient adjoint solver (PSTR), and the main part of this work is taken from [Clerici and Alauzet 2021]. The idea behind the PSTR solver is that if the algorithm for the computation of the primal solution reaches the convergence, then the same algorithm (characterized by the same time accuracy, CFL, relaxation strategies, cells measure, ...) applied to a transient adjoint equation should provide a steady state accordingly [START_REF] Giles | [END_REF], Nielsen et al. 2004, Pini 2013]. The transient discrete adjoint equation reads as

M ∂W * ∂t + ∂R h ∂W h T W * - ∂J ∂W h = 0, (3.66)
where M is the mass matrix including the area or volume information of the cells and the time step. Within this context, we solve (3.66) in a way that it reaches a steady state, which solves exactly the adjoint problem. Since the mass matrix M is trivially invertible, equation (3.66) can be interpreted as a system of linear ODEs of the form

ẋ + Ax = b. (3.67)
The solution of (3.67), when A is invertible and x(0) = 0, reads as

x(t) = x s + e -At (x(0) -x s ), (3.68)
where x s is the searched stationary solution, Ax s = b, and

e B := ∞ m=0 1 k! B k . (3.69)
Hence, the convergence depends on the eigenvalues of the matrix A. All the eigenvalues must be positive. For an ill-conditioned matrix, we could have at least one small eigenvalue that will slow down the convergence to a steady state. In the most extreme case, that is when the matrix A is singular, the general solution to (3.67) reads as

x(t) = e -At x(0) + t 0
e -As bds.

(3.70)

Hence, any solution satisfying Ax = b depends on the initial value x(0). This fact is particularly important as, in this way, the PSTR resolution is dependent of the initial guess. If we discretize (3.66) by means of a backward Euler scheme, we get

M dt ([W * ] n+1 -[W * ] n ) + ∂R h ∂W h T [W * ] n+1 - ∂J ∂W h = 0, (3.71)
and hence,

M dt 1 + ∂R h ∂W h T [δW * ] n = ∂J ∂W h - ∂R h ∂W h T [W * ] n . (3.72)
We remark that

[W * ] n = n-1 k=1 M dt 1 + ∂R h ∂W h T -k ∂J ∂W h , (3.73)
hence, (3.73) converges to a steady state if

∀i, λ i M dt 1 + ∂R h ∂W h T > 1.
(3.74)

The condition (3.74) can be reached by setting a proper CF L. Hence, this suggests to start from a low CF L value, and then increase it until the residual at step n, given by

R n adj = ∂J ∂W h - ∂R h ∂W h T [W * ] n , (3.75)
becomes bigger than the residual at step n -1 (meaning that the solution is diverging). Something very similar is done on the primal solver too. Note, anyway, that no divergence should happen when the Jacobian ∂R h ∂W h is not ill-conditioned. In any case, provided that the system (3.72) is solved exactly, the convergence to a steady state is guaranteed. If this is the case, the difference between two consecutive solutions at step n and n -1 is given by

||[δW * ] n || = M dt 1 + ∂R h ∂W h T -n ∂J ∂W h , (3.76)
hence, provided all the hypothesis, we expect ||[δW * ] k || to converge to zero monotonically. The linear system (3.72) is solved using several SGS iterations, which does not ensure the convergence to a steady state and does not ensure (3.76) to converge to zero monotonically.

To solve this issue, one can choose a rather low CF L in order to enforce the diagonal dominance of the matrix M dt 1

+ ∂R h ∂W h
T and hence reach a high accuracy in the SGS solver by using a fixed number of iterations, but this slows down the convergence of the quantity (3.75). Because of these considerations, the CF L should be chosen in order to reach a proper balance between the rate of convergence to a steady state (high CF L) and an accurate resolution given by the SGS solver (low CF L). To this aim, we note that the residual associated to the SGS resolution of (3.72) is given by

R n sgs = ∂J ∂W h - ∂R h ∂W h T [W * ] n - M dt 1 + ∂R h ∂W h T [δW * ] n . (3.77)
It has two contributions: one is the adjoint residual, the other is a source of error due to the time step,

∆R n = - M dt 1 + ∂R h ∂W h T [δW * ] n , (3.78) hence, R n adj = R n sgs + ∆R n . (3.79)
We cannot control (3.78), but we can control R n sgs by reducing the CF L and/or increasing the number of SGS iterations. We rely on the first approach, and we tune automatically the CF L as follows,

CF L n+1 =      m cf l CF L n , if 10||R n sgs || ≤ ||∆R n ||, CF L n m 4 cf l , otherwise .
(3.80)

The parameters of (3.80) have been obtained with several numerical tests. That is, we multiply once the CF L by m cf l if the SGS residual contribution to R n adj is less than 10 times the ∆R n contribution, otherwise we scale it by m 4 cf l , hence adding diagonal dominance to the system. In this way, we are able to target the optimal CF L value which makes the convergence fast and ensure that the SGS solver properly converges. In practice, the CF L is started at a value of 0.1, and its maximal value is set to the same maximal value of the primal solver CFL. m cf l is inherited too from the primal solver. We have applied the PSTR methodology to the 2D cases of Section 2.2, and Figures 3. 47-3.48-3.49 are showing the CF L evolution and the two contributions of (3.79) to the adjoint residual. We can see that in the RAE2822 and the NACA0012 cases the CF L is monotonically increased up to its maximal value as R sgs is always suitably smaller than ∆R. This is not the case with HLCRM2D, in which the SGS residual has a sudden increase Anyway, in general simulations, we experienced that the PSTR suffers from the same drawbacks of the BiCGSTAB. It is usually slower than the GMRES-based methods, and it is not able to converge the adjoint residual of more than 2 or 3 orders of magnitude on cases with a high number of mesh vertices or with particularly stiff Jacobians. Nontheless, thanks to its restart properties, we found out that it is actually a good alternative to GMRES when this fails.

To this aim, we have considered the HLCRM2D airfoil case, and we have set the Mach number to M = 0.2, the Reynolds number Re = 5.0 × 10 6 and α = 8. We have employed a full adaptation loop starting from 4000 vertices and ending up to 4096000. We have performed two adjoint computations: one with a GMRES preconditioned with 40 SGS iterations, and the other with the PSTR using at most 40 SGS iterations as linear solver. The computation on a new mesh is restarted with the solutions W h and W * of the previous mesh, suitably interpolated [Alauzet and Mehrenberger 2010]. If such interpolation is convenient with the PSTR, on the other hand it seems that there is no advantage to restart the adjoint solution for the SGS-GMRES solver, and in this case W * is set to zero before the resolution. We show the lift-converged solutions at complexities of 1, 2 and 4 millions of vertices in Figures 3.50, 3.51 and 3.52. As we can see, the GMRES is able to reach a proper convergence for a complexity of 1 million of vertices (it succeeds also for lower complexities), but it starts degrading the adjoint solution after this point. The pseudo-transient algorithm, on the contrary, is not GMRES R adj = 4.07 × 10 -2 , cpu = 1h22m57s PSTR, R adj = 3.10 × 10 -3 cpu = 29m40s To sum up,

• the PSTR is able to control the convergence of the SGS solver through the automatic modification of the CF L; • the PSTR is able to restart from a valid adjont solution, contrary to the GMRES, which does not benefit from this; • anyway, the PSTR is much less robust than the GMRES, specially for stiff problems;

• the PSTR provides still better solutions than the GMRES if this stagnates.

Conclusions

In this chapter, we have defined the adjoint problem associated with the RANS equation. We have characterized the adjoint solution in terms of a Lagrange multiplier in optimization processes, and as a sensitivity measure of a functional to be optimized under certain constraints. We have shown several examples in aeronautics, concerning shape optimization and discretization error estimation, where the adjoint problem is particularly useful. Wolf includes an implementation of the discrete adjoint problem associated with the discretized RANS equations, as the same routines for computing the primal flow field are used to assemble the adjoint system. In addition to this, the discrete adjoint is in general sharper than the continuous one, and provides more precise derivatives, at least in the application of shape optimization.

Concerning the adjoint characterization, we have shown that the adjoint solution flows from downstream to upstream, and that there is a strong dependency between the adjoint magnitude and the mesh size. Such dependency does not always show up, and this issue should be still investigated. Concerning the comparison between the weakly cand the strongly coupled turbulence adjoints, we have shown with one 2D and one 3D examples the main differences between the two approaches. The adjoint solution shows a discontinuous derivative inside boundary layers, and also in the regions around the trailing edges and their wake, as these effects are due to the sharp variations of the Spalart-Allmaras destruction term in these specific regions.

Concerning the resolution of the adjoint problem, as this cannot be solved by means of SGS iterations, we depicted several Krylov space-based methods such as the BiCGSTAB, the GMRES and two variants of the FGMRES. Among these, the most promising resolution strategy is the SGS-FGMRES, that is, the flexible GMRES where the preconditioning SGS iterations number increases after each FGMRES iteration. Future studies could include the an optimal tuning of the number of the SGS preconditioning iterations, possibly taking into account the cpu time. In the context of the linear algebra solvers, we have also introduced two different types of algebraic multigrid, which could be useful in some cases where the standard SGS solver provides a stagnating residual, but further studies should be pursued. Eventually, we have described and tested the pseudo-transient continuation algorithm, which turned out to be particularly useful when the GMRES fails to converge reaching stagnation. In fact, the GMRES stagnation provides deteriorated adjoint solutions which have a bad impact on mesh adaptation. The pseudo-transient continuation allows to preserve the original adjoint structure and, at the same time, to reduce the relative adjoint residual of at least three orders of magnitude.

Chapter 4

Mesh adaptation

This chapter serves as an introduction to Chapter (5) by presenting a mathematical formulation that links a computational mesh to an interpolation error of a function defined on the mesh. This formulation provides the fundamental tools needed to describe the goaloriented anisotropic mesh adaptation procedure, which forms the core of the content in (5).

More in detail, we first introduce the basic tools to describe completely an anisotropic mesh from two equivalent perspectives: the discrete and the continuous mesh framework. After this, we show how it is possible to minimize the interpolation error of functions defined on the considered mesh with respect to the quantities characterizing the local mesh directions and shapes from a continuous point of view. Concerning the nomenclature, we indicate as Ω the continuous domain, and as Ω h the discrete one, we use H to refer to a mesh, and use interchangeably K to indicate a subset of the continuous domain Ω or a tetrahedron belonging to H. We indicate as Π a general piecewise linear interpolation operator taking in input suitably smooth functions defined on Ω and mapping them to the space of piecewise linear functions on Ω or H, and we use N to indicate the number of vertices of a mesh H and with C the complexity of a continuous mesh (which, as we show, is equivalent to N in the case of a discrete mesh).

This chapter is organized as follows: in Section 4.1, along the lines of [Frazza 2018], we describe a simple 1D purely turbulent diffusive problem and how it is possible to rearrange the points of the underlying mesh in order to minimize an interpolation error; in Section 4.2 we describe briefly the concept of Riemannian metric space, which represents the basic mathematics to handle continuous meshes and interpolation oeprators; in Section 4.3 we introduce the continuous mesh framework which includes the description of a continuous mesh and defines the continuous interpolation operator; in Section 4.4 we describe the socalled multiscale mesh adaptation, which allows to control the L p norm of the interpolation error of a sensor function with respect to the mesh entities.

Error minimization of 1D purely diffusive turbulence

The objective of this section is to introduce the basic concepts which are used to adapt a computational mesh in order to minimize the interpolation error of a sensor function associated with a differential problem, by using a 1D example. In particular, we rely on the 1D Spalart-Allmaras purely diffusive parabolic problem, which reads as

∂ν t ∂t = 1 σ ∂ ∂y (ν + ν t ) ∂ν t ∂y + c b2 σ ∂ν t ∂y 2 in R × (0, T ] ν t (y, 0) = ν 0 1 - y 2 δ 2 0 on R. (4.1)
An analytical solution to (4.1), provided ν = 0, is

ν t (y, t) = ν t,max (t) 1 - y 2 δ 2 (t)
, where ν t,max (t)

ν 0 = 1 + 2ν 0 (3 + 2c b2 )t σδ 2 0 -1 3+2c b2 , δ(t) δ 0 = 1 + 2ν 0 (3 + 2c b2 )t σδ 2 0 1+c b2 3+2c b2 .
Here, we recall that σ = 2 3 and c b2 = 0.622. The numerical solution to (4.1), which is called ν t,h , is obtained by applying a centered second order finite differences for the space discretization, while we use the backward Euler scheme concerning the time discretization,

ν n+1 t,h -ν n t,h = ∆tR h (ν n+1 t,h ), (4.2)
where R h is the discrete counterpart of the right-hand-side of (4.1), and the solution to (4.2) is obtained by using the Newton method. In the sequel, we use ν 0 = δ 0 = T = 1, and ∆t is dynamically set to the maximum value allowing a convergence of the Newton method to (4.2) within 20 iterations. The stopping criterion of the Newton method is a threshold of 10 -12 on the value of

||ν n+1 t,h -ν n t,h -∆tR h (ν n+1 t,h )||. Problem (4.
2) is solved on Ω h = (-20δ 0 , 20δ 0 ), and we set homogeneous Dirichlet boundary conditions at x = ±20δ 0 .

Our objective concerning problem (4.2), is to find a suitable discretization H so that, for each fixed t, we realize the minimum of the L p norm of the linear interpolation error associated with ν t , that is

||ν t -Π h ν t || p = Ω |ν t -Π h ν t | p dx 1 p , (4.3)
under a constraint on the number of points (to avoid zero-length elements), hence C(H) = N . Here, Π h is the linear interpolation operator. By developing (4.3) with a Taylor expansion on each element [y i , y i+1 ], the constant and the linear terms vanish, and one ends up with the expression

y i+1 y i |ν t -Π h ν t | p dx 1 2p + 1 ν t (y m ) 4 p h 2p+1 i , (4.4)
where y m is the middle point of [y i , y i+1 ] and h i its length. We can note that the right hand side of (4.4) is multiplied by the length of the segment [y i , y i+1 ]. Such quantity is constant for each element of Ω h , but we can generalize this concept by introducing a continuous element length which varies as a function of x, and we indicate such quantity as l(y). Hence, we can see (4.4) as the approximation of an integral including l(y), that is

1 2p + 1 ν t (y m ) 4 p h 2p+1 i 1 2p + 1 y i+1 y i ν t (y) 4 p l(y) 2p dx. (4.5)
In this formula, function l(y) is also called Riemannian metric, and provides the length of any interval as

l([a, b]) = b a l(y)dx.
We note that for a uniform discretization of Ω (of unitary lenght), we have that the number of elements N is given by

N = 1 h , (4.6)
where h is the length of a single segment. In the same way we deduce

N = Ω 1 l(y)
dx.

(4.7)

We are now able to minimize (4.3). This can be pursued in two different ways. In the first one, one considers the discrete description of the mesh, and hence minimizes the right hand side of (4.4) under the contraint (4.6), but this can become computationally prohibitive, specially in 2D or 3D cases when using direct optimization, where the number of degrees of freedom is high. One can, instead, rely on (4.5) under the constraint (4.7), and hence ending up within a continuous formulation, which has a unique solution. We choose to pursue with the continuous framework, because it is more flexible and it is easier to express the constraint on the number of elements. By performing a minimization process through the Lagrangian function, one ends up with

l(y) = |ν t (y, t)| -p 2p+1 N Ω |ν t (s, t)| p 2p+1 ds ∀t ∈ (0, T ]. (4.8)
Expression (4.8) requires to know the exact value of the solution ν t , which could not be available like for instance in the RANS case. In a numerical context, one can use an appropriate reconstruction of the solution ν t of (4.1) at fixed t into (4.8) to get an optimal discretization H by looking for that mesh whose elements are unitary with respect to (4.8), that is

y i+1 y i l(y)dx = 1, ∀i = 1, ..., N. (4.9)
We conclude this introductive section by showing the numerical results associated to problem (4.1) and the adaptation method based on (4.8). We perform four simulations of problem (4.2) by optimizing the mesh as described, with the L 1 , L 2 , L 4 and L ∞ norms. We have written a program in C++ to compute the solution and to adapt the mesh. Concerning the mesh adaptation part, such process is done by estimating the second derivative of ν t , e.g. ν t , with the L 2 projection gradient reconstruction, and all the optimal vertex positions have been computed starting from the left boundary point of the domain and using a bisection method to target the exact unitary length l(y i ), until the last point on the right is reached. Before that, a gradation limiting algorithm [Alauzet 2010] is applied to reduce the gradation rate of the continuous element size l(y) in the mesh, in particular we aim at correcting a metric field in such a way that

1 α ≤ l(y i ) l(y i+1 ) ≤ α, ∀i = 1, ..., N -1 (4.10)
where α > 1. In this way the size variation of the mesh is kept below α, which, in this case, is set to 1.6. For each experiment, we set N to 25, 50, 100 and 200, but here only the results with N = 200 are presented. The mesh is adapted at each time step, and the solution ν t,h is transferred from the mesh at time t n to the mesh at time t n+1 by using a conservative interpolation [Alauzet and Mehrenberger 2010] (meaning that no turbulent viscosity is created nor destroyed in the interpolation process). The numerical solution, the true solution and the optimal meshes at T = 1 are shown in Figure 4.1 in the right-corner location of the parabola, for all the four kinds of interpolation. We can see that as p increases, the adaptation produces a sharper point cluster on the corner of the parabola, i.e., where the real solution shows a discontinuous derivative. This fact happens also in 2D and 3D context: for low p, the mesh is adapted also on regions with low variations, while for high p the mesh is adapted preferencially on regions with high variations. In any case, what we have done here is the adaptation of the mesh on a transient solution for each t. It is possible to include also the time variation of the solution in the mesh adaptation process, but this is beyond the scope of this work. For furher reading about the adaptation of transient problems, see [Belme 2011]. In this section we have anticipated several concepts which are formalized rigorously in this chapter, that is,

L 1 L 2 L 4 L ∞
• the concept of Riemannian metric space, and the concept of discrete and continuous element length, • the concept of discrete and continuous linear interpolation errors,

• the concept of L p mesh adaptation, also known as multiscale adaptation.

Riemannian metric spaces

In this section, we describe the Riemannian metric spaces, which provide the basic mathematical tools to describe a continuous mesh and the continuous linear interpolation.

The context that we use here is the continuous mesh framework [Loseille andAlauzet 2011a, Loseille andAlauzet 2011b]. We depict such framework in a 3D context, and we explicitly write the expressions in 2D when these are not trivial to be derived. In any case, this context can be generalized to any dimensionality.

Consider a symmetric positive definite (s.p.d.) matrix M ∈ R 3×3 . With this entity, it is possible to define a scalar product

< x, y > M =< x T M, y >, (4.11)
and since M is s.p.d., it also induces a norm from (4.11), ||x|| M = √ < x, x > M . The coupling between R 3 and M is called normed vector space, and it is indicated by

(R 3 , || • || M ).
Within this framework, we can measure volumes and lengths in R 3 thanks to definition (4.11), for instance, for a given subset K ⊂ R 3 we have

|K| M = K det(M)dK = det(M)|K| I ,
where the subscript I refers to the Euclidean metric. For a given segment e, we have

l(e) = ||e|| M .
Consider a tetrahedral mesh H. In such a case, the volume of a tetrahedron K having edges of unitary length is given by

|K| M = √ 2 12 det(M). (4.12)
Since M is s.p.d., this can be diagonalized as

M = R T ΛR, (4.13)
where R = [e 1 , e 2 , ..., e n ] denotes the set of the eigenvectors and Λ = diag(λ 1 , λ 2 , ..., λ n ) the set of its eigenvalues. The eigenvalue decomposition of M helps to visualize how M modifies lengths and volumes in 2D. To do that, we observe that λ i = h -2 i , where h i are the lengths of the vectors obtained by the action of M -1 2 on the unit vectors of the canonical basis. This fact can be easily visualized as the action of the map M -1 2 on the points of the unit ball in R 2 , see Figure 4.2.

When M varies smoothly in R 3 , we are dealing with a Riemannian metric space M = M(x). Provided such definition, M can be used as well to compute the length of any segment, which is a critical computation in the context of mesh adaptation. Given a segment ab and its linear parametrization

γ(t) = a + tab, with t ∈ [0, 1], we have R 2 , I2 R 2 , M M 1 2 M -1 2 e1 e2 e1 e2 h1 h2 1 1 Figure 4.2 -Action of the metric M on the unitary ball in R 2 . M1 M2 M1∩2 Figure 4.3 -Example of 2D metric intersection between M 1 and M 2 , giving M 1∩2 , in red. l M (ab) = 1 0 ||γ(t)|| M dt = 1 0 ab T M(a + tab)abdt, (4.14)
as well as volumes, given by

|K| M = K det(M(x))dΩ. (4.15)
Given two metrics M 1 and M 2 , we define two central operations that turn out to be extremely useful when dealing with mesh adaptation: metric intersection and metric interpolation. Metric intersection is needed when one wants to define a metric M 1∩2 which inherits the most restrictive directions from M 1 and M 2 . If we consider its action on the unit ball, M 1∩2 defines the biggest ellipse which contains the intersection between the ellipses provided by M 1 and M 2 . Figure 4.3 shows an example of such operation in 2D. In order to define metric intersection, we need to apply a transformation to the metrics M 1 and M 2 so that they share the same eigenvector basis, so that, we can select the maximal eigenvalues (or, the minimal distances) of their decomposition, and hence obtain the searched intersection. Consider M -1 2 and define

M 1 = M -1 2 ,T 1 M 1 M -1 2 1 ≡ 1, M 2 = M -1 2 ,T 1 M 2 M -1 2 1 .
Then, consider the eigenvalue decomposition of M 2 (4.16) since the columns of P are orthonormal, we can use them to provide the eigenvalue decomposition of M 1 , that is M 1 = 1 = P1P T . Hence, we define the transformed intersected metric

M 2 = P     λ 1 0 0 0 λ 2 0 0 0 λ 3     P T ,
M 1∩2 = P     max(1, λ 1 ) 0 0 0 max(1, λ 2 ) 0 0 0 max(1, λ 3 )     P T .
At this point we can transform back the intersection with

M 1∩2 = M -1 2 ,T 1 M 1∩2 M -1 2 1 to obtain the desired result.
Concerning metric interpolation, we need such tool as, in practical applications, the metric field M(x) is a piecewise linear function defined on the vertices of a mesh. Hence, when we want to compute, for example, the lengths of the edges of a mesh, we should use suitable interpolated values to get the values of M(x) in between the edge endpoints. We define the logarithmic addition ⊕ and the logarithmic scalar multiplication between two metrics M 1 and M 2 as

M 1 ⊕ M 2 = exp(log(M 1 ) + log(M 2 )), α M = exp(αlog(M)), (4.17)
where the matrix logarithmic and exponential are given by

log(M) = Rlog(Λ)R T , exp(M) = Rexp(Λ)R T .
The space of metrics equipped with (4.17) forms a vector space. We define the interpolation of M in a point x = n i=1 α i x i , with n i=1 α i using {M(x i )} n i=1 as

M(x) = n i=1 α i M(x i ) = exp n i=1 α i ln(M(x i )) . (4.18)

Continuous mesh framework

In this section, we describe the continuous mesh framework, which, since its first formalism in [George et al. 1991], allows to introduce a duality between the discrete and the continuous meshes and interpolations. In particular, such framework allows to easily define and generate adapted meshes, specifically when one wants to minimize linear interpolation errors. In particular, the leading idea is the concept of unit mesh. In fact, by using such concept, the target of this section is to identify a continuous mesh with a collection M = (M(x)) x∈Ω , i.e., a Riemannian metric space, such that the corresponding discrete mesh is unitary with respect to it. Hence, we provide the definition of complexity, unit element and unit mesh with respect to a metric field M(x). Since we assume that M(x) is s.p.d. for each x ∈ Ω, we can write its eigenvalue decomposition. In particular, we write it by using the following form

M(x) = d 2 3 (x)R(x)     r -2 3 1 (x) r -2 3 2 (x) r -2 3 3 (x)     R(x) T , (4.19)
where the density

d is d = (h 1 h 2 h 3 ) -1 = (λ 1 λ 2 λ 3 ) 1 2 and r i = h 3 i (h 1 h 2 h 3 ) -1 , h i = λ -1 2 i
are the principal directions of the metric M and λ i its eigenvalues. The density represents the accuracy of the metric M(x), that is, a scalar value multiplying M which does not modify its anisotropic properties (like ratio and orientation), but only the size. We define the complexity of M,

C(M) = Ω d(x)dx = Ω det(M(x))dx.
(4.20)

Expression (4.20) can be interpreted as the continuous counterpart of the numer of vertices of a discrete mesh. We say that two metrics M and N are embedded when there exists c ∈ R such that

N (x) = cM(x), ∀x ∈ Ω.
By using the notion of embedded spaces, we can suitably rescale a continuous mesh in order to target a complexity N

N (x) = N C(M) M(x). (4.21)
In (4.21), the continuous meshes N and M have the same anisotropic properties (meaning, the directions and the orientations), but a different size. In order to provide the notion of unit mesh, we give the following Definition 4.3.1. A tetrahedron K with edges (e i ) 6 i=1 is said to be quasi-unit with respect to

M(x), if 1/ √ 2 ≤ l M (e i ) ≤ √ 2.
Hence, the notion of unit mesh is given by Definition 4.3.2. A mesh H is said to be unit with respect to M(x) when all of its elements are quasi-unit with respect to M(x).

The necessity to use quasi-unit elements instead of unit ones (i.e., when all the edges of a tetrahedron have exactly length 1 with respect to M(x)), is due to the techincal contraints of mesh generators, as it is impossible to target edges of exactly unitary length in realistic 2D or 3D cases.

Continuous linear interpolate

In this section, we discuss about the main results concerning the a priori discrete linear interpolation error estimation, and then we extend such tools to the continuous mesh framework. The estimation of the linear interpolation error is the main ingredient used in mesh adaptation [Nadler 1985, Formaggia and Perotto 2001, Micheletti et al. 2010]. Given a discrete linear interpolator Π h and a function u, the idea is to find an upper bound to ||u -Π h u|| in some norm, which depends on the local mesh size h and the function u itself (or its derivatives). Since we are dealing with anisotropic mesh adaptation, our aim is to find an upper bound depending also on the local directionality of the mesh. The objective is twofold, i.e.,

• find a generalization of Π h in the context of the continuous mesh framework, that is Π M , and • provide an expression to M which minimizes ||u -Π M u||. Consider a quadratic function of the form (4.22) where x ∈ Ω, and H is a symmetric positive definite matrix, and consider its linear discrete interpolation Π h u over a tetrahedral mesh H. Then, we have that [Loseille and Alauzet 2011a]

u(x) = 1 2 x T Hx,
||u -Π h u|| L 1 (K) = |K| 40 6 i=1 e T i He i , (4.23)
where K ∈ H is a tetrahedron, and {e i } 6 i=1 is the set of its edges. Assuming a triangular mesh in 2D we have that

||u -Π h u|| L 1 (K) = |K| 24 3 i=1 e T i He i . (4.24)
We can write an upper bound to ||u -Π h u|| L 1 (K) depending on a metric M such that K is unit with respect to K. Since û = u(M -1 2 x) is of the form (4.22), its hessian verifies

H û = M -1 2 ,T H u M -1 2 .
Hence, with (4.23), we get

||u -Π h u|| L 1 (K) = √ 2 240 det(M -1 2 )trace(M -1 2 HM -1 2 ). (4.25)
Generalizations of (4.25) to the L 2 or H 1 norm can be found in [Berzins 1997, Nadler 1985], while estimations for functions characterized by a low smoothness can be found in [Micheletti et al. 2010, Formaggia and[START_REF] Formaggia | [END_REF], which are based on the Clément interpolation [Clément 1975]. Given a continous mesh M and the result in (4.23), we are able to construct pointwisely the continuous interpolant Π M following [Loseille and Alauzet 2011a]: given u ∈ C 2 (Ω) and a continuous mesh (M(x)) x∈Ω , we have that there exists a unique continuous interpolant Π M such that

|u -Π M u|(a) = 2 ||u Q -Π h u Q || L 1 (Ω) |K| , a ∈ Ω, (4.26)
where

u Q (a; x) = u(a) + ∇u(a)(x -a) + 1 2 < (x -a), H(a)(x -a) > .
In particular, in 3D,

|u -Π M u|(a) = 1 10 trace(M -1 2 (a)|H|M -1 2 (a)). (4.27)
With (4.26), we can identify an analogy between the global and the local discrete and continuous interpolation errors. For instance, in the discrete case, the global error is given by performing a summation over the tetrahedra of the mesh H,

||u -Π h u|| L 1 (Ω h ) = k∈H ||u -Π h u|| L 1 (K) , (4.28)
while its continuous counterpart is given by

||u -Π M u|| L 1 (Ω) = Ω |u -Π M u|(x)dx. (4.29)
The framework here described works for quadratic functions, anyway, in [Loseille and Alauzet 2011b] it is shown that the equivalence between (4.28) and (4.29) works with a suitable level of accuracy also for non-quadratic functions. To sum up, the duality between the discrete and the continuous meshes is synthetized in Table 4.1.

Multiscale adaptation

In this section, we introduce and describe the basic tools to adapt a mesh H in order to minimize the interpolation error of a sensor function in the L p norm. In general, one starts by considering an initial, not-adapted mesh H 0 , and a piecewise linear function u 0 defined on it. Then, some metric M 0 is computed by using H 0 and u 0 , and the mesh is adapted in order to minimize such error, and a new function u 1 is eventually interpolated on the newly found mesh H 1 . Anyway, H 1 is obtained by using the error computed on u 0 , and it could be still high also for u 1 . For this reason, the mesh is adapted again and a new function is interpolated on it iteratively until the error decrement is acceptable. This process is even more important when the function u i comes from the resolution of a differential problem, like the RANS equations, and not only from a simple linear interpolation: in this case, an intermediate function u i 0 is found by interpolating u i on the newly found mesh, and u i 0 is used as a starting solution to an iterative process.

Figure 4.4 shows the adaptation loop which takes in input a couple (H 0 , u 0 ) representing the initial mesh and an initial solution. After that, a new solution is produced, and it is used to compute a suitable metric which, in turn, is used to generate a new mesh. The solution at step i is interpolated to provide the new initial starting solution at the step i+1, and the algorithm re-iterates. In Figure 4.5, we show a sequence of meshes obtained by applying mesh adaptation to a RAE2822 airfoil with α = 2.31, Re = 6.5e6, M a = 0.729, and with a target complexity of 4000 vertices, where the first one is the initial, not-adapted mesh, the second one is obtained after one adaptation loop, the third after 10 loops and the final after 20 loops. We can see that only by applying several mesh adaptation loops the mesh is able to capture several physical phenomena otherwise missed with only one loop, like the boundary layer, the shockwave and the downstream wake.

As anticipated in this chapter, our objective is to find a mesh M which minimizes the interpolation error of a function u in the L p norm for some p ∈ [1, ∞]. Mathematically, the problem translates to

H = argmin H ||u -Π h u|| L p (Ω h )
, where H has N vertices.

(4.30) Problem (4.30) is too complex to be solved directly, as the meshes used in the most expensive applications provide too many degrees of freedom to (4.30). For this reason, the

H 0 , u 0 Compute u i Compute M i Generate H i+1 Interpolate u 0 i+1 H i , u 0 i H i , u i
M = argmin M ||u -Π M u|| L p (Ω) = argmin M Ω trace M(x) -1 2 |H u (x)| M(x) -1 2 p dx 1 p
, where M = ( M(x)) x∈R has complexity C( M) = N. (4.31) In [Loseille and Alauzet 2011a], it is shown that problem (4.31) has a unique solution. It can be solved by using the concept of Lagrangian and calculus of variation: assume u is a twice differentiable function u : R 3 → R, and consider the Lagrangian

L(M, λ) = Ω trace M(x) -1 2 |H u (x)| M(x) -1 2 p dx -λ Ω d(x)dx -N , (4.32)
where we dropped the exponent 1/p from the L p norm as x 1/p is an increasing function.

We use the decomposition (4.19) to get a minimization problem with respect to the char-

acteristics of M L(d, M, λ) = Ω d -2p 3 trace M(x) -1 2 |H u (x)|M(x) -1 2 p dx -λ Ω d(x)dx -N , (4.33)
where

M = R(x)     r -2 3 1 (x) r -2 3 2 (x) r -2 3 3 (x)     R(x) T .
(4.34)

In equation (4.33), we have separated the anisotropic properties of the metric (i.e., the direction and orientation) from the density (i.e., the size), and this comes in help as we can easily apply the constraint on the number of elements directly to this latter contribution. The derivatives of (4.34) read as (4.36) where the derivative with respect to a matrix is computed by derivation with respect to its eigenvalues and the orientations of its eigenvectors. Note that the second equation of (4.36) provides the optimal metric direction independently of the size, and hence the proof is pursued by proving that the error is minimal when the direction of the metric is aligned with that of the Hessian of u. Thus, the value of the optimal M is cast into the first of (4.36) to compute the density d(x) in order to satisfy the complexity constraint, and λ is eliminated by using C(M) = N . The resulting optimal metric is given by

∂L ∂d = Ω - 2p 3 d(x) -2p+3 3 trace M(x) -1 2 |H u (x)|M(x) -1 2 p -λ δd(x), ∀δd, ∂L ∂ M = Ω d(x) -2p 3 ∂ ∂M trace M(x) -1 2 |H u (x)|M(x) -1 2 p δM(x), ∀δM, (4.35) hence - 2p 3 d(x) -2p+3 3 trace M(x) -1 2 |H u (x)|M(x) -1 2 p = 0, λ ∂ ∂M trace M(x) -1 2 |H u (x)|M(x) -1 2 p = 0,
M L p (x) = N 2 3 Ω det(|H u (x)|) p 2p+3 dx -2 3 det(|H u (x)|) -1 2p+3 |H u (x)|. (4.37)
The metric as in (4.37) cannot be used in practical applications, as the real value of the Hessian of u is not know a priori. Furthermore, such Hessian could not even exists, for example in the context of the present work, where we rely only on P 1 functions. For this reason we replace u in (4.37) by a smoother substitute obtained by applying a reconstruction operator to the discrete solution R h u h . Such operator can be either a recovery one like those developed by Zienkiewicz and Zhu [Zienkiewicz andZhu 1992a, Zienkiewicz andZhu 1992b] but we, in particular, rely on the L 2 -projection operator [Clément 1975], which allows to obtain a P 1 function from a P 0 one. It relies on a volume-averaged nodal quantity as follows (4.38) where u h,K is the value of u h over an element K. By differenciating u h ∈ P 0 and by applying operator (4.38) to the resulting gradient we get R h (∇u h ) ∈ P 1 . Then, by differenciating again and by applying another time R h we get the nodal values of the Hessian.

R h u h = K∈N (i) |K|u h,K K∈N (i) |K| , u h ∈ P 0 ,
Given the optimal metric field constructed with (4.38), the mesh adaptation process in this work is pursued by using feflo.a, which is a software written in Fortran devoted to remeshing and boundary layer generation operations for 2D and 3D cases, and it is based on the concept of cavity-based operation [Loseille and Lohner 2013] to decide the position of the new points inside the domain and on the surfaces.

To sum up, in this Chapter, we have described the basic tools to adapt the computational mesh with respect to the interpolation error on a function defined in the domain, by means of the continuous mesh framework. Such tools are the foundations of the next Chapter 5, which describes the core of this work: goal-oriented anisotropic mesh adaptation.

Chapter 5

Goal-oriented RANS mesh adaptation

Introduction

In chapter 4, we have introduced the continuous mesh framework and described the multiscale mesh adaptation process, which allows to control the L p norm of the interpolation error of a sensor function u defined on the domain Ω. It turns out to be a powerful tool to adapt the mesh, but the main drawback is that (4.37) only targets domain regions dominated by the Hessian of u. For this reason, the choice of the sensor u is of great importance when applying the multiscale mesh adaptation. In order to get meshes pointing out a particular characteristic of the flow field, we describe and implement in this chapter the so-called goal-oriented mesh adaptation. This framework represents a generalization of the multiscale mesh adaptation, and allows to target the discretization error of a goal functional. In the case of the RANS equations, the goal-oriented error estimate represents the generalization of the L p interpolation error, and it is made of three main ingredients: the viscous contribution, the turbulent contribution and the adjoint contribution. This chapter is organized as follows: in Section 5.1, we recall the present state of the art in goaloriented estimation for RANS equations and we introduce the problem at hand; in Section 5.2, we describe the convective and the viscous contribution to the general estimate; in Section 5.3, we describe the turbulent contribution; in Section 5.4, we describe the adjoint (or, dual) contribution and, in 5.5, we show and compare the results.

As mentioned, the objective here is to find a mesh which minimizes the discretization error committed on the computation of a functional depending on the solution provided by the RANS and the adjoint RANS equations. In particular, we are interested to find an upper bound to |J(W ) -J(W h )|, with such upper bound having the form of a weighted sum of the RANS and adjoint RANS problem, that is

|J(W ) -J(W h )| ≤ G(W h , W * , J)|W -Π h W | + G * (W h , W * , J)|W * -Π h W * |, (5.1)
where G and G * are weights depending on the primal flow solution W h , on the adjoint W * h , and on the functional J. The reason why we are looking at a specific form like (5.1), is that, by using the tools developed in chapter 4, we are able to find an optimal metric to (5.1) by using relation (4.37). In [Belme 2011], the error estimate (5.1) contains only terms relative to the convective fluxes, and has been verified in the case of the Euler equations. In [Frazza 2018], (5.1) contains terms relative to the mean-flow equation, and has been verified on the RANS equations. The objective of this chapter is to include the turbulence information coming from the Spalart-Allmaras turbulence model and to add the adjoint contribution. In this specific section, we recall the current methodology to treat problems of the type (5.1), and to provide a general error estimate in a suitable functional setting. We assume that we are dealing with a nonlinear variational problem of the type

(Ψ(u), φ) = 0, ∀φ ∈ V, (5.2)
where Ψ : V → V * is a nonlinear operator, u ∈ V , φ ∈ V , V is at least a Banach space, and V * its dual. Consider its discrete form (5.3) where u h ∈ V h and φ h ∈ V h . Here, Ψ h can represent the mixed finite element -finite volume discretization of Wolf. Note that we indicate as u h the actual solution to (5.3), as this could satisfy (Ψ(u h ), φ h ) = 0 only approximately. We define the associated linearized dual problems (Ψ (u)φ, z) = (J (u), φ), (5.4)

(Ψ h (u h ), φ h ) = 0 ∀φ h ∈ V h ,
(Ψ h (u h )φ h , z h ) = (J (u h ), φ h ), (5.5)
where z is the solution of the continuous adjoint problem, and z h represents the discrete adjoint solution. Note that in (5.5) we used the definition of the discrete adjoint.

A possible approach to get an approximate upper bound to (5.1), is the linearization of the objective functional J on the evaluation point Π h W [Venditti andDarmofal 2002, Venditti andDarmofal 2003],

J(Π h u) J(u h ) + ∂J ∂u h • (Π h u -u h ).
(5.6)

Since Π h u is unknown, it is replaced by Π h u h/2 , which is the linear interpolation of a solution u h/2 (computed on a finer mesh) on the coarser mesh. It is possible to avoid the computation of Π h u h/2 by linearizing the expression

Π h/2 u h -u h/2 ∂Ψ h/2 ∂u h/2 -1 Ψ h/2 (Π h/2 u h ).
(5.7)

From expression (5.6) and (5.7) we get

J h/2 (u h/2 ) J h/2 (Π h/2 u h ) + z h/2 • Ψ h/2 (Π h/2 u h ), (5.8)
where z h/2 = (∂Ψ h/2 /∂u h/2 ) -T J h/2 . Expression (5.8) allows to avoid the computation of the inverse of ∂Ψ h/2 /∂W h/2 . Furthermore, z h/2 is replaced by Π h/2 z h , as it is assumed that the Jacobian of the residuals and the objective functional have a negligible change as the mesh gets finer. Similar approaches to recover a smoother solution without relying on a finer mesh could be the superconvergent patch recovery developed in [Zienkiewicz andZhu 1992a, Zienkiewicz andZhu 1992b]. Anyway, the approach (5.8) requires the computation of a finer mesh, and still does not consider the adjoint solution W * contribution. An alternative approach is to bound J(W ) -J(W h ) by relying on the DWR (Dual Weighted Residual) method, which provides estimates depending on the residuals of the primal solution and suitable weights depending on the adjoint variable, developed in [START_REF] Becker | [END_REF]Rannacher 1996b, Becker and[START_REF] Becker | [END_REF] for linear problems, and in [Rannacher and Vihharev 2013] for nonlinear ones. Anyway, the core of this work relies on the a posteriori goal-oriented estimation [Micheletti andPerotto 2008, Kamenetskiy et al. 2022]. To this aim, we state and prove the following Theorem 5.1.1. Let V be a Banach space, V h the space of the finite element functions, Ψ a nonlinear operator such that Ψ : V → V * , J a functional J : V → R, and Ψ h a suitable discretization of Ψ. Let u ∈ V be the solution of the continuous problem (5.2),

u h ∈ V h the J(u) -J(u h ) = - 1 2 (Ψ(u h ), z -z h ) + 1 2 (J (u h ), u -Π h u) - 1 2 (Ψ (u h )(u -Π h u), z h ) + (Ψ(u h ), z h ) + R (2) ,
with R (2) a second order reminder in ((u -u h ), (z -z h )). We conclude the proof by assuming z h Π h z.

Starting from the result developed in [Rannacher and Vihharev 2013], we assumed that the adjoint z h is produced with the discrete adjoint approach, which provides an error estimate converging with order 2 instead of 3. Here we have used two assumptions: the first that Π h u -u h strongly converges to zero, which seems enough reasonable, and the second one that Ψ h (u h ) -Ψ (u h ) weakly converges to 0 with at least order 1. In other words, we are assuming a form of adjoint consistency, which seems not to be always true, and it is strongly dependent of the functional J used (see Section 3.1.1). This hypothesis could have an impact when applying Theorem 5.1.1 to the RANS equations. Theorem 5.1.1 states a general goal-oriented error estimate, and can be used for any nonlinear problem satisfying its hypothesis. That is, the way Ψ, Ψ and J are defined influences the goal-oriented error estimation form. For instance, in [Micheletti and Perotto 2012] a goal-oriented error estimation is developed in the context of advection-diffusion-reaction equations; in [START_REF] Frey | [END_REF]Alauzet 2005, Belme 2011] the authors develop a goal-oriented error estimation for Euler (inviscid) flow assuming Ψ(u h ) = 0, in [START_REF][END_REF], Belme et al. 2019] the results are extended to the case of viscous flows and in [START_REF] Clerici | [END_REF] the results are further extended by taking into account turbulence, for 2D cases only. In particular, in [START_REF] Alauzet | 3D RANS anisotropic mesh adaptation on the high-lift version of NASA's Common Research Model (HL-CRM)[END_REF] the viscous contribution of (5.9) is applied to RANS equations to compute the flow field around the 3 rd AIAA CFD High Lift Prediction Workshop benchmark, but still assuming Ψ(u h ) = 0. In [START_REF] Micheletti | [END_REF], the authors write a goal-oriented error estimate for Navier-Stokes which includes the contributions due to the boundary conditions and the stabilization terms, and they also consider a continuous adjoint approach, and hence, in this case, the reminder of (5.9) is a third-order one.

The objective of the next sections is to compute and show the explicit terms involved in (5.9) for the RANS equations, that is, the expressions of the weights of the interpolation errors for each variable. The work of this chapter is incremental with respect to [START_REF] Alauzet | [END_REF]], hence we first describe briefly the expression of the error estimate shown in that work. The error estimate there depends only on the mean-flow variables and fluxes, meaning that no turbulent viscosity contribution is taken into account, the turbulent viscosity in the viscous fluxes of the mean-flow is assumed constant, the adjoint variables are computed with the weakly coupled approach, and no adjoint interpolation contribution (that is, (Ψ(ũ h ), z -z h )) is considered. Here, the error estimate has the form

J(W ) -J(W h ) Ω g(W h )(W -Π h W )dΩ,
where the local weights g are given by (5.12) where H W is the Hessian of W . We can see that the first term of (5.12) corresponds to the second term of (5.9), while the second and the third terms of (5.12), representing the non-linear Navier-Stokes operator, correspond to the third term of (5.9). Concerning the weight relative to the convective contribution, that is -∂F ∂W T • ∇W * , this has been

g(W h ) = ∂J ∂W h - ∂F ∂W h T • ∇W * - ∂S ∂∇W h T H W h ,
(V (W )-V (Π h W ))f (Π h W ) = (V (W ) -V (Π h W ))[(f (Π h W ) -f (W )) + f (W )] = (V (W ) -V (Π h W ))f (W ) + (V (W ) -V (Π h W ))(f (Π h W ) -f (W )) (V (W ) -V (Π h W ))f (W ),
as both the terms (V (W ) -V (Π h W )) and (f (Π h W ) -f (W )) goes to zero with at least order 1, and so their product goes to zero with order 2.

The second result is straightfoward, and it is given by Lemma 5.2.2. Let f ∈ C 1 (R), W the vector of the conservative variables of the RANS equations, V the vector of the physical variables and Π h the interpolation operator. Then,

f (W ) -f (Π h W ) = ∇f | W • (W -Π h W ).
Lemma 5.2.2 is particularly useful when f (W ) = V (W ) is the function providing the physical variables from the conservative variables,

∇f =             1 0 0 0 0 0 -u ρ 1 ρ 0 0 0 0 -v ρ 0 1 ρ 0 0 0 -w ρ 0 0 1 ρ 0 0 -E ρ 0 0 0 1 ρ 0 0 0 0 0 0 1            
.

The third result regards the development of the term µ t (W ) -µ t (Π h W ), and it is given by the following Lemma 5.2.3. Let W be the vector of the conservative variables of the RANS equations, µ t the turbulent dynamic viscosity given by the Spalart-Allmaras turbulence model and Π h the interpolation operator. Then, we have that

µ t (W ) -µ t (Π h W ) νf v1 (ρ -Π h ρ) + ρ[f v1 + νf v1 ](ν -Π h ν),
where

f v1 = 3c 3 v1 χ 3 ν(3χ 3 + c 3 v1 ) 2 . Proof. Recalling µ t = ρνf v1 , we have that µ t (W ) -µ t (Π h W ) = ρ(W )ν(W )f v1 (ν(W )) -ρ(Π h W )ν(Π h W )f v1 (ν(Π h W )).
To such expression, we directly apply Lemma 5.2.2 to obtain the proof.

We are now able to provide the convective and the viscous weights contribution to the RANS error estimate of (5.9). To this aim, we separate the convective and the viscous contribution to (5.13).

Convective contribution

The convective contribution is integrated by part omitting the boundary terms, and then we revert (5.15) to get

Ω ∇ • (F (W ) -F (Π h W )) • W * h dΩ - Ω i ∂F i ∂W T W h ∂W * h ∂x i (W -Π h W )dΩ.
(5.16)

Defining q = ||u|| 2 , we explicitly provide the expression of ∂F i ∂W in 2D

∂F x ∂W =          0 1 0 0 0 γ-1 2 q -u 2 -(γ -3)u -(γ -1)v γ -1 0 -uv v u 0 0 ((γ -1)q -γE)u γE -γ-1 2 (2u 2 + q) -(γ -1)uv γu 0 0 ν 0 0 ρu          , ∂F y ∂W =          0 0 1 0 0 -uv v u 0 0 γ-1 2 q -v 2 -(γ -1)u -(γ -3)v γ -1 0 ((γ -1)q -γE)v -(γ -1)uv γE -γ-1 2 (2v 2 + q) γv 0 0 0 ν 0 ρv         
, while in 3D we have

∂F x ∂W =             0 1 0 0 0 0 γ-1 2 q -u 2 -(γ -3)u -(γ -1)v -(γ -1)w γ -1 0 -uv v u 0 0 0 -uw w 0 u 0 0 ((γ -1)q -γE)u γE -γ-1 2 (2u 2 + q) -(γ -1)uv -(γ -1)uw γu 0 0 ν 0 0 0 ρu             , ∂F y ∂W =             0 0 1 0 0 0 -uv v u 0 0 0 γ-1 2 q -v 2 -(γ -1)u -(γ -3)v -(γ -1)w γ -1 0 -vw 0 w v 0 0 ((γ -1)q -γE)v -(γ -1)uv γE -γ-1 2 (2v 2 + q) -(γ -1)vw γv 0 0 0 ν 0 0 ρv             , ∂F z ∂W =             0 0 0 1 0 0 -uw w 0 u 0 0 -vw 0 w v 0 0 γ-1 2 q -w 2 -(γ -1)u -(γ -1)v -(γ -3)w γ -1 0 ((γ -1)q -γE)w -(γ -1)uw -(γ -1)vw γE -γ-1 2 (2w 2 + q) γw 0 0 0 0 ν 0 ρw             .
Note that the additional terms arising from turbulence are represented by the lower row of the matrices above, which are not included in [START_REF] Michal | Comparing anisotropic error estimates for theOnera M6 wing RANS simulations[END_REF][START_REF] Alauzet | 3D RANS anisotropic mesh adaptation on the high-lift version of NASA's Common Research Model (HL-CRM)[END_REF].

Viscous contribution

Concerning the viscous contribution, as said, in [Frazza 2018] it is assumed a frozen turbulent viscosity, and hence the viscous fluxes S can be seen as functions of the gradients of the conservative variables, S(W h ) = S(∇W h ). The same treatment cannot be done here as the turbulent viscosity does not appear in the gradient form. Anyway, these terms are linear in the turbulent viscosity, and hence finding a linearization is straightforward. We start from the momentum equations, with integration by part omitting the boundary term:

- Ω ∇ • (S(W ) -S(Π h W ))W * dΩ = Ω (µ + µ t (W ))τ (W ) -(µ + µ t (Π h W ))τ (Π h W ) : ∇W * ρu dΩ,
(5.17)

where W ρu = (ρu, ρv, ρw). Hence, we add and subtract inside the integral the quantity

(µ + µ t (W ))τ (Π h W ) : ∇W * ρu , getting Ω (µ + µ t (W ))(τ (W ) -τ (Π h W )) + (µ t (W ) -µ t (Π h W ))τ (Π h W ) : ∇W * ρu dΩ. (5.18)
The first term is already treated in [START_REF] Michal | Comparing anisotropic error estimates for theOnera M6 wing RANS simulations[END_REF][START_REF] Alauzet | 3D RANS anisotropic mesh adaptation on the high-lift version of NASA's Common Research Model (HL-CRM)[END_REF]] by differenciating the viscous fluxes with respect to the gradient of W . The only difference here is that the viscosities µ + µ t are not outside the integral, but are enclosed in the weights of the form ((µ + µ t )(ρV ) * x i ) x j (or, (µ + µ t ) x j (ρV ) * x i + (µ + µ t )(ρV ) * x i x j ) and not (µ + µ t )(ρV ) * x i x j . Then, we use Lemma 5.2.1 to get the additional terms

Ω ρ(f v1 + νf v1 ) τ : ∇W * ρu (ν -Π h ν)dΩ + Ω f v1 ν τ : ∇W * ρu (ρ -Π h ρ)dΩ.
(5.19)

The energy part is treated in the same exact way, leading to the following two additional contributions

Ω ρ(f v1 + νf v1 ) τ • u + C p P r t ∇T • ∇(ρE) * (ν -Π h ν)dΩ + Ω f v1 ν τ • u + C p P r t ∇T • ∇(ρE) * (ρ -Π h ρ)dΩ.
(5.20)

The final contribution, representing the turbulent diffusion, is integrated by part (we neglet the boundary terms, which often are already zero in the implementations of the Spalart-Allmaras model), and it reads as

T ν * = Ω ρ σ (ν + ν(W ))∇ν(W ) -(ν + ν(Π h W ))∇ν(Π h W ) ∇ν * dΩ.
(5.21)

Then, we use ν∇ν = 1 2 ∇ν 2 , another integration by parts, and the fact that ν2 (W ) -

ν2 (Π h W ) 2ν(W )(ν(W ) -ν(Π h W )) to get T ν * = - Ω ν + ν σ ∇ • (ρ∇ν * )(ν(W ) -ν(Π h W ))dΩ.
(5.22)

To sum up, the following terms are added to the standard weight G(ρ) of [START_REF] Michal | Comparing anisotropic error estimates for theOnera M6 wing RANS simulations[END_REF][START_REF] Alauzet | 3D RANS anisotropic mesh adaptation on the high-lift version of NASA's Common Research Model (HL-CRM)[END_REF] and read as

G new (ρ) = G(ρ) -f v1 ν τ : ∇W * ρu + τ • u + C p P r t ∇T • ∇(ρE) * ,
and we also introduce the weight relative to the turbulent viscosity, reading as

G(ν) = - ∂J ∂ ν + i ∂F i ∂W T • ∇ i W * + ρ(f v1 + νf v1 ) τ : ∇W * ρu + τ • u + C p P r t ∇T • ∇(ρE) * - ν + ν σ ∇ • (ρ∇ν * ),
where ∂J ∂ ν = 0 if J uses values on no-slip boundaries.

Turbulent contribution

Here, we show the main turbulent contribution to (5.9), which comes from the source terms Q. Here, we still rely on the transformation (5.14), and we linearize these terms by considering each sub-contribution singularly, providing an exact linearization and by considering a piecewise linear exact density. Recalling the second form of (5.14), we have, explicitly,

Ω (Q(W ) -Q(Π h W ))ν * dΩ = Ω c b2 ρ σ ||∇ν(W )|| 2 - c b2 ρ σ ||∇ν(Π h W )|| 2 + ρc b1 S(W )ν(W ) -ρc b1 S(Π h W )ν(Π h W ) + -cw1fw(W )ρ ν(W ) d 2 + cw1fw(Π h W )ρ ν(Π h W ) d 2 ν * dΩ (5.23)
The contribution due to c b2 ρ σ ||∇ν|| 2 can be simply differentiated and integrated by part, and using Lemma 5.2.2 we get

Ω c b2 ρ σ ||∇ν(W )|| 2 - c b2 ρ σ ||∇ν(Π h W )|| 2 ν * dΩ - 2c b2 σ Ω ∇ • (ρν * ∇ν)(ν(W ) -ν(Π h W ))dΩ. (5.24)
The contribution due to ρc b1 S ν is developed by separating the two contributions forming

S = ||∇ × u|| + ν κ 2 d 2 f v2 , Ω ρc b1 S(W )ν(W )-S(Π h W )ν(Π h W ) ν * dΩ = Ω ρc b1 S(W )(ν(W )-ν(Π h W ))-ν(Π h W )( S(W )-S(Π h W )) ν * dΩ.
(5.25)

The first term of (5.25) can be already treated, while the second term of (5.25), after applying Lemma 5.2.1 is

Ω ρc b1 ν ||∇ × u(W )|| + ν(W ) κ 2 d 2 f v2 (W ) -||∇ × u(Π h W )|| - ν(Π h W ) κ 2 d 2 f v2 (Π h W ) ν * dΩ.
(5.26) The curl part is handled by differenciating the norm operator ∇ x ||x|| = x ||x|| and using the integration by part

Ω φ • ∇ × ψdΩ = Ω ∇ × φ • ψdΩ -∂Ω φ × ψ • dS, which leads to Ω ρc b1 ν ||∇×u(W )||-||∇×u(Π h W )|| ν * dΩ Ω ∇× ρc b1 ν ν * ||∇ × u|| ∇ × u •(u(W )-u(Π h W ))dΩ. (5.27) Note that in 2D the term ∇ × ρc b1 ν ν * ||∇×u|| ∇ × u is equal to ∇ × ρc b1 ν ν * ||∇ × u|| ∇ × u = sgn(∂ x v -∂ y u) ∂ y (ρc b1 ν ν * ) -∂ x (ρc b1 ν ν * )
.

(5.28)

The remaining part of (5.26) is treated by differenciating ν κ 2 d 2 f v2 , leading to (5.29) where

Ω c b1 ρν ν * κ 2 d 2 f v2 + f v2 ν (ν(W ) -ν(Π h W ))dΩ,
f v2 = - χ 6 -3c 3 v1 χ 4 + 2c 3 v1 χ 3 + c 6 v1 ν(χ 4 + χ 3 + c 3 v1 ) 2
.

(5.30)

Then, after applying Lemma 5.2.2 to (5.27), we sum up (5.27) and (5.29) to get the following three contributions

Ω ρc b1 S(W )ν(W ) -ρc b1 S(Π h W )ν(Π h W ) ν * dΩ - Ω 1 ρ ∇ × ρc b1 ν ν * ||∇ × u|| ∇ × u • u(ρ -Π h ρ)dΩ + Ω 1 ρ ∇ × ρc b1 ν ν * ||∇ × u|| ∇ × u • (ρu -Π h ρu)dΩ + Ω ρc b1 S ν * + c b1 ρν ν * κ 2 d 2 fv2 + f v2 ν (ν -Π h ν)dΩ.
(5.31)

The final contribution due to c w1 f w ρ ν d 2 is treated in the same way. Before doing it, we provide the exact differentiation of f w = f w (u, ν) with respect to its two arguments. We have that ∇ u,ν f w = f w (g)g (r)h(ν, S, d)∇ u,ν r (5.32) with f w (g) = c 6 w3 (c 6 w3 + 1)

c 6 w3 +1 c 6 w3 +g 6 5 6 (c 6 w3 + g 6 ) 2
, g (r) = 1 + c w2 (6r 5 -1),

h(ν, S, d) =    0 ν Sk 2 d 2 ≤ 10 1 else , and ∇ u,ν r =        - κ 2 d 2 ν ||∇ × u||(κ 2 d 2 ||∇ × u|| + νf v2 ) 2 ∇ × u κ 2 d 2 ||∇ × u|| -ν2 f v2 (κ 2 d 2 ||∇ × u|| + νf v2 ) 2 .        .
In the sequel, we divide the two components of (5.32) as

∇ u,ν f w =     ∇ u f w ∂ ν f w     .
The contribution due to c w1 f w ρ ν d 2 , after applying the usual transformations, provides the following two terms

Ω -cw1fw(W )ρ ν(W ) d 2 + cw1fw(Π h W )ρ ν(Π h W ) d 2 ν * dΩ - Ω cw1ρ d 2 ν2 (fw(W ) -fw(Π h W ))ν * - cw1ρ d 2 fw(ν 2 (W ) -ν2 (Π h W ))ν * dΩ.
The first term gives three contributions after the application of Lemma 5.2.2, linearization and integration by parts

- Ω cw1ρ d 2 ν2 (fw(W ) -fw(Π h W ))ν * dΩ - Ω cw1ρν * d 2 ν2 ∇ufw • ∇ × (u(W ) -u(Π h W ))dΩ - Ω cw1ρν * d 2 ν2 ∂ν fw(ν(W ) -ν(Π h W ))dΩ = - Ω cw1∇ × ρν * ν2 d 2 ∇ufw • (u(W ) -u(Π h W ))dΩ - Ω cw1ρν * d 2 ν2 ∂ν fw(ν(W ) -ν(Π h W ))dΩ = Ω cw1 ρ ∇ × ρν * ν2 d 2 ∇ufw • u(ρ -Π h ρ)dΩ- Ω cw1 ρ ∇ × ρν * ν2 d 2 ∇ufw • (ρu -Π h ρu)dΩ- Ω cw1ρν * d 2 ν2 ∂ν fw(ν -Π h ν)dΩ (5.33)
while the second term, after using

ν(W ) 2 -ν(Π h W ) 2 2ν(ν(W ) -ν(Π h W )) becomes - Ω c w1 ρ d 2 f w (ν 2 (W ) -ν2 (Π h W ))ν * dΩ - Ω 2c w1 ρf w ν * ν d 2 (ν -Π h ν)dΩ.
(5.34)

Eventually, we sum up (5.33) and (5.34) to get

Ω c w1 ρ ∇ × ρν * ν2 d 2 ∇ u f w • u(ρ -Π h ρ)dΩ - Ω c w1 ρ ∇ × ρν * ν2 d 2 ∇ u f w •(ρu -Π h ρu)dΩ - Ω c w1 ρν * ν d 2 [2f w + ν∂ ν f w ](ν -Π h ν)dΩ.
(5.35)

We can express the contributions due to the turbulence source term resulting from (5.24), (5.31) and (5.35) introducing three local weights relative to the turbulence source terms, indicated as g T ρ , g T ρu , g T ρν , such that

g T ρu = 1 ρ ∇ × ρc b1 ν ν * ||∇ × u|| ∇ × u - c w1 ρ ∇ × ρν * ν2 d 2 ∇ u f w , g T ρ = -g T ρu • u, g T ν = - 2c b2 σ ∇ • (ρν * ∇ν) + ρc b1 S ν * + c b1 ρν ν * κ 2 d 2 f v2 + f v2 ν - c w1 ρν * ν d 2 [2f w + ν∂ ν f w ]
(5.36) We close this section by providing the values of (5.36) by neglecting the contributions due to S, f w and ρ:

g T ρu =0, g T ρ =0, g T ν = - 2c b2 σ ∇ • (ρν * ∇ν) + ρc b1 S ν * + c b1 ρν ν * κ 2 d 2 f v2 + f v2 ν - 2f w c w1 ρν * ν d 2 .
(5.37)

On one side the exclusion of such terms provides an error estimate which is simpler, and the metric could contain less singularities. But, on the other side, we would exclude all the terms which provide refined meshes in regions of high vorticity, and hence, turbulence production. For example, consider the term ∇ × ρc b1 ν ν * ||∇×u|| ∇ × u . The argument of the outer curl is the vorticity modulated by the quantity of turbulence and the adjoint turbulent variable. This means that the mesh results to be refined on regions where

• the velocity has a high gradient/hessian, and

• the vorticity has a high rate of "rotation". This has a precise physical meaning in 3D vortices: this happens when a vortex is stretching in the direction of a gradient of velocity due to the conservation of angular momentum, and this is also weighted by the sensitivity of the functional with respect the the turbulent viscosity (meaning that we don't care about regions having a low influence on the functional J).

Adjoint contribution

In this section, we describe the terms due to the adjoint interpolation error. In particular, we recover the error estimate (5.9) by introducing the additional contribution -(1/2)(Ψ(ũ h ), z -Π h z). In the case of the RANS equations, this is equivalent to

- 1 2 (R( Wh ), W * -Π h W * ).
(5.38)

These term is already written in the form of a weighted sum of interpolation errors on the adjoint variable W * , and hence its development does not need particular explanations. The only remarks concerns the computation of the continuous residual evaluated on the numerical solution Wh , that is R( Wh ). Such term involves first and second derivatives, which, are not continuous and do not exists, respectively, for P 1 functions. For this reason we still rely on the L 2 projection to obtain P 1 gradients and Hessians, which are then suitably evaluated on each vertex. The term R( Wh ) reads as

R =       ∇ • (ρu) ∇ • (ρu ⊗ u) + ∇p -∇ • T ∇ • ((ρE + p)u) -∇ • (T • u) -∇ • (λ∇T ) u • ∇(ρν) -c b1 Sρν + c w1 f w ρ ν d 2 -ρ σ [∇ • ((ν + ν)∇ν) + c b2 ||∇ν|| 2 ]       . (5.39)
The computation of the continuous residual in (5.39) is pursued in Wolf by with a multiplyand-differentiate strategy. Consider, for example, the first component of (5.39), that is ∇ • (ρu). In Wolf, an auxiliary array of length 2N V (in 2D), or 3N V (in 3D) is filled with ρu, and then the L2 projection gradient is applied to such vector to compute its divergence. The alternative approach, that is, the differentiate-and-multiply strategy, would consist in the prior computation of all the gradients of the physical variables u and ρ, and, then, the computation of the continuous residual would be pursued on ∇

• (ρu) = ∇ρ • u + ρ∇ • u.
The use of the multiply-and-differentiate strategy is slower as one should compute more gradients, but it is easier to code and requires still a negligible cpu time with respect ot the primal flow or the adjoint solvers one.

Applied cases

In this section, we show the results obtained by applying the adaptation loop (4.4) with the goal-oriented error estimate to several benchmarks in aerodynamics. The research that has been made is incremental with respect to the methodologies implemented so far, for this reason, we divide into three classes the experiments made for each case.

W-error estimate

The W-error estimate (W-EE) is the error estimate developed in [START_REF] Michal | Comparing anisotropic error estimates for theOnera M6 wing RANS simulations[END_REF][START_REF] Alauzet | 3D RANS anisotropic mesh adaptation on the high-lift version of NASA's Common Research Model (HL-CRM)[END_REF]. We refer to it with the nomenclature "W-EE" to underline that it only depends on the mean-flow primal variables and fluxes. In particular, it is of the form

|J(W ) -J(W h )| ≤ |(J (W h ), W -Π h W ) -(R (W h )(W -Π h W ), W * )|, (5.40)
where W = (ρ, ρu, ρv, ρw, ρe), R = F -S, and the adjoint W * = (ρ * , (ρu) * , (ρv) * , (ρw) * , (ρe) * ) is produced with the weakly coupled turbulence approach.

W+T-error estimate

The W+T-EE is the first increment to (5.40). The nomenclature W+T-EE indicates that it includes the complete description of turbulence in its implementation. In particular, here we assume the same form as (5.40), with the difference that W = (ρ, ρu, ρv, ρw, ρe, ν), R = F -S -Q, and the adjoint W * = (ρ * , (ρu) * , (ρv) * , (ρw) * , (ρe) * , ν * ) is produced with the strongly coupled turbulence approach. We recall, from section 3.2, that the strongly coupled adjoint modifies the adjoint mean-flow variables, and hence here we have two separated contributions: one coming from the fact that we are using the strongly coupled adjoint, and the other derivatives from the fact that we are enriching the error estimate (5.40) with the turbulent information. In the sequel, we indicate the amount of contributions which is due to the sole coupled adjoint modification (i.e., we use the strongly coupled adjoint variables on the W-EE), and which contributions are due to the additional turbulent terms in the error estimate. When necessary, we run two different simulations to have a deeper insight on this.

W+T+D-error estimate

The final contribution is represented by the adjoint interpolation error terms in the error estimate (5.9), and for this reason we indicate as W+T+D-EE such estimate, where D stands for "dual". In such a case, the error estimate takes the form Of course, when necessary, we explore the W+D-EE, that is, the W-EE enriched with the mean-flow adjoint interpolation error.

|J(u) -J( Wh )| ≤ | -(R( Wh ), W * -Π h W * ) + (J ( Wh ), W -Π h W ) -(Ψ ( Wh )(W -Π h W ), W * )|. (5.41)
To sum up, we compare the W-EE to the W+T-EE and the W+T+D-EE in terms of

• convergence of the goal functional J. We expect that as h → 0 we have that J stabilizes faster on the target value; • physical feature of the computational mesh. We expect the mesh to capture more physics, possibly related to J, in particular in regions characterized by a high turbulence and vortices.

All the results are obtained by using Wolf to get the primal flow variables, the adjoint state and the optimal metric, and feflo.a to adapt the mesh. In addition to that, when possible, we also compare the results with other CFD/mesh adaptation software.

NACA0012

The first case we consider is the NACA0012 airfoil, which is a standard benchmark used to validate new methodologies in CFD. Since this case consists in a simple 2D geometry, we use this benchmark to point out the most basic differences among the error estimates shown in the previous sections. Such case consists in a 2D wing cut of an airfoil set in the center of a circular domain with a diameter of adimensional length of 200. Its chord has an adimensional length of 1, and its biggest thickness is reached at the 30% of the chord length and it measures 0.012. The physical parameters are shown in Table 5.1, and these include the Reynolds number Re, the Mach number M a, the reference temperature T , the angle of attack α, and the chosen adjoint functional. The numerical parameters are shown in Table 5.2, and these include the minimum and the maximum number of vertices employed for the mesh adaptation loop, that is, N V,min and N V,max , respectively, the limiter used in the case, the residual threshold which triggers a CFL decrease for the Newton and the SGS solver, indicated by τ N ewton and τ SGS , respectively, the number of SGS iterations, and the residual thresholds used as stopping criteria for the nonlinear and the linear solvers, indicated by Res N ewton and Res SGS , respectively. Figure 5.1 shows the initial ρ field and the initial mesh, which, as one can notice, does not have any physical feature (like boundary layers and wakes).

N V,min 4K N V,max 256K Limiter No τ N ewton 1.1 τ SGS 5e-3

SGS iterations 20

Res N ewton 1e-10

Res SGS 5e-3 The mesh adaptation loop 4.4 is applied to a set of increasing (doubling) complexities starting from a mesh with N V,min = 4000 up to N V,max = 256000. In particular, the convergence of each adaptation loop at fixed complexity is checked by looking at the variations of C L , C D , C p and C f . In particular 4.4 is run until

|C n+1 L -C n L | < , |C n L -C n-1 L | < , |C n+1 D -C n D | < , |C n D -C n-1 D | < , |C n+1 Dp -C n Dp | < , |C n Dp -C n-1 Dp | < , |C n+1 Df -C n Df | < , |C n Df -C n-1 Df | < ,
(5.42) with = 0.002. Once (5.42) are satisfied, the complexity is doubled and the solution at complexity N V,m-1 is interpolated and used as starting solution to the first computation at complexity N V,m . The resulting algorithm, which we refer to as C-continuation, is shown in

Algorithm 6: C-continuation algorithm input: H 1 , W 1 h , W * ,1 , N V = {N V,1 , N V,2 , ..., N V,m } for i = 1, 2, ..., m do n = 0 while (5.42) is not satisfied do Compute M with W n h , W * ,n and N V,i vertices Adapt H n with M W n h,0 ← W n h (interpolation) Compute W n h , W * ,n n ← n + 1
Algorithm 6 is usually used to perform mesh-independency studies of CFD computations, and it is particularly useful within this context. In Figure 5.2 we show the convergence of the functionals involved in (5.42) with respect to the number of vertices (we recall that the complexity N V is never really targeted with the remesher, as this would require having edges of exactly length 1 in the metric space). We have run four different simulations using the goal-oriented error estimates shown in this chapter (W-EE, W+T-EE, W+T+D-EE) and a multiscale adaptation minimizing the L 4 norm of the interpolation error of the local Mach number. We see that, for at least low complexities, the W+T+D-EE has the fastest convergence for the goal functional C L , followed by the W+T-EE, the W-EE and, eventually by the reference multiscale adaptation. As shown in Section 3.2, the use of the weakly coupled and the strongly coupled adjoints fields produces quite different solutions, and such differences have a high impact on the resulting mesh. For instance, the adjoint on the leading edges, which is shown in Figure 5. ), produces a sharper mesh in the case of the strongly coupled one, and this impacts the C Df , which is higher in the W+T-EE case. Furthermore, the trailing edges presents characteristic meshes when including turbulence (see, again, Section 3.2). Figure 5.4 shows such region in the NACA0012 case, and we see that the destruction term influence the adjoint, which, in turn, makes a dark mesh band to emerge. The quantities involved in the destruction term are shown in Figure 5.5, and they present the same characteristics as for the HLCRM2DWC case shown in Figure 3.15, meaning that the vorticity ω z tends to zero, and this produces a sharp profile in D.

The inclusion of the adjoint interpolation error terms in the W+T+D-EE enriches the mesh with additional features. For instance, Figure 5.6 shows the ρ * field along with the computational mesh for the W-EE and the W+T+D-EE in the upstream region. We can see that the sonic line characterizing the adjoint fields appears more defined in the case of the W+T+D-EE, and the mesh follows its pattern. Anyway, this is not always beneficial: we observed that for a fixed complexity N V , the inclusion of the adjoint interpolation error terms from one side enriches the mesh with additional features, but this enrichment has a cost: in order to refine such regions, other critical regions like shocks, wakes and boundary layers are refined with less vertices, and this could have a negative impact on the convergence of the aerodynamic coefficients. For example, the W+T+D-EE shows the lowest C Df at mesh convergence, and this is due to the fact that the boundary layer regions have a lower number of vertices with respect to the other adaptation strategies. This is better pointed out in the next cases.

W-EE mesh W-EE ρ * W+T-EE mesh W+T-EE ρ *

RAE2822

The second considered case is the RAE2822. This case is particularly interesting as it is run under transonic conditions, and provides insights about the behavior of different adaptation strategies on the shock wave and in the shock-boundary layer interaction region. The geometry is a 2D airfoil centered in a squared domain with a side of adimensional length of 200, its chord has an adimensional length of 1 and the maximum thickness, having a length of 0.121, is reached at the 37.9% of the chord. Figure 5.7 shows the initial ρ field and the initial mesh, which, as one can notice, does not have any physical feature (for this specific case, boundary layers, wakes and shock wave).

N V,min 4K N V,max 1024K Limiter Gamma(2) τ N ewton 1.1 τ SGS 5e-2

SGS iterations 20

Res N ewton 1e-10

Res SGS 5e-3 Table 5.3 shows the physical parameters, and Table 5.4 the numerical ones. In particular, we choose the drag coefficient C D as target functional, and we use a set of increasing complexity starting from 4000 vertices up to 1024000. We apply the C-continuation algorithm (6) to study the mesh convergence with respect to several error estimates, and we skip to a higher mesh complexity once the conditions (5.42) are satisfied with = 0.002. Figure 5.8 shows the convergence of C L , C D , C Dp , C Df with respect to the number of vertices of the computational meshes. We can see that, likewise the NACA0012 case, the W+T+D-EE has the fastest convergence with respect to C L , but has the slowest one for C Df , again, due to the fact that the adjoint interpolation errors requires the relocation of vertices from the boundary layers to the sonic line. Considering the other functionals, the approaches target in general different solutions. Concerning the drag coefficient C D , which is the goal of the adaptation, we see that the W-EE and the W+T-EE get approximately the same value, but the inclusion of turbulence accelerates the convergence. Also, in terms of C D , there is a difference of approximately 0.5 drag count between the multiscale adaptation and the W+T+D-EE, as these point out different characteristics of the flow field.

In order to point out the negative effects of the W+T+D-EE on the adapted mesh,

N V,min 4K N V,max 256K Limiter No τ N ewton 1.1 τ SGS 5e-3

SGS iterations 20

Res N ewton 1e-11

Res SGS 1e-2 In Figure 5.12, we show the convergence of C L , C D , C Dp , C Df . We can draw the same conclusions as the other 2D cases: in general, we get different trends for different adaptation strategies, as these point out different characteristics of the flow field. In the multiscale case and in the W+T-EE we get the highest C Df values, thanks to the fact that, with the first approach, we get a strong refinement of the boundary layers following the primal flow solution, while, by using the second approach, we obtain the same refinement thanks to the stronger gradient of the adjoint field in those regions. We get the lowest values of C Df with the W+T+D-EE because, even though we include the adjoint interpolation error in the resulting metric fields, a consistent amount of vertices are relocated from the boundary layers to the sonic line, following the adjoint shape. For the HLCRM2D case such relocation is even more obvious than the previously shown NACA0012 case (cf. Figure 5.6), as each of the three airfoil elements produces a sonic line refinement due to the adjoint. In these locations, the adjoint adaptation enforces the adjoint gradients, as shown in Figure 5.13.

Another feature of the W+T-EE pointed out in [START_REF] Clerici | [END_REF], is relative to the boundaries of the turbulence production regions. It is known that here the turbulent viscosity ν t goes to zero with an angle, and hence provides a discontinuous gradient. For this reason, when including the ν contribution in the goal-oriented error estimate, we get a high refinenment on these regions. To validate this fact, we run two different simulations by employing the W+T-EE, each with a different freestream turbulent variable value ν∞ . Usually, the Wolf flow solver sets by default a value of ν∞ = 3ν ∞ , that is, three times the value of the freestream kinematic viscosity. Hence, in addition to the simulation with ν∞ = 3ν ∞ , we have run another simulation with ν∞ = 50ν ∞ , as higher values of the freestream turbulent viscosity smooths the discontinuous jumps of the first derivative of ν. The results are compared in Figure 5.14, which shows the region of the slat cove of the HLCRM2D. We can see that by employing the usual value, the cove region boundary shows a sharper and more refined mesh, and this appears coarser when the discontinuity in the ν derivatives field is damped.

We close this section by showing the mesh across the leading edges of the slat and of the main wing, which show the characteristic dark band due to the sharp profile of the adjoint field, as shown in Figures 3.18-3.19 in Section 3.2. These are shown in Figure 5.15 for both the W-EE and the W+T-EE at the highest complexity, and we see clearly that the mesh patterns provided by the W+T-EE coincide with the adjoint discontinuities. We recall that these features emerge even by simply employing the strongly coupled adjoint inside the W-EE, hence, this is not really due to the turbulent terms inside the W+T-EE. Of course, we get the same behavior when employing the W+T+D-EE, in fact, the same trend can be noticed for the RAE2822 case, in Figure 5.9: despite the fact that the W+T+D-EE coarses the mesh inside the turbulence production regions, the dense thin layer of elements above in the W+T+D-EE case, which is not present in the W-EE approach, is due to the first derivative jump of ν.

Onera M6 (OM6)

In this section, we apply the methodologies developed so far on the Onera M6 (OM6) wing under transonic conditions. This is a 3D case, and the wing is a swept, semi-span wing with an aspect ratio of 3.8. The leading edge has a sweep angle of 30 • while its trailing edge of 15.8 • . The chords has an adimesional length of 1, while the wing is in the center of a the domain which is a semi-sphere having an adimensional radius of 100. The other half of the domain is modelled through a symmetry plane. The physical parameters are shown in Figure 5.7, while the numerical parameters are shown in Table 5.8. The initial mesh and solution are shown in Figure 5.16, and also in this case the initial mesh does not capture flow features like shocks and boundary layers. The initial mesh has 31156 vertices.

N V,min 10K N V,max 2560K Limiter Gamma(2) τ N ewton 1 τ SGS 1

SGS iterations 20

LogRes N ewton 1e-12

Res SGS 1e-2 We apply the C-continuation algorithm shown in Algorithm 6 starting with a complexity of 10 000, and this is doubled until we reach a complexity of 2 560 000. Note that in this case the actual number of vertices of the adapted meshes is approximately twice the nominal complexities as shown in Table 5.8, hence we start the computations from meshes having a number of vertices ∼20 000 up to ∼5 000 000. The target functional is the drag coefficient C D . The obtained values of C L , C D , C Dp and C Df for each mesh complexity are shown in Figure 5.17 for the multiscale adaptation (using the Mach number as a sensor field and the L 4 norm), the W-EE, the W+T-EE and the W+T+D-EE. We start our comment about convergence from the drag, as this is the targeted functional by the adaptation process. In constrast to the multiscale adaptation, the goal-oriented error estimations are able to speed up the convergence of the goal functional C D , as pointed out in [Frazza 2018], because these have an early capturing of the boundary layer. We notice anyway that the C Df is higher in the case of the multiscale adaptation, as this is able to resolve better the flow in this location. Specifically for low mesh complexities, the W+T-EE has the fastest convergence. This is only due to the trade-off between the C Dp and the C Df , as taken singularly these trends show the worst convergence specifically with the W+T+D-EE. In particular the C Df , as the vertices are relocated from the boundary layer to the sonic line. This is also the consequence of the different C Df : in Figure 5.18 we show a zoom over the convergence plot of C D and C Df , and we see that here the differences among the approaches span ∼5 drag count for C D and ∼2 drag count for C Df . This means that, in the case of the goal-oriented approaches, even if the boundary layer is not completely resolved, the target functional J = C D is better approximated. In Figure 5.19, we show the wing tip location, and specifically the computational meshes obtained with the W+T-EE and the W+T+D-EE on a cutplane orthogonal with respect to the flow direction (x = -1.015), and the values of C Df for both the approaches. We can see that the adjoint interpolation error mostly reduces the refinement on this location.

Another difference between the W+T+D-EE approach and the others concerns the shock waves location. To underline this, we show the p values in the suction region above the wing, in Figure 5.20. Here, the mesh provided by the W+T+D-EE is less refined and isotropic with respect to the W-EE (the same difference exists when comparing to the W+T-EE). This has an impact also on the shock wave location: of this thesis. In fact, the geometry represents an aircraft [Lacy and Clark 2020], in the so-called high-lift configuration. It includes a multi-element wing with leading edge and trailing edge devices, and these comprehend the slat and its brackets, two flaps and their fairings, one nacelle connected to the main wing trough a pylon and a vortex generator (see Figure 5.23). The presence of these components produces complex flow patterns: the boundary layer of each component develops from stagnation to developed turbulence, the junctions produce corner flows, the generated wakes interact with boundary layers, and the coves create circulation regions [Park 2022]. For instance, in Figure 5.24, we show the vorticity magnitude on several cutplanes parallel to the main wing, relative to a simulation conducted with an angle of attack α = 7.05 • , where we can see the interaction between the wake generated by the nacelle and the boundary layer of the main element, and, in the outboard region of the wing, the wakes generated by the slat brackets, producing small perturbation over the main wing. In Figure 5.25, we can see the separation induced by the flap fairings for the same run on several cut planes orthogonal to the y axis. As for the other cases, we show the physical parameters in Table 5.9, and the numerical parameters in Table 5.10. • Fixed Grid RANS (RANS),

• Mesh Adaptation for RANS (ADAPT),

• High Order Discretization (HO),

• Hybrid RANS/LES (HRLES),

• Wall-Modeled LES and Lattice-Boltzmann (WMLESLB). The present work has been pursued within the activities of the ADAPT TFG. The Spalart-Allmaras turbulence model is expected to deviate substantially from experimental data near the high-lift angle of attack, hence the objective of the TFG is not to validate the turbulence model, instead, the primary objective is to verify mesh adaptation for the Spalart-Allmaras model, in particular by controlling the discretization error of the lift coefficient. Several numerical entries of the workshop have been pursued by using the W-EE described in [START_REF] Alauzet | [END_REF]]. Here, we analyze the results relative to the W+T-EE and we compare them to the W-EE results obtained with Wolf. We do not show here the results with the W+T+D-EE as this turned out to be problematic in certain cases, as shown previously with other benchmarks, and, in addition, in this benchmark it is important to capture properly boundary layers, and the W+T+D-EE has the lowest accuracy in this sense.

Experimentally, the present geometry reaches the highest lift coefficient with an angle of attack of around 19 degrees. The data requested for the workshop are relative to a range of angles of attack. In the simulation provided here, the angle of attack spans from 7.05 to 23.05 (with an increment of 0.5 degrees), in order to study the Spalart-Allmaras model behavior at high-lift configuration. One can get the desired simulation results by running a C-continuation loop as in Algorithm 6 for each angle, starting from a non-adapted mesh. But, as pointed out in [Park 2022], this benchmark shows multiple solutions, that is, one can get different solutions by starting from different initial guesses, and the C-continuation algorithm could have a poor robustness in this sense. In order to target a "desirable" solution, we implement the so-called α-continuation algorithm. Here, at first, one get the simulation results at the starting angle of attack by running a C-continuation algorithm. Then, when a certain compexity is reached (in this case, 5 120 000 vertices), one get the next angle of attack solution by running a simulation at fixed complexity (still 5 120 000 vertices), and by using the final solutions of the previous angle as an inital guess. The algorithm is schematized in Figure 5.26. both the approaches are equivalent for angles of attack smaller than 15.55. Then, with the W+T-EE the lift coefficient is higher, and it provides a more reliable estimate of C L,max than the one of the W-EE. The explanation of this beahavior can be found in the trend of C Df . As pointed out in the other cases, the W+T-EE resolves in a better way the boundary layer, and this provides more accurate estimate of the skin friction, in the sense that it is more aligned with the other entries of the Workshop. In this way, the separation regions of HLPW4 and the interaction regions between wakes and boundary layers are better resolved. Within the activities of the Workshop, several locations of the HLPW4 are suspected to present multiple solutions, and these are:

• the inboard flap region,

• the outboard slat brackets,

• the nacelle and wing root.

When comparing the W-EE and the W+T-EE, we noticed that these are the regions where the two approaches differ most. In the sequel, we analyze in detail each location.

Nacelle and wing root separation

Another region of interest is the one including the nacelle, the pylon and the wing root. Some entries of the Workshop show a separated flow in the upper part of the nacelle at α = 11.29, while for others it is still attached. By comparing the W-EE and the W+T-EE (see Figure 5.31), we see that both the approaches provide an attached flow over the upper part of the nacelle up to α = 14.05. The W-EE detaches the flow on that region for α = 16.05. At α = 19.55, that is, the angle providing C L,max for the present case, both the W-EE and the W+T-EE provide a separated flow over the nacelle, but their separation pattern is different (Figure 5.31). By looking at the plot of C L in Figure 5.27 we see that the main part of the deviation between the W-EE and the W+T-EE trends is due to the nacelle separation and its effect on the main wing. Figure 5.32 shows the adapted computational mesh on a cutplane orthogonal to the y axis at y = -9.62 passing through the nacelle and the pylon at α = 19.55, and we clearly see how, in the case of the W+T-EE, the boundary layer and the wake of the nacelle are better captured. Figure 5.33 shows the vorticity magnitude |ω| and the adapted mesh on a cut plane orthogonal to the x axis at x = -32.38 for both the approaches: we can see the different separation pattern generated by the nacelle for the W-EE and the W+T-EE. adaptation. Apart from the first two entries, most of the other ones used the C-continuation loop. We start the comparison by showing a single C-continuation loop relative to the first angle of attack α = 7.05. We show the convergence of C L , C D and C m in Figure 5.34. We see that, despite the fact that the Wolf entries are not enough mesh converged, these are aligned with the other Workshop results, and there are not relevant differences between the W-EE and the W+T-EE.

Concerning the α-continuation loop, the trends of the aerodynamic coefficients of all the platforms are shown in Figure 5.35, which shows the values of C L , C D , C m and the polar plot (C L vs C D ) for α ≥ 12.5, in order to focus on the C L,max region only. Concerning the C L trend, we have that the highest estimate is given by the FUN3D (37M) run, which provides a value of around C L,max 2.53 at α 19, while the lowest value is given by Wolf W-EE (10M), with C L,max 2.44. Concerning the W+T-EE, Wolf provides a value C L,max 2.48, which is near the values provided by GGNS-MS (55M), HEMLAB (12M) and FUN3D (20M). For angles of attack lower than 16 degrees, both the W-EE and the W+T-EE are aligned with most of the Workshop entries. The W-EE provides the lowest lift coefficient for α ≥ 16.05 because of the flow separation at the nacelle leading edge. In any case, the FUN3D (37M) entry noted incomplete iterative convergence, and this could explain its deviation from the other entries, which appears remarkable in the plots of C D and C m . Concerning the entry of ITU HEMLAB, some issues have been reported with iterative convergence and a sensitivity to CF L number, and the relative skin friction fields appear noisy despite the fact that values of the aerodynamic coefficients are aligned with the other Workshop entries. Concerning the C m plot, we observe that a higher peak is detected with Wolf W+T-EE than those of FUN3D (20M) and GGNS-MS (55M), but it is lower than the one of GGNS-GO (55M). This could suggest that a higher number of nodes is desirable even with the W+T-EE, as it is not fully mesh-converged. Eventually, the same observations for C L and C D apply to the polar plot (C L vs C D ).

Conclusion

In this chapter, we have introduced the goal oriented error estimate, linking the discretization error on a functional to a weighted sum of the interpolation errors of the primal and the adjoint variables, with the weights depending on the flow fluxes and their derivatives. We have written the error estimate specifically for the RANS equations, making use of the Spalart-Allmaras turbulence model. We started from a first formalization introduced in [START_REF] Alauzet | [END_REF], where the weakly coupled adjoint solver is used along with the mean-flow part only of the fluxes, and we incremented such estimate by adding the Spalart-Allmaras fluxes, the Spalart-Allamras variable ν interpolation error, and the interpolation error of all the adjoint variable. We found out, in general, that the introduction of turbulence enriches the computational mesh with physics-related information coming from the source terms of the Spalart-Allmaras equation, and that the convergence of the target functional is faster. In addition to this, the use of the strongly coupled adjoint inside the primal variable weights allows to capture more accurately boundary layers and wakes. In contrast to this, the introduction of the adjoint interpolation error seems not to be beneficial in general, since, as pointed out in Section 3.1.2, very often the adjoint solutions are discontinuous, and, hence, such discontinuities relocate vertices from relevant regions like boundary layers and shock waves. The consistency of the adjoint problem seems to have a role in this sense, and hence the overall mechanism should be studied more deeply. Eventually, we remark that the early capturing of the boundary layer property of the W+T-EE has a beneficial effect on the HLPW4 benchmark. Thanks to the introduction of turbulence, the separation from the leading edge of the nacelle advances progressively in contrast to the error estimate making only use of mean-flow quantities. This allows to have more reliable estimate of C L,max , which are more aligned to those provided by the Workshop participants. We remark that Wolf obtained reliable solutions with the W+T-EE using meshes of 10 millions of vertices. Such solutions are comparable to those of FUN3D and GGNS both in terms of functional convergence and local skin friction field, and these entries are using meshes with a number of vertices varying from 20 to 55 millions. In any case, the number of vertices used for the W+T-EE seems not to be enough to reach full mesh-convergence, and hence a run with a higher mesh complexity should be pursued, at least to study the behavior of the estimate for finer meshes.

Conclusion and Perspectives

Conclusion

In this work, we have described the Wolf RANS flow and adjoint solver, which is employed for the RANS equations resolution on highly anisotropic unstructured meshes, and we have shown several metric-based mesh adaptation strategies to adapt the computational mesh for high-fidelity RANS simulations. Even if not widely spread nowadays, the use of automatic mesh adaptation turns out to be a powerful tool to increase the solution accuracy and, at the same time, to reduce the computational resources, as it is possible to capture the physics even at small scales, for example in boundary layers, shock waves, leading and trailing edges and wakes, while avoiding the refinment in regions characterized by a constant or a smooth field.

Wolf RANS flow and adjoint solver is based on a vertex-centered mixed finite-element -finite-volume formulation. It allows to control the amount of artificial diffusion, and the convergence of the nonlinear solver, as well as the convergence of the linear one, by controlling locally the CF L number and the limiter in an automatic way. We have studied in detail the behavior of the limiter functions, as it is strongly linked with the convergence of the local residual and with the oscillations of the local solution increment. In fact, continuous limiter activations and deactivations make the local residual convergence difficult, and this has an impact even on the global convergence. We have circumvented this problem either by automatically activating the limiter for low-magnitude gradients, or by acting on the CF L for vertices showing an oscillating solution. We have also studied the impact of local mesh modifications to break residual limit cycles, and it shows promising results, even if it is still an explorative methodology with a wide margin of improvement.

Still concerning the RANS flow solver, we have introduced the strong coupling between the mean-flow equations and the Spalart-Allmaras model, and we have validated the coupling terms by means of finite differences and by comparing the behaviors of the weakly and the strongly coupled solvers on several 2D and 3D cases. Despite the fact that, in general, a strong coupling could not be always beneficial for solving a system of nonlinear equations, we still recommend the use of the strongly coupled solver, as it provides nonlinear convergence rates which are faster, or, as fast as those of the weakly coupled solver, without a relevant algorithmic complexity increase.

The RANS adjoint solver allows the resolution of the weakly coupled and the strongly coupled discrete adjoint systems. When the right-hand-side adjoint functional depends on solution values defined on no-slip surfaces, the use of the strongly coupled adjoint is mandatory to obtain non-zero values for the adjoint Spalart-Allmaras variable ν * . In addition to that, we have shown how the introduction of the strong coupling modifies the adjoint mean-flow variables as well, producing fields which are strongly dependent of the turbulence production and destruction of the Spalart-Allmaras model. In this case, the obtained fields are richer in detail, containing more physics-related information. In any case, we underlined how in most of the cases, there is a dependency between the discrete adjoint field (either weakly or strongly coupled) and the mesh size, in fact, we have shown how the adjoint associated with the RANS equations always increases its magnitude as the mesh size reduces, specially inside boundary layers.

We have introduced the continuous mesh framework to describe rigorously the concept of Riemannian metric space, of unit mesh and of continuous interpolation. With these tools, we have provided the expression of the optimal metric field minimizing the L p norm of the interpolation error of a sensor function u, which is the main ingredient of the multi-scale mesh adaptation. Then, we obtained a general expression linking the discretization error of a functional J(u), being u the solution of a nonlinear variational problem, and a weighted sum of the interpolation errors of the primal and the adjoint solutions associated with the nonlinear problem itself, namely, the goal-oriented mesh adaptation. In particular, we enriched the error estimate developed in [START_REF] Alauzet | [END_REF]] with turbulence and adjoint information. By running several test cases in 2D and 3D, we found out that, in general, the use of the strongly coupled adjoint and the turbulent information are beneficial in terms of boundary layer refinement, early capturing, and for the detection of boundary layer separation lines and points. The impact of the introduction of the adjoint contribution is still not clear: the adjoint adaptation tends to relocate points from physically relevant regions, like boundary layers and shock waves, to regions characterized by adjoint discontinuities, like the sonic line, and this has a negative impact on functional convergence. In addition to that, the adjoint solver of Wolf seems not to be consistent, that is the discrete adjoint solution and the continuous adjoint solution are not converging to the same field as the mesh size decreases: this could introduce an hypothesis violation in the error estimate driving the adjoint-based adaptation.

Eventually, we have applied the turbulence information-enriched error estimate to the common research model of the 4 th AIAA CFD High Lift Prediction Workshop. This benchmark is of particular interest as it is suspected to have multiple solutions, and in this case the introduction of the turbulent information in the error estimate has helped to target solutions which are closer to the other entries of the Workshop by using, at the same time, a smaller number of elements. In particular, the W+T-EE turned out to be much more accurate that the W-EE in the detection of the separation lines on the flap and on the nacelle of the geometry, and this has a dramatic improvement on the estimation of C L,max .

Perspectives

The aim of this work is to run high-fidelity RANS simulations with the help of mesh adaptation, hence it is crucial to use a RANS flow solver being capable to successfully run on highly distorted anisotropic meshes. For this reason, it is necessary to increase the robustness of the Wolf flow solver. The most direct approach is to act on the local CF L number and the limiter selection, and to introduce more sophisticated tuning mechanisms. The main problem of this kind of approaches is the introduction of additional parameters which are difficult to be tuned, like, for instance, the parameter of the modified Gamma limiter of (1.16), which deactivates the limiter function in smooth field regions, or the threshold to locate a shock wave in order to apply the limiter on it. Hence, it is desirable to automatize this kind of processes to reduce the human intervention and speed up the parameter setup phase.

Concerning the linear system resolution, the replacement of the SGS solver with a more robust one could come in hand, but both the GMRES and the algebraic multigrid seem not to bring any substantial improvement, except for few particular cases. For this reason, alternative approaches should be considered, like, for instance, the incomplete LU factorization (ILU) [Saad 2003]. As the classical LU factorization greatly increases the size of the lower and the upper part of the matrix, to overcome this issue, the ILU considers restricted sparsity patterns of the factorization matrices, with a lower level of fill-in. Such method turns out to be particularly robust when used as preconditioner for GMRES, but it is more difficult to parallelize in contrast to the SGS method, specially for high levels of fill-in.

Eventually, still concerning the flow solver, a mesh optimization algorithm to increase the diagonal dominance of the Jacobian of the residual could help to reduce the number of SGS iterations needed to solve each linear system, but it is still an explorative study showing promising results in breaking local residual limit cycles. The diagonal dominance associated with each vertex depends on the values of the surrounding points, and hence a global optimization algorithm should be pursued in order to increase globally the diagonal dominance.

Concerning the adjoint problem resolution, the biggest question to be answered concerns the adjoint consistency between the implemented discrete adjoint and the continuous one. In Wolf, the discrete adjoint solution seems not to converge to the continuous one as the mesh size decreases. In fact, there is a strong mesh dependency between the mesh size and the adjoint magnitude. The clarification of this mechanism is also propedeutic for the dual error estimate developed in Chapter 5, as it assumes the consistency of the discrete adjoint problem. A possible approach to get more insight about this topic, is to implement the continuous adjoint solver, and to compare the two obtained solutions as the mesh size reduces.

The adjoint system, either weakly or strongly coupled, turns out to be particularly stiff, and hence it requires a robust solver to get a reliable adjoint solution. We found out that varying the number of SGS iterations in the FGMRES solver is the most promising approach to get reliable solutions without wasting computational resources. In this work, we only tested the increase of the number of SGS iterations, but we noticed that it could be beneficial to tune this parameter automatically in order to improve the residual decrease with respect to the CPU time. To do that, one should compute the rate of residual reduction with respect to the execution time for a given number of SGS iterations, and then evalute the variations of such quantity with respect to the number of preconditioning iterations to decide its optimal value.

Concerning the W+T-EE, we observed that the leading and trailing edge adjoint discontinuities underlined by mesh adaptation in 2D cases are not well-resolved in the 3D ones, and for this reason the W+T-EE should be run at higher mesh complexities to understand whether or not such features are present in 3D. A very similar test should be applied to the CRM-HL, as it seems to require a higher number of vertices in the C-and the α-continuation loops, and, at the same time, one should compare with the other Workshop entries by using a more comparable number of vertices (between 20 and 55 millions). An easy way to reduce the computational cost of this test is to reuse the alpha-continuation results obtained with 10 millions of vertices. In fact, one can select few angles of attack, and run a C-continuation loop by using the results at 10 millions of vertices as initial guesses, but this procedure could inherit some inaccuracies of the present simulation data.

Eventually, concerning the W+T+D-EE, one should pursue a comprehensive study of the adjoint problem consistency and the adjoint interpolation error term, as these two topics are strictly connected. We expect that the resolution of the continuous adjoint problem and the use of the continuous adjoint solution inside the error estimate should improve the the W+T+D-EE, as the inconsistency issue should not be present in this case. More advanced study could be made concerning the discrete adjoint problem, in order to make it consistent and to remove the dependency of the adjoint magnitude on the mesh size. Title: Anisotropic mesh adaptation for high-fidelity RANS simulations with application to aeronautics Keywords: Scientific computing; Anisotropic mesh adaptation; Error estimation; Computational fluid dynamics; Turbulence modeling; Aeronautics Abstract: In the context of fluid simulations, anisotropic mesh adaptation is a promising tool to capture automatically the main features of a flow on complex geometries without the requirement of prohibitive computational resources. In particular, such technique aims at finding the mesh which minimizes the discretization error committed on a certain quantity, in general the solution itself, or a functional, such as the lift or the drag coefficients. The objective of the present work is to improve the current RANS solver and to enrich the anisotropic error estimation with additional information coming from the turbulence model. For this reason, this work is divided into three main contributions. The first concerns the improvement of the RANS flow solver, in particular by applying novel and automatic CFL and limiter tuning strategies to control the residual convergence, and, the introduction of the strongly coupled turbulence to improve Newton convergence of the nonlinear equations. The second contribution concerns the resolution of the adjoint problem, which turns out to be particularly stiff if compared to the primal flow counterpart resolution, and, at the same time, is of great importance when adapting meshes; here, several methods have been applied to the resolution, such as the flexible GMRES and the pseudo-transient continuation. In addition to that, we have studied the strongly coupled turbulence for the adjoint problem, and we found out that such introduction enriches the adjoint flow with more physics-related information. Eventually, the third contribution concerns the error estimate driving the mesh adaptation procedure, which here includes the turbulent contribution coming from the primal and the adjoint flow fields. These procedures have been applied to both classical benchmarks of aeronautics as well as to more complex geometries like the common research models of the 3rd and the 4th AIAA CFD High Lift Prediction Workshops.

Figure 2 -

 2 Figure 2 -Cascade de Triberg, Allemagne : à gauche, on voit une photographie obtenue avec un temps d'exposition court, tandis qu'à droite, on voit une photographie de la même scène en utilisant un temps d'exposition supérieur à la période de fluctuation du fluide, ce qui donne une image moyennée dans le temps.

Figure 5 -

 5 Figure 5 -Triberg waterfall, Germany: on the left it is shown a photograph obtained with a short exposure time, while on the right it is shown a photograph of the same scene by using an exposure time bigger than the fluid fluctuation period, resulting in a time-averaged image.

Figure 1

 1 Figure 1.1 -Two examples of 2D triangular (left) and 3D tetrahedral (right) meshes.

  Figure1.2 -Portion of the median cell C i relative to an element K associated with the vertex P i , 2D on the left, 3D on the right. We have indicated in red the boundaries of the median cell portion in 2D and 3D. We show also the edge midpoints, indicated by P i P j /2, P i P k /2, and, in 3D, P i P l /2, and the barycenter of each element G. In 3D, we have also indicated the barycenter of the involved faces, G f i , G f k and G f l .

Figure 1

 1 Figure 1.3 -Representation of the upwind and downwind triangles used in the 2D MUSCL extrapolation scheme. These are indicated in red, while the finite volume cells are shown in green. A zoom on the right of the image is showing the normals (green) associated with each cell inteface segment, and (bold black) the resulting normal used in the flux computation. With M i and M j (red) we indicate the points involved in the computation of the V6 gradients.

Figure 1 . 4 -

 14 Figure 1.4 -Representation of the upwind and downwind tetrahedra used in the 3D MUSCL extrapolation scheme, indicated in red. With M i and M j (red) we indicate the points involved in the computation of the V6 gradients.

  Figure 1.6 -A smooth viscous field over a NACA0012 airfoil.

Figure 1 . 7 -

 17 Figure 1.7 -Value of R for the case shown in Figure 1.6 for different zooms.

Figure 1 . 8 -

 18 Figure 1.8 -On the left, V1-ball vertices (red) of the point P i (yellow), on the right, V2-ball vertices (red) of the point P i (yellow).

  Since D + L and D + U are, respectively, a lower and an upper triangular matrix, (D + L)X = Y and (D + U)X = Y can be solved exactly, respectively, with a forward and a backward sweep Forward sweep: (D + L)δW * = R Backward sweep: (D + U)δW n = DδW * .

  Figure 1.9 -Transonic Euler NACA0012: continuity equation residual field and limiter oscillations.

Figure 1

 1 Figure 1.11 -RAE2822 airfoil in transonic conditions: plot of the residual for different dissipation increase strategies.

Figure 1

 1 Figure 1.14 -DPW7 in transonic conditions: plot of C L for the mesh convergence study.

  Figure 1.15 -Transonic RAE2822, α = 2.31, M a = 0.729, Re = 6.5e6.

Figure 1

 1 Figure1.18 -Transonic RAE2822, α = 2.31, M a = 0.729, Re = 6.5e6. Breaking of the limit cycle of vertex 2104 by applying transformation (1.28) after 500 time iterations.

  Figure2.1 -Comparison between the weakly coupled and the strongly coupled Jacobian Newton method to solve the system (2.1) dependong on the starting point: x 0 = (1, 1) T on the left, x 0 = (10, 10) T on the right.

Figure 2

 2 Figure 2.2 -RAE2822 airfoil test case: mesh on the left, Mach number on the right.

Figure 2

 2 Figure 2.3 -HLCRM2D airfoil test case: mesh on the left, Mach number on the right.

Figure 2

 2 Figure 2.4 -NACA0012 airfoil test case: mesh on the left, Mach number on the right.

Figure 2 Figure 2

 22 Figure2.6 -RAE2822 airfoil fixed mesh test case: ρ-residual on the left, ν-residual on the right. Here, all the approaches provide the same convergence rate.

Figure 2 .

 2 Figure 2.15 -OM6 wing test case: mesh on the left, Mach number on the right.

Figure 2 .

 2 Figure 2.16 -HLPW3 geometry test case: mesh on the left, Mach number on the right.

Figure 2 .Figure 2

 22 Figure 2.17 -DPW7 geometry test case: mesh on the left, Mach number on the right.

  Figure 2.20 -DPW7 geometry test case: ρ-residual on the left, ν-residual on the right.Here, we see that the strongly coupled approach performs significantly better than the weakly coupled one.

  Figure 2.21 -Average CFL vs time step for the HLPW3 (left) and the DPW7 (right) fixed mesh tests.

CC

  Figure 2.26 -HLPW3 airfoil test case: aerodynamic coefficients for each time iteration.The performances in terms of functional convergence is comparable for both the weakly coupled and the strongly coupled approach.

  Figure 3.1 -Discrete adjoint density field obtained with GGNS and Wolf based on the same mesh and primal solution. GGNS is employing the continuous adjoint solver based on the finite element formulation of the primal flow solver, while Wolf is using the discrete adjoint solver based on the mixed finite-element finite-volume formulation.

  39) is indicating, is that the values of discrete adjoint solution component W * i is not dependent of the values it takes on the boundary conditions points W * b . In fact, these values can be computed afterwards by multiplying (3.37) by B, leading to

  Figure 3.2 -Primal and adjoint solutions of the HLCRM2D.

  Figure 3.3 -HLCRM2D anisotropic adapted meshes: 64k vertices on the left, 256k vertices on the right.

  46) holds for any ψ ∈ V , this provides the strong form of the adjoint problem associated with (3.41), that is-β • ∇u * -µ∆u * = g.(3.49)

  Figure 3.4 -HLCRM2D adjoint density field: case with 64k vertices on the left, case with 256k vertices on the right. Above the colormap with the original scale, below the colormap with the same (64k) scale.

Figure 3

 3 Figure 3.5 -On the left it is shown the adjoint solution obtained with the 256k mesh and the 64k primal solution. On the right the 256k original adjoint solution. The scale used is relative to the calculation on the left.

Figure 3

 3 Figure 3.6 -On the left it is shown the adjoint solution obtained with the 64k mesh and the 256k primal solution. On the right the 256k original adjoint solution. The scale used is relative to the calculation on the left.

Figure 3

 3 Figure3.8 -HLCRM2D case: plot of the profiles of W h obtained with mesh adaptation based on the weakly coupled adjoint (on the left column) and the strongly coupled adjint

  Figure 3.11 -Adjoint density fields obtained with the weakly coupled adjoint solver (left) and the strongly coupled adjoint solver (right) on the HLCRM2D case. The mesh

Figure 3 .

 3 Figure 3.14 -Adjoint density fields obtained with the weakly coupled adjoint solver (left) and the strongly coupled adjoint solver (right) in the region of the main wing trailing edge.

Figure 3

 3 Figure 3.15 -Line plots of D, f w , r and ω z in the slat trailing edge region shown in Figure 3.13.

Figure 3 .Figure 3

 33 Figure 3.16 -Location (black line, approximate) of the line plots in Figure 3.15.

  Figure 3.22 -Adjoint density fields obtained with the weakly coupled adjoint solver (left) and the strongly coupled adjoint solver (right) on the HLPW3 case. The mesh used is the final step of an adaptation process with a complexity of 10 240 000 vertices.

Figure 3 .

 3 Figure 3.23ν * obtained with the strongly coupled adjoint solver on the HLPW3 case

Figure 3

 3 Figure3.27 -BiCG convergence on an adjoint problem generated from an adapted mesh over the HLCRM2D airfoil at α = 8, starting from a fully converged primal solution. The mesh has 2 382 678 vertices.

  as this kind of polynomials are expected to regularize the residual convergence. The weights of the BiCGSTAB are obtained by orthogonality and by minimizing the norm of the residual vectors r k = Q k (A)P k (A) (for the full computation see [van der Vorst 1992]).

Figure 3 Figure 3 Figure 3 Figure 3 Figure 3

 33333 Figure3.28 -RAE2822 airfoil test case: weakly coupled adjoint residual for different methods, with respect to the iteration index to the left, and with respect to the cpu time (in seconds) to the right.

Figure 3

 3 Figure 3.33 -Multigrid cycle types for a 4-level AMG partition.

  Figure 3.34 -Stencil of the C-AMG 3-path contribution to the triple matrix product (3.63). On the left the extra-diagonal contribution (i = j), on the right the diagonal contribution (i = j) to the coarse matrix. Here, i and j are both C-points, while k and l are F-points.

  Figure3.36 -Example of point aggregation in G-AMG: here, a coarse mesh of 4 vertices is obtained by aggregating 17 vertices of the fine mesh into 4 groups. In this example, the coarse mesh has 5 edges: 1-2, 1-3, 2-3, 2-4, 3-4.

Figure 3 .Figure 3 Figure 3 Figure 3 Figure 3

 33333 Figure 3.38 -NACA0012 (transonic) AMG test case: Mach number on the left, mesh on the right.

Figure 3

 3 Figure 3.47 -RAE2822 airfoil PSTR test case: on the left it is shown the CF L evolution, on the right the residuals R n sgs and ∆R n .

Figure 3

 3 Figure 3.48 -HLCRM2D airfoil PSTR test case: on the left it is shown the CF L evolution, on the right the residuals R n sgs and ∆R n .

Figure 3 .

 3 Figure 3.54 -Original GMRES and restarted PSTR simulation: N V = 2 million

Figure 4 . 1 -

 41 Figure 4.1 -Results relative to problem (4.1) by optimizing the mesh with respect to the L 1 -norm interpolation error.

Figure 4

 4 Figure 4.4 -Mesh adaptation loop used to adapt a mesh over a solution obtained from a differential problem.

Figure 5

 5 Figure 5.1 -NACA0012 airfoil test case: initial mesh on the left, initial ρ field on the right.

Figure 5

 5 Figure 5.2 -NACA0012 airfoil test case: convergence of C L , C D , C Dp , C Df .

Figure 5 Figure 5

 55 Figure 5.3 -NACA0012 airfoil test case: leading edges for the W-EE and the W+T-EE.

Figure 5

 5 Figure 5.7 -RAE2822 airfoil test case: initial ρ field on the left, initial mesh on the right.

Figure 5

 5 Figure 5.12 -HLCRM2D airfoil test case: convergence of C L , C D , C Dp , C Df .

Figure 5 .

 5 Figure 5.16 -OM6 wing test case: initial ρ field on the left, initial mesh on the right.

Figure 5 .

 5 Figure 5.18 -OM6 wing test case: convergence of C D , C Df (zoom).

  Figure 5.20 -OM6 wing test case: location of the shock-induced separation.

Figure 5 .

 5 Figure 5.21 -OM6 wing test case: wing suction region showing the lambda shock location. Difference between the surface ρe fields obtained with the W-EE and the W+T+D-EE.

Figure 5

 5 Figure 5.22 -OM6 wing test case: convergence of C Dp with respect to the number of vertices for different platforms.

Figure 5 .

 5 Figure 5.23 -HLPW4 aircraft test case geometry, global view and particulars.

Figure 5 .

 5 Figure 5.24 -HLPW4 test case: cutplanes parallel to the main wing, showing the vorticity magnitude in the interaction region between the nacelle and the wing at α = 7.05.

Figure 5 .Figure 5

 55 Figure 5.25 -HLPW4 test case: cutplanes orthogonal to the y axis, showing the vorticity magnitude in the wake of the wing at α = 7.05.

Figure 5 .

 5 Figure 5.27 -HLPW4 test case: values of C L , C D , C Df and C m for each angle of attack α for W-EE and W+T-EE.

Figure 5 .

 5 Figure 5.29 -Experimental oil flow over the HLPW4 geometry, at α = 5.98.

  Figure 5.32 -HLPW4 test case: adapted mesh on a cutplane at y = -9.62 passing through the nacelle and the pylon at α = 19.55.

Figure 5

 5 Figure 5.34 -HLPW4 test case: plot of C L , C D and C m for INRIA Wolf W-EE, INRIA Wolf W+T-EE, NASA FUN3D (stabilized finite element and finite volume), Boeing GGNS (multiscale and goal-oriented), and ITU HEMLAB relative to a C-continuation simulation with an angle of attack α = 7.05.

  Figure 5.35 -HLPW4 test case: plot of C L , C D , C m and polar plot (C L vs C D ) for INRIA Wolf W-EE, INRIA Wolf W+T-EE, NASA FUN3D (20M and 37M), Boeing GGNS (multiscale and goal-oriented), and ITU HEMLAB.

  Titre : Adaptation de maillage anisotrope pour des simulations RANS à haute fidélité: applications à l'aéronautique Mots clés : Calcul scientifique; Adaptation de maillage anisotrope; Estimations d'erreurs; Dynamique des fluides numérique; Modèle de turbulence; Aéronautique Résumé : Dans le contexte de la mécanique des fluides numérique, l'adaptation de maillage anisotrope est un outil prometteur pour capturer automatiquement les principales caractéristiques d'un écoulement sur des géométries complexes sans nécessiter de ressources de calcul prohibitives et d'intervention humaine. En particulier, une telle technique vise à trouver le maillage qui minimise l'erreur de discrétisation commise sur une certaine quantité, en général la solution elle-même, ou une fonctionnelle d'intérêt, telle que la portance ou le coefficient de traînée. L'objectif de ce travail était d'améliorer le solveur RANS, le solveur adjoint et d'enrichir l'estimation d'erreur anisotrope avec des informations supplémentaires provenant du modèle de turbulence. Pour ces raisons, ce travail est divisé en trois contributions principales. La première concerne l'amélioration du solveur RANS. Pour cela, on mis en place de nouvelles stratégies automatiques de contrôle de la CFL et un couplage fort entre les équations de Navier-Stokes et le modèle de turbulence. Ces développements permettent d'améliorer la convergence non linéaire de la méthode de Newton. La deuxième contribution concerne la résolution du problème adjoint, qui s'avère particulièrement raide si on la compare à la résolution du problème primal, et, en même temps, est d'une grande importance lors du processus d'adaptation de maillage. Plusieurs méthodes ont été développées pour la résolution du problème adjoint, telle que la méthode flexible GMRES et une méthode pseudo-transitoire similaire à celle du problème primal. De plus, nous avons étudié l'impact du couplage fort entre les équations de Navier-Stokes et le modèle de turbulence pour le problème adjoint, et nous avons découvert que ce couplage fort enrichit la solution adjointe. En effet, l'état adjoint contient plus d'informations liées à la physique. Enfin, la troisième contribution concerne l'estimation d'erreur pilotant la procédure d'adaptation du maillage, qui inclut ici la contribution turbulente provenant des champs primaux et adjoints. Ces procédures ont été appliquées aussi bien à des benchmarks classiques de l'aéronautique qu'à des géométries plus complexes comme les modèles d'avion complet des 3ème et 4ème AIAA CFD High Lift Prediction Workshops.

Table 1 .

 1 1 -Summary of the Wolf RANS flow solver robustness

	Low robustness	High robustness
	High precision	Low precision
	High order schemes	Low order schemes
	Low dissipation limiters High dissipation limiters
	Local or no freezing	Global freezing
	High CFL	Low CFL

Basically, we found out that the parameters shown in Table

1

.1 should be properly tuned

2

  Table 1.2 -Global and local CF L values by and without applying oepration (1.28) to vertex 2104 in the RAE2822 benchmark

	No modification v2104 modification

Table 2

 2

	.1. The fixed meshes and the

Table 2 .

 2 2 -Parameters relative to the 3D cases We can see that we target the same functional values for any approach.

		RAE = 2.31, M=0.729, Re=6.5e6			RAE = 2.31, M=0.729, Re=6.5e6
		0.73				0.01230
		0.72				0.01225
	CL	0.71			CD	0.01220
		0.70				0.01215
		0.69		weakly cpl strongly cpl		0.01210	weakly cpl strongly cpl
		10 4	10 5	10 6			10 4	10 5	10 6
		NV					NV
		C L vs N V				C D vs N V
		RAE = 2.31, M=0.729, Re=6.5e6			RAE = 2.31, M=0.729, Re=6.5e6
		0.0069		weakly cpl strongly cpl		0.0058
		0.0068				0.0057
						0.0056
	CDp	0.0067			CDf	0.0055
		0.0066				0.0054
						0.0053
		0.0065				0.0052	weakly cpl strongly cpl
		10 4	10 5	10 6			10 4	10 5	10 6
		NV				NV
				Re	M	α	N V
		OM6	4.6e6 0.84 3.06 156 601
		HLPW3 3.26e6 0.2 16.0 625 455
		DPW7 20.0e6 0.85 2.75 508 156

C Dp vs N V C Df vs N V Figure 2

.9 -RAE2822 airfoil test case: aerodynamic coefficients for each mesh complexity.

C

  Dp vs N V C Df vs N V Figure 2.22 -OM6 wing test case: aerodynamic coefficients for each mesh complexity. We can see that the targeted functional values are the same for both the approaches.

				2.38	OM6 = 7.05, M=0.2, Re=5.49e6 HLPW3 = 16, M=0.2, Re=3.26e6				0.270	OM6 = 7.05, M=0.2, Re=5.49e6 HLPW3 = 16, M=0.2, Re=3.26e6
		0.270		2.36							0.0180		0.268
		0.260 0.265		2.34							0.0175		0.264 0.266
	CL	0.250 0.255	CL	2.30 2.32						CD	0.0165 0.0170	CD	0.260 0.262
		0.235 0.245 0.240	10 4	2.28 2.26	10 5	NV	10 6	NV	10 6 weakly cpl strongly cpl	weakly cpl strongly cpl	0.0160 0.0155	10 4	0.258 0.254 0.256	10 5	NV	10 6	NV	10 6 weakly cpl strongly cpl	weakly cpl strongly cpl
				0.254	C L vs N V C L vs N V OM6 = 7.05, M=0.2, Re=5.49e6 HLPW3 = 16, M=0.2, Re=3.26e6					C D vs N V C D vs N V OM6 = 7.05, M=0.2, Re=5.49e6 HLPW3 = 16, M=0.2, Re=3.26e6
		0.017		0.252					weakly cpl strongly cpl		0.005		0.016
		0.016		0.250							0.004		0.015
	CDp	0.015	CDp	0.248						CDf	0.003	CDf	0.014
		0.014		0.246
		0.012 0.013	10 4	0.242 0.244	10 5	NV	10 6	NV	10 6	weakly cpl strongly cpl	0.001 0.002	10 4	0.013 0.012	10 5	NV	10 6	NV	10 6 weakly cpl strongly cpl	weakly cpl strongly cpl

  OM6 wing test case: aerodynamic coefficients for each time iteration. Here, we can see the presence of oscillation trends in the aerodynamic coefficients, due to the presence of the highly-resolved lambda shock. The performances in terms of functional convergence is comparable for both the depicted approaches.

		0.28 0.29		OM6 = 7.05, M=0.2, Re=5.49e6 weakly cpl strongly cpl	0.024		OM6 = 7.05, M=0.2, Re=5.49e6	weakly cpl strongly cpl
		0.27			0.022
	CL	0.26		CD	0.020
		0.25			0.018
		0.24			0.016
		0.23	0	20000 40000 60000 80000 100000 120000 140000	0.014	0	20000 40000 60000 80000 100000 120000 140000
				Iter			Iter
				C L vs iteration			C D vs iteration
				OM6 = 7.05, M=0.2, Re=5.49e6			OM6 = 7.05, M=0.2, Re=5.49e6
		0.024		weakly cpl strongly cpl	0.005		weakly cpl strongly cpl
		0.022			0.004
		0.020			0.003
	CDp	0.018		CDf
		0.016			0.002
		0.014			0.001
		0.012			0.000
			0	20000 40000 60000 80000 100000 120000 140000		0	20000 40000 60000 80000 100000 120000 140000
				Iter			Iter
				C Dp vs iteration			C Df vs iteration
	Figure 2.25 -

Table 3 .

 3 1 -Maximal and minimal eigenvalues, and their ratio

		λ max	λ min	λ max /λ min
	RAE2822 airfoil	662.393 2.61321e-10 2.53479e+12
	HLCRM2D airfoil 40741.9 1.17548e-11 3.46597e+15

Table 3 .

 3 3 -Parameters relative to AMG tests

		Re	M	α	N V	N SGS
	NACA0012 (Subsonic)	-	0.3	2.0	588	20
	NACA0012 (Transonic)	-	0.83	2.0	19837	20
	M3V4 (Uniform)	15.1e6 0.173 16.21 12263	20
	M3V4 (Adapted)	15.1e6 0.173 16.21 19416	20
	HLCRM2D	5.0e6	0.2	8.0	75885	20

Table 4

 4 Linear interpolate Π h Continuous linear interpolate Π M

	.1 -Summary of the continuous mesh framework
	Discrete	Continuous
	Element K	Metric M
	Mesh H	Riemannian metric space M(x)
	Number of elements N	Complexity C(M)

Table 5 .

 5 1 -Physical parameters relative to the NACA0012 case

	Re	6.0e6
	M	0.15
	T	300
	α	10
	Adjoint	C L
	Table 5.2 -Numerical parameters relative to the NACA0012 case

Table 5 .

 5 3 -Physical parameters relative to the RAE2822 case

	Re	6.5e6
	M	0.729
	T	300
	α	2.31
	Adjoint	C D
	Table 5.4 -Numerical parameters relative to the RAE2822 case

  RAE2822 airfoil test case: convergence of C L , C D , C Dp , C Df .

	CL CDp	10 4 RAE2822 M=0.729, = 2.31, Re=6.5e6 10 5 NV MS L4 10 6 W-EE W+T-EE W+T+D-EE C L 10 4 10 5 10 6 NV RAE2822 M=0.729, = 2.31, Re=6.5e6 MS L4 W-EE W+T-EE W+T+D-EE C Dp Figure 5.8 -Table 5.5 -Physical parameters relative to the HLCRM2D case 10 4 10 5 NV 0.0121 0.0122 0.0123 0.0124 0.0125 0.0126 0.0127 CD RAE2822 M=0.729, = 2.31, Re=6.5e6 MS L4 10 6 W-EE W+T-EE W+T+D-EE C D 0.0066 0.67 0.68 0.69 0.70 0.71 0.72 0.73 0.0068 0.0070 0.0072 10 4 10 5 10 6 NV 0.0048 0.0050 0.0052 0.0054 0.0056 0.0058 CDf RAE2822 M=0.729, = 2.31, Re=6.5e6 MS L4 W-EE W+T-EE W+T+D-EE C Df Re 5e6 M 0.2 T 272.1 α 16 Adjoint C L Table 5.6 -Numerical parameters relative to the HLCRM2D case

Table 5 .

 5 7 -Physical parameters relative to the OM6 case

	Re	14.6e6
	M	0.84
	T	300
	α	3.06
	Adjoint	C D
	Table 5.8 -Numerical parameters relative to the OM6 case

Table 5

 5 In the context of the 4 th AIAA CFD High Lift Prediction Workshop, such case has been studied by 6 Technical Focus Groups (TFG), each focusing on a different methodology, namely• Geometry Modeling and Preparation for Meshing (GEOM),

	.9 -Physical parameters relative to the HLPW4 case
	Re	5.49e6
	M	0.2
	T	289.444
	α	from 7.05 to 23.05
	Adjoint	C L

Remerciements

able to reach a proper convergence (also for lower complexities), but it is able to preserve the solution structure thanks to the restarting from a previous solution. Furthermore, the pseudo-transient algorithm is more efficient in terms of cpu time and in terms of storage, as it does not require to store hundreds of Krylov vectors. Since the adjoint density fields obtained with the GMRES and the pseudo-transient algorithm are structurallty different, we perform a crossed simulation by running a pseudo-transient algorithm on a mesh with 1 million of vertices obtained by using the GMRES from the beginning, and using the corresponding GMRES converged solution as its initial value. This check is done in order to verify whether the pseudo-transient algorithm is able to keep the solution in the same basin of attraction of the previous valid solution. The result is presented in Figure 3.53, together with the original result obtained with a psuedo-transient adjoint algorithm from the beginning, for a mesh complexity of 1 million of vertices. We note that the pseudo-transient adjoint restarted on a GMRES converged solution still stalls, even on a lower residual, but it is able to preserve the structure of the converged solution obtained in the previous iteration. Hence, it makes sense to introduce a mechanism for the selection of the adjoint solver as follows:

• if the GMRES converges, then set to zero the next adjoint first guess and use again the GMRES, • if the GMRES stalls, interpolate the previous valid adjoint field and apply the PSTR from now on. Hence, based on the results shown in Figure 3.53, we conduct another simulation where the adjoint solver is switched from the GMRES to PSTR at 2 millions of vertices, and the solution of the discrete problem (5.3), z ∈ V the solution of the continuous adjoint problem (5.4), and z h ∈ V h the solution of the discrete adjoint problem (5.5). Then, we have that

(5.9)

where R (2) is a second order remainder in ((u -u h ), (z -z h )).

Before proceeding with the proof, we comment the result of Theorem 5.1.1. The expression in (5.9) allows us to bound the discretization error of the functional J, and such upper bound consists in a weighted sum of the interpolation errors of the primal solution u and of the adjoint solution z. That is, if applied to the RANS equations, it provides a form which is very similar to (5.1). Note that when u h solves exactly the discretized continuous problem, i.e., u h = u h , we have

where R (3) is a third order reminder, and such estimate represents the error estimate developed in [Frazza 2018]. The final term (Ψ(u h ), z h ) of (5.9) arises from the analysis of [Rannacher and Vihharev 2013], and here it is used to evaluate the convergence of the nonlinear problem. In this work it is basically neglected, but, nontheless, even this term is canceled when assuming u h = u h . We now proceed with the proof of Theorem 5.1.1.

Proof. From [Rannacher and Vihharev 2013], we have the following third-order approximation of J(u) -J(u h )

(5.10) with R (3) a third-order reminder. We now divide the error contribution due to the interpolation, u -Π h u, and the implicit error Π h u -u h . We have that

(5.11)

Thanks to the discrete adjoint problem definition (5.5),

Here, we assume that Π h u -u h converges strongly to zero with at least order 1, and that Ψ h (u h ) -Ψ (u h ) weakly converges to 0, with the same order. Hence, we end up with obtained by integration by part so that the gradient is moved from the derivative of the convective fluxes to the adjoint variable. The viscous fluxes contribution, in addition to the same integration by part, is characterized by the fact that its linearization is pursued with respect to the gradient of W h , as these terms are linear in ∇W h . Hence, more precisely, the objective of the next sections is to write an error estimate for the RANS equations so that • depends on the Spalart-Allmaras variable ν and fluxes,

• do not consider a constant turbulent viscosity when computing the viscous contribution, • depends on the strongly coupled adjoint variables.

Convective and viscous contributions

In this section, we describe the convective and the viscous contributions to (5.9), which have been widely developed in [Frazza 2018], but do not include turbulence. For this reason, we also refer to these terms as the mean-flow contribution. For the moment, we reduce the form of (5.9) to

(5.13)

In practice, we neglect the adjoint contribution, and we assume that ũh = u h . In [Frazza 2018], two approaches are compared to get the weights of (5.13). Here, it is considered (5.14) where the second and the third expression of (5.14) provide different weights to the interpolation errors of (5.13). Since, experimentally, the approach given by the second expression of (5.14) produces better results, and since it is easier to treat the viscous flux contribution, we rely on it. Hence, explicitly, we have

(5.15) Before going further, we provide three auxiliary results. The first concerns an approximation on a term of the type (V (W ) -V (Π h W ))f (Π h W ), where V is a physical variable, and it is given by the following Lemma 5.2.1. Let f ∈ C 1 , W the vector of the conservative variables of the RANS equations, V the vector of the physical variables and Π h the interpolation operator. Then,

up to a second order reminder in h.

Proof. We have that W-EE W+T+D-EE Figure 5.9 -RAE2822 airfoil test case: mesh inside the turbulence production region of the suction area (middle of the chord length) for the W-EE and the W+T+D-EE.

we show the regions of the turbulence production in the suction area, and the shock wave. Figure 5.9 shows the region of turbulence production, and we see that in the case of the W+T+D-EE this is less refined, and justifies why the C Df is lower for a given complexity when including the adjoint contribution. The worst impact on the mesh, anyway, is located on the shock wave, which is shown in Figure 5.10 for all the adaptation strategies. Here, the shock location is slightly different for all the cases, and the mesh in the W+T+D-EE case is basically isotropic, coarser, and less precise than the other approaches. As pointed out in [START_REF] Giles | [END_REF], the locations characterized by a discontinuous primal flow do not necessarily show a discontinuous adjoint field, and hence the adjoint interpolation error contribution has a smoothing effect on shock waves.

4 th AIAA CFD High Lift Prediction Workshop 2D common research model (HLCRM2D)

The third considered case is the 2D geometry used as common research model for the 4 th AIAA CFD High Lift Prediction Workshop. It is a multi-ement airfoil, and it is set in the center of a square having an adimesional side of length 2000. The complete description of the test case can be found in [Ursachi et al. 2020, Michal et al. 2020]. In particular, the main contributions reported here concerning the W+T-EE have been presented at the AIAA SciTech Forum 2022, and can be found in [START_REF] Clerici | [END_REF]. Likewise the NACA0012 and the RAE2822 airfoils, we show here the initial mesh and the initial ρ field in Figure 5.11, while the physical and the numerical parameters are shown in Tables 5.5-5.6. For this case, we use the C L as goal functional driving the mesh adaptation, and the set of complexities are the same as for the NACA0012 benchmark. The maximal complexity for this case has been bounded to 256000 vertices, as the functionals are basically stationary after this value. Anyway, some of the figures in the sequel are showing meshes and solutions at 1024000 vertices, to show several peculiar characteristics of the inclusion of turbulence and adjoint.

Inboard flap separation pocket

We can see in Figure 5.27 that the C L has a small drop in its increase at α = 11.05. This is due to two boundary layer separations. The first separation occurs because of the wake generared by the first outboard bracket, which, is already present even at α = 7.05 but is enlarged at α = 11.05, and it is not present in the experiments [Park 2022]. The second one is represented by a small separation pocket on the inboard flap, where it meets the fuselage, which gets bigger at α = 11.05. To this aim, Figure 5.28 shows this region for both the approaches at α = 7.05 and α = 11.05. We can see that there is not a remarkable difference between the W-EE and the W+T-EE. At the same time, the region between the two flaps is not separated. The separation pocket of the inboard flap and the attached flow between the two flaps can be found in all the other entries of the Workshop, in fact, the separation pocket on the inboard flap is already present at α = 7.05 and higher angles for all the Workshop participants, and the same for the attached flow in the region between the two flaps. Anyway, these trend are not matching the experimental data (see Figure 5.29), as in this case the experimental flow, in contrast to the numerical simulations,

• is not separated between the inboard flap and the fuselage, and

• it is separated up to the mid-chord of the flaps, along the majority of the span, including the inter-flap region.

Slat brackets wake

Each slat bracket generates a wake which interacts with the boundary layer of the main wing. In general, this interaction is better captured with the W+T-EE. Starting from the first angle of attack α = 7.05, as said, the first bracket generates a separation, which is

Comparison with other Workshop entries

In this section, we show and compare the results obtained with the W-EE and the W+T-EE with the entries of other participants of the Workshop. We recall that here we use Wolf mixed finite element -finite volume solver, with a second order scheme for the computation of the convective fluxes. As the objective is the verification of the implemented code, the primary target is to reduce the gap between Wolf and the other Workshop entries at C L,max , hence, we expect the W+T-EE being closer to the other participants results. To this aim, we include in the comparison five additional simulations, that is

• one run made with NASA FUN3D stabilized finite element code v13.7 and the Refine mesh adaptation package v3, with approximately 20 millions of nodes and multiscale mesh adaptation, the C-continuation algorithm for low angles of attack and a combination of C-continuation and α-continuation for the rest, • another run made with NASA FUN3D finite volume code v13.7 and the Refine mesh adaptation package v3, with approximately 37 millions of nodes and multiscale mesh adaptation, and the α-continuation algorithm, • one run made with Boeing GGNS (stabilized finite element) and the EPIC mesh adaptation package, with a number of nodes varying between 52 and 55 millions and using the multiscale mesh adaptation. • another run made with Boeing GGNS and the EPIC mesh adaptation package, with a number of nodes varying between 52 and 55 millions and using the goal-oriented mesh adaptation. • one run made with ITU HEMLAB and the pyAMG mesh adaptation package, with a number of nodes of approximately 12 millions and using the multiscale mesh