Commit 306da91a authored by Kirill Terekhov's avatar Kirill Terekhov

Organization of unknowns into blocks for Automatizator

parent 049af67d
......@@ -149,7 +149,7 @@ int main(int argc,char ** argv)
Automatizator aut;
Automatizator::MakeCurrent(&aut);
INMOST_DATA_ENUM_TYPE iphi = aut.RegisterTag(phi,CELL);
aut.EnumerateTags();
aut.EnumerateEntries();
// Set the indeces intervals for the matrix and vectors
R.SetInterval(aut.GetFirstIndex(),aut.GetLastIndex());
......@@ -329,4 +329,4 @@ int main(int argc,char ** argv)
#endif
Solver::Finalize(); // Finalize solver and close MPI activity
return 0;
}
\ No newline at end of file
}
......@@ -427,7 +427,7 @@ int main(int argc,char ** argv)
Automatizator aut; // declare class to help manage unknowns
Automatizator::MakeCurrent(&aut);
dynamic_variable P(aut,aut.RegisterTag(tag_P,CELL|(hybrid?FACE:NONE))); //register pressure as primary unknown
aut.EnumerateTags(); //enumerate all primary variables
aut.EnumerateEntries(); //enumerate all primary variables
std::cout << "Enumeration done, size " << aut.GetLastIndex() - aut.GetFirstIndex() << std::endl;
......
......@@ -480,7 +480,7 @@ int main(int argc,char ** argv)
Automatizator aut; // declare class to help manage unknowns
dynamic_variable Q(aut,aut.RegisterTag(tag_Q,two_point ? CELL : (CELL|FACE))); //register pressure as primary unknown
aut.EnumerateTags(); //enumerate all primary variables
aut.EnumerateEntries(); //enumerate all primary variables
std::cout << "Enumeration done, size " << aut.GetLastIndex() - aut.GetFirstIndex() << std::endl;
......
......@@ -120,7 +120,7 @@ void ps_inmost (Sparse::Matrix & A, const std::string file)
ps_ij (row,jt->first);
row++;
}
ps_file (file, NULL, NULL);
ps_file (file, 0, NULL);
}
#endif
......
......@@ -2227,7 +2227,7 @@ int main(int argc, char ** argv)
num_orphans[it->GetElementType()]++;
}
printf("number of orphan elements: %d\n",orphans.size());
printf("number of orphan elements: %lu\n",orphans.size());
for(std::map<ElementType,int>::iterator it = num_orphans.begin(); it != num_orphans.end(); ++it)
printf("%s %d\n",ElementTypeName(it->first),it->second);
int was = orphans.size();
......@@ -2239,7 +2239,7 @@ int main(int argc, char ** argv)
orphans.push_back(it->self());
num_topo[it->GetElementType()]++;
}
printf("number of elements with topology error: %d\n",orphans.size()-was);
printf("number of elements with topology error: %lu\n",orphans.size()-was);
for(std::map<ElementType,int>::iterator it = num_topo.begin(); it != num_topo.end(); ++it)
printf("%s %d\n",ElementTypeName(it->first),it->second);
for(int k = was; k < orphans.size(); ++k)
......
......@@ -168,7 +168,7 @@ namespace INMOST
}
}
printf("done from boundary faces, total streamlines = %d\n", output.size());
printf("done from boundary faces, total streamlines = %lu\n", output.size());
printf("started building streamlines from unvisited cells\n");
tot = 0;
......@@ -196,13 +196,13 @@ namespace INMOST
fflush(stdout);
}
}
printf("done from unvisited cells, total streamlines = %d\n", output.size());
printf("done from unvisited cells, total streamlines = %lu\n", output.size());
mesh->ReleaseMarker(visited,vel_def);
}
mesh->DeleteTag(cell_size);
printf("done, total streamlines = %d\n", output.size());
printf("done, total streamlines = %lu\n", output.size());
printf("killing octree, was sets %d\n", mesh->NumberOfSets());
octsearch.Destroy();
printf("done, sets %d\n", mesh->NumberOfSets());
......@@ -299,4 +299,4 @@ namespace INMOST
file << "</g>" << std::endl;
}
}
}
\ No newline at end of file
}
......@@ -318,7 +318,7 @@ namespace INMOST
if (q%pace == 0) faces.back().set_flag(true);
q++;
}
printf("number of faces %d\n", faces.size());
printf("number of faces %lu\n", faces.size());
}
void volumetric2::camera(double pos[3], int interactive)
......
This diff is collapsed.
This diff is collapsed.
......@@ -16,11 +16,13 @@ namespace INMOST
template<> struct Promote<INMOST_DATA_REAL_TYPE, INMOST_DATA_REAL_TYPE> {typedef INMOST_DATA_REAL_TYPE type;};
#if defined(USE_AUTODIFF)
//For INMOST_DATA_INTEGER_TYPE
template<> struct Promote<INMOST_DATA_INTEGER_TYPE, multivar_expression_reference> {typedef variable type;};
template<> struct Promote<INMOST_DATA_INTEGER_TYPE, unknown> {typedef variable type;};
template<> struct Promote<INMOST_DATA_INTEGER_TYPE, variable> {typedef variable type;};
template<> struct Promote<INMOST_DATA_INTEGER_TYPE, multivar_expression_reference> {typedef variable type;};
template<> struct Promote<INMOST_DATA_INTEGER_TYPE, hessian_multivar_expression_reference> {typedef hessian_variable type;};
template<> struct Promote<INMOST_DATA_INTEGER_TYPE, hessian_variable> {typedef hessian_variable type;};
//For INMOST_DATA_REAL_TYPE
template<> struct Promote<INMOST_DATA_REAL_TYPE, unknown> {typedef variable type;};
template<> struct Promote<INMOST_DATA_REAL_TYPE, variable> {typedef variable type;};
template<> struct Promote<INMOST_DATA_REAL_TYPE, multivar_expression_reference> {typedef variable type;};
template<> struct Promote<INMOST_DATA_REAL_TYPE, hessian_multivar_expression_reference> {typedef hessian_variable type;};
......@@ -28,29 +30,33 @@ namespace INMOST
//For multivar_expression_reference
template<> struct Promote<multivar_expression_reference, INMOST_DATA_INTEGER_TYPE> {typedef variable type;};
template<> struct Promote<multivar_expression_reference, INMOST_DATA_REAL_TYPE> {typedef variable type;};
template<> struct Promote<multivar_expression_reference, multivar_expression_reference> {typedef variable type;};
template<> struct Promote<multivar_expression_reference, unknown> {typedef variable type;};
template<> struct Promote<multivar_expression_reference, variable> {typedef variable type;};
template<> struct Promote<multivar_expression_reference, multivar_expression_reference> {typedef variable type;};
template<> struct Promote<multivar_expression_reference, hessian_multivar_expression_reference> {typedef variable type;};
template<> struct Promote<multivar_expression_reference, hessian_variable> {typedef variable type;};
//For variable
template<> struct Promote<variable, INMOST_DATA_INTEGER_TYPE> {typedef variable type;};
template<> struct Promote<variable, INMOST_DATA_REAL_TYPE> {typedef variable type;};
template<> struct Promote<variable, multivar_expression_reference> {typedef variable type;};
template<> struct Promote<variable, unknown> {typedef variable type;};
template<> struct Promote<variable, variable> {typedef variable type;};
template<> struct Promote<variable, multivar_expression_reference> {typedef variable type;};
template<> struct Promote<variable, hessian_multivar_expression_reference> {typedef hessian_variable type;};
template<> struct Promote<variable, hessian_variable> {typedef hessian_variable type;};
//For hessian_multivar_expression_reference
template<> struct Promote<hessian_multivar_expression_reference, INMOST_DATA_INTEGER_TYPE> {typedef hessian_variable type;};
template<> struct Promote<hessian_multivar_expression_reference, INMOST_DATA_REAL_TYPE> {typedef hessian_variable type;};
template<> struct Promote<hessian_multivar_expression_reference, multivar_expression_reference> {typedef hessian_variable type;};
template<> struct Promote<hessian_multivar_expression_reference, unknown> {typedef hessian_variable type;};
template<> struct Promote<hessian_multivar_expression_reference, variable> {typedef hessian_variable type;};
template<> struct Promote<hessian_multivar_expression_reference, multivar_expression_reference> {typedef hessian_variable type;};
template<> struct Promote<hessian_multivar_expression_reference, hessian_multivar_expression_reference> {typedef hessian_variable type;};
template<> struct Promote<hessian_multivar_expression_reference, hessian_variable> {typedef hessian_variable type;};
//For hessian_variable
template<> struct Promote<hessian_variable, INMOST_DATA_INTEGER_TYPE> {typedef hessian_variable type;};
template<> struct Promote<hessian_variable, INMOST_DATA_REAL_TYPE> {typedef hessian_variable type;};
template<> struct Promote<hessian_variable, multivar_expression_reference> {typedef hessian_variable type;};
template<> struct Promote<hessian_variable, unknown> {typedef hessian_variable type;};
template<> struct Promote<hessian_variable, variable> {typedef hessian_variable type;};
template<> struct Promote<hessian_variable, multivar_expression_reference> {typedef hessian_variable type;};
template<> struct Promote<hessian_variable, hessian_multivar_expression_reference> {typedef hessian_variable type;};
template<> struct Promote<hessian_variable, hessian_variable> {typedef hessian_variable type;};
#endif
......@@ -2357,6 +2363,8 @@ namespace INMOST
/// shortcut for matrix of real values.
typedef Matrix<INMOST_DATA_REAL_TYPE> rMatrix;
#if defined(USE_AUTODIFF)
/// shortcut for matrix of variables with single unit entry of first order derivative.
typedef Matrix<unknown> uMatrix;
/// shortcut for matrix of variables with first order derivatives.
typedef Matrix<variable> vMatrix;
//< shortcut for matrix of variables with first and second order derivatives.
......
......@@ -91,6 +91,7 @@ namespace INMOST
INMOST_DATA_REAL_TYPE value;
INMOST_DATA_ENUM_TYPE index;
public:
var_expression() : value(0), index(ENUMUNDEF) {}
var_expression(const var_expression & other) :value(other.value), index(other.index) {}
var_expression(INMOST_DATA_REAL_TYPE pvalue, INMOST_DATA_ENUM_TYPE pindex) : value(pvalue), index(pindex) {}
__INLINE void SetValue(INMOST_DATA_REAL_TYPE val) { value = val; }
......@@ -558,13 +559,15 @@ namespace INMOST
#pragma pack(pop,r1)
#endif
static INMOST_DATA_REAL_TYPE stub_multivar_expression_reference_value; //for default constructor in multivar_expression_reference
class multivar_expression_reference : public shell_expression<multivar_expression_reference>
{
INMOST_DATA_REAL_TYPE & value;
Sparse::Row * entries;
public:
/// Default constructor
multivar_expression_reference() : value(stub_multivar_expression_reference_value), entries(NULL) {}
/// Constructor, set links to the provided value and entries
multivar_expression_reference(INMOST_DATA_REAL_TYPE & _value, Sparse::Row * _entries)
: value(_value), entries(_entries) {}
......@@ -2083,7 +2086,6 @@ template<class A> __INLINE INMOST_DATA_REAL_TY
__INLINE void set_value(INMOST::multivar_expression_reference & Arg, const INMOST::var_expression & Val) {Arg.SetValue(Val.GetValue()); }
__INLINE void set_value(INMOST::multivar_expression_reference & Arg, const INMOST::multivar_expression & Val) {Arg.SetValue(Val.GetValue()); }
__INLINE void set_value(INMOST::multivar_expression_reference & Arg, const INMOST::multivar_expression_reference & Val) {Arg.SetValue(Val.GetValue()); }
__INLINE void assign(INMOST::var_expression & Arg, INMOST_DATA_REAL_TYPE Val) {Arg = Val;}
__INLINE void assign(INMOST_DATA_INTEGER_TYPE & Arg, INMOST_DATA_INTEGER_TYPE Val) {Arg = Val;}
__INLINE void assign(INMOST_DATA_INTEGER_TYPE & Arg, INMOST_DATA_REAL_TYPE Val) {Arg = (INMOST_DATA_INTEGER_TYPE)Val;}
__INLINE void assign(INMOST_DATA_INTEGER_TYPE & Arg, const INMOST::var_expression & Val) {Arg = (INMOST_DATA_INTEGER_TYPE)Val.GetValue();}
......@@ -2098,6 +2100,9 @@ template<class A> __INLINE INMOST_DATA_REAL_TY
__INLINE void assign(INMOST_DATA_REAL_TYPE & Arg, const INMOST::multivar_expression_reference & Val) {Arg = Val.GetValue();}
__INLINE void assign(INMOST_DATA_REAL_TYPE & Arg, const INMOST::hessian_multivar_expression & Val) {Arg = Val.GetValue(); }
__INLINE void assign(INMOST_DATA_REAL_TYPE & Arg, const INMOST::hessian_multivar_expression_reference & Val) {Arg = Val.GetValue(); }
__INLINE void assign(INMOST::var_expression & Arg, INMOST_DATA_INTEGER_TYPE Val) {Arg = (INMOST_DATA_REAL_TYPE)Val; }
__INLINE void assign(INMOST::var_expression & Arg, INMOST_DATA_REAL_TYPE Val) {Arg = Val; }
__INLINE void assign(INMOST::var_expression & Arg, const INMOST::var_expression & Val) {Arg = Val; }
__INLINE void assign(INMOST::multivar_expression & Arg, INMOST_DATA_INTEGER_TYPE Val) {Arg = (INMOST_DATA_REAL_TYPE)Val; }
__INLINE void assign(INMOST::multivar_expression & Arg, INMOST_DATA_REAL_TYPE Val) {Arg = Val; }
__INLINE void assign(INMOST::multivar_expression & Arg, const INMOST::var_expression & Val) {Arg = Val; }
......@@ -2184,7 +2189,7 @@ __INLINE INMOST_DATA_REAL_TYPE get_table(INMOST_DATA_RE
#else //USE_AUTODIFF
__INLINE void assign(INMOST_DATA_INTEGER_TYPE & Arg, INMOST_DATA_INTEGER_TYPE Val) {Arg = Val;}
__INLINE void assign(INMOST_DATA_INTEGER_TYPE & Arg, INMOST_DATA_REAL_TYPE Val) {Arg = Val;}
__INLINE void assign(INMOST_REAL_INTEGER_TYPE & Arg, INMOST_DATA_INTEGER_TYPE Val) {Arg = Val;}
__INLINE void assign(INMOST_DATA_REAL_TYPE & Arg, INMOST_DATA_INTEGER_TYPE Val) {Arg = Val;}
__INLINE void assign(INMOST_DATA_REAL_TYPE & Arg, INMOST_DATA_REAL_TYPE Val) {Arg = Val;}
__INLINE void set_value(INMOST_DATA_REAL_TYPE & Arg, INMOST_DATA_REAL_TYPE Val) {Arg = Val;}
__INLINE INMOST_DATA_REAL_TYPE get_value(INMOST_DATA_REAL_TYPE Arg) {return Arg;}
......
......@@ -253,44 +253,32 @@ namespace INMOST
class dynamic_variable : public shell_dynamic_variable<var_expression,dynamic_variable >
{
private:
Tag index_tag, value_tag;
MarkerType mask;
const AbstractEntry * entry;
INMOST_DATA_ENUM_TYPE comp;
public:
dynamic_variable() : index_tag(),value_tag(),mask(0),comp(ENUMUNDEF) {}
dynamic_variable(Automatizator & paut, INMOST_DATA_ENUM_TYPE pregval, INMOST_DATA_ENUM_TYPE pcomp = 0) : comp(pcomp)
{
if( pregval != ENUMUNDEF )
{
mask = paut.GetMask(pregval);
value_tag = paut.GetValueTag(pregval);
index_tag = paut.GetIndexTag(pregval);
}
}
dynamic_variable(const dynamic_variable & other) : index_tag(other.index_tag), value_tag(other.value_tag), mask(other.mask), comp(other.comp) {}
dynamic_variable() :entry(NULL), comp(ENUMUNDEF) {}
dynamic_variable(Automatizator & aut, INMOST_DATA_ENUM_TYPE reg_index, INMOST_DATA_ENUM_TYPE comp = 0) : entry(&aut.GetEntry(reg_index)), comp(comp) {}
dynamic_variable(const AbstractEntry * re, INMOST_DATA_ENUM_TYPE comp = 0) : entry(re), comp(comp) {}
dynamic_variable(const dynamic_variable & other) : entry(other.entry), comp(other.comp) {}
dynamic_variable & operator =(const dynamic_variable & other)
{
index_tag = other.index_tag;
value_tag = other.value_tag;
mask = other.mask;
entry = other.entry;
comp = other.comp;
return * this;
}
INMOST_DATA_REAL_TYPE Value(const Storage & e) const {return e->RealArray(value_tag)[comp];}
INMOST_DATA_ENUM_TYPE Index(const Storage & e) const {return (!mask || e->GetMarker(mask))?e->IntegerArray(index_tag)[comp]:ENUMUNDEF;}
INMOST_DATA_REAL_TYPE Value(const Storage & e) const {return entry->Value(e,comp);}
INMOST_DATA_ENUM_TYPE Index(const Storage & e) const {return entry->isValid(e) ? entry->Index(e,comp):ENUMUNDEF;}
multivar_expression Variable(const Storage & e) const
{
if( !mask || e->GetMarker(mask) )
return multivar_expression(e->RealArray(value_tag)[comp],e->IntegerArray(index_tag)[comp]);
if( entry->isValid(e) )
return entry->Unknown(e,comp);
else
return multivar_expression(e->RealArray(value_tag)[comp]);
return entry->Value(e,comp);
}
var_expression operator [](const Storage & e) const {return var_expression(e->RealArray(value_tag)[comp],(!mask || e->GetMarker(mask))?e->IntegerArray(index_tag)[comp]:ENUMUNDEF);}
Tag IndexTag() {return index_tag;}
Tag ValueTag() {return value_tag;}
var_expression operator [](const Storage & e) const {return var_expression(entry->Value(e,comp),entry->isValid(e)?entry->Index(e,comp):ENUMUNDEF);}
void GetVariation(const Storage & e, Sparse::Row & r) const { (*this)[e].GetJacobian(1.0,r); }
void GetVariation(const Storage & e, Sparse::RowMerger & r) const { (*this)[e].GetJacobian(1.0,r); }
bool isUnknown(const Storage & e) const {return (!mask || e->GetMarker(mask))?true:false;}
bool isUnknown(const Storage & e) const {return entry->isValid(e)?true:false;}
abstract_dynamic_variable * Copy() const {return static_cast<abstract_dynamic_variable *>(new dynamic_variable(*this));}
};
......
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