Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
Direct Execution Launch

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:

Arcane::String case_file_name = {};
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.

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>
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
using namespace Arcane;
void executeSample(const String& case_file)
{
// Create a standalone subdomain
// Arcane will automatically call finalization when the variable
// goes out of scope.
Arcane::ISubDomain* sd = launcher.subDomain();
// Get the trace class to display messages
Arcane::ITraceMng* tm = launcher.traceMng();
// Create an instance of the Mesh Reader.
// Create a mesh named 'Mesh1' from the file 'plancher.msh'.
// The format is automatically choosen from the extension
Arcane::IMesh* mesh = mrm.readMesh("AdditionalMesh", "plancher.msh", sd->parallelMng());
Int32 nb_cell = mesh->nbCell();
tm->info() << "NB_CELL=" << nb_cell;
// Loop over the cells and compute the center of each cell
Arcane::VariableNodeReal3& nodes_coordinates = mesh->nodesCoordinates();
ENUMERATE_ (Cell, icell, mesh->allCells()) {
Arcane::Cell cell = *icell;
Arcane::Real3 cell_center;
// Iteration over nodes of the cell
for (Node node : cell.nodes()) {
cell_center += nodes_coordinates[node];
}
cell_center /= cell.nbNode();
tm->info() << "Cell=" << cell.uniqueId() << " center=" << cell_center;
}
}
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/
int main(int argc, char* argv[])
{
String case_file;
auto func = [&] {
std::cout << "Sample: StandaloneSubDomain\n";
// Initialize Arcane
Arcane::CommandLineArguments cmd_line_args(&argc, &argv);
if (argc > 1)
case_file = argv[argc - 1];
executeSample(case_file);
};
}
/*---------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------*/