-
Paul Dechamps authoredPaul Dechamps authored
wSolver.h 2.96 KiB
/*
* Copyright 2020 University of Liège
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef WSOLVER_H
#define WSOLVER_H
#include "dart.h"
#include "wObject.h"
#include "wTimers.h"
#include <iostream>
#include <vector>
#include <memory>
#include <Eigen/Dense>
namespace dart
{
/**
* @brief Exit code of DART solver
*/
enum class Status
{
CONVERGED = 0, // fully converged to prescribed (relative or absolute) tolerance
MAXIT = 1, // not fully converged (max. number of iterations exceeded)
FAILED = 2 // NaN in the solution vector
};
/**
* @brief Base class for full potential solvers
* @authors Adrien Crovato
*/
class DART_API Solver : public fwk::wSharedObject
{
public:
std::shared_ptr<Problem> pbl; ///< problem definition
std::shared_ptr<tbox::LinearSolver> linsol; ///< linear solver
double relTol; ///< relative tolerance on the residual
double absTol; ///< absolute tolerance on the residual
int maxIt; ///< max number of iterations
int nthreads; ///< number of threads for the execution
int verbose; ///< display more info
int nIt; ///< number of iterations
std::vector<double> phi; ///< full potential
std::vector<double> rPhi; ///< residual on potential
std::vector<double> vPhi; ///< perturbation potential
std::vector<Eigen::Vector3d> U; ///< velocity
std::vector<double> rho; ///< density
std::vector<double> M; ///< mach number
std::vector<double> Cp; ///< pressure coefficient
double Cl; ///< lift coefficient
double Cd; ///< drag coefficient
double Cs; ///< sideforce coefficient
double Cm; ///< pitch moment coefficient (positive nose-up)
protected:
fwk::Timers tms; ///< internal timers
std::vector<int> rows; ///< unknown nodal index
public:
Solver(std::shared_ptr<Problem> _pbl, std::shared_ptr<tbox::LinearSolver> _linsol, double rTol, double aTol, int mIt, int nthrds, int vrb);
virtual ~Solver();
void reset();
virtual Status run();
void save(tbox::MshExport *mshWriter, std::string const &suffix = "");
int getRow(size_t i) const { return rows[i]; };
void setRelTol(double const rtol) { relTol = rtol; }
void setAbsTol(double const atol) { absTol = atol; }
protected:
void computeFlow();
void computeLoad();
};
} // namespace dart
#endif // WSOLVER_H