// ============================================================================ // == == // == AMDiS - Adaptive multidimensional simulations == // == == // == http://www.amdis-fem.org == // == == // ============================================================================ // // Software License for AMDiS // // Copyright (c) 2010 Dresden University of Technology // All rights reserved. // Authors: Simon Vey, Thomas Witkowski et al. // // This file is part of AMDiS // // See also license.opensource.txt in the distribution. /** \file PetscSolverNavierStokes.h */ #ifndef AMDIS_PETSC_SOLVER_NAVIER_STOKES_H #define AMDIS_PETSC_SOLVER_NAVIER_STOKES_H #include "parallel/PetscSolverGlobalMatrix.h" namespace AMDiS { using namespace std; struct NavierStokesSchurData { KSP kspMass, kspLaplace; Mat matConDif; }; class PetscSolverNavierStokes : public PetscSolverGlobalMatrix { private: class IdFct : public AbstractFunction { public: IdFct() : AbstractFunction(1) {} double operator()(const double& x) const { return x; } }; class MultConstFct : public AbstractFunction { public: MultConstFct(double c) : AbstractFunction(1), mConst(c) {} double operator()(const double& x) const { return mConst * x; } private: double mConst; }; class Multiplier3 : public BinaryAbstractFunction { public: Multiplier3() : BinaryAbstractFunction(6) {} double operator()(const double& phi, const double& phase) const { return phase * phi; } }; class EinsMinus : public AbstractFunction { public: EinsMinus(double d) : AbstractFunction(2), c(d) {} double operator()(const double& x) const { return c * std::max(1.0-x,0.000001); } private: double c; }; struct Multiplication : public BinaryAbstractFunction{ double operator()(const double &v1, const double &v2) const{ return v2 / v1; } }; public: PetscSolverNavierStokes(string name); void setStokesData(double *nuPtr, double *invTauPtr, SystemVector *vec) { nu = nuPtr; invTau = invTauPtr; solution = vec; } void setPhase(DOFVector *d) { phase = d; } protected: void initSolver(KSP &ksp); void initPreconditioner(PC pc); private: int pressureComponent; PetscSolver *massMatrixSolver, *laplaceMatrixSolver, *conDifMatrixSolver; NavierStokesSchurData matShellContext; double *nu, *invTau; SystemVector* solution; DOFVector* phase; IdFct idFct; }; } #endif