-
Notifications
You must be signed in to change notification settings - Fork 247
Class Visibility and Exposure
Kratos framework is mainly divided into "Core" and "Application" layers. The "Core" layer will provide functionality while Interfaces, Wrappers, and other Cores will consume it.
In order provide access to its classes and functions correctly, there are some guidelines that you must follow while implementing components inside a Core.
In order to ease the resolution of visibility of your symbols, Kratos provides the KRATOS_API(<APPLICATION_NAME>)
which you can (and must) use when you are creating a source file containing the implementation of a class you intend to be usable outside the Core layer.
// custom_example.h
class KRATOS_API(CUSTOM_APP) CustomExample
{
CustomExample();
~CustomExample();
...
}
// custom_example.cpp
CustomExample::CustomExample()
{
...
}
CustomExample::~CustomExample()
{
...
}
We understand by exposure the degree of functionality that you intend to make public to other users to use, modify and extend your classes. We distinguish several scenarios which will govern how your classes must be implemented:
- Private classes
- Public classes with no templates
- Public classes with templates
- Final, No Specialized
- Final, Specialized
- Derivable, No Specialized
- Derivable, Specialized
We understand by private classes the ones that are not meant to be used outside the same compilation unit. You can do mostly anything you want:
- Must be split into source and header.
- No need to use
KRATOS_API
- Can freely use templates in any fashion.
Example:
// private_example.h
class PrivateExample
{
PrivateExample();
~PrivateExample();
...
}
// private_example.cpp
PrivateExample::PrivateExample()
{
...
}
PrivateExample::~PrivateExample()
{
...
}
We understand by public class the ones that are meant to be usable outside the same compilation unit. For example, a process or a utility.
- Must not contain templates.
- Must be split into source and header.
- Need to use
KRATOS_API
in the header only (se example) - Can be final or not.
Example:
// public_example.h
class KRATOS_API(PUBLIC_CLASS) PublicExample
{
PublicExample();
~PublicExample();
...
}
// public_example.cpp
PublicExample::PublicExample()
{
...
}
PublicExample::~PublicExample()
{
...
}
We understand by Public template classes the ones that are meant to be usable outside the same compilation unit and use templates.
Inside this category we will make several distinctions, mostly depending on how this classes are going to be instantiated and derived.
If your class is Final (impossible to derive) and No Specialized (you will do the same for all instance parameters)
- Must be split into source and header.
- Must be explicitly instantiated with all instances you intend to make public
- Need to use
KRATOS_API
in the header only (se example) - Must be marked with the
final
keyword to avoid confusion
Example:
// public_example.h
temaplte<class TData>
class final KRATOS_API(PUBLIC_CLASS) PublicExample
{
PublicExample();
~PublicExample();
...
}
// public_example.cpp
teamplate<class TData>
PublicExample<TData>::PublicExample()
{
...
}
teamplate<class TData>
PublicExample<TData>::~PublicExample()
{
...
}
// All types must be exposed here
template class PublicExample<int>
template class PublicExample<double>
We strongly suggest not to use this combination. Please consider if constexpr
instead.
If your class is non Final (derivable) and No Specialized (you will do the same for all instance parameters)
- Must be header only
- Must not use
KRATOS_API
in any case.
Example:
// public_example.h
temaplte<class TData>
class final PublicExample
{
PublicExample()
{
...
};
~PublicExample()
{
...
};
}
We strongly suggest not to use this combination. Please consider if constexpr
instead.
- Getting Kratos (Last compiled Release)
- Compiling Kratos
- Running an example from GiD
- Kratos input files and I/O
- Data management
- Solving strategies
- Manipulating solution values
- Multiphysics
- Video tutorials
- Style Guide
- Authorship of Kratos files
- Configure .gitignore
- How to configure clang-format
- How to use smart pointer in Kratos
- How to define adjoint elements and response functions
- Visibility and Exposure
- Namespaces and Static Classes
Kratos structure
Conventions
Solvers
Debugging, profiling and testing
- Compiling Kratos in debug mode
- Debugging Kratos using GDB
- Cross-debugging Kratos under Windows
- Debugging Kratos C++ under Windows
- Checking memory usage with Valgind
- Profiling Kratos with MAQAO
- Creating unitary tests
- Using ThreadSanitizer to detect OMP data race bugs
- Debugging Memory with ASAN
HOW TOs
- How to create applications
- Python Tutorials
- Kratos For Dummies (I)
- List of classes and variables accessible via python
- How to use Logger
- How to Create a New Application using cmake
- How to write a JSON configuration file
- How to Access DataBase
- How to use quaternions in Kratos
- How to do Mapping between nonmatching meshes
- How to use Clang-Tidy to automatically correct code
- How to use the Constitutive Law class
- How to use Serialization
- How to use GlobalPointerCommunicator
- How to use PointerMapCommunicator
- How to use the Geometry
- How to use processes for BCs
- How to use Parallel Utilities in futureproofing the code
- Porting to Pybind11 (LEGACY CODE)
- Porting to AMatrix
- How to use Cotire
- Applications: Python-modules
- How to run multiple cases using PyCOMPSs
- How to apply a function to a list of variables
- How to use Kratos Native sparse linear algebra
Utilities
Kratos API
Kratos Structural Mechanics API