JDFTx  1.7.0
VectorField.h File Reference

Fixed-length multiplet of ScalarField and ScalarFieldTilde, and specialization to vector fields (3-component) More...

#include <core/ScalarField.h>
#include <core/GridInfo.h>
#include <core/Operators.h>
#include <core/RadialFunction.h>

Classes

struct  ScalarFieldMultiplet< T, N >
 Generic multiplet object with overloaded arithmetic. More...
 

Macros

#define Tptr   std::shared_ptr<T>
 shorthand for writing the template operators (undef'd at end of header)
 
#define TptrMul   ScalarFieldMultiplet<T,N>
 shorthand for the template operators/functions (undef'd at end of file)
 
#define RptrMul   ScalarFieldMultiplet<ScalarFieldData,N>
 shorthand for real-space-only template operators/functions (undef'd at end of file)
 
#define GptrMul   ScalarFieldMultiplet<ScalarFieldTildeData,N>
 shorthand for reciprocal-space-only template operators/functions (undef'd at end of file)
 

Typedefs

typedef ScalarFieldMultiplet< ScalarFieldData, 3 > VectorField
 Real space vector field.
 
typedef ScalarFieldMultiplet< ScalarFieldTildeData, 3 > VectorFieldTilde
 Reciprocal space vector field.
 
typedef ScalarFieldMultiplet< ScalarFieldData, 5 > TensorField
 Symmetric traceless tensor: real space field.
 
typedef ScalarFieldMultiplet< ScalarFieldTildeData, 5 > TensorFieldTilde
 Symmetric traceless tensor: reciprocal space field.
 

Functions

template<class T , int N>
TptrMul clone (const TptrMul &X)
 Clone (NOTE: operator= is by reference for ScalarField multiplets)
 
template<class T , int N>
void initZero (TptrMul &X)
 Initialize data to 0 and scale factors to 1.
 
template<class T , int N>
void nullToZero (TptrMul &X, const GridInfo &gInfo)
 Allocate and initialize each component of X to 0 if null.
 
template<int N>
void initRandom (RptrMul &X, double cap=0.0)
 initialize element-wise with a unit-normal random number (with a cap if cap>0)
 
template<int N>
void initRandomFlat (RptrMul &X)
 initialize element-wise with a unit-flat [0:1) random number
 
template<int N>
void randomize (RptrMul &X)
 alternate interface required by Minimizable
 
template<class T , int N>
TptrMuloperator*= (TptrMul &in, const TptrMul &other)
 Elementwise multiply each component.
 
template<class T , int N>
TptrMul operator* (const TptrMul &in1, const TptrMul &in2)
 Elementwise multiply each component (preserve inputs)
 
template<class T , int N>
TptrMul operator* (TptrMul &&in1, const TptrMul &in2)
 Elementwise multiply each component (destructible input)
 
template<class T , int N>
TptrMul operator* (const TptrMul &in1, TptrMul &&in2)
 Elementwise multiply each component (destructible input)
 
template<class T , int N>
TptrMul operator* (TptrMul &&in1, TptrMul &&in2)
 Elementwise multiply each component (destructible inputs)
 
template<class T , int N>
TptrMuloperator*= (TptrMul &inM, const Tptr &inS)
 Elementwise multiply each component.
 
template<class T , int N>
TptrMul operator* (const TptrMul &inM, const Tptr &inS)
 Elementwise multiply each component (preserve inputs)
 
template<class T , int N>
TptrMul operator* (const Tptr &inS, const TptrMul &inM)
 Elementwise multiply each component (preserve inputs)
 
template<class T , int N>
TptrMul operator* (TptrMul &&inM, const Tptr &inS)
 Elementwise multiply each component (destructible input)
 
template<class T , int N>
TptrMul operator* (const Tptr &inS, TptrMul &&inM)
 Elementwise multiply each component (destructible input)
 
template<class T , int N>
TptrMuloperator*= (TptrMul &in, double scaleFac)
 Scale.
 
template<class T , int N>
TptrMul operator* (const TptrMul &in, double scaleFac)
 Scalar multiply (preserve input)
 
template<class T , int N>
TptrMul operator* (double scaleFac, const TptrMul &in)
 Scalar multiply (preserve input)
 
template<class T , int N>
TptrMul operator* (TptrMul &&in, double scaleFac)
 Scalar multiply (destructible input)
 
template<class T , int N>
TptrMul operator* (double scaleFac, TptrMul &&in)
 Scalar multiply (destructible input)
 
template<class T >
ScalarFieldMultiplet< T, 3 > operator* (vector3<> v, const Tptr &in)
 3-vector multiply
 
template<class T >
Tptr dot (vector3<> v, const ScalarFieldMultiplet< T, 3 > &in)
 3-vector multiply
 
template<class T , int N>
void axpy (double alpha, const TptrMul &X, TptrMul &Y)
 Linear combine Y += alpha * X.
 
template<class T , int N>
TptrMuloperator+= (TptrMul &in, const TptrMul &other)
 Increment.
 
template<class T , int N>
TptrMuloperator-= (TptrMul &in, const TptrMul &other)
 Decrement.
 
template<class T , int N>
TptrMul operator+ (const TptrMul &in1, const TptrMul &in2)
 Add (preserve inputs)
 
template<class T , int N>
TptrMul operator+ (const TptrMul &in1, TptrMul &&in2)
 Add (destructible input)
 
template<class T , int N>
TptrMul operator+ (TptrMul &&in1, const TptrMul &in2)
 Add (destructible input)
 
template<class T , int N>
TptrMul operator+ (TptrMul &&in1, TptrMul &&in2)
 Add (destructible inputs)
 
template<class T , int N>
TptrMul operator- (const TptrMul &in1, const TptrMul &in2)
 Subtract (preserve input)
 
template<class T , int N>
TptrMul operator- (const TptrMul &in1, TptrMul &&in2)
 Subtract (destructible input)
 
template<class T , int N>
TptrMul operator- (TptrMul &&in1, const TptrMul &in2)
 Subtract (destructible input)
 
template<class T , int N>
TptrMul operator- (TptrMul &&in1, TptrMul &&in2)
 Subtract (destructible inputs)
 
template<class T , int N>
TptrMul operator- (const TptrMul &in)
 Negate.
 
template<class T , int N>
TptrMul operator- (TptrMul &&in)
 Negate.
 
template<class T , int N>
void axpy (double alpha, const Tptr &X, TptrMul &Y)
 Linear combine Y += alpha * X.
 
template<class T , int N>
TptrMuloperator+= (TptrMul &in, const Tptr &other)
 Increment.
 
template<class T , int N>
TptrMuloperator-= (TptrMul &in, const Tptr &other)
 Decrement.
 
template<class T , int N>
TptrMul operator+ (const TptrMul &in1, const Tptr &in2)
 Add (preserve inputs)
 
template<class T , int N>
TptrMul operator+ (const Tptr &in1, const TptrMul &in2)
 Add (preserve inputs)
 
template<class T , int N>
TptrMul operator+ (const Tptr &in1, TptrMul &&in2)
 Add (destructible input)
 
template<class T , int N>
TptrMul operator+ (TptrMul &&in1, const Tptr &in2)
 Add (destructible input)
 
template<class T , int N>
TptrMul operator- (const TptrMul &in1, const Tptr &in2)
 Subtract (preserve input)
 
template<class T , int N>
TptrMul operator- (const Tptr &in1, const TptrMul &in2)
 Subtract (preserve input)
 
template<class T , int N>
TptrMul operator- (TptrMul &&in1, const Tptr &in2)
 Subtract (destructible input)
 
template<class T , int N>
TptrMul operator- (const Tptr &in1, TptrMul &&in2)
 Subtract (destructible input)
 
template<class T , int N>
double dot (const TptrMul &X, const TptrMul &Y)
 Inner product.
 
template<class T , int N>
double nrm2 (const TptrMul &X)
 2-norm
 
template<class T , int N>
double sum (const TptrMul &X)
 Sum of elements.
 
vector3 getGzero (const VectorFieldTilde &X)
 return G=0 components
 
void setGzero (const VectorFieldTilde &X, vector3<> v)
 set G=0 components
 
vector3 sumComponents (const VectorField &X)
 Sum of elements (component-wise)
 
ScalarField lengthSquared (const VectorField &X)
 Elementwise length squared.
 
ScalarField lengthSquaredWeighted (const vector3<> &w, const VectorField &X)
 Elementwise length squared (weighted)
 
ScalarField dotElemwise (const VectorField &X, const VectorField &Y)
 Elementwise dot.
 
matrix3 dotOuter (const VectorField &X, const VectorField &Y)
 Compute m(i,j) = dot(X[i], Y[j])
 
matrix3 dotOuter (const VectorField &X, const VectorField &Y, const ScalarField &w)
 Compute m(i,j) = dot(X[i], w * Y[j])
 
template<int N>
RptrMuloperator+= (RptrMul &in, double scalar)
 Increment by scalar.
 
template<int N>
RptrMul operator+ (double scalar, const RptrMul &in)
 Add scalar (preserve input)
 
template<int N>
RptrMul operator+ (const RptrMul &in, double scalar)
 Add scalar (preserve input)
 
template<int N>
RptrMul operator+ (double scalar, RptrMul &&in)
 Add scalar (destructible input)
 
template<int N>
RptrMul operator+ (RptrMul &&in, double scalar)
 Add scalar (destructible input)
 
template<int N>
GptrMuloperator*= (GptrMul &in, const RealKernel &kernel)
 Multiply by kernel.
 
template<int N>
GptrMul operator* (const RealKernel &kernel, const GptrMul &in)
 Multiply by kernel (preserve input)
 
template<int N>
GptrMul operator* (const GptrMul &in, const RealKernel &kernel)
 Multiply by kernel (preserve input)
 
template<int N>
GptrMul operator* (const RealKernel &kernel, GptrMul &&in)
 Multiply by kernel (destructible input)
 
template<int N>
GptrMul operator* (GptrMul &&in, const RealKernel &kernel)
 Multiply by kernel (destructible input)
 
template<int N>
GptrMul O (GptrMul &&X)
 Inner product operator (diagonal in PW basis)
 
template<int N>
GptrMul O (const GptrMul &X)
 Inner product operator (diagonal in PW basis)
 
template<int N>
RptrMul I (GptrMul &&X)
 Forward transform: PW basis -> real space (destructible input)
 
template<int N>
GptrMul J (const RptrMul &X)
 Inverse transform: Real space -> PW basis.
 
template<int N>
GptrMul Idag (const RptrMul &X)
 Forward transform transpose: Real space -> PW basis.
 
template<int N>
RptrMul Jdag (GptrMul &&X)
 Inverse transform transpose: PW basis -> real space (destructible input)
 
template<int N>
RptrMul Jdag (const GptrMul &X)
 Inverse transform transpose: PW basis -> real space (preserve input)
 
template<int N>
RptrMul I (const GptrMul &X)
 Forward transform: PW basis -> real space (preserve input)
 
VectorFieldTilde gradient (const ScalarFieldTilde &)
 compute the gradient of a complex field, returns cartesian components
 
VectorField gradient (const ScalarField &)
 compute the gradient of a complex field, returns cartesian components
 
ScalarFieldTilde divergence (const VectorFieldTilde &)
 compute the divergence of a vector field specified in cartesian components
 
ScalarField divergence (const VectorField &)
 compute the divergence of a vector field specified in cartesian components
 
VectorFieldTilde operator* (const RadialFunctionG &, const VectorFieldTilde &)
 Convolve a vector field by a radial function (preserve input)
 
VectorFieldTilde operator* (const RadialFunctionG &, VectorFieldTilde &&)
 Convolve a vector field by a radial function (destructible input)
 
TensorFieldTilde tensorGradient (const ScalarFieldTilde &)
 symmetric traceless tensor second derivative of a scalar field
 
ScalarFieldTilde tensorDivergence (const TensorFieldTilde &)
 second derivative contraction of a symmetric traceless tensor field
 
template<int N>
void printStats (const RptrMul &, const char *name, FILE *fpLog=stdout)
 Print mean and standard deviation of each component array with specified name (debug utility)
 

Detailed Description

Fixed-length multiplet of ScalarField and ScalarFieldTilde, and specialization to vector fields (3-component)