30#include "../../../Common/include/toolboxes/CQuasiNewtonInvLeastSquares.hpp"
31#include "../../../Common/include/linear_algebra/CSysSolve.hpp"
41 #ifdef CODI_FORWARD_TYPE
81 unsigned long wrt_sol_freq = std::numeric_limits<unsigned long>::max();
134 bool Iterate(
unsigned short iZone,
unsigned long iInnerIter,
bool KrylovMode =
false);
258 template<
class Container>
261 for (
auto iSol = 0u, offset = 0u; iSol <
MAX_SOLS; ++iSol) {
263 if (!(solver && solver->GetAdjoint()))
continue;
265 for (
auto iPoint = 0ul; iPoint < nPoint; ++iPoint)
266 for (
auto iVar = 0ul; iVar < solver->GetnVar(); ++iVar)
268 offset += solver->GetnVar();
Headers of the main subroutines for driving single or multi-zone problems. The subroutines and functi...
A templated matrix/vector-like object.
Definition C2DContainer.hpp:374
Block Gauss-Seidel driver for multizone / multiphysics discrete adjoint problems.
Definition CDiscAdjMultizoneDriver.hpp:38
void SetResidual_BGS(unsigned short iZone)
Compute BGS residuals.
Definition CDiscAdjMultizoneDriver.cpp:1177
void SetSolutionOldToSolution(unsigned short iZone)
Puts Solution into SolutionOld.
Definition CDiscAdjMultizoneDriver.cpp:1137
bool Iterate(unsigned short iZone, unsigned long iInnerIter, bool KrylovMode=false)
Run one inner iteration for a given zone.
Definition CDiscAdjMultizoneDriver.cpp:398
void ComputeAdjoints(unsigned short iZone, bool eval_transfer=true)
Summary of all routines to evaluate the adjoints in iZone.
Definition CDiscAdjMultizoneDriver.cpp:1008
void SetAdjObjFunction()
Initialize the adjoint value of the objective function.
Definition CDiscAdjMultizoneDriver.cpp:983
AD::Identifier ObjFunc_Index
Index of the value of the objective function.
Definition CDiscAdjMultizoneDriver.hpp:75
su2vector< bool > Has_Deformation
True if iZone has mesh deformation (used for lazy evaluation of TRANSFER tape section).
Definition CDiscAdjMultizoneDriver.hpp:83
vector< vector< vector< su2passivematrix > > > Cross_Terms
Fixed-Point corrector that can be applied to inner iterations.
Definition CDiscAdjMultizoneDriver.hpp:89
COutput ** direct_output
Array of pointers to the direct outputs.
Definition CDiscAdjMultizoneDriver.hpp:78
void Set_Solution_To_BGSSolution_k(unsigned short iZone)
Puts BGSSolution_k back into Solution.
Definition CDiscAdjMultizoneDriver.cpp:1157
void DirectIteration(unsigned short iZone, RECORDING kind_recording)
Run one direct iteration in a zone.
Definition CDiscAdjMultizoneDriver.cpp:903
Tape_Positions
Position markers within a tape.
Definition CDiscAdjMultizoneDriver.hpp:60
@ DEPENDENCIES
Derived values (e.g. gradients) are set.
Definition CDiscAdjMultizoneDriver.hpp:63
@ TRANSFER
Solution data is transferred between coupled solvers of different physical zones (giving cross contri...
Definition CDiscAdjMultizoneDriver.hpp:65
@ ITERATION_READY
Until here, all derivative information is gathered so that it can be connected to a solver update eva...
Definition CDiscAdjMultizoneDriver.hpp:67
@ REGISTERED
Solver variables are registered on the tape.
Definition CDiscAdjMultizoneDriver.hpp:62
@ OBJECTIVE_FUNCTION
Objective function is set.
Definition CDiscAdjMultizoneDriver.hpp:64
@ START
Beginning of the tape.
Definition CDiscAdjMultizoneDriver.hpp:61
void AddExternalToSolution(unsigned short iZone)
Add External_Old vector to Solution.
Definition CDiscAdjMultizoneDriver.cpp:1127
void Set_BGSSolution_k_To_Solution(unsigned short iZone)
Puts Solution into BGSSolution_k.
Definition CDiscAdjMultizoneDriver.cpp:1167
vector< unsigned long > nInnerIter
Number of inner iterations for each zone.
Definition CDiscAdjMultizoneDriver.hpp:80
void SetRecording(RECORDING kind_recording, Kind_Tape tape_type, unsigned short record_zone)
Record one iteration of the primal problem within each zone.
Definition CDiscAdjMultizoneDriver.cpp:769
~CDiscAdjMultizoneDriver(void) override
Destructor of the class.
Definition CDiscAdjMultizoneDriver.cpp:146
const Scalar KrylovTol
Definition CDiscAdjMultizoneDriver.hpp:96
vector< unsigned short > direct_nInst
Total number of instances in the direct problem.
Definition CDiscAdjMultizoneDriver.hpp:79
void InitializeCrossTerms()
Setup the matrix of cross-terms. Allocate necessary memory and initialize to zero.
Definition CDiscAdjMultizoneDriver.cpp:1045
void SetExternalToDualTimeDer()
Puts dual time derivative vector to External.
Definition CDiscAdjMultizoneDriver.cpp:1115
void StartSolver() override
[Overload] Launch the computation for discrete adjoint multizone problems.
Definition CDiscAdjMultizoneDriver.cpp:196
bool EvaluateObjectiveFunctionGradient()
Evaluate the gradient of the objective function and add to "External".
Definition CDiscAdjMultizoneDriver.cpp:662
vector< CQuasiNewtonInvLeastSquares< passivedouble > > FixPtCorrector
Members to use GMRES to drive inner iterations (alternative to quasi-Newton).
Definition CDiscAdjMultizoneDriver.hpp:92
vector< CSysSolve< Scalar > > LinSolver
Definition CDiscAdjMultizoneDriver.hpp:97
CIteration *** direct_iteration
Array of pointers to the direct iterations.
Definition CDiscAdjMultizoneDriver.hpp:77
vector< CSysVector< Scalar > > AdjRHS
Definition CDiscAdjMultizoneDriver.hpp:98
void UpdateCrossTerm(unsigned short iZone, unsigned short jZone)
Extract contribution of iZone to jZone with BGS relaxation.
Definition CDiscAdjMultizoneDriver.cpp:1147
unsigned long wrt_sol_freq
File output frequency.
Definition CDiscAdjMultizoneDriver.hpp:81
passivedouble Scalar
Definition CDiscAdjMultizoneDriver.hpp:44
void KrylovInnerIters(unsigned short iZone)
Run inner iterations using a Krylov method (GMRES atm).
Definition CDiscAdjMultizoneDriver.cpp:435
void EvaluateSensitivities(unsigned long Iter, bool force_writing)
Evaluate sensitivites for the current adjoint solution and output files.
Definition CDiscAdjMultizoneDriver.cpp:696
void Preprocess(unsigned long TimeIter) override
Preprocess the multizone iteration.
Definition CDiscAdjMultizoneDriver.cpp:162
Kind_Tape
Kinds of recordings.
Definition CDiscAdjMultizoneDriver.hpp:50
@ FULL_SOLVER_TAPE
Entire derivative information for a coupled adjoint solution update.
@ OBJECTIVE_FUNCTION_TAPE
Record only the dependence of the objective function w.r.t. solver variables (from all zones).
void HandleDataTransfer()
Transfer data between zones and update grids when required.
Definition CDiscAdjMultizoneDriver.cpp:1076
int TapeTestGatherErrors(AD::DebugControl &debug_control) const
Get the total error count after a tape test run of the discrete adjoint multizone solver.
Definition CDiscAdjMultizoneDriver.cpp:377
void TapeTest()
Launch the tape test run of the discrete adjoint multizone solver.
Definition CDiscAdjMultizoneDriver.cpp:269
RECORDING RecordingState
The kind of recording that the tape currently holds.
Definition CDiscAdjMultizoneDriver.hpp:71
void GetAdjointRHS(unsigned short iZone, Container &rhs) const
Get the external of all adjoint solvers in a zone.
Definition CDiscAdjMultizoneDriver.hpp:259
bool eval_transfer
Evaluate the transfer section of the tape.
Definition CDiscAdjMultizoneDriver.hpp:73
void SetObjFunction(RECORDING kind_recording)
Set the objective function.
Definition CDiscAdjMultizoneDriver.cpp:918
su2double ObjFunc
Value of the objective function.
Definition CDiscAdjMultizoneDriver.hpp:74
bool GetTimeConvergence() const override
gets Convergence on physical time scale, (deactivated in adjoint case)
Definition CDiscAdjMultizoneDriver.hpp:251
static constexpr unsigned long KrylovMinIters
Definition CDiscAdjMultizoneDriver.hpp:95
vector< CSysVector< Scalar > > AdjSol
Definition CDiscAdjMultizoneDriver.hpp:98
void AddSolutionToExternal(unsigned short iZone)
Add Solution vector to External.
Definition CDiscAdjMultizoneDriver.cpp:1105
void Run() override
[Overload] Run an discrete adjoint update of all solvers within multiple zones.
Definition CDiscAdjMultizoneDriver.cpp:488
CSolver ***** solver_container
Container vector with all the solutions.
Definition CDriverBase.hpp:71
CGeometry **** geometry_container
Geometrical definition of the problem.
Definition CDriverBase.hpp:70
unsigned short iZone
Iterator on zones.
Definition CDriverBase.hpp:59
unsigned long GetnPoint() const
Get number of points.
Definition CGeometry.hpp:587
Parent class for defining a single iteration of a physics problem.
Definition CIteration.hpp:50
Class for driving zone-specific iterations.
Definition CMultizoneDriver.hpp:40
unsigned long TimeIter
Definition CMultizoneDriver.hpp:46
Class for writing the convergence history and to write solution data to file.
Definition COutput.hpp:68
CVariable * GetNodes()
Allow outside access to the nodes of the solver, containing conservatives, primitives,...
Definition CSolver.hpp:229
const su2double * Get_External(unsigned long iPoint) const
Get the external contributions of the problem.
Definition CVariable.hpp:551
double passivedouble
Definition code_config.hpp:129
passivedouble su2double
Definition code_config.hpp:181
int SU2_Comm
Definition mpi_structure.hpp:619
int Identifier
Definition ad_structure.hpp:56
passivedouble GetValue(const su2double &data)
Get the (primitive) value of the datatype (needs to be specialized for active types).
Definition datatype_structure.hpp:113
const unsigned int INST_0
Definition of the first instance per grid level.
Definition option_structure.hpp:92
@ MAX_SOLS
Definition option_structure.hpp:80
const unsigned int MESH_0
Definition of the finest grid level.
Definition option_structure.hpp:88
RECORDING
Definition option_structure.hpp:2820
Struct to store information about errors during a tag debug run.
Definition ad_structure.hpp:332