Peano
Loading...
Searching...
No Matches
peano4.api.Project.Project Class Reference

Represents a Peano 4 project. More...

Inheritance diagram for peano4.api.Project.Project:
Collaboration diagram for peano4.api.Project.Project:

Public Member Functions

 __init__ (self, namespace, project_name, directory=".", subdirectory="", executable="")
 project_name Simple string.
 __str__ (self)
 set_fenv_handler (self, args)
 cleanup (self)
 This routine has to be called after you've generated your code.
 generate (self, overwrite=Overwrite.Default, throw_away_data_after_generation=False)
 Generate all code.
 build (self, make=True, make_clean_first=True, throw_away_data_after_build=False, number_of_parallel_builds=-1)
 Invokes the underlying make build mechanism on the project.
 run (self, executable, args=[], prefix=None, pipefile=None, rebuild_if_required=True)
 Runs the code.
 add_subproject (self, 'Project' subproject, master=False)
 Adds a new Peano4 project into this Peano 4 project.
 subdirectory (self)

Data Fields

 rootnamespace = namespace.copy()
 namespace = namespace
list namespaces = []
list subdirectories = []
list temporary_subdirectories = []
 project_name = project_name
 directory = directory
 temporary_directory = tempfile.mkdtemp()
 temporary_subdirectory = tempfile.mkdtemp()
 subdirectory
 output = peano4.api.output.Output()
 datamodel = peano4.api.datamodel.Model(self.namespace, self, self.subdirectory)
 solversteps = peano4.api.solversteps.Steps(self)
 main = peano4.api.runner.DefaultSequence(self)
bool is_generated = False
bool is_built = False
bool build_was_successful = False
 constants = peano4.api.output.Constants(self)
list subconstants = []
bool is_extended = False

Protected Attributes

 _subdirectory = subdirectory

Detailed Description

Represents a Peano 4 project.

namespace Sequence of strings representing the (nested) namespace. Pass in [ "examples", "algebraicmg" ] for example if you wanna write a solver that is embedded into the namespace examples.algebraicmg.

Global project properties

If you want to alter some global constants, you should manipulate the constants attribute. It will eventually feed into the generated file Constants.h. See peano4.api.output.Constants for further info.

Definition at line 26 of file Project.py.

Constructor & Destructor Documentation

◆ __init__()

peano4.api.Project.Project.__init__ ( self,
namespace,
project_name,
directory = ".",
subdirectory = "",
executable = "" )

project_name Simple string.

Definition at line 44 of file Project.py.

Member Function Documentation

◆ __str__()

peano4.api.Project.Project.__str__ ( self)

Definition at line 101 of file Project.py.

References datamodel, and solversteps.

Referenced by peano4.api.toolbox.particles.postprocessing.ParticleVTUReader.VTUParticleSet.__repr__().

Here is the caller graph for this function:

◆ add_subproject()

peano4.api.Project.Project.add_subproject ( self,
'Project' subproject,
master = False )

Adds a new Peano4 project into this Peano 4 project.

assert( lhs.namespace == rhs.namespace ), "namespaces of the projects being merged don't match"

assert( lhs.directory == rhs.directory ), "directories of the projects being merged don't match"

assert( lhs.output.makefile.d["CXX"] == lhs.output.makefile.d["CXX"] ), "CXX compilers of the projects being merged don't match"

assert( lhs.output.makefile.d["FC"] == lhs.output.makefile.d["FC"] ), "FC compilers of the projects being merged don't match"

assert( lhs.output.makefile.d["DIM"] == lhs.output.makefile.d["DIM"] ), "dimensions of the projects being merged don't match"

assert( lhs.output.makefile.d["MODE"] == lhs.output.makefile.d["MODE"] ), "compile modes of the projects being merged don't match"

Definition at line 344 of file Project.py.

References api.Project.Project._subdirectory, exahype2.api.Project.Project._subdirectory, peano4.api.datamodel.Model.Model._subdirectory, _subdirectory, assert, datamodel, is_extended, main, exahype2.api.dslhype2.AbstractSyntaxTree.Function.namespace, peano4.api.datamodel.DoF.DoF.namespace, peano4.api.datamodel.Model.Model.namespace, peano4.api.output.ActionSet.ActionSet.namespace, peano4.api.output.Jinja2TemplatedHeaderFile.Jinja2TemplatedHeaderFile.namespace, peano4.api.output.Jinja2TemplatedHeaderImplementationFilePair.Jinja2TemplatedHeaderImplementationFilePair.namespace, peano4.api.output.Jinja2TemplateStringHeaderImplementationFilePair.Jinja2TemplateStringHeaderImplementationFilePair.namespace, peano4.api.output.Observer.Observer.namespace, peano4.api.output.TemplatedHeaderFile.TemplatedHeaderFile.namespace, peano4.api.output.TemplatedHeaderImplementationFilePair.TemplatedHeaderImplementationFilePair.namespace, namespace, peano4.api.datamodel.Model.Model.namespaces, namespaces, exahype2.api.rkfd4.actionsets.ComputeLinearCombination.ComputeLinearCombination.output, output, rootnamespace, solversteps, subconstants, peano4.api.datamodel.Model.Model.subdirectories, subdirectories, peano4.api.datamodel.Model.Model.temporary_subdirectories, and temporary_subdirectories.

◆ build()

peano4.api.Project.Project.build ( self,
make = True,
make_clean_first = True,
throw_away_data_after_build = False,
number_of_parallel_builds = -1 )

Invokes the underlying make build mechanism on the project.

number_of_parallel_builds: int This is mapped onto make -jnumber_of_parallel_builds, i.e., it determines how many parallel make instances the code spawns. Usually, a lot of the generated code is quite lengthy. Therefore compile time can be high. If you pass something smaller or equal to zero, it will use the core count as guideline how to compile.

throw_away_data_after_build: Bool see generate()

Definition at line 223 of file Project.py.

References build_was_successful, cleanup(), plot_celldepth_benchmarks.BenchmarkData.cleanup, datamodel, directory, exahype2::VolumeIndex< N, Args >.generate(), exahype2::VolumeIndex< 0, Args... >.generate(), peano4.api.datamodel.DaStGen2.DaStGen2Artefact.generate(), peano4.api.output.ActionSet.ActionSet.generate(), peano4.api.output.Constants.Constants.generate(), peano4.api.output.Constants.Constants.generate(), peano4.api.output.InvokeExternalTool.InvokeExternalTool.generate(), peano4.api.output.Jinja2TemplatedHeaderFile.Jinja2TemplatedHeaderFile.generate(), peano4.api.output.Jinja2TemplatedHeaderImplementationFilePair.Jinja2TemplatedHeaderImplementationFilePair.generate(), peano4.api.output.Jinja2TemplateStringHeaderImplementationFilePair.Jinja2TemplateStringHeaderImplementationFilePair.generate(), peano4.api.output.Makefile.Makefile.generate(), peano4.api.output.Observer.Observer.generate(), peano4.api.output.Output.Output.generate(), peano4.api.output.Readme.Readme.generate(), peano4.api.output.TemplatedHeaderFile.TemplatedHeaderFile.generate(), peano4.api.output.TemplatedHeaderImplementationFilePair.TemplatedHeaderImplementationFilePair.generate(), generate(), is_built, is_generated, exahype2.api.rkfd4.actionsets.ComputeLinearCombination.ComputeLinearCombination.output, output, and solversteps.

Referenced by run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ cleanup()

peano4.api.Project.Project.cleanup ( self)

This routine has to be called after you've generated your code.

Definition at line 107 of file Project.py.

References constants, datamodel, is_built, is_generated, main, exahype2.api.rkfd4.actionsets.ComputeLinearCombination.ComputeLinearCombination.output, output, solversteps, and subconstants.

Referenced by build().

Here is the caller graph for this function:

◆ generate()

peano4.api.Project.Project.generate ( self,
overwrite = Overwrite.Default,
throw_away_data_after_generation = False )

Generate all code.

If you add stuff to your project after a build, you have to (re-)generate the code. If you compile only once, you don't have to invoke this routine explicitly. It is lazily called by the other project routines - the latest before you run the code.

It is important that I reset the output after each generate call before you change parameter settings and call generate again. To do so, invoke cleanup(). If you forget this, two subsequent generate calls enrich the output twice.

throw_away_data_after_generation: Bool The Peano 4 memory footprint can become quite substantial effectively reducing the translation capabilities (as compilers tend to require a lot of memory, too). So pass in True if you want the script to throw away the data structures (and run a garbage collection) after all files have been generated. Please note that it invalidates both this object (and maybe another object that you've used to generate the present one - such as ExaHyPE). It really strips everything down to the stuff you absolutely need to translate and run the code.

Definition at line 123 of file Project.py.

References constants, datamodel, directory, generate(), is_built, is_generated, main, exahype2.api.rkfd4.actionsets.ComputeLinearCombination.ComputeLinearCombination.output, output, project_name, solversteps, subconstants, peano4.api.datamodel.Model.Model.subdirectories, subdirectories, peano4.api.datamodel.DoF.DoF.subdirectory, peano4.api.datamodel.Model.Model.subdirectory, peano4.api.output.ActionSet.ActionSet.subdirectory, peano4.api.output.InvokeExternalTool.InvokeExternalTool.subdirectory, peano4.api.output.Jinja2TemplatedHeaderFile.Jinja2TemplatedHeaderFile.subdirectory, peano4.api.output.Jinja2TemplatedHeaderImplementationFilePair.Jinja2TemplatedHeaderImplementationFilePair.subdirectory, peano4.api.output.Jinja2TemplateStringHeaderImplementationFilePair.Jinja2TemplateStringHeaderImplementationFilePair.subdirectory, peano4.api.output.Observer.Observer.subdirectory, peano4.api.output.TemplatedHeaderFile.TemplatedHeaderFile.subdirectory, peano4.api.output.TemplatedHeaderImplementationFilePair.TemplatedHeaderImplementationFilePair.subdirectory, subdirectory, temporary_directory, peano4.api.datamodel.Model.Model.temporary_subdirectories, temporary_subdirectories, peano4.api.datamodel.DoF.DoF.temporary_subdirectory, peano4.api.datamodel.Model.Model.temporary_subdirectory, and temporary_subdirectory.

Referenced by build(), and generate().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ run()

peano4.api.Project.Project.run ( self,
executable,
args = [],
prefix = None,
pipefile = None,
rebuild_if_required = True )

Runs the code.

args should be a list of strings or the empty list. prefix is an array, too. A typical invocation looks alike project.run( ["16.0", "32.0"], ["/opt/mpi/mpirun", "-n", "1"] ) The operation returns True if the run had been successful

pipefile: string or None

Definition at line 298 of file Project.py.

References build(), build_was_successful, and is_built.

Here is the call graph for this function:

◆ set_fenv_handler()

peano4.api.Project.Project.set_fenv_handler ( self,
args )

Definition at line 104 of file Project.py.

References main.

◆ subdirectory()

peano4.api.Project.Project.subdirectory ( self)

Field Documentation

◆ _subdirectory

peano4.api.Project.Project._subdirectory = subdirectory
protected

Definition at line 62 of file Project.py.

Referenced by add_subproject(), and subdirectory().

◆ build_was_successful

peano4.api.Project.Project.build_was_successful = False

Definition at line 90 of file Project.py.

Referenced by build(), and run().

◆ constants

peano4.api.Project.Project.constants = peano4.api.output.Constants(self)

Definition at line 92 of file Project.py.

Referenced by cleanup(), and generate().

◆ datamodel

peano4.api.Project.Project.datamodel = peano4.api.datamodel.Model(self.namespace, self, self.subdirectory)

Definition at line 82 of file Project.py.

Referenced by __str__(), add_subproject(), build(), cleanup(), and generate().

◆ directory

peano4.api.Project.Project.directory = directory

Definition at line 60 of file Project.py.

Referenced by build(), and generate().

◆ is_built

bool peano4.api.Project.Project.is_built = False

Definition at line 89 of file Project.py.

Referenced by build(), cleanup(), generate(), and run().

◆ is_extended

bool peano4.api.Project.Project.is_extended = False

◆ is_generated

bool peano4.api.Project.Project.is_generated = False

Definition at line 88 of file Project.py.

Referenced by build(), cleanup(), and generate().

◆ main

peano4.api.Project.Project.main = peano4.api.runner.DefaultSequence(self)

Definition at line 86 of file Project.py.

Referenced by add_subproject(), cleanup(), generate(), and set_fenv_handler().

◆ namespace

peano4.api.Project.Project.namespace = namespace

Definition at line 55 of file Project.py.

Referenced by add_subproject().

◆ namespaces

list peano4.api.Project.Project.namespaces = []

Definition at line 56 of file Project.py.

Referenced by add_subproject().

◆ output

peano4.api.Project.Project.output = peano4.api.output.Output()

Definition at line 77 of file Project.py.

Referenced by add_subproject(), build(), cleanup(), and generate().

◆ project_name

peano4.api.Project.Project.project_name = project_name

Definition at line 59 of file Project.py.

Referenced by generate().

◆ rootnamespace

peano4.api.Project.Project.rootnamespace = namespace.copy()

Definition at line 54 of file Project.py.

Referenced by add_subproject().

◆ solversteps

peano4.api.Project.Project.solversteps = peano4.api.solversteps.Steps(self)

Definition at line 84 of file Project.py.

Referenced by __str__(), add_subproject(), build(), cleanup(), and generate().

◆ subconstants

peano4.api.Project.Project.subconstants = []

Definition at line 93 of file Project.py.

Referenced by add_subproject(), cleanup(), and generate().

◆ subdirectories

peano4.api.Project.Project.subdirectories = []

Definition at line 57 of file Project.py.

Referenced by add_subproject(), and generate().

◆ subdirectory

peano4.api.Project.Project.subdirectory

Definition at line 70 of file Project.py.

Referenced by generate().

◆ temporary_directory

peano4.api.Project.Project.temporary_directory = tempfile.mkdtemp()

Definition at line 61 of file Project.py.

Referenced by generate().

◆ temporary_subdirectories

peano4.api.Project.Project.temporary_subdirectories = []

Definition at line 58 of file Project.py.

Referenced by add_subproject(), and generate().

◆ temporary_subdirectory

peano4.api.Project.Project.temporary_subdirectory = tempfile.mkdtemp()

Definition at line 63 of file Project.py.

Referenced by generate().


The documentation for this class was generated from the following file: