Commit 811ced06 authored by Kirill Terekhov's avatar Kirill Terekhov
Browse files

Some improvements

Fixed const-correctness in class keyval_table in inmost_expression.h

Optimized reading of .grid files by Mohammad, now sets are not created
for regions.
parent 3c199079
...@@ -1498,7 +1498,7 @@ namespace INMOST ...@@ -1498,7 +1498,7 @@ namespace INMOST
return std::make_pair(vals[i] + der * (arg - args[i]), der); return std::make_pair(vals[i] + der * (arg - args[i]), der);
} }
keyval_table() :name(""), vals(NULL), args(NULL), size(0) {} keyval_table() :name(""), vals(NULL), args(NULL), size(0) {}
keyval_table(std::string _name, INMOST_DATA_REAL_TYPE * _args, INMOST_DATA_REAL_TYPE * _vals, INMOST_DATA_ENUM_TYPE _size) keyval_table(std::string _name, const INMOST_DATA_REAL_TYPE * _args, const INMOST_DATA_REAL_TYPE * _vals, INMOST_DATA_ENUM_TYPE _size)
{ {
name = _name; name = _name;
size = _size; size = _size;
......
...@@ -8,10 +8,10 @@ ...@@ -8,10 +8,10 @@
namespace INMOST namespace INMOST
{ {
// mesh format by Mohammad Karimi-Fard // mesh format by Mohammad Karimi-Fard
void Mesh::LoadMKF(std::string File) void Mesh::LoadMKF(std::string File)
{ {
int verbosity = 0; int verbosity = 0;
for(INMOST_DATA_ENUM_TYPE k = 0; k < file_options.size(); ++k) for(INMOST_DATA_ENUM_TYPE k = 0; k < file_options.size(); ++k)
{ {
if( file_options[k].first == "VERBOSITY" ) if( file_options[k].first == "VERBOSITY" )
...@@ -51,6 +51,9 @@ namespace INMOST ...@@ -51,6 +51,9 @@ namespace INMOST
std::vector<HandleType> newnodes; std::vector<HandleType> newnodes;
std::vector<HandleType> newpolygon; std::vector<HandleType> newpolygon;
std::vector<HandleType> newpolyhedron; std::vector<HandleType> newpolyhedron;
std::vector<INMOST_DATA_REAL_TYPE> poro_zones;
std::vector<INMOST_DATA_REAL_TYPE> factor_zones;
std::vector<INMOST_DATA_REAL_TYPE> perm_zones;
ElementArray<ElementSet> newsets(this); ElementArray<ElementSet> newsets(this);
ElementArray<Node> f_nodes(this); ElementArray<Node> f_nodes(this);
ElementArray<Face> c_faces(this); ElementArray<Face> c_faces(this);
...@@ -58,21 +61,26 @@ namespace INMOST ...@@ -58,21 +61,26 @@ namespace INMOST
newnodes.resize(nbnodes); newnodes.resize(nbnodes);
newpolygon.resize(nbpolygon); newpolygon.resize(nbpolygon);
newpolyhedron.resize(nbpolyhedra); newpolyhedron.resize(nbpolyhedra);
poro_zones.resize(nbzones);
factor_zones.resize(nbzones);
perm_zones.resize(nbzones*9);
/*
newsets.resize(nbzones); newsets.resize(nbzones);
if( verbosity > 0 ) printf("Creating %d sets for zones.\n",nbzones); if( verbosity > 0 ) printf("Creating %d sets for zones.\n",nbzones);
report_pace = std::max<int>(nbzones/250,1); report_pace = std::max<int>(nbzones/250,1);
for(int i = 0; i < nbzones; i++) for(int i = 0; i < nbzones; i++)
{ {
std::stringstream str; std::stringstream str;
str << "ZONE_" << i << "_SET"; str << "ZONE_" << i << "_SET";
newsets[i] = CreateSetUnique(str.str()).first; newsets[i] = CreateSetUnique(str.str()).first;
newsets[i]->Integer(zone) = i; newsets[i]->Integer(zone) = i;
if( verbosity > 1 && i % report_pace == 0 ) if( verbosity > 1 && i % report_pace == 0 )
{ {
printf("sets %3.1f%%\r",(i*100.0)/(1.0*nbzones)); printf("sets %3.1f%%\r",(i*100.0)/(1.0*nbzones));
fflush(stdout); fflush(stdout);
} }
} }
*/
if( verbosity > 0 ) printf("Reading %d nodes.\n",nbnodes); if( verbosity > 0 ) printf("Reading %d nodes.\n",nbnodes);
report_pace = std::max<int>(nbnodes/250,1); report_pace = std::max<int>(nbnodes/250,1);
for(int i = 0; i < nbnodes; i++) for(int i = 0; i < nbnodes; i++)
...@@ -140,7 +148,7 @@ namespace INMOST ...@@ -140,7 +148,7 @@ namespace INMOST
} }
Face f = CreateFace(f_nodes).first; Face f = CreateFace(f_nodes).first;
f->Integer(zone) = num; f->Integer(zone) = num;
if( num >= 0 ) newsets[num]->PutElement(f); //if( num >= 0 ) newsets[num]->PutElement(f);
newpolygon[i] = f->GetHandle(); newpolygon[i] = f->GetHandle();
f_nodes.clear(); f_nodes.clear();
...@@ -186,7 +194,7 @@ namespace INMOST ...@@ -186,7 +194,7 @@ namespace INMOST
Cell c = CreateCell(c_faces).first; Cell c = CreateCell(c_faces).first;
c->Integer(zone) = num; c->Integer(zone) = num;
newpolyhedron[i] = c->GetHandle(); newpolyhedron[i] = c->GetHandle();
if( num >= 0 ) newsets[num]->PutElement(newpolyhedron[i]); //if( num >= 0 ) newsets[num]->PutElement(newpolyhedron[i]);
c_faces.clear(); c_faces.clear();
if( verbosity > 1 && i % report_pace == 0 ) if( verbosity > 1 && i % report_pace == 0 )
...@@ -250,19 +258,44 @@ namespace INMOST ...@@ -250,19 +258,44 @@ namespace INMOST
//just copy //just copy
memcpy(K,readK,sizeof(Storage::real)*9); memcpy(K,readK,sizeof(Storage::real)*9);
} }
/*
for(ElementSet::iterator it = newsets[num]->Begin(); it != newsets[num]->End(); ++it) for(ElementSet::iterator it = newsets[num]->Begin(); it != newsets[num]->End(); ++it)
{ {
it->Real(volume_factor) = vfac; it->Real(volume_factor) = vfac;
it->Real(porosity) = poro; it->Real(porosity) = poro;
memcpy(it->RealArray(permiability).data(),K,sizeof(Storage::real)*9); memcpy(it->RealArray(permiability).data(),K,sizeof(Storage::real)*9);
} }
*/
poro_zones[num] = poro;
factor_zones[num] = vfac;
for(int l = 0; l < 9; ++l)
perm_zones[num*9+l] = K[l];
if( verbosity > 1 && i % report_pace == 0 ) if( verbosity > 1 && i % report_pace == 0 )
{ {
printf("data %3.1f%%\r",(i*100.0)/(1.0*nbzones)); printf("data %3.1f%%\r",(i*100.0)/(1.0*nbzones));
fflush(stdout); fflush(stdout);
} }
} }
for(int i = 0; i < nbpolygon; ++i)
{
int z = Integer(newpolygon[i],zone);
if( z >= 0 )
{
Real(newpolygon[i],volume_factor) = factor_zones[z];
Real(newpolygon[i],porosity) = poro_zones[z];
memcpy(RealArray(newpolygon[i],permiability).data(),&perm_zones[z*9],sizeof(Storage::real)*9);
}
}
for(int i = 0; i < nbpolyhedra; ++i)
{
int z = Integer(newpolyhedron[i],zone);
if( z >= 0 )
{
Real(newpolyhedron[i],volume_factor) = factor_zones[z];
Real(newpolyhedron[i],porosity) = poro_zones[z];
memcpy(RealArray(newpolyhedron[i],permiability).data(),&perm_zones[z*9],sizeof(Storage::real)*9);
}
}
//TEMPORARY //TEMPORARY
//for(int i = 0; i < nbzones; i++) newsets[i]->Delete(); //for(int i = 0; i < nbzones; i++) newsets[i]->Delete();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment