File: TopLevelSequenceElement.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 (91 lines) | stat: -rw-r--r-- 3,003 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
@*
TopLevelSequenceElement.tmpl

Created by Graham Dennis on 2007-08-27.

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.Segments.SequenceSegment

@assert $segmentNumber == 0
@attr $globalNameSpaceName = "topLevelSequence"

@*
  Description of template
*@
@def description: segment $segmentNumber (Top level sequence)

@def functionImplementations
  @#
  @# Make this empty as the content of the top-level sequence will be written by
  @# a simulation driver
  @#
@end def

@def topLevelSequenceInnerContent
  @#
$propagationDimension = 0.0;
  @#

  @set $fieldsNotToInitialise = set()
  @for $momentGroup in $momentGroups
    @# Initialise the raw vector
${momentGroup.rawVector.functions['initialise'].call()}
    @# Don't call the initialise method as that will cause
    @# its aliases to be initialised, which is bad.
    @silent fieldsNotToInitialise.add(momentGroup.outputField)
  @end for
  @#
  @set $vectorsToInitialise = set()
  @for field in [f for f in $fields if f not in fieldsNotToInitialise]
    @silent vectorsToInitialise.update([v for v in field.managedVectors if not (v.isComputed or v.isNoise)])
  @end for
  @#
  @for vector in self.evaluationOrderForVectors(vectorsToInitialise, static = True)
    @if vector.isComputed
      @# Computed vectors were explicitly removed from the set of vectors that need
      @# initialisation. The only way we can get one now is if one of the other vectors depends on this
      @# vector. In this case, we must provide the information the other vector is requiring. To do this,
      @# we must evaluate the vector, not initialise it.
${vector.functions['evaluate'].call()}
    @else
${vector.initialise}@slurp
    @end if
  @end for
  @#
  @for $momentGroup in $momentGroups
    @# We only need to set the sample index for the propagation dimension
    @# and only if this moment group has the propagation dimension as one
    @# of its dimensions
    @if not $momentGroup.outputField.hasDimensionName($propagationDimension)
      @continue
    @end if
_${momentGroup.outputField.id}_index_${propagationDimension} = 0;
  @end for
  @#
  @for $momentGroup in filter(lambda x: x.requiresInitialSample, $momentGroups)
_mg${momentGroup.number}_sample();
  @end for
  @#
${segmentFunctionBody(function=None)}@slurp
  @#

  @for $momentGroup in $momentGroups
_mg${momentGroup.number}_process();
  @end for  
  @#
@end def