Discontinuous Galerkin Library
#include "dg/algorithm.h"
refined_elliptic.h
Go to the documentation of this file.
1#pragma once
2
5#include "elliptic.h"
7#ifdef MPI_VERSION
9#endif
10
15namespace dg
16{
17
25template < class Geometry,class IMatrix, class Matrix, class Container>
27{
28 public:
29 using geometry_type = Geometry;
30 using matrix_type = Matrix;
31 using container_type = Container;
40 RefinedElliptic( const Geometry& g_coarse, const Geometry& g_fine, direction dir = forward): RefinedElliptic( g_coarse, g_fine, g_fine.bcx(), g_fine.bcy(), dir){}
41
51 RefinedElliptic( const Geometry& g_coarse, const Geometry& g_fine, bc bcx, bc bcy, direction dir = forward):
52 elliptic_( g_fine, bcx, bcy, dir)
53 {
54 construct( g_coarse, g_fine, bcx, bcy, dir);
55 }
56
63 template<class ContainerType0>
64 void set_chi( const ContainerType0& chi)
65 {
66 //dg::blas2::gemv( Q_, chi, temp1_);
67 //elliptic_.set_chi( temp1_);
68 elliptic_.set_chi( chi);
69 }
70
71 const Container& weights()const {return weights_;}
76 const Container& precond()const {return precond_;}
77
85 template<class ContainerType0, class ContainerType1>
86 void symv( const ContainerType0& x, ContainerType1& y)
87 {
88 dg::blas2::gemv( Q_, x, temp1_);
89 elliptic_.symv( temp1_, temp2_);
90 dg::blas2::gemv( P_, temp2_, y);
91 return;
92 }
93
94 private:
95 void construct( const Geometry& g_coarse, const Geometry& g_fine, bc bcx, bc bcy, direction dir)
96 {
97 dg::blas2::transfer( dg::create::interpolation( g_fine, g_coarse), Q_);
98 dg::blas2::transfer( dg::create::projection( g_coarse, g_fine), P_);
99
100 dg::assign( dg::evaluate( dg::one, g_fine), temp1_);
101 dg::assign( dg::evaluate( dg::one, g_fine), temp2_);
102 dg::assign( dg::create::weights( g_coarse), weights_);
103 dg::assign( dg::evaluate( dg::one ,g_coarse), precond_);
104 vol_ = dg::tensor::volume( g_fine.metric());
105
106 }
107 IMatrix P_, Q_;
108 Elliptic<Geometry, Matrix, Container> elliptic_;
109 Container temp1_, temp2_;
110 Container weights_, precond_;
111 Container vol_;
112};
113
114
116template< class G, class IM, class M, class V>
117struct TensorTraits< RefinedElliptic<G, IM, M, V> >
118{
119 using value_type = get_value_type<V>;
120 using tensor_category = SelfMadeMatrixTag;
121};
122
124
125} //namespace dg
126
The refined version of Elliptic.
Definition: refined_elliptic.h:27
const Container & weights() const
Definition: refined_elliptic.h:71
Geometry geometry_type
Definition: refined_elliptic.h:29
get_value_type< Container > value_type
Definition: refined_elliptic.h:32
const Container & precond() const
Returns the preconditioner to use in conjugate gradient.
Definition: refined_elliptic.h:76
Container container_type
Definition: refined_elliptic.h:31
RefinedElliptic(const Geometry &g_coarse, const Geometry &g_fine, direction dir=forward)
Construct from a coarse and a fine grid.
Definition: refined_elliptic.h:40
Matrix matrix_type
Definition: refined_elliptic.h:30
void symv(const ContainerType0 &x, ContainerType1 &y)
Computes the polarisation term.
Definition: refined_elliptic.h:86
RefinedElliptic(const Geometry &g_coarse, const Geometry &g_fine, bc bcx, bc bcy, direction dir=forward)
Construct from grid and boundary conditions.
Definition: refined_elliptic.h:51
void set_chi(const ContainerType0 &chi)
Change Chi.
Definition: refined_elliptic.h:64
General negative elliptic operators.
void assign(const from_ContainerType &from, ContainerType &to, Params &&... ps)
Generic way to assign the contents of a from_ContainerType object to a ContainerType object optionall...
Definition: blas1.h:665
static DG_DEVICE double one(double x)
Definition: functions.h:20
void gemv(get_value_type< ContainerType1 > alpha, MatrixType &&M, const ContainerType1 &x, get_value_type< ContainerType1 > beta, ContainerType2 &y)
; (alias for symv)
Definition: blas2.h:299
void transfer(const MatrixType &x, AnotherMatrixType &y)
; Generic way to copy and/or convert a Matrix type to a different Matrix type
Definition: blas2.h:443
bc
Switch between boundary conditions.
Definition: enums.h:15
direction
Direction of a discrete derivative.
Definition: enums.h:97
@ forward
forward derivative (cell to the right and current cell)
Definition: enums.h:98
@ y
y direction
@ x
x direction
thrust::host_vector< real_type > evaluate(UnaryOp f, const RealGrid1d< real_type > &g)
Evaluate a 1d function on grid coordinates.
Definition: evaluation.h:67
MPI_Vector< thrust::host_vector< real_type > > weights(const aRealMPITopology2d< real_type > &g)
Nodal weight coefficients.
Definition: mpi_weights.h:22
cusp::coo_matrix< int, real_type, cusp::host_memory > interpolation(const thrust::host_vector< real_type > &x, const RealGrid1d< real_type > &g, dg::bc bcx=dg::NEU, std::string method="dg")
Create interpolation matrix.
Definition: interpolation.h:254
dg::MIHMatrix_t< real_type > projection(const aRealMPITopology2d< real_type > &g_new, const aRealMPITopology2d< real_type > &g_old, std::string method="dg")
Create a projection between two grids.
Definition: mpi_projection.h:247
ContainerType volume(const SparseTensor< ContainerType > &t)
Definition: multiply.h:406
typename TensorTraits< std::decay_t< Vector > >::value_type get_value_type
Definition: tensor_traits.h:38
1D, 2D and 3D interpolation matrix creation functions
Useful MPI typedefs and overloads of interpolation and projection.
This is the namespace for all functions and classes defined and used by the discontinuous Galerkin li...
Creation of projection matrices.
NotATensorTag tensor_category
Definition: tensor_traits.h:33
void value_type
Definition: tensor_traits.h:32