3from swift2.particle.Particle
import Particle
16 A dummy particle containing meaningless variables to test the functionality
19 All this particle does is define variables, and then test getters, setters,
31 super(DastgenTestDummyParticle, self).
__init__(
90 var_basename =
"DebugUserDefinedAttribute"
91 defs = [
"PeanoDebug > 0"]
93 var_basename =
"UserDefinedAttribute"
95 self.
data.add_attribute(
97 name=
"myStatic" + var_basename,
103 qualifier=dastgen2.attributes.Attribute.Qualifier.STATIC,
104 user_type_has_toString_method=
False,
110 Generate boolean attributes.
113 if True, add debug ifdefs to the attributes.
118 var_basename =
"Boolean"
120 var_basename =
"DebugBoolean"
125 defs = [
"PeanoDebug > 0"]
129 self.
data.add_attribute(
132 qualifier=dastgen2.attributes.Attribute.Qualifier.NONE,
136 self.
data.add_attribute(
138 "myInitval" + var_basename,
140 qualifier=dastgen2.attributes.Attribute.Qualifier.NONE,
144 self.
data.add_attribute(
146 "myStatic" + var_basename,
147 qualifier=dastgen2.attributes.Attribute.Qualifier.STATIC,
151 self.
data.add_attribute(
153 "myStaticInitval" + var_basename,
155 qualifier=dastgen2.attributes.Attribute.Qualifier.STATIC,
159 self.
data.add_attribute(
161 "myConst" + var_basename,
163 qualifier=dastgen2.attributes.Attribute.Qualifier.CONST,
167 self.
data.add_attribute(
169 "myConstStatic" + var_basename,
171 qualifier=dastgen2.attributes.Attribute.Qualifier.CONST_STATIC,
175 self.
data.add_attribute(
177 "myConstExpr" + var_basename,
179 qualifier=dastgen2.attributes.Attribute.Qualifier.CONSTEXPR,
188 Generate double attributes.
191 if True, enable compression.
194 if True, add debug ifdefs to the attributes.
199 var_basename =
"Double"
200 if compress
and not ifdefs:
201 var_basename =
"CompressedDouble"
202 if ifdefs
and not compress:
203 var_basename =
"DebugDouble"
204 if ifdefs
and compress:
205 var_basename =
"DebugCompressedDouble"
208 valid_mantissa_bits =
None
210 valid_mantissa_bits = 23
215 defs = [
"PeanoDebug > 0"]
219 self.
data.add_attribute(
222 qualifier=dastgen2.attributes.Attribute.Qualifier.NONE,
223 valid_mantissa_bits=valid_mantissa_bits,
227 self.
data.add_attribute(
229 "myInitval" + var_basename,
231 qualifier=dastgen2.attributes.Attribute.Qualifier.NONE,
232 valid_mantissa_bits=valid_mantissa_bits,
236 self.
data.add_attribute(
238 "myStatic" + var_basename,
239 qualifier=dastgen2.attributes.Attribute.Qualifier.STATIC,
240 valid_mantissa_bits=valid_mantissa_bits,
244 self.
data.add_attribute(
246 "myStaticInitval" + var_basename,
248 qualifier=dastgen2.attributes.Attribute.Qualifier.STATIC,
249 valid_mantissa_bits=valid_mantissa_bits,
253 self.
data.add_attribute(
255 "myConst" + var_basename,
257 qualifier=dastgen2.attributes.Attribute.Qualifier.CONST,
258 valid_mantissa_bits=valid_mantissa_bits,
262 self.
data.add_attribute(
264 "myConstStatic" + var_basename,
266 qualifier=dastgen2.attributes.Attribute.Qualifier.CONST_STATIC,
267 valid_mantissa_bits=valid_mantissa_bits,
271 self.
data.add_attribute(
273 "myConstExpr" + var_basename,
275 qualifier=dastgen2.attributes.Attribute.Qualifier.CONSTEXPR,
276 valid_mantissa_bits=valid_mantissa_bits,
285 Generate enum attributes.
288 if True, add debug ifdefs to the attributes.
293 var_basename =
"Enum"
298 var_basename =
"DebugEnum"
299 defs = [
"PeanoDebug > 0"]
301 self.
data.add_attribute(
304 variants=[
"Foo",
"Bar",
"Baz",
"Last"],
305 qualifier=dastgen2.attributes.Attribute.Qualifier.NONE,
314 Generate integer attributes.
317 if True, enable compression.
320 if True, add debug ifdefs to the attributes.
325 var_basename =
"Integer"
326 if compress
and not ifdefs:
327 var_basename =
"CompressedInteger"
328 if ifdefs
and not compress:
329 var_basename =
"DebugInteger"
330 if ifdefs
and compress:
331 var_basename =
"DebugCompressedInteger"
343 defs = [
"PeanoDebug > 0"]
347 self.
data.add_attribute(
350 qualifier=dastgen2.attributes.Attribute.Qualifier.NONE,
356 self.
data.add_attribute(
358 "myInitval" + var_basename,
360 qualifier=dastgen2.attributes.Attribute.Qualifier.NONE,
366 self.
data.add_attribute(
368 "myStatic" + var_basename,
369 qualifier=dastgen2.attributes.Attribute.Qualifier.STATIC,
375 self.
data.add_attribute(
377 "myStaticInitval" + var_basename,
379 qualifier=dastgen2.attributes.Attribute.Qualifier.STATIC,
385 self.
data.add_attribute(
387 "myConst" + var_basename,
389 qualifier=dastgen2.attributes.Attribute.Qualifier.CONST,
395 self.
data.add_attribute(
397 "myConstStatic" + var_basename,
399 qualifier=dastgen2.attributes.Attribute.Qualifier.CONST_STATIC,
405 self.
data.add_attribute(
407 "myConstExpr" + var_basename,
409 qualifier=dastgen2.attributes.Attribute.Qualifier.CONSTEXPR,
420 Generate string attributes.
423 if True, add debug ifdefs to the attributes.
428 var_basename =
"String"
433 var_basename =
"DebugString"
434 defs = [
"PeanoDebug > 0"]
438 self.
data.add_attribute(
441 qualifier=dastgen2.attributes.Attribute.Qualifier.NONE,
445 self.
data.add_attribute(
447 "myInitval" + var_basename,
449 qualifier=dastgen2.attributes.Attribute.Qualifier.NONE,
453 self.
data.add_attribute(
455 "myStatic" + var_basename,
456 qualifier=dastgen2.attributes.Attribute.Qualifier.STATIC,
460 self.
data.add_attribute(
462 "myStaticInitval" + var_basename,
463 initval=
"static_initval",
464 qualifier=dastgen2.attributes.Attribute.Qualifier.STATIC,
468 self.
data.add_attribute(
470 "myConst" + var_basename,
471 initval=
"const_initval",
472 qualifier=dastgen2.attributes.Attribute.Qualifier.CONST,
476 self.
data.add_attribute(
478 "myConstStatic" + var_basename,
479 initval=
"const_static_initval",
480 qualifier=dastgen2.attributes.Attribute.Qualifier.CONST_STATIC,
498 Generate boolean-array attributes.
501 if True, enable compression.
504 if True, add debug ifdefs to the attributes.
509 var_basename =
"BooleanArray"
510 if compress
and not ifdefs:
511 var_basename =
"CompressedBooleanArray"
512 if ifdefs
and not compress:
513 var_basename =
"DebugBooleanArray"
514 if ifdefs
and compress:
515 var_basename =
"CompressedDebugBooleanArray"
520 defs = [
"PeanoDebug > 0"]
522 self.
data.add_attribute(
526 qualifier=dastgen2.attributes.Attribute.Qualifier.NONE,
536 Generate integer-array attributes.
539 if True, enable compression.
542 if True, add debug ifdefs to the attributes.
547 var_basename =
"IntegerArray"
548 if compress
and not ifdefs:
549 var_basename =
"CompressedIntegerArray"
550 if ifdefs
and not compress:
551 var_basename =
"DebugIntegerArray"
552 if ifdefs
and compress:
553 var_basename =
"CompressedDebugIntegerArray"
558 defs = [
"PeanoDebug > 0"]
567 self.
data.add_attribute(
571 qualifier=dastgen2.attributes.Attribute.Qualifier.NONE,
582 Generate double-array attributes.
585 if True, enable compression.
588 if True, add debug ifdefs to the attributes.
593 var_basename =
"DoubleArray"
594 if compress
and not ifdefs:
595 var_basename =
"CompressedDoubleArray"
596 if ifdefs
and not compress:
597 var_basename =
"DebugDoubleArray"
598 if ifdefs
and compress:
599 var_basename =
"CompressedDebugDoubleArray"
604 defs = [
"PeanoDebug > 0"]
607 valid_mantissa_bits =
None
609 valid_mantissa_bits = 23
611 self.
data.add_attribute(
615 qualifier=dastgen2.attributes.Attribute.Qualifier.NONE,
616 valid_mantissa_bits=valid_mantissa_bits,
625 Generate peano4 integer-array attributes.
628 if True, enable compression.
631 if True, add debug ifdefs to the attributes.
636 var_basename =
"PeanoIntegerArray"
637 if compress
and not ifdefs:
638 var_basename =
"CompressedPeanoIntegerArray"
639 if ifdefs
and not compress:
640 var_basename =
"DebugPeanoIntegerArray"
641 if ifdefs
and compress:
642 var_basename =
"CompressedDebugPeanoIntegerArray"
647 defs = [
"PeanoDebug > 0"]
656 self.
data.add_attribute(
670 Generate peano4 double-array attributes.
673 if True, enable compression.
676 if True, add debug ifdefs to the attributes.
681 var_basename =
"PeanoDoubleArray"
682 if compress
and not ifdefs:
683 var_basename =
"CompressedPeanoDoubleArray"
684 if ifdefs
and not compress:
685 var_basename =
"DebugPeanoDoubleArray"
686 if ifdefs
and compress:
687 var_basename =
"CompressedDebugPeanoDoubleArray"
692 defs = [
"PeanoDebug > 0"]
695 valid_mantissa_bits =
None
697 valid_mantissa_bits = 23
699 self.
data.add_attribute(
703 valid_mantissa_bits=valid_mantissa_bits,
713 Return algorithm steps: A list of AlgorithmStep objects to be executed in
719 name=
"dummyDastgenTest",
720 dependencies=AlgorithmStep.Dependencies.SELF,
721 effect=AlgorithmStep.Effect.ALTER_LOCAL_STATE,
722 touch_vertex_first_time_kernel=
"""::swift2::dastgenTest::checkDastgen(assignedParticles);""",
723 prepare_traversal_kernel=
"""
724 ::swift2::dastgenTest::dummyMoveForwardInTime<globaldata::{}>();""".format(
728 #include "DastgenTest.h"
737 name=
"dummyDastgenTest2",
738 dependencies=AlgorithmStep.Dependencies.SELF,
739 effect=AlgorithmStep.Effect.ALTER_LOCAL_STATE,
740 touch_vertex_last_time_kernel=
"""::swift2::dastgenTest::checkDastgen(assignedParticles);""",
741 unprepare_traversal_kernel=
"""
742 globaldata::{PARTICLE}::getSpecies().setTimeStamp( globaldata::{PARTICLE}::getSpecies().getMinTimeStamp() + globaldata::{PARTICLE}::getSpecies().getMinTimeStepSize(), false );
743 ::swift2::dastgenTest::reportStep<globaldata::{PARTICLE}>( "{PARTICLE}" );
748 #include "DastgenTest.h"
758 Set the mantissa size of doubles and Peano double arrays if
759 we want to use reduced precission via Clang annotations. As a reference,
760 floats have mantissa size = 23.
765 @mantissa_size.setter
767 if mantissa_size < 0:
768 raise ValueError(
"Mantissa size has to be larger than 0.")
774 Transform namespace into cpp format. Could be used to append namespace to
775 constants in kernels (not used currently).
778 namespace =
"::".join(self._swift_project_namespace) +
"::"
788 super(DastgenTestDummyParticle, self).readme_descriptor
791 Dummy particle containing meaningless variables to test the functionality
Represent an array of boolean flags.
An array of doubles, i.e.
cardinality is a string (you can thus use symbols as well as long as they will be defined at compile ...
Wrapper around C++ enumerations which is not a datatype supported natively by MPI.
Wrapper around C++ string which is not a dataype supported by MPI natively.
Wrapper around user-defined attribute.
Specialisation of dastgen2.attributes.DoubleArray which relies on Peano's tarch.
Defines the meta data around one algorithmic step per particle.
Base class for any particle in the project.
A dummy particle containing meaningless variables to test the functionality of dastgen2.
_generate_peano_double_array_attributes(self, bool compress, bool ifdefs)
Generate peano4 double-array attributes.
mantissa_size(self)
Set the mantissa size of doubles and Peano double arrays if we want to use reduced precission via Cla...
_generate_peano_integer_array_attributes(self, bool compress, bool ifdefs)
Generate peano4 integer-array attributes.
algorithm_steps(self)
Return algorithm steps: A list of AlgorithmStep objects to be executed in that order.
_generate_integer_attributes(self, bool compress, bool ifdefs)
Generate integer attributes.
_generate_string_attributes(self, bool ifdefs)
Generate string attributes.
initialisation_steps(self)
Return sequence of algorithm steps that have to be performed throughout initialisation.
_generate_double_array_attributes(self, bool compress, bool ifdefs)
Generate double-array attributes.
_generate_boolean_attributes(self, bool ifdefs)
Generate boolean attributes.
_generate_integer_array_attributes(self, bool compress, bool ifdefs)
Generate integer-array attributes.
_generate_enum_attributes(self, bool ifdefs)
Generate enum attributes.
_generate_user_defined_attributes(self, bool ifdefs)
_generate_boolean_array_attributes(self, bool compress, bool ifdefs)
Generate boolean-array attributes.
_generate_double_attributes(self, bool compress, bool ifdefs)
Generate double attributes.
get_cpp_namespace_from_project_namespace(self)
Transform namespace into cpp format.
__init__(self, name, particles_per_cell=0, min_h=0.3, max_h=0.3)
Initialise the particle.