Commit 6b241b0f authored by Kirill Terekhov's avatar Kirill Terekhov
Browse files

Updates

Doxygen comments for Automatizator class.

Some additional features for Automatizator class: copy/assignment, list
tags, unregister tag.

Fix compilation issue with Octree example on newer gcc.
parent 199f5aaa
......@@ -134,7 +134,7 @@ void NotMainProcess()
int type = type_C - '0';
//redistribute(&thegrid,type);
pre_redistribute(type);
cout << rank << ": iteration " << iteration++ << " complete. Cells: " << thegrid.mesh->NumberOfCells() << endl;
cout << ::rank << ": iteration " << iteration++ << " complete. Cells: " << thegrid.mesh->NumberOfCells() << endl;
}
if (buff[0] == 'u') // Need remove ghosts
{
......@@ -315,7 +315,7 @@ int main(int argc, char ** argv)
::rank = thegrid.mesh->GetProcessorRank();
//dump_to_vtk();
if (rank == 0) cout << "Test start" << endl;
if (::rank == 0) cout << "Test start" << endl;
{
mx = 0.1;
......@@ -329,24 +329,24 @@ int main(int argc, char ** argv)
{
BARRIER
ct = Timer();
if (rank == 0) LOG(1, "Iteration: " << i)
if (::rank == 0) LOG(1, "Iteration: " << i)
gridAMR(&thegrid,0);
BARRIER
tt = Timer();
if (rank == 0) LOG(1, "AMR time = " << tt-ct);
if (::rank == 0) LOG(1, "AMR time = " << tt-ct);
ct = tt;
redistribute(&thegrid, 0);
BARRIER
tt = Timer();
if (rank == 0) LOG(1, "Red time = " << tt-ct);
if (::rank == 0) LOG(1, "Red time = " << tt-ct);
ct = tt;
LOG(2, rank << ": iteration " << i << " complete. Cells: " << thegrid.mesh->NumberOfCells())
LOG(2, ::rank << ": iteration " << i << " complete. Cells: " << thegrid.mesh->NumberOfCells())
i++;
mx += h;
}
BARRIER
tt = Timer() - tt;
if (rank == 0) cout << "time = " << tt << endl;
if (::rank == 0) cout << "time = " << tt << endl;
dump_to_vtk(&thegrid);
// send_dump_command();
......
......@@ -54,34 +54,74 @@ namespace INMOST
#endif //USE_MESH
#if defined(USE_MESH)
Automatizator::Automatizator() :first_num(0), last_num(0) {}
Automatizator::Automatizator(const Automatizator & b) : name(b.name+"_copy")
{
std::vector<INMOST_DATA_ENUM_TYPE> regs = b.ListRegisteredTags();
for(std::vector<INMOST_DATA_ENUM_TYPE>::iterator kt = regs.begin(); kt != regs.end(); ++kt)
RegisterTag(b.GetValueTag(*kt),b.GetElementType(*kt),b.GetMask(*kt));
if( b.last_num != 0 ) EnumerateTags();
}
Automatizator & Automatizator::operator =(Automatizator const & b)
{
if( &b != this )
{
name = b.name+"_copy";
del_tags.clear();
reg_tags.clear();
std::vector<INMOST_DATA_ENUM_TYPE> regs = b.ListRegisteredTags();
for(std::vector<INMOST_DATA_ENUM_TYPE>::iterator kt = regs.begin(); kt != regs.end(); ++kt)
RegisterTag(b.GetValueTag(*kt),b.GetElementType(*kt),b.GetMask(*kt));
if( b.last_num != 0 ) EnumerateTags();
}
return *this;
}
Automatizator::Automatizator(std::string _name) :name(_name), first_num(0), last_num(0) {}
Automatizator::~Automatizator()
{
for (unsigned k = 0; k < index_tags.size(); k++)
index_tags[k].indices = index_tags[k].indices.GetMeshLink()->DeleteTag(index_tags[k].indices);
del_tags.clear();
for (unsigned k = 0; k < reg_tags.size(); k++) if( reg_tags[k].active )
reg_tags[k].indices = reg_tags[k].indices.GetMeshLink()->DeleteTag(reg_tags[k].indices);
}
INMOST_DATA_ENUM_TYPE Automatizator::RegisterTag(Tag t, ElementType typemask, MarkerType domain_mask)
{
tagpair p;
p.d.domain_mask = domain_mask;
p.d.t = t;
tagdata p;
p.domain_mask = domain_mask;
p.t = t;
ElementType def = NONE, sparse = NONE;
for (ElementType q = NODE; q <= MESH; q = q << 1) if (q & typemask)
{
if (t.isDefined(q)) def |= q;
if (t.isSparse(q)) sparse |= q;
}
p.indices = t.GetMeshLink()->CreateTag(t.GetTagName() + "_index", DATA_INTEGER, def, sparse, t.GetSize());
INMOST_DATA_ENUM_TYPE ret = static_cast<INMOST_DATA_ENUM_TYPE>(reg_tags.size());
reg_tags.push_back(p);
index_tags.push_back(p);
p.indices = t.GetMeshLink()->CreateTag(t.GetTagName() + "_index_" + name, DATA_INTEGER, def, sparse, t.GetSize());
p.active = true;
INMOST_DATA_ENUM_TYPE ret;
if( del_tags.empty() )
{
ret = static_cast<INMOST_DATA_ENUM_TYPE>(reg_tags.size());
reg_tags.push_back(p);
}
else
{
ret = del_tags.back();
assert(!reg_tags[ret].active);
del_tags.pop_back();
reg_tags[ret] = p;
}
return ret;
}
void Automatizator::UnregisterTag(INMOST_DATA_ENUM_TYPE ind)
{
assert(reg_tags[ind].active);
del_tags.push_back(ind);
reg_tags[ind].active = false;
}
void Automatizator::EnumerateTags()
{
first_num = last_num = 0;
const ElementType paralleltypes = NODE | EDGE | FACE | CELL;
for (index_enum::iterator it = index_tags.begin(); it != index_tags.end(); ++it)
for (tag_enum::iterator it = reg_tags.begin(); it != reg_tags.end(); ++it) if( it->active )
{
Mesh * m = it->indices.GetMeshLink();
for (ElementType etype = NODE; etype <= MESH; etype = etype << 1)
......@@ -93,10 +133,10 @@ namespace INMOST
}
for (index_enum::iterator it = index_tags.begin(); it != index_tags.end(); ++it)
for (tag_enum::iterator it = reg_tags.begin(); it != reg_tags.end(); ++it) if( it->active )
{
Mesh * m = it->indices.GetMeshLink();
for (ElementType etype = NODE; etype <= MESH; etype = etype << 1)
for (ElementType etype = MESH; etype >= NODE; etype = PrevElementType(etype))
{
if (it->indices.isDefined(etype))
{
......@@ -106,10 +146,10 @@ namespace INMOST
{
for (Mesh::iteratorStorage jt = m->Begin(etype); jt != m->End(); ++jt)
{
if ((!(etype & paralleltypes) || ((etype & paralleltypes) && jt->getAsElement()->GetStatus() != Element::Ghost)) && (it->d.domain_mask == 0 || jt->GetMarker(it->d.domain_mask)))
if ((!(etype & paralleltypes) || ((etype & paralleltypes) && jt->getAsElement()->GetStatus() != Element::Ghost)) && (it->domain_mask == 0 || jt->GetMarker(it->domain_mask)))
{
Storage::integer_array indarr = jt->IntegerArray(it->indices);
indarr.resize(jt->RealArray(it->d.t).size());
indarr.resize(jt->RealArray(it->t).size());
for (Storage::integer_array::iterator qt = indarr.begin(); qt != indarr.end(); ++qt)
*qt = last_num++;
}
......@@ -119,10 +159,10 @@ namespace INMOST
{
for (Mesh::iteratorStorage jt = m->Begin(etype); jt != m->End(); ++jt)
{
if ((!(etype & paralleltypes) || ((etype & paralleltypes) && jt->getAsElement()->GetStatus() != Element::Ghost)) && (jt->HaveData(it->d.t) && (it->d.domain_mask == 0 || jt->GetMarker(it->d.domain_mask))))
if ((!(etype & paralleltypes) || ((etype & paralleltypes) && jt->getAsElement()->GetStatus() != Element::Ghost)) && (jt->HaveData(it->t) && (it->domain_mask == 0 || jt->GetMarker(it->domain_mask))))
{
Storage::integer_array indarr = jt->IntegerArray(it->indices);
indarr.resize(jt->RealArray(it->d.t).size());
indarr.resize(jt->RealArray(it->t).size());
for (Storage::integer_array::iterator qt = indarr.begin(); qt != indarr.end(); ++qt)
*qt = last_num++;
}
......@@ -135,7 +175,7 @@ namespace INMOST
{
for (Mesh::iteratorStorage jt = m->Begin(etype); jt != m->End(); ++jt)
{
if ((!(etype & paralleltypes) || ((etype & paralleltypes) && jt->getAsElement()->GetStatus() != Element::Ghost)) && (it->d.domain_mask == 0 || jt->GetMarker(it->d.domain_mask)))
if ((!(etype & paralleltypes) || ((etype & paralleltypes) && jt->getAsElement()->GetStatus() != Element::Ghost)) && (it->domain_mask == 0 || jt->GetMarker(it->domain_mask)))
{
Storage::integer_array indarr = jt->IntegerArray(it->indices);
for (Storage::integer_array::iterator qt = indarr.begin(); qt != indarr.end(); ++qt)
......@@ -147,7 +187,7 @@ namespace INMOST
{
for (Mesh::iteratorStorage jt = m->Begin(etype); jt != m->End(); ++jt)
{
if ((!(etype & paralleltypes) || ((etype & paralleltypes) && jt->getAsElement()->GetStatus() != Element::Ghost)) && (jt->HaveData(it->d.t) && (it->d.domain_mask == 0 || jt->GetMarker(it->d.domain_mask))))
if ((!(etype & paralleltypes) || ((etype & paralleltypes) && jt->getAsElement()->GetStatus() != Element::Ghost)) && (jt->HaveData(it->t) && (it->domain_mask == 0 || jt->GetMarker(it->domain_mask))))
{
Storage::integer_array indarr = jt->IntegerArray(it->indices);
for (Storage::integer_array::iterator qt = indarr.begin(); qt != indarr.end(); ++qt)
......@@ -168,10 +208,10 @@ namespace INMOST
MPI_Scan(&last_num, &first_num, 1, INMOST_MPI_DATA_ENUM_TYPE, MPI_SUM, MPI_COMM_WORLD);
first_num -= last_num;
ElementType exch_mask = NONE;
for (index_enum::iterator it = index_tags.begin(); it != index_tags.end(); ++it)
for (tag_enum::iterator it = reg_tags.begin(); it != reg_tags.end(); ++it) if( it->active )
{
Mesh * m = it->indices.GetMeshLink();
for (ElementType etype = NODE; etype <= MESH; etype = etype << 1)
for (ElementType etype = NODE; etype <= MESH; etype = NextElementType(etype))
{
if (it->indices.isDefined(etype))
{
......@@ -182,7 +222,7 @@ namespace INMOST
{
for (Mesh::iteratorStorage jt = m->Begin(etype); jt != m->End(); ++jt)
{
if ((!(etype & paralleltypes) || ((etype & paralleltypes) && jt->getAsElement()->GetStatus() != Element::Ghost)) && (it->d.domain_mask == 0 || jt->GetMarker(it->d.domain_mask)))
if ((!(etype & paralleltypes) || ((etype & paralleltypes) && jt->getAsElement()->GetStatus() != Element::Ghost)) && (it->domain_mask == 0 || jt->GetMarker(it->domain_mask)))
{
Storage::integer_array indarr = jt->IntegerArray(it->indices);
for (Storage::integer_array::iterator qt = indarr.begin(); qt != indarr.end(); ++qt)
......@@ -194,10 +234,10 @@ namespace INMOST
{
for (Mesh::iteratorStorage jt = m->Begin(etype); jt != m->End(); ++jt)
{
if ((!(etype & paralleltypes) || ((etype & paralleltypes) && jt->getAsElement()->GetStatus() != Element::Ghost)) && (jt->HaveData(it->d.t) && (it->d.domain_mask == 0 || jt->GetMarker(it->d.domain_mask))))
if ((!(etype & paralleltypes) || ((etype & paralleltypes) && jt->getAsElement()->GetStatus() != Element::Ghost)) && (jt->HaveData(it->t) && (it->domain_mask == 0 || jt->GetMarker(it->domain_mask))))
{
Storage::integer_array indarr = jt->IntegerArray(it->indices);
indarr.resize(jt->RealArray(it->d.t).size());
indarr.resize(jt->RealArray(it->t).size());
for (Storage::integer_array::iterator qt = indarr.begin(); qt != indarr.end(); ++qt)
*qt += first_num;
}
......@@ -210,7 +250,7 @@ namespace INMOST
{
for (Mesh::iteratorStorage jt = m->Begin(etype); jt != m->End(); ++jt)
{
if ((!(etype & paralleltypes) || ((etype & paralleltypes) && jt->getAsElement()->GetStatus() != Element::Ghost)) && (it->d.domain_mask == 0 || jt->GetMarker(it->d.domain_mask)))
if ((!(etype & paralleltypes) || ((etype & paralleltypes) && jt->getAsElement()->GetStatus() != Element::Ghost)) && (it->domain_mask == 0 || jt->GetMarker(it->domain_mask)))
{
Storage::integer_array indarr = jt->IntegerArray(it->indices);
for (Storage::integer_array::iterator qt = indarr.begin(); qt != indarr.end(); ++qt)
......@@ -222,7 +262,7 @@ namespace INMOST
{
for (Mesh::iteratorStorage jt = m->Begin(etype); jt != m->End(); ++jt)
{
if ((!(etype & paralleltypes) || ((etype & paralleltypes) && jt->getAsElement()->GetStatus() != Element::Ghost)) && (jt->HaveData(it->d.t) && (it->d.domain_mask == 0 || jt->GetMarker(it->d.domain_mask))))
if ((!(etype & paralleltypes) || ((etype & paralleltypes) && jt->getAsElement()->GetStatus() != Element::Ghost)) && (jt->HaveData(it->t) && (it->domain_mask == 0 || jt->GetMarker(it->domain_mask))))
{
Storage::integer_array indarr = jt->IntegerArray(it->indices);
for (Storage::integer_array::iterator qt = indarr.begin(); qt != indarr.end(); ++qt)
......@@ -238,16 +278,16 @@ namespace INMOST
last_num += first_num;
{
std::map<Mesh *,std::vector<Tag> > exch_tags;
for (index_enum::iterator it = index_tags.begin(); it != index_tags.end(); ++it)
for (tag_enum::iterator it = reg_tags.begin(); it != reg_tags.end(); ++it) if( it->active )
exch_tags[it->indices.GetMeshLink()].push_back(it->indices);
for(std::map<Mesh *,std::vector<Tag> >::iterator it = exch_tags.begin(); it != exch_tags.end(); ++it)
it->first->ExchangeData(it->second, exch_mask,0);
}
//compute out-of-bounds indices
for (index_enum::iterator it = index_tags.begin(); it != index_tags.end(); ++it)
for (tag_enum::iterator it = reg_tags.begin(); it != reg_tags.end(); ++it) if( it->active )
{
Mesh * m = it->indices.GetMeshLink();
for (ElementType etype = NODE; etype <= MESH; etype = etype << 1)
for (ElementType etype = NODE; etype <= MESH; etype = NextElementType(etype))
{
if (it->indices.isDefined(etype))
{
......@@ -258,7 +298,7 @@ namespace INMOST
{
for (Mesh::iteratorStorage jt = m->Begin(etype); jt != m->End(); ++jt)
{
if ((!(etype & paralleltypes) || ((etype & paralleltypes) && jt->getAsElement()->GetStatus() == Element::Ghost)) && (it->d.domain_mask == 0 || jt->GetMarker(it->d.domain_mask)))
if ((!(etype & paralleltypes) || ((etype & paralleltypes) && jt->getAsElement()->GetStatus() == Element::Ghost)) && (it->domain_mask == 0 || jt->GetMarker(it->domain_mask)))
{
Storage::integer_array indarr = jt->IntegerArray(it->indices);
for (Storage::integer_array::iterator qt = indarr.begin(); qt != indarr.end(); ++qt)
......@@ -273,10 +313,10 @@ namespace INMOST
{
for (Mesh::iteratorStorage jt = m->Begin(etype); jt != m->End(); ++jt)
{
if ((!(etype & paralleltypes) || ((etype & paralleltypes) && jt->getAsElement()->GetStatus() == Element::Ghost)) && (jt->HaveData(it->d.t) && (it->d.domain_mask == 0 || jt->GetMarker(it->d.domain_mask))))
if ((!(etype & paralleltypes) || ((etype & paralleltypes) && jt->getAsElement()->GetStatus() == Element::Ghost)) && (jt->HaveData(it->t) && (it->domain_mask == 0 || jt->GetMarker(it->domain_mask))))
{
Storage::integer_array indarr = jt->IntegerArray(it->indices);
indarr.resize(jt->RealArray(it->d.t).size());
indarr.resize(jt->RealArray(it->t).size());
for (Storage::integer_array::iterator qt = indarr.begin(); qt != indarr.end(); ++qt)
{
if( static_cast<INMOST_DATA_ENUM_TYPE>(*qt) < first_num ) Pre.insert(*qt);
......@@ -292,7 +332,7 @@ namespace INMOST
{
for (Mesh::iteratorStorage jt = m->Begin(etype); jt != m->End(); ++jt)
{
if ((!(etype & paralleltypes) || ((etype & paralleltypes) && jt->getAsElement()->GetStatus() == Element::Ghost)) && (it->d.domain_mask == 0 || jt->GetMarker(it->d.domain_mask)))
if ((!(etype & paralleltypes) || ((etype & paralleltypes) && jt->getAsElement()->GetStatus() == Element::Ghost)) && (it->domain_mask == 0 || jt->GetMarker(it->domain_mask)))
{
Storage::integer_array indarr = jt->IntegerArray(it->indices);
for (Storage::integer_array::iterator qt = indarr.begin(); qt != indarr.end(); ++qt)
......@@ -307,7 +347,7 @@ namespace INMOST
{
for (Mesh::iteratorStorage jt = m->Begin(etype); jt != m->End(); ++jt)
{
if ((!(etype & paralleltypes) || ((etype & paralleltypes) && jt->getAsElement()->GetStatus() == Element::Ghost)) && (jt->HaveData(it->d.t) && (it->d.domain_mask == 0 || jt->GetMarker(it->d.domain_mask))))
if ((!(etype & paralleltypes) || ((etype & paralleltypes) && jt->getAsElement()->GetStatus() == Element::Ghost)) && (jt->HaveData(it->t) && (it->domain_mask == 0 || jt->GetMarker(it->domain_mask))))
{
Storage::integer_array indarr = jt->IntegerArray(it->indices);
for (Storage::integer_array::iterator qt = indarr.begin(); qt != indarr.end(); ++qt)
......@@ -343,6 +383,23 @@ namespace INMOST
merger.Resize(first_num,last_num,std::vector<INMOST_DATA_ENUM_TYPE>(Pre.begin(),Pre.end()),std::vector<INMOST_DATA_ENUM_TYPE>(Post.begin(),Post.end()),false);
#endif
}
std::vector<INMOST_DATA_ENUM_TYPE> Automatizator::ListRegisteredTags() const
{
std::vector<INMOST_DATA_ENUM_TYPE> ret;
for(tag_enum::size_type it = 0; it < reg_tags.size(); ++it) if( reg_tags[it].active )
ret.push_back(static_cast<INMOST_DATA_ENUM_TYPE>(it));
return ret;
}
ElementType Automatizator::GetElementType(INMOST_DATA_ENUM_TYPE ind) const
{
Tag index = GetIndexTag(ind);
ElementType ret = NONE;
for(ElementType etype = NODE; etype <= MESH; etype = NextElementType(etype))
ret |= (index.isDefined(etype) ? etype : NONE);
return ret;
}
#endif //USE_MESH
};
......
......@@ -5,24 +5,10 @@
#include "inmost_mesh.h"
#include "inmost_solver.h"
#include "inmost_variable.h"
#include <sstream> //for debug
//#define NEW_VERSION
//#if defined(USE_AUTODIFF) && (!defined(USE_MESH))
//#warning "USE_AUTODIFF require USE_MESH"
//#undef USE_AUTODIFF
//#endif
//#define DPRNT
#if defined(USE_AUTODIFF)
#include <math.h>
namespace INMOST
{
class Automatizator; //forward declaration
......@@ -128,44 +114,111 @@ namespace INMOST
#endif
#if defined(USE_MESH)
/// The Automatizator class helps in defining primary unknowns of the model and
/// enhances user experience in interaction with automatic differentiation functionality.
/// User may declare real-typed mesh data as primary unknowns on the mesh with the
/// function RegisterTag. The returned integer code can be used with dynamic_variable
/// class, that is part of automatic differentiation framework helping to assemble
/// unknowns or expressions that could be evaluated into variable on the mesh element.
/// In addition this class provides automatic differentiation with acceleration structures
/// that help evaluate expressions faster.
/// \todo
/// 1. UnRegisterTag.
/// 2. (test) Copy constructor.
class Automatizator
{
private:
static Automatizator * CurrentAutomatizator;
static Automatizator * CurrentAutomatizator; //< Currently used automatizator for automatic differentiation acceleration structures.
#if defined(USE_OMP)
std::vector<Sparse::RowMerger> merger;
std::vector<Sparse::RowMerger> merger; //< Automatic differentiation acceleration structures.
#else
Sparse::RowMerger merger;
Sparse::RowMerger merger; //< Automatic differentiation acceleration structures.
#endif
typedef struct{ Tag t; MarkerType domain_mask; } tagdomain;
typedef struct{ tagdomain d; Tag indices; } tagpair;
typedef dynarray<tagpair, 128> tagpairs_type;
typedef std::vector<tagpair> index_enum;
typedef struct{ Tag t, indices; MarkerType domain_mask; bool active;} tagdata; //< Pair of tag and it's mask marker.
typedef std::vector<tagdata> tag_enum; //< A type for an array of registered tags.
typedef std::vector<INMOST_DATA_ENUM_TYPE> del_enum; // A type for an array of deleted positions.
private:
index_enum index_tags;
tagpairs_type reg_tags;
INMOST_DATA_ENUM_TYPE first_num;
INMOST_DATA_ENUM_TYPE last_num;
std::string name; //< Name of the automatizator.
del_enum del_tags; //< Array of deleted positions.
tag_enum reg_tags; //< Array of registered tags.
INMOST_DATA_ENUM_TYPE first_num; //< First index in unknowns of locally owned elements.
INMOST_DATA_ENUM_TYPE last_num; //< Last index in unknowns of locally owned elements.
public:
Automatizator();
/// Make a copy.
/// \warning
/// Calls Automatizator::EnumerateTags after copy for indices
/// to be valid only if original was enumerated.
Automatizator(const Automatizator & b);
/// Performs assignment.
/// \warning
/// Calls Automatizator::EnumerateTags after copy for indices
/// to be valid only if original was enumerated.
Automatizator & operator =(Automatizator const & b);
/// Makes an empty Automatizator.
Automatizator(std::string name = "");
/// Destructor for the automatizator, deletes all the tags corresponding to indices from
/// respective meshes.
~Automatizator();
__INLINE INMOST_DATA_ENUM_TYPE GetFirstIndex() { return first_num; }
__INLINE INMOST_DATA_ENUM_TYPE GetLastIndex() { return last_num; }
/// Retrive first index of unknowns, local to the processor.
__INLINE INMOST_DATA_ENUM_TYPE GetFirstIndex() const { return first_num; }
/// Retrive last index of unknowns, local to the processor.
__INLINE INMOST_DATA_ENUM_TYPE GetLastIndex() const { return last_num; }
/// Set data of tag t defined on domain_mask to be dynamic data.
/// @param t Tag of DATA_REAL that represents independent data of the model.
/// @param typemask Element types on which that data is independent.
/// @param domain_mask Marker that may be used to mask indepndent data on certain elements.
/// \warning
/// Don't register tag twice.
/// 1. Don't register tag twice.
/// 2. Have to call Automatizator::EnumerateTags to compute indices.
/// \todo
/// Read comments inside, change merger.Resize() behavior.
INMOST_DATA_ENUM_TYPE RegisterTag(Tag t, ElementType typemask, MarkerType domain_mask = 0);
INMOST_DATA_ENUM_TYPE RegisterTag(Tag t, ElementType typemask, MarkerType domain_mask = 0);
/// Erase a registered tag.
/// @param ind Integer returned from Automatizator::RegisterTag.
/// \warning
/// 1. Have to call Automatizator::EnumerateTags to recompute indices.
void UnregisterTag(INMOST_DATA_ENUM_TYPE ind);
/// Set index for every data entry of dynamic tag.
void EnumerateTags();
__INLINE Tag GetValueTag(INMOST_DATA_ENUM_TYPE ind) { return reg_tags[ind].d.t; }
__INLINE Tag GetIndexTag(INMOST_DATA_ENUM_TYPE ind) { return reg_tags[ind].indices; }
__INLINE MarkerType GetMask(INMOST_DATA_ENUM_TYPE ind) { return reg_tags[ind].d.domain_mask; }
__INLINE INMOST_DATA_REAL_TYPE GetValue(const Storage & e, INMOST_DATA_ENUM_TYPE ind, INMOST_DATA_ENUM_TYPE comp = 0) { return e->RealArray(GetValueTag(ind))[comp]; }
__INLINE INMOST_DATA_ENUM_TYPE GetIndex(const Storage & e, INMOST_DATA_ENUM_TYPE ind, INMOST_DATA_ENUM_TYPE comp = 0) { return e->IntegerArray(GetIndexTag(ind))[comp]; }
__INLINE bool isValid(const Storage & e, INMOST_DATA_ENUM_TYPE ind) { MarkerType mask = GetMask(ind); return mask == 0 || e->GetMarker(mask); }
Sparse::RowMerger & GetMerger()
void EnumerateTags();
/// Check whether the tag is still registered.
/// @param True if tag is still registered.
__INLINE bool isRegistretedTag(INMOST_DATA_ENUM_TYPE ind) const {return reg_tags[ind].active;}
/// Retrive the tag that is used to store values of the unknown on the mesh.
/// This is the same tag as provided to Automatizator::RegisterTag.
/// @param ind Integer returned from Automatizator::RegisterTag.
/// @return Tag related to values.
__INLINE Tag GetValueTag(INMOST_DATA_ENUM_TYPE ind) const { return reg_tags[ind].t; }
/// Retrive the tag that is used to store indices of the unknown on the mesh.
/// @param ind Integer returned from Automatizator::RegisterTag.
/// @return Tag related to indices.
__INLINE Tag GetIndexTag(INMOST_DATA_ENUM_TYPE ind) const { return reg_tags[ind].indices; }
/// Retrive the mask marker of the registered tag.
/// @param ind Integer returned from Automatizator::RegisterTag.
/// @return Mask marker.
__INLINE MarkerType GetMask(INMOST_DATA_ENUM_TYPE ind) const { return reg_tags[ind].domain_mask; }
/// Retrive the type of elements for the registered tag.
/// @param ind Integer returned from Automatizator::RegisterTag.
/// @return Element types.
ElementType GetElementType(INMOST_DATA_ENUM_TYPE ind) const;
/// Retrive value of the unknown on provided mesh element.
/// @param e Mesh element.
/// @param ind Integer returned from Automatizator::RegisterTag.
/// @return Value of the unknown on element.
__INLINE INMOST_DATA_REAL_TYPE GetValue(const Storage & e, INMOST_DATA_ENUM_TYPE ind, INMOST_DATA_ENUM_TYPE comp = 0) const { return e->RealArray(GetValueTag(ind))[comp]; }
/// Retrive index of the unknown on provided mesh element.
/// @param e Mesh element.
/// @param ind Integer returned from Automatizator::RegisterTag.
/// @return Index of the unknown on element.
__INLINE INMOST_DATA_ENUM_TYPE GetIndex(const Storage & e, INMOST_DATA_ENUM_TYPE ind, INMOST_DATA_ENUM_TYPE comp = 0) const { return e->IntegerArray(GetIndexTag(ind))[comp]; }
/// Check that the data is defined and independent on provided mesh element.
/// @param e Mesh element.
/// @param ind Integer returned from Automatizator::RegisterTag.
/// @return Returns true if the data is defined.
__INLINE bool isValid(const Storage & e, INMOST_DATA_ENUM_TYPE ind) const { MarkerType mask = GetMask(ind); return mask == 0 || e->GetMarker(mask); }
/// Retrive acceleration structure for automatic differentiation.
/// This structure can be used for operations on the matrix.
/// @return Acceleration structure.
Sparse::RowMerger & GetMerger()
{
#if defined(USE_OMP)
return merger[omp_get_thread_num()];
......@@ -173,14 +226,18 @@ namespace INMOST
return merger;
#endif
}
/// Remove global current automatizator.
/// Remove global current automatizator used to set acceleration structures for automatic differentation.
static void RemoveCurrent() {CurrentAutomatizator = NULL;}
/// Set current global automatizator, so that variable will be optimized with row merger.
static void MakeCurrent(Automatizator * aut) {CurrentAutomatizator = aut;}
/// Check that there is an automatizator.
static bool HaveCurrent() {return CurrentAutomatizator != NULL;}
/// Retrive the automatizator.
/// @return Currently set automatizator.
static Automatizator * GetCurrent() {return CurrentAutomatizator;}
/// Lists all the indices of registered tags.
/// @return An array with indices corresponding to all registered tags.
std::vector<INMOST_DATA_ENUM_TYPE> ListRegisteredTags() const;
};
#endif
} //namespace INMOST
......
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