Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
ComponentItemVectorView.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/* ComponentItemVectorView.cc (C) 2000-2024 */
9/* */
10/* View over a vector of component entities. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/core/materials/ComponentItemVectorView.h"
15
16#include "arcane/utils/NotImplementedException.h"
17#include "arcane/utils/ArgumentException.h"
18
19#include "arcane/core/materials/IMeshMaterial.h"
20#include "arcane/core/materials/IMeshEnvironment.h"
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25namespace Arcane::Materials
26{
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
30
32material() const
33{
34 return static_cast<IMeshMaterial*>(component());
35}
36
37/*---------------------------------------------------------------------------*/
38/*---------------------------------------------------------------------------*/
39
41environment() const
42{
43 return static_cast<IMeshEnvironment*>(component());
44}
45
46/*---------------------------------------------------------------------------*/
47/*---------------------------------------------------------------------------*/
48
49/*---------------------------------------------------------------------------*/
50/*---------------------------------------------------------------------------*/
51
52ComponentItemVectorView ComponentItemVectorView::
53_subView(Integer begin, Integer size)
54{
55 Integer nb_total = nbItem();
56
57 // No elements, returns an empty array
58 if (nb_total == 0) {
59 return ComponentItemVectorView(m_component);
60 }
61
62 if (begin >= nb_total) {
63 // Start index greater than the number of elements.
64 ARCANE_THROW(ArgumentException, "Bad 'begin' value '{0}' total={1}", begin, nb_total);
65 }
66
67 ConstituentItemLocalIdListView mn = m_constituent_list_view._subView(begin, size);
68 ConstArrayView<MatVarIndex> mvs = _matvarIndexes().subView(begin, size);
69 ConstArrayView<Int32> ids = _internalLocalIds().subView(begin, size);
70
71 return { m_component, mvs, mn, ids };
72}
73
74/*---------------------------------------------------------------------------*/
75/*---------------------------------------------------------------------------*/
76
77MatItemVectorView MatItemVectorView::
78_subView(Integer begin, Integer size)
79{
80 return { component(), ComponentItemVectorView::_subView(begin, size) };
81}
82
83/*---------------------------------------------------------------------------*/
84/*---------------------------------------------------------------------------*/
85
86EnvItemVectorView EnvItemVectorView::
87_subView(Integer begin, Integer size)
88{
89 return { component(), ComponentItemVectorView::_subView(begin, size) };
90}
91
92/*---------------------------------------------------------------------------*/
93/*---------------------------------------------------------------------------*/
94
95} // End namespace Arcane::Materials
96
97/*---------------------------------------------------------------------------*/
98/*---------------------------------------------------------------------------*/
#define ARCANE_THROW(exception_class,...)
Macro for throwing an exception with formatting.
constexpr ConstArrayView< T > subView(Integer abegin, Integer asize) const noexcept
Sub-view (constant) starting from element abegin and containing asize elements.
View over a vector of entities of a component.
IMeshComponent * component() const
Associated component.
Integer nbItem() const
Number of entities in the view.
View over a vector of entities of an environment.
IMeshEnvironment * environment() const
Associated environment.
View over a vector of entities of a material.
IMeshMaterial * material() const
Associated material.
Always enables tracing in Arcane parts concerning materials.
Int32 Integer
Type representing an integer.