It is possible to use Arcane without going through the mechanisms that use modules and the time loop. This can be useful for very simple codes or utilities, but this mechanism is not recommended for large calculation codes because it does not automatically allow access to all of Arcane's features, such as load balancing, safeguards/recoveries, or modules (even if these mechanisms remain manually accessible).
There are two ways to launch standalone mode:
- the mode with accelerator support. In this mode, only the accelerator API and Arcane's utility classes are available. The page Standalone Accelerator Mode describes how to use this mode.
- the subdomain mode. This mode allows manual access to most of Arcane's features, such as meshing, parsing, or load balancing.
The two examples standalone_subdomain and standalone_accelerator show how to use these mechanisms.
The page Launching a Calculation explains how to provide the parameters to initialize Arcane.
Standalone Subdomain Mode
This mode allows manual control of most of Arcane's features, such as meshing and parsing. To use this mode, simply use the class method ArcaneLauncher::createStandaloneSubDomain() after initializing Arcane:
static void init(const CommandLineArguments &args)
Positions information from command-line arguments and initializes the launcher.
static StandaloneSubDomain createStandaloneSubDomain(const String &case_file_name)
Creates a standalone implementation to manage a subdomain.
Standalone implementation of a sub-domain.
Unicode character string.
It is possible to specify a filename for the dataset. In this case, if this file contains meshes, they will be automatically created when the subdomain is created.
The sub_domain instance must remain valid as long as you wish to use the subdomain. It is therefore preferable to define it in the code's main().
- Warning
- Only one call to ArcaneLauncher::createStandaloneSubDomain is allowed.
For example, the following code reads a mesh, displays the number of cells, calculates, and displays the coordinates of the cell centers.
#include "arcane/launcher/ArcaneLauncher.h"
#include "arcane/utils/ITraceMng.h"
#include "arcane/utils/FatalErrorException.h"
#include "arcane/utils/Real3.h"
#include "arcane/core/MeshReaderMng.h"
#include "arcane/core/IMesh.h"
#include "arcane/core/ISubDomain.h"
#include "arcane/core/IParallelMng.h"
#include "arcane/core/ItemGroup.h"
#include "arcane/core/VariableTypes.h"
#include "arcane/utils/Exception.h"
#include <iostream>
void executeSample(
const String& case_file)
{
Int32 nb_cell = mesh->
nbCell();
tm->
info() <<
"NB_CELL=" << nb_cell;
cell_center += nodes_coordinates[node];
}
tm->
info() <<
"Cell=" << cell.
uniqueId() <<
" center=" << cell_center;
}
}
int main(int argc, char* argv[])
{
auto func = [&] {
std::cout << "Sample: StandaloneSubDomain\n";
if (argc > 1)
case_file = argv[argc - 1];
executeSample(case_file);
};
}