Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Kirill Terekhov
INMOST
Commits
10d1e034
Commit
10d1e034
authored
Feb 18, 2021
by
Kirill Terekhov
Browse files
make all code compile with USE_FP64=OFF
parent
e65952a3
Changes
47
Hide whitespace changes
Inline
Side-by-side
Examples/ADFVDiscr/main.cpp
View file @
10d1e034
...
...
@@ -16,7 +16,7 @@ using namespace INMOST;
#define BARRIER
#endif
double
func
(
double
x
[
3
],
double
tmp
)
Storage
::
real
func
(
Storage
::
real
x
[
3
],
Storage
::
real
tmp
)
{
// return x[0] + 2 * x[1] + 3 * x[2];
return
sin
(
M_PI
*
x
[
0
])
*
sin
(
M_PI
*
x
[
1
])
*
sin
(
M_PI
*
x
[
2
]);
...
...
@@ -24,7 +24,7 @@ double func(double x[3], double tmp)
}
double
func_rhs
(
double
x
[
3
],
double
tmp
)
Storage
::
real
func_rhs
(
Storage
::
real
x
[
3
],
Storage
::
real
tmp
)
{
// return 0;
return
-
3
*
tmp
*
M_PI
*
M_PI
*
sin
(
M_PI
*
x
[
0
])
*
sin
(
M_PI
*
x
[
1
])
*
sin
(
M_PI
*
x
[
2
]);
...
...
@@ -46,7 +46,7 @@ int main(int argc,char ** argv)
TagRealArray
tag_BC
;
TagReal
phi_ref
;
Mesh
*
m
=
new
Mesh
();
// Create an empty mesh
double
ttt
=
Timer
();
Storage
::
real
ttt
=
Timer
();
bool
repartition
=
false
;
(
void
)
repartition
;
m
->
SetCommunicator
(
INMOST_MPI_COMM_WORLD
);
// Set the MPI communicator for the mesh
...
...
@@ -67,7 +67,7 @@ int main(int argc,char ** argv)
if
(
m
->
GetProcessorRank
()
==
0
)
std
::
cout
<<
"Processors: "
<<
m
->
GetProcessorsNumber
()
<<
std
::
endl
;
if
(
m
->
GetProcessorRank
()
==
0
)
std
::
cout
<<
"Load(MPI_File): "
<<
Timer
()
-
ttt
<<
std
::
endl
;
//~
double
ttt2 = Timer();
//~
Storage::real
ttt2 = Timer();
//~ Mesh t;
//~ t.SetCommunicator(INMOST_MPI_COMM_WORLD);
//~ t.SetParallelFileStrategy(0);
...
...
@@ -126,7 +126,7 @@ int main(int argc,char ** argv)
else
{
std
::
cout
<<
"Set boundary conditions"
<<
std
::
endl
;
double
x
[
3
];
Storage
::
real
x
[
3
];
tag_BC
=
m
->
CreateTag
(
"BOUNDARY_CONDITION"
,
DATA_REAL
,
FACE
,
FACE
,
3
);
for
(
Mesh
::
iteratorFace
face
=
m
->
BeginFace
();
face
!=
m
->
EndFace
();
++
face
)
if
(
face
->
Boundary
()
&&
!
(
face
->
GetStatus
()
==
Element
::
Ghost
)
)
...
...
@@ -148,7 +148,7 @@ int main(int argc,char ** argv)
{
std
::
cout
<<
"Set rhs"
<<
std
::
endl
;
tag_F
=
m
->
CreateTag
(
"FORCE"
,
DATA_REAL
,
CELL
,
NONE
,
1
);
// Create a new tag for external force
double
x
[
3
];
Storage
::
real
x
[
3
];
for
(
Mesh
::
iteratorCell
cell
=
m
->
BeginCell
();
cell
!=
m
->
EndCell
();
++
cell
)
// Loop over mesh cells
{
cell
->
Centroid
(
x
);
...
...
@@ -162,7 +162,7 @@ int main(int argc,char ** argv)
else
if
(
makerefsol
)
{
phi_ref
=
m
->
CreateTag
(
"REFRENCE_SOLUTION"
,
DATA_REAL
,
CELL
,
NONE
,
1
);
double
x
[
3
];
Storage
::
real
x
[
3
];
for
(
Mesh
::
iteratorCell
cell
=
m
->
BeginCell
();
cell
!=
m
->
EndCell
();
++
cell
)
{
cell
->
Centroid
(
x
);
...
...
@@ -218,7 +218,7 @@ int main(int argc,char ** argv)
{
variable
flux
;
//should be more efficient to define here to avoid multiple memory allocations if storage for variations should be expanded
rMatrix
x1
(
3
,
1
),
x2
(
3
,
1
),
xf
(
3
,
1
),
n
(
3
,
1
);
double
d1
,
d2
,
k1
,
k2
,
area
,
T
,
a
,
b
,
c
;
Storage
::
real
d1
,
d2
,
k1
,
k2
,
area
,
T
,
a
,
b
,
c
;
#if defined(USE_OMP)
#pragma omp for
#endif
...
...
@@ -328,12 +328,12 @@ int main(int argc,char ** argv)
if
(
phi_ref
.
isValid
()
)
{
Tag
error
=
m
->
CreateTag
(
"error"
,
DATA_REAL
,
CELL
,
NONE
,
1
);
double
err_C
=
0.0
,
err_L2
=
0.0
,
vol
=
0.0
;
Storage
::
real
err_C
=
0.0
,
err_L2
=
0.0
,
vol
=
0.0
;
#if defined(USE_OMP)
#pragma omp parallel
#endif
{
double
local_err_C
=
0
;
Storage
::
real
local_err_C
=
0
;
#if defined(USE_OMP)
#pragma omp for reduction(+:err_L2) reduction(+:vol)
#endif
...
...
@@ -342,11 +342,11 @@ int main(int argc,char ** argv)
Cell
cell
=
Cell
(
m
,
ComposeCellHandle
(
icell
));
if
(
cell
->
GetStatus
()
!=
Element
::
Ghost
)
{
double
old
=
phi
[
cell
];
double
exact
=
phi_ref
[
cell
];
double
res
=
Update
[
Phi
.
Index
(
cell
)];
double
sol
=
old
-
res
;
double
err
=
fabs
(
sol
-
exact
);
Storage
::
real
old
=
phi
[
cell
];
Storage
::
real
exact
=
phi_ref
[
cell
];
Storage
::
real
res
=
Update
[
Phi
.
Index
(
cell
)];
Storage
::
real
sol
=
old
-
res
;
Storage
::
real
err
=
fabs
(
sol
-
exact
);
if
(
err
>
local_err_C
)
local_err_C
=
err
;
err_L2
+=
err
*
err
*
cell
->
Volume
();
vol
+=
cell
->
Volume
();
...
...
Examples/ADMFD/elastic.cpp
View file @
10d1e034
...
...
@@ -43,7 +43,7 @@ static void SVD2Eigen(const Matrix<T> & U, Matrix<T> & S, Matrix<T> & V)
{
for
(
unsigned
i
=
0
;
i
<
V
.
Cols
();
++
i
)
{
double
dot
=
0.0
;
Storage
::
real
dot
=
0.0
;
for
(
unsigned
j
=
0
;
j
<
V
.
Rows
();
++
j
)
dot
+=
get_value
(
U
(
j
,
i
))
*
get_value
(
V
(
j
,
i
));
if
(
dot
<
0.0
)
...
...
@@ -74,8 +74,8 @@ class BlockRow
public:
BlockRow
(
unsigned
h
,
unsigned
w
)
:
height
(
h
),
width
(
w
)
{}
rMatrix
&
operator
[]
(
unsigned
col
)
{
return
GetAdd
(
col
);
}
double
&
operator
()
(
unsigned
i
,
unsigned
j
)
{
return
GetAdd
(
j
)(
i
%
height
,
j
%
width
);}
double
operator
()
(
unsigned
i
,
unsigned
j
)
const
Storage
::
real
&
operator
()
(
unsigned
i
,
unsigned
j
)
{
return
GetAdd
(
j
)(
i
%
height
,
j
%
width
);}
Storage
::
real
operator
()
(
unsigned
i
,
unsigned
j
)
const
{
std
::
map
<
unsigned
,
rMatrix
>::
const_iterator
s
=
entries
.
find
(
j
/
width
);
if
(
s
!=
entries
.
end
()
)
...
...
@@ -247,11 +247,11 @@ void KTensor(const real_array & Cv, rMatrix & K)
void
GetBC
(
const
real_array
&
bc
,
const
rMatrix
&
n
,
rMatrix
&
Ra
,
rMatrix
&
Rb
,
rMatrix
&
r
)
{
const
rMatrix
I
=
rMatrix
::
Unit
(
3
);
double
alpha_perp
,
alpha_parallel
,
beta_perp
,
beta_parallel
;
Storage
::
real
alpha_perp
,
alpha_parallel
,
beta_perp
,
beta_parallel
;
if
(
bc
.
size
()
==
6
)
{
double
alpha
,
beta
,
proj
;
Storage
::
real
alpha
,
beta
,
proj
;
alpha
=
bc
[
0
];
beta
=
bc
[
1
];
proj
=
bc
[
2
];
...
...
@@ -302,7 +302,7 @@ void PrintSV(const rMatrix & A)
void
PrintRS
(
const
rMatrix
&
A
)
{
double
sum
;
Storage
::
real
sum
;
std
::
cout
<<
"row sum:"
;
for
(
unsigned
i
=
0
;
i
<
A
.
Rows
();
++
i
)
{
...
...
@@ -403,7 +403,7 @@ int main(int argc,char ** argv)
std
::
cout
<<
"Edges "
<<
m
->
TotalNumberOf
(
EDGE
)
<<
std
::
endl
;
std
::
cout
<<
"Nodes "
<<
m
->
TotalNumberOf
(
NODE
)
<<
std
::
endl
;
const
double
vB
[]
=
const
Storage
::
real
vB
[]
=
{
1
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
1
,
...
...
@@ -415,7 +415,7 @@ int main(int argc,char ** argv)
0
,
0
,
0
,
1
,
0
,
0
,
0
,
0
,
1
,
0
,
0
,
0
};
const
double
viBtB
[]
=
const
Storage
::
real
viBtB
[]
=
{
1
,
0
,
0
,
0.0
,
0.0
,
0.0
,
0
,
1
,
0
,
0.0
,
0.0
,
0.0
,
...
...
@@ -442,7 +442,7 @@ int main(int argc,char ** argv)
// 0 -1 0 0 0 0 0 0 0
// 0 0 0 0 0 0 0 0 0
//
const
double
vCurl
[]
=
const
Storage
::
real
vCurl
[]
=
{
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
0
,
1
,
0
,
...
...
@@ -512,9 +512,9 @@ int main(int argc,char ** argv)
{
rMatrix
N
,
R
,
L
,
M
(
9
,
9
),
T
,
K
(
9
,
9
),
iK
(
9
,
9
),
C
(
6
,
6
),
Q
,
W1
,
W2
,
W3
,
W3s
,
U
,
S
,
V
,
w
,
u
,
v
;
rMatrix
x
(
3
,
1
),
xf
(
3
,
1
),
n
(
3
,
1
);
double
area
;
//area of the face
Storage
::
real
area
;
//area of the face
//double volume; //volume of the cell
double
dist
;
//distance from cell center to face
Storage
::
real
dist
;
//distance from cell center to face
#if defined(USE_OMP)
#pragma omp for
#endif
...
...
@@ -570,8 +570,8 @@ int main(int argc,char ** argv)
if
(
true
)
{
double
alpha
=
0
;
double
beta
=
alpha
;
Storage
::
real
alpha
=
0
;
Storage
::
real
beta
=
alpha
;
//M = B*iBtB*B.Transpose();
//R = R*(I9 + M)*0.5;
...
...
@@ -856,7 +856,7 @@ int main(int argc,char ** argv)
}
std
::
cout
<<
"Matrix was annotated"
<<
std
::
endl
;
double
condest
=
0
;
Storage
::
real
condest
=
0
;
do
{
R
.
Clear
();
//clean up the residual
...
...
@@ -938,7 +938,7 @@ int main(int argc,char ** argv)
ff
<<
" boundary"
;
ff
<<
std
::
endl
;
const
int
bs
=
3
;
std
::
vector
<
double
>
VR
(
3
);
std
::
vector
<
Storage
::
real
>
VR
(
3
);
BlockRow
BR
(
bs
,
bs
);
for
(
int
q
=
0
;
q
<
bs
;
++
q
)
...
...
Examples/DrawGrid/clipper.cpp
View file @
10d1e034
...
...
@@ -63,7 +63,7 @@ namespace INMOST
Storage
::
integer
clip_plane_edge
(
double
sp0
[
3
],
double
sp1
[
3
],
double
p
[
3
],
double
n
[
3
],
double
node
[
3
])
Storage
::
integer
clip_plane_edge
(
Storage
::
real
sp0
[
3
],
Storage
::
real
sp1
[
3
],
Storage
::
real
p
[
3
],
Storage
::
real
n
[
3
],
Storage
::
real
node
[
3
])
{
Storage
::
real
u
[
3
],
w
[
3
],
D
,
N
,
sI
;
u
[
0
]
=
sp1
[
0
]
-
sp0
[
0
];
u
[
1
]
=
sp1
[
1
]
-
sp0
[
1
];
u
[
2
]
=
sp1
[
2
]
-
sp0
[
2
];
...
...
@@ -188,7 +188,7 @@ namespace INMOST
kdtree
::
kdtree
()
:
set
(
NULL
),
marked
(
0
),
size
(
0
),
children
(
NULL
)
{}
inline
int
kdtree
::
plane_bbox
(
double
p
[
3
],
double
n
[
3
])
const
inline
int
kdtree
::
plane_bbox
(
Storage
::
real
p
[
3
],
Storage
::
real
n
[
3
])
const
{
Storage
::
real
pv
[
3
],
nv
[
3
];
for
(
int
k
=
0
;
k
<
3
;
++
k
)
...
...
@@ -214,7 +214,7 @@ namespace INMOST
else
return
0
;
}
bool
kdtree
::
sub_intersect_plane_edge
(
Tag
clip_point
,
Tag
clip_state
,
ElementArray
<
Cell
>
&
cells
,
MarkerType
mrk
,
double
p
[
3
],
double
n
[
3
])
bool
kdtree
::
sub_intersect_plane_edge
(
Tag
clip_point
,
Tag
clip_state
,
ElementArray
<
Cell
>
&
cells
,
MarkerType
mrk
,
Storage
::
real
p
[
3
],
Storage
::
real
n
[
3
])
{
if
(
size
==
1
)
{
...
...
@@ -244,7 +244,7 @@ namespace INMOST
return
marked
!=
0
;
}
void
kdtree
::
sub_intersect_plane_faces
(
Tag
clip_state
,
double
p
[
3
],
double
n
[
3
])
void
kdtree
::
sub_intersect_plane_faces
(
Tag
clip_state
,
Storage
::
real
p
[
3
],
Storage
::
real
n
[
3
])
{
if
(
size
==
1
)
{
...
...
@@ -379,7 +379,7 @@ namespace INMOST
}
}
void
kdtree
::
intersect_plane_edge
(
Tag
clip_point
,
Tag
clip_state
,
ElementArray
<
Cell
>
&
cells
,
MarkerType
mark_cells
,
double
p
[
3
],
double
n
[
3
])
void
kdtree
::
intersect_plane_edge
(
Tag
clip_point
,
Tag
clip_state
,
ElementArray
<
Cell
>
&
cells
,
MarkerType
mark_cells
,
Storage
::
real
p
[
3
],
Storage
::
real
n
[
3
])
{
if
(
marked
)
{
...
...
@@ -389,7 +389,7 @@ namespace INMOST
sub_intersect_plane_edge
(
clip_point
,
clip_state
,
cells
,
mark_cells
,
p
,
n
);
}
void
kdtree
::
intersect_plane_face
(
Tag
clip_state
,
double
p
[
3
],
double
n
[
3
])
void
kdtree
::
intersect_plane_face
(
Tag
clip_state
,
Storage
::
real
p
[
3
],
Storage
::
real
n
[
3
])
{
sub_intersect_plane_faces
(
clip_state
,
p
,
n
);
}
...
...
@@ -446,7 +446,7 @@ namespace INMOST
clip_state
=
m
->
CreateTag
(
"CLIP_STATE"
,
DATA_INTEGER
,
EDGE
,
NONE
,
1
);
}
double
clipper
::
compute_value
(
Edge
e
,
Storage
::
real
*
pnt
)
Storage
::
real
clipper
::
compute_value
(
Edge
e
,
Storage
::
real
*
pnt
)
{
if
(
isColorBarEnabled
())
{
...
...
@@ -771,9 +771,9 @@ namespace INMOST
{
for
(
INMOST_DATA_ENUM_TYPE
q
=
offset
;
q
<
offset
+
cln
[
r
];
q
++
)
{
glVertex
3
dv
(
cnt
);
glVertex
3
dv
(
&
cl
[
q
*
3
]);
glVertex
3
dv
(
&
cl
[(((
q
+
1
-
offset
)
%
cln
[
r
])
+
offset
)
*
3
]);
glVertex
N
dv
(
cnt
);
glVertex
N
dv
(
&
cl
[
q
*
3
]);
glVertex
N
dv
(
&
cl
[(((
q
+
1
-
offset
)
%
cln
[
r
])
+
offset
)
*
3
]);
}
}
else
if
(
elevation
)
...
...
@@ -789,21 +789,21 @@ namespace INMOST
pos
[
0
]
=
cnt
[
0
]
+
n
[
0
]
*
t
;
pos
[
1
]
=
cnt
[
1
]
+
n
[
1
]
*
t
;
pos
[
2
]
=
cnt
[
2
]
+
n
[
2
]
*
t
;
glVertex
3
dv
(
pos
);
glVertex
N
dv
(
pos
);
if
(
!
(
GetVisualizationType
()
==
CELL
&&
!
isVisualizationSmooth
()))
glTexCoord1d
(
GetColorBar
()
->
pick_texture
(
clv
[
q
]));
t
=
(
clv
[
q
]
-
GetColorBar
()
->
get_min
())
/
(
GetColorBar
()
->
get_max
()
-
GetColorBar
()
->
get_min
());
pos
[
0
]
=
cl
[
q
*
3
+
0
]
+
n
[
0
]
*
t
;
pos
[
1
]
=
cl
[
q
*
3
+
1
]
+
n
[
1
]
*
t
;
pos
[
2
]
=
cl
[
q
*
3
+
2
]
+
n
[
2
]
*
t
;
glVertex
3
dv
(
pos
);
glVertex
N
dv
(
pos
);
if
(
!
(
GetVisualizationType
()
==
CELL
&&
!
isVisualizationSmooth
()))
glTexCoord1d
(
GetColorBar
()
->
pick_texture
(
clv
[(
q
+
1
-
offset
)
%
cln
[
r
]
+
offset
]));
t
=
(
clv
[(
q
+
1
-
offset
)
%
cln
[
r
]
+
offset
]
-
GetColorBar
()
->
get_min
())
/
(
GetColorBar
()
->
get_max
()
-
GetColorBar
()
->
get_min
());
pos
[
0
]
=
cl
[((
q
+
1
-
offset
)
%
cln
[
r
]
+
offset
)
*
3
+
0
]
+
n
[
0
]
*
t
;
pos
[
1
]
=
cl
[((
q
+
1
-
offset
)
%
cln
[
r
]
+
offset
)
*
3
+
1
]
+
n
[
1
]
*
t
;
pos
[
2
]
=
cl
[((
q
+
1
-
offset
)
%
cln
[
r
]
+
offset
)
*
3
+
2
]
+
n
[
2
]
*
t
;
glVertex
3
dv
(
pos
);
glVertex
N
dv
(
pos
);
}
}
else
...
...
@@ -814,13 +814,13 @@ namespace INMOST
glTexCoord1d
(
GetColorBar
()
->
pick_texture
(
cells
[
k
].
RealDF
(
GetVisualizationTag
())));
else
glTexCoord1d
(
GetColorBar
()
->
pick_texture
(
cntv
));
glVertex
3
dv
(
cnt
);
glVertex
N
dv
(
cnt
);
if
(
!
(
GetVisualizationType
()
==
CELL
&&
!
isVisualizationSmooth
()))
glTexCoord1d
(
GetColorBar
()
->
pick_texture
(
clv
[
q
]));
glVertex
3
dv
(
&
cl
[
q
*
3
]);
glVertex
N
dv
(
&
cl
[
q
*
3
]);
if
(
!
(
GetVisualizationType
()
==
CELL
&&
!
isVisualizationSmooth
()))
glTexCoord1d
(
GetColorBar
()
->
pick_texture
(
clv
[(
q
+
1
-
offset
)
%
cln
[
r
]
+
offset
]));
glVertex
3
dv
(
&
cl
[((
q
+
1
-
offset
)
%
cln
[
r
]
+
offset
)
*
3
]);
glVertex
N
dv
(
&
cl
[((
q
+
1
-
offset
)
%
cln
[
r
]
+
offset
)
*
3
]);
}
}
offset
+=
cln
[
r
];
...
...
@@ -854,12 +854,12 @@ namespace INMOST
pos
[
0
]
=
cl
[
q
*
3
+
0
]
+
t
*
n
[
0
];
pos
[
1
]
=
cl
[
q
*
3
+
1
]
+
t
*
n
[
1
];
pos
[
2
]
=
cl
[
q
*
3
+
2
]
+
t
*
n
[
2
];
glVertex
3
dv
(
pos
);
glVertex
N
dv
(
pos
);
t
=
(
clv
[(
q
+
1
-
offset
)
%
cln
[
r
]
+
offset
]
-
GetColorBar
()
->
get_min
())
/
(
GetColorBar
()
->
get_max
()
-
GetColorBar
()
->
get_min
());
pos
[
0
]
=
cl
[((
q
+
1
-
offset
)
%
cln
[
r
]
+
offset
)
*
3
+
0
]
+
t
*
n
[
0
];
pos
[
1
]
=
cl
[((
q
+
1
-
offset
)
%
cln
[
r
]
+
offset
)
*
3
+
1
]
+
t
*
n
[
1
];
pos
[
2
]
=
cl
[((
q
+
1
-
offset
)
%
cln
[
r
]
+
offset
)
*
3
+
2
]
+
t
*
n
[
2
];
glVertex
3
dv
(
pos
);
glVertex
N
dv
(
pos
);
}
offset
+=
cln
[
r
];
}
...
...
@@ -876,8 +876,8 @@ namespace INMOST
{
for
(
INMOST_DATA_ENUM_TYPE
q
=
offset
;
q
<
offset
+
cln
[
r
];
q
++
)
{
glVertex
3
dv
(
&
cl
[
q
*
3
]);
glVertex
3
dv
(
&
cl
[((
q
+
1
-
offset
)
%
cln
[
r
]
+
offset
)
*
3
]);
glVertex
N
dv
(
&
cl
[
q
*
3
]);
glVertex
N
dv
(
&
cl
[((
q
+
1
-
offset
)
%
cln
[
r
]
+
offset
)
*
3
]);
}
offset
+=
cln
[
r
];
}
...
...
@@ -913,7 +913,7 @@ namespace INMOST
else
tree
=
new
kdtree
(
mm
,
faces
,
nfaces
);
}
double
bnd_clipper
::
compute_value
(
Node
n1
,
Node
n2
,
Storage
::
real
*
c1
,
Storage
::
real
*
c2
,
Storage
::
real
*
pnt
)
Storage
::
real
bnd_clipper
::
compute_value
(
Node
n1
,
Node
n2
,
Storage
::
real
*
c1
,
Storage
::
real
*
c2
,
Storage
::
real
*
pnt
)
{
if
(
isColorBarEnabled
())
{
...
...
Examples/DrawGrid/clipper.h
View file @
10d1e034
...
...
@@ -27,16 +27,16 @@ namespace INMOST
void
radix_sort
(
int
dim
,
struct
entry
*
temp
);
void
kdtree_build
(
int
dim
,
int
&
done
,
int
total
,
struct
entry
*
temp
);
kdtree
();
inline
int
plane_bbox
(
double
p
[
3
],
double
n
[
3
])
const
;
bool
sub_intersect_plane_edge
(
Tag
clip_point
,
Tag
clip_state
,
ElementArray
<
Cell
>
&
cells
,
MarkerType
mrk
,
double
p
[
3
],
double
n
[
3
]);
void
sub_intersect_plane_faces
(
Tag
clip_state
,
double
p
[
3
],
double
n
[
3
]);
inline
int
plane_bbox
(
Storage
::
real
p
[
3
],
Storage
::
real
n
[
3
])
const
;
bool
sub_intersect_plane_edge
(
Tag
clip_point
,
Tag
clip_state
,
ElementArray
<
Cell
>
&
cells
,
MarkerType
mrk
,
Storage
::
real
p
[
3
],
Storage
::
real
n
[
3
]);
void
sub_intersect_plane_faces
(
Tag
clip_state
,
Storage
::
real
p
[
3
],
Storage
::
real
n
[
3
]);
void
unmark_old_edges
(
Tag
clip_state
);
void
clear_children
();
public:
kdtree
(
Mesh
*
m
);
kdtree
(
Mesh
*
m
,
HandleType
*
eset
,
INMOST_DATA_ENUM_TYPE
size
);
void
intersect_plane_edge
(
Tag
clip_point
,
Tag
clip_state
,
ElementArray
<
Cell
>
&
cells
,
MarkerType
mark_cells
,
double
p
[
3
],
double
n
[
3
]);
void
intersect_plane_face
(
Tag
clip_state
,
double
p
[
3
],
double
n
[
3
]);
void
intersect_plane_edge
(
Tag
clip_point
,
Tag
clip_state
,
ElementArray
<
Cell
>
&
cells
,
MarkerType
mark_cells
,
Storage
::
real
p
[
3
],
Storage
::
real
n
[
3
]);
void
intersect_plane_face
(
Tag
clip_state
,
Storage
::
real
p
[
3
],
Storage
::
real
n
[
3
]);
~
kdtree
();
};
...
...
@@ -45,7 +45,7 @@ namespace INMOST
public:
struct
edge_point
{
double
val
;
Storage
::
real
val
;
Storage
::
real
xyz
[
3
];
Storage
::
integer
edge
;
edge_point
();
...
...
@@ -64,7 +64,7 @@ namespace INMOST
public:
~
clipper
();
clipper
(
Mesh
*
m
);
double
compute_value
(
Edge
e
,
Storage
::
real
*
pnt
);
Storage
::
real
compute_value
(
Edge
e
,
Storage
::
real
*
pnt
);
void
clip_plane
(
Storage
::
real
p
[
3
],
Storage
::
real
n
[
3
]);
void
gen_clip
(
std
::
vector
<
face2gl
>
&
out
,
Storage
::
real
n
[
3
],
bool
elevation
);
void
draw_clip
(
INMOST_DATA_ENUM_TYPE
pace
,
Storage
::
real
n
[
3
],
bool
elevation
);
...
...
@@ -82,7 +82,7 @@ namespace INMOST
public:
~
bnd_clipper
();
bnd_clipper
(
Mesh
*
m
,
HandleType
*
_faces
,
INMOST_DATA_ENUM_TYPE
size
);
double
compute_value
(
Node
n1
,
Node
n2
,
Storage
::
real
*
c1
,
Storage
::
real
*
c2
,
Storage
::
real
*
pnt
);
Storage
::
real
compute_value
(
Node
n1
,
Node
n2
,
Storage
::
real
*
c1
,
Storage
::
real
*
c2
,
Storage
::
real
*
pnt
);
void
clip_plane
(
Storage
::
real
p
[
3
],
Storage
::
real
n
[
3
]);
void
gen_clip
(
std
::
vector
<
face2gl
>
&
out
,
Storage
::
real
p
[
3
],
Storage
::
real
n
[
3
],
bool
elevation
);
void
draw_clip
(
INMOST_DATA_ENUM_TYPE
pace
,
Storage
::
real
p
[
3
],
Storage
::
real
n
[
3
]);
...
...
@@ -91,4 +91,4 @@ namespace INMOST
};
}
#endif
\ No newline at end of file
#endif
Examples/DrawGrid/coord.cpp
View file @
10d1e034
...
...
@@ -2,15 +2,15 @@
double
abs
(
const
coord
&
p
)
INMOST_DATA_REAL_TYPE
abs
(
const
coord
&
p
)
{
return
sqrt
(
p
^
p
);
}
void
get_matrix
(
const
coord
&
a
,
const
coord
&
b
,
double
matrix
[
16
])
void
get_matrix
(
const
coord
&
a
,
const
coord
&
b
,
INMOST_DATA_REAL_TYPE
matrix
[
16
])
{
double
d
;
INMOST_DATA_REAL_TYPE
d
;
coord
z
=
(
b
-
a
)
/
sqrt
((
b
-
a
)
^
(
b
-
a
));
coord
y
;
coord
x
;
...
...
@@ -41,4 +41,4 @@ void get_matrix(const coord & a, const coord & b, double matrix[16])
matrix
[
13
]
=
0
;
matrix
[
14
]
=
0
;
matrix
[
15
]
=
1
;
}
\ No newline at end of file
}
Examples/DrawGrid/coord.h
View file @
10d1e034
...
...
@@ -2,42 +2,42 @@
#define _COORD_H
#include <cmath>
#include "inmost_common.h"
class
coord
{
double
p
[
3
];
INMOST_DATA_REAL_TYPE
p
[
3
];
public:
coord
()
{
p
[
0
]
=
p
[
1
]
=
p
[
2
]
=
0
;
}
coord
(
double
xyz
[
3
])
{
p
[
0
]
=
xyz
[
0
];
p
[
1
]
=
xyz
[
1
];
p
[
2
]
=
xyz
[
2
];
}
coord
(
double
x
,
double
y
,
double
z
)
{
p
[
0
]
=
x
;
p
[
1
]
=
y
;
p
[
2
]
=
z
;
}
coord
(
INMOST_DATA_REAL_TYPE
xyz
[
3
])
{
p
[
0
]
=
xyz
[
0
];
p
[
1
]
=
xyz
[
1
];
p
[
2
]
=
xyz
[
2
];
}
coord
(
INMOST_DATA_REAL_TYPE
x
,
INMOST_DATA_REAL_TYPE
y
,
INMOST_DATA_REAL_TYPE
z
)
{
p
[
0
]
=
x
;
p
[
1
]
=
y
;
p
[
2
]
=
z
;
}
coord
(
const
coord
&
other
)
{
p
[
0
]
=
other
.
p
[
0
];
p
[
1
]
=
other
.
p
[
1
];
p
[
2
]
=
other
.
p
[
2
];
}
coord
&
operator
=
(
coord
const
&
other
)
{
p
[
0
]
=
other
.
p
[
0
];
p
[
1
]
=
other
.
p
[
1
];
p
[
2
]
=
other
.
p
[
2
];
return
*
this
;
}
coord
&
operator
+=
(
const
coord
&
other
)
{
p
[
0
]
+=
other
.
p
[
0
];
p
[
1
]
+=
other
.
p
[
1
];
p
[
2
]
+=
other
.
p
[
2
];
return
*
this
;
}
coord
&
operator
-=
(
const
coord
&
other
)
{
p
[
0
]
-=
other
.
p
[
0
];
p
[
1
]
-=
other
.
p
[
1
];
p
[
2
]
-=
other
.
p
[
2
];
return
*
this
;
}
coord
&
operator
*=
(
const
coord
&
other
)
{
double
tmp
[
3
]
=
{
p
[
1
]
*
other
.
p
[
2
]
-
p
[
2
]
*
other
.
p
[
1
],
p
[
2
]
*
other
.
p
[
0
]
-
p
[
0
]
*
other
.
p
[
2
],
p
[
0
]
*
other
.
p
[
1
]
-
p
[
1
]
*
other
.
p
[
0
]
};
INMOST_DATA_REAL_TYPE
tmp
[
3
]
=
{
p
[
1
]
*
other
.
p
[
2
]
-
p
[
2
]
*
other
.
p
[
1
],
p
[
2
]
*
other
.
p
[
0
]
-
p
[
0
]
*
other
.
p
[
2
],
p
[
0
]
*
other
.
p
[
1
]
-
p
[
1
]
*
other
.
p
[
0
]
};
p
[
0
]
=
tmp
[
0
];
p
[
1
]
=
tmp
[
1
];
p
[
2
]
=
tmp
[
2
];
return
*
this
;
}
coord
&
operator
*=
(
double
other
)
{
p
[
0
]
*=
other
;
p
[
1
]
*=
other
;
p
[
2
]
*=
other
;
return
*
this
;
}
coord
&
operator
/=
(
double
other
)
{
p
[
0
]
/=
other
;
p
[
1
]
/=
other
;
p
[
2
]
/=
other
;
return
*
this
;
}
coord
&
operator
*=
(
INMOST_DATA_REAL_TYPE
other
)
{
p
[
0
]
*=
other
;
p
[
1
]
*=
other
;
p
[
2
]
*=
other
;
return
*
this
;
}
coord
&
operator
/=
(
INMOST_DATA_REAL_TYPE
other
)
{
p
[
0
]
/=
other
;
p
[
1
]
/=
other
;
p
[
2
]
/=
other
;
return
*
this
;
}
coord
operator
-
(
const
coord
&
other
)
const
{
return
coord
(
p
[
0
]
-
other
.
p
[
0
],
p
[
1
]
-
other
.
p
[
1
],
p
[
2
]
-
other
.
p
[
2
]);
}
coord
operator
+
(
const
coord
&
other
)
const
{
return
coord
(
p
[
0
]
+
other
.
p
[
0
],
p
[
1
]
+
other
.
p
[
1
],
p
[
2
]
+
other
.
p
[
2
]);
}
coord
operator
*
(
const
coord
&
other
)
const
{
return
coord
(
p
[
1
]
*
other
.
p
[
2
]
-
p
[
2
]
*
other
.
p
[
1
],
p
[
2
]
*
other
.
p
[
0
]
-
p
[
0
]
*
other
.
p
[
2
],
p
[
0
]
*
other
.
p
[
1
]
-
p
[
1
]
*
other
.
p
[
0
]);
}
coord
operator
/
(
double
other
)
const
{
return
coord
(
p
[
0
]
/
other
,
p
[
1
]
/
other
,
p
[
2
]
/
other
);
}
coord
operator
*
(
double
other
)
const
{
return
coord
(
p
[
0
]
*
other
,
p
[
1
]
*
other
,
p
[
2
]
*
other
);
}
double
operator
^
(
const
coord
&
other
)
const
{
return
p
[
0
]
*
other
.
p
[
0
]
+
p
[
1
]
*
other
.
p
[
1
]
+
p
[
2
]
*
other
.
p
[
2
];
}
coord
operator
/
(
INMOST_DATA_REAL_TYPE
other
)
const
{
return
coord
(
p
[
0
]
/
other
,
p
[
1
]
/
other
,
p
[
2
]
/
other
);
}
coord
operator
*
(
INMOST_DATA_REAL_TYPE
other
)
const
{
return
coord
(
p
[
0
]
*
other
,
p
[
1
]
*
other
,
p
[
2
]
*
other
);
}
INMOST_DATA_REAL_TYPE
operator
^
(
const
coord
&
other
)
const
{
return
p
[
0
]
*
other
.
p
[
0
]
+
p
[
1
]
*
other
.
p
[
1
]
+
p
[
2
]
*
other
.
p
[
2
];
}
~
coord
()
{}
double
length
()
const
{
return
sqrt
((
*
this
)
^
(
*
this
));
}
double
&
operator
[](
int
i
)
{
return
p
[
i
];
}
double
operator
[](
int
i
)
const
{
return
p
[
i
];
}
double
*
data
()
{
return
p
;
}
const
double
*
data
()
const
{
return
p
;
}
INMOST_DATA_REAL_TYPE
length
()
const
{
return
sqrt
((
*
this
)
^
(
*
this
));
}
INMOST_DATA_REAL_TYPE
&
operator
[](
int
i
)
{
return
p
[
i
];
}
INMOST_DATA_REAL_TYPE
operator
[](
int
i
)
const
{
return
p
[
i
];
}
INMOST_DATA_REAL_TYPE
*
data
()
{
return
p
;
}
const
INMOST_DATA_REAL_TYPE
*
data
()
const
{
return
p
;
}
};
double
abs
(
const
coord
&
p
);
void
get_matrix
(
const
coord
&
a
,
const
coord
&
b
,
double
matrix
[
16
]);
INMOST_DATA_REAL_TYPE
abs
(
const
coord
&
p
);
void
get_matrix
(
const
coord
&
a
,
const
coord
&
b
,
INMOST_DATA_REAL_TYPE
matrix
[
16
]);
#endif
\ No newline at end of file
#endif
Examples/DrawGrid/face2gl.h
View file @
10d1e034
...
...
@@ -39,7 +39,9 @@ namespace INMOST
void
set_color
(
double
r
,
double
g
,
double
b
,
double
a
)
{
c
[
0
]
=
r
;
c
[
1
]
=
g
;
c
[
2
]
=
b
;
c
[
3
]
=
a
;
}
void
add_vert
(
double
x
,
double
y
,
double
z
)
{
unsigned
s
=
(
unsigned
)
verts
.
size
();
verts
.
resize
(
s
+
3
);
verts
[
s
]
=
x
;
verts
[
s
+
1
]
=
y
;
verts
[
s
+
2
]
=
z
;
}
void
add_vert
(
double
v
[
3
])
{
verts
.
insert
(
verts
.
end
(),
v
,
v
+
3
);
}
void
add_vert
(
float
v
[
3
])
{
verts
.
insert
(
verts
.
end
(),
v
,
v
+
3
);
}
void
add_vert
(
double
*
v
,
int
N
)
{
double
vv
[
3
]
=
{
0
,
0
,
0
};
for
(
int
k
=
0
;
k
<
N
;
++
k
)
vv
[
k
]
=
v
[
k
];
verts
.
insert
(
verts
.
end
(),
vv
,
vv
+
3
);
}
void
add_vert
(
float
*
v
,
int
N
)
{
double
vv
[
3
]
=
{
0
,
0
,
0
};
for
(
int
k
=
0
;
k
<
N
;
++
k
)
vv
[
k
]
=
v
[
k
];
verts
.
insert
(
verts
.
end
(),
vv
,
vv
+
3
);
}
void
add_color
(
color_t
c
)
{
colors
.
push_back
(
c
);
}
void
add_texcoord
(
double
val
)
{
texcoords
.
push_back
(
val
);
}
double
*
get_vert
(
int
k
)
{
return
&
verts
[
k
*
3
];
}
...
...
Examples/DrawGrid/main.cpp
View file @
10d1e034
...
...
@@ -214,13 +214,13 @@ public:
}
void
Draw
()
{
glVertex
3
dv
(
v
[
0
].
data
());
glVertex
3
dv
(
v
[
1
].
data
());
glVertex
N
dv
(
v
[
0
].
data
());
glVertex
N
dv
(
v
[
1
].
data
());
}
void
SVGDraw
(
std
::
ostream
&
file
,
double
modelview
[
16
],
double
projection
[
16
],
int
viewport
[
4
])
{
double
*
v0
=
v
[
0
].
data
();
double
*
v1
=
v
[
1
].
data
();
Storage
::
real
*
v0
=
v
[
0
].
data
();
Storage
::
real
*
v1
=
v
[
1
].
data
();
svg_line
(
file
,
v0
[
0
],
v0
[
1
],
v0
[
2
],
v1
[
0
],
v1
[
1
],
v1
[
2
],
modelview
,
projection
,
viewport
);
}
};
...
...
Examples/DrawGrid/streamline.cpp
View file @
10d1e034
...
...
@@ -82,19 +82,19 @@ namespace INMOST
//return ret;
}
double
GetSizeProj
(
double
bounds
[
3
][
2
],
const
coord
&
v
)
INMOST_DATA_REAL_TYPE
GetSizeProj
(
INMOST_DATA_REAL_TYPE
bounds
[
3
][
2
],
const
coord
&
v
)
{
double
vl
=
v
.
length
();
INMOST_DATA_REAL_TYPE
vl
=
v
.
length
();
if
(
!
vl
)
return
0
;
coord
uv
=
v
/
vl
;
double
ret
=
0
;
INMOST_DATA_REAL_TYPE
ret
=
0
;
for
(
int
k
=
0
;
k
<
3
;
++
k
)
ret
+=
fabs
(
uv
[
k
]
*
(
bounds
[
k
][
1
]
-
bounds
[
k
][
0
]));
return
ret
;
}
double
GetSizeProj
(
Element
c
,
const
coord
&
v
)
INMOST_DATA_REAL_TYPE
GetSizeProj
(
Element
c
,
const
coord
&
v
)
{
double
bounds
[
3
][
2
];
INMOST_DATA_REAL_TYPE
bounds
[
3
][
2
];
GetBbox
(
c
,
bounds
);
return
GetSizeProj
(
bounds
,
v
);
}
...
...
@@ -308,7 +308,7 @@ namespace INMOST
GLUquadric
*
cylqs
=
NULL
;
void
drawcylinder
(
coord
a
,
coord
b
,
double
width
)
{
double
matrix
[
16
];
INMOST_DATA_REAL_TYPE
matrix
[
16
];
if
(
cylqs
==
NULL
)
{
cylqs
=
gluNewQuadric
();
...
...
@@ -319,7 +319,11 @@ namespace INMOST
glPushMatrix
();