Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
ArcaneCaseMeshMasterService.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* ArcaneCaseMeshMasterService.h (C) 2000-2024 */
9/* */
10/* Arcane Service managing the dataset meshes. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
15#include "arcane/core/ICaseMeshMasterService.h"
16#include "arcane/core/IMainFactory.h"
17#include "arcane/core/ICaseMeshService.h"
18#include "arcane/core/MeshBuildInfo.h"
19#include "arcane/impl/ArcaneCaseMeshMasterService_axl.h"
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
24namespace Arcane
25{
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
30class ArcaneCaseMeshMasterService
32{
33 public:
34
35 explicit ArcaneCaseMeshMasterService(const ServiceBuildInfo& sbi)
37 , m_sub_domain(sbi.subDomain())
38 {}
39
40 private:
41
42 void createMeshes() override
43 {
44 if (m_is_created)
45 ARCANE_FATAL("Meshes have already been created");
46
47 Integer nb_mesh = options()->mesh.size();
48 info() << "Creating meshes from 'ArcaneCaseMeshMasterService' nb_mesh=" << nb_mesh;
49 Integer index = 0;
50 for (ICaseMeshService* s : options()->mesh) {
51 String name = String("Mesh") + String::fromNumber(index);
52 s->createMesh(name);
53 ++index;
54 }
55 m_is_created = true;
56 }
57
58 void allocateMeshes() override
59 {
60 if (m_is_allocated)
61 ARCANE_FATAL("Meshes have already been allocated");
62 if (!m_is_created)
63 ARCANE_FATAL("You need to call createMeshes() before allocateMeshes()");
64
65 for (ICaseMeshService* s : options()->mesh)
66 s->allocateMeshItems();
67 m_is_allocated = true;
68 }
69
70 void partitionMeshes() override
71 {
72 if (!m_is_allocated)
73 ARCANE_FATAL("Meshes have do be allocated before partitioning. call allocateMeshes() before");
74 for (ICaseMeshService* s : options()->mesh)
75 s->partitionMesh();
76 }
77
79 {
80 if (!m_is_allocated)
81 ARCANE_FATAL("Meshes are not allocated. call allocateMeshes() before");
82 for (ICaseMeshService* s : options()->mesh)
83 s->applyAdditionalOperations();
84 }
85
86 ICaseOptions* _options() override
87 {
88 return options()->caseOptions();
89 }
90
91 private:
92
93 ISubDomain* m_sub_domain;
94 bool m_is_created = false;
95 bool m_is_allocated = false;
96 UniqueArray<IPrimaryMesh*> m_meshes;
97};
98
99/*---------------------------------------------------------------------------*/
100/*---------------------------------------------------------------------------*/
101
102ARCANE_REGISTER_SERVICE_ARCANECASEMESHMASTERSERVICE(ArcaneCaseMeshMasterService,
104
105/*---------------------------------------------------------------------------*/
106/*---------------------------------------------------------------------------*/
107
108} // End namespace Arcane
109
110/*---------------------------------------------------------------------------*/
111/*---------------------------------------------------------------------------*/
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
This file contains the various service factories and macros for registering services.
CaseOptionsArcaneCaseMeshMasterService * options() const
Options du jeu de données du service.
ArcaneArcaneCaseMeshMasterServiceObject(const Arcane::ServiceBuildInfo &sbi)
Constructeur.
void partitionMeshes() override
Partitions the meshes.
void allocateMeshes() override
Creates the meshes.
void applyAdditionalOperationsOnMeshes() override
Applies any additional operations on the created mesh.
void createMeshes() override
Creates the meshes.
Interface of the service managing dataset meshes.
Interface for a list of data set options.
ISubDomain * subDomain() const
Access to the associated ISubDomain.
Structure containing the information to create a service.
TraceMessage info() const
Flow for an information message.
constexpr Integer size() const noexcept
Returns the size of the array.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.