Commit 9a92cf91 authored by Igor Konshin's avatar Igor Konshin

Merge branch 'master' of https://github.com/INMOST-DEV/INMOST

Conflicts:
	solver.cpp
parents b2d17c6f 8cfc4bfa
......@@ -101,6 +101,7 @@ option(COMPILE_TESTS "Compile some tests" OFF)
option(USE_PARTITIONER_PARMETIS "Use ParMetis partitioner" OFF)
option(USE_PARTITIONER_ZOLTAN "Use Zoltan partitioner" OFF)
option(USE_SOLVER_METIS "Use METIS for matrix reordering" OFF)
option(USE_SOLVER_MONDRIAAN "Use Mondriaan for matrix reordering" OFF)
option(USE_SOLVER_PETSC "Use PETSc solvers" OFF)
option(USE_SOLVER_TRILINOS "Use Trilinos solvers" OFF)
#option(USE_AUTODIFF_OPENCL "Use OpenCL for automatic differentiation (under work)" OFF)
......@@ -174,6 +175,20 @@ if(USE_SOLVER_METIS)
endif()
endif()
if(USE_SOLVER_MONDRIAAN)
find_package(MONDRIAAN)
if(NOT MONDRIAAN_FOUND)
set(USE_SOLVER_MONDRIAAN OFF)
message("Mondriaan NOT FOUND")
else()
link_directories(${MONDRIAAN_LIBRARY_DIRS})
include_directories(${MONDRIAAN_INCLUDE_DIRS})
set(USE_SOLVER_MONDRIAAN ON)
message("Mondriaan FOUND")
endif()
endif()
if(USE_PARTITIONER_ZOLTAN)
find_package(ZOLTAN)
if(NOT ZOLTAN_FOUND)
......
......@@ -2,6 +2,6 @@ Copy and paste contents of autoexp.dat into
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Packages\Debugger\autoexp.dat
or the directry where Visual Studio was installed.
In future capabilities will grove.
In future capabilities will grow.
Tested with Visual studio 2010.
Copyright (c) 2014-2015
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This folder contains scripts for CMake that aid in compilation of the INMOST library with third party libraries.
The original files were obtained through internet from the following projects:
- PETSc
- MSTK
- FindOpenCL
And may appear in original or modified form.
\ No newline at end of file
......@@ -34,6 +34,10 @@ if(OPENGL_FOUND)
message("linking DrawMatrix with Metis")
target_link_libraries(DrawMatrix ${METIS_LIBRARIES})
endif()
if(USE_SOLVER_MONDRIAAN)
message("linking DrawMatrix with Mondriaan")
target_link_libraries(DrawMatrix ${MONDRIAAN_LIBRARIES})
endif()
endif()
......
......@@ -25,6 +25,10 @@ if(USE_SOLVER)
message("linking FVDiscr with Metis")
target_link_libraries(FVDiscr ${METIS_LIBRARIES})
endif()
if(USE_SOLVER_MONDRIAAN)
message("linking FVDiscr with Mondriaan")
target_link_libraries(FVDiscr ${MONDRIAAN_LIBRARIES})
endif()
endif()
......
......@@ -128,6 +128,7 @@ int main(int argc,char ** argv)
ttt = Timer();
Solver S(Solver::INNER_ILU2); // Specify the linear solver to ASM+ILU2+BiCGStab one
S.SetParameterReal("absolute_tolerance",1e-8);
Solver::Matrix A; // Declare the matrix of the linear system to be solved
Solver::Vector x,b; // Declare the solution and the right-hand side vectors
......@@ -242,6 +243,8 @@ int main(int argc,char ** argv)
ttt = Timer();
Tag error = m->CreateTag("error",DATA_REAL,CELL,NONE,1);
Storage::real err_C = 0.0, err_L2 = 0.0;
for( Mesh::iteratorCell cell = m->BeginCell(); cell != m->EndCell(); ++cell )
if( cell->GetStatus() != Element::Ghost )
......@@ -251,6 +254,7 @@ int main(int argc,char ** argv)
if (err > err_C)
err_C = err;
err_L2 += err * err * cell->Volume();
cell->Real(error) = err;
// x[cell->Integer(id)] = err;
}
err_C = m->AggregateMax(err_C); // Compute the maximal C norm for the error
......
......@@ -33,6 +33,10 @@ if(USE_SOLVER)
message("linking MatSolve with Metis")
target_link_libraries(MatSolve ${METIS_LIBRARIES})
endif()
if(USE_SOLVER_MONDRIAAN)
message("linking MatSolve with Mondriaan")
target_link_libraries(MatSolve ${MONDRIAAN_LIBRARIES})
endif()
endif()
......
......@@ -538,6 +538,7 @@ class incident_matrix
}
return success;
}
/*
Storage::real compute_measure(dynarray<T,64> & data)
{
Storage::real measure = 0;
......@@ -622,6 +623,7 @@ class incident_matrix
}
return measure;
}
*/
void recursive_find(unsigned node, unsigned length)
{
if( !min_loop.empty() && length > min_loop.size() ) return;
......@@ -851,7 +853,7 @@ public:
}
} while( min_loop.empty() && first != UINT_MAX );
for(dynarray<T,64>::iterator it = min_loop.begin(); it != min_loop.end(); ++it)
for(typename dynarray<T,64>::iterator it = min_loop.begin(); it != min_loop.end(); ++it)
ret.push_back(it->self());
//ret.insert(ret.end(),min_loop.begin(),min_loop.end());
min_loop.clear();
......
This diff is collapsed.
......@@ -168,6 +168,46 @@ void rotatevector(double * vec)
vec[2] = ret[2]/ret[3];
}
void reverse_rotatevector(double * vec)
{
int i;
double rot[16];
double temp[4] = {vec[0],vec[1],vec[2],1.0};
double ret[4];
q.x = -q.x;
q.y = -q.y;
q.z = -q.z;
rot[ 0] = (q.w*q.w + q.x*q.x - q.y*q.y - q.z*q.z);
rot[ 1] = 2.*(q.x*q.y - q.w*q.z);
rot[ 2] = 2.*(q.x*q.z + q.w*q.y);
rot[ 3] = 0.0;
rot[ 4] = 2.*(q.x*q.y + q.w*q.z);
rot[ 5] = (q.w*q.w - q.x*q.x + q.y*q.y - q.z*q.z);
rot[ 6] = 2.*(q.y*q.z - q.w*q.x);
rot[ 7] = 0.0;
rot[ 8] = 2.*(q.x*q.z - q.w*q.y);
rot[ 9] = 2.*(q.y*q.z + q.w*q.x);
rot[10] = (q.w*q.w - q.x*q.x - q.y*q.y + q.z*q.z);
rot[11] = 0.0;
rot[12] = 0.0;
rot[13] = 0.0;
rot[14] = 0.0;
rot[15] = (q.w*q.w + q.x*q.x + q.y*q.y + q.z*q.z);
for(i=0; i < 4; i++)
{
ret[i] = temp[0] * rot[i*4];
ret[i] += temp[1] * rot[i*4+1];
ret[i] += temp[2] * rot[i*4+2];
ret[i] += temp[3] * rot[i*4+3];
}
vec[0] = ret[0]/ret[3];
vec[1] = ret[1]/ret[3];
vec[2] = ret[2]/ret[3];
q.x = -q.x;
q.y = -q.y;
q.z = -q.z;
}
void revrotatevector(double * vec)
{
int i;
......@@ -240,6 +280,51 @@ void rotatevector_from_stack(double * vec)
vec[2] = ret[2]/ret[3];
}
void quatget(double *vec)
{
vec[0] = q.x / q.w;
vec[1] = q.y / q.w;
vec[2] = q.z / q.w;
}
void reverse_rotatevector_from_stack(double * vec)
{
int i;
struct quaternion q = storage.back();
q.x = -q.x;
q.y = -q.y;
q.z = -q.z;
double rot[16];
double temp[4] = {vec[0],vec[1],vec[2],1.0};
double ret[4];
rot[ 0] = (q.w*q.w + q.x*q.x - q.y*q.y - q.z*q.z);
rot[ 1] = 2.*(q.x*q.y - q.w*q.z);
rot[ 2] = 2.*(q.x*q.z + q.w*q.y);
rot[ 3] = 0.0;
rot[ 4] = 2.*(q.x*q.y + q.w*q.z);
rot[ 5] = (q.w*q.w - q.x*q.x + q.y*q.y - q.z*q.z);
rot[ 6] = 2.*(q.y*q.z - q.w*q.x);
rot[ 7] = 0.0;
rot[ 8] = 2.*(q.x*q.z - q.w*q.y);
rot[ 9] = 2.*(q.y*q.z + q.w*q.x);
rot[10] = (q.w*q.w - q.x*q.x - q.y*q.y + q.z*q.z);
rot[11] = 0.0;
rot[12] = 0.0;
rot[13] = 0.0;
rot[14] = 0.0;
rot[15] = (q.w*q.w + q.x*q.x + q.y*q.y + q.z*q.z);
for(i=0; i < 4; i++)
{
ret[i] = temp[0] * rot[i*4];
ret[i] += temp[1] * rot[i*4+1];
ret[i] += temp[2] * rot[i*4+2];
ret[i] += temp[3] * rot[i*4+3];
}
vec[0] = ret[0]/ret[3];
vec[1] = ret[1]/ret[3];
vec[2] = ret[2]/ret[3];
}
void rotate()
{
double rot[16];
......
......@@ -20,13 +20,16 @@
void clickmotion(int nmx, int nmy);
void motion(int nmx, int nmy);
void click(int b, int s, int nmx, int nmy);
void quatget(double * vec);
void quatinit();
void quatpush();
void quatpop();
void rotate();
void rotate_from_stack();
void rotatevector(double * vec);
void reverse_rotatevector(double * vec);
void revrotatevector(double * vec);
void rotatevector_from_stack(double * vec);
void reverse_rotatevector_from_stack(double * vec);
#endif
......@@ -25,6 +25,10 @@ if(USE_SOLVER)
message("linking Solver with Metis")
target_link_libraries(Solver ${METIS_LIBRARIES})
endif()
if(USE_SOLVER_MONDRIAAN)
message("linking Solver with Mondriaan")
target_link_libraries(Solver ${MONDRIAAN_LIBRARIES})
endif()
endif(USE_SOLVER)
if(USE_PARTITIONER)
......
......@@ -529,6 +529,9 @@ namespace INMOST
void Mesh::GetGeometricData(HandleType e, GeometricData type, Storage::real * ret)
{
assert(e != InvalidHandle());
assert(ret != NULL);
assert(type == MEASURE || type == CENTROID || type == BARYCENTER || type == NORMAL);
ElementType etype = GetHandleElementType(e);
integer edim = Element::GetGeometricDimension(GetGeometricType(e));
integer mdim = GetDimensions();
......
......@@ -27,6 +27,8 @@ set(INMOST_LIBRARIES inmost)
set(USE_MPI @USE_MPI@)
set(USE_PARTITIONER_ZOLTAN @USE_PARTITIONER_ZOLTAN@)
set(USE_PARTITIONER_PARMETIS @USE_PARTITIONER_PARMETIS@)
set(USE_SOLVER_MONDRIAAN @USE_SOLVER_MONDRIAAN@)
set(USE_SOLVER_METIS @USE_SOLVER_METIS@)
set(USE_SOLVER_TRILINOS @USE_SOLVER_TRILINOS@)
set(USE_SOLVER_PETSC @USE_SOLVER_PETSC@)
......@@ -49,6 +51,16 @@ if( USE_PARTITIONER_PARMETIS )
list(APPEND INMOST_INCLUDE_DIRS "@METIS_INCLUDE_DIR@")
endif( USE_PARTITIONER_PARMETIS )
if( USE_SOLVER_MONDRIAAN )
list(APPEND INMOST_LIBRARIES "@MONDRIAAN_LIBRARIES@")
list(APPEND INMOST_INCLUDE_DIRS "@MONDRIAAN_INCLUDE_DIRS@")
list(APPEND INMOST_LIBRARY_DIRS "@MONDRIAAN_LIBRARY_DIRS@")
endif( USE_SOLVER_MONDRIAAN )
if( USE_SOLVER_METIS )
list(APPEND INMOST_LIBRARIES "@METIS_LIBRARIES@")
list(APPEND INMOST_INCLUDE_DIRS "@METIS_INCLUDE_DIR@")
endif( USE_SOLVER_METIS )
if( USE_SOLVER_TRILINOS )
list(APPEND INMOST_LIBRARIES "@Trilinos_LIBRARIES@")
......
......@@ -137,7 +137,7 @@ namespace INMOST
__INLINE INMOST_DATA_INTEGER_TYPE GetHandleElementNum (HandleType h) {return h >> handle_etype_shift;}
__INLINE ElementType GetHandleElementType (HandleType h) {return 1 << GetHandleElementNum(h);}
__INLINE HandleType ComposeHandle (ElementType etype, INMOST_DATA_INTEGER_TYPE ID) {return ID == -1 ? InvalidHandle() : ((ElementNum(etype) << handle_etype_shift) + (1+ID));}
__INLINE HandleType ComposeHandle (INMOST_DATA_INTEGER_TYPE etypenum, INMOST_DATA_INTEGER_TYPE ID) {return ID == -1 ? InvalidHandle() : ((etypenum << handle_etype_shift) + (1+ID));}
__INLINE HandleType ComposeHandleNum (INMOST_DATA_INTEGER_TYPE etypenum, INMOST_DATA_INTEGER_TYPE ID) {return ID == -1 ? InvalidHandle() : ((etypenum << handle_etype_shift) + (1+ID));}
__INLINE bool isValidHandle (HandleType h) {return h != 0;}
......@@ -2356,7 +2356,7 @@ namespace INMOST
void Exit ();
int & GetFuncID () {return func_id;}
std::fstream & GetStream ();
std::fstream & WriteTab (std::fstream & f);
std::ostream & WriteTab (std::ostream & f);
void FinalizeFile ();
static void AtExit (void);
#endif
......@@ -2933,7 +2933,7 @@ namespace INMOST
void EndSequentialCode ();
//iterator.cpp::::::::::::::::::::::::::::::::::::::::::::::::::
public:
Element ElementByLocalID (integer etypenum, integer lid) {assert(etypenum < 5 && (lid >= 0 && lid < static_cast<integer>(links[etypenum].size())) || (etypenum == 5 && lid == 0)); return Element(this,ComposeHandle(etypenum,lid));}
Element ElementByLocalID (integer etypenum, integer lid) {assert(etypenum < 5 && (lid >= 0 && lid < static_cast<integer>(links[etypenum].size())) || (etypenum == 5 && lid == 0)); return Element(this,ComposeHandleNum(etypenum,lid));}
Element ElementByLocalID (ElementType etype, integer lid) {return ElementByLocalID(ElementNum(etype),lid);}
Element ElementByHandle (HandleType h) {return Element(this,h);}
......@@ -2941,16 +2941,16 @@ namespace INMOST
HandleType PrevHandle (HandleType h) const; //returns InvalidHandle() when go beyond first element
HandleType NextHandle (HandleType h, ElementType mask) const;
HandleType PrevHandle (HandleType h, ElementType mask) const; //returns InvalidHandle() when go beyond first element
HandleType FirstHandle () const {return ComposeHandle(ElementNum(NODE),0);}
HandleType LastHandle () const {return ComposeHandle(ElementNum(MESH),1);}
HandleType FirstHandle (ElementType etype) const {return ComposeHandle(ElementNum(etype),0);}
HandleType LastHandle (ElementType etype) const {integer num = ElementNum(etype); return ComposeHandle(num,static_cast<integer>(links[num].size()));}
HandleType FirstHandle () const {return ComposeHandleNum(ElementNum(NODE),0);}
HandleType LastHandle () const {return ComposeHandleNum(ElementNum(MESH),1);}
HandleType FirstHandle (ElementType etype) const {return ComposeHandleNum(ElementNum(etype),0);}
HandleType LastHandle (ElementType etype) const {integer num = ElementNum(etype); return ComposeHandleNum(num,static_cast<integer>(links[num].size()));}
Node NodeByLocalID (integer lid) { assert(lid >= 0 && lid < static_cast<integer>(links[0].size())); return Node(this,ComposeHandle(0,lid)); }
Edge EdgeByLocalID (integer lid) { assert(lid >= 0 && lid < static_cast<integer>(links[1].size())); return Edge(this,ComposeHandle(1,lid)); }
Face FaceByLocalID (integer lid) { assert(lid >= 0 && lid < static_cast<integer>(links[2].size())); return Face(this,ComposeHandle(2,lid));}
Cell CellByLocalID (integer lid) { assert(lid >= 0 && lid < static_cast<integer>(links[3].size())); return Cell(this,ComposeHandle(3,lid)); }
ElementSet EsetByLocalID (integer lid) { assert(lid >= 0 && lid < static_cast<integer>(links[4].size())); return ElementSet(this,ComposeHandle(4,lid)); }
Node NodeByLocalID (integer lid) { assert(lid >= 0 && lid < static_cast<integer>(links[0].size())); return Node(this,ComposeHandleNum(0,lid)); }
Edge EdgeByLocalID (integer lid) { assert(lid >= 0 && lid < static_cast<integer>(links[1].size())); return Edge(this,ComposeHandleNum(1,lid)); }
Face FaceByLocalID (integer lid) { assert(lid >= 0 && lid < static_cast<integer>(links[2].size())); return Face(this,ComposeHandleNum(2,lid));}
Cell CellByLocalID (integer lid) { assert(lid >= 0 && lid < static_cast<integer>(links[3].size())); return Cell(this,ComposeHandleNum(3,lid)); }
ElementSet EsetByLocalID (integer lid) { assert(lid >= 0 && lid < static_cast<integer>(links[4].size())); return ElementSet(this,ComposeHandleNum(4,lid)); }
integer NodeNextLocalID (integer lid) const {++lid; while(lid < static_cast<integer>(links[0].size()) && links[0][lid] == -1) ++lid; return lid;}
integer EdgeNextLocalID (integer lid) const {++lid; while(lid < static_cast<integer>(links[1].size()) && links[1][lid] == -1) ++lid; return lid;}
......
......@@ -15,6 +15,7 @@
#cmakedefine USE_PARTITIONER_PARMETIS
#cmakedefine USE_SOLVER
#cmakedefine USE_SOLVER_MONDRIAAN
#cmakedefine USE_SOLVER_METIS
#cmakedefine USE_SOLVER_PETSC
#cmakedefine USE_SOLVER_TRILINOS
......
......@@ -50,7 +50,7 @@ namespace INMOST
else break;
}
if( num == 5 && id > 0 ) id = 1;
return ComposeHandle(num,id);
return ComposeHandleNum(num,id);
}
HandleType Mesh::PrevHandle(HandleType h) const
......@@ -61,7 +61,7 @@ namespace INMOST
{
if( id < 0 )
num = 4;
else return ComposeHandle(ElementNum(MESH),0);
else return ComposeHandleNum(ElementNum(MESH),0);
}
while( num >= 0 )
{
......@@ -74,7 +74,7 @@ namespace INMOST
else break;
}
if( num < 0 ) return InvalidHandle();
return ComposeHandle(num,id);
return ComposeHandleNum(num,id);
}
HandleType Mesh::NextHandle(HandleType h, ElementType etype) const
......@@ -102,7 +102,7 @@ namespace INMOST
else break;
}
if( num == 5 && id > 0 ) id = 1;
return ComposeHandle(num,id);
return ComposeHandleNum(num,id);
}
HandleType Mesh::PrevHandle(HandleType h, ElementType etype) const
......@@ -127,7 +127,7 @@ namespace INMOST
}
if( stop ) return InvalidHandle();
}
else return ComposeHandle(ElementNum(MESH),0);
else return ComposeHandleNum(ElementNum(MESH),0);
}
while( num >= 0 )
{
......@@ -150,7 +150,7 @@ namespace INMOST
else break;
}
if( num < 0 ) return InvalidHandle();
return ComposeHandle(num,id);
return ComposeHandleNum(num,id);
}
Storage::integer Mesh::FirstLocalID(ElementType etype) const
......
......@@ -440,7 +440,7 @@ namespace INMOST
#endif //USE_MPI
#if defined(USE_PARALLEL_WRITE_TIME)
FinalizeFile();
out_time.close();
for(size_t q = 0; q < allocated_meshes.size(); ++q)
if (allocated_meshes[q] == this)
allocated_meshes[q] = NULL;
......@@ -862,7 +862,7 @@ namespace INMOST
Node Mesh::CreateNode(const real * coords)
{
integer id = TieElement(0);
HandleType h = ComposeHandle(0,id);
HandleType h = ComposeHandleNum(0,id);
SetGeometricType(h,Element::Vertex);
real * v = static_cast<Storage::real *>(MGetDenseLink(h,CoordsTag()));
for(integer i = 0; i < dim; i++) v[i] = coords[i];
......@@ -912,7 +912,7 @@ namespace INMOST
if (test != InvalidHandle()) return std::make_pair(Edge(this,test),false);
}
integer id = TieElement(1);
he = ComposeHandle(1,id);
he = ComposeHandleNum(1,id);
for(ElementArray<Node>::size_type i = 0; i < nodes.size(); i++)
{
Element::adj_type & hc = HighConn(nodes.at(i));
......@@ -1004,7 +1004,7 @@ namespace INMOST
if (test != InvalidHandle()) return std::make_pair(Face(this,test),false);
}
integer id = TieElement(2);
he = ComposeHandle(2,id);
he = ComposeHandleNum(2,id);
for(ElementArray<Edge>::size_type i = 0; i < f_edges.size(); i++)
{
Element::adj_type & hc = HighConn(f_edges.at(i));
......@@ -1374,7 +1374,7 @@ namespace INMOST
if (test != InvalidHandle()) return std::make_pair(Cell(this,test),false);
}
integer id = TieElement(3);
he = ComposeHandle(3,id);
he = ComposeHandleNum(3,id);
for(ElementArray<Face>::size_type i = 0; i < c_faces.size(); i++)
{
Element::adj_type & hc = HighConn(c_faces.at(i));
......@@ -1476,7 +1476,7 @@ namespace INMOST
if( e->GetName() == name )
return std::make_pair(e->self(),false);
}
HandleType he = ComposeHandle(4,TieElement(4));
HandleType he = ComposeHandleNum(4,TieElement(4));
bulk_array set_name = BulkArrayDV(he,SetNameTag());
set_name.resize(static_cast<bulk_array::size_type>(name.size()));
memcpy(set_name.data(),name.c_str(),name.size());
......@@ -1498,7 +1498,7 @@ namespace INMOST
Storage::integer j = 0;
for(Storage::integer k = 0; k < NodeLastLocalID(); ++k) if( isValidElement(0,k) )
{
memcpy(temp.data()+j,MGetDenseLink(ComposeHandle(0,k),CoordsTag()),sizeof(Storage::real)*dims);
memcpy(temp.data()+j,MGetDenseLink(ComposeHandleNum(0,k),CoordsTag()),sizeof(Storage::real)*dims);
j+=dims;
}
......@@ -1507,7 +1507,7 @@ namespace INMOST
j = 0;
for(Storage::integer k = 0; k < NodeLastLocalID(); ++k) if( isValidElement(0,k) )
{
memcpy(MGetDenseLink(ComposeHandle(0,k),CoordsTag()),temp.data()+j,sizeof(Storage::real)*dims);
memcpy(MGetDenseLink(ComposeHandleNum(0,k),CoordsTag()),temp.data()+j,sizeof(Storage::real)*dims);
j+=dims;
}
dim = dims;
......@@ -1536,7 +1536,7 @@ namespace INMOST
back_links[etypenum][ADDR] = -1;
empty_space[etypenum].push_back(ADDR);
empty_links[etypenum].push_back(ID);
//REPORT_VAL("destroyed",ComposeHandle(etypenum,ID) << " " << etypenum << " " << ADDR << " " << ID);
//REPORT_VAL("destroyed",ComposeHandleNum(etypenum,ID) << " " << etypenum << " " << ADDR << " " << ID);
}
}
......@@ -1576,7 +1576,7 @@ namespace INMOST
new_size = GetArrayCapacity(etypenum);
if( new_size != old_size ) ReallocateData(etypenum,new_size);
back_links[etypenum][ADDR] = ID;
last_created = ComposeHandle(etypenum,ID);
last_created = ComposeHandleNum(etypenum,ID);
//REPORT_VAL("created",last_created << " " << etypenum << " " << ADDR << " " << ID);
}
return ID;
......
This diff is collapsed.
This diff is collapsed.
......@@ -346,9 +346,17 @@ namespace INMOST
{
queue.push_back(*it);
m->Integer(queue.back(),index) = visited++;
if( visited % chunk == 0 )
{
queue.clear();
break;
}
}
}
if( visited % chunk == 0 ) queue.clear();
//this may not fire properly
//if( visited % chunk == 0 ) queue.clear();
}
}
m->DeleteTag(order);
......
#define _CRT_SECURE_NO_WARNINGS
#include "inmost_solver.h"
#if defined(USE_SOLVER)
#include "solver_petsc.h"
......@@ -1337,37 +1338,47 @@ namespace INMOST
(void)argv;
if( database != NULL )
{
std::fstream file(database,std::ios::in);
char str[4096];
while( !file.eof() && file.getline(str,4096) )
{
int k = 0, l;
for(k = 0; k < (int)strlen(str); ++k)
{
if( str[k] == ':' ) break;
}
if( k == strlen(str) ) continue; //invalid line
for(l = 0; l < k; ++l) str[l] = tolower(str[l]);
l = k+1;
while(l < (int)strlen(str) && isspace(str[l]) ) ++l;
if( l == strlen(str) ) continue; //skip empty entry
if( !strncmp(str,"petsc",k) )
petsc_database_file = std::string(str+l);
else if( !strncmp(str,"trilinos_ifpack",k) )
trilinos_ifpack_database_file = std::string(str+l);
else if( !strncmp(str,"trilinos_aztec",k) )
trilinos_aztec_database_file = std::string(str+l);
else if( !strncmp(str,"trilinos_ml",k) )
trilinos_ml_database_file = std::string(str+l);
else if( !strncmp(str,"trilinos_belos",k) )
trilinos_belos_database_file = std::string(str+l);
else if( !strncmp(str,"ani",k) )
ani_database_file = std::string(str+l);
else if( !strncmp(str,"fcbiilu2",k) )
fcbiilu2_database_file = std::string(str+l);
else if( !strncmp(str,"k3biilu2",k) )
k3biilu2_database_file = std::string(str+l);
}
FILE * f = fopen(database,"r");
if( f )
{
//std::fstream file(database,std::ios::in);
char str[4096];
//while( !file.eof() && file.getline(str,4096) )
while( !feof(f) && fgets(str,4096,f) )
{
int k = 0, l;
for(k = 0; k < (int)strlen(str); ++k)
{
if( str[k] == ':' ) break;
}
if( k == strlen(str) ) continue; //invalid line
for(l = 0; l < k; ++l) str[l] = tolower(str[l]);
l = (int)strlen(str)-1; // Right-trim string
while(l > 0 && isspace(str[l]) ) --l;
str[l+1] = 0;
l = k+1;
while(l < (int)strlen(str) && isspace(str[l]) ) ++l;
if( l == strlen(str) ) continue; //skip empty entry
if( !strncmp(str,"petsc",k) )
petsc_database_file = std::string(str+l);
else if( !strncmp(str,"trilinos_ifpack",k) )
trilinos_ifpack_database_file = std::string(str+l);
else if( !strncmp(str,"trilinos_aztec",k) )
trilinos_aztec_database_file = std::string(str+l);
else if( !strncmp(str,"trilinos_ml",k) )
trilinos_ml_database_file = std::string(str+l);
else if( !strncmp(str,"trilinos_belos",k) )
trilinos_belos_database_file = std::string(str+l);
else if( !strncmp(str,"ani",k) )
ani_database_file = std::string(str+l);
else if( !strncmp(str,"fcbiilu2",k) )
fcbiilu2_database_file = std::string(str+l);
else if( !strncmp(str,"k3biilu2",k) )
k3biilu2_database_file = std::string(str+l);
}
//file.close();
fclose(f);
}
}
//std::cout << "PETSc \"" << petsc_database_file << "\"" << std::endl;
//std::cout << "Trilinos_Ifpack \"" << trilinos_ifpack_database_file << "\"" << std::endl;
......
......@@ -46,13 +46,15 @@ namespace INMOST
shell<INMOST_DATA_REAL_TYPE> u(pu,n*n);
shell<INMOST_DATA_REAL_TYPE> v(pv,n*n);
shell<INMOST_DATA_REAL_TYPE> w(pw,n);
std::copy(a.begin(),a.end(),u.begin());
//std::copy(a.begin(),a.end(),u.begin());
//memcpy(u,a,sizeof(INMOST_DATA_REAL_TYPE)*n*n);
int flag, i, its, j, jj, k, l, nm;
INMOST_DATA_REAL_TYPE c, f, h, s, x, y, z;
INMOST_DATA_REAL_TYPE anorm = 0.0, g = 0.0, scale = 0.0;
static std::vector<INMOST_DATA_REAL_TYPE> rv1(n);
dynarray<INMOST_DATA_REAL_TYPE,64> rv1;
rv1.resize(n);
// Householder reduction to bidiagonal form
for (i = 0; i < n*n; ++i) u[i] = a[i];
for (i = 0; i < n; i++)
{
// left-hand reduction
......@@ -624,13 +626,13 @@ namespace INMOST
}
#endif
INMOST_DATA_ENUM_TYPE i = 0;
bool halt = false;
if( last_resid < atol || last_resid < rtol*resid0 )
{
reason = "initial solution satisfy tolerances";
goto exit;
halt = true;
}
#if defined(USE_OMP)
#pragma omp parallel
#endif
......@@ -826,17 +828,24 @@ namespace INMOST
sigma[j-1] = sigma_sum;
}
#if defined(CONVEX_COMBINATION)
INMOST_DATA_REAL_TYPE lagrangian = 0.0;
for(INMOST_DATA_ENUM_TYPE j = 0; j < l; j++) lagrangian += tau[j+size*j];
sigma[l] = lagrangian;
tau[(l+1)*(l+1)-1] = 0.0;
for(INMOST_DATA_ENUM_TYPE j = 0; j < l; j++)
#if defined(USE_OMP)
#pragma omp single
#endif
{
tau[l + j*(l+1)] = -lagrangian;
tau[l*(l+1)+j] = lagrangian;
INMOST_DATA_REAL_TYPE lagrangian = 0.0;
for(INMOST_DATA_ENUM_TYPE j = 0; j < l; j++) lagrangian += tau[j+size*j];
sigma[l] = lagrangian;
tau[(l+1)*(l+1)-1] = 0.0;
for(INMOST_DATA_ENUM_TYPE j = 0; j < l; j++)
{
tau[l + j*(l+1)] = -lagrangian;
tau[l*(l+1)+j] = lagrangian;
}
}
#endif
info->Integrate(tau,size*size+size); //sigma is updated with tau
info->Integrate(tau,(l+2)*(l+1)); //sigma is updated with tau
//info->Integrate(tau,size*size);
//info->Integrate(sigma,size);
#if defined(USE_OMP)
#pragma omp single
......@@ -1136,7 +1145,6 @@ namespace INMOST