Commit f4e48a59 authored by Kirill Terekhov's avatar Kirill Terekhov

More features for xml reader

Still testing xml reader.

Preparations for NMPFA example.
parent 55b8f6aa
......@@ -6,5 +6,6 @@ add_subdirectory(GridGen)
add_subdirectory(FVDiscr)
add_subdirectory(ADFVDiscr)
add_subdirectory(ADMFD)
#add_subdirectory(NMPFA)
#add_subdirectory(OctreeCutcell)
add_subdirectory(Solver)
project(NMPFA)
set(SOURCE main.cpp)
add_executable(NMPFA ${SOURCE})
target_link_libraries(NMPFA inmost)
if(USE_SOLVER)
if(USE_SOLVER_ANI)
message("linking NMPFA with ani3d and BLAS")
target_link_libraries(NMPFA ani3d ${BLAS_LIBRARIES})
if(BLAS_LINKER_FLAGS)
set_target_properties(NMPFA PROPERTIES LINK_FLAGS "${BLAS_LINKER_FLAGS}")
endif()
endif()
if(USE_SOLVER_PETSC)
message("linking NMPFA with PETSc")
target_link_libraries(NMPFA ${PETSC_LIBRARIES})
endif()
if(USE_SOLVER_TRILINOS)
message("linking NMPFA with Trilinos")
target_link_libraries(NMPFA ${Trilinos_LIBRARIES} ${Trilinos_TPL_LIBRARIES})
endif()
if(USE_SOLVER_METIS)
message("linking NMPFA with Metis")
target_link_libraries(NMPFA ${METIS_LIBRARIES})
endif()
if(USE_SOLVER_MONDRIAAN)
message("linking NMPFA with Mondriaan")
target_link_libraries(NMPFA ${MONDRIAAN_LIBRARIES})
endif()
if(USE_SOLVER_SUPERLU)
message("linking NMPFA with SuperLU")
target_link_libraries(NMPFA ${SUPERLU_LIBRARIES})
endif()
endif()
if(USE_PARTITIONER)
if(USE_PARTITIONER_ZOLTAN)
message("linking NMPFA with Zoltan")
target_link_libraries(NMPFA ${ZOLTAN_LIBRARIES})
endif()
if(USE_PARTITIONER_PARMETIS)
message("linking NMPFA with ParMETIS")
target_link_libraries(NMPFA ${PARMETIS_LIBRARIES})
endif()
endif()
if(USE_MPI)
message("linking NMPFA with MPI")
target_link_libraries(NMPFA ${MPI_LIBRARIES})
if(MPI_LINK_FLAGS)
set_target_properties(NMPFA PROPERTIES LINK_FLAGS "${MPI_LINK_FLAGS}")
endif()
endif(USE_MPI)
install(TARGETS NMPFA EXPORT inmost-targets RUNTIME DESTINATION bin)
This diff is collapsed.
......@@ -42,7 +42,7 @@ double last_time;
double gleft, gright, gbottom, gtop, gnear, gfar, zoom = 1;
bool transparent = false;
//#define MASAHIKO_MESH
//#define SPHERE_MESH
#define OBJ_READERS
#define INIT_PERM
......@@ -52,6 +52,16 @@ void transformation(double xyz[3])
{
#if defined(SPHERE_MESH)
return;
#elif defined(MASAHIKO_MESH)
if( xyz[2] < 11.0/36.0 )
xyz[2] = (xyz[2]-0)*11.9/11.0;
else if( xyz[2] < 12.0/36.0 )
xyz[2] = (xyz[2]-11.0/36.0)*0.1 + 11.9/36.0;
else if( xyz[2] < 23.0/36.0 )
xyz[2] = (xyz[2]-12.0/36.0)*11.9/11.0 + 12.0/36.0;
else if( xyz[2] < 24.0/36.0 )
xyz[2] = (xyz[2]-23.0/36.0)*0.1 + 23.9/36.0;
return;
#endif
make_proj.Project(xyz);
/*
......@@ -72,7 +82,17 @@ void transformation(double xyz[3])
mat_ret_type get_material_types(double xyz[3])
{
#if defined(SPHERE_MESH)
#if defined(MASAHIKO_MESH)
mat_ret_type ret;
//ret.push_back(1);
const double eps = 1.0e-5;
double test = xyz[2] - (2*xyz[0]-0.5);
if( test < eps ) ret.push_back(1);
if( test > -eps ) ret.push_back(2);
return ret;
#elif defined(SPHERE_MESH)
mat_ret_type ret;
const double eps = 1.0e-5;
double sphere = 0.5 - sqrt((xyz[0]-0.5)*(xyz[0]-0.5) + (xyz[1]-0.5)*(xyz[1]-0.5) + (xyz[2]-0.5)*(xyz[2]-0.5));
......@@ -94,6 +114,18 @@ mat_ret_type get_material_types(double xyz[3])
int cell_should_unite(struct grid * g, int cell)
{
#if defined(MASAHIKO_MESH)
return 0;
//refinement along well
double x,y,z;
x = g->cells[cell].center[0];
y = g->cells[cell].center[1];
z = g->cells[cell].center[2];
double plane = fabs(z - (1.25-2*x));
double mid = fabs(y-0.5);
return plane > 0.06 && mid > 0.06;
#endif
const double r = 0.03;
//const double r = 0.001;
double r2 = (1.0/(double)g->n[0]*1.0/(double)g->n[0]+1.0/(double)g->n[1]*1.0/(double)g->n[1])/2.0;
......@@ -108,7 +140,18 @@ int cell_should_unite(struct grid * g, int cell)
}
int cell_should_split(struct grid * g, int cell)
{
#if defined(MASAHIKO_MESH)
return 0;
//refinement along well
double x,y,z;
x = g->cells[cell].center[0];
y = g->cells[cell].center[1];
z = g->cells[cell].center[2];
double plane = fabs(z - (1.25-2*x));
double mid = fabs(y-0.5);
return plane < 0.05 && mid < 0.05 && g->cells[cell].level < level_max;
#endif
const double r = 0.03;
//const double r = 0.001;
double r2 = (1.0/(double)g->n[0]*1.0/(double)g->n[0]+1.0/(double)g->n[1]*1.0/(double)g->n[1])/2.0;
......@@ -850,7 +893,11 @@ int global_test_number = -1;
int main(int argc, char ** argv)
{
int i;
#if defined(MASAHIKO_MESH)
int n[3] = {36,36,36};
#else
int n[3] = {8,8,8};
#endif
last_time = Timer();
if( argc > 3 )
......@@ -1015,6 +1062,81 @@ int main(int argc, char ** argv)
#endif
#if defined(MASAHIKO_MESH)
gridAMR(&thegrid,recreate);
//gridRefine(&thegrid);
gridRecreateINMOST(&thegrid);
{
Storage::real x[3];
Tag tensor_K = thegrid.mesh->CreateTag("PERM",DATA_REAL,CELL | FACE, FACE, 3);
Tag poro = thegrid.mesh->CreateTag("PORO",DATA_REAL,CELL | FACE, FACE, 1);
Tag aperture = thegrid.mesh->CreateTag("APERTURE",DATA_REAL,FACE,FACE,1);
Tag mats = thegrid.mesh->GetTag("MATERIALS"); //face,edge,node
Tag mat = thegrid.mesh->GetTag("MATERIAL");
int fault_faces = 0;
for(Mesh::iteratorFace f = thegrid.mesh->BeginFace(); f != thegrid.mesh->EndFace(); ++f)
{
Storage::real_array fmats = f->RealArray(mats);
if( fmats.size() == 2 ) //fault
{
Storage::real_array K = f->RealArray(tensor_K);
K[0] = K[1] = K[2] = 10000; // 10D perm
f->Real(aperture) = 0.01;
f->Real(poro) = 0.6;
fault_faces++;
}
}
std::cout << "fault faces: " << fault_faces << std::endl;
for(Mesh::iteratorCell c = thegrid.mesh->BeginCell(); c != thegrid.mesh->EndCell(); ++c)
{
c->Centroid(x);
Storage::real_array K = c->RealArray(tensor_K);
if( x[2] <= 11.9/36.0 ) // bottom reservoir
{
c->Integer(mat) = 0;
K[0] = (rand()*1.0)/static_cast<double>(RAND_MAX)*90+10;
K[1] = (rand()*1.0)/static_cast<double>(RAND_MAX)*90+10;
K[2] = (rand()*1.0)/static_cast<double>(RAND_MAX)*9+1;
c->Real(poro) = sqrt((K[0]*K[0] + K[1]*K[1] + K[2]*K[2])/(100*100+100*100+10*10))*0.6;
}
else if( x[2] <= 12.0/36.0 ) //empty part between bottom and middle reservoir
{
c->Integer(mat) = 1;
K[0] = K[1] = K[2] = 0.1;
c->Real(poro) = 0.01;
}
else if( x[2] <= 23.9/36.0 ) //middle reservoir
{
c->Integer(mat) = 2;
K[0] = (rand()*1.0)/static_cast<double>(RAND_MAX)*120+30;
K[1] = (rand()*1.0)/static_cast<double>(RAND_MAX)*170+30;
K[2] = (rand()*1.0)/static_cast<double>(RAND_MAX)*10+5;
c->Real(poro) = sqrt((K[0]*K[0] + K[1]*K[1] + K[2]*K[2])/(150*150+200*200+15*15))*0.6;
}
else if( x[2] <= 24.0/36.0 ) //empty part between middle and top reservoir
{
c->Integer(mat) = 3;
K[0] = K[1] = K[2] = 0.1;
c->Real(poro) = 0.01;
}
else //top reservoir
{
c->Integer(mat) = 4;
K[0] = (rand()*1.0)/static_cast<double>(RAND_MAX)*60+20;
K[1] = (rand()*1.0)/static_cast<double>(RAND_MAX)*40+20;
K[2] = (rand()*1.0)/static_cast<double>(RAND_MAX)*6+3;
c->Real(poro) = sqrt((K[0]*K[0] + K[1]*K[1] + K[2]*K[2])/(80*80+60*60+9*9))*0.6;
}
}
thegrid.mesh->Save("masahiko.xml");
thegrid.mesh->Save("masahiko.vtk");
onclose();
return 0;
}
#endif
#if defined(__GRAPHICS__)
......
......@@ -4035,6 +4035,12 @@ int main(int argc, char ** argv)
//printf("Delete %lg\n",Timer()-tt);
//return 0;
//Mesh::GeomParam param;
//param[MEASURE] = CELL;
//param[ORIENTATION] = FACE;
//mesh->RemoveGeometricData(param);
//mesh->PrepareGeometricData(param);
std::map<Element::GeometricType,int> elems;
for(Mesh::iteratorElement it = mesh->BeginElement(CELL|FACE|EDGE|NODE); it != mesh->EndElement(); ++it)
......
......@@ -85,11 +85,17 @@ namespace INMOST
void SkipComments(State RetState);
std::string StateName(State s) const;
public:
/// 2 - lot's of output
/// 1 - output key steps, currently in ReadXML
void SetVerbosity(int verbosity) {verbose = verbosity;}
void Report(const char * fmt, ...) const;
XMLReader(std::string sourcename, std::istream & input);
void PushStream(std::string file);
void PopStream();
//wait for '<' on input,
//returns true and changes state to WaitTag if '<' encountered,
//otherwise returns false
bool ExpectOpenTag();
//read in <TagName returns TagName
std::string ReadOpenTag();
//read > or /> skipping for attributes
......@@ -151,19 +157,49 @@ namespace INMOST
std::string name; //<Name of the XML tag
std::vector<XMLAttrib> attributes; //<List of attributes
int finish; //<Whether to close the tag
///This is data without ![CDATA[ wrap
bool RawData() const {return finish == 5;}
///This is data within ![CDATA[ wrap
bool BlockData() const {return finish == 4;}
///Was not able to read the tag
bool Failure() const;
bool Failure() const {return finish == 0;}
///Tag was red, can process the contents
bool Process() const;
bool Process() const {return finish == 1 || finish == 2;}
///Tag was not red, finish of enclosing tag was encountered
bool Finalize() const;
const XMLAttrib & GetAttib(int n) const;
XMLAttrib & GetAttib(int n);
int NumAttrib() const;
bool Finalize() const {return finish == 3;}
const XMLAttrib & GetAttib(int n) const {return attributes[n];}
XMLAttrib & GetAttib(int n) {return attributes[n];}
int NumAttrib() const {return (int)attributes.size();}
std::string GetName() const {return name;}
};
XMLTag OpenTag();
bool CloseTag(XMLTag & tag);
struct XMLTree
{
XMLTag tag;
std::vector<XMLTree> children;
std::string contents;
const XMLTree & GetChild(int n) const {return children[n];}
int NumChildren() const {return (int)children.size();}
const XMLAttrib & GetAttrib(int n) const {return tag.GetAttib(n);}
int NumAttrib() const {return (int)tag.NumAttrib();}
std::string GetName() const {return tag.GetName();}
const std::string & GetContents() const {return contents;}
};
private:
std::string ReadUntil(std::string stop);
int ReadXMLSub(XMLTree & root);
public:
/// Read entire XML file into structure,
/// it may be more efficient to read the file partially
XMLTree ReadXML();
};
}
......
This diff is collapsed.
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