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
e145375f
Commit
e145375f
authored
Jan 15, 2015
by
Kirill Terekhov
Browse files
Fixes #5
Adapting mesh_file.cpp to new comparator's behavior.
parent
c5f557ac
Changes
3
Hide whitespace changes
Inline
Side-by-side
examples/Solver/main.cpp
View file @
e145375f
...
@@ -146,11 +146,23 @@ Storage::real tensor_K_mat_rotOxy(Storage::integer mat)
...
@@ -146,11 +146,23 @@ Storage::real tensor_K_mat_rotOxy(Storage::integer mat)
int
main
(
int
argc
,
char
**
argv
)
int
main
(
int
argc
,
char
**
argv
)
{
{
Mesh
::
Initialize
(
&
argc
,
&
argv
);
Solver
::
Initialize
(
&
argc
,
&
argv
,
"database.txt"
);
Solver
::
Initialize
(
&
argc
,
&
argv
,
"database.txt"
);
#if defined(USE_PARTITIONER)
#if defined(USE_PARTITIONER)
Partitioner
::
Initialize
(
&
argc
,
&
argv
);
Partitioner
::
Initialize
(
&
argc
,
&
argv
);
#endif
#endif
{
Mesh
m
;
//m.SetFileOption("VERBOSITY","2");
m
.
Load
(
argv
[
1
]);
m
.
Save
(
"dump.pvtk"
);
}
Solver
::
Finalize
();
Partitioner
::
Finalize
();
Mesh
::
Finalize
();
return
0
;
if
(
argc
>
1
)
if
(
argc
>
1
)
{
{
Tag
phi
,
tensor_K
,
id
,
mat
;
Tag
phi
,
tensor_K
,
id
,
mat
;
...
...
mesh.cpp
View file @
e145375f
...
@@ -372,8 +372,25 @@ namespace INMOST
...
@@ -372,8 +372,25 @@ namespace INMOST
#if defined(USE_MPI_P2P)
#if defined(USE_MPI_P2P)
if
(
m_state
==
Mesh
::
Parallel
)
if
(
m_state
==
Mesh
::
Parallel
)
{
{
MPI_Free_mem
(
shared_space
);
int
test
=
0
;
MPI_Win_free
(
&
window
);
MPI_Finalized
(
&
test
);
if
(
!
test
)
{
MPI_Free_mem
(
shared_space
);
MPI_Win_free
(
&
window
);
}
else
{
std
::
cout
<<
"Cannot release memory and window allocated by MPI"
<<
std
::
endl
;
std
::
cout
<<
"since MPI was already finalized. Most likely this"
<<
std
::
endl
;
std
::
cout
<<
"happens when you define class Mesh in main() function"
<<
std
::
endl
;
std
::
cout
<<
"so that destructor get called after Mesh::Finalize()"
<<
std
::
endl
;
std
::
cout
<<
"Please enclose area where you use Mesh class"
<<
std
::
endl
;
std
::
cout
<<
"with scopes, so that destructor get called when"
<<
std
::
endl
;
std
::
cout
<<
"execution goes out of the scope or dynamically"
<<
std
::
endl
;
std
::
cout
<<
"allocate and explicitly delete Mesh class."
<<
std
::
endl
;
std
::
cout
<<
"Thank you!"
<<
std
::
endl
;
}
//~ MPI_Comm_free(&comm);
//~ MPI_Comm_free(&comm);
}
}
#endif //USE_MPI_P2P
#endif //USE_MPI_P2P
...
...
mesh_file.cpp
View file @
e145375f
...
@@ -581,7 +581,12 @@ ecl_exit_loop:
...
@@ -581,7 +581,12 @@ ecl_exit_loop:
if
(
!
old_nodes
.
empty
()
)
if
(
!
old_nodes
.
empty
()
)
{
{
std
::
vector
<
HandleType
>::
iterator
it
=
std
::
lower_bound
(
old_nodes
.
begin
(),
old_nodes
.
end
(),
node_xyz
,
CentroidComparator
(
this
));
std
::
vector
<
HandleType
>::
iterator
it
=
std
::
lower_bound
(
old_nodes
.
begin
(),
old_nodes
.
end
(),
node_xyz
,
CentroidComparator
(
this
));
if
(
it
!=
old_nodes
.
end
()
)
find
=
static_cast
<
int
>
(
it
-
old_nodes
.
begin
());
if
(
it
!=
old_nodes
.
end
()
)
{
Storage
::
real_array
c
=
RealArrayDF
(
*
it
,
CoordsTag
());
if
(
CentroidComparator
(
this
).
Compare
(
node_xyz
,
c
.
data
())
==
0
)
find
=
static_cast
<
int
>
(
it
-
old_nodes
.
begin
());
}
}
}
if
(
find
==
-
1
)
newnodes
[
numnode
++
]
=
CreateNode
(
node_xyz
)
->
GetHandle
();
if
(
find
==
-
1
)
newnodes
[
numnode
++
]
=
CreateNode
(
node_xyz
)
->
GetHandle
();
else
newnodes
[
numnode
++
]
=
old_nodes
[
find
];
else
newnodes
[
numnode
++
]
=
old_nodes
[
find
];
...
@@ -793,7 +798,14 @@ ecl_exit_loop:
...
@@ -793,7 +798,14 @@ ecl_exit_loop:
old_nodes
[
qq
++
]
=
*
it
;
old_nodes
[
qq
++
]
=
*
it
;
}
}
if
(
!
old_nodes
.
empty
()
)
if
(
!
old_nodes
.
empty
()
)
{
std
::
sort
(
old_nodes
.
begin
(),
old_nodes
.
end
(),
CentroidComparator
(
this
));
std
::
sort
(
old_nodes
.
begin
(),
old_nodes
.
end
(),
CentroidComparator
(
this
));
//for(std::vector<HandleType>::iterator it = old_nodes.begin(); it != old_nodes.end(); ++it)
//{
// Storage::real_array c = RealArrayDF(*it,CoordsTag());
// REPORT_VAL("coord: ",c[0] << " " << c[1] << " " << c[2]);
//}
}
FILE
*
f
=
fopen
(
File
.
c_str
(),
"r"
);
FILE
*
f
=
fopen
(
File
.
c_str
(),
"r"
);
...
@@ -1335,7 +1347,12 @@ ecl_exit_loop:
...
@@ -1335,7 +1347,12 @@ ecl_exit_loop:
if
(
!
old_nodes
.
empty
()
)
if
(
!
old_nodes
.
empty
()
)
{
{
std
::
vector
<
HandleType
>::
iterator
it
=
std
::
lower_bound
(
old_nodes
.
begin
(),
old_nodes
.
end
(),
coords
,
CentroidComparator
(
this
));
std
::
vector
<
HandleType
>::
iterator
it
=
std
::
lower_bound
(
old_nodes
.
begin
(),
old_nodes
.
end
(),
coords
,
CentroidComparator
(
this
));
if
(
it
!=
old_nodes
.
end
()
)
find
=
static_cast
<
int
>
(
it
-
old_nodes
.
begin
());
if
(
it
!=
old_nodes
.
end
()
)
{
Storage
::
real_array
c
=
RealArrayDF
(
*
it
,
CoordsTag
());
if
(
CentroidComparator
(
this
).
Compare
(
c
.
data
(),
coords
)
==
0
)
find
=
static_cast
<
int
>
(
it
-
old_nodes
.
begin
());
}
}
}
if
(
find
==
-
1
)
if
(
find
==
-
1
)
newnodes
[
i
]
=
CreateNode
(
coords
)
->
GetHandle
();
newnodes
[
i
]
=
CreateNode
(
coords
)
->
GetHandle
();
...
@@ -1365,7 +1382,12 @@ ecl_exit_loop:
...
@@ -1365,7 +1382,12 @@ ecl_exit_loop:
if
(
!
old_nodes
.
empty
()
)
if
(
!
old_nodes
.
empty
()
)
{
{
std
::
vector
<
HandleType
>::
iterator
it
=
std
::
lower_bound
(
old_nodes
.
begin
(),
old_nodes
.
end
(),
coords
,
CentroidComparator
(
this
));
std
::
vector
<
HandleType
>::
iterator
it
=
std
::
lower_bound
(
old_nodes
.
begin
(),
old_nodes
.
end
(),
coords
,
CentroidComparator
(
this
));
if
(
it
!=
old_nodes
.
end
()
)
find
=
static_cast
<
int
>
(
it
-
old_nodes
.
begin
());
if
(
it
!=
old_nodes
.
end
()
)
{
Storage
::
real_array
c
=
RealArrayDF
(
*
it
,
CoordsTag
());
if
(
CentroidComparator
(
this
).
Compare
(
c
.
data
(),
coords
)
==
0
)
find
=
static_cast
<
int
>
(
it
-
old_nodes
.
begin
());
}
}
}
if
(
find
==
-
1
)
newnodes
[
i
]
=
CreateNode
(
coords
)
->
GetHandle
();
if
(
find
==
-
1
)
newnodes
[
i
]
=
CreateNode
(
coords
)
->
GetHandle
();
else
newnodes
[
i
]
=
old_nodes
[
find
];
else
newnodes
[
i
]
=
old_nodes
[
find
];
...
@@ -2105,7 +2127,12 @@ ecl_exit_loop:
...
@@ -2105,7 +2127,12 @@ ecl_exit_loop:
if
(
!
old_nodes
.
empty
()
)
if
(
!
old_nodes
.
empty
()
)
{
{
std
::
vector
<
HandleType
>::
iterator
it
=
std
::
lower_bound
(
old_nodes
.
begin
(),
old_nodes
.
end
(),
xyz
,
CentroidComparator
(
this
));
std
::
vector
<
HandleType
>::
iterator
it
=
std
::
lower_bound
(
old_nodes
.
begin
(),
old_nodes
.
end
(),
xyz
,
CentroidComparator
(
this
));
if
(
it
!=
old_nodes
.
end
()
)
find
=
static_cast
<
int
>
(
it
-
old_nodes
.
begin
());
if
(
it
!=
old_nodes
.
end
()
)
{
Storage
::
real_array
c
=
RealArrayDF
(
*
it
,
CoordsTag
());
if
(
CentroidComparator
(
this
).
Compare
(
xyz
,
c
.
data
())
==
0
)
find
=
static_cast
<
int
>
(
it
-
old_nodes
.
begin
());
}
}
}
if
(
find
==
-
1
)
newnodes
[
i
]
=
CreateNode
(
xyz
)
->
GetHandle
();
if
(
find
==
-
1
)
newnodes
[
i
]
=
CreateNode
(
xyz
)
->
GetHandle
();
else
newnodes
[
i
]
=
old_nodes
[
find
];
else
newnodes
[
i
]
=
old_nodes
[
find
];
...
@@ -2471,7 +2498,12 @@ read_node_num_link:
...
@@ -2471,7 +2498,12 @@ read_node_num_link:
if
(
!
old_nodes
.
empty
()
)
if
(
!
old_nodes
.
empty
()
)
{
{
std
::
vector
<
HandleType
>::
iterator
it
=
std
::
lower_bound
(
old_nodes
.
begin
(),
old_nodes
.
end
(),
xyz
,
CentroidComparator
(
this
));
std
::
vector
<
HandleType
>::
iterator
it
=
std
::
lower_bound
(
old_nodes
.
begin
(),
old_nodes
.
end
(),
xyz
,
CentroidComparator
(
this
));
if
(
it
!=
old_nodes
.
end
()
)
find
=
static_cast
<
int
>
(
it
-
old_nodes
.
begin
());
if
(
it
!=
old_nodes
.
end
()
)
{
Storage
::
real_array
c
=
RealArrayDF
(
*
it
,
CoordsTag
());
if
(
CentroidComparator
(
this
).
Compare
(
xyz
,
c
.
data
())
==
0
)
find
=
static_cast
<
int
>
(
it
-
old_nodes
.
begin
());
}
}
}
if
(
find
==
-
1
)
newnodes
[
nodenum
]
=
CreateNode
(
xyz
)
->
GetHandle
();
if
(
find
==
-
1
)
newnodes
[
nodenum
]
=
CreateNode
(
xyz
)
->
GetHandle
();
else
newnodes
[
nodenum
]
=
old_nodes
[
find
];
else
newnodes
[
nodenum
]
=
old_nodes
[
find
];
...
@@ -3236,7 +3268,12 @@ read_elem_num_link:
...
@@ -3236,7 +3268,12 @@ read_elem_num_link:
if
(
!
old_nodes
.
empty
()
)
if
(
!
old_nodes
.
empty
()
)
{
{
std
::
vector
<
HandleType
>::
iterator
it
=
std
::
lower_bound
(
old_nodes
.
begin
(),
old_nodes
.
end
(),
coords
,
CentroidComparator
(
this
));
std
::
vector
<
HandleType
>::
iterator
it
=
std
::
lower_bound
(
old_nodes
.
begin
(),
old_nodes
.
end
(),
coords
,
CentroidComparator
(
this
));
if
(
it
!=
old_nodes
.
end
()
)
find
=
static_cast
<
int
>
(
it
-
old_nodes
.
begin
());
if
(
it
!=
old_nodes
.
end
()
)
{
Storage
::
real_array
c
=
RealArrayDF
(
*
it
,
CoordsTag
());
if
(
CentroidComparator
(
this
).
Compare
(
coords
,
c
.
data
())
==
0
)
find
=
static_cast
<
int
>
(
it
-
old_nodes
.
begin
());
}
}
}
if
(
find
==
-
1
)
new_nodes
[
i
]
=
CreateNode
(
coords
)
->
GetHandle
();
if
(
find
==
-
1
)
new_nodes
[
i
]
=
CreateNode
(
coords
)
->
GetHandle
();
else
new_nodes
[
i
]
=
old_nodes
[
find
];
else
new_nodes
[
i
]
=
old_nodes
[
find
];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment