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
|
@shBang #!/usr/bin/env python3
@*
SIStepper.tmpl
Created by Joe Hope on 2008-03-24.
Copyright (c) 2008-2012, Joe Hope and 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.Segments.Integrators._Stepper
@def name: SI
@attr $ipPropagationStepFractions = ['0.5']
@attr $extraIntegrationArrayNames = ['oldCopy']
@attr $isCrossCapable = True
@attr $iterations = 3
@*
Single integration step (SI)
*@
@def singleIntegrationStep($function)
@#
@set $arguments = {'_step': '_step', $propagationDimension: $propagationDimension}
${callFunction('nonconstantIPFields', arguments, _exponent = 1, parentFunction=function)}
${callFunction('ipEvolve', arguments, _exponent = +1, parentFunction=function)}
${propagationDimension} += 0.5*_step;
${transformVectorsToBasis($integrationVectors, $homeBasis)}@slurp
${copyVectors($integrationVectors, '_oldCopy')}@slurp
@for $vector in $integrationVectors
_active_${vector.id} = _${vector.id};
@end for
@if $cross
// Interpolate dependencies to the half-step
${interpolateDependencies}@slurp
@end if
for (int _iteration = 0; _iteration < ${iterations}; _iteration++) {
if (_iteration < ${iterations} - 1) {
${callFunction('deltaA', arguments, _step = '0.5*_step', parentFunction=function), autoIndent=True}@slurp
} else {
${callFunction('deltaA', arguments, parentFunction=function), autoIndent=True}@slurp
}
${transformVectorsToBasis($integrationVectors, $homeBasis), autoIndent=True}@slurp
${loopOverVectorsWithInnerContentTemplate($integrationVectors,
"""// a = oldCopy + a
_${vector.id}[$index] += _oldCopy_${vector.id}[$index];
""", basis=$homeBasis), autoIndent=True}@slurp
}
${callFunction('ipEvolve', arguments, _exponent = +1, parentFunction=function)}
${propagationDimension} += 0.5*_step;
@#
@end def
@def interpolateDependencies
@#
@# Insert code to interpolate the dependency vectors onto the half-step point.
@#
${reducedFieldCopy($integrator.dependencyMap,
"""
_active_${reducedVector.id}[_${reducedVector.id}_index_pointer + ${componentIndex}] = \\
0.5*(_active_${vector.id}[_${vector.id}_index_pointer + ${componentIndex}]
+ _active_${vector.id}[_${vector.id}_index_pointer + ${componentIndex} + ${skipSize} * _${vector.id}_ncomponents]);
""")}@slurp
@#
@end def
|