Phalanx  Development
Users Guide

Index

Getting Started

A. Understand Templates

Phalanx is a complex package that make heavy use of the C++ templating mechanism. We recommend that users of the Phalanx package first familiarize themselves with C++ templates. An excellent reference is "C++ Templates: The Complete Guide" by Vandevoorde and Josuttis, 2003. While users do not need to understand template metaprogramming to use Phalanx, the concepts underlying many operations in Phalanx can be found in "C++ Template Metaprogramming" by Abrahams and Gurtovoy, 2004 and the Boost template metaprogramming library (MPL).

Once Phalanx is integrated into a code by a template savvy developer, the only operation application users should perform is to extend the evaluation routines to new equations and new models by adding new Evaluators. We realize that application developers and application users typically have distictly different skill sets. Much design work has been invested in making the Evaluator implementation very clean and as template free as possible. Therefore, users of the code who only write new Evaluators DO NOT need to know templates.

B. Learn the Phalanx Nomenclature

Users should then learn the nomeclature used in the package defined in the Phalanx Domain Model.

C. Tutorial

The main concept of Phalanx is to evaluate fields typically for solving PDEs (although it is not limited to this). We demonstrate the integration process using the simple example found in phalanx/example/MultiDimensionalArray. Suppose that we want to solve the heat equation over the physical space $ \Omega $:

\[ \nabla \cdot (-k \nabla T) + s = 0 \]

where $ T $ is the temparature (and our degree of freedom), $ k $ is the thermal conductivity, and $s$ is a nonlinear source term. We pose this in terms of a conservation law system:

\[ \nabla \cdot (\mathbf{q}) + s = 0 \]

where $ \mathbf{q} = -k \nabla T $ is the heat flux. The specific discretization technique whether finite element (FE) or finite volume (FV) will ask for $\mathbf{q}$ and $s$ at points on the cell. Phalanx will evaluate $\mathbf{q}$ and $s$ at those points and return them to the discretization driver.

Using finite elements, we pose the problem in variational form: Find $ u \in {\mathit{V^h}} $ and $ \phi \in {\mathit{S^h}} $ such that:

\[ - \int_{\Omega} \nabla \phi \cdot \mathbf{q} d\Omega + \int_{\Gamma} \phi \mathbf{n} \cdot \mathbf{q} + \int_{\Omega} \phi s d\Omega = 0 \]

Phalanx will evaluate $\mathbf{q}$ and $s$ at the quadrature points of the cells and pass them off to the integrator such as Intrepid.

This is a trivial example, but the dependency chains can grow quite complex if performing something such as a chemically reacting flow calculation coupled to Navier-Stokes and energy conservation.

Follow the steps below to integrate Phalanx into your application. The example code shown in the steps comes from the energy flux example in the directory "phalanx/example/EnergyFlux". Note that many classes are named with the word "My" such as MyWorkset, MyTraits, and MyFactory traits. Any object that starts with the word "My" denotes that this is a user defined class. The user must implement this class specific to their application. All Evaluator derived objects are additionally implemented by the user even though they do not follow the convention of starting with the word "My".

Phalanx Domain Model

  • Cell

    Partial differential equations are solved in a domain. This domain is discretized into cells (also called elements for the finite element method). This library assumes that the block of cells being iterated over is of the same type! If different evaluators (i.e. different material properties) are required in different blocks of cells, a new FieldMangager must be used for each unique block of elements. This is required for efficiency.

  • Parallel and Serial Architectures

    Phalanx can be used on both serial and multi-processor architectures. The library is designed to perform "local" evalautions on a "local" set of cells. The term local means that all cell and field data required for an evaluation is on the processor that the evaluation is executed. So for parallel runs, the cells are distributed over the processors and a FieldManager is built on each processor to evaluate only the cells that are assigned to that processor. If there is any data distributed to another processor that is required for the evaluation, the user must handle pulling that information on to the evaluation processor. The design of Phalanx will also allow for users to take advantage of multi-core architectures through a variety of implementations.

  • Workset

    For performance and memory limitations, the evaluation of fields can be divided into worksets. While Phalanx does not require the use of worksets, we recomend their use for controlling the memory footprint (this can be important when offloading the kernels onto an accelerator and even for host node memory). The goal of using worksets is to fit all the required fields into the processor cache so that an evaluation is not slowed down by paging memory. Suppose we have a cell-based discretization with 2020 cells to evaluate on a 4 node machine. We might distribute the load so that 505 cells are on each MPI processor. Now the user must figure out the workset size. This is the number of cells to per evaluation call so that the field memory will fit into cache. If we have 505 cells on a processor, suppose we find that only 50 cells at a time will fit into cache. Then we will create a FieldManager with a size of 50 cells. This number is specified in the construction of data layouts. During the call to postRegistrationSetup(), the FieldManager will allocate workspace storage for all fields relevant to the evaluation.

    For our example, there will be 11 worksets. The first 10 worksets will have the 50 cell maximum and the final workset will have the 5 remaining cells. The evaluation routine is called for each workset, where workset information can be passed in through the evaluate call:

    std::vector<WorksetData> workset_data;
    .
    .
    // Initialize workset data
    .
    .
    for (std::size_t i = 0; i < workset_data.size(); ++i) {
    field_manager.evaluateFields<MyTraits::Residual>(workset_data[i]);
    .
    .
    // use evaluated fields
    .
    .
    }

    Note that the call to evaluateFields() takes a workset data object in this example. The field_manager is templated on a traits class that allows the user to define the actual object passed into the evaluatFields call. This does not have to be a workset_data object but can be any class or struct the user defines (even void).

    Note that you do not have to use the workset idea. In this cell-based discretization example, one could just evaluate all local elements in one loop (equivalent to a single workset). Be aware that this can result in a possibly large performance hit.

    Phalanx, in fact, does not restrict you to cell based iteration. You can iterate over any entity type such as edge or face structures.

  • Consistent Evaluation

    Phalanx was imtended to perform consistent evaluations. By consistent, we mean that all dependencies of a field evaluation are current with respect to the current degree of freedom values. For example, suppose we need to evaluate the the energy flux. This has dependencies on the diffusivity, and the temperature gradient. Each of these quantities in turn depends on the temperature. So before the diffusivity and temperature gradient are evaluated, the temperature must be evaluated. Before the energy flux can be evaluated, the density, diffusivity, and temperature gradient must be evaluated. Phalanx forces an ordered evaluation that updates fields in order to maintain consistency of the dependency chain. Without this, one might end up with lagged values being used from a previous evaluate call.

    This does not rule out the use of semi-implicit or operator split schemes. In fact these have been demonstrated in Phalanx. It just rquires that users store any lagged history and provide a field evaluator to pull that history in.

  • Scalar Type

    A scalar type, typically the template argument ScalarT in Phalanx code, is the type of scalar used in an evaluation. It is typically a double or float, but can be special object types for extended precision, complex values, and special embedded methods data types such as sensitivity analysis. For example, for sensitivity analysis, a double scalar type is replaced with a foward automatic differentiation object (FAD) or a reverse automatic differentaion object (RAD) to produce sensitivity information. Whatever type is used, the standard mathematical operators are overloaded for the particular embedded technology. For an example of this, see the Sacado Automatic Differentiation Library. Some sample scalar types include:

    • float
    • double
    • Sacado::Fad::DFad<double> (for sensitivity analysis)

  • Data Type

    The data type is a deprecated concept used in the original Phalanx implementation. It is now equivalent to the scalar type. You might see use older code specifying a DataT template parameter, but this is now equivalent the ScalarT template parameter.

  • Evaluation Type

    The evaluation type, typically the template argument EvalT in Phalanx code, defines a unique type of evaluation to perform. The user is free to choose/create the evaluation types - they implement their own class or struct for their own evaluation types. An EvaluationContainer is allocated for each evaluation type specified in the users traits class. Examples that we usually use include:

    • Residual (simple function evaluation)
    • Jacobian (function sensitivities with respect to state variables)
    • Tangent (parameter sensitivity)

    The evaluation type must be associated with one default scalar type and can optionally support additional scalar types. The scalar type usually determines what is being evaluated. For example, to evaluate the equation residuals, the scalar type is usually a double, a float or an extended precision type. To evaluate a Jacobian, the scalar type could be a forward automatic differentiation object, Sacado::Fad::DFAD<double>. By introducing the evaluation type in Phalanx, the same scalar type can be used for different evaluation types and can be specialized accordingly. For example computing the Jacobian and computing parameter sensitivities both could use the Sacado::Fad::DFAD<double> scalar type.

  • Storage

    A DataContainer object stores all fields of a particular data type. Each EvaluationContainer holds a vector of DataContainers, one DataContainer for each vaid data type that is associated with that particular evaluation type. One EvaluationContainer is constructed for each evaluation type.

    NOTE: this concept was needed for memory allocation in the first generation Phalanx library when all fields for an evaluation type were stored contiguously in memory. Since the Kokkos transition, memory in now controlled by the Kokkos::View. We could remove this concept and corresponding code in the future. This object is not used by the user and is an underlying implementatino detail. It's removal will NOT result in changes to user code.

  • Data Layout

    The DataLayout object is used to define layout of the multidimensional array used to store Phalanx Fields. It provides the size of each rank in the multidimensional array and provides a unique string name to distinguish fields with the same name that might exist on different layouts. For example, supposed we have written an evaluator the computes the "Density" field for a set of points in the cell. Now we want to evaluate the density at a different set of points in the cell. We might have a "Density" field in a cell associated with a set of integration points (quadrature/integration points in finite elements) and another field associated with the nodes (nodal basis degree of freedom points in finite elements). We use the same field name (so we can reuse the same Evaluator), "Density", but use two different DataLayouts, one for integration points and one for nodal point. Now a FieldTag comparison will differentiate the fields due to the different DataLayout.

  • Field Tag

    The FieldTag is a description of a field. It is templated on the data type, DataT. It is used to identify a field stored in the field manager. It contains a unique identifier (an stl std::string) and a pointer to a data layout object. If two FieldTags are equal, the DataLayout, the data type, and the string name are exactly the same.

  • Field

    A Field is a set of values for a particular quantity of interest that must be evaluated. It is templated on the data type, DataT. It consists of a FieldTag and a reference counted smart pointer (Teuchos::RCP<DataT>) to the data array where the values are stored.

  • Evaluator

    An Evaluator is an object that evaluates a set of Fields. It contains two vectors of Fields, one set is the fields it will evaluate and one set is the fields it depends on for the evaluation. For example to evaluate a density field that is a function of temperature and pressure, the field the evaluator will evaluate (the first field set) is a density field, and the set of fields it requires to meet its dependencies are the temperature and pressure fields (the second field set). The evaluator is templated on the evaluation type and the traits class.

  • Evaluator Manager

    The main object that stores all Fields and Evaluators. The evaluator manager (EM) sorts the evaluators and determines which evaluators to call and the order necessary to ensure consistency in the fields. The EM also allocates the memory for storage of all fields so that if we want to force all fields to be in a contiguous block, we have that option available. Users can write their own allocator for memory management.

  • Multidimensional Array

    Instead of using the concept of an algebraic type that the user implements, it may be easier to use a multidimensional array. For example, suppose we have ten cells, and in each cell there are four points (specifically quadrature points) where we want to store a 3x3 matrix for the stress tensor. Using the concepts of algebraic types, we would use a user defined matrix in a Phalanx Field:

    PHX::MDA::Layout<Cell,QP> layout(10,4);
    PHX::Field< MyTensor<double> > stress("Stress",layout);

    However, Phalanx also implements the idea of a multidimensional array with optional compile time checking on rank accessors.

    PHX::MDA::Layout<Cell,QP,Dim,Dim> layout(10,4,3,3);
    PHX::MDField<double,Cell,QP,Dim,Dim> stress("Stress",layout);

    Here, the "Cell", "QP", and "Dim" objects are small structs that allow users to describe the ordinates associated with the multidimensional array.

    The benefits of using the multidimensional array are that (1) checking of the rank accessor at either compile time or runtime (runtime checking is only enabled for debug builds for efficiency) prevent coding errors and (2) the documentation of the ordinals is built into the code - no relying on comments that go out of date.

    The EnergyFlux example is reimplemented using the multidimensional array instead of the algebric types in the directory Trilinos/packages/phalanx/example/MultiDimensionalArray/.

    Our recomendation is to use the multidimensional array version as future codes plan to use this object. The PHX::MDField is fully compatible with Intrepid whereas the PHX::Field is not. We keep the PHX::Field object around for performance measurements since it directly accesses the Teuchos::ArrayRCP object where the PHX::MDField uses a shards::Array object. If the compiler optimizes correctly, there should be no difference in performance. By testing both the Field and MDField, we can test compiler optimization.

Performance

Some recomendations for efficient code:

  • Use worksets This may eliminate cache misses.

  • Enable compiler optimization: The Field and MDField classes use inlined bracket operators for data access. That means if you build without optimization some compilers will produce very slow code. To see if your compiler is optimizing away the bracket operator overhead, run the test found in the directory "phalanx/test/Performance/BracketOperator". If the timings are the same between a raw pointer array and the Field and MDField classes, your compiler has removed the overhead. For example, on gnu g++ 4.2.4, compiling with -O0 shows approximately 2x overhead for bracket accessors, while -O2 shows about a 10% overhead, while -O3 completely removes the overhead.

  • Algebraic Types: Implementing your own algebraic types, while convenient for users, can introduce overhead as opposed to using raw arrays or the multidimensional array. The tests found in "phalanx/test/Performance/AlgebraicTypes" demonstrate some of this overhead. Expression templates should remove this overhead, but in our experience, this seems to be very compiler and implementation dependent. If you build in tvmet support, you can compare expression templates, our "dumb" implementation for vectors and matrices, and our multidimensional array against raw array access. Our testing on gnu compilers shows an overhead of about 20-25% when using "dumb" objects and the expresion templates as opposed to raw arrays. We recommend using raw arrays with the multi-dimensional array (MDField) for fastest runtimes.

  • Use Contiguous Allocator: Phalanx has two allocators, one that uses the "new" command for each separate field, and one that allocates a single contiguous array for ALL fields. If cache performance is the limiting factor, the contiguous allocator could have a big effect on performance. Additionally, alignment issues can play a part in the allocators depending on how you implement your algrbraic types. Our ContiguousAllocator allows users to choose the alignment based on a template parameter. Typically, this is double.

  • Limit the number of Fields and/or Evaluators: The more evaluators used in your code, the more the loop sturcutre is broken up. You go from a single loop to a bunch of small loops. This can have an effect on the overall performance. Users should also be judicious on choosing Fields. Only select Fields as a place to introduce variability in your models or for reuse. For example, if you require density in a single place in the code and there is only one single model that won't change, do not make it a field. Just evaluate it once where needed. But if you need density in multiple providers or you want to swap models at runtime, then it should be a field. This prevents having to recompute the model or recompile your code to switch models. This is usually not an issue as long as the amount of work in each evaluator is larger than vtable lookup to make the evaluate call. In our experience, we have never observed this behaviour. We point it our here just in case.

  • Slow compilation times: As the number of Evaluators in a code grows, the compilation times can become very long. Making even a minor change can result in the code recompiling all Evaluator code. Therefore, we recommend using explicit template instantiation. An example can be found in Trilinos/packages/phalanx/example/FEM_Nonlinear. All evaluators use explicit template instantiation if phalanx is built with explicit template instation enabled (in the cmake build system, use the flag -D Phalanx__EXPLICIT_TEMPLATE_INSTANTIATION=ON).

Multi-Dimensional Array Domain Model

The multidimensional array was designed for interoperability between a number of Trilinos packages including shards, phalanx and intrepid. These codes each have their own implementations but follow a basic set of requirements so that functions templated on the array type can use any of the multidimensional array implementations. The required functions are:

  • ScalarT& operator[] - the bracket operator
  • ScalarT& operator(1,2,3,...,N) - accessor operators for each rank N array.
  • size_type rank() - integer number of ordinates
  • size_type dimension(size_type ordinate) - size of ordinate
  • size_type size() - total size of array

Phalanx implements the multidimensional array in the PHX::MDField class and supports arrays with up to 8 ranks (one more than Fortran arrays support). More information can be found in the shards library.

Step 1: Configuring, Building, and installing Phalanx

A. General Library Requirements

Phalanx is distributed as a package in the Trilinos Framework. It can be enabled as part of a trilinos build with the configure option "-D Trilinos_ENABLE_Phalanx=ON". Phalanx currently has direct dependencies on the following third party libraries:

B. Performance Example Requirements

  • Optional: Some performance tests run comparisons against TVMET: Tiny Vector Matrix library using Expression Templates. This is to get a feel for how our "dumb" vector matrix objects perform compared to expression templates. You must enable the tvmet TPL add the path to the TVMET library during Trilinos configuration. An example configuration file can be found in Trilinos/packages/phalanx/build_scripts/build_phalanx_gcc.sh.

TVMET is optional and hidden behind an ifdef. The performance tests will be built regardless of whether tvmet is enabled/disabled.

C. Nonlinear Finite Element Example Requirements

To build the example problem in "phalanx/example/FEM_Nonlinear", distributed vector, distributed sparse matrix, and corresponding linear solvers are required. The following Trilinos packages need to be enabled to build the FEM_Nonlinear example:

  • Requires: the Epetra Library, supplies the linear algebra data structures for spares matrices. Can be enabled during the Trilinos configure with the flag "-D Trilinos_ENABLE_Epetra=ON".
  • Requires: the Ifpack Library, supplies incomplete factorization preconditioners. Can be enabled during the Trilinos configure with the flag "-D Trilinos_ENABLE_Ifpack=ON".
  • Requires: the Belos Library, supplies block GMRES iterative linear solver. Can be enabled during the Trilinos configure with the flag "-D Trilinos_ENABLE_Belos=ON".

This example will be disabled if the above packages are not enabled.

D. Configure Trilinos/Phalanx

The general instructions for building trilinos can be found at Trilinos Documentation Page. Of particular importance are the Overview, User Guide, and Tutorial documents. At a minimum you must enable the Teuchos, Sacado, and Phalanx packages. An example configure script is:

Once configure is run, build and install the library with the command:

make install

Step 2: Determine Types

Users must next determine the evaluation types and data types they will require in their simulation. Please see the section Phalanx Domain Model for detailed explanation of types. Following the example in the phalanx/example/EnergyFlux directory, we will be requiring two evaluation types, one for the residual evaluation of the discretized PDE equation and one for the corresponding Jacobian. Additional evaluation types might be for the parameter sensitivites and uncertainty quantification.

Once the evaluation types are chosen, users must decide on a default scalar type and on all data types that are valid for each evaluation type. The data types should all be templated on the default scalar type for the particular evaluation type, but this is not a requirement (expert users can violate this for performance reasons). Uses must implement their own data types or get them from a separate library. For sensitivities, the trilinos package Sacado should be used. For uncertainty quantification, the Trilinos package Stokhos should be used.

In our example, the user has written an implementation of vector (MyVector) and matrix (MyTensor) classes found in the file AlgebraicTypes.hpp. They are templated on a scalar type and can be used for all evaluation types.

  • Residual - Default scalar type will be "double". The data types will be:
    • double
    • MyVector<double>
    • MyTensor<double>
  • Jacobian - Default scalar type will be "Sacado::Fad::DFad<double>". This scalar type will carry both the residual information as well as sensitivity information. The data types will be:
    • Sacado::Fad::DFad<double>
    • MyVector< Sacado::Fad::DFad<double> >
    • MyTensor< Sacado::Fad::DFad<double> >

Typical examples of algebraic types include vectors, matrices, or higher order tensor objects, but in reality can be any struct/class that the user desires. Remember to template the objects on the scalar type if possible. An example of a very inefficient Vector and Matrix implementation (operator overloading without expression templates) can be found in AlgebraicTypes.hpp.

Step 3: Write the Traits Object

The Traits object is a struct that defines the evaluation types, the data types for each evaluation type, the allocator type, and the user defined types that will be passed through evaluator calls. We will go through each of these defninitions.

The basic class should derive from the PHX::TraitsBase object.

The Traits struct must define each of the following typedef members of the struct:

  • EvalTypes - an mpl::vector of user defined evaluation types. Each evaluation type must have a typedef member called ScalarT that provides the default scalar type. This is used to automate the building of evaluators for each evaluation type using the EvaluatorFactory.
  • EvalToDataMap - an mpl::map. The key is an evaluation type and the value is an mpl::vector of valid data types for that particular evaluation type.
  • Allocator type - type that defines the allocator class to use to allocate the memory for data storage.
  • SetupData - A user defined type to be passed in to the postRegistrationSetup() call. Allows users to pass in arbitrary data to the evaluators during setup.
  • EvalData - A user defined type to be passed in to the evaluateFields() call. Allows users to pass in arbitrary data.
  • PreEvalData - A user defined type to be passed in to the preEvaluate() call. Allows users to pass in arbitrary data.
  • PostEvalData - A user defined type to be passed in to the postEvaluate() call. Allows users to pass in arbitrary data.

A. Basic Class

The basic outline of the traits struct is:

struct MyTraits : public PHX::TraitsBase {
.
.
.
};

Inside this struct we need to implement all the typedefs listed above. The example we will follow is in the file Traits.hpp in "phalanx/example/EnergyFlux" directory.

B. EvalTypes

First we need to know the evaluation types. Each evaluation type must include at least a typedef'd default scalar type argument as a public member called ScalarT. Here is the example code:

struct MyTraits : public PHX::TraitsBase {
// ******************************************************************
// *** Scalar Types
// ******************************************************************
// Scalar types we plan to use
typedef double RealType;
typedef Sacado::Fad::DFad<double> FadType;
// ******************************************************************
// *** Evaluation Types
// ******************************************************************
struct Residual { typedef RealType ScalarT; };
struct Jacobian { typedef FadType ScalarT; };
typedef Sacado::mpl::vector<Residual, Jacobian> EvalTypes;
.
.
.

The typedefs RealType and FadType are done only for convenience. They are not actually required but cut down on the typing. Only the EvalTypes typedef is required in the code above.

C. EvaltoDataMap

Next we need to link the data types to the evaluation type. Note that one could use the same data type in multiple evaluation types:

.
.
.
// Residual (default scalar type is RealType)
typedef Sacado::mpl::vector< RealType,
MyVector<RealType>,
MyTensor<RealType>
> ResidualDataTypes;
// Jacobian (default scalar type is Fad<double>)
typedef Sacado::mpl::vector< FadType,
MyVector<FadType>,
MyTensor<FadType>
> JacobianDataTypes;
.
.
.

D. Allocator

Define the Allocator type to use. Phalanx comes with two allocators, but the user can write their own allocator class if these aren't sufficient. The Phalanx allocator classes are:

  • PHX::NewAllocator: uses the C++ "new" command to allocate each field on the heap separately.
  • PHX::ContiguousAllocator: allocates a single contiguous block of memory on the heap for all fields regardless of the type. This allows us to fit a subset of elements into cache to speed up the evaluation.

Code using the NewAllocator is:

.
.
.
// ******************************************************************
// *** Allocator Type
// ******************************************************************
typedef PHX::NewAllocator Allocator;
.
.
.

E. EvalData,PreEvalData,PostEvalData

Users can pass their own data to the postRegistrationSetup(), evaluateFields(), preEvaluate() and postEvaluate() methods of the PHX::FiledManager class. In this example, the user passes in a struct that they have written called MyEvalData. This contains information about the cell workset. The user is not required to write their own object. They could just pass in a null pointer if they don't need auxiliary information passed into the routine. This is demonstrated in the SetupSetup, PreEvalData, and PostEvalData. A void* is set for the data member.

.
.
.
// ******************************************************************
// *** User Defined Object Passed in for Evaluation Method
// ******************************************************************
typedef void* SetupData;
typedef const MyEvalData& EvalData;
typedef void* PreEvalData;
typedef void* PostEvalData;
};

Step 4: Specialize the PHX::TypeString Object

For debugging information, Phalanx makes a forward declaration of the PHX::TypeString object. This must be specialized for each evaluation type and each data type so that if there is a run-time error, phalanx can report detailed information on the problem. We could have used the typeinfo from the stl, but the name() method is not demangled on every platform, so it can make debugging a challenge. The specialized classes can go into their own file or can be added to the traits file above depending on how you use the Traits class. During linking, if the compiler complains about multiple defninitions of your specialized traits classes, separate the traits implementation into their own .cpp file.

namespace PHX {
// ******************************************************************
// ******************************************************************
// Debug strings. Specialize the Evaluation and Data types for the
// TypeString object in the phalanx/src/Phalanx_TypeString.hpp file.
// ******************************************************************
// ******************************************************************
// Evaluation Types
template<> struct TypeString<MyTraits::Residual>
{ static const std::string value; };
template<> struct TypeString<MyTraits::Jacobian>
{ static const std::string value; };
const std::string TypeString<MyTraits::Residual>::value =
"Residual";
const std::string TypeString<MyTraits::Jacobian>::value =
"Jacobian";
// Data Types
template<> struct TypeString<double>
{ static const std::string value; };
template<> struct TypeString< MyVector<double> >
{ static const std::string value; };
template<> struct TypeString< MyTensor<double> >
{ static const std::string value; };
template<> struct TypeString< Sacado::Fad::DFad<double> >
{ static const std::string value; };
template<> struct TypeString< MyVector<Sacado::Fad::DFad<double> > >
{ static const std::string value; };
template<> struct TypeString< MyTensor<Sacado::Fad::DFad<double> > >
{ static const std::string value; };
const std::string TypeString<double>::value =
"double";
const std::string TypeString< MyVector<double> >::value =
"MyVector<double>";
const std::string TypeString< MyTensor<double> >::value =
"MyTensor<double>";
const std::string TypeString< Sacado::Fad::DFad<double> >::
value = "Sacado::Fad::DFad<double>";
const std::string TypeString< MyVector<Sacado::Fad::DFad<double> > >::
value = "Sacado::Fad::DFad< MyVector<double> >";
const std::string TypeString< MyTensor<Sacado::Fad::DFad<double> > >::
value = "Sacado::Fad::DFad< MyTensor<double> >";
}

Step 5: Write your Evaluators

Before Writing your evaluators, you must decide on how you plan to build the evaluators. In most cases you will want to build one Evaluator for each evaluation type. Phalanx provides an automated factory called the PHX::EvaluatorFactory that will build an evaluator for each evaluation type automatically, but this places a restriction on the constructor of all evaluators built this way. If you plan to use the automated builder, the constructor for the Evaluator must contain only one argument - a Teuchos::ParameterList. This paramter list must contain a key called "Type" with an integer value corresponding to the type of Evaluator object to build. The parameterlist can contain any other information the user requires for proper construction of the Evaluator. You are not restricted to using the automated factory for every Evalautor. You can selectively use the automated factory where convenient.

For each field, you will need an evaluator. Evaluators can evlauate multiple fields at the same time. You can derive from the base class PHX::Evaluator, or you can derive from class PHX::EvaluatorWithBaseImpl that has most of the methods already implemented so that the same support code is not replicted in each evaluator. We STRONGLY recommend deriving from the class PHX::EvaluatorWithBaseImpl.

An example for evaluating the density field is:

#ifndef PHX_EXAMPLE_VP_DENSITY_HPP
#define PHX_EXAMPLE_VP_DENSITY_HPP
#include "Phalanx_config.hpp"
#include "Phalanx_Evaluator_WithBaseImpl.hpp"
#include "Phalanx_Evaluator_Derived.hpp"
#include "Phalanx_Field.hpp"
template<typename EvalT, typename Traits>
class Density :
public PHX::EvaluatorDerived<EvalT, Traits> {
public:
Density(const Teuchos::ParameterList& p);
void postRegistrationSetup(typename Traits::SetupData d,
void evaluateFields(typename Traits::EvalData ud);
private:
typedef typename EvalT::ScalarT ScalarT;
double constant;
std::size_t data_layout_size;
};
#include "Evaluator_Density_Def.hpp"
#endif

Note that if you want to use the automated factory PHX::EvaluatorFactory to build an object of each evaluation type, you must derive from the PHX::EvaluatorDerived class as shown in the example above. This allows the variable manager to store a vector of base object pointers for each evaluation type in a single stl vector.

Also note that we pull the scalar type, ScalarT, out of the evaluation type.

The implementation is just as simple:

// **********************************************************************
template<typename EvalT, typename Traits> Density<EvalT, Traits>::
Density(const Teuchos::ParameterList& p) :
density("Density", p.get< Teuchos::RCP<PHX::DataLayout> >("Data Layout") ),
temp("Temperature", p.get< Teuchos::RCP<PHX::DataLayout> >("Data Layout") )
{
this->addEvaluatedField(density);
this->addDependentField(temp);
this->setName("Density");
}
// **********************************************************************
template<typename EvalT, typename Traits>
void Density<EvalT, Traits>::
postRegistrationSetup(typename Traits::SetupData d,
{
this->utils.setFieldData(density,vm);
this->utils.setFieldData(temp,vm);
data_layout_size = density.fieldTag().dataLayout().size();
}
// **********************************************************************
template<typename EvalT, typename Traits>
void Density<EvalT, Traits>::evaluateFields(typename Traits::EvalData d)
{
std::size_t size = d.num_cells * data_layout_size;
for (std::size_t i = 0; i < size; ++i)
density[i] = temp[i] * temp[i];
}

The constructor pulls out data from the parameter list to set the correct data layout. Additionally, it tells the FieldManager what fields it will evaluate and what fields it requires/depends on to perform the evaluation.

The postRegistrationSetup method gets pointers from the FieldManager to the array for storing data for each particular field.

Writing evaluators can be tedious. We have invested much time in minimizing the amount of code a user writes for a new evaluator. Our experience is that you can literally have hundreds of evaluators. So we have added macros to hide the boilerplate code in each evaluator. Not only does this streamline/condense the code, but it also hides much of the templating. So if your user base is uncomfortable with C++ templates, the macro definitions could be very helpful. The definitions are found in the file Phalanx_Evaluator_Macros.hpp. The same evaluator shown above is now implemented using the macro definitions:

Class declaration:

#ifndef PHX_EXAMPLE_VP_DENSITY_HPP
#define PHX_EXAMPLE_VP_DENSITY_HPP
#include "Phalanx_Evaluator_Macros.hpp"
#include "Phalanx_Field.hpp"
PHX_EVALUATOR_CLASS(Density)
double constant;
std::size_t data_layout_size;
PHX_EVALUATOR_CLASS_END
#include "Evaluator_Density_Def.hpp"
#endif

Class definition:

//**********************************************************************
PHX_EVALUATOR_CTOR(Density,p) :
density("Density", p.get< Teuchos::RCP<PHX::DataLayout> >("Data Layout") ),
temp("Temperature", p.get< Teuchos::RCP<PHX::DataLayout> >("Data Layout") )
{
this->addEvaluatedField(density);
this->addDependentField(temp);
this->setName("Density");
}
//**********************************************************************
PHX_POST_REGISTRATION_SETUP(Density,data,fm)
{
this->utils.setFieldData(density,fm);
this->utils.setFieldData(temp,fm);
data_layout_size = density.fieldTag().dataLayout().size();
}
//**********************************************************************
PHX_EVALUATE_FIELDS(Density,d)
{
std::size_t size = d.num_cells * data_layout_size;
for (std::size_t i = 0; i < size; ++i)
density[i] = temp[i] * temp[i];
}

The evaluators for the example problem in "phalanx/example/EnergyFlux" have been rewritten using the macro definitions and can be found in the directory "phalanx/test/Utilities/evaluators".

Finally, since writing even the above code contains much boilerplate, we have written a python script that will generate the above skeleton files for you. All you need provide is the class name and the filename. The script is called phalanx_create_evaluator.py and can be found in the "scripts" directory. A "make install" will place the script in the "bin" directory. To generate a skeleton for the above function, you would execute the following command at the prompt:

> ./phalanx_create_evaluator.py -c -n Density Evaluator_Density

Step 6: Implement the FieldManager in your code

Adding the FieldManager to your code is broken into steps. You must build each Evaluator for each field type, register the evaluators with the FieldManager, and then call the evaluate routines. Continuing from our example:

A. Building your Evaluators

Users can build their own Evaluators and register them with the FieldManager or they can use our automated factory, PHX::EvaluatorFactory to handle this for them. Normally, users will want to build an evaluator for each evaluation type. The factory makes this very easy. Additionally, you are not restricted to using the automated factory for every Evalautor. You can selectively use the automated factory where convenient. The next two sections describe how to build the evaluators.

A.1 Building and Registering Evaluators Manually.

To build an Evaluator manually, all you need to do is allocate the Evaluator on the heap using a reference counted smart pointer (Teuchos::RCP) to point ot the object. This will ensure proper memory management of the object. Here is an example of code to build a Density evaluator for each evaluation type and register it with the corresponding manager.

// Create a FieldManager
FieldManager<MyTraits> fm;
// Constructor requirements
RCP<ParameterList> p = rcp(new ParameterList);
p->set< RCP<DataLayout> >("Data Layout", qp);
// Residual
Teuchos::RCP< Density<MyTraits::Residual,MyTraits> > residual_density =
Teuchos::rcp(new Density<MyTraits::Residual,MyTriats>(p));
fm.registerEvaluator<MyTraits::Residual>(residual_density);
// Jacobian
Teuchos::RCP< Density<MyTraits::Jacobian,MyTraits> > jacobian_density =
Teuchos::rcp(new Density<MyTraits::Jacobian,MyTriats>(p));
fm.registerEvaluator<MyTraits::Residual>(jacobian_density);

As one can see, this becomes very tedious if there are many evaluation types. It is much better to use the automated factory to build one for each evalaution type. Where this method is useful is if you are in a class already templated on the evaluation type, and would like to build and register an evaluator in that peice of code.

A.2 Using the Automated Factory

Phalanx provides an automated builder PHX::EvaluatorFactory that will create an object of each evaluation type. The following requirements are placed on each and every Evaluator that a user writes if they plan to use the automated factory:

  1. The constructor of your Evaluator must take exactly one argument that is a Teuchos::ParamterList object. A Teuchos::ParameterList allows you to pass an arbitrary number of objects with arbitrary types.

  2. In the Teuchos::ParamterList, you must have one key called "Type" that is associated with an integer value that uniquely corresponds to an Evaluator object written by the user. This integer is defined in the users factory traits object described below.

  3. The Evaluator must derive from the PHX::EvaluatorDerived class as shown in the example above. This allows the variable manager to store a vector of base object pointers for each evaluation type in a single stl vector yet be able to return the derived class.

To build an PHX::EvaluatorFactory, you must provide a factory traits class that gives the factory a list of its evaluator types. An example of the factory traits class is the FactoryTraits object in the file FactoryTraits.hpp:

#ifndef EXAMPLE_FACTORY_TRAITS_HPP
#define EXAMPLE_FACTORY_TRAITS_HPP
// mpl (Meta Programming Library) templates
#include "Sacado_mpl_vector.hpp"
// User Defined Evaluator Types
#include "Evaluator_Constant.hpp"
#include "Evaluator_Density.hpp"
#include "Evaluator_EnergyFlux_Fourier.hpp"
#include "Evaluator_FEInterpolation.hpp"
#include "Evaluator_NonlinearSource.hpp"
#include "Sacado_mpl_placeholders.hpp"
using namespace Sacado::mpl::placeholders;
template<typename Traits>
struct MyFactoryTraits {
static const int id_constant = 0;
static const int id_density = 1;
static const int id_fourier = 2;
static const int id_feinterpolation = 3;
static const int id_nonlinearsource = 4;
typedef Sacado::mpl::vector< Constant<_,Traits>, // 0
Density<_,Traits>, // 1
Fourier<_,Traits>, // 2
FEInterpolation<_,Traits>, // 3
NonlinearSource<_,Traits> // 4
> EvaluatorTypes;
};
#endif

Since the factory is built at compile time, we need to link a run-time choice to the compile-time list of object types. Thus the user must provide the static const int identifiers that are unique for each type that can be constructed. Users can ignore the "_" argument in the mpl vector. This is a placeholder argument that allows us to iterate over and instert each evaluation type into the factory traits.

Now let's build the evaluators. The following code can be found in the Example.cpp file in the directory "phalanx/example/EnergyFlux". We create a ParameterList for each evaluator and call the factory constructor. Since we are using the factory, we need to specify the "Type" argument set to the integer of the corresponding Evaluator in the factory traits that we wish to build:

RCP<DataLayout> qp = rcp(new FlatLayout("QP", 4));
RCP<DataLayout> node = rcp(new FlatLayout("NODE", 4));
// Parser will build parameter list that determines the field
// evaluators to build
map<string, RCP<ParameterList> > evaluators_to_build;
{ // Temperature
RCP<ParameterList> p = rcp(new ParameterList);
int type = MyFactoryTraits<MyTraits>::id_constant;
p->set<int>("Type", type);
p->set<string>("Name", "Temperature");
p->set<double>("Value", 2.0);
p->set< RCP<DataLayout> >("Data Layout", node);
evaluators_to_build["DOF_Temperature"] = p;
}
{ // Density
RCP<ParameterList> p = rcp(new ParameterList);
int type = MyFactoryTraits<MyTraits>::id_density;
p->set<int>("Type", type);
p->set< RCP<DataLayout> >("Data Layout", qp);
evaluators_to_build["Density"] = p;
}
{ // Constant Thermal Conductivity
RCP<ParameterList> p = rcp(new ParameterList);
int type = MyFactoryTraits<MyTraits>::id_constant;
p->set<int>("Type", type);
p->set<string>("Name", "Thermal Conductivity");
p->set<double>("Value", 2.0);
p->set< RCP<DataLayout> >("Data Layout", qp);
evaluators_to_build["Thermal Conductivity"] = p;
}
{ // Nonlinear Source
RCP<ParameterList> p = rcp(new ParameterList);
int type = MyFactoryTraits<MyTraits>::id_nonlinearsource;
p->set<int>("Type", type);
p->set< RCP<DataLayout> >("Data Layout", qp);
evaluators_to_build["Nonlinear Source"] = p;
}
{ // Fourier Energy Flux
RCP<ParameterList> p = rcp(new ParameterList);
int type = MyFactoryTraits<MyTraits>::id_fourier;
p->set<int>("Type", type);
p->set< RCP<DataLayout> >("Data Layout", qp);
evaluators_to_build["Energy Flux"] = p;
}
{ // FE Interpolation
RCP<ParameterList> p = rcp(new ParameterList);
int type = MyFactoryTraits<MyTraits>::id_feinterpolation;
p->set<int>("Type", type);
p->set<string>("Node Variable Name", "Temperature");
p->set<string>("QP Variable Name", "Temperature");
p->set<string>("Gradient QP Variable Name", "Temperature Gradient");
p->set< RCP<DataLayout> >("Node Data Layout", node);
p->set< RCP<DataLayout> >("QP Data Layout", qp);
evaluators_to_build["FE Interpolation"] = p;
}
// Build Field Evaluators for each evaluation type
EvaluatorFactory<MyTraits,MyFactoryTraits<MyTraits> > factory;
RCP< vector< RCP<Evaluator_TemplateManager<MyTraits> > > >
evaluators;
evaluators = factory.buildEvaluators(evaluators_to_build);
// Create a FieldManager
FieldManager<MyTraits> fm;
// Register all Evaluators
registerEvaluators(evaluators, fm);

The map "evaluators_to_build" has a key of type "std::string". This key is irrelevant to the execution of the code. It is an identifer that can help users debug code or search for a specific provider in the list. What you put in the key is for your own use.

You are free to register evaluators until the time you call the method postRegistrationSetup() on the field manager. Once this is called, you can not register any more evaluators. You can make multiple registration calls to add more providers - there is no limit on the number of calls.

B. Request which Fields to Evaluate

You must tell the FieldManager which quantities it should evaluate. This step can occur before, after, or in-between the registration of Evaluators. You must request variables separately for each evaluation type. This is required since since data types can exist in multiple evaluation types.

// Request quantities to assemble RESIDUAL PDE operators
{
typedef MyTraits::Residual::ScalarT ResScalarT;
Tag< MyVector<ResScalarT> > energy_flux("Energy_Flux", qp);
fm.requireField<MyTraits::Residual>(energy_flux);
Tag<ResScalarT> source("Nonlinear Source", qp);
fm.requireField<MyTraits::Residual>(source);
}
// Request quantities to assemble JACOBIAN PDE operators
{
typedef MyTraits::Jacobian::ScalarT JacScalarT;
Tag< MyVector<JacScalarT> > energy_flux("Energy_Flux", qp);
fm.requireField<MyTraits::Jacobian>(energy_flux);
Tag<JacScalarT> source("Nonlinear Source", qp);
fm.requireField<MyTraits::Jacobian>(source);
}

You are free to request fields to evaluate until the time you call the method postRegistrationSetup() on the field manager. Once this is called, you can not request any more fields.

C. Call FieldManager::postRegistrationSetup()

Once the evaluators are registered with the FieldManager and it knows which field it needs to provide, call the postRegistrationSetup() method on the FieldManager. This method requires that the user specify the maximum number of cells for each evaluation - the workset size. This number should be selected so that all fields can fit in the cache of the processor if possible.

// Assume we have 102 cells on processor and can fit 20 cells in cache
const std::size_t num_local_cells = 102;
const std::size_t workset_size = 20;
fm.postRegistrationSetup(workset_size);

The postRegistrationSetup() method causes the following actions to take place in the FieldManager:

  1. Based on the requested fields in B. Request which Fields to Evaluate, the FieldManager will trace through the evaluators to determine which evaluators to call and the order in which they need to be called to achieve a consistent evaluation. Not all evaluators that are registered will be used. They will only be called to satisfy dependencies of the required fields.
  2. Once the dependency chain is known, we can pull together a flat list of all fields that will be used. Now the FieldManager will allocate memory to store all fields. It will use the Allocator object from the users traits class to accomplish this. By unifying the allocation into a single object, we can force all fields to be allocated in a single contiguous block of memory if desired.
  3. Once the memory for field data is allocated, we must set the pointer to that memory block inside each Field or MDField object in each evaluator. The FieldManager does this by calling the postRegistrationSetup() method on each evaluator that is required for the computation.

Note: you can no longer register evaluators or request fields to evaluate once postRegistrationSetup() method is called.

D. Setup Worksets

If the user plans to use worksets, these objects are typically passed in through the member of the evaluate call as defined in your traits class. In our example, we chose to pass a user defined class called a MyWorkset in to the evaluate call. Since we plan to use worksets, each object of MyWorkset contains information about the workset. Here is the MyWorkset implementation:

#ifndef PHX_EXAMPLE_MY_WORKSET_HPP
#define PHX_EXAMPLE_MY_WORKSET_HPP
#include "Phalanx_config.hpp" // for std::vector
#include "Cell.hpp"
struct MyWorkset {
std::size_t local_offset;
std::size_t num_cells;
std::vector<MyCell>::iterator begin;
std::vector<MyCell>::iterator end;
};
#endif

The user has written a MyCell class that contains data for each specific local cell. MyWorkset contains iterators to the beginning and end of the chunk of cells for this particular workset. The local_offset is the starting index into the local cell array. The num_cells is the number of cells in the workset. The MyWorkset objects are created one for each workset via the following code:

// Create Workset information: Cells and EvalData objects
std::vector<MyCell> cells(num_local_cells);
for (std::size_t i = 0; i < cells.size(); ++i)
cells[i].setLocalIndex(i);
std::vector<MyWorkset> worksets;
std::vector<MyCell>::iterator cell_it = cells.begin();
std::size_t count = 0;
MyWorkset w;
w.local_offset = cell_it->localIndex();
w.begin = cell_it;
for (; cell_it != cells.end(); ++cell_it) {
++count;
std::vector<MyCell>::iterator next = cell_it;
++next;
if ( count == workset_size || next == cells.end()) {
w.end = next;
w.num_cells = count;
worksets.push_back(w);
count = 0;
if (next != cells.end()) {
w.local_offset = next->localIndex();
w.begin = next;
}
}
}

Note that you do not have to use the workset idea. You could just pass in workset size equal to the number of local cells on the processor or you could use a workset size of one cell and wrap the evaluate call in a loop over the number of cells. Be aware that this can result in a possible performance hit.

E. Call evaluate()

Finally, users can call the evlauate routines and the pre/post evaluate routines if required.

fm.preEvaluate<MyTraits::Residual>(NULL);
// Process all local cells on processor by looping over worksets
for (std::size_t i = 0; i < worksets.size(); ++i) {
fm.evaluateFields<MyTraits::Residual>(worksets[i]);
// Use workset values
.
.
.
}
fm.postEvaluate<MyTraits::Residual>(NULL);

F. Accessing Data

Accessing field data is achieved as follows:

Field< MyVector<double> > ef("Energy_Flux", qp);
fm.getFieldData<MyVector<double>,MyTraits::Residual>(ef);

You do not need to use the Field objects to access field data. You can get the reference counted smart pointer to the data array directly by using the field tag:

RCP<DataLayout> qp = rcp(new FlatLayout("QP", 4));
PHX::FieldTag<double> s("Nonlinear Source", qp);
Teuchos::ArrayRCP<double> source_values;
fm.getFieldData<double,MyTraits::Residual>(s,source_values);
PHX::DagManager::printEvaluator
void printEvaluator(const PHX::Evaluator< Traits > &e, std::ostream &os) const
Helper function.
Definition: Phalanx_DAG_Manager_Def.hpp:390
PHX::MDFieldIterator::reference_type
PHX::MDFieldTypeTraits< typename MDField< T >::array_type >::return_type reference_type
Reference to an entry of the MDField.
Definition: Phalanx_MDField_Utilities.hpp:72
PHX::Evaluator::getName
virtual const std::string & getName() const =0
Returns the name/identifier of this provider.
PHX::EvalautorUnitTester::addAuxiliaryEvalautor
void addAuxiliaryEvalautor(const Teuchos::RCP< PHX::Evaluator< Traits >> &e)
Register an extra evaluator that is not tested but is used to provide intermediate quantities for tes...
Definition: Phalanx_Evaluator_UnitTester.hpp:82
PHX::EvaluatorWithBaseImpl::deleteDeviceEvaluator
virtual void deleteDeviceEvaluator(PHX::DeviceEvaluator< Traits > *e) const override
Call dtor and delete device memory. Only used for Device DAG support.
Definition: Phalanx_Evaluator_WithBaseImpl_Def.hpp:445
PHX::DataLayout::identifier
virtual std::string identifier() const =0
Unique name identifier that can be used for strict weak ordering in stl std::map keys.
PHX::TemplateManager::end
PHX::TemplateManager< TypeSeq, BaseT, ObjectT >::iterator end()
Return an iterator that points one past the last type object.
Definition: Phalanx_TemplateManager_Def.hpp:141
PHX::TemplateIterator::operator->
PHX::TemplateIterator< TypeSeq, BaseT, ObjectT >::pointer operator->() const
-> operator
Definition: Phalanx_TemplateIterator.hpp:97
PHX::KokkosViewFactory
Definition: Phalanx_KokkosViewFactory.hpp:15
PHX::Evaluator::evaluateFields
virtual void evaluateFields(typename Traits::EvalData d)=0
Evaluate all fields that the provider supplies.
PHX::TemplateIterator::operator++
TemplateIterator operator++(int)
Postfix ++.
Definition: Phalanx_TemplateIterator.hpp:108
PHX::FieldTag
Definition: Phalanx_FieldTag.hpp:58
PHX::ConstTemplateIterator::operator!=
bool operator!=(const ConstTemplateIterator &t) const
Not equal operator.
Definition: Phalanx_TemplateIterator.hpp:157
PHX::MDFieldIterator::operator++
MDFieldIterator< T > & operator++()
Increment the iterator. Efficient.
Definition: Phalanx_MDField_Utilities_Def.hpp:78
PHX::EvaluatorWithBaseImpl::evaluateFields
virtual void evaluateFields(typename Traits::EvalData d) override=0
Evaluate all fields that the provider supplies.
PHX::DagNode
DAG Node wrapper for graph algorithms (DFS and topological sort).
Definition: Phalanx_DAG_Node.hpp:17
PHX::DagManager::contributed_field_to_node_index_
std::unordered_map< std::string, std::unordered_set< int > > contributed_field_to_node_index_
Hash map of contributed field key to evaluator index.
Definition: Phalanx_DAG_Manager.hpp:237
PHX::DummyMemoryBinder
Dummy functor to satisfy binding to dummy field tags.
Definition: Phalanx_Evaluator_WithBaseImpl_Def.hpp:98
PHX::DevEvalWrapper
Kokkos functor that wraps a users evaluator functor (Decorator design pattern). This eliminates the u...
Definition: Phalanx_CreateDeviceEvaluator.hpp:35
PHX::RunDeviceDag
Definition: Phalanx_DAG_Manager_Def.hpp:453
PHX::FieldManager::writeGraphvizFile
void writeGraphvizFile(const std::string filename="graph.dot", bool writeEvaluatedFields=true, bool writeDependentFields=false, bool debugRegisteredEvaluators=false) const
Writes graphviz dot file for the evaluation type.
Definition: Phalanx_FieldManager_Def.hpp:421
PHX::DagManager::field_to_node_index_
std::unordered_map< std::string, int > field_to_node_index_
Hash map of field key to evaluator index.
Definition: Phalanx_DAG_Manager.hpp:233
PHX::ConstTemplateIterator::operator==
bool operator==(const ConstTemplateIterator &t) const
Equal operator.
Definition: Phalanx_TemplateIterator.hpp:152
PHX::MDFieldIterator::operator->
Ptr operator->() const
Syntactic wrapper to (*it). .
Definition: Phalanx_MDField_Utilities_Def.hpp:147
PHX::DagManager::sortAndOrderEvaluators
void sortAndOrderEvaluators()
Definition: Phalanx_DAG_Manager_Def.hpp:167
PHX::TemplateManager
Container class to manager template instantiations of a template class.
Definition: Phalanx_TemplateManager.hpp:92
PHX::FTComp
Functor for RCP<FieldTag> comparisons in stl std::map. This must follow strict weak ordering rules.
Definition: Phalanx_FieldTag_STL_Functors.hpp:55
PHX::Evaluator::postRegistrationSetup
virtual void postRegistrationSetup(typename Traits::SetupData d, PHX::FieldManager< Traits > &vm)=0
Allows providers to grab pointers to data arrays.
PHX::FieldManager::postRegistrationSetup
void postRegistrationSetup(typename Traits::SetupData d, const bool &buildDeviceDAG=false)
Builds DAG and allocates memory for all evaluation types.
Definition: Phalanx_FieldManager_Def.hpp:312
PHX::FieldManager::postRegistrationSetupForType
void postRegistrationSetupForType(typename Traits::SetupData d, const bool &buildDeviceDAG=false)
Builds DAG and allocates memory for a single evaluation type.
Definition: Phalanx_FieldManager_Def.hpp:302
PHX::EvalautorUnitTester::checkFloatValues4
void checkFloatValues4(const FieldType &gold_field, const typename FieldType::value_type &tolerance, bool &success, std::ostream &out)
Check the field values to a specified tolerance for a rank 4 MDField.
Definition: Phalanx_Evaluator_UnitTester.hpp:152
PHX::EvaluatorUtilities
Utilities to hide templating in concrete Evaluators.
Definition: Phalanx_Evaluator_Utilities.hpp:67
PHX::DimTag
Abstract base class for array dimension tags supplied to the Array template class.
Definition: Phalanx_DimTag.hpp:87
PHX::DagManager::device_evaluators_
Kokkos::View< PHX::DeviceEvaluatorPtr< Traits > *, PHX::Device > device_evaluators_
Contians pointers to DeviceEvaluators for Device DAG support.
Definition: Phalanx_DAG_Manager.hpp:277
PHX::ConstTemplateIterator::ConstTemplateIterator
ConstTemplateIterator(const PHX::TemplateManager< TypeSeq, BaseT, ObjectT > &m, typename std::vector< Teuchos::RCP< BaseT > >::const_iterator p)
Constructor.
Definition: Phalanx_TemplateIterator.hpp:143
PHX::remove_all_pointers
Definition: Phalanx_KokkosDeviceTypes.hpp:75
PHX::TemplateIterator
Definition: Phalanx_TemplateIterator.hpp:66
PHX::eval_scalar_types
Definition: Phalanx_Traits.hpp:56
PHX::EvaluationContainer::bindField
void bindField(const PHX::FieldTag &f, const PHX::any &a)
Bind the memory pointer for a field in all evaluators.
Definition: Phalanx_EvaluationContainer_Def.hpp:314
PHX::EvaluationContainer::setUnmanagedField
void setUnmanagedField(const PHX::FieldTag &f, const PHX::any &a)
Set the memory for an unmanaged field.
Definition: Phalanx_EvaluationContainer_Def.hpp:290
PHX::DagManager::getFieldTags
const std::vector< Teuchos::RCP< PHX::FieldTag > > & getFieldTags()
Definition: Phalanx_DAG_Manager_Def.hpp:754
PHX::DagManager
Class to generate the directed acyclic graph (DAG) for evaluation. Determined which Evaluators should...
Definition: Phalanx_DAG_Manager.hpp:76
PHX::EvaluatorWithBaseImpl::getName
virtual const std::string & getName() const override
Returns the name/identifier of this provider.
Definition: Phalanx_Evaluator_WithBaseImpl_Def.hpp:407
PHX::Evaluator::Evaluator
Evaluator()
Ctor.
Definition: Phalanx_Evaluator.hpp:78
PHX::Layout
Default DataLayout implementation that allows for runtime sizing.
Definition: Phalanx_DataLayout_DynamicLayout.hpp:56
PHX::KokkosDeviceSession
Definition: Phalanx_KokkosUtilities.hpp:15
PHX::FieldManager::aliasFieldForAllEvaluationTypes
void aliasFieldForAllEvaluationTypes(const PHX::FieldTag &aliasedField, const PHX::FieldTag &targetField)
Makes two fields point to (alias) the same memory for all evaluation types.
Definition: Phalanx_FieldManager_Def.hpp:220
PHX::DagManager::preEvaluate
void preEvaluate(typename Traits::PreEvalData d)
This routine is called before each residual/Jacobian fill.
Definition: Phalanx_DAG_Manager_Def.hpp:557
PHX::DagManager::sorting_called_
bool sorting_called_
Flag to tell the setup has been called.
Definition: Phalanx_DAG_Manager.hpp:261
PHX::DagManager::getEvaluatorsBindingField
std::vector< Teuchos::RCP< PHX::Evaluator< Traits > > > & getEvaluatorsBindingField(const PHX::FieldTag &ft)
Returns all evalautors that either evaluate or require the given field. This is used to bind memory f...
Definition: Phalanx_DAG_Manager_Def.hpp:860
PHX::EvalautorUnitTester::setEvalautorToTest
void setEvalautorToTest(const Teuchos::RCP< PHX::Evaluator< Traits >> &e)
Register the evaluator that will be unit tested.
Definition: Phalanx_Evaluator_UnitTester.hpp:65
PHX::Field
Definition: Phalanx_Evaluator_Utilities.hpp:55
PHX::DagManager::field_to_evaluators_binding_
std::unordered_map< std::string, std::vector< Teuchos::RCP< PHX::Evaluator< Traits > > > > field_to_evaluators_binding_
A map that returns all evalautors that bind the memory of a particular field. Key is unique field ide...
Definition: Phalanx_DAG_Manager.hpp:271
PHX::EvalautorUnitTester::testEvaluator
void testEvaluator(typename Traits::SetupData d, typename Traits::PreEvalData pre_eval_data, typename Traits::EvalData eval_data, typename Traits::PostEvalData post_eval_data)
begin
Definition: Phalanx_Evaluator_UnitTester.hpp:97
PHX::EvaluationContainer
Container that holds all data associated with an evaluation type.
Definition: Phalanx_EvaluationContainer.hpp:66
PHX::UnmanagedFieldDummy
Evalautor that performs no computations. Typically used to satisfy DAG dependencies for unmanaged fie...
Definition: Phalanx_Evaluator_UnmanagedFieldDummy.hpp:57
PHX::PrintDimension
Definition: Phalanx_Print_Utilities.hpp:53
PHX::EvalautorUnitTester::checkFloatValues1
void checkFloatValues1(const FieldType &gold_field, const typename FieldType::value_type &tolerance, bool &success, std::ostream &out)
Check the field values to a specified tolerance for a rank 1 MDField.
Definition: Phalanx_Evaluator_UnitTester.hpp:110
PHX::ConstTemplateIterator
Definition: Phalanx_TemplateIterator.hpp:138
PHX::EvaluatorWithBaseImpl::bindField
virtual void bindField(const PHX::FieldTag &ft, const PHX::any &f) override
Binds memory to a field. WARNING: this is a POWER-USER function. Only use this if you understand the ...
Definition: Phalanx_Evaluator_WithBaseImpl_Def.hpp:413
PHX::ConstTemplateIterator::operator*
const PHX::ConstTemplateIterator< TypeSeq, BaseT, ObjectT >::reference operator*() const
Dereference operator.
Definition: Phalanx_TemplateIterator.hpp:163
PHX::EvaluatorFactory::registerEvaluators
void registerEvaluators(const Teuchos::RCP< std::vector< Teuchos::RCP< PHX::Evaluator_TemplateManager< Traits > > > > &t, PHX::FieldManager< Traits > &fm)
Nonmember helper function for registering field evaluators for all scalar types that are built with t...
PHX::AliasField::evaluateFields
void evaluateFields(typename Traits::EvalData)
Evaluate all fields that the provider supplies.
Definition: Phalanx_Evaluator_AliasField.hpp:80
MDFieldKokkos
Definition: Phalanx_MDFieldToKokkos.hpp:11
PHX::DagManager::getDagNodes
const std::vector< PHX::DagNode< Traits > > & getDagNodes() const
Returns the internally registered nodes. Used for unit testing.
Definition: Phalanx_DAG_Manager_Def.hpp:775
PHX::KokkosDimensionType
Definition: Phalanx_MDField.hpp:74
PHX::Evaluator::contributedFields
virtual const std::vector< Teuchos::RCP< FieldTag > > & contributedFields() const =0
Returns vector of fields that contribute partially to the evaluation of a field. This allows users to...
PHX::DagManager::analyzeGraph
void analyzeGraph(double &speedup, double &parallelizability) const
Returns the speedup and parallelizability of the graph.
Definition: Phalanx_DAG_Manager_Def.hpp:824
PHX::AliasField::postRegistrationSetup
void postRegistrationSetup(typename Traits::SetupData, PHX::FieldManager< Traits > &)
Allows providers to grab pointers to data arrays.
Definition: Phalanx_Evaluator_AliasField.hpp:77
PHX::Evaluator::preEvaluate
virtual void preEvaluate(typename Traits::PreEvalData d)=0
This routine is called before each residual/Jacobian fill.
PHX::DagManager::postRegistrationSetup
void postRegistrationSetup(typename Traits::SetupData d, PHX::FieldManager< Traits > &vm, const bool &buildDeviceDAG)
Definition: Phalanx_DAG_Manager_Def.hpp:412
PHX::MDFieldIterator::idx
size_type idx() const
Get the index of the current value.
Definition: Phalanx_MDField_Utilities_Def.hpp:152
PHX::MDFieldTypeTraits
Definition: Phalanx_MDField_TypeTraits.hpp:11
PHX::circular_dag_exception
Definition: Phalanx_Exceptions.hpp:9
PHX::EvaluatorFactory
Definition: Phalanx_Evaluator_Factory.hpp:57
PHX::DimTag::name
virtual const char * name() const =0
Name of the tag, typically the name of the derived class.
PHX::MDALayout::identifier
virtual std::string identifier() const override
Unique name identifier that can be used for strict weak ordering in stl std::map keys.
Definition: Phalanx_DataLayout_MDALayout_Def.hpp:578
PHX::Tag
Typed Field Tag.
Definition: Phalanx_FieldTag_Tag.hpp:67
PHX::TemplateIterator::operator==
bool operator==(const TemplateIterator &t) const
Equal operator.
Definition: Phalanx_TemplateIterator.hpp:80
PHX::ConstTemplateIterator::operator++
ConstTemplateIterator & operator++()
Prefix ++.
Definition: Phalanx_TemplateIterator.hpp:174
PHX::EvalautorUnitTester::checkFloatValues5
void checkFloatValues5(const FieldType &gold_field, const typename FieldType::value_type &tolerance, bool &success, std::ostream &out)
Check the field values to a specified tolerance for a rank 5 MDField.
Definition: Phalanx_Evaluator_UnitTester.hpp:168
PHX::ConstTemplateIterator::operator++
ConstTemplateIterator operator++(int)
Postfix ++.
Definition: Phalanx_TemplateIterator.hpp:180
PHX::EvaluatorWithBaseImpl::postEvaluate
virtual void postEvaluate(typename Traits::PostEvalData d) override
This routine is called after each residual/Jacobian fill.
Definition: Phalanx_Evaluator_WithBaseImpl_Def.hpp:401
PHX::DevLayout
Definition: Phalanx_KokkosDeviceTypes.hpp:99
PHX::FieldManager::setUnmanagedField
void setUnmanagedField(PHX::MDField< DataT, Tag0, Tag1, Tag2, Tag3, Tag4, Tag5, Tag6, Tag7 > &f)
Allows the user to manage the memory allocation of a particular field and dynamically set/swap the me...
Definition: Phalanx_FieldManager_Def.hpp:170
PHX::TemplateIterator::rcp
Teuchos::RCP< BaseT > rcp() const
Returns a reference counted pointer object.
Definition: Phalanx_TemplateIterator.hpp:115
PHX::DagManager::build_device_dag_
bool build_device_dag_
If set to true, allocated DeviceEvaluators for Device DAG for evaluation.
Definition: Phalanx_DAG_Manager.hpp:274
PHX::EvaluatorWithBaseImpl::postRegistrationSetup
virtual void postRegistrationSetup(typename Traits::SetupData d, PHX::FieldManager< Traits > &vm) override
Allows providers to grab pointers to data arrays.
Definition: Phalanx_Evaluator_WithBaseImpl_Def.hpp:344
PHX::TraitsBase
Definition: Phalanx_Traits.hpp:54
PHX::DagManager::setDefaultGraphvizFilenameForErrors
void setDefaultGraphvizFilenameForErrors(const std::string &file_name)
Sets the default filename for graphiz file generation for DAG construction errors.
Definition: Phalanx_DAG_Manager_Def.hpp:151
PHX::MDField< DataT, void, void, void, void, void, void, void, void >
Definition: deprecated/Phalanx_MDField.hpp:341
PHX::TemplateManager::getAsBase
Teuchos::RCP< BaseT > getAsBase()
Get RCP to object corrensponding to ScalarT as BaseT.
Definition: Phalanx_TemplateManager_Def.hpp:84
PHX::DeviceEvaluator
Pure virtual interface for instantiating an evaluator on device.
Definition: Phalanx_DeviceEvaluator.hpp:10
PHX::missing_evaluator_exception
Definition: Phalanx_Exceptions.hpp:13
PHX::FieldManager::buildDagForType
void buildDagForType()
Definition: Phalanx_FieldManager_Def.hpp:485
PHX::DeviceEvaluatorPtr
Struct for holding evaluator pointers in a Kokkos::View.
Definition: Phalanx_DeviceEvaluator.hpp:28
PHX::DagManager::nodes_
std::vector< PHX::DagNode< Traits > > nodes_
Vector of all registered evaluators.
Definition: Phalanx_DAG_Manager.hpp:230
PHX::DagManager::registerEvaluator
void registerEvaluator(const Teuchos::RCP< PHX::Evaluator< Traits > > &p)
Registers an evaluator with the manager.
Definition: Phalanx_DAG_Manager_Def.hpp:104
PHX::DeviceEvaluator::evaluate
virtual KOKKOS_FUNCTION void evaluate(const member_type &team, typename Traits::EvalData d)=0
Performs the evaluation.
PHX::DagManager::allow_multiple_evaluators_for_same_field_
bool allow_multiple_evaluators_for_same_field_
Backwards compatibility option: set to true to disable a check that throws if multiple registered eva...
Definition: Phalanx_DAG_Manager.hpp:264
PHX::Evaluator::createDeviceEvaluator
virtual PHX::DeviceEvaluator< Traits > * createDeviceEvaluator() const =0
Returns a DeviceEvaluator object instantiated on the Device using malloc and placement new so that vt...
PHX::MDFieldIterator
Iterate over entries of an MDField<DataT>, a runtime MDField.
Definition: Phalanx_MDField_Utilities.hpp:67
PHX::FTPred
Predicate for searches of stl std::vector< RCP<FieldTag> > using find_if algorithm.
Definition: Phalanx_FieldTag_STL_Functors.hpp:65
PHX::TemplateIterator::operator!=
bool operator!=(const TemplateIterator &t) const
Not equal operator.
Definition: Phalanx_TemplateIterator.hpp:85
PHX::ConstTemplateIterator::rcp
Teuchos::RCP< BaseT > rcp() const
Returns a reference counted pointer object.
Definition: Phalanx_TemplateIterator.hpp:187
PHX::Evaluator::~Evaluator
virtual ~Evaluator()
Dtor.
Definition: Phalanx_Evaluator.hpp:81
PHX::EvalautorUnitTester::checkFloatValues2
void checkFloatValues2(const FieldType &gold_field, const typename FieldType::value_type &tolerance, bool &success, std::ostream &out)
Check the field values to a specified tolerance for a rank 2 MDField.
Definition: Phalanx_Evaluator_UnitTester.hpp:123
PHX::Field::get_static_view
KOKKOS_INLINE_FUNCTION array_type get_static_view()
Returns a static view of the underlying kokkos static view.
Definition: Phalanx_Field_Def.hpp:277
PHX::EvaluatorWithBaseImpl
Class that implements helper functions for the pure virtual PHX::Evaluator class.
Definition: Phalanx_Evaluator_WithBaseImpl.hpp:68
PHX::DagManager::evaluateFields
void evaluateFields(typename Traits::EvalData d)
Evaluate the required fields using data parallel evaluation on topological sort of tasks....
Definition: Phalanx_DAG_Manager_Def.hpp:431
PHX::MDFieldIterator::Ptr
Definition: Phalanx_MDField_Utilities_Def.hpp:53
PHX::Check_num_ctor_arguments_equal_to_num_template_arguments
Definition: Phalanx_DataLayout_MDALayout.hpp:56
PHX::AliasField
Evaluator to help set dependencies for aliased fields.
Definition: Phalanx_Evaluator_AliasField.hpp:59
PHX::EvalautorUnitTester::setDependentFieldValues
void setDependentFieldValues(FieldType &mdfield)
Set an unmanaged MDField that provides dependent field values for the evaluator to be tested against.
Definition: Phalanx_Evaluator_UnitTester.hpp:87
PHX::DagManager::graphviz_filename_for_errors_
std::string graphviz_filename_for_errors_
Use this name for graphviz file output for DAG construction errors.
Definition: Phalanx_DAG_Manager.hpp:253
PHX::EvaluatorWithBaseImpl::preEvaluate
virtual void preEvaluate(typename Traits::PreEvalData d) override
This routine is called before each residual/Jacobian fill.
Definition: Phalanx_Evaluator_WithBaseImpl_Def.hpp:395
PHX::EvaluationContainer::requireField
void requireField(const PHX::FieldTag &f)
Requests that the container must compute this field.
Definition: Phalanx_EvaluationContainer_Def.hpp:76
PHX::DagManager::postEvaluate
void postEvaluate(typename Traits::PostEvalData d)
This routine is called after each residual/Jacobian fill.
Definition: Phalanx_DAG_Manager_Def.hpp:566
PHX::DagManager::required_fields_
std::vector< Teuchos::RCP< PHX::FieldTag > > required_fields_
Fields required by the user.
Definition: Phalanx_DAG_Manager.hpp:223
PHX::TemplateManager::~TemplateManager
~TemplateManager()
Destructor.
Definition: Phalanx_TemplateManager_Def.hpp:58
PHX::EvaluationContainer_TemplateManager
Definition: Phalanx_EvaluationContainer_TemplateManager.hpp:57
PHX::Evaluator::rebuildDeviceEvaluator
virtual void rebuildDeviceEvaluator(PHX::DeviceEvaluator< Traits > *e) const =0
Call dtor and then call placement new on the memory to rebind data. Needed to rebind unmanaged fields...
PHX::Field::operator=
PHX::Field< DataT, Rank > & operator=(const Field< CopyDataT, Rank > &source)
For const/non-const compatibility.
Definition: Phalanx_Field_Def.hpp:149
PHX::EvaluationContainerBase
Definition: Phalanx_EvaluationContainer_Base.hpp:58
PHX::Evaluator::dependentFields
virtual const std::vector< Teuchos::RCP< FieldTag > > & dependentFields() const =0
Returns vector of fields needed to compute the evaluated fields.
PHX::Layout::identifier
virtual std::string identifier() const override
Unique name identifier that can be used for strict weak ordering in stl std::map keys.
Definition: Phalanx_DataLayout_DynamicLayout.cpp:103
PHX::MDField
Definition: deprecated/Phalanx_MDField.hpp:65
PHX::TemplateManager::getAsObject
Teuchos::RCP< typename Sacado::mpl::apply< ObjectT, ScalarT >::type > getAsObject()
Get RCP to object corrensponding to ScalarT as ObjectT<ScalarT>
Definition: Phalanx_TemplateManager_Def.hpp:103
PHX::TemplateManager::DefaultBuilderOp
The default builder class for building objects for each ScalarT.
Definition: Phalanx_TemplateManager.hpp:126
PHX::FieldManager::evaluateFieldsDeviceDag
void evaluateFieldsDeviceDag(const int &work_size, const int &team_size, const int &vector_size, typename Traits::EvalData d)
Evalaute fields using Device DAG capability where a single parallel_for evaluates the entire DAG.
Definition: Phalanx_FieldManager_Def.hpp:335
PHX::DagManager::requireField
void requireField(const PHX::FieldTag &v)
Require a variable to be evaluated.
Definition: Phalanx_DAG_Manager_Def.hpp:91
PHX::FieldTag::identifier
virtual const std::string identifier() const =0
Unique name identifier that can be used for strict weak ordering in stl std::map keys.
PHX::DagManager::print
void print(std::ostream &os) const
Printing.
Definition: Phalanx_DAG_Manager_Def.hpp:782
PHX::EvaluationContainer::setupCalled
bool setupCalled() const
Return true if the postRegistrationSetupMethod has been called.
Definition: Phalanx_EvaluationContainer_Def.hpp:339
PHX::EvaluationContainer_TemplateBuilder
Definition: Phalanx_EvaluationContainer_TemplateBuilder.hpp:53
PHX::DagManager::write_graphviz_file_on_error_
bool write_graphviz_file_on_error_
If set to true, will write graphviz file for DAG construction errors.
Definition: Phalanx_DAG_Manager.hpp:256
PHX::KokkosDimType
Definition: Phalanx_Field.hpp:66
PHX::FieldManager::aliasField
void aliasField(const PHX::FieldTag &aliasedField, const PHX::FieldTag &targetField)
Makes two fields point to (alias) the same memory for a specific evaluation type.
Definition: Phalanx_FieldManager_Def.hpp:233
PHX::TemplateManager::TemplateManager
TemplateManager()
Default constructor.
Definition: Phalanx_TemplateManager_Def.hpp:49
PHX::TemplateManager::iterator
TemplateIterator< TypeSeq, BaseT, ObjectT > iterator
Typedef for iterator.
Definition: Phalanx_TemplateManager.hpp:120
PHX::TemplateIterator::operator*
PHX::TemplateIterator< TypeSeq, BaseT, ObjectT >::reference operator*() const
Dereference operator.
Definition: Phalanx_TemplateIterator.hpp:91
PHX::FieldManager::getFieldTagsForSizing
const std::vector< Teuchos::RCP< PHX::FieldTag > > & getFieldTagsForSizing()
Definition: Phalanx_FieldManager_Def.hpp:494
PHX::EvaluatorWithBaseImpl::createDeviceEvaluator
virtual PHX::DeviceEvaluator< Traits > * createDeviceEvaluator() const override
Returns a DeviceEvaluator object instantiated on the Device using malloc and placement new so that vt...
Definition: Phalanx_Evaluator_WithBaseImpl_Def.hpp:423
PHX::EvalautorUnitTester::checkFloatValues3
void checkFloatValues3(const FieldType &gold_field, const typename FieldType::value_type &tolerance, bool &success, std::ostream &out)
Check the field values to a specified tolerance for a rank 3 MDField.
Definition: Phalanx_Evaluator_UnitTester.hpp:137
PHX::EvaluatorWithBaseImpl::evaluatedFields
virtual const std::vector< Teuchos::RCP< FieldTag > > & evaluatedFields() const override
Returns vector of fields that this object evaluates.
Definition: Phalanx_Evaluator_WithBaseImpl_Def.hpp:351
PHX::UFO
Unary Function Object (UFO) - helper class required for mpl::for_each<>.
Definition: Phalanx_Evaluator_Factory_UFO.hpp:60
PHX::Tag::identifier
const std::string identifier() const override
Unique name identifier that can be used for strict weak ordering in stl std::map keys.
Definition: Phalanx_FieldTag_Tag_Def.hpp:130
PHX::any
Definition: Phalanx_any.hpp:64
PHX::MDALayout
A concrete implementation of the DataLayout class for compile time checked multidimensional arrays.
Definition: Phalanx_DataLayout_MDALayout.hpp:71
PHX::MDFieldIterator::operator*
reference_type operator*() const
Syntactic wrapper to ref().
Definition: Phalanx_MDField_Utilities_Def.hpp:142
PHX::DimTag::to_index
virtual size_type to_index(size_type dimension, const std::string &label) const
Given a dimension and input strige produce an index.
Definition: Phalanx_DimTag.cpp:69
Intrepid2::is_mdfield
Definition: deprecated/Phalanx_MDField.hpp:523
PHX::disable_if
Definition: Phalanx_any.hpp:62
PHX::Evaluator::postEvaluate
virtual void postEvaluate(typename Traits::PostEvalData d)=0
This routine is called after each residual/Jacobian fill.
PHX::MDField::get_static_view
KOKKOS_FORCEINLINE_FUNCTION array_type get_static_view()
Returns a static view of the underlying kokkos static view.
Definition: Phalanx_MDField_Def.hpp:411
PHX::MDFieldIterator::size_type
PHX::MDField< T >::size_type size_type
Index type.
Definition: Phalanx_MDField_Utilities.hpp:74
PHX::TemplateManager::const_iterator
ConstTemplateIterator< TypeSeq, BaseT, ObjectT > const_iterator
Typedef for const_iterator.
Definition: Phalanx_TemplateManager.hpp:123
PHX::DLTagList
Definition: Phalanx_DataLayout_MDALayout.hpp:62
PHX::EvaluatorDerived
Definition: Phalanx_Evaluator_Derived.hpp:56
PHX::Evaluator::deleteDeviceEvaluator
virtual void deleteDeviceEvaluator(PHX::DeviceEvaluator< Traits > *e) const =0
Call dtor and delete device memory. Only used for Device DAG support.
PHX::DagManager::setWriteGraphvizFileOnError
void setWriteGraphvizFileOnError(bool write_file)
If set to true, a graphviz file will be written during for DAG construction errors.
Definition: Phalanx_DAG_Manager_Def.hpp:159
PHX::DagManager::fields_
std::vector< Teuchos::RCP< PHX::FieldTag > > fields_
All fields that are needed for the evaluation.
Definition: Phalanx_DAG_Manager.hpp:240
PHX::disable_if_c
Definition: Phalanx_any.hpp:54
PHX::EvaluationContainer::buildDag
void buildDag()
Definition: Phalanx_EvaluationContainer_Def.hpp:384
PHX::Evaluator
Definition: Phalanx_Evaluator.hpp:71
PHX::DagManager::getEvaluatorInternalOrdering
const std::vector< int > & getEvaluatorInternalOrdering() const
Returns the Topological sort ordering. Used for unit testing.
Definition: Phalanx_DAG_Manager_Def.hpp:769
PHX::TemplateManager::buildObjects
void buildObjects()
Build objects for each ScalarT using default builder.
Definition: Phalanx_TemplateManager_Def.hpp:74
PHX::EvaluatorWithBaseImpl::contributedFields
virtual const std::vector< Teuchos::RCP< FieldTag > > & contributedFields() const override
Returns vector of fields that contribute partially to the evaluation of a field. This allows users to...
Definition: Phalanx_Evaluator_WithBaseImpl_Def.hpp:357
PHX::DagManager::writeGraphvizDfsVisit
void writeGraphvizDfsVisit(PHX::DagNode< Traits > &node, std::vector< PHX::DagNode< Traits >> &nodes_copy, std::ostream &os, const bool writeEvaluatedFields, const bool writeDependentFields) const
Depth-first search algorithm specialized for writing graphviz output.
Definition: Phalanx_DAG_Manager_Def.hpp:645
PHX::TemplateManager::DefaultBuilderOp::build
Teuchos::RCP< BaseT > build() const
Returns a new rcp for an object of type ObjectT<ScalarT>
Definition: Phalanx_TemplateManager.hpp:130
PHX::TemplateManager::begin
PHX::TemplateManager< TypeSeq, BaseT, ObjectT >::iterator begin()
Return an iterator that points to the first type object.
Definition: Phalanx_TemplateManager_Def.hpp:123
PHX::FieldManager::evaluateFields
void evaluateFields(typename Traits::EvalData d)
Evalaute fields with a separate parallel_for for each node in the DAG.
Definition: Phalanx_FieldManager_Def.hpp:325
PHX::DeviceEvaluator::prepareForRecompute
virtual KOKKOS_FUNCTION void prepareForRecompute(const member_type &, typename Traits::EvalData)
Used to bind EvalData objects to functor.
Definition: Phalanx_DeviceEvaluator.hpp:19
PHX::ConstTemplateIterator::operator->
const PHX::ConstTemplateIterator< TypeSeq, BaseT, ObjectT >::pointer operator->() const
-> operator
Definition: Phalanx_TemplateIterator.hpp:169
PHX::Evaluator_TemplateBuilder
Definition: Phalanx_Evaluator_TemplateBuilder.hpp:56
PHX::Evaluator::evaluatedFields
virtual const std::vector< Teuchos::RCP< FieldTag > > & evaluatedFields() const =0
Returns vector of fields that this object evaluates.
PHX::MemoryBinder
Functor to bind unmanaged memory to a MDField or Field.
Definition: Phalanx_Evaluator_WithBaseImpl_Def.hpp:59
PHX::DagManager::evaluateFieldsDeviceDag
void evaluateFieldsDeviceDag(const int &work_size, const int &team_size, const int &vector_size, typename Traits::EvalData d)
Evaluate the required fields using data parallel evaluation on topological sort of tasks....
Definition: Phalanx_DAG_Manager_Def.hpp:484
PHX::MDFieldIterator::ref
reference_type ref() const
Get a reference to the current value.
Definition: Phalanx_MDField_Utilities_Def.hpp:124
PHX::Evaluator_TemplateManager
Definition: Phalanx_Evaluator_TemplateManager.hpp:57
PHX::bad_any_cast
Definition: Phalanx_any.hpp:235
PHX::EvalautorUnitTester
Utility that allows for unit testing of single evalautor.
Definition: Phalanx_Evaluator_UnitTester.hpp:58
PHX::MDFieldIterator::done
bool done() const
Returns whether the iterator has reached the end.
Definition: Phalanx_MDField_Utilities_Def.hpp:119
Kokkos::View
Definition: Phalanx_FieldManager.hpp:72
PHX::EvalautorUnitTester::checkFloatValues6
void checkFloatValues6(const FieldType &gold_field, const typename FieldType::value_type &tolerance, bool &success, std::ostream &out)
Check the field values to a specified tolerance for a rank 6 MDField.
Definition: Phalanx_Evaluator_UnitTester.hpp:185
PHX::FieldManager
Definition: Phalanx_DAG_Manager.hpp:71
PHX::FieldManager::begin
FieldManager::iterator begin()
Return iterator to first EvaluationContainer.
Definition: Phalanx_FieldManager_Def.hpp:402
PHX::TemplateIterator::TemplateIterator
TemplateIterator(PHX::TemplateManager< TypeSeq, BaseT, ObjectT > &m, typename std::vector< Teuchos::RCP< BaseT > >::iterator p)
Constructor.
Definition: Phalanx_TemplateIterator.hpp:71
PHX::DagManager::dfsVisit
void dfsVisit(PHX::DagNode< Traits > &node, int &time)
Depth-first search algorithm.
Definition: Phalanx_DAG_Manager_Def.hpp:270
PHX::MDFieldIterator::MDFieldIterator
MDFieldIterator(const PHX::MDField< T > &a)
User constructor.
Definition: Phalanx_MDField_Utilities_Def.hpp:66
PHX::TemplateIterator::operator++
TemplateIterator & operator++()
Prefix ++.
Definition: Phalanx_TemplateIterator.hpp:102
PHX::MDField::dimensions
KOKKOS_FORCEINLINE_FUNCTION void dimensions(std::vector< iType > &dims)
Definition: deprecated/Phalanx_MDField_Def.hpp:334
PHX::EvaluatorWithBaseImpl::dependentFields
virtual const std::vector< Teuchos::RCP< FieldTag > > & dependentFields() const override
Returns vector of fields needed to compute the evaluated fields.
Definition: Phalanx_Evaluator_WithBaseImpl_Def.hpp:363
PHX::DimTag::to_string
virtual std::string to_string(size_type dimension, size_type index) const
Given a dimension and index produce a string for output.
Definition: Phalanx_DimTag.cpp:60
PHX::SetExtentsImpl
Definition: Phalanx_DataLayout.hpp:56
PHX::FTPredRef
Predicate for searches of stl std::vector< RCP<FieldTag> > using find_if algorithm.
Definition: Phalanx_FieldTag_STL_Functors.hpp:78
PHX::KokkosViewFactoryFunctor
Definition: Phalanx_KokkosViewFactoryFunctor.hpp:14
PHX::Evaluator::bindField
virtual void bindField(const PHX::FieldTag &ft, const PHX::any &f)=0
Binds memory to a field. WARNING: this is a POWER-USER function. Only use this if you understand the ...
PHX::KokkosDimentionType
Definition: deprecated/Phalanx_MDField.hpp:71
PHX::EvaluatorWithBaseImpl::rebuildDeviceEvaluator
virtual void rebuildDeviceEvaluator(PHX::DeviceEvaluator< Traits > *e) const override
Call dtor and then call placement new on the memory to rebind data. Needed to rebind unmanaged fields...
Definition: Phalanx_Evaluator_WithBaseImpl_Def.hpp:436
PHX::DataLayout
A pure virtual class to provide size and rank information and a unique identifier for a fields.
Definition: Phalanx_DataLayout.hpp:94
PHX::multiple_evaluator_for_field_exception
Definition: Phalanx_Exceptions.hpp:17
PHX::UnmanagedFieldDummy::evaluateFields
void evaluateFields(typename Traits::EvalData) override
Evaluate all fields that the provider supplies.
Definition: Phalanx_Evaluator_UnmanagedFieldDummy.hpp:66
PHX::FieldManager::end
FieldManager::iterator end()
Return iterator to last EvaluationContainer.
Definition: Phalanx_FieldManager_Def.hpp:411
PHX::EvaluationContainer::getFieldTags
const std::vector< Teuchos::RCP< PHX::FieldTag > > & getFieldTags()
Definition: Phalanx_EvaluationContainer_Def.hpp:392
PHX::EvaluatorBase
Template Manager "Base" class object for all field evaluators.
Definition: Phalanx_Evaluator_Base.hpp:54