Commit 3af9ff86 authored by Alexis SALZMAN's avatar Alexis SALZMAN

[xInterface][AOMD] add func to xMeshToolAOMD and xAOMDEntityUtil+misc

 * Add a getPoint function to simplify xPoint creation from mVertex (no
   need of vector like getPoints which is more general).

 * make alive commented (in xMesh) printMesh and printEntity functions.
   They will certainly move to AOMD interface one day. But for now
   please let them stay active has I use then for debugging in my
   application. No time to do a test case on the subject.

 * To avoid warning on unused variable clean creation of object returned
   by many function that are not used afterward.
parent 62dcf4fb
#ifndef XAOMDENTITYUTIL_H
#define XAOMDENTITYUTIL_H
#include <cassert>
#include <iostream>
// aomd trellis
#include "AOMD_Internals.h"
......@@ -104,6 +105,12 @@ inline std::vector<xtensor::xPoint> getPoints(const AOMD::mEntity &e)
for (size_t i = 0; i < nv; ++i) points[i] = static_cast<AOMD::mVertex *>(e.get(0, int(i)))->point();
return points;
}
//! Return an xPoint associated to vertex e.
inline xtensor::xPoint getPoint(const AOMD::mEntity &e)
{
assert(e.getLevel() == 0);
return static_cast<xtensor::xPoint>(static_cast<const AOMD::mVertex &>(e).point());
}
inline mType mapTomType(xmapping::xReferenceElementType in)
{
......@@ -168,6 +175,111 @@ inline xmapping::xReferenceElementType getRefElementType(const AOMD::mEntity &e)
return mapToxReferenceElementType(mtype);
}
/*! A crud function which print in given stream all topological information of an AOMD mEntity using node ID.
* If deep argument is true all declared adjacency of the given entity is also printed by using a recursive call
* to this function.
* Adress and ID of given entity are also printed
*/
inline void printEntity(std::ostream &os, const AOMD::mEntity *e, bool deep)
{
if (deep) os << std::endl;
int n;
switch (e->getLevel())
{
case 0:
{
os << "node " << e << " " << e->getId() << std::endl;
for (int i = 1; deep && i < 4; ++i)
{
if (e->isAdjacencyCreated(i))
{
os << " adjancy " << i << std::endl;
for (int k = 0, m = e->size(i); k < m; ++k) printEntity(os, e->get(i, k), false);
}
}
break;
}
case 1:
{
n = 2;
os << "edge " << e << " " << e->getId();
if (e->isAdjacencyCreated(0))
{
if (e->size(0) == n)
{
os << " (" << e->get(0, 0)->getId();
for (int k = 1; k < n; ++k) os << "-" << e->get(0, k)->getId();
os << ")" << std::endl;
}
else
os << " (wrong number of nodes !! sould be " << n << " but is " << e->size(0) << ")" << std::endl;
}
for (int i = 1; deep && i < 4; ++i)
{
if (e->isAdjacencyCreated(i))
{
os << " adjancy " << i << std::endl;
for (int k = 0, m = e->size(i); k < m; ++k) printEntity(os, e->get(i, k), false);
}
}
break;
}
case 2:
{
n = 3;
os << "tria " << e << " " << e->getId();
if (e->isAdjacencyCreated(0))
{
if (e->size(0) == n)
{
os << " (" << e->get(0, 0)->getId();
for (int k = 1; k < n; ++k) os << "-" << e->get(0, k)->getId();
os << ")" << std::endl;
}
else
os << " (wrong number of nodes !! sould be " << n << " but is " << e->size(0) << ")" << std::endl;
}
for (int i = 1; deep && i < 4; ++i)
{
if (e->isAdjacencyCreated(i))
{
os << " adjancy " << i << std::endl;
for (int k = 0, m = e->size(i); k < m; ++k) printEntity(os, e->get(i, k), false);
}
}
break;
}
case 3:
{
n = 4;
os << "tet " << e << " " << e->getId();
if (e->isAdjacencyCreated(0))
{
if (e->size(0) == n)
{
os << " (" << e->get(0, 0)->getId();
for (int k = 1; k < n; ++k) os << "-" << e->get(0, k)->getId();
os << ")" << std::endl;
}
else
os << " (wrong number of nodes !! sould be " << n << " but is " << e->size(0) << ")" << std::endl;
}
for (int i = 1; deep && i < 4; ++i)
{
if (e->isAdjacencyCreated(i))
{
os << " adjancy " << i << std::endl;
for (int k = 0, m = e->size(i); k < m; ++k) printEntity(os, e->get(i, k), false);
}
}
break;
}
}
}
} // end namespace aomd
} // namespace xinterface
......
......@@ -10,55 +10,62 @@
#include <vector>
#include "mEntity.h"
#include "mEdge.h"
#include "mEntity.h"
#include "mFace.h"
#include "mRegion.h"
#include "mHex.h"
#include "mRegion.h"
#include "mTet.h"
#include "xAttachedDataManagerAOMD.h"
// interface aomd
namespace xfem {
namespace xfem
{
class xMesh;
}
namespace xfem {
namespace xfem
{
class xMesh;
}
namespace xinterface {
namespace aomd {
namespace xinterface
{
namespace aomd
{
void modifyAllState(AOMD::mMesh& mmesh);
void modifyAllStateFalse(AOMD::mMesh& mmesh);
/// fill out with a hard copy of in.
/*!
link between elements of in and out are made using attached Entity with tags xMesh::has_a_copy_tag, and
xMesh::is_the_copy_of_tag. by defaults, so that the source mesh is not modifyied at all on exit, the attached entity to get the
copied element on the source mesh are deleted. Setting the flag clean_tag_on_source_mesh to false permit to keep then
*/
void xCopyMesh(const xfem::xMesh& in, xfem::xMesh& out);
void xCopyMesh(const xfem::xMesh& in, xfem::xMesh& out, xAttachedDataManagerAOMD<AOMD::mEntity*>& is_copied_to,
void xCopyMesh(const xfem::xMesh& in, xfem::xMesh& out, xAttachedDataManagerAOMD<AOMD::mEntity*>& is_copied_to,
xAttachedDataManagerAOMD<AOMD::mEntity*>& is_the_copy_of);
void Simplexify( AOMD::mMesh& );
void DeleteEntity( AOMD::mMesh&, AOMD::mEntity* );
void QuadToTri( AOMD::mMesh&, AOMD::mFace* );
void HexToTet( AOMD::mMesh&, AOMD::mHex* );
void PrismToTet( AOMD::mMesh&, AOMD::mEntity* );
void PyramidToTet( AOMD::mMesh&, AOMD::mEntity* );
void CreateTetWithPrismVertices( AOMD::mMesh&, int N0, int N1, int N2, int N3, int N4, int N5, AOMD::pGEntity );
void CreateTetWithPyramidVertices( AOMD::mMesh&, int N0, int N1, int N2, int N3, int N4, AOMD::pGEntity );
int IndexOfMinAmong( std::vector<int>& iValue, std::vector<int>& index );
void PrintMesh( AOMD::mMesh& );
}
}
void Simplexify(AOMD::mMesh&);
void DeleteEntity(AOMD::mMesh&, AOMD::mEntity*);
void QuadToTri(AOMD::mMesh&, AOMD::mFace*);
void HexToTet(AOMD::mMesh&, AOMD::mHex*);
void PrismToTet(AOMD::mMesh&, AOMD::mEntity*);
void PyramidToTet(AOMD::mMesh&, AOMD::mEntity*);
void CreateTetWithPrismVertices(AOMD::mMesh&, int N0, int N1, int N2, int N3, int N4, int N5, AOMD::pGEntity);
void CreateTetWithPyramidVertices(AOMD::mMesh&, int N0, int N1, int N2, int N3, int N4, AOMD::pGEntity);
int IndexOfMinAmong(std::vector<int>& iValue, std::vector<int>& index);
void PrintMesh(AOMD::mMesh&);
/*! A crud function which print a mesh using printEntity function. Only topological information are given.
* If deep argument is true all declared adjacency of all entities are also printed by calling printEntity
* with its deep parameter to true.
*/
void printMesh(std::ostream& os, xfem::xMesh& mesh, bool deep);
} // namespace aomd
} // namespace xinterface
#endif
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