Arcane  v3.14.10.0
Documentation utilisateur
Chargement...
Recherche...
Aucune correspondance
VariableUtilsInternal.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2024 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/* VariableUtilsInternal.cc (C) 2000-2024 */
9/* */
10/* Fonctions utilitaires diverses sur les variables internes à Arcane. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/core/internal/VariableUtilsInternal.h"
15
16#include "arcane/utils/ArrayView.h"
17#include "arcane/utils/MemoryView.h"
18
19#include "arcane/core/IVariable.h"
20#include "arcane/core/IData.h"
21#include "arcane/core/internal/IDataInternal.h"
22
23#include "arcane/accelerator/core/RunQueue.h"
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28namespace Arcane
29{
30
31/*---------------------------------------------------------------------------*/
32/*---------------------------------------------------------------------------*/
33
34bool VariableUtilsInternal::
35fillFloat64Array(IVariable* v, ArrayView<double> values)
36{
37 IData* var_data = v->data();
38 auto* true_data = dynamic_cast<IArrayDataT<double>*>(var_data);
39 if (!true_data)
40 return true;
41 // TODO: Vérifier la taille
42 ArrayView<Real> var_values(true_data->view());
43 values.copy(var_values);
44 return false;
45}
46
47/*---------------------------------------------------------------------------*/
48/*---------------------------------------------------------------------------*/
49
50bool VariableUtilsInternal::
51setFromFloat64Array(IVariable* v, ConstArrayView<double> values)
52{
53 return setFromMemoryBuffer(v, ConstMemoryView(values));
54}
55
56/*---------------------------------------------------------------------------*/
57/*---------------------------------------------------------------------------*/
58
59bool VariableUtilsInternal::
60setFromMemoryBuffer(IVariable* v, ConstMemoryView mem_view)
61{
62 INumericDataInternal* num_data = v->data()->_commonInternal()->numericData();
63 if (!num_data)
64 return true;
65 RunQueue queue;
66 impl::copyContiguousData(num_data, mem_view, queue);
67 return false;
68}
69
70/*---------------------------------------------------------------------------*/
71/*---------------------------------------------------------------------------*/
72
73IDataInternal* VariableUtilsInternal::
74getDataInternal(IVariable* v)
75{
76 return v->data()->_commonInternal();
77}
78
79/*---------------------------------------------------------------------------*/
80/*---------------------------------------------------------------------------*/
81
82} // namespace Arcane::VariableUtils
83
84/*---------------------------------------------------------------------------*/
85/*---------------------------------------------------------------------------*/
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-