Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F94234273
test_grid_tools.hh
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Wed, Dec 4, 23:54
Size
2 KB
Mime Type
text/x-c++
Expires
Fri, Dec 6, 23:54 (1 d, 11 h)
Engine
blob
Format
Raw Data
Handle
22739915
Attached To
rAKA akantu
test_grid_tools.hh
View Options
/**
* Copyright (©) 2013-2023 EPFL (Ecole Polytechnique Fédérale de Lausanne)
* Laboratory (LSMS - Laboratoire de Simulation en Mécanique des Solides)
*
* This file is part of Akantu
*
* Akantu is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* Akantu is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Akantu. If not, see <http://www.gnu.org/licenses/>.
*/
#include <map>
#include "aka_common.hh"
#include "aka_types.hh"
#define TOLERANCE 1e-7
template
<
Int
dim
>
class
Point
{
public
:
Point
()
:
id
(
0
),
tol
(
TOLERANCE
)
{
for
(
Int
i
=
0
;
i
<
dim
;
++
i
)
pos
[
i
]
=
0.
;
}
Point
(
const
Point
&
pt
)
:
id
(
pt
.
id
),
tol
(
pt
.
tol
)
{
for
(
Int
i
=
0
;
i
<
dim
;
++
i
)
pos
[
i
]
=
pt
.
pos
[
i
];
}
Point
(
const
Vector
<
Real
>
&
pt
,
UInt
id
=
0
)
:
id
(
id
),
tol
(
TOLERANCE
)
{
for
(
Int
i
=
0
;
i
<
dim
;
++
i
)
pos
[
i
]
=
pt
(
i
);
}
bool
operator
==
(
const
Point
&
pt
)
const
{
for
(
Int
i
=
0
;
i
<
dim
;
++
i
)
{
// std::cout << i << " " << pos[i] << " " << pt.pos[i] << " " <<
// std::abs(pos[i] - pt.pos[i]);
if
(
std
::
abs
(
pos
[
i
]
-
pt
.
pos
[
i
])
>
tol
)
{
// std::cout << " " << false << std::endl;
return
false
;
}
// else
// std::cout << " " << true << std::endl;
}
return
true
;
}
bool
operator
<
(
const
Point
&
pt
)
const
{
UInt
i
=
0
,
j
=
0
;
for
(;
(
i
<
dim
)
&&
(
j
<
dim
);
i
++
,
j
++
)
{
if
(
pos
[
i
]
<
pt
.
pos
[
j
])
return
true
;
if
(
pt
.
pos
[
j
]
<
pos
[
i
])
return
false
;
}
return
(
i
==
dim
)
&&
(
j
!=
dim
);
}
bool
operator
!=
(
const
Point
&
pt
)
const
{
return
!
(
operator
==
(
pt
));
}
Real
&
operator
()(
UInt
d
)
{
return
pos
[
d
];
}
const
Real
&
operator
()(
UInt
d
)
const
{
return
pos
[
d
];
}
void
read
(
const
std
::
string
&
str
)
{
std
::
stringstream
sstr
(
str
);
for
(
Int
i
=
0
;
i
<
dim
;
++
i
)
sstr
>>
pos
[
i
];
}
void
write
(
std
::
ostream
&
ostr
)
const
{
for
(
Int
i
=
0
;
i
<
dim
;
++
i
)
{
if
(
i
!=
0
)
ostr
<<
" "
;
// ostr << std::setprecision(std::numeric_limits<Real>::digits) <<
// pos[i];
ostr
<<
std
::
setprecision
(
9
)
<<
pos
[
i
];
}
}
private
:
UInt
id
;
Real
pos
[
dim
];
double
tol
;
};
template
<
Int
dim
>
struct
neighbors_map_t
{
typedef
std
::
map
<
Point
<
dim
>
,
std
::
vector
<
Point
<
dim
>>>
type
;
};
template
<
Int
dim
>
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
stream
,
const
Point
<
dim
>
&
_this
)
{
_this
.
write
(
stream
);
return
stream
;
}
Event Timeline
Log In to Comment