dudley/src/NodeFile.h
Go to the documentation of this file.
/*****************************************************************************
*
* Copyright (c) 2003-2020 by The University of Queensland
* http://www.uq.edu.au
*
* Primary Business: Queensland, Australia
* Licensed under the Apache License, version 2.0
* http://www.apache.org/licenses/LICENSE-2.0
*
* Development until 2012 by Earth Systems Science Computational Center (ESSCC)
* Development 2012-2013 by School of Earth Sciences
* Development from 2014-2017 by Centre for Geoscience Computing (GeoComp)
* Development from 2019 by School of Earth and Environmental Sciences
**
*****************************************************************************/
#ifndef __DUDLEY_NODEFILE_H__
#define __DUDLEY_NODEFILE_H__
#include "Dudley.h"
#include "NodeMapping.h"
#include <escript/Distribution.h>
#ifdef ESYS_HAVE_PASO
#include <paso/Coupler.h>
#endif
#ifdef ESYS_HAVE_TRILINOS
#include <trilinoswrap/types.h>
#endif
namespace escript {
struct IndexList;
}
namespace dudley {
class NodeFile
{
public:
NodeFile(int nDim, escript::JMPI MPIInfo);
~NodeFile();
void allocTable(dim_t numNodes);
void freeTable();
void print() const;
inline index_t getFirstNode() const;
inline index_t getLastNode() const;
inline dim_t getGlobalNumNodes() const;
inline const index_t* borrowGlobalNodesIndex() const;
inline dim_t getNumNodes() const;
inline dim_t getNumDegreesOfFreedom() const;
inline dim_t getNumDegreesOfFreedomTargets() const;
inline const index_t* borrowNodesTarget() const;
inline const index_t* borrowDegreesOfFreedomTarget() const;
inline const index_t* borrowTargetDegreesOfFreedom() const;
inline const index_t* borrowTargetNodes() const;
inline void updateTagList();
dim_t createDenseDOFLabeling();
dim_t createDenseNodeLabeling(IndexVector& nodeDistribution,
const IndexVector& dofDistribution);
void createNodeMappings(const IndexVector& dofDistribution,
const IndexVector& nodeDistribution);
void assignMPIRankToDOFs(int* mpiRankOfDOF,
const IndexVector& distribution);
void copyTable(index_t offset, index_t idOffset, index_t dofOffset,
const NodeFile* in);
void gather(const index_t* index, const NodeFile* in);
void gather_global(const index_t* index, const NodeFile* in);
void setCoordinates(const escript::Data& newX);
void setTags(int newTag, const escript::Data& mask);
std::pair<index_t,index_t> getDOFRange() const;
#ifdef ESYS_HAVE_TRILINOS
void createTrilinosGraph(const escript::IndexList* indexList);
esys_trilinos::const_TrilinosGraph_ptr getTrilinosGraph() const {
return m_graph;
}
#endif
private:
std::pair<index_t,index_t> getGlobalIdRange() const;
std::pair<index_t,index_t> getGlobalDOFRange() const;
std::pair<index_t,index_t> getGlobalNodeIDIndexRange() const;
dim_t prepareLabeling(const std::vector<short>& mask, IndexVector& buffer,
IndexVector& distribution, bool useNodes);
void createDOFMappingAndCoupling();
NodeMapping nodesMapping;
NodeMapping degreesOfFreedomMapping;
dim_t numNodes;
#ifdef ESYS_HAVE_TRILINOS
esys_trilinos::const_TrilinosGraph_ptr m_graph;
#endif
public:
escript::JMPI MPIInfo;
int numDim;
index_t* Id;
int* Tag;
std::vector<int> tagsInUse;
index_t* globalDegreesOfFreedom;
double* Coordinates;
index_t* globalNodesIndex;
escript::Distribution_ptr nodesDistribution;
escript::Distribution_ptr dofDistribution;
#ifdef ESYS_HAVE_PASO
paso::Connector_ptr degreesOfFreedomConnector;
#endif
// these are the packed versions of Id
index_t* degreesOfFreedomId;
int status;
};
//
// implementation of inline methods
//
inline index_t NodeFile::getFirstNode() const
{
return nodesDistribution->getFirstComponent();
}
inline index_t NodeFile::getLastNode() const
{
return nodesDistribution->getLastComponent();
}
inline dim_t NodeFile::getGlobalNumNodes() const
{
return nodesDistribution->getGlobalNumComponents();
}
inline const index_t* NodeFile::borrowGlobalNodesIndex() const
{
return globalNodesIndex;
}
inline dim_t NodeFile::getNumNodes() const
{
return numNodes;
}
inline dim_t NodeFile::getNumDegreesOfFreedom() const
{
return dofDistribution->getMyNumComponents();
}
inline dim_t NodeFile::getNumDegreesOfFreedomTargets() const
{
return degreesOfFreedomMapping.numTargets;
}
inline const index_t* NodeFile::borrowNodesTarget() const
{
return nodesMapping.map;
}
inline const index_t* NodeFile::borrowDegreesOfFreedomTarget() const
{
return degreesOfFreedomMapping.map;
}
inline const index_t* NodeFile::borrowTargetNodes() const
{
return nodesMapping.target;
}
inline const index_t* NodeFile::borrowTargetDegreesOfFreedom() const
{
return degreesOfFreedomMapping.target;
}
inline void NodeFile::updateTagList()
{
util::setValuesInUse(Tag, numNodes, tagsInUse, MPIInfo);
}
} // namespace dudley
#endif // __DUDLEY_NODEFILE_H__
Dudley.h
dudley::NodeFile
Definition: dudley/src/NodeFile.h:40
dudley::NodeFile::degreesOfFreedomMapping
NodeMapping degreesOfFreedomMapping
Definition: dudley/src/NodeFile.h:132
dudley::NodeFile::getGlobalNodeIDIndexRange
std::pair< index_t, index_t > getGlobalNodeIDIndexRange() const
Definition: dudley/src/NodeFile.cpp:167
dudley::NodeFile::numDim
int numDim
number of spatial dimensions
Definition: dudley/src/NodeFile.h:146
dudley::NodeFile::~NodeFile
~NodeFile()
destructor
Definition: dudley/src/NodeFile.cpp:58
dudley::NodeFile::dofDistribution
escript::Distribution_ptr dofDistribution
MPI distribution of degrees of freedom.
Definition: dudley/src/NodeFile.h:167
dudley::NodeFile::createDenseNodeLabeling
dim_t createDenseNodeLabeling(IndexVector &nodeDistribution, const IndexVector &dofDistribution)
dudley::NodeFile::globalNodesIndex
index_t * globalNodesIndex
assigns each local node a global unique ID in a dense labeling
Definition: dudley/src/NodeFile.h:161
dudley::NodeFile::degreesOfFreedomId
index_t * degreesOfFreedomId
Definition: dudley/src/NodeFile.h:173
dudley::NodeFile::borrowNodesTarget
const index_t * borrowNodesTarget() const
returns the mapping from target to the local nodes
Definition: dudley/src/NodeFile.h:219
dudley::NodeFile::setTags
void setTags(int newTag, const escript::Data &mask)
set tags to newTag where mask > 0
Definition: dudley/src/NodeFile.cpp:201
dudley::NodeFile::getNumNodes
dim_t getNumNodes() const
returns the number of FEM nodes (on this rank)
Definition: dudley/src/NodeFile.h:204
dudley::NodeFile::prepareLabeling
dim_t prepareLabeling(const std::vector< short > &mask, IndexVector &buffer, IndexVector &distribution, bool useNodes)
dudley::NodeFile::borrowTargetDegreesOfFreedom
const index_t * borrowTargetDegreesOfFreedom() const
returns the mapping from local degrees of freedom to a target
Definition: dudley/src/NodeFile.h:234
dudley::NodeFile::setCoordinates
void setCoordinates(const escript::Data &newX)
Definition: dudley/src/NodeFile.cpp:172
dudley::NodeFile::gather
void gather(const index_t *index, const NodeFile *in)
Definition: NodeFile_gather.cpp:77
dudley::NodeFile::getGlobalDOFRange
std::pair< index_t, index_t > getGlobalDOFRange() const
Definition: dudley/src/NodeFile.cpp:162
dudley::NodeFile::createDenseDOFLabeling
dim_t createDenseDOFLabeling()
Definition: NodeFile_createDenseLabelings.cpp:22
dudley::NodeFile::createNodeMappings
void createNodeMappings(const IndexVector &dofDistribution, const IndexVector &nodeDistribution)
Definition: NodeFile_createMappings.cpp:224
dudley::NodeFile::borrowGlobalNodesIndex
const index_t * borrowGlobalNodesIndex() const
Definition: dudley/src/NodeFile.h:199
dudley::NodeFile::getDOFRange
std::pair< index_t, index_t > getDOFRange() const
Definition: dudley/src/NodeFile.cpp:146
dudley::NodeFile::globalDegreesOfFreedom
index_t * globalDegreesOfFreedom
Definition: dudley/src/NodeFile.h:157
dudley::NodeFile::getNumDegreesOfFreedom
dim_t getNumDegreesOfFreedom() const
returns the number of degrees of freedom (on this rank)
Definition: dudley/src/NodeFile.h:209
dudley::NodeFile::print
void print() const
Definition: dudley/src/NodeFile.cpp:108
dudley::NodeFile::tagsInUse
std::vector< int > tagsInUse
vector of tags which are actually used
Definition: dudley/src/NodeFile.h:152
dudley::NodeFile::assignMPIRankToDOFs
void assignMPIRankToDOFs(int *mpiRankOfDOF, const IndexVector &distribution)
Definition: dudley/src/NodeFile.cpp:220
dudley::NodeFile::getGlobalNumNodes
dim_t getGlobalNumNodes() const
Definition: dudley/src/NodeFile.h:194
dudley::NodeFile::freeTable
void freeTable()
empties the node table and frees all memory
Definition: dudley/src/NodeFile.cpp:90
dudley::NodeFile::borrowTargetNodes
const index_t * borrowTargetNodes() const
returns the mapping from local nodes to a target
Definition: dudley/src/NodeFile.h:229
dudley::NodeFile::getLastNode
index_t getLastNode() const
Definition: dudley/src/NodeFile.h:189
dudley::NodeFile::numNodes
dim_t numNodes
number of nodes
Definition: dudley/src/NodeFile.h:135
dudley::NodeFile::nodesMapping
NodeMapping nodesMapping
Definition: dudley/src/NodeFile.h:131
dudley::NodeFile::status
int status
Definition: dudley/src/NodeFile.h:177
dudley::NodeFile::copyTable
void copyTable(index_t offset, index_t idOffset, index_t dofOffset, const NodeFile *in)
Definition: dudley/src/NodeFile.cpp:125
dudley::NodeFile::createDOFMappingAndCoupling
void createDOFMappingAndCoupling()
Definition: NodeFile_createMappings.cpp:29
dudley::NodeFile::MPIInfo
escript::JMPI MPIInfo
MPI information.
Definition: dudley/src/NodeFile.h:144
dudley::NodeFile::getFirstNode
index_t getFirstNode() const
Definition: dudley/src/NodeFile.h:184
dudley::NodeFile::getNumDegreesOfFreedomTargets
dim_t getNumDegreesOfFreedomTargets() const
returns the number of degrees of freedom targets (own and shared)
Definition: dudley/src/NodeFile.h:214
dudley::NodeFile::gather_global
void gather_global(const index_t *index, const NodeFile *in)
Definition: NodeFile_gather.cpp:85
dudley::NodeFile::NodeFile
NodeFile(int nDim, escript::JMPI MPIInfo)
Definition: dudley/src/NodeFile.cpp:44
dudley::NodeFile::borrowDegreesOfFreedomTarget
const index_t * borrowDegreesOfFreedomTarget() const
returns the mapping from target to the local degrees of freedom
Definition: dudley/src/NodeFile.h:224
dudley::NodeFile::allocTable
void allocTable(dim_t numNodes)
allocates the node table within this node file to hold numNodes nodes.
Definition: dudley/src/NodeFile.cpp:63
dudley::NodeFile::getGlobalIdRange
std::pair< index_t, index_t > getGlobalIdRange() const
Definition: dudley/src/NodeFile.cpp:157
dudley::NodeFile::Tag
int * Tag
Tag[i] is the tag of node i.
Definition: dudley/src/NodeFile.h:150
dudley::NodeFile::updateTagList
void updateTagList()
Definition: dudley/src/NodeFile.h:239
dudley::NodeFile::Coordinates
double * Coordinates
Coordinates[INDEX2(k,i,numDim)] is the k-th coordinate of node i.
Definition: dudley/src/NodeFile.h:159
dudley::NodeFile::nodesDistribution
escript::Distribution_ptr nodesDistribution
MPI distribution of nodes.
Definition: dudley/src/NodeFile.h:164
dudley::NodeFile::Id
index_t * Id
Id[i] is the unique ID number of FEM node i.
Definition: dudley/src/NodeFile.h:148
escript::Data
Data represents a collection of datapoints.
Definition: Data.h:64
NodeMapping.h
dudley::util::setValuesInUse
void setValuesInUse(const int *values, dim_t numValues, std::vector< int > &valuesInUse, escript::JMPI mpiinfo)
Definition: dudley/src/Util.cpp:224
dudley
A suite of factory methods for creating 2D and 3D dudley domains.
Definition: dudley/src/Assemble.h:32
escript::DataTypes::IndexVector
std::vector< index_t > IndexVector
Definition: DataTypes.h:64
escript::DataTypes::dim_t
index_t dim_t
Definition: DataTypes.h:66
escript::DataTypes::index_t
int index_t
type for array/matrix indices used both globally and on each rank
Definition: DataTypes.h:61
escript
Definition: AbstractContinuousDomain.cpp:23
escript::Distribution_ptr
boost::shared_ptr< Distribution > Distribution_ptr
Definition: Distribution.h:25
escript::JMPI
boost::shared_ptr< JMPI_ > JMPI
Definition: EsysMPI.h:74
paso::Connector_ptr
boost::shared_ptr< Connector > Connector_ptr
Definition: Coupler.h:38
dudley::NodeMapping
Definition: dudley/src/NodeMapping.h:28
dudley::NodeMapping::map
index_t * map
maps the target nodes back to the FEM nodes: target[map[i]]=i
Definition: dudley/src/NodeMapping.h:99
dudley::NodeMapping::numTargets
dim_t numTargets
size of map (number of target nodes, e.g. DOF, reduced DOF, etc.)
Definition: dudley/src/NodeMapping.h:96
dudley::NodeMapping::target
index_t * target
target[i] defines the target of FEM node i=0,...,numNodes
Definition: dudley/src/NodeMapping.h:93
escript::IndexList
Definition: escriptcore/src/IndexList.h:29