Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
I
INMOST
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kirill Terekhov
INMOST
Commits
ae0bf6b1
Commit
ae0bf6b1
authored
Dec 19, 2015
by
Kirill Terekhov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixes and updates
Including issue #15
parent
5cbb6419
Changes
19
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
938 additions
and
691 deletions
+938
-691
Examples/ADFVDiscr/main.cpp
Examples/ADFVDiscr/main.cpp
+2
-1
Examples/ADMFD/main.cpp
Examples/ADMFD/main.cpp
+2
-1
Source/Autodiff/autodiff.cpp
Source/Autodiff/autodiff.cpp
+33
-2
Source/Data/tag.cpp
Source/Data/tag.cpp
+24
-0
Source/Headers/container.hpp
Source/Headers/container.hpp
+4
-3
Source/Headers/inmost_autodiff.h
Source/Headers/inmost_autodiff.h
+9
-0
Source/Headers/inmost_data.h
Source/Headers/inmost_data.h
+26
-12
Source/Headers/inmost_dense.h
Source/Headers/inmost_dense.h
+146
-85
Source/Headers/inmost_expression.h
Source/Headers/inmost_expression.h
+262
-37
Source/Headers/inmost_mesh.h
Source/Headers/inmost_mesh.h
+4
-41
Source/Headers/inmost_variable.h
Source/Headers/inmost_variable.h
+129
-272
Source/IO/mesh_gmv_file.cpp
Source/IO/mesh_gmv_file.cpp
+10
-9
Source/IO/mesh_pmf_file.cpp
Source/IO/mesh_pmf_file.cpp
+1
-1
Source/IO/mesh_vtk_file.cpp
Source/IO/mesh_vtk_file.cpp
+32
-8
Source/Mesh/mesh.cpp
Source/Mesh/mesh.cpp
+39
-56
Source/Mesh/node.cpp
Source/Mesh/node.cpp
+5
-1
Source/Mesh/parallel.cpp
Source/Mesh/parallel.cpp
+8
-4
Source/Solver/solver.cpp
Source/Solver/solver.cpp
+3
-3
Source/Solver/solver_bcgsl.hpp
Source/Solver/solver_bcgsl.hpp
+199
-155
No files found.
Examples/ADFVDiscr/main.cpp
View file @
ae0bf6b1
...
...
@@ -149,6 +149,7 @@ int main(int argc,char ** argv)
{
Automatizator
aut
(
m
);
Automatizator
::
MakeCurrent
(
&
aut
);
INMOST_DATA_ENUM_TYPE
iphi
=
aut
.
RegisterDynamicTag
(
phi
,
CELL
);
aut
.
EnumerateDynamicTags
();
...
...
@@ -164,7 +165,7 @@ int main(int argc,char ** argv)
#pragma omp parallel
#endif
{
enhanced_variable
flux
(
aut
)
;
//should be more efficient to define here to avoid multiple memory allocations if storage for variations should be expanded
variable
flux
;
//should be more efficient to define here to avoid multiple memory allocations if storage for variations should be expanded
#if defined(USE_OMP)
#pragma omp for
#endif
...
...
Examples/ADMFD/main.cpp
View file @
ae0bf6b1
...
...
@@ -454,9 +454,10 @@ int main(int argc,char ** argv)
{
//Main loop for problem solution
Automatizator
aut
(
m
);
// declare class to help manage unknowns
Automatizator
::
MakeCurrent
(
&
aut
);
Sparse
::
RowMerger
&
merger
=
aut
.
GetMerger
();
//get structure that helps matrix assembly
dynamic_variable
P
(
aut
,
aut
.
RegisterDynamicTag
(
tag_P
,
CELL
|
FACE
));
//register pressure as primary unknown
enhanced_variable
calc
(
aut
)
;
//declare variable that helps calculating the value with variations
variable
calc
;
//declare variable that helps calculating the value with variations
aut
.
EnumerateDynamicTags
();
//enumerate all primary variables
...
...
Source/Autodiff/autodiff.cpp
View file @
ae0bf6b1
...
...
@@ -13,9 +13,40 @@
namespace
INMOST
{
Automatizator
*
Automatizator
::
CurrentAutomatizator
=
NULL
;
bool
print_ad_ctor
=
false
;
bool
GetAutodiffPrint
()
{
return
print_ad_ctor
;}
void
SetAutodiffPrint
(
bool
set
)
{
print_ad_ctor
=
set
;}
bool
CheckCurrentAutomatizator
()
{
return
Automatizator
::
HaveCurrent
();}
void
multivar_expression
::
FromBasicExpression
(
const
basic_expression
&
expr
)
{
Sparse
::
RowMerger
&
merger
=
Automatizator
::
GetCurrent
()
->
GetMerger
();
expr
.
GetDerivative
(
1.0
,
merger
);
merger
.
RetriveRow
(
entries
);
merger
.
Clear
();
}
void
multivar_expression
::
AddBasicExpression
(
INMOST_DATA_REAL_TYPE
multme
,
INMOST_DATA_REAL_TYPE
multit
,
const
basic_expression
&
expr
)
{
Sparse
::
RowMerger
&
merger
=
Automatizator
::
GetCurrent
()
->
GetMerger
();
merger
.
PushRow
(
multme
,
entries
);
expr
.
GetDerivative
(
multit
,
merger
);
merger
.
RetriveRow
(
entries
);
merger
.
Clear
();
}
void
multivar_expression
::
FromGetDerivative
(
INMOST_DATA_REAL_TYPE
mult
,
Sparse
::
Row
&
r
)
const
{
Sparse
::
RowMerger
&
merger
=
Automatizator
::
GetCurrent
()
->
GetMerger
();
GetDerivative
(
mult
,
merger
);
merger
.
AddRow
(
1.0
,
r
);
merger
.
RetriveRow
(
r
);
merger
.
Clear
();
}
#if defined(NEW_VERSION)
//! returns offset from the end of precomputed z
//! returns offset from the end of precomputed z
void
Automatizator
::
DerivativeFill
(
expr
&
var
,
INMOST_DATA_ENUM_TYPE
element
,
INMOST_DATA_ENUM_TYPE
parent
,
Sparse
::
RowMerger
&
entries
,
INMOST_DATA_REAL_TYPE
multval
,
void
*
user_data
)
{
INMOST_DATA_ENUM_TYPE
voffset
=
var
.
values_offset
(
element
),
doffset
=
var
.
derivatives_offset
(
element
);
...
...
Source/Data/tag.cpp
View file @
ae0bf6b1
...
...
@@ -400,6 +400,8 @@ namespace INMOST
{
if
(
!
tag
.
isSparse
(
mask
)
)
{
//this was already done in Mesh::DeleteTag()
//ReallocateData(tag,ElementNum(mask),0); //this should clean up the structures
dense_data
[
tpos
].
clear
();
//here all data should be deleted
empty_dense_data
.
push_back
(
tpos
);
}
...
...
@@ -517,6 +519,17 @@ namespace INMOST
}
}
}
#if defined(USE_AUTODIFF)
else
if
(
data_type
==
DATA_VARIABLE
)
//Have to perform in-memory deallocation to correctly remove class inheritance
{
for
(
INMOST_DATA_ENUM_TYPE
it
=
new_size
;
it
<
old_size
;
++
it
)
{
variable
*
p
=
static_cast
<
variable
*>
(
static_cast
<
void
*>
(
&
arr
[
it
]));
for
(
INMOST_DATA_ENUM_TYPE
jt
=
0
;
jt
<
data_size
;
++
jt
)
p
[
jt
].
~
variable
();
}
}
#endif
#if defined(USE_OMP)
#pragma omp critical
#endif
...
...
@@ -538,6 +551,17 @@ namespace INMOST
#endif
}
}
#if defined(USE_AUTODIFF)
else
if
(
data_type
==
DATA_VARIABLE
)
//Have to perform in-memory allocation to correctly setup class inheritance
{
for
(
INMOST_DATA_ENUM_TYPE
it
=
old_size
;
it
<
new_size
;
++
it
)
{
variable
*
p
=
static_cast
<
variable
*>
(
static_cast
<
void
*>
(
&
arr
[
it
]));
for
(
INMOST_DATA_ENUM_TYPE
jt
=
0
;
jt
<
data_size
;
++
jt
)
new
(
p
+
jt
)
variable
();
}
}
#endif
}
}
...
...
Source/Headers/container.hpp
View file @
ae0bf6b1
...
...
@@ -18,18 +18,19 @@
//TODO
// 1. change to uniform size_type instead of size_t, make it INMOST_DATA_ENUM_TYPE
/*
template<class element, class T1> struct isInputRandomIterators
{
static
void
constraints
(
T1
a
,
T1
b
)
{
/*element x = static_cast<element>(*a); (void)x;*/
++
a
;
(
void
)
a
++
;
a
==
a
;
a
!=
a
;
a
-
b
;
}
static void constraints(T1 a, T1 b) { ++a; (void)a++; a==a; a!=a; a-b; }
isInputRandomIterators() { void(*p)(T1,T1) = constraints; (void)p; }
};
template<class element, class T1> struct isInputForwardIterators
{
static
void
constraints
(
T1
a
)
{
/*element x = static_cast<element>(*a); (void)x;*/
++
a
;
(
void
)
a
++
;
}
static void constraints(T1 a) {++a; (void)a++; }
isInputForwardIterators() { void(*p)(T1) = constraints; (void)p; }
};
*/
namespace
INMOST
{
...
...
Source/Headers/inmost_autodiff.h
View file @
ae0bf6b1
...
...
@@ -92,6 +92,7 @@ namespace INMOST
typedef
dynarray
<
stencil_pair
,
64
>
stencil_pairs
;
typedef
void
(
*
stencil_callback
)(
const
Storage
&
current_element
,
stencil_pairs
&
out_stencil
,
void
*
user_data
);
private:
static
Automatizator
*
CurrentAutomatizator
;
#if defined(USE_OMP)
std
::
vector
<
Sparse
::
RowMerger
>
merger
;
#else
...
...
@@ -187,6 +188,14 @@ namespace INMOST
return
merger
;
#endif
}
/// Remove global current automatizator.
static
void
RemoveCurrent
()
{
CurrentAutomatizator
=
NULL
;}
/// Set current global automatizator, so that variable will be optimized with row merger.
static
void
MakeCurrent
(
Automatizator
*
aut
)
{
CurrentAutomatizator
=
aut
;}
/// Check that there is an automatizator.
static
bool
HaveCurrent
()
{
return
CurrentAutomatizator
!=
NULL
;}
/// Retrive the automatizator.
static
Automatizator
*
GetCurrent
()
{
return
CurrentAutomatizator
;}
}
;
#if defined(NEW_VERSION)
...
...
Source/Headers/inmost_data.h
View file @
ae0bf6b1
...
...
@@ -240,24 +240,38 @@ namespace INMOST
typedef
tag_array_type
::
iterator
iteratorTag
;
public:
virtual
~
TagManager
();
/// Check existance of a data tag by it's name.
bool
HaveTag
(
std
::
string
name
)
const
;
/// Retrive a data tag by it's name.
Tag
GetTag
(
std
::
string
name
)
const
;
/// Retrive names for all the tags present on the mesh.
void
ListTagNames
(
std
::
vector
<
std
::
string
>
&
list
)
const
;
/// Create tag with prescribed attributes.
Tag
CreateTag
(
Mesh
*
m
,
std
::
string
name
,
DataType
dtype
,
ElementType
etype
,
ElementType
sparse
,
INMOST_DATA_ENUM_TYPE
size
=
ENUMUNDEF
);
/// Delete tag from certain elements.
virtual
Tag
DeleteTag
(
Tag
tag
,
ElementType
mask
);
/// Check that the tag was defined on certain elements.
bool
ElementDefined
(
Tag
const
&
tag
,
ElementType
etype
)
const
;
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
);
/// Reallocate all the data for all the tags.
void
ReallocateData
(
INMOST_DATA_INTEGER_TYPE
etypenum
,
INMOST_DATA_ENUM_TYPE
new_size
);
///Retrive substructure for representation of the sparse data without permission for modification.
__INLINE
sparse_sub_type
const
&
GetSparseData
(
int
etypenum
,
int
local_id
)
const
{
return
sparse_data
[
etypenum
][
local_id
];}
///Retrive substructure for representation of the sparse data.
__INLINE
sparse_sub_type
&
GetSparseData
(
int
etypenum
,
int
local_id
)
{
return
sparse_data
[
etypenum
][
local_id
];}
///Retrive substructure for representation of the dense data without permission for modification.
__INLINE
dense_sub_type
const
&
GetDenseData
(
int
pos
)
const
{
return
dense_data
[
pos
];}
///Retrive substructure for representation of the dense data.
__INLINE
dense_sub_type
&
GetDenseData
(
int
pos
)
{
return
dense_data
[
pos
];}
///Copy data from one element to another.
static
void
CopyData
(
const
Tag
&
t
,
void
*
adata
,
const
void
*
bdata
);
///Destroy data that represents array of variable size.
static
void
DestroyVariableData
(
const
Tag
&
t
,
void
*
adata
);
protected:
typedef
tag_array_type
::
iterator
tag_iterator
;
typedef
tag_array_type
::
const_iterator
tag_const_iterator
;
typedef
tag_array_type
::
iterator
tag_iterator
;
//< Use this type to iterate over tags of the mesh.
typedef
tag_array_type
::
const_iterator
tag_const_iterator
;
//< Use this type to iterate over tags of the mesh without right for modification.
protected:
tag_array_type
tags
;
empty_data
empty_dense_data
;
...
...
@@ -432,16 +446,16 @@ namespace INMOST
/// If there is a link to handle provided (automatically by ElementArray and reference_array),
/// then remote handle value will be modified
Storage
&
operator
=
(
Storage
const
&
other
);
__INLINE
bool
operator
<
(
const
Storage
&
other
)
const
;
__INLINE
bool
operator
>
(
const
Storage
&
other
)
const
;
__INLINE
bool
operator
<=
(
const
Storage
&
other
)
const
;
__INLINE
bool
operator
>=
(
const
Storage
&
other
)
const
;
__INLINE
bool
operator
==
(
const
Storage
&
other
)
const
;
__INLINE
bool
operator
!=
(
const
Storage
&
other
)
const
;
__INLINE
Storage
*
operator
->
();
__INLINE
const
Storage
*
operator
->
()
const
;
__INLINE
Storage
&
self
();
__INLINE
const
Storage
&
self
()
const
;
__INLINE
bool
operator
<
(
const
Storage
&
other
)
const
{
return
handle
<
other
.
handle
;}
__INLINE
bool
operator
>
(
const
Storage
&
other
)
const
{
return
handle
>
other
.
handle
;}
__INLINE
bool
operator
<=
(
const
Storage
&
other
)
const
{
return
handle
<=
other
.
handle
;}
__INLINE
bool
operator
>=
(
const
Storage
&
other
)
const
{
return
handle
>=
other
.
handle
;}
__INLINE
bool
operator
==
(
const
Storage
&
other
)
const
{
return
handle
==
other
.
handle
;}
__INLINE
bool
operator
!=
(
const
Storage
&
other
)
const
{
return
handle
!=
other
.
handle
;}
__INLINE
Storage
*
operator
->
()
{
return
this
;}
__INLINE
const
Storage
*
operator
->
()
const
{
return
this
;}
__INLINE
Storage
&
self
()
{
return
*
this
;}
__INLINE
const
Storage
&
self
()
const
{
return
*
this
;}
virtual
~
Storage
()
{}
public:
/// Retrieve real value associated with Tag. Implemented in inmost_mesh.h.
...
...
Source/Headers/inmost_dense.h
View file @
ae0bf6b1
This diff is collapsed.
Click to expand it.
Source/Headers/inmost_expression.h
View file @
ae0bf6b1
This diff is collapsed.
Click to expand it.
Source/Headers/inmost_mesh.h
View file @
ae0bf6b1
...
...
@@ -1987,12 +1987,15 @@ namespace INMOST
/// @param tag tag that represents the data
/// @see Tag::GetSize
INMOST_DATA_ENUM_TYPE
GetDataSize
(
HandleType
h
,
const
Tag
&
tag
)
const
;
//For DATA_BULK return number of bytes, otherwise return the length of array
/// Return the size of the structure required to represent the data on current element.
/// Return the size of the structure
in bytes
required to represent the data on current element.
/// This is equal to GetDataSize times Tag::GetBytesSize for all the data types,
/// except for DATA_VARIABLE, that requires a larger structure to accomodate derivatives.
/// @param h handle of element
/// @param tag tag that represents the data
INMOST_DATA_ENUM_TYPE
GetDataCapacity
(
HandleType
h
,
const
Tag
&
tag
)
const
;
/// Returns the number of bytes in data used for given type of tag.
/// Trivial for all the types except DATA_VARIABLE.
INMOST_DATA_ENUM_TYPE
GetDataCapacity
(
const
INMOST_DATA_BULK_TYPE
*
data
,
INMOST_DATA_ENUM_TYPE
size
,
const
Tag
&
tag
)
const
;
/// Sets the size of the array for data of variable size.
/// If you try to change size of data of constant size then if size is
/// different from current then in debug mode (NDEBUG not set) assertion will fail,
...
...
@@ -3199,46 +3202,6 @@ namespace INMOST
//////////////////////////////////////////////////////////////////////
/// Inline functions for class Storage //
//////////////////////////////////////////////////////////////////////
__INLINE
bool
Storage
::
operator
<
(
const
Storage
&
other
)
const
{
return
handle
<
other
.
handle
;
}
__INLINE
bool
Storage
::
operator
>
(
const
Storage
&
other
)
const
{
return
handle
>
other
.
handle
;
}
__INLINE
bool
Storage
::
operator
<=
(
const
Storage
&
other
)
const
{
return
handle
<=
other
.
handle
;
}
__INLINE
bool
Storage
::
operator
>=
(
const
Storage
&
other
)
const
{
return
handle
>=
other
.
handle
;
}
__INLINE
bool
Storage
::
operator
==
(
const
Storage
&
other
)
const
{
return
handle
==
other
.
handle
;
}
__INLINE
bool
Storage
::
operator
!=
(
const
Storage
&
other
)
const
{
return
handle
!=
other
.
handle
;
}
__INLINE
Storage
*
Storage
::
operator
->
()
{
return
this
;
}
__INLINE
const
Storage
*
Storage
::
operator
->
()
const
{
return
this
;
}
__INLINE
Storage
&
Storage
::
self
()
{
return
*
this
;
}
__INLINE
const
Storage
&
Storage
::
self
()
const
{
return
*
this
;
}
__INLINE
Storage
::
real
&
Storage
::
Real
(
const
Tag
&
tag
)
const
{
return
GetMeshLink
()
->
Real
(
GetHandle
(),
tag
);
...
...
Source/Headers/inmost_variable.h
View file @
ae0bf6b1
This diff is collapsed.
Click to expand it.
Source/IO/mesh_gmv_file.cpp
View file @
ae0bf6b1
...
...
@@ -96,9 +96,6 @@ namespace INMOST
!
t
->
isSparse
(
etype
)
&&
t
->
GetTagName
().
substr
(
0
,
9
)
!=
"PROTECTED"
&&
t
->
GetDataType
()
!=
DATA_REFERENCE
&&
#if defined(USE_AUTODIFF)
t
->
GetDataType
()
!=
DATA_VARIABLE
&&
#endif
t
->
GetDataType
()
!=
DATA_REMOTE_REFERENCE
)
{
sprintf
(
keyword
,
"%s"
,
t
->
GetTagName
().
substr
(
0
,
8
).
c_str
());
...
...
@@ -119,6 +116,9 @@ namespace INMOST
case
DATA_INTEGER
:
keyval
=
static_cast
<
Storage
::
real
>
(
e
->
Integer
(
*
t
));
break
;
case
DATA_REAL
:
keyval
=
e
->
Real
(
*
t
);
break
;
case
DATA_BULK
:
keyval
=
static_cast
<
Storage
::
real
>
(
e
->
Bulk
(
*
t
));
break
;
#if defined(USE_AUTODIFF)
case
DATA_VARIABLE
:
keyval
=
e
->
Variable
(
*
t
).
GetValue
();
break
;
#endif
default:
throw
NotImplemented
;
}
fwrite
(
&
keyval
,
sizeof
(
Storage
::
real
),
1
,
file
);
...
...
@@ -136,9 +136,6 @@ namespace INMOST
t
->
GetSize
()
==
1
&&
t
->
isSparse
(
etype
)
&&
t
->
GetDataType
()
!=
DATA_REFERENCE
&&
#if defined(USE_AUTODIFF)
t
->
GetDataType
()
!=
DATA_VARIABLE
&&
#endif
t
->
GetDataType
()
!=
DATA_REMOTE_REFERENCE
)
{
Storage
::
integer
temp
;
...
...
@@ -173,6 +170,9 @@ namespace INMOST
case
DATA_INTEGER
:
keyval
=
static_cast
<
Storage
::
real
>
(
e
->
Integer
(
*
t
));
break
;
case
DATA_REAL
:
keyval
=
e
->
Real
(
*
t
);
break
;
case
DATA_BULK
:
keyval
=
static_cast
<
Storage
::
real
>
(
e
->
Bulk
(
*
t
));
break
;
#if defined(USE_AUTODIFF)
case
DATA_VARIABLE
:
keyval
=
e
->
Variable
(
*
t
).
GetValue
();
break
;
#endif
default:
throw
NotImplemented
;
}
fwrite
(
&
keyval
,
sizeof
(
Storage
::
real
),
1
,
file
);
...
...
@@ -230,10 +230,8 @@ namespace INMOST
t
->
GetSize
()
!=
1
&&
t
->
GetSize
()
!=
ENUMUNDEF
&&
!
t
->
isSparse
(
etype
)
&&
t
->
GetTagName
().
substr
(
0
,
9
)
!=
"PROTECTED"
&&
t
->
GetDataType
()
!=
DATA_REFERENCE
&&
#if defined(USE_AUTODIFF)
t
->
GetDataType
()
!=
DATA_VARIABLE
&&
#endif
t
->
GetDataType
()
!=
DATA_REMOTE_REFERENCE
)
{
...
...
@@ -261,6 +259,9 @@ namespace INMOST
case
DATA_INTEGER
:
keyval
=
static_cast
<
Storage
::
real
>
(
e
->
IntegerArray
(
*
t
)[
q
]);
break
;
case
DATA_REAL
:
keyval
=
e
->
RealArray
(
*
t
)[
q
];
break
;
case
DATA_BULK
:
keyval
=
static_cast
<
Storage
::
real
>
(
e
->
BulkArray
(
*
t
)[
q
]);
break
;
#if defined(USE_AUTODIFF)
case
DATA_VARIABLE
:
keyval
=
e
->
VariableArray
(
*
t
)[
q
].
GetValue
();
break
;
#endif
default:
throw
NotImplemented
;
}
fwrite
(
&
keyval
,
sizeof
(
Storage
::
real
),
1
,
file
);
...
...
Source/IO/mesh_pmf_file.cpp
View file @
ae0bf6b1
...
...
@@ -331,7 +331,7 @@ namespace INMOST
{
if
(
arr
[
k
].
isValid
()
)
{
uconv
.
write_iValue
(
out
,
arr
[
k
].
GetMeshLink
()
->
GetMeshName
().
size
(
));
uconv
.
write_iValue
(
out
,
static_cast
<
INMOST_DATA_ENUM_TYPE
>
(
arr
[
k
].
GetMeshLink
()
->
GetMeshName
().
size
()
));
out
.
write
(
arr
[
k
].
GetMeshLink
()
->
GetMeshName
().
c_str
(),
arr
[
k
].
GetMeshLink
()
->
GetMeshName
().
size
());
wetype
=
arr
[
k
].
GetElementType
();
out
.
put
(
wetype
);
...
...
Source/IO/mesh_vtk_file.cpp
View file @
ae0bf6b1
...
...
@@ -236,9 +236,6 @@ safe_output:
t
.
GetDataType
()
!=
DATA_BULK
&&
t
.
GetDataType
()
!=
DATA_REFERENCE
&&
t
.
GetDataType
()
!=
DATA_REMOTE_REFERENCE
&&
#if defined(USE_AUTODIFF)
t
.
GetDataType
()
!=
DATA_VARIABLE
&&
#endif
t
!=
CoordsTag
()
&&
t
!=
SharedTag
()
&&
t
!=
SendtoTag
()
&&
...
...
@@ -261,7 +258,13 @@ safe_output:
else
{
{
fprintf
(
f
,
"SCALARS %s %s %d
\n
"
,
tags
[
i
].
GetTagName
().
c_str
(),(
tags
[
i
].
GetDataType
()
==
DATA_REAL
?
"double"
:
"int"
),
comps
);
std
::
string
type_str
=
"int"
;
if
(
tags
[
i
].
GetDataType
()
==
DATA_REAL
#if defined(USE_AUTODIFF)
||
tags
[
i
].
GetDataType
()
==
DATA_VARIABLE
#endif
)
type_str
=
"double"
;
fprintf
(
f
,
"SCALARS %s %s %d
\n
"
,
tags
[
i
].
GetTagName
().
c_str
(),
type_str
.
c_str
(),
comps
);
fprintf
(
f
,
"LOOKUP_TABLE default
\n
"
);
for
(
Mesh
::
iteratorCell
it
=
BeginCell
();
it
!=
EndCell
();
it
++
)
{
...
...
@@ -281,6 +284,15 @@ safe_output:
fprintf
(
f
,
"
\n
"
);
}
break
;
#if defined(USE_AUTODIFF)
case
DATA_VARIABLE
:
{
Storage
::
var_array
arr
=
it
->
VariableArray
(
tags
[
i
]);
for
(
unsigned
int
m
=
0
;
m
<
comps
;
m
++
)
fprintf
(
f
,
"%14e "
,
arr
[
m
].
GetValue
());
fprintf
(
f
,
"
\n
"
);
}
break
;
#endif
default:
continue
;
}
}
...
...
@@ -300,9 +312,6 @@ safe_output:
t
.
GetDataType
()
!=
DATA_BULK
&&
t
.
GetDataType
()
!=
DATA_REFERENCE
&&
t
.
GetDataType
()
!=
DATA_REMOTE_REFERENCE
&&
#if defined(USE_AUTODIFF)
t
.
GetDataType
()
!=
DATA_VARIABLE
&&
#endif
t
!=
CoordsTag
()
&&
t
!=
SharedTag
()
&&
t
!=
SendtoTag
()
&&
...
...
@@ -322,7 +331,13 @@ safe_output:
else
{
{
fprintf
(
f
,
"SCALARS %s %s %d
\n
"
,
tags
[
i
].
GetTagName
().
c_str
(),(
tags
[
i
].
GetDataType
()
==
DATA_REAL
?
"double"
:
"int"
),
comps
);
std
::
string
type_str
=
"int"
;
if
(
tags
[
i
].
GetDataType
()
==
DATA_REAL
#if defined(USE_AUTODIFF)
||
tags
[
i
].
GetDataType
()
==
DATA_VARIABLE
#endif
)
type_str
=
"double"
;
fprintf
(
f
,
"SCALARS %s %s %d
\n
"
,
tags
[
i
].
GetTagName
().
c_str
(),
type_str
.
c_str
(),
comps
);
fprintf
(
f
,
"LOOKUP_TABLE default
\n
"
);
for
(
Mesh
::
iteratorNode
it
=
BeginNode
();
it
!=
EndNode
();
it
++
)
{
...
...
@@ -342,6 +357,15 @@ safe_output:
fprintf
(
f
,
"
\n
"
);
}
break
;
#if defined(USE_AUTODIFF)
case
DATA_VARIABLE
:
{
Storage
::
var_array
arr
=
it
->
VariableArray
(
tags
[
i
]);
for
(
unsigned
int
m
=
0
;
m
<
comps
;
m
++
)
fprintf
(
f
,
"%14e "
,
arr
[
m
].
GetValue
());
fprintf
(
f
,
"
\n
"
);
}
break
;
#endif
default:
continue
;
}
}
...
...
Source/Mesh/mesh.cpp
View file @
ae0bf6b1
...
...
@@ -257,7 +257,7 @@ namespace INMOST
{
ret
+=
t
->
GetRecordSize
();
//all utilized data for fixed data, size of support structure for variable data
if
(
t
->
GetSize
()
==
ENUMUNDEF
)
ret
+=
GetData
Size
(
h
,
*
t
)
*
t
->
GetBytesSize
(
);
//actually occupied size for sparse data
ret
+=
GetData
Capacity
(
h
,
*
t
);
//actually occupied size for sparse data
}
}
if
(
!
sparse_data
[
etypenum
].
empty
()
)
ret
+=
sizeof
(
sparse_sub_type
);
//size needed to support sparse data
...
...
@@ -2042,6 +2042,24 @@ namespace INMOST
}
return
tag
.
GetSize
();
}
INMOST_DATA_ENUM_TYPE
Mesh
::
GetDataCapacity
(
const
INMOST_DATA_BULK_TYPE
*
adata
,
INMOST_DATA_ENUM_TYPE
size
,
const
Tag
&
tag
)
const
{
assert
(
tag
.
GetMeshLink
()
==
this
);
if
(
tag
.
GetDataType
()
!=
DATA_VARIABLE
)
return
size
*
tag
.
GetBytesSize
();
#if defined(USE_AUTODIFF)
else
{
INMOST_DATA_ENUM_TYPE
ret
=
0
;
const
Sparse
::
Row
::
entry
*
arr
=
static_cast
<
const
Sparse
::
Row
::
entry
*>
(
static_cast
<
const
void
*>
(
adata
));
for
(
INMOST_DATA_ENUM_TYPE
k
=
0
;
k
<
size
;
++
k
)
ret
+=
variable
::
RetriveSize
(
arr
+
ret
);
return
ret
*
sizeof
(
Sparse
::
Row
::
entry
);
}
#endif
assert
(
false
);
return
0
;
}
INMOST_DATA_ENUM_TYPE
Mesh
::
GetDataCapacity
(
HandleType
h
,
const
Tag
&
tag
)
const
{
assert
(
tag
.
GetMeshLink
()
==
this
);
...
...
@@ -2062,9 +2080,8 @@ namespace INMOST
{
INMOST_DATA_ENUM_TYPE
ret
=
0
;
const
inner_variable_array
*
arr
=
static_cast
<
const
inner_variable_array
*>
(
adata
);
ret
+=
arr
->
size
();
for
(
inner_variable_array
::
size_type
k
=
0
;
k
<
arr
->
size
();
++
k
)
ret
+=
(
*
arr
)[
k
].
GetRow
().
Size
();
ret
+=
(
*
arr
)[
k
].
RecordSize
();
//(*arr)[k].
GetRow().Size();
return
ret
*
sizeof
(
Sparse
::
Row
::
entry_s
);
}
#endif
...
...
@@ -2073,11 +2090,7 @@ namespace INMOST
}
#if defined(USE_AUTODIFF)
if
(
tag
.
GetDataType
()
==
DATA_VARIABLE
)
{
INMOST_DATA_ENUM_TYPE
ret
=
0
;
const
var
*
v
=
static_cast
<
const
var
*>
(
MGetLink
(
h
,
tag
));
return
(
1
+
v
->
GetRow
().
Size
())
*
sizeof
(
Sparse
::
Row
::
entry_s
);
}
return
static_cast
<
const
var
*>
(
MGetLink
(
h
,
tag
))
->
RecordSize
()
*
sizeof
(
Sparse
::
Row
::
entry_s
);
#endif
return
tag
.
GetSize
()
*
tag
.
GetBytesSize
();
}
...
...
@@ -2130,18 +2143,7 @@ namespace INMOST
Sparse
::
Row
::
entry_s
*
data
=
static_cast
<
Sparse
::
Row
::
entry_s
*>
(
data_out
);
int
k
=
0
;
for
(
INMOST_DATA_ENUM_TYPE
r
=
0
;
r
<
size
;
++
r
)
{
const
Sparse
::
Row
&
row
=
(
*
arr
)[
r
+
shift
].
GetRow
();
data
[
k
].
first
=
row
.
Size
();
data
[
k
].
second
=
(
*
arr
)[
r
+
shift
].
GetValue
();
++
k
;
for
(
INMOST_DATA_ENUM_TYPE
q
=
0
;
q
<
row
.
Size
();
++
q
)
{
data
[
k
].
first
=
row
.
GetIndex
(
q
);
data
[
k
].
second
=
row
.
GetValue
(
q
);
++
k
;
}
}
k
+=
(
*
arr
)[
r
+
shift
].
Record
(
data
+
k
);
}
break
;
#endif
...
...
@@ -2154,18 +2156,7 @@ namespace INMOST
const
var
*
v
=
static_cast
<
const
var
*>
(
MGetLink
(
h
,
tag
));
int
k
=
0
;
for
(
INMOST_DATA_ENUM_TYPE
r
=
0
;
r
<
size
;
++
r
)
{
const
Sparse
::
Row
&
row
=
v
[
shift
+
r
].
GetRow
();
data
[
k
].
first
=
row
.
Size
();
data
[
k
].
second
=
v
[
shift
+
r
].
GetValue
();
++
k
;
for
(
INMOST_DATA_ENUM_TYPE
r
=
0
;
r
<
row
.
Size
();
++
r
)
{
data
[
k
].
first
=
row
.
GetIndex
(
r
);
data
[
k
].
second
=
row
.
GetValue
(
r
);
++
k
;
}
}
k
+=
v
[
r
+
shift
].
Record
(
data
+
k
);
}
#endif
else
memcpy
(
data_out
,
static_cast
<
const
INMOST_DATA_BULK_TYPE
*>
(
adata
)
+
shift
*
bytes
,
size
*
bytes
);
...
...
@@ -2195,18 +2186,7 @@ namespace INMOST
const
Sparse
::
Row
::
entry_s
*
data
=
static_cast
<
const
Sparse
::
Row
::
entry_s
*>
(
data_in
);
int
k
=
0
;
for
(
INMOST_DATA_ENUM_TYPE
r
=
0
;
r
<
size
;
++
r
)
{
Sparse
::
Row
&
row
=
(
*
arr
)[
r
+
shift
].
GetRow
();
row
.
Resize
(
data
[
k
].
first
);
(
*
arr
)[
r
+
shift
].
SetValue
(
data
[
k
].
second
);
++
k
;
for
(
INMOST_DATA_ENUM_TYPE
q
=
0
;
q
<
row
.
Size
();
++
q
)
{
row
.
GetIndex
(
q
)
=
data
[
k
].
first
;
row
.
GetValue
(
q
)
=
data
[
k
].
second
;
++
k
;
}
}
k
+=
(
*
arr
)[
r
+
shift
].
Retrive
(
data
+
k
);
}
break
;
#endif
...
...
@@ -2219,18 +2199,7 @@ namespace INMOST
var
*
v
=
static_cast
<
var
*>
(
MGetLink
(
h
,
tag
));
int
k
=
0
;
for
(
INMOST_DATA_ENUM_TYPE
r
=
0
;
r
<
size
;
++
r
)
{
Sparse
::
Row
&
row
=
v
[
shift
+
r
].
GetRow
();
row
.
Resize
(
data
[
k
].
first
);
v
[
shift
+
r
].
SetValue
(
data
[
k
].
second
);
++
k
;
for
(
INMOST_DATA_ENUM_TYPE
r
=
0
;
r
<
row
.
Size
();
++
r
)
{
row
.
GetIndex
(
r
)
=
data
[
k
].
first
;
row
.
GetValue
(
r
)
=
data
[
k
].
second
;
++
k
;
}
}
k
+=
v
[
r
+
shift
].
Retrive
(
data
+
k
);
}
#endif
else
memcpy
(
static_cast
<
INMOST_DATA_BULK_TYPE
*>
(
adata
)
+
shift
*
bytes
,
data_in
,
size
*
bytes
);
...
...
@@ -2246,6 +2215,13 @@ namespace INMOST
{
if
(
tag
.
GetSize
()
==
ENUMUNDEF
)
TagManager
::
DestroyVariableData
(
tag
,
data
);
#if defined(USE_AUTODIFF)
else
if
(
tag
.
GetDataType
()
==
DATA_VARIABLE
)
//Have to deallocate the structure to remove inheritance
{
for
(
INMOST_DATA_ENUM_TYPE
k
=
0
;
k
<
tag
.
GetSize
();
++
k
)
(
static_cast
<
variable
*>
(
data
)[
k
]).
~
variable
();
}
#endif
//else if( tag.GetDataType() == DATA_REFERENCE )
// memset(data,0xff,tag.GetRecordSize());
else
memset
(
data
,
0
,
tag
.
GetRecordSize
());
...
...
@@ -2261,6 +2237,13 @@ namespace INMOST
{
if
(
tag
.
GetSize
()
==
ENUMUNDEF
)
TagManager
::
DestroyVariableData
(
tag
,
s
[
i
].
rec
);
#if defined(USE_AUTODIFF)
else
if
(
tag
.
GetDataType
()
==
DATA_VARIABLE
)
//Have to deallocate the structure to remove inheritance
{
for
(
INMOST_DATA_ENUM_TYPE
k
=
0
;
k
<
tag
.
GetSize
();
++
k
)
(
static_cast
<
variable
*>
(
s
[
i
].
rec
)[
k
]).
~
variable
();
}
#endif
free
(
s
[
i
].
rec
);
s
.
erase
(
s
.
begin
()
+
i
);
break
;
...
...
Source/Mesh/node.cpp
View file @
ae0bf6b1
...
...
@@ -154,7 +154,11 @@ namespace INMOST
{
adj_type
const
&
lc
=
m
->
LowConn
(
GetHandle
());
for
(
adj_type
::
size_type
it
=
0
;
it
<
lc
.
size
();
++
it
)
if
(
invert
^
m
->
GetMarker
(
lc
[
it
],
mask
)
)
aret
.
push_back
(
lc
[
it
]);
{
bool
mrk
=
m
->
GetMarker
(
lc
[
it
],
mask
);
bool
test
=
invert
^
mrk
;
if
(
test
)
aret
.
push_back
(
lc
[
it
]);
}
}
else
{
...
...
Source/Mesh/parallel.cpp
View file @
ae0bf6b1
...
...
@@ -2216,7 +2216,8 @@ namespace INMOST
// REPORT_VAL("value " << qq, (*(Storage::integer *)&array_data_recv[pos+qq*tag.GetBytesSize()]));
//}
op
(
tag
,
Element
(
this
,
*
eit
),
&
array_data_recv
[
pos
],
array_size_recv
[
k
]);
pos
+=
GetDataCapacity
(
*
eit
,
tag
);
// array_size_recv[k]*tag.GetBytesSize();
pos
+=
GetDataCapacity
(
&
array_data_recv
[
pos
],
array_size_recv
[
k
],
tag
);
//pos += array_size_recv[k]*tag.GetBytesSize();
++
k
;
++
total_unpacked
;
}
...
...
@@ -2228,7 +2229,8 @@ namespace INMOST
eit
=
elements
[
i
].
begin
()
+
array_size_recv
[
k
++
];
assert
(
!
select
||
GetMarker
(
*
eit
,
select
)
);
//if fires then very likely that marker was not synchronized
op
(
tag
,
Element
(
this
,
*
eit
),
&
array_data_recv
[
pos
],
size
);
pos
+=
GetDataCapacity
(
*
eit
,
tag
);
//size*tag.GetBytesSize();
pos
+=
GetDataCapacity
(
&
array_data_recv
[
pos
],
size
,
tag
);
//pos += size*tag.GetBytesSize();
++
total_unpacked
;
}
}
...
...
@@ -2240,7 +2242,8 @@ namespace INMOST
for
(
eit
=
elements
[
i
].
begin
();
eit
!=
elements
[
i
].
end
();
eit
++
)
if
(
!
select
||
GetMarker
(
*
eit
,
select
)
)
{
op
(
tag
,
Element
(
this
,
*
eit
),
&
array_data_recv
[
pos
],
array_size_recv
[
k
]);
pos
+=
GetDataCapacity
(
*
eit
,
tag
);
//array_size_recv[k]*tag.GetBytesSize();
pos
+=
GetDataCapacity
(
&
array_data_recv
[
pos
],
array_size_recv
[
k
],
tag
);
//pos += array_size_recv[k]*tag.GetBytesSize();
++
k
;
++
total_unpacked
;
}
...
...
@@ -2250,7 +2253,8 @@ namespace INMOST
for
(
eit
=
elements
[
i
].
begin
();
eit
!=
elements
[
i
].
end
();
eit
++
)
if
(
!
select
||
GetMarker
(
*
eit
,
select
)
)
{
op
(
tag
,
Element
(
this
,
*
eit
),
&
array_data_recv
[
pos
],
size
);
pos
+=
GetDataCapacity
(
*
eit
,
tag
);
//size*tag.GetBytesSize();
pos
+=
GetDataCapacity
(
&
array_data_recv
[
pos
],
size
,
tag
);
//pos += size*tag.GetBytesSize();
++
total_unpacked
;
}
}
...
...
Source/Solver/solver.cpp
View file @
ae0bf6b1
...
...
@@ -46,8 +46,8 @@
//#define USE_OMP
//
#define KSOLVER BCGSL_solver
#define KSOLVER BCGS_solver
#define KSOLVER BCGSL_solver
//
#define KSOLVER BCGS_solver
//#define ACCELERATED_CONDEST
//#define PRINT_CONDEST
...
...
@@ -64,7 +64,7 @@ namespace INMOST
#define GUARD_MPI(x) {ierr = x; if( ierr != MPI_SUCCESS ) {
std::cout << #x << " not successfull "
<< std::endl; MPI_Abort(comm,-1000);}}