Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
VariableUtilsInternal.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/* VariableUtilsInternal.cc (C) 2000-2024 */
9/* */
10/* Various utility functions for internal Arcane variables. */
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
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: Check the size
42 ArrayView<Real> var_values(true_data->view());
43 values.copy(var_values);
44 return false;
45}
46
47/*---------------------------------------------------------------------------*/
48/*---------------------------------------------------------------------------*/
49
55
56/*---------------------------------------------------------------------------*/
57/*---------------------------------------------------------------------------*/
58
61{
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
78
79/*---------------------------------------------------------------------------*/
80/*---------------------------------------------------------------------------*/
81
82} // namespace Arcane
83
84/*---------------------------------------------------------------------------*/
85/*---------------------------------------------------------------------------*/
Modifiable view of an array of type T.
void copy(const U &copy_array)
Copies the array copy_array into the instance.
Constant view of an array of type T.
Constant view on a contiguous memory region containing fixed-size elements.
Interface of a 1D array data item of type T.
Definition IData.h:300
Internal part of IData.
virtual INumericDataInternal * numericData()
Generic interface for numeric data (nullptr if the data is not numeric).
Interface of a data item.
Definition IData.h:34
virtual IDataInternal * _commonInternal()=0
Interface for an 'IData' of a numeric type.
Interface of a variable.
Definition IVariable.h:40
virtual IData * data()=0
Data associated with the variable.
static bool setFromFloat64Array(IVariable *v, ConstArrayView< double > values)
Copies the values values into the variable v.
static bool fillFloat64Array(IVariable *v, ArrayView< double > values)
Fills values with the variable's values.
static bool setFromMemoryBuffer(IVariable *v, ConstMemoryView values)
Copies the values values into the variable v.
static IDataInternal * getDataInternal(IVariable *v)
Returns the internal IData API associated with the variable v.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --