34template <
class Geometry,
class Matrix,
class Container>
59 std::string mode =
"df",
bool commute =
false):
60 PolCharge( alpha, eps_gamma, g, g.bcx(), g.bcy(), dir, jfactor, mode,
83 value_type jfactor=1., std::string mode =
"df",
bool commute =
false)
86 m_eps_gamma = eps_gamma;
95 m_ell.construct(g, bcx, bcy, dir, jfactor );
97 for(
unsigned u=0; u<3; u++)
99 m_multi_gamma.push_back( {m_alpha, {m_multi_g.
grid(u), bcx, bcy,
105 m_ell.construct(g, bcx, bcy, dir, jfactor );
106 m_multi_gamma.resize(1);
107 m_multi_gamma.resize(1);
108 m_multi_gamma[0].construct( m_alpha,
dg::Elliptic<Geometry,
109 Matrix, Container>{g, bcx, bcy, dir, jfactor});
111 m_inv_sqrt.
construct( m_multi_gamma[0], -1,
112 m_multi_gamma[0].
weights(), m_eps_gamma[0]);
114 if (m_mode ==
"ffO4")
116 m_tensorell.construct(g, bcx, bcy, dir, jfactor);
118 for(
unsigned u=0; u<3; u++)
120 m_multi_gamma.push_back({ m_alpha, {m_multi_g.
grid(u), bcx, bcy,
127 template<
class ...Params>
131 *
this =
PolCharge( std::forward<Params>( ps)...);
139 template<
class ContainerType0>
143 m_ell.set_chi(sigma);
144 if (m_mode ==
"ffO4")
146 m_tensorell.set_chi(sigma);
155 template<
class ContainerType0>
160 if (m_mode ==
"ffO4")
162 m_tensorell.set_chi(tau);
171 template<
class ContainerType0>
174 if (m_mode ==
"ffO4")
176 m_tensorell.set_iota(sigma);
196 if (m_mode ==
"ffO4")
197 return m_tensorell.weights();
198 else return m_ell.weights();
209 if (m_mode ==
"ffO4")
210 return m_tensorell.precond();
211 else return m_ell.precond();
214 template<
class ContainerType0,
class ContainerType1>
215 void variation(
const ContainerType0& phi, ContainerType1& varphi)
218 m_ell.variation(phi, varphi);
219 if (m_mode ==
"ffO4")
220 m_tensorell.variation(phi, varphi);
230 template<
class ContainerType0,
class ContainerType1>
231 void operator()(
const ContainerType0& x, ContainerType1& y){
243 template<
class ContainerType0,
class ContainerType1>
244 void symv(
const ContainerType0& x, ContainerType1& y){
257 template<
class ContainerType0,
class ContainerType1>
268 if (m_commute ==
false)
271 std::vector<unsigned> number = m_multi_g.
solve(
272 m_multi_gamma, m_temp2,
x, m_eps_gamma);
273 m_temp2_ex.
update(m_temp2);
275 m_ell.symv(alpha, m_temp2, beta,
y);
279 m_ell.symv(1.0,
x, 0.0, m_temp);
282 std::vector<unsigned> number = m_multi_g.
solve(
283 m_multi_gamma, m_temp2, m_temp, m_eps_gamma);
284 m_temp2_ex.
update(m_temp2);
293 if (m_commute ==
false)
295 unsigned number = 0 ;
299 m_ell.symv(1.0, m_temp2, 0.0, m_temp);
312 if (m_mode ==
"ffO4")
314 if (m_commute ==
false)
317 std::vector<unsigned> number = m_multi_g.
solve(
318 m_multi_gamma, m_temp2,
x, m_eps_gamma);
319 m_temp2_ex.
update(m_temp2);
321 m_tensorell.symv(1.0, m_temp2, 0.0, m_temp);
324 number = m_multi_g.
solve( m_multi_gamma, m_temp2,
325 m_temp, m_eps_gamma);
326 m_temp_ex.
update(m_temp2);
330 if (m_commute ==
true)
341 std::vector< dg::Helmholtz<Geometry, Matrix, Container> > m_multi_gamma;
344 Container m_temp, m_temp2;
346 std::vector<value_type> m_eps_gamma;
357template<
class G,
class M,
class V>
358struct TensorTraits< mat::PolCharge<G, M, V> >
Various arbitary wavelength polarization charge operators of delta-f (df) and full-f (ff)
Definition: polarization.h:36
PolCharge(value_type alpha, std::vector< value_type > eps_gamma, const Geometry &g, bc bcx, bc bcy, direction dir=forward, value_type jfactor=1., std::string mode="df", bool commute=false)
Construct from boundary conditions.
Definition: polarization.h:81
PolCharge()
empty object ( no memory allocation)
Definition: polarization.h:40
const Container & weights() const
Return the vector making the matrix symmetric.
Definition: polarization.h:195
get_value_type< Container > value_type
Definition: polarization.h:38
bool get_commute() const
Get the current state of commute.
Definition: polarization.h:188
void set_chi(const SparseTensor< ContainerType0 > &tau)
Change in the elliptic or tensor elliptic operator.
Definition: polarization.h:156
void variation(const ContainerType0 &phi, ContainerType1 &varphi)
Definition: polarization.h:215
void symv(value_type alpha, const ContainerType0 &x, value_type beta, ContainerType1 &y)
Compute elliptic term and add to output.
Definition: polarization.h:258
void symv(const ContainerType0 &x, ContainerType1 &y)
Compute elliptic term and store in output.
Definition: polarization.h:244
void operator()(const ContainerType0 &x, ContainerType1 &y)
Compute elliptic term and store in output.
Definition: polarization.h:231
void set_iota(const ContainerType0 &sigma)
Change in the tensor elliptic operator.
Definition: polarization.h:172
void construct(Params &&...ps)
Perfect forward parameters to one of the constructors.
Definition: polarization.h:128
void set_chi(const ContainerType0 &sigma)
Change in the elliptic or tensor elliptic operator.
Definition: polarization.h:140
const Container & precond() const
Return the default preconditioner to use in conjugate gradient.
Definition: polarization.h:208
void set_commute(bool commute)
Set the commute.
Definition: polarization.h:183
PolCharge(value_type alpha, std::vector< value_type > eps_gamma, const Geometry &g, direction dir=forward, value_type jfactor=1., std::string mode="df", bool commute=false)
Construct from Grid.
Definition: polarization.h:57
void apply(get_value_type< ContainerType1 > alpha, MatrixType &&M, const ContainerType1 &x, get_value_type< ContainerType1 > beta, ContainerType2 &y)
static DG_DEVICE double zero(double x)
void axpby(get_value_type< ContainerType > alpha, const ContainerType1 &x, get_value_type< ContainerType > beta, ContainerType &y)
void scal(ContainerType &x, get_value_type< ContainerType > alpha)
thrust::host_vector< real_type > evaluate(UnaryOp f, const RealGrid1d< real_type > &g)
typename TensorTraits< std::decay_t< Vector > >::value_type get_value_type
Classes for Krylov space approximations of a Matrix-Vector product.
std::vector< unsigned > solve(std::vector< MatrixType > &ops, ContainerType0 &x, const ContainerType1 &b, value_type eps)
void construct(Params &&...ps)
const Geometry & grid(unsigned stage) const
NotATensorTag tensor_category
void construct(Params &&...ps)
Perfect forward parameters to one of the constructors.
Definition: matrixsqrt.h:62
Matrix class that represents the arbitrary polarization operator.
Definition: tensorelliptic.h:25
contains special differential operators