Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
ComponentItemInternal.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/* ComponentItemInternal.cc (C) 2000-2024 */
9/* */
10/* Internal part of a material or environment cell. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/core/materials/ComponentItemInternal.h"
15
16#include "arcane/utils/FixedArray.h"
17#include "arcane/utils/FatalErrorException.h"
18
19#include <mutex>
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
24namespace Arcane::Materials
25{
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
30/*!
31 * \brief Container for the null entity.
32 *
33 * This allows using ComponentItemSharedInfo::_nullInstance()
34 */
36{
37 public:
38
39 FixedArray<ConstituentItemIndex, 2> m_first_sub_constituent_item_id_list;
40 FixedArray<Int16, 2> m_component_id_list = { { -1, -1 } };
41 FixedArray<Int16, 2> m_nb_sub_constituent_item_list = {};
42 FixedArray<Int32, 2> m_global_item_local_id_list = { { NULL_ITEM_LOCAL_ID } };
43 FixedArray<ConstituentItemIndex, 2> m_super_component_item_local_id_list = {};
44 FixedArray<MatVarIndex, 2> m_var_index_list = { { MatVarIndex(-1, -1) } };
45};
46
47namespace
48{
49 NullComponentItemSharedInfoContainer global_null_component_item_shared_info_container;
50}
51
52/*---------------------------------------------------------------------------*/
53/*---------------------------------------------------------------------------*/
54
55ComponentItemSharedInfo ComponentItemSharedInfo::null_shared_info;
56ComponentItemSharedInfo* ComponentItemSharedInfo::null_shared_info_pointer = &ComponentItemSharedInfo::null_shared_info;
57namespace
58{
59 std::once_flag component_set_null_instance_once_flag;
60}
61
62/*---------------------------------------------------------------------------*/
63/*---------------------------------------------------------------------------*/
64
65void ComponentItemSharedInfo::
66_setNullInstance()
67{
68 auto init_func = []() {
69 ComponentItemSharedInfo* x = null_shared_info_pointer;
70 NullComponentItemSharedInfoContainer& c = global_null_component_item_shared_info_container;
71
72 x->m_storage_size = 0;
73 x->m_first_sub_constituent_item_id_data = c.m_first_sub_constituent_item_id_list.data() + 1;
74 x->m_super_component_item_local_id_data = c.m_super_component_item_local_id_list.data() + 1;
75 x->m_component_id_data = c.m_component_id_list.data() + 1;
76
77 x->m_nb_sub_constituent_item_data = c.m_nb_sub_constituent_item_list.data() + 1;
78 x->m_global_item_local_id_data = c.m_global_item_local_id_list.data() + 1;
79 x->m_var_index_data = c.m_var_index_list.data() + 1;
80 };
81 // Guarantees that this will be called only once and protects against concurrent calls.
82 std::call_once(component_set_null_instance_once_flag, init_func);
83}
84
85/*---------------------------------------------------------------------------*/
86/*---------------------------------------------------------------------------*/
87
88std::ostream&
89operator<<(std::ostream& o, const ConstituentItemIndex& id)
90{
91 o << id.localId();
92 return o;
93}
94
95/*---------------------------------------------------------------------------*/
96/*---------------------------------------------------------------------------*/
97
98void ConstituentItemLocalIdListView::
99_checkCoherency() const
100{
101 if (!m_component_shared_info)
102 ARCANE_FATAL("Null ComponentItemSharedInfo");
103}
104
105/*---------------------------------------------------------------------------*/
106/*---------------------------------------------------------------------------*/
107
108} // End namespace Arcane::Materials
109
110/*---------------------------------------------------------------------------*/
111/*---------------------------------------------------------------------------*/
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
Represents an index on material and environment variables.
Always enables tracing in Arcane parts concerning materials.