Unverified Commit 1b369e53 authored by Kirill Terekhov's avatar Kirill Terekhov Committed by GitHub

Merge branch 'master' into andre_branch

parents 4d363998 d9a63eb6
......@@ -12,3 +12,5 @@ Source/Solver/solver_fcbiilu2/fcbiilu2.cpp
Source/Solver/solver_k3biilu2/k3d.cpp
Source/Solver/solver_k3biilu2/k3d.h
.vscode/*
......@@ -265,6 +265,9 @@ endif(COMPILE_TESTS)
set(INMOST_INSTALL_HEADERS Source/Headers/inmost.h
Source/Headers/inmost_autodiff.h
Source/Headers/inmost_residual.h
Source/Headers/inmost_model.h
Source/Headers/inmost_operator.h
Source/Headers/inmost_common.h
Source/Headers/inmost_data.h
Source/Headers/inmost_dense.h
......@@ -276,6 +279,7 @@ set(INMOST_INSTALL_HEADERS Source/Headers/inmost.h
Source/Headers/inmost_sparse.h
Source/Headers/inmost_xml.h
Source/Headers/inmost_variable.h
Source/Headers/inmost_block_variable.h
Source/Headers/container.hpp)
......@@ -295,6 +299,9 @@ set_property(TARGET inmost PROPERTY PUBLIC_HEADER
"${PROJECT_BINARY_DIR}/inmost_options.h"
"${PROJECT_SOURCE_DIR}/Source/Headers/inmost.h"
"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_autodiff.h"
"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_residual.h"
"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_operator.h"
"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_model.h"
"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_common.h"
"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_data.h"
"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_dense.h"
......@@ -305,6 +312,7 @@ set_property(TARGET inmost PROPERTY PUBLIC_HEADER
"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_solver.h"
"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_sparse.h"
"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_variable.h"
"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_block_variable.h"
"${PROJECT_SOURCE_DIR}/Source/Headers/inmost_xml.h"
"${PROJECT_SOURCE_DIR}/Source/Headers/container.hpp")
......
......@@ -420,7 +420,7 @@ void draw()
glBegin(GL_QUADS);
for(Sparse::Matrix::iterator it = m->Begin(); it != m->End(); ++it)
for(Sparse::Row::iterator jt = it->Begin(); jt != it->End(); ++jt)
if( jt->first != it - m->Begin() )
if( jt->first != it - m->Begin() && jt->second)
//DrawEntry(ord->position((it - m->Begin())), m->Size() - ord->position(jt->first));//, sqrt((jt->second-min)/(max-min)));
DrawEntry(jt->first, m->Size() - (it - m->Begin()));//, sqrt((jt->second-min)/(max-min)));
glEnd();
......@@ -451,17 +451,17 @@ void draw()
}
glEnd();
zoom += 1;
//zoom += 1;
glColor3f(1.0, 0, 0);
glBegin(GL_QUADS);
for (Sparse::Matrix::iterator it = m->Begin(); it != m->End(); ++it)
{
int ind = it - m->Begin();
if (fabs((*it)[ind]) < 1e-9) //DrawEntry(ord->position((it - m->Begin())), m->Size() - ord->position(ind));
if (fabs((*it)[ind]) < 1e-13) //DrawEntry(ord->position((it - m->Begin())), m->Size() - ord->position(ind));
DrawEntry((it - m->Begin()), m->Size() - ind);
}
glEnd();
zoom -= 1;
//zoom -= 1;
if (CommonInput != NULL)
{
......
......@@ -9,6 +9,14 @@ add_executable(SliceFunc slice_func.cpp)
add_executable(SplitNonplanar split_nonplanar.cpp)
add_executable(CollapseDegenerate collapse_degenerate.cpp)
add_executable(Bnd2Stl bnd2stl.cpp)
add_executable(Sector sector.cpp)
add_executable(Sew sew.cpp)
add_executable(Scale scale.cpp)
add_executable(Move move.cpp)
add_executable(Convert convert.cpp)
add_executable(SameMeshDifference difference_same.cpp)
add_executable(MeshDifference difference_map.cpp)
add_library(FractureLib fracture.cpp fracture.h)
target_link_libraries(FixFaults inmost)
if(USE_MPI)
......@@ -106,4 +114,82 @@ if(USE_MPI)
endif(USE_MPI)
install(TARGETS Bnd2Stl EXPORT inmost-targets RUNTIME DESTINATION bin)
target_link_libraries(Sector inmost)
if(USE_MPI)
message("linking Sector with MPI")
target_link_libraries(Sector ${MPI_LIBRARIES})
if(MPI_LINK_FLAGS)
set_target_properties(Sector PROPERTIES LINK_FLAGS "${MPI_LINK_FLAGS}")
endif()
endif(USE_MPI)
install(TARGETS Sector EXPORT inmost-targets RUNTIME DESTINATION bin)
target_link_libraries(Sew inmost)
if(USE_MPI)
message("linking Sew with MPI")
target_link_libraries(Sew ${MPI_LIBRARIES})
if(MPI_LINK_FLAGS)
set_target_properties(Sew PROPERTIES LINK_FLAGS "${MPI_LINK_FLAGS}")
endif()
endif(USE_MPI)
install(TARGETS Sew EXPORT inmost-targets RUNTIME DESTINATION bin)
target_link_libraries(Scale inmost)
if(USE_MPI)
message("linking Scale with MPI")
target_link_libraries(Scale ${MPI_LIBRARIES})
if(MPI_LINK_FLAGS)
set_target_properties(Scale PROPERTIES LINK_FLAGS "${MPI_LINK_FLAGS}")
endif()
endif(USE_MPI)
install(TARGETS Scale EXPORT inmost-targets RUNTIME DESTINATION bin)
target_link_libraries(Move inmost)
if(USE_MPI)
message("linking Move with MPI")
target_link_libraries(Move ${MPI_LIBRARIES})
if(MPI_LINK_FLAGS)
set_target_properties(Move PROPERTIES LINK_FLAGS "${MPI_LINK_FLAGS}")
endif()
endif(USE_MPI)
install(TARGETS Move EXPORT inmost-targets RUNTIME DESTINATION bin)
target_link_libraries(Convert inmost)
if(USE_MPI)
message("linking Convert with MPI")
target_link_libraries(Convert ${MPI_LIBRARIES})
if(MPI_LINK_FLAGS)
set_target_properties(Convert PROPERTIES LINK_FLAGS "${MPI_LINK_FLAGS}")
endif()
endif(USE_MPI)
install(TARGETS Convert EXPORT inmost-targets RUNTIME DESTINATION bin)
target_link_libraries(SameMeshDifference inmost)
if(USE_MPI)
message("linking SameMeshDifference with MPI")
target_link_libraries(SameMeshDifference ${MPI_LIBRARIES})
if(MPI_LINK_FLAGS)
set_target_properties(SameMeshDifference PROPERTIES LINK_FLAGS "${MPI_LINK_FLAGS}")
endif()
endif(USE_MPI)
install(TARGETS SameMeshDifference EXPORT inmost-targets RUNTIME DESTINATION bin)
target_link_libraries(MeshDifference inmost)
if(USE_MPI)
message("linking MeshDifference with MPI")
target_link_libraries(MeshDifference ${MPI_LIBRARIES})
if(MPI_LINK_FLAGS)
set_target_properties(MeshDifference PROPERTIES LINK_FLAGS "${MPI_LINK_FLAGS}")
endif()
endif(USE_MPI)
install(TARGETS MeshDifference EXPORT inmost-targets RUNTIME DESTINATION bin)
set_property(TARGET FractureLib PROPERTY PUBLIC_HEADER "${CMAKE_CURRENT_SOURCE_DIR}/fracture.h")
install(TARGETS FractureLib EXPORT inmost-targets
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
PUBLIC_HEADER DESTINATION include)
#include <stdio.h>
#include "inmost.h"
using namespace INMOST;
typedef Storage::real real;
typedef Storage::real_array real_array;
int main(int argc, char ** argv)
{
if( argc < 3 )
{
printf("Usage: %s input_mesh1 [input_mesh2] ... output_format\n",argv[0]);
return -1;
}
std::string output_fmt = argv[argc-1];
std::cout << "Output format: " << output_fmt << std::endl;
for(int k = 1 ; k < argc-1; ++k)
{
Mesh m;
std::string load_file = std::string(argv[k]);
std::string save_file = load_file.substr(0,load_file.find_last_of(".")) + "." + output_fmt;
std::cout << load_file << " -> " << save_file << std::endl;
m.Load(load_file);
m.Save(save_file);
}
return 0;
}
This diff is collapsed.
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "inmost.h"
using namespace INMOST;
int main(int argc, char *argv[])
{
if (argc < 3)
{
std::cout << "Usage: " << argv[0] ;
std::cout << " mesh1 mesh2" << std::endl;
return -1;
}
Mesh m1,m2;
//m1.SetFileOption("VTK_GRID_DIMS","2");
//m2.SetFileOption("VTK_GRID_DIMS","2");
m1.SetFileOption("VERBOSITY","2");
m2.SetFileOption("VERBOSITY","2");
m1.Load(argv[1]);
m2.Load(argv[2]);
Tag volumes_tag = m1.CreateTag("VOLUMES_FOR_NORMS_CALCULATION",DATA_REAL,CELL|FACE|EDGE|NODE,NONE,1);
for(ElementType etype = NODE; etype <= CELL; etype = etype << 1)
{
for(int id = 0; id < m1.LastLocalID(etype); id++)
{
Element c1 = m1.ElementByLocalID(etype,id);
if( c1.isValid() )
{
Storage::real vol = 0;
ElementArray<Cell> cells = c1.getCells();
for(ElementArray<Cell>::iterator it = cells.begin(); it != cells.end(); ++it)
{
vol += it->Volume() / static_cast<Storage::real>(it->nbAdjElements(etype));
}
c1->RealDF(volumes_tag) = vol;
}
}
}
for(Mesh::iteratorTag t = m1.BeginTag(); t != m1.EndTag(); t++)
{
if( *t == m1.CoordsTag() ) continue;
if( t->GetSize() == ENUMUNDEF ) continue;
if( t->GetDataType() != DATA_REAL ) continue;
if( m2.HaveTag(t->GetTagName()) )
{
Tag t2 = m2.GetTag(t->GetTagName());
if( t->GetSize() != t2.GetSize() ) continue;
for(ElementType etype = NODE; etype <= CELL; etype = etype << 1)
{
if( m1.ElementDefined(*t,etype) && m2.ElementDefined(t2,etype) )
{
Storage::real Cnorm = 0, L1norm = 0, L2norm = 0, absval, Lvol = 0, vol;
for(int id = 0; id < m1.LastLocalID(etype); id++)
{
Element c1 = m1.ElementByLocalID(etype,id);
Element c2 = m2.ElementByLocalID(etype,id);
if( c1.isValid() && c2.isValid() )
{
vol = c1->RealDF(volumes_tag);
Storage::real_array arr1 = c1->RealArray(*t);
Storage::real_array arr2 = c2->RealArray(t2);
for(int k = 0; k < (int)arr1.size(); k++)
{
absval = fabs(arr1[k]-arr2[k]);
arr1[k] = absval;
if( Cnorm < absval ) Cnorm = absval;
L1norm += absval*vol;
L2norm += absval*absval*vol;
Lvol += vol;
}
}
}
std::cout << "Data " << t->GetTagName() << " on " << ElementTypeName(etype) << " Cnorm " << Cnorm << " L1norm " << L1norm/Lvol << " L2norm " << sqrt(L2norm/Lvol) << std::endl;
}
}
}
}
m1.DeleteTag(volumes_tag);
m1.Save("diff.gmv");
m1.Save("diff.vtk");
m1.Save("diff.pmf");
return 0;
}
This diff is collapsed.
#ifndef __FRACTURE_H
#define __FRACTURE_H
#include "inmost.h"
using namespace INMOST;
class Fracture
{
Mesh * m;
Tag fracture_aperture;
Tag fracture_volume;
Tag fracture_area;
MarkerType fracture_marker;
MarkerType multiple_fracture_joints;
MarkerType matrix_fracture;
public:
MarkerType isFracture() const {return fracture_marker;}
MarkerType MultipleJoints() const {return multiple_fracture_joints;}
MarkerType MatrixFracture() const {return matrix_fracture;}
///Default constructor, defines empty set.
Fracture(Mesh & _m) : m(&_m) {}
///Copy constructor.
Fracture(const Fracture & b) : m(b.m) {}
///Assignment operator.
Fracture & operator = (Fracture const & b) {m = b.m; return * this;}
INMOST_DATA_REAL_TYPE Volume(Cell c) const;
INMOST_DATA_REAL_TYPE Area(Face f) const;
void FaceCenter(Face f, INMOST_DATA_REAL_TYPE cnt[3]) const;
void Open(Tag aperture);
};
#endif //__FRACTURE_H
\ No newline at end of file
#include <stdio.h>
#include "inmost.h"
using namespace INMOST;
typedef Storage::real real;
typedef Storage::real_array real_array;
int main(int argc, char ** argv)
{
if( argc < 2 )
{
printf("Usage: %s input_mesh [move_x=1] [move_y=1] [move_z=1] [output_mesh]\n",argv[0]);
return -1;
}
Mesh m;
m.Load(argv[1]);
double mx = argc > 2 ? atof(argv[2]) : 1;
double my = argc > 3 ? atof(argv[3]) : 1;
double mz = argc > 4 ? atof(argv[4]) : 1;
std::string save_file = argc > 5 ? std::string(argv[5]) : "out.vtk";
double xmax = -1.0e20, xmin = 1.0e20;
double ymax = -1.0e20, ymin = 1.0e20;
double zmax = -1.0e20, zmin = 1.0e20;
for(Mesh::iteratorNode n = m.BeginNode(); n != m.EndNode(); ++n)
{
double x = n->Coords()[0], y = n->Coords()[1], z = n->Coords()[2];
if( x > xmax ) xmax = x;
if( x < xmin ) xmin = x;
if( y > ymax ) ymax = y;
if( y < ymin ) ymin = y;
if( z > zmax ) zmax = z;
if( z < zmin ) zmin = z;
}
std::cout << "x: " << xmin << ":" << xmax << std::endl;
std::cout << "y: " << ymin << ":" << ymax << std::endl;
std::cout << "z: " << zmin << ":" << zmax << std::endl;
for(Mesh::iteratorNode n = m.BeginNode(); n != m.EndNode(); ++n)
{
n->Coords()[0] += mx;
n->Coords()[1] += my;
n->Coords()[2] += mz;
}
xmax = -1.0e20, xmin = 1.0e20;
ymax = -1.0e20, ymin = 1.0e20;
zmax = -1.0e20, zmin = 1.0e20;
for(Mesh::iteratorNode n = m.BeginNode(); n != m.EndNode(); ++n)
{
double x = n->Coords()[0], y = n->Coords()[1], z = n->Coords()[2];
if( x > xmax ) xmax = x;
if( x < xmin ) xmin = x;
if( y > ymax ) ymax = y;
if( y < ymin ) ymin = y;
if( z > zmax ) zmax = z;
if( z < zmin ) zmin = z;
}
std::cout << "x: " << xmin << ":" << xmax << std::endl;
std::cout << "y: " << ymin << ":" << ymax << std::endl;
std::cout << "z: " << zmin << ":" << zmax << std::endl;
std::cout << "Save to " << save_file << std::endl;
m.Save(save_file);
return 0;
}
......@@ -18,3 +18,34 @@ unite_faces - Unite faces of the cell that share the same adjacent cell, some ed
mesh_input - general polyhedral grid
mesh_output - output general polyhedral grid with united faces, default grid.vtk
difference_same - Computes difference between the real data on all elements of two similar grids
and writes the grid with the difference. It writes absolute value of difference.
Outputs L_inf, L_1, L_2 norms of the difference.
Similar grids means their grid blocks order should match between each other
Usage:
difference_same mesh_file1 mesh_file2
mesh_file1 - first mesh file
mesh_file2 - second mesh file
difference_map - Computes difference between the real data on cells of two different grids
and writes both grids with the difference. It writes absolute value of difference.
Outputs L_inf, L_1, L_2 norms of the difference.
It will map cells between two grids by checking which cell centers on one grid
fit into which cells on the other and vice verse, resulting in bijective mapping.
Then for each cell on one grid difference between it's value and mean value
of it's mapping is calculated.
Usage:
difference_map mesh_input1 mesh_input2 [mesh_output1] [mesh_output2]
mesh_input1 - first mesh file
mesh_input2 - second mesh file
mesh_output1 - where to write first mesh with the difference, if not specified, writes to mesh1diff.vtk
mesh_output2 - where to write second mesh with the difference, if not specified, writes to mesh2diff.vtk
\ No newline at end of file
#include <stdio.h>
#include "inmost.h"
using namespace INMOST;
typedef Storage::real real;
typedef Storage::real_array real_array;
int main(int argc, char ** argv)
{
if( argc < 2 )
{
printf("Usage: %s input_mesh [scale_x=1] [scale_y=1] [scale_z=1] [output_mesh]\n",argv[0]);
return -1;
}
Mesh m;
m.Load(argv[1]);
double sx = argc > 2 ? atof(argv[2]) : 1;
double sy = argc > 3 ? atof(argv[3]) : 1;
double sz = argc > 4 ? atof(argv[4]) : 1;
std::string save_file = argc > 5 ? std::string(argv[5]) : "out.vtk";
double xmax = -1.0e20, xmin = 1.0e20;
double ymax = -1.0e20, ymin = 1.0e20;
double zmax = -1.0e20, zmin = 1.0e20;
for(Mesh::iteratorNode n = m.BeginNode(); n != m.EndNode(); ++n)
{
double x = n->Coords()[0], y = n->Coords()[1], z = n->Coords()[2];
if( x > xmax ) xmax = x;
if( x < xmin ) xmin = x;
if( y > ymax ) ymax = y;
if( y < ymin ) ymin = y;
if( z > zmax ) zmax = z;
if( z < zmin ) zmin = z;
}
std::cout << "x: " << xmin << ":" << xmax << std::endl;
std::cout << "y: " << ymin << ":" << ymax << std::endl;
std::cout << "z: " << zmin << ":" << zmax << std::endl;
for(Mesh::iteratorNode n = m.BeginNode(); n != m.EndNode(); ++n)
{
n->Coords()[0] *= sx;
n->Coords()[1] *= sy;
n->Coords()[2] *= sz;
}
xmax = -1.0e20, xmin = 1.0e20;
ymax = -1.0e20, ymin = 1.0e20;
zmax = -1.0e20, zmin = 1.0e20;
for(Mesh::iteratorNode n = m.BeginNode(); n != m.EndNode(); ++n)
{
double x = n->Coords()[0], y = n->Coords()[1], z = n->Coords()[2];
if( x > xmax ) xmax = x;
if( x < xmin ) xmin = x;
if( y > ymax ) ymax = y;
if( y < ymin ) ymin = y;
if( z > zmax ) zmax = z;
if( z < zmin ) zmin = z;
}
std::cout << "x: " << xmin << ":" << xmax << std::endl;
std::cout << "y: " << ymin << ":" << ymax << std::endl;
std::cout << "z: " << zmin << ":" << zmax << std::endl;
std::cout << "Save to " << save_file << std::endl;
m.Save(save_file);
return 0;
}
#include <stdio.h>
#include "inmost.h"
using namespace INMOST;
typedef Storage::real real;
typedef Storage::real_array real_array;
int main(int argc, char ** argv)
{
if( argc < 2 )
{
printf("Usage: %s input_mesh [rotation_angle=0 degrees] [output_mesh]\n",argv[0]);
return -1;
}
Mesh m;
m.Load(argv[1]);
const double pi = 3.1415926536;
double theta = 0, ct, st;
if( argc > 2 ) theta = atof(argv[2])/180.0*pi;
ct = cos(theta);
st = sin(theta);
double xmin = 1.0e20, xmax = -1.0e20;
double ymin = 1.0e20, ymax = -1.0e20;
for(Mesh::iteratorNode n = m.BeginNode(); n != m.EndNode(); ++n)
{
double x = n->Coords()[0];
double y = n->Coords()[1];
if( x > xmax ) xmax = x;
if( x < xmin ) xmin = x;
if( y > ymax ) ymax = y;
if( y < ymin ) ymin = y;
}
std::cout << "x: " << xmin << ":" << xmax << std::endl;
std::cout << "y: " << ymin << ":" << ymax << std::endl;
for(Mesh::iteratorNode n = m.BeginNode(); n != m.EndNode(); ++n)
{
double x = n->Coords()[0], mx = x;
double y = n->Coords()[1], my = y;
double alpha = pi/4*(2*y-1);
mx += 1 - x*(1-cos(alpha)) + x*cos(2*alpha)*0.2;
my += x*sin(alpha);
n->Coords()[0] = (mx-0.5)*ct - (my-0.5)*st + 0.5;
n->Coords()[1] = (mx-0.5)*st + (my-0.5)*ct + 0.5;
}
xmin = 1.0e20, xmax = -1.0e20;
ymin = 1.0e20, ymax = -1.0e20;
for(Mesh::iteratorNode n = m.BeginNode(); n != m.EndNode(); ++n)
{
double x = n->Coords()[0];
double y = n->Coords()[1];
if( x > xmax ) xmax = x;
if( x < xmin ) xmin = x;
if( y > ymax ) ymax = y;
if( y < ymin ) ymin = y;
}
std::cout << "x: " << xmin << ":" << xmax << std::endl;
std::cout << "y: " << ymin << ":" << ymax << std::endl;
if( argc > 3 )
{
std::cout << "Save to " << argv[3] << std::endl;
m.Save(argv[3]);
}
else
{
std::cout << "Save to out.vtk" << std::endl;
m.Save("out.vtk");
}
return 0;
}
#include <stdio.h>
#include "inmost.h"
using namespace INMOST;
typedef Storage::real real;
typedef Storage::real_array real_array;
int main(int argc, char ** argv)
{
if( argc < 2 )
{
printf("Usage: %s input_mesh1 [input_mesh2] ... [output_mesh]\n",argv[0]);
return -1;
}
Mesh m;
for(int k = 1 ; k < argc; ++k)
m.Load(argv[k]);
double xmax = -1.0e20, xmin = 1.0e20;
double ymax = -1.0e20, ymin = 1.0e20;
double zmax = -1.0e20, zmin = 1.0e20;
for(Mesh::iteratorNode n = m.BeginNode(); n != m.EndNode(); ++n)
{
double x = n->Coords()[0], y = n->Coords()[1], z = n->Coords()[2];
if( x > xmax ) xmax = x;
if( x < xmin ) xmin = x;
if( y > ymax ) ymax = y;
if( y < ymin ) ymin = y;
if( z > zmax ) zmax = z;
if( z < zmin ) zmin = z;
}
std::cout << "x: " << xmin << ":" << xmax << std::endl;
std::cout << "y: " << ymin << ":" << ymax << std::endl;
std::cout << "z: " << zmin << ":" << zmax << std::endl;
std::cout << "Save to out.pmf" << std::endl;
m.Save("out.pmf");
return 0;
}
This diff is collapsed.
......@@ -29,7 +29,9 @@ set(SOURCE main.cpp
picker.h
picker.cpp
clipper.h
clipper.cpp)
clipper.cpp
vector.h
vector.cpp)
find_package(OpenGL)
find_package(GLUT)
......
<
......@@ -73,14 +73,14 @@ bool setTextToPasteboard(std::string str)
PasteboardCreate( kPasteboardClipboard, &pasteboard );
err = PasteboardClear( pasteboard );
require_noerr( err, PasteboardClear_FAILED );
//require_noerr( err, PasteboardClear_FAILED );
CFDataRef data;
data = CFDataCreate(kCFAllocatorDefault, (UInt8*)byteArrayIndex, strlen(byteArrayIndex)+1);
err = PasteboardPutItemFlavor( pasteboard, (PasteboardItemID)1, kUTTypeUTF8PlainText, data, 0);
require_noerr( err, PasteboardPutItemFlavor_FAILED );
//require_noerr( err, PasteboardPutItemFlavor_FAILED );