Branch data Line data Source code
1 : : // ***************************************************************************** 2 : : /*! 3 : : \file src/PDE/Transport/Problem/CylVortex.cpp 4 : : \copyright 2012-2015 J. Bakosi, 5 : : 2016-2018 Los Alamos National Security, LLC., 6 : : 2019-2021 Triad National Security, LLC. 7 : : All rights reserved. See the LICENSE file for details. 8 : : \brief Problem configuration for transport equations 9 : : \details This file defines a Problem policy class for the transport 10 : : equations, defined in PDE/Transport/CGTransport.hpp implementing 11 : : node-centered continuous Galerkin (CG) and PDE/Transport/DGTransport.hpp 12 : : implementing cell-centered discontinuous Galerkin (DG) discretizations. 13 : : See PDE/Transport/Problem.hpp for general requirements on Problem policy 14 : : classes for cg::Transport and dg::Transport. 15 : : */ 16 : : // ***************************************************************************** 17 : : 18 : : #include "CylVortex.hpp" 19 : : 20 : : using inciter::TransportProblemCylVortex; 21 : : 22 : : std::vector< tk::real > 23 : 0 : TransportProblemCylVortex::initialize( ncomp_t ncomp, 24 : : const std::vector< EOS >&, 25 : : tk::real x, tk::real y, tk::real, 26 : : tk::real t ) 27 : : // ***************************************************************************** 28 : : // Evaluate initial solution at (x,y,t) for all components 29 : : //! \param[in] ncomp Number of components in this transport equation system 30 : : //! \param[in] x X coordinate where to evaluate the solution 31 : : //! \param[in] y Y coordinate where to evaluate the solution 32 : : //! \param[in] t Time where to evaluate the solution 33 : : //! \return Values of all components evaluated at (x,y,t=0) 34 : : //! \details This function only gives the initial condition for the cylinder, 35 : : //! and not the solution at any time t>0. 36 : : // ***************************************************************************** 37 : : { 38 [ - - ]: 0 : const auto vel = prescribedVelocity( ncomp, x, y, 0.0, t ); 39 : : 40 [ - - ][ - - ]: 0 : if (ncomp != 4) Throw("Cylinder deformation in vortex is only set up for 4 " [ - - ][ - - ] 41 : : "components"); 42 : : 43 [ - - ]: 0 : std::vector< tk::real > s( ncomp, 0.0 ); 44 : : 45 : : // center of the cylinder 46 : 0 : auto x0 = 0.5; 47 : 0 : auto y0 = 0.75; 48 : 0 : auto r = sqrt((x-x0)*(x-x0) + (y-y0)*(y-y0)); 49 : : 50 [ - - ]: 0 : if (r<=0.15) { 51 [ - - ][ - - ]: 0 : if (x<x0 && y>=y0) s[0] = 1.0; 52 [ - - ][ - - ]: 0 : else if (x>=x0 && y>=y0) s[1] = 1.0; 53 [ - - ][ - - ]: 0 : else if (x>=x0 && y<y0) s[2] = 1.0; 54 [ - - ][ - - ]: 0 : else if (x<x0 && y<y0) s[3] = 1.0; 55 : : } 56 : : 57 : 0 : return s; 58 : : } 59 : : 60 : : std::vector< std::array< tk::real, 3 > > 61 : 0 : TransportProblemCylVortex::prescribedVelocity( ncomp_t ncomp, 62 : : tk::real x, tk::real y, tk::real, tk::real t ) 63 : : // ***************************************************************************** 64 : : //! Assign prescribed velocity at a point 65 : : //! \param[in] ncomp Number of components in this transport equation 66 : : //! \param[in] x x coordinate at which to assign velocity 67 : : //! \param[in] y y coordinate at which to assign velocity 68 : : //! \param[in] t time at which to assign velocity 69 : : //! \return Velocity assigned to all vertices of a tetrehedron, size: 70 : : //! ncomp * ndim = [ncomp][3] 71 : : // ***************************************************************************** 72 : : { 73 [ - - ]: 0 : std::vector< std::array< tk::real, 3 > > vel( ncomp ); 74 : : 75 : 0 : auto pi = 4.0 * std::atan(1.0); 76 [ - - ]: 0 : for (ncomp_t c=0; c<ncomp; ++c) { 77 : 0 : vel[c][0] = - 2.0*std::cos(t*pi/4.0) * std::pow(std::sin(pi*x), 2) 78 : 0 : * std::sin(pi*y) * std::cos(pi*y); 79 : 0 : vel[c][1] = 2.0*std::cos(t*pi/4.0) * std::pow(std::sin(pi*y), 2) 80 : 0 : * std::sin(pi*x) * std::cos(pi*x); 81 : 0 : vel[c][2] = 0.0; 82 : : } 83 : : 84 : 0 : return vel; 85 : : }