@*
ConstantIPOperator.tmpl

Interaction-picture transverse derivative operator

Created by Graham Dennis on 2007-10-06.

Copyright (c) 2007-2012, Graham Dennis

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

*@
@extends xpdeint.Operators._IPOperator

@attr $calculateOperatorFieldFunctionArguments = []

@def calculateOperatorFieldFunctionContents($function)
  @#
${integrator.createStepVariable}@slurp

  @super(function)
  @#
@end def


@def insideCalculateOperatorFieldLoops($codeString)
  @#
${insideCalculateOperatorFieldLoopsBegin}@slurp
  @#
  @# We expect the integrator to have defined '_step'
  @#
// The purpose of the following define is to give a (somewhat helpful) compile-time error
// if the user has attempted to use the propagation dimension variable in a constant IP operator/
// The user probably shouldn't be doing this, but if they must, they should use a non-constant EX
// operator instead
#define ${propagationDimension} Dont_use_propagation_dimension_${propagationDimension}_in_constant_IP_operator___Use_non_constant_EX_operator_instead
// ************** Operator code *****************
${codeString}@slurp
// **********************************************
#undef ${propagationDimension}
  @# Loop over the propagation step fractions
  @for $fractionIndex, $propagationStepFraction in enumerate($integrator.ipPropagationStepFractions)
    
    @# Loop over each operator component
    @for $operatorComponentNumber, $operatorComponent in enumerate($operatorComponents.iterkeys())
      @set $offsetIndex = $operatorComponentNumber + $fractionIndex * len($operatorComponents)
_${operatorVector.id}[_${operatorVector.id}_index_pointer + ${offsetIndex}] = ${expFunction}(${operatorComponent}${valueSuffix} * $propagationStepFraction * _step);
    @end for
  @end for
  @#
@end def

@def exponentIndex
(abs(_exponent) - 1) * ${len($operatorComponents)}@slurp
@end def

