TrioCFD 1.9.8
TrioCFD documentation
Loading...
Searching...
No Matches
IJK_ptr.h
1/****************************************************************************
2* Copyright (c) 2025, CEA
3* All rights reserved.
4*
5* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6* 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7* 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
8* 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
9*
10* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
11* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
12* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
13*
14*****************************************************************************/
15
16#ifndef IJK_ptr_included
17#define IJK_ptr_included
18
19#include <ConstIJK_ptr.h>
20
21// We can automaticaly cast an IJK_ptr to a constIJK_ptr but not reversed.
22template <typename _TYPE_, typename _TYPE_ARRAY_ >
23class IJK_ptr : public ConstIJK_ptr<_TYPE_, _TYPE_ARRAY_>
24{
25public:
26 IJK_ptr(IJK_Field_local_template<_TYPE_,_TYPE_ARRAY_>& field, int i, int j, int k): ConstIJK_ptr<_TYPE_, _TYPE_ARRAY_>(field, i, j, k)
27 {
28 }
29 /*! @brief Performs the assignment: field(i+i_offset,j,k) = val
30 *
31 */
32 void put_val(int i_offset, const _TYPE_ & val)
33 {
34 assert(this->i_ + i_offset >= this->i_min_ && this->i_ + i_offset < this->i_max_);
35 // cast en non const ok car on avait un IJK_Field non const au depart
36 const _TYPE_ *ptr = this->ptr_;
37 ((_TYPE_*)ptr)[i_offset] = val;
38 }
39 void put_val(int i_offset, const Simd_template<_TYPE_>& val)
40 {
41 assert(this->i_ + i_offset >= this->i_min_ && this->i_ + i_offset < this->i_max_);
42 const _TYPE_ *ptr = this->ptr_;
43 SimdPut((_TYPE_*)ptr + i_offset, val);
44 }
45};
46
47using IJK_float_ptr = IJK_ptr<float, ArrOfFloat>;
48using IJK_double_ptr = IJK_ptr<double, ArrOfDouble>;
49
50
51#endif
ConstIJK_ptr(const IJK_Field_local_template< _TYPE_, _TYPE_ARRAY_ > &field, int i, int j, int k)
builds a pointer to field(i,j,k);
: This class describes a scalar field in an ijk box without any parallel information.
void put_val(int i_offset, const Simd_template< _TYPE_ > &val)
Definition IJK_ptr.h:39
void put_val(int i_offset, const _TYPE_ &val)
Performs the assignment: field(i+i_offset,j,k) = val.
Definition IJK_ptr.h:32
IJK_ptr(IJK_Field_local_template< _TYPE_, _TYPE_ARRAY_ > &field, int i, int j, int k)
Definition IJK_ptr.h:26
This class provides a generic access to simd operations on x86, x86 AMD and ARM architectures.