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
394ccbe7
Commit
394ccbe7
authored
Oct 29, 2019
by
Kirill Terekhov
Browse files
Tool to change tag name, compute pressure gradient in ADMFD
parent
3109165f
Changes
6
Hide whitespace changes
Inline
Side-by-side
Examples/ADMFD/diffusion.cpp
View file @
394ccbe7
...
...
@@ -98,7 +98,11 @@ int main(int argc,char ** argv)
Tag
tag_F
;
// Forcing term
Tag
tag_BC
;
// Boundary conditions
Tag
tag_W
;
// Gradient matrix acting on harmonic points on faces and returning gradient on faces
TagRealArray
tag_PG
;
// Pressure gradient
TagRealArray
tag_WG
;
// matrix to reconstruct gradient
if
(
m
->
GetProcessorsNumber
()
>
1
)
//skip for one processor job
{
// Exchange ghost cells
...
...
@@ -133,6 +137,9 @@ int main(int argc,char ** argv)
if
(
m
->
HaveTag
(
"PRESSURE"
)
)
//Is there a pressure on the mesh?
tag_P
=
m
->
GetTag
(
"PRESSURE"
);
//Get the pressure
tag_PG
=
m
->
CreateTag
(
"PRESSURE_GRADIENT"
,
DATA_REAL
,
CELL
,
NONE
,
3
);
tag_WG
=
m
->
CreateTag
(
"WGRAD"
,
DATA_REAL
,
CELL
,
NONE
);
if
(
!
tag_P
.
isValid
()
||
!
tag_P
.
isDefined
(
CELL
)
)
// Pressure was not initialized or was not defined on nodes
{
...
...
@@ -209,6 +216,9 @@ int main(int argc,char ** argv)
store_W
.
resize
(
NF
*
NF
);
//write down the gradient matrix
std
::
copy
(
W
.
data
(),
W
.
data
()
+
NF
*
NF
,
store_W
.
data
());
tag_WG
[
cell
].
resize
(
3
*
NF
);
tag_WG
(
cell
,
3
,
NF
)
=
(
NK
.
Transpose
()
*
R
).
PseudoInvert
(
1.0e-12
)
*
NK
.
Transpose
()
*
Areas
;
}
//end of loop over cells
}
std
::
cout
<<
"Construct W matrix: "
<<
Timer
()
-
ttt
<<
std
::
endl
;
...
...
@@ -288,6 +298,7 @@ int main(int argc,char ** argv)
for
(
int
k
=
0
;
k
<
NF
;
++
k
)
pF
(
k
,
0
)
=
(
P
(
faces
[
k
])
-
P
(
cell
));
FLUX
=
W
*
pF
;
//fluxes on faces
tag_PG
(
cell
,
3
,
1
)
=
tag_WG
(
cell
,
3
,
NF
)
*
pF
;
if
(
cell
.
GetStatus
()
!=
Element
::
Ghost
)
{
for
(
int
k
=
0
;
k
<
NF
;
++
k
)
//loop over faces of current cell
...
...
Examples/GridTools/CMakeLists.txt
View file @
394ccbe7
...
...
@@ -36,6 +36,7 @@ add_executable(glue_faces glue_faces.cpp)
add_executable
(
check_collapse check_collapse.cpp
)
add_executable
(
test_fracture test_fracture.cpp
)
add_executable
(
segment_data segment_data.cpp
)
add_executable
(
ChangeTagName change_tag_name.cpp
)
add_library
(
FractureLib fracture.cpp fracture.h
)
add_library
(
SliceFuncLib slice_func.cpp slice_func.h
)
...
...
@@ -431,6 +432,16 @@ endif(USE_MPI)
install
(
TARGETS segment_data EXPORT inmost-targets RUNTIME DESTINATION bin/GridTools
)
target_link_libraries
(
ChangeTagName inmost
)
if
(
USE_MPI
)
message
(
"linking ChangeTagName with MPI"
)
target_link_libraries
(
ChangeTagName
${
MPI_LIBRARIES
}
)
if
(
MPI_LINK_FLAGS
)
set_target_properties
(
ChangeTagName PROPERTIES LINK_FLAGS
"
${
MPI_LINK_FLAGS
}
"
)
endif
()
endif
(
USE_MPI
)
install
(
TARGETS ChangeTagName EXPORT inmost-targets RUNTIME DESTINATION bin/GridTools
)
set_property
(
TARGET FractureLib PROPERTY PUBLIC_HEADER
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/fracture.h"
)
set_property
(
TARGET SliceFuncLib PROPERTY PUBLIC_HEADER
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/slice_func.h"
)
...
...
Examples/GridTools/change_tag_name.cpp
0 → 100644
View file @
394ccbe7
#include "inmost.h"
#include <stdio.h>
using
namespace
INMOST
;
typedef
Storage
::
real
real
;
typedef
Storage
::
real_array
real_array
;
int
main
(
int
argc
,
char
**
argv
)
{
if
(
argc
<
4
)
{
printf
(
"Usage: %s input_mesh tag_name new_tag_name [output_mesh=out.pmf]
\n
"
,
argv
[
0
]);
return
-
1
;
}
std
::
string
inpmesh
;
std
::
string
outmesh
=
"out.pmf"
;
std
::
string
tagname
;
std
::
string
newtagname
;
if
(
argc
>
1
)
inpmesh
=
std
::
string
(
argv
[
1
]);
if
(
argc
>
2
)
tagname
=
std
::
string
(
argv
[
2
]);
if
(
argc
>
3
)
newtagname
=
std
::
string
(
argv
[
3
]);
if
(
argc
>
4
)
outmesh
=
std
::
string
(
argv
[
4
]);
Mesh
m
;
std
::
cout
<<
"load "
<<
inpmesh
<<
std
::
endl
;
m
.
Load
(
inpmesh
);
std
::
cout
<<
"rename "
<<
tagname
<<
" -> "
<<
newtagname
<<
std
::
endl
;
if
(
m
.
RenameTag
(
tagname
,
newtagname
)
)
std
::
cout
<<
"success!"
<<
std
::
endl
;
else
std
::
cout
<<
"failure"
<<
std
::
endl
;
std
::
cout
<<
"save "
<<
outmesh
<<
std
::
endl
;
m
.
Save
(
outmesh
);
return
0
;
}
Examples/GridTools/sector.cpp
View file @
394ccbe7
...
...
@@ -19,10 +19,10 @@ int main(int argc, char ** argv)
const
double
pi
=
3.1415926536
;
double
theta
=
0
,
ct
,
st
;
int
refine
=
1
;
double
refine
=
1
;
int
stype
=
0
;
if
(
argc
>
2
)
theta
=
atof
(
argv
[
2
])
/
180.0
*
pi
;
if
(
argc
>
3
)
refine
=
ato
i
(
argv
[
3
]);
if
(
argc
>
3
)
refine
=
ato
f
(
argv
[
3
]);
if
(
argc
>
5
)
stype
=
atoi
(
argv
[
5
]);
ct
=
cos
(
theta
);
st
=
sin
(
theta
);
...
...
@@ -52,6 +52,13 @@ int main(int argc, char ** argv)
a
=
sin
(
3.14159265359
*
a
/
2.0
);
else
if
(
refine
==
-
1
)
a
=
1
-
sin
(
3.14159265359
*
(
1
-
a
)
/
2.0
);
else
{
if
(
refine
<
0
)
a
=
2
*
(
0.5
+
0.5
*
(
a
*
0.5
-
0.5
)
/
sqrt
(
pow
(
a
*
0.5
-
0.5
,
2
)
+
pow
(
refine
,
2
))
*
sqrt
(
0.25
+
pow
(
refine
,
2
))
*
2
);
else
if
(
refine
>
0
)
a
=
2
*
(
0.5
+
0.5
*
(
a
*
0.5
)
/
sqrt
(
pow
(
a
*
0.5
,
2
)
+
pow
(
refine
,
2
))
*
sqrt
(
0.25
+
pow
(
refine
,
2
))
*
2
-
0.5
);
}
n
->
Coords
()[
0
]
=
(
xmax
-
xmin
)
*
a
+
xmin
;
}
}
...
...
Source/Data/tag.cpp
View file @
394ccbe7
...
...
@@ -88,6 +88,11 @@ namespace INMOST
{
mem
=
other
.
mem
;
}
void
Tag
::
ChangeName
(
std
::
string
name
)
{
mem
->
tagname
=
name
;
}
void
TagManager
::
CopyData
(
const
Tag
&
t
,
void
*
adata
,
const
void
*
bdata
)
{
...
...
@@ -309,6 +314,23 @@ namespace INMOST
tags
.
clear
();
}
bool
TagManager
::
RenameTag
(
std
::
string
old_name
,
std
::
string
new_name
)
{
for
(
tag_array_type
::
size_type
i
=
0
;
i
<
tags
.
size
();
i
++
)
{
if
(
tags
[
i
].
GetTagName
()
==
new_name
)
return
false
;
//tag already exists
}
for
(
tag_array_type
::
size_type
i
=
0
;
i
<
tags
.
size
();
i
++
)
{
if
(
tags
[
i
].
GetTagName
()
==
old_name
)
{
tags
[
i
].
ChangeName
(
new_name
);
return
true
;
}
}
return
false
;
//tag not found
}
Tag
TagManager
::
CreateTag
(
Mesh
*
m
,
std
::
string
name
,
DataType
dtype
,
ElementType
etype
,
ElementType
sparse
,
INMOST_DATA_ENUM_TYPE
size
)
...
...
Source/Headers/inmost_data.h
View file @
394ccbe7
...
...
@@ -202,6 +202,7 @@ namespace INMOST
__INLINE
INMOST_DATA_ENUM_TYPE
GetPosition
(
ElementType
type
)
const
;
__INLINE
void
SetSparse
(
ElementType
type
);
__INLINE
INMOST_DATA_ENUM_TYPE
GetPositionByDim
(
INMOST_DATA_ENUM_TYPE
typenum
)
const
;
__INLINE
void
ChangeName
(
std
::
string
newname
);
public:
~
Tag
();
Tag
();
...
...
@@ -270,6 +271,8 @@ namespace INMOST
virtual
Tag
DeleteTag
(
Tag
tag
,
ElementType
mask
);
/// Check that the tag was defined on certain elements.
bool
ElementDefined
(
Tag
const
&
tag
,
ElementType
etype
)
const
;
/// Change tag name
bool
RenameTag
(
std
::
string
oldname
,
std
::
string
newname
);
protected:
/// Shrink or enlarge arrays for a dense data.
void
ReallocateData
(
const
Tag
&
t
,
INMOST_DATA_INTEGER_TYPE
etypenum
,
INMOST_DATA_ENUM_TYPE
new_size
);
...
...
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