Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
MeshBlock.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/* MeshBlock.cc (C) 2000-2016 */
9/* */
10/* Block of a mesh. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/utils/ArgumentException.h"
15
16#include "arcane/core/IMesh.h"
17
18#include "arcane/materials/MeshBlock.h"
19#include "arcane/materials/IMeshMaterialMng.h"
20#include "arcane/materials/MatItemEnumerator.h"
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25namespace Arcane::Materials
26{
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
31MeshBlock::
32MeshBlock(IMeshMaterialMng* mm, Int32 block_id, const MeshBlockBuildInfo& info)
33: TraceAccessor(mm->traceMng())
34, m_material_mng(mm)
35, m_block_id(block_id)
36, m_name(info.name())
37, m_cells(info.cells())
38, m_environments(info.environments())
39{
40}
41
42/*---------------------------------------------------------------------------*/
43/*---------------------------------------------------------------------------*/
44
45void MeshBlock::
46build()
47{
48}
49
50/*---------------------------------------------------------------------------*/
51/*---------------------------------------------------------------------------*/
52
54view()
55{
56 return m_material_mng->view(m_cells);
57}
58
59/*---------------------------------------------------------------------------*/
60/*---------------------------------------------------------------------------*/
61
62/*!
63 * \brief Adds the environment \a env to the block.
64 *
65 * This can only be done during the initialization phase
66 * (before IMeshMaterialMng::endCreate() has been called).
67 */
68void MeshBlock::
69addEnvironment(IMeshEnvironment* env)
70{
71 if (m_environments.contains(env))
72 throw ArgumentException(A_FUNCINFO,
73 String::format("environment {0} already in block {1}",
74 env->name(), this->name()));
75 m_environments.add(env);
76}
77
78/*---------------------------------------------------------------------------*/
79/*---------------------------------------------------------------------------*/
80
81/*!
82 * \brief Removes the environment \a env from the block.
83 *
84 * This can only be done during the initialization phase
85 * (before IMeshMaterialMng::endCreate() has been called).
86 */
87void MeshBlock::
88removeEnvironment(IMeshEnvironment* env)
89{
90 Integer index = -1;
91 for (Integer i = 0, n = m_environments.size(); i < n; ++i)
92 if (m_environments[i] == env) {
93 index = i;
94 break;
95 }
96 if (index == (-1))
97 throw ArgumentException(A_FUNCINFO,
98 String::format("environment {0} not in block {1}",
99 env->name(), this->name()));
100 m_environments.remove(index);
101}
102
103/*---------------------------------------------------------------------------*/
104/*---------------------------------------------------------------------------*/
105
106} // namespace Arcane::Materials
107
108/*---------------------------------------------------------------------------*/
109/*---------------------------------------------------------------------------*/
virtual String name() const =0
Component name.
Interface for the material and environment manager of a mesh.
Brief: Information for the creation of a block.
Always enables tracing in Arcane parts concerning materials.
Int32 Integer
Type representing an integer.
std::int32_t Int32
Signed integer type of 32 bits.