Commit 953b8f8d authored by Alexis SALZMAN's avatar Alexis SALZMAN
Browse files

Xfiles] miscellaneous change related to warnings

Changes are:
  * unused variable
  * wrong order for explicit member creation
  * wrong sign comparison
  * change int to size_t
  * virtual destructor addition to avoid in future a possible memory leek
parent c04103bc
This diff is collapsed.
......@@ -69,7 +69,7 @@ void xApproxFunctionBySupportComponentGenerator::generateKeysAndFcts(AOMD::mEnti
for (size_t i = 0; i < fctsnew.size(); ++i)
{
fcts->push_back(approxFctPtr_t(new xApproxFunctionEnrichedXFEM(f, fctsnew[i])));
sprintf(buffer, "%lu\0", i);
sprintf(buffer, "%zu\0", i);
key_modifier->addToExtension(std::string(buffer));
(*key_modifier)(key);
keys->push_back(key);
......@@ -82,9 +82,9 @@ void xApproxFunctionBySupportComponentGenerator::generateKeys(xfem::xValKey &key
femFcts_t fctsnew;
getEnrichmentFunctions(e_enriched, fctsnew);
char buffer[256];
for (int i = 0; i < fctsnew.size(); ++i)
for (size_t i = 0; i < fctsnew.size(); ++i)
{
sprintf(buffer, "%lu\0", i);
sprintf(buffer, "%zu\0", i);
key_modifier->addToExtension(std::string(buffer));
(*key_modifier)(key);
keys->push_back(key);
......
/*
/*
This file is a part of eXlibris C++ Library
under the GNU Lesser General Public License.
See the NOTICE.md & LICENSE.md files for terms
See the NOTICE.md & LICENSE.md files for terms
and conditions.
*/
......@@ -9,57 +9,67 @@
#define __SPACEFACTORY_H
#include <string>
#include "xSpace.h"
#include "xSpacePolynomial.h"
#include "xSpacePolynomialQH.h"
namespace xfem
{
class xNonLocalInfoGeneratorForKeysAndFcts;
class xNonLocalInfoGeneratorForKeysAndFcts;
class xSpaceFactoryBase
{
public:
enum space_product_tensorial_type { SCALAR, V1Dx, V1Dy, V1Dz, V2Dxy, V2Dxz, V2Dyz, V3D };
void setSpaceProductOrder(const int order_);
void setSpaceProductPhysStrings(std::vector<std::string> & phys_strings_ );
void setSpaceProductGenerator(xNonLocalInfoGeneratorForKeysAndFcts * generator);
const std::string & getPhysString( unsigned int id) const;
virtual xSpace::spacePtr getSpace()=0;
virtual xSpace::spacePtr getSpace(std::string s)=0;
protected:
template <typename SPACE >
SPACE createSpaceProduct(std::string &phys ,xSpace::TensorialType_t space_tensorial);
xSpaceLagrange::lag_degree_t getHierachicalOrder();
void setPhysString(std::string s1);
void forceSetPhysString(std::string & s1);
void setPhysString(std::string s1,std::string s2);
void setPhysString(std::string s1,std::string s2, std::string s3);
void error1();
xNonLocalInfoGeneratorForKeysAndFcts * generator;
std::vector<std::string> phys_strings;
int order;
public:
enum space_product_tensorial_type
{
SCALAR,
V1Dx,
V1Dy,
V1Dz,
V2Dxy,
V2Dxz,
V2Dyz,
V3D
};
void setSpaceProductOrder(const int order_);
void setSpaceProductPhysStrings(std::vector<std::string> &phys_strings_);
void setSpaceProductGenerator(xNonLocalInfoGeneratorForKeysAndFcts *generator);
const std::string &getPhysString(unsigned int id) const;
virtual ~xSpaceFactoryBase() = default;
virtual xSpace::spacePtr getSpace() = 0;
virtual xSpace::spacePtr getSpace(std::string s) = 0;
protected:
template <typename SPACE>
SPACE createSpaceProduct(std::string &phys, xSpace::TensorialType_t space_tensorial);
xSpaceLagrange::lag_degree_t getHierachicalOrder();
void setPhysString(std::string s1);
void forceSetPhysString(std::string &s1);
void setPhysString(std::string s1, std::string s2);
void setPhysString(std::string s1, std::string s2, std::string s3);
void error1();
xNonLocalInfoGeneratorForKeysAndFcts *generator;
std::vector<std::string> phys_strings;
int order;
};
template <typename SPACE, xSpaceFactoryBase::space_product_tensorial_type TT>
class xSpaceFactory : public xSpaceFactoryBase
{
public:
xSpaceFactory();
xSpace::spacePtr getSpace() override;
xSpace::spacePtr getSpace(std::string s) override;
private:
public:
xSpaceFactory();
xSpace::spacePtr getSpace() override;
xSpace::spacePtr getSpace(std::string s) override;
private:
};
} // end of namespace
} // namespace xfem
#include "xSpaceFactory_imp.h"
......
......@@ -336,7 +336,7 @@ xVertex aomdMeshQueryInterface::getMeshVertexFromId(int ID) const { return xVert
void aomdMeshQueryInterface::translateToPartitionManagerXentity(xPartitionManagerXentity& part_man_XENT,
const partmanAOMD_t& part_man_AOMD)
{
MPI_Comm _comm = part_man_AOMD.getComm();
// MPI_Comm _comm = part_man_AOMD.getComm();
// the new partition manager (to be return)
// xPartitionManagerXentity part_man_XENT(*this, _comm);
......
......@@ -3,182 +3,165 @@
#include <vector>
//#include <type_traits>
#include <string>
#include "xClassification.h"
#include "xPoint.h"
#include <string>
#include "small_any.h"
#include "xAttachableData.h"
#include "xClassification.h"
#include "xDataType.h"
#include "xMeshQueryInterface.h"
#include "xEntityType.h"
#include "xMeshQueryInterface.h"
#include "xPoint.h"
#include "xAttachableData.h"
namespace xinterface{
namespace xmeshinterface{
using any = small_any;
class xVertex;
class xEdge;
class xFace;
class xSolid;
class xEntity {
protected:
// here, a pointer to a query because it can be nullptr: use fonction isValid() to test. Use isGhost() to test if the query is know through its name (tag)
const xMeshQueryInterface* pQuery =nullptr;
any entity_identifier = 0 ;
mutable unsigned int tagOfQuery =0 ;
mutable void* uniqueAddress =nullptr;
public:
xEntity(const void* a, const unsigned int t);
template< typename T >
xEntity( const T& thing , const xMeshQueryInterface& _mi ): entity_identifier(thing) , pQuery(&_mi) , tagOfQuery(0),uniqueAddress(0) { }
public:
xEntity() = default;
xEntity& operator=(xEntity&&rhs) = default;
xEntity(xEntity&&rhs) = default;
xEntity(const xEntity &rhs) = default;
xEntity& operator=(const xEntity &rhs) = default;
virtual ~xEntity() {}
bool isGhost() const;
bool isValid() const;
const any& getEntityIdentifier() const ;
eType getType() const ;
int getId() const ;
int size(int i) const ;
xVertex getVertex( int j) const ;
xEdge getEdge( int j) const ;
xFace getFace( int j) const ;
xSolid getSolid( int j) const ;
xEntity get(int i , int j) const ;
xClassification getClassification() const;
int isAdjacencyCreated(int level) const ;
bool operator==(const xEntity& other) const ;
bool operator!=(const xEntity& other) const ;
bool operator< (const xEntity& other) const ;
bool operator> (const xEntity& other) const ;
public:
const xMeshQueryInterface* getQuery() const ;
int getLevel() const;
std::string printType() const;
void print() const ;
void printGhost() const ;
std::vector<xVertex> getVertices() const ;
std::vector<xVertex> &getVertices(std::vector<xVertex> &vertices) const ;
std::vector<xEdge> getEdges() const;
std::vector<xFace> getFaces() const;
std::vector<xSolid> getSolids() const ;
std::vector<xSolid> &getSolids(std::vector<xSolid> &solids) const ;
void* getUniqueAddress() const;
unsigned int getTagOfQuery() const ;
xtensor::xPoint getCentroid() const ;
public:
// ATTACH Methods------------------------------------------
template<typename T>
void attachData(const unsigned int& tag, const T& objet) const
{
void* stored = pQuery->getAttachedPointer(entity_identifier, tag);
if (stored) {
( static_cast<xAttachableData<T>*>(stored) )->setData(objet) ;
}
xAttachableData<T>* to_store = new xAttachableData<T>(objet);
const_cast<xMeshQueryInterface*>(pQuery)->attachPointer( const_cast<small_any&>(entity_identifier), tag, static_cast<void*>(to_store) );
}
template<typename T>
T& getData(const unsigned int& tag) const
namespace xinterface
{
namespace xmeshinterface
{
using any = small_any;
class xVertex;
class xEdge;
class xFace;
class xSolid;
class xEntity
{
protected:
// here, a pointer to a query because it can be nullptr: use fonction isValid() to test. Use isGhost() to test if the query is
// know through its name (tag)
const xMeshQueryInterface* pQuery = nullptr;
any entity_identifier = 0;
mutable unsigned int tagOfQuery = 0;
mutable void* uniqueAddress = nullptr;
public:
xEntity(const void* a, const unsigned int t);
template <typename T>
xEntity(const T& thing, const xMeshQueryInterface& _mi)
: pQuery(&_mi), entity_identifier(thing), tagOfQuery(0), uniqueAddress(0)
{
}
public:
xEntity() = default;
xEntity& operator=(xEntity&& rhs) = default;
xEntity(xEntity&& rhs) = default;
xEntity(const xEntity& rhs) = default;
xEntity& operator=(const xEntity& rhs) = default;
virtual ~xEntity() {}
bool isGhost() const;
bool isValid() const;
const any& getEntityIdentifier() const;
eType getType() const;
int getId() const;
int size(int i) const;
xVertex getVertex(int j) const;
xEdge getEdge(int j) const;
xFace getFace(int j) const;
xSolid getSolid(int j) const;
xEntity get(int i, int j) const;
xClassification getClassification() const;
int isAdjacencyCreated(int level) const;
bool operator==(const xEntity& other) const;
bool operator!=(const xEntity& other) const;
bool operator<(const xEntity& other) const;
bool operator>(const xEntity& other) const;
public:
const xMeshQueryInterface* getQuery() const;
int getLevel() const;
std::string printType() const;
void print() const;
void printGhost() const;
std::vector<xVertex> getVertices() const;
std::vector<xVertex>& getVertices(std::vector<xVertex>& vertices) const;
std::vector<xEdge> getEdges() const;
std::vector<xFace> getFaces() const;
std::vector<xSolid> getSolids() const;
std::vector<xSolid>& getSolids(std::vector<xSolid>& solids) const;
void* getUniqueAddress() const;
unsigned int getTagOfQuery() const;
xtensor::xPoint getCentroid() const;
public:
// ATTACH Methods------------------------------------------
template <typename T>
void attachData(const unsigned int& tag, const T& objet) const
{
void* stored = pQuery->getAttachedPointer(entity_identifier, tag);
if (stored)
{
void* stored = pQuery->getAttachedPointer(entity_identifier, tag);
if ( !stored)
{
std::cout << "ERROR: using xEntity::getData(tag="<<tag <<") while no data is attached."<<std::endl;
std::cout << " Use function xEntity::hasData(tag) to check if data exists" <<std::endl;
throw;
}
return ( static_cast<xAttachableData<T>*>(stored) )->getData() ;
(static_cast<xAttachableData<T>*>(stored))->setData(objet);
}
template<typename T>
void deleteData(const unsigned int& tag) const//deleteData
xAttachableData<T>* to_store = new xAttachableData<T>(objet);
const_cast<xMeshQueryInterface*>(pQuery)->attachPointer(const_cast<small_any&>(entity_identifier), tag,
static_cast<void*>(to_store));
}
template <typename T>
T& getData(const unsigned int& tag) const
{
void* stored = pQuery->getAttachedPointer(entity_identifier, tag);
if (!stored)
{
void* stored = pQuery->getAttachedPointer(entity_identifier, tag);
if (stored) delete static_cast<xAttachableData<T>*>(stored) ;
const_cast<xMeshQueryInterface*>(pQuery)->deleteAttachment(const_cast<small_any&>(entity_identifier), tag);
std::cout << "ERROR: using xEntity::getData(tag=" << tag << ") while no data is attached." << std::endl;
std::cout << " Use function xEntity::hasData(tag) to check if data exists" << std::endl;
throw;
}
bool hasData(const unsigned int& tag) const //hasData
{
void* stored = pQuery->getAttachedPointer(entity_identifier, tag);
if ( !stored) return false;
return true ;
}
};
} // namepsace xmeshinterface
} // namespace xinterface
namespace xtool {
/// Specialization of xDatatype for xEntity
template < >
class xDataType < xinterface::xmeshinterface::xEntity >{
public:
static xinterface::xmeshinterface::xEntity zero() { return xinterface::xmeshinterface::xEntity(); }
static std::string stype() { return "xEntity"; }
};
return (static_cast<xAttachableData<T>*>(stored))->getData();
}
template <typename T>
void deleteData(const unsigned int& tag) const // deleteData
{
void* stored = pQuery->getAttachedPointer(entity_identifier, tag);
if (stored) delete static_cast<xAttachableData<T>*>(stored);
const_cast<xMeshQueryInterface*>(pQuery)->deleteAttachment(const_cast<small_any&>(entity_identifier), tag);
}
bool hasData(const unsigned int& tag) const // hasData
{
void* stored = pQuery->getAttachedPointer(entity_identifier, tag);
if (!stored) return false;
return true;
}
};
} // namespace xmeshinterface
} // namespace xinterface
namespace xtool
{
/// Specialization of xDatatype for xEntity
template <>
class xDataType<xinterface::xmeshinterface::xEntity>
{
public:
static xinterface::xmeshinterface::xEntity zero() { return xinterface::xmeshinterface::xEntity(); }
static std::string stype() { return "xEntity"; }
};
} // namespace xtool
namespace std
{
template <>
inline bool std::equal_to<xinterface::xmeshinterface::xEntity>::operator()(const xinterface::xmeshinterface::xEntity& e,
const xinterface::xmeshinterface::xEntity& o) const
{
return (e == o);
}
template <>
struct hash<xinterface::xmeshinterface::xEntity>
{
int operator()(const xinterface::xmeshinterface::xEntity& e) const { return hash<int>()(e.getId()); }
};
namespace std {
template<>
inline bool std::equal_to< xinterface::xmeshinterface::xEntity >::operator() ( const xinterface::xmeshinterface::xEntity & e,
const xinterface::xmeshinterface::xEntity & o ) const
{
return (e==o);
}
template <> struct hash<xinterface::xmeshinterface::xEntity>
{
int operator()(const xinterface::xmeshinterface::xEntity & e) const
{
return hash<int>()( e.getId() );
}
};
}
} // namespace std
#endif
#ifndef _XPARTITIONMANAGERXENTITY_H
#define _XPARTITIONMANAGERXENTITY_H
#include "xEntity.h"
#include "xEntityHashKey.h"
#include "xPartitionManager.h"
#include "xGeneralUnorderedMapDataManager.h"
#include "xPartitionManager.h"
namespace xinterface{
namespace xmeshinterface{
// cas particulier pour xEntity : la map est gérée par xEntity, mais on stocke uniquement une void* correspondant à la UniqueAdDress de xEntity. Ceci se fait avec la fonction insertUntyped(...) du partitionObject (po).
template < class DATATYPE >
using DataManagerXentity = xtool::xGeneralUnorderedMapDataManager<xEntity, DATATYPE, xEntityHashKey, xEntityEqualKey >;
//--------------------------------------------------------------------------
// classe de base
//--------------------------------------------------------------------------
class xPartitionManagerXentityBase : public xtool::xPartitionManager< DataManagerXentity > {
public:
xPartitionManagerXentityBase(MPI_Comm _comm = MPI_COMM_WORLD) : xPartitionManager(_comm){};
~xPartitionManagerXentityBase() =default;
virtual xEntity getXentityFromUniqueAddressAndQueryTag( const void* address, unsigned int tag ) const =0;
virtual void print() const =0 ;
inline MPI_Comm getComm() const { return comm;};
};
class xPartitionManagerXentityUnion;
//--------------------------------------------------------------------------
// classe d'un partition_manager construit à partir d'une query
//--------------------------------------------------------------------------
class xPartitionManagerXentity : public xPartitionManagerXentityBase {
public:
xPartitionManagerXentity(const xMeshQueryInterface& _query, MPI_Comm _comm= MPI_COMM_WORLD): query(_query), xPartitionManagerXentityBase(_comm) {};
~xPartitionManagerXentity()=default;
xEntity getXentityFromUniqueAddressAndQueryTag( const void* address, unsigned int tag ) const;
inline const xMeshQueryInterface& getQuery() const {return query; };
void print() const;
protected:
// case of simple partition_manager (not union), query is needed but
xEntity getXentityFromUniqueAddress ( const void* address ) const;
friend xPartitionManagerXentityUnion;
private:
const xMeshQueryInterface& query;
};
//----------------------------------------------------------------------------------
// classe d'un partition_manager construit à partir d'une union de plusieurs query :
//----------------------------------------------------------------------------------
// => utile pour un DOF manager s'appuyant sur plusieurs queries/maillages
// xPartitionManagerXentityUnion----------------------------
class xPartitionManagerXentityUnion : public xPartitionManagerXentityBase {
private:
std::vector<const xPartitionManagerXentity*> partman_container;
public:
xPartitionManagerXentityUnion(MPI_Comm _comm= MPI_COMM_WORLD) : xPartitionManagerXentityBase( _comm) {};
~xPartitionManagerXentityUnion() ;
void add(const xPartitionManagerXentity& new_element);
const xtool::xConstPartitionObject < xEntity > getConstPartitionObject(xEntity& enti) const;
xEntity getXentityFromUniqueAddressAndQueryTag( const void* address , unsigned int tag) const;
void print() const;
};
} // namespace xmeshinterface
} // namespace xinterface
namespace xinterface
{
namespace xmeshinterface
{
// cas particulier pour xEntity : la map est gérée par xEntity, mais on stocke uniquement une void* correspondant à la
// UniqueAdDress de xEntity. Ceci se fait avec la fonction insertUntyped(...) du partitionObject (po).
template <class DATATYPE>
using DataManagerXentity = xtool::xGeneralUnorderedMapDataManager<xEntity, DATATYPE, xEntityHashKey, xEntityEqualKey>;
//--------------------------------------------------------------------------
// classe de base
//--------------------------------------------------------------------------
class xPartitionManagerXentityBase : public xtool::xPartitionManager<DataManagerXentity>
{
public:
xPartitionManagerXentityBase(MPI_Comm _comm = MPI_COMM_WORLD) : xPartitionManager(_comm){};
~xPartitionManagerXentityBase() = default;
virtual xEntity getXentityFromUniqueAddressAndQueryTag(const void* address, unsigned int tag) const = 0;
virtual void print() const = 0;
inline MPI_Comm getComm() const { return comm; };
};
class xPartitionManagerXentityUnion;
//--------------------------------------------------------------------------
// classe d'un partition_manager construit à partir d'une query
//--------------------------------------------------------------------------