File: NonConstantIPOperator.tmpl

package info (click to toggle)
xmds2 2.2.2%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 53,384 kB
  • ctags: 7,223
  • sloc: python: 54,076; cpp: 3,929; ansic: 1,463; makefile: 135; sh: 20
file content (100 lines) | stat: -rw-r--r-- 3,327 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
@*
NonConstantIPOperator.tmpl

Interaction-picture transverse derivative operator

Created by Graham Dennis on 2007-11-21.

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

@from xpdeint.CallOnceGuards import callOncePerInstanceGuard

@attr $calculateOperatorFieldFunctionArguments = [('real', '_step'), ('int', '_exponent')]

@def globals
  @#
  @super
  @#
real _${id}_last_timestep_size_map[${len($integrator.ipPropagationStepFractions)}];
  @#
@end def

@@callOncePerInstanceGuard
@def initialise
  @#
memset(_${id}_last_timestep_size_map, 0, sizeof(_${id}_last_timestep_size_map));
  @#
@end def

@def calculateOperatorFieldFunctionContents($function)
  @#
  @if len($integrator.ipPropagationStepFractions) > 1
static const real _propagationStepFractions[] = {
  @for $propagationStepFraction in $integrator.ipPropagationStepFractions
  $propagationStepFraction,
  @end for
};
const long _arrayIndex = _exponent - 1;
const real _propagationStepFraction = _propagationStepFractions[_arrayIndex];
  @else
const real _propagationStepFraction = ${integrator.ipPropagationStepFractions[0]};
const long _arrayIndex = 0;
  @end if

// If the timestep hasn't changed from the last time, then we're done.
if (_propagationStepFraction * _step == _${id}_last_timestep_size_map[_arrayIndex])
  return;

  @#
  @super(function)
  @#

_${id}_last_timestep_size_map[_arrayIndex] = _propagationStepFraction * _step;
  @#
@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 each operator component
  @for $operatorComponentNumber, $operatorComponent in enumerate($operatorComponents.iterkeys())
_${operatorVector.id}[_${operatorVector.id}_index_pointer + _arrayIndex * $len($operatorComponents) + ${operatorComponentNumber}]@slurp
 = ${expFunction}(${operatorComponent}${valueSuffix} * _propagationStepFraction * _step);
  @end for
  @#
@end def

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