NeoFOAM
WIP Prototype of a modern OpenFOAM core
Loading...
Searching...
No Matches
Namespaces | Classes | Concepts | Typedefs | Functions | Variables
NeoFOAM Namespace Reference

Namespaces

namespace  detail
 
namespace  dsl
 
namespace  finiteVolume
 
namespace  la
 
namespace  sundials
 
namespace  timeIntegration
 

Classes

class  ArgList
 
class  BaseClassData
 Represents the data for a base class. More...
 
class  BaseClassDocumentation
 Provides a mechanism for registering and retrieving documentation for base and derived classes. More...
 
class  BoundaryFields
 Represents the boundary fields for a computational domain. More...
 
class  BoundaryMesh
 Represents boundaries of an unstructured mesh. More...
 
class  Collection
 A type-erased interface collection types. More...
 
class  CollectionMixin
 A mixin class for collection of documents in a database to simplify the implementation of common operations. More...
 
class  CPUExecutor
 Executor for handling multicore CPU based parallelization. More...
 
class  Database
 
class  DerivedClassDocumentation
 Class representing the documentation for a derived class. More...
 
class  Dictionary
 A class representing a dictionary that stores key-value pairs. More...
 
class  DimensionMismatch
 Error for handling two containers of incompatible lengths. More...
 
class  Document
 A class representing a document in a database. More...
 
class  DomainField
 Represents the domain fields for a computational domain. More...
 
class  Error
 Base class for consistent error representation. More...
 
class  Field
 A class to contain the data and executors for a field and define some basic operations. More...
 
class  GPUExecutor
 Executor for GPU offloading. More...
 
class  NeoFOAMException
 Custom exception class for NeoFOAM. More...
 
struct  Parameters
 
struct  RegisterDocumentation
 Template struct for registering documentation of a base class. More...
 
class  RuntimeSelectionFactory
 A factory class for runtime selection of derived classes. More...
 
class  RuntimeSelectionFactory< Base, Parameters< Args... > >
 
class  SegmentedField
 Data structure that stores a segmented fields or a vector of vectors. More...
 
class  SegmentedFieldView
 A class representing a segment of indices. More...
 
class  SerialExecutor
 Reference executor for serial CPU execution. More...
 
class  Span
 
class  StencilDataBase
 A class that represents a stencil database. More...
 
struct  SumKernel
 
class  Time
 
class  TokenList
 A class representing a list of tokens. More...
 
class  UnstructuredMesh
 Represents an unstructured mesh in NeoFOAM. More...
 
class  Vector
 A class for the representation of a 3D Vector. More...
 

Concepts

concept  parallelForKernel
 
concept  parallelForFieldKernel
 

Typedefs

using DocumentValidator = std::function< bool(Dictionary)>
 A type alias for a function that validates a Dictionary object.
 
using Executor = std::variant< SerialExecutor, CPUExecutor, GPUExecutor >
 
using Input = std::variant< Dictionary, TokenList >
 
using label = int32_t
 
using localIdx = uint32_t
 
using globalIdx = uint64_t
 
using size_t = std::size_t
 
using mpi_label_t = int
 
typedef float scalar
 
using word = std::string
 
using labelField = NeoFOAM::Field< label >
 
using scalarField = NeoFOAM::Field< scalar >
 
using vectorField = NeoFOAM::Field< Vector >
 

Functions

template<typename Type >
void validateRegistration (const Type &obj, const std::string errorMessage)
 Validates that a field is registered in the database.
 
bool hasId (Dictionary doc)
 Checks if a Dictionary object has an "id" key.
 
const std::string & name (const NeoFOAM::Document &doc)
 Retrieves the name of a Document.
 
std::string & name (NeoFOAM::Document &doc)
 Retrieves the name of a Document.
 
std::string demangle (const char *mangledName)
 
template<typename T , typename Container , typename Key >
void logBadAnyCast (const std::bad_any_cast &e, const Key &key, const Container &data)
 
void logOutRange (const std::out_of_range &e, const std::string &key, const std::unordered_map< std::string, std::any > &data)
 
bool operator== (const Executor &lhs, const Executor &rhs)
 Checks if two executors are equal, i.e. they are of the same type.
 
bool operator!= (const Executor &lhs, const Executor &rhs)
 Checks if two executors are not equal, i.e. they are not of the same type.
 
template<class DataClass >
DataClass read (Input input)
 
template<typename Executor , parallelForKernel Kernel>
void parallelFor (const Executor &exec, std::pair< size_t, size_t > range, Kernel kernel, std::string name="parallelFor")
 
template<parallelForKernel Kernel>
void parallelFor (const NeoFOAM::Executor &exec, std::pair< size_t, size_t > range, Kernel kernel, std::string name="parallelFor")
 
template<typename Executor , typename ValueType , parallelForFieldKernel< ValueType > Kernel>
void parallelFor (const Executor &exec, Field< ValueType > &field, Kernel kernel, std::string name="parallelFor")
 
template<typename ValueType , parallelForFieldKernel< ValueType > Kernel>
void parallelFor (Field< ValueType > &field, Kernel kernel, std::string name="parallelFor")
 
template<typename Executor , typename Kernel , typename T >
void parallelReduce (const Executor &exec, std::pair< size_t, size_t > range, Kernel kernel, T &value)
 
template<typename Kernel , typename T >
void parallelReduce (const NeoFOAM::Executor &exec, std::pair< size_t, size_t > range, Kernel kernel, T &value)
 
template<typename Executor , typename ValueType , typename Kernel , typename T >
void parallelReduce (const Executor &exec, Field< ValueType > &field, Kernel kernel, T &value)
 
template<typename ValueType , typename Kernel , typename T >
void parallelReduce (Field< ValueType > &field, Kernel kernel, T &value)
 
template<typename Executor , typename Kernel >
void parallelScan (const Executor &exec, std::pair< size_t, size_t > range, Kernel kernel)
 
template<typename Kernel >
void parallelScan (const NeoFOAM::Executor &exec, std::pair< size_t, size_t > range, Kernel kernel)
 
template<typename Executor , typename Kernel , typename ReturnType >
void parallelScan (const Executor &exec, std::pair< size_t, size_t > range, Kernel kernel, ReturnType &returnValue)
 
template<typename Kernel , typename ReturnType >
void parallelScan (const NeoFOAM::Executor &exec, std::pair< size_t, size_t > range, Kernel kernel, ReturnType &returnValue)
 
KOKKOS_INLINE_FUNCTION Vector operator* (const scalar &sclr, Vector rhs)
 
KOKKOS_INLINE_FUNCTION Vector operator& (const Vector &lhs, Vector rhs)
 
KOKKOS_INLINE_FUNCTION scalar mag (const Vector &vec)
 
std::ostream & operator<< (std::ostream &out, const Vector &vec)
 
template<typename T >
Field< T > operator+ (Field< T > lhs, const Field< T > &rhs)
 Arithmetic add operator, addition of two fields.
 
template<typename T >
Field< T > operator- (Field< T > lhs, const Field< T > &rhs)
 Arithmetic subtraction operator, subtraction one field from another.
 
template<typename T , typename Inner >
void map (Field< T > &a, const Inner inner, std::pair< size_t, size_t > range={0, 0})
 Map a field using a specific executor.
 
template<typename ValueType >
void fill (Field< ValueType > &a, const std::type_identity_t< ValueType > value, std::pair< size_t, size_t > range={0, 0})
 Fill the field with a scalar value using a specific executor.
 
template<typename ValueType >
void setField (Field< ValueType > &a, const std::span< const std::type_identity_t< ValueType > > b, std::pair< size_t, size_t > range={0, 0})
 Set the field with a span of values using a specific executor.
 
template<typename ValueType >
void scalarMul (Field< ValueType > &a, const std::type_identity_t< ValueType > value)
 
template<typename ValueType >
void add (Field< ValueType > &a, const Field< std::type_identity_t< ValueType > > &b)
 
template<typename ValueType >
void sub (Field< ValueType > &a, const Field< std::type_identity_t< ValueType > > &b)
 
template<typename ValueType >
void mul (Field< ValueType > &a, const Field< std::type_identity_t< ValueType > > &b)
 
template<typename... Args>
auto spans (Args &... fields)
 
template<typename... Args>
auto copyToHosts (Args &... fields)
 
template<typename T >
bool equal (Field< T > &field, T value)
 
template<typename T >
bool equal (const Field< T > &field, const Field< T > &field2)
 
template<typename T >
bool equal (const Field< T > &field, std::span< T > span2)
 
template<typename T >
sum (const Field< T > &field)
 
template<>
scalar sum (const Field< scalar > &field)
 
template<typename IndexType >
IndexType segmentsFromIntervals (const Field< IndexType > &intervals, Field< IndexType > &offsets)
 Compute segment offsets from an input field corresponding to lengths by computing a prefix sum.
 
UnstructuredMesh createSingleCellMesh (const Executor exec)
 creates a mesh containing only a single cell @warn currently this is only a 2D mesh
 
UnstructuredMesh create1DUniformMesh (const Executor exec, const size_t nCells)
 A factory function for a 1D mesh.
 

Variables

constexpr scalar ROOTVSMALL = 1e-18
 

Typedef Documentation

◆ DocumentValidator

A type alias for a function that validates a Dictionary object.

This type alias represents a function that takes a Dictionary object as an argument and returns a boolean value indicating whether the Dictionary is valid or not.

Example usage:

DocumentValidator validator = [](Dictionary dict) -> bool {
// Validation logic here
return true; // or false based on validation
};
A class representing a dictionary that stores key-value pairs.
std::function< bool(Dictionary)> DocumentValidator
A type alias for a function that validates a Dictionary object.
Definition document.hpp:30

Definition at line 30 of file document.hpp.

◆ Executor

using NeoFOAM::Executor = typedef std::variant<SerialExecutor, CPUExecutor, GPUExecutor>

Definition at line 16 of file executor.hpp.

◆ globalIdx

using NeoFOAM::globalIdx = typedef uint64_t

Definition at line 16 of file label.hpp.

◆ Input

using NeoFOAM::Input = typedef std::variant<Dictionary, TokenList>

Definition at line 13 of file input.hpp.

◆ label

using NeoFOAM::label = typedef int32_t

Definition at line 13 of file label.hpp.

◆ labelField

Definition at line 13 of file fieldTypeDefs.hpp.

◆ localIdx

using NeoFOAM::localIdx = typedef uint32_t

Definition at line 14 of file label.hpp.

◆ mpi_label_t

using NeoFOAM::mpi_label_t = typedef int

Definition at line 18 of file label.hpp.

◆ scalar

typedef float NeoFOAM::scalar

Definition at line 11 of file scalar.hpp.

◆ scalarField

Definition at line 14 of file fieldTypeDefs.hpp.

◆ size_t

using NeoFOAM::size_t = typedef std::size_t

Definition at line 17 of file label.hpp.

◆ vectorField

Definition at line 15 of file fieldTypeDefs.hpp.

◆ word

using NeoFOAM::word = typedef std::string

Definition at line 15 of file time.hpp.

Function Documentation

◆ add()

template<typename ValueType >
void NeoFOAM::add ( Field< ValueType > &  a,
const Field< std::type_identity_t< ValueType > > &  b 
)

Definition at line 119 of file fieldFreeFunctions.hpp.

◆ copyToHosts()

template<typename... Args>
auto NeoFOAM::copyToHosts ( Args &...  fields)

Definition at line 150 of file fieldFreeFunctions.hpp.

◆ create1DUniformMesh()

UnstructuredMesh NeoFOAM::create1DUniformMesh ( const Executor  exec,
const size_t  nCells 
)

A factory function for a 1D mesh.

A 1D mesh in 3D space in which each cell has a left and a right face. The 1D mesh is aligned with the x coordinate of Cartesian coordinate system.

◆ createSingleCellMesh()

UnstructuredMesh NeoFOAM::createSingleCellMesh ( const Executor  exec)

creates a mesh containing only a single cell @warn currently this is only a 2D mesh

a 2D mesh in 3D space with left, right, top, bottom boundary faces with the centre at (0.5, 0.5, 0.0) left, top, right, bottom faces and four boundaries one left, right, top, bottom

◆ demangle()

std::string NeoFOAM::demangle ( const char *  mangledName)

◆ equal() [1/3]

template<typename T >
bool NeoFOAM::equal ( const Field< T > &  field,
const Field< T > &  field2 
)

Definition at line 171 of file fieldFreeFunctions.hpp.

◆ equal() [2/3]

template<typename T >
bool NeoFOAM::equal ( const Field< T > &  field,
std::span< T >  span2 
)

Definition at line 193 of file fieldFreeFunctions.hpp.

◆ equal() [3/3]

template<typename T >
bool NeoFOAM::equal ( Field< T > &  field,
value 
)

Definition at line 156 of file fieldFreeFunctions.hpp.

◆ fill()

template<typename ValueType >
void NeoFOAM::fill ( Field< ValueType > &  a,
const std::type_identity_t< ValueType >  value,
std::pair< size_t, size_t range = {0, 0} 
)

Fill the field with a scalar value using a specific executor.

Parameters
fieldThe field to fill.
valueThe scalar value to fill the field with.
rangeThe range to fill the field in. If not provided, the whole field is filled.

Definition at line 50 of file fieldFreeFunctions.hpp.

◆ hasId()

bool NeoFOAM::hasId ( Dictionary  doc)

Checks if a Dictionary object has an "id" key.

This function checks if the given Dictionary object has an "id" key.

Parameters
docThe Dictionary object to check.
Returns
true if the Dictionary has an "id" key, false otherwise.

◆ logBadAnyCast()

template<typename T , typename Container , typename Key >
void NeoFOAM::logBadAnyCast ( const std::bad_any_cast &  e,
const Key &  key,
const Container &  data 
)

Definition at line 19 of file demangle.hpp.

◆ logOutRange()

void NeoFOAM::logOutRange ( const std::out_of_range &  e,
const std::string &  key,
const std::unordered_map< std::string, std::any > &  data 
)

◆ mag()

KOKKOS_INLINE_FUNCTION scalar NeoFOAM::mag ( const Vector vec)

Definition at line 152 of file vector.hpp.

◆ map()

template<typename T , typename Inner >
void NeoFOAM::map ( Field< T > &  a,
const Inner  inner,
std::pair< size_t, size_t range = {0, 0} 
)

Map a field using a specific executor.

Parameters
aThe field to map.
innerThe function to apply to each element of the field.
rangeThe range to map the field in. If not provided, the whole field is mapped.

Definition at line 29 of file fieldFreeFunctions.hpp.

◆ mul()

template<typename ValueType >
void NeoFOAM::mul ( Field< ValueType > &  a,
const Field< std::type_identity_t< ValueType > > &  b 
)

Definition at line 136 of file fieldFreeFunctions.hpp.

◆ name() [1/2]

const std::string & NeoFOAM::name ( const NeoFOAM::Document doc)

Retrieves the name of a Document.

This function retrieves the name of the Document by looking up the "name" key in the Document's Dictionary object.

Parameters
docThe Document to retrieve the name from.
Returns
std::string The name of the Document.

◆ name() [2/2]

std::string & NeoFOAM::name ( NeoFOAM::Document doc)

Retrieves the name of a Document.

This function retrieves the name of the Document by looking up the "name" key in the Document's Dictionary object.

Parameters
docThe Document to retrieve the name from.
Returns
std::string The name of the Document.

◆ operator!=()

bool NeoFOAM::operator!= ( const Executor lhs,
const Executor rhs 
)
inline

Checks if two executors are not equal, i.e. they are not of the same type.

Parameters
lhsThe first executor.
rhsThe second executor.
Returns
True if the executors not are equal, false otherwise.

Definition at line 51 of file executor.hpp.

◆ operator&()

KOKKOS_INLINE_FUNCTION Vector NeoFOAM::operator& ( const Vector lhs,
Vector  rhs 
)

Definition at line 146 of file vector.hpp.

◆ operator*()

KOKKOS_INLINE_FUNCTION Vector NeoFOAM::operator* ( const scalar sclr,
Vector  rhs 
)

Definition at line 139 of file vector.hpp.

◆ operator+()

template<typename T >
Field< T > NeoFOAM::operator+ ( Field< T >  lhs,
const Field< T > &  rhs 
)

Arithmetic add operator, addition of two fields.

Parameters
lhsThe field to add with this field.
rhsThe field to add with this field.
Returns
The result of the addition.

Definition at line 438 of file field.hpp.

◆ operator-()

template<typename T >
Field< T > NeoFOAM::operator- ( Field< T >  lhs,
const Field< T > &  rhs 
)

Arithmetic subtraction operator, subtraction one field from another.

Parameters
lhsThe field to subtract from.
rhsThe field to subtract by.
Returns
The result of the subtraction.

Definition at line 451 of file field.hpp.

◆ operator<<()

std::ostream & NeoFOAM::operator<< ( std::ostream &  out,
const Vector vec 
)

◆ operator==()

bool NeoFOAM::operator== ( const Executor lhs,
const Executor rhs 
)
inline

Checks if two executors are equal, i.e. they are of the same type.

Parameters
lhsThe first executor.
rhsThe second executor.
Returns
True if the executors are equal, false otherwise.

Definition at line 24 of file executor.hpp.

◆ parallelFor() [1/4]

template<typename Executor , typename ValueType , parallelForFieldKernel< ValueType > Kernel>
void NeoFOAM::parallelFor ( const Executor exec,
Field< ValueType > &  field,
Kernel  kernel,
std::string  name = "parallelFor" 
)

Definition at line 74 of file parallelAlgorithms.hpp.

◆ parallelFor() [2/4]

template<typename Executor , parallelForKernel Kernel>
void NeoFOAM::parallelFor ( const Executor exec,
std::pair< size_t, size_t range,
Kernel  kernel,
std::string  name = "parallelFor" 
)

Definition at line 27 of file parallelAlgorithms.hpp.

◆ parallelFor() [3/4]

template<parallelForKernel Kernel>
void NeoFOAM::parallelFor ( const NeoFOAM::Executor exec,
std::pair< size_t, size_t range,
Kernel  kernel,
std::string  name = "parallelFor" 
)

Definition at line 55 of file parallelAlgorithms.hpp.

◆ parallelFor() [4/4]

template<typename ValueType , parallelForFieldKernel< ValueType > Kernel>
void NeoFOAM::parallelFor ( Field< ValueType > &  field,
Kernel  kernel,
std::string  name = "parallelFor" 
)

Definition at line 102 of file parallelAlgorithms.hpp.

◆ parallelReduce() [1/4]

template<typename Executor , typename ValueType , typename Kernel , typename T >
void NeoFOAM::parallelReduce ( const Executor exec,
Field< ValueType > &  field,
Kernel  kernel,
T &  value 
)

Definition at line 146 of file parallelAlgorithms.hpp.

◆ parallelReduce() [2/4]

template<typename Executor , typename Kernel , typename T >
void NeoFOAM::parallelReduce ( const Executor exec,
std::pair< size_t, size_t range,
Kernel  kernel,
T &  value 
)

Definition at line 108 of file parallelAlgorithms.hpp.

◆ parallelReduce() [3/4]

template<typename Kernel , typename T >
void NeoFOAM::parallelReduce ( const NeoFOAM::Executor exec,
std::pair< size_t, size_t range,
Kernel  kernel,
T &  value 
)

Definition at line 137 of file parallelAlgorithms.hpp.

◆ parallelReduce() [4/4]

template<typename ValueType , typename Kernel , typename T >
void NeoFOAM::parallelReduce ( Field< ValueType > &  field,
Kernel  kernel,
T &  value 
)

Definition at line 175 of file parallelAlgorithms.hpp.

◆ parallelScan() [1/4]

template<typename Executor , typename Kernel >
void NeoFOAM::parallelScan ( const Executor exec,
std::pair< size_t, size_t range,
Kernel  kernel 
)

Definition at line 183 of file parallelAlgorithms.hpp.

◆ parallelScan() [2/4]

template<typename Executor , typename Kernel , typename ReturnType >
void NeoFOAM::parallelScan ( const Executor exec,
std::pair< size_t, size_t range,
Kernel  kernel,
ReturnType &  returnValue 
)

Definition at line 199 of file parallelAlgorithms.hpp.

◆ parallelScan() [3/4]

template<typename Kernel >
void NeoFOAM::parallelScan ( const NeoFOAM::Executor exec,
std::pair< size_t, size_t range,
Kernel  kernel 
)

Definition at line 193 of file parallelAlgorithms.hpp.

◆ parallelScan() [4/4]

template<typename Kernel , typename ReturnType >
void NeoFOAM::parallelScan ( const NeoFOAM::Executor exec,
std::pair< size_t, size_t range,
Kernel  kernel,
ReturnType &  returnValue 
)

Definition at line 214 of file parallelAlgorithms.hpp.

◆ read()

template<class DataClass >
DataClass NeoFOAM::read ( Input  input)

Definition at line 16 of file input.hpp.

◆ scalarMul()

template<typename ValueType >
void NeoFOAM::scalarMul ( Field< ValueType > &  a,
const std::type_identity_t< ValueType >  value 
)

Definition at line 94 of file fieldFreeFunctions.hpp.

◆ segmentsFromIntervals()

template<typename IndexType >
IndexType NeoFOAM::segmentsFromIntervals ( const Field< IndexType > &  intervals,
Field< IndexType > &  offsets 
)

Compute segment offsets from an input field corresponding to lengths by computing a prefix sum.

The offsets are computed by a prefix sum of the input values. So, with given input of {1, 2, 3, 4, 5} the offsets are {0, 1, 3, 6, 10, 15}. Note that the length of offSpan must be length of valSpan + 1 and are all elements of offSpan are required to be zero

Parameters
[in]inThe values to compute the offsets from.
[in,out]offsetsThe field to store the resulting offsets in.

Definition at line 24 of file segmentedField.hpp.

◆ setField()

template<typename ValueType >
void NeoFOAM::setField ( Field< ValueType > &  a,
const std::span< const std::type_identity_t< ValueType > >  b,
std::pair< size_t, size_t range = {0, 0} 
)

Set the field with a span of values using a specific executor.

Parameters
aThe field to set.
bThe span of values to set the field with.
rangeThe range to set the field in. If not provided, the whole field is set.

Definition at line 76 of file fieldFreeFunctions.hpp.

◆ spans()

template<typename... Args>
auto NeoFOAM::spans ( Args &...  fields)

Definition at line 144 of file fieldFreeFunctions.hpp.

◆ sub()

template<typename ValueType >
void NeoFOAM::sub ( Field< ValueType > &  a,
const Field< std::type_identity_t< ValueType > > &  b 
)

Definition at line 128 of file fieldFreeFunctions.hpp.

◆ sum() [1/2]

template<>
scalar NeoFOAM::sum ( const Field< scalar > &  field)

Definition at line 67 of file sum.hpp.

◆ sum() [2/2]

template<typename T >
T NeoFOAM::sum ( const Field< T > &  field)

Definition at line 58 of file sum.hpp.

◆ validateRegistration()

template<typename Type >
void NeoFOAM::validateRegistration ( const Type &  obj,
const std::string  errorMessage 
)

Validates that a field is registered in the database.

Template Parameters
TypeThe type of the field.
Parameters
fieldThe field to validate.
Exceptions
std::runtime_errorif the field is not registered in the database.

Definition at line 119 of file database.hpp.

Variable Documentation

◆ ROOTVSMALL

constexpr scalar NeoFOAM::ROOTVSMALL = 1e-18
constexpr

Definition at line 14 of file scalar.hpp.