svFSIplus
svFSI
utils.h
1
/* Copyright (c) Stanford University, The Regents of the University of California, and others.
2
*
3
* All Rights Reserved.
4
*
5
* See Copyright-SimVascular.txt for additional details.
6
*
7
* Permission is hereby granted, free of charge, to any person obtaining
8
* a copy of this software and associated documentation files (the
9
* "Software"), to deal in the Software without restriction, including
10
* without limitation the rights to use, copy, modify, merge, publish,
11
* distribute, sublicense, and/or sell copies of the Software, and to
12
* permit persons to whom the Software is furnished to do so, subject
13
* to the following conditions:
14
*
15
* The above copyright notice and this permission notice shall be included
16
* in all copies or substantial portions of the Software.
17
*
18
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
19
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
21
* PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
22
* OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
*/
30
31
#ifndef UTILS_H
32
#define UTILS_H
33
34
#include "Array.h"
35
36
namespace
utils {
37
38
class
stackType
39
{
40
public
:
41
/// Maximum length of the stack
42
int
maxN
= 0;
43
44
/// Current size of stack
45
int
n
= 0;
46
47
/// Values inside stack
48
Vector<int>
v
;
49
};
50
51
class
queueType
52
{
53
public
:
54
int
n = 0;
55
int
maxN = 0;
56
Vector<int>
v;
57
};
58
59
60
bool
btest(
int
value,
int
pos);
61
62
int
CountBits(
int
n);
63
64
double
cput();
65
66
Vector<double>
cross(
const
Array<double>& V);
67
68
bool
dequeue(
queueType
& que,
int
& iVal);
69
void
enqueue(
queueType
& que,
int
iVal);
70
71
int
ibclr(
int
value,
int
pos);
72
int
ibset(
int
value,
int
pos);
73
bool
is_zero(
double
value1,
double
value2=0.0);
74
75
double
mem_usage(
const
bool
print_usage=
false
,
const
std::string& prefix=
""
);
76
77
double
norm(
const
Vector<double>
& U);
78
double
norm(
const
Vector<double>
& U,
const
Vector<double>
& V);
79
double
norm(
const
Array<double>& U);
80
81
void
print_mem(
const
std::string& type,
const
std::string& prefix,
const
double
memory_in_use,
const
double
memory_returned);
82
void
print_stats(
const
std::string& type,
const
std::string& prefix,
const
int
allocated,
const
int
active);
83
84
bool
pull_stack(
stackType
& stk,
int
& iVal);
85
void
push_stack(
stackType
& stk,
int
iVal);
86
void
push_stack(
stackType
& stk, std::initializer_list<int> values);
87
88
int
sign(
double
value);
89
90
void
swap(
int
& value1,
int
& value2);
91
92
};
93
94
#endif
95
Vector< int >
utils::queueType
Definition:
utils.h:52
utils::stackType
Definition:
utils.h:39
utils::stackType::maxN
int maxN
Maximum length of the stack.
Definition:
utils.h:42
utils::stackType::n
int n
Current size of stack.
Definition:
utils.h:45
utils::stackType::v
Vector< int > v
Values inside stack.
Definition:
utils.h:48
Generated by
1.9.1